From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@akeo-ie.20150623.gappssmtp.com header.s=20150623 header.b=CWwX2xeC; spf=none, err=permanent DNS error (domain: akeo.ie, ip: 209.85.128.67, mailfrom: pete@akeo.ie) Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by groups.io with SMTP; Thu, 29 Aug 2019 08:27:03 -0700 Received: by mail-wm1-f67.google.com with SMTP id t9so4283392wmi.5 for ; Thu, 29 Aug 2019 08:27:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akeo-ie.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=dbsbbbWky4qInXof/QuhbOBmWJIs0c7KGEc84TobRQA=; b=CWwX2xeCpQrOQW06/Iws0+sIRnr61l7ne1v6Rzu0wKDGI6zXYmSfuU7USCryrih0PX 7L85osXa+RR3rnH3VQCPAbmvAYtqYL4woQ+yVIcIKmTiGf1H4darVRDKL3F/+e+K/G3P 7bfJDWz6AaGj+8oG3w5IhJtPZcMIIvNUaH9E86ioJ6ul0sc/p7QqOyyQCb9/GMnU+944 WHF5ORd1PT9Q8Jonx6UeM/qdP3eF8Qh7Fj1hfoTKaUFQaGgDS2dfv/SH65+w3KG1OK4P UGiA0yJN0lCunOJUNza/IOYcGcVzT7nXh8J1hB+16eA9JHY2xtHWXmbg3H1G4ROenLPk 4MsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=dbsbbbWky4qInXof/QuhbOBmWJIs0c7KGEc84TobRQA=; b=SBoZ2zOGx4nKFig3NUk2Sv/v5sjAGD9xoKeVF8IeGQeCkEFLc74fnCLVPb3xcDuABV 1Z4pruEfAfiOysa7b3srnczTu02OvA7dP94iIKt1AztENs4NCNn1wD/gneWaXNauALN6 8ojFg+8VRvqo2H//TgQNwEnGq98c56TAzEU4zyXuIfeUKOrprjg4Wl/yqcPz5UzRwvtw I7fnyNknvjn21inBLKdIwqsTbevL6k0PouS1nouOadQ5LsaWasoYFtu56VIf++gthOIW 7o8u/vWCsAff0ggbVn9QQoKd6freVn98meJoyu3txNiTmgHysTrq6xlx4jYkWEwn2bv7 pzCQ== X-Gm-Message-State: APjAAAULO/1SXEkjf/B+lQtRrD1Oz38jTPlE4xCGmloUdHP8bH6Jx416 AhoqVNLHoM3JNozp1rW0tF2Vmg== X-Google-Smtp-Source: APXvYqzVtQHAGLrYcDBzo9l8/uJM+Z2XVDqFpNmkja/uKx1oXJPreJw/wshWOlWDX8xQhaDZIjs8AA== X-Received: by 2002:a1c:7606:: with SMTP id r6mr12639814wmc.78.1567092421298; Thu, 29 Aug 2019 08:27:01 -0700 (PDT) Return-Path: Received: from [10.0.0.122] ([84.203.56.193]) by smtp.googlemail.com with ESMTPSA id o9sm3553597wrj.17.2019.08.29.08.26.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Aug 2019 08:26:59 -0700 (PDT) Subject: Re: [edk2-platforms: PATCH v2 1/1] Platform/Rpi3: Add compatible property to the "usb" Device Tree node To: Leif Lindholm Cc: devel@edk2.groups.io, ard.biesheuvel@linaro.org References: <20190823122050.5244-1-pete@akeo.ie> <20190823122050.5244-2-pete@akeo.ie> <20190829135459.GS29255@bivouac.eciton.net> From: "Pete Batard" Message-ID: <981c8b57-1be1-0cab-7019-969ce4c6fa9a@akeo.ie> Date: Thu, 29 Aug 2019 16:26:58 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190829135459.GS29255@bivouac.eciton.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Hi Leif, On 2019.08.29 14:54, Leif Lindholm wrote: > On Fri, Aug 23, 2019 at 01:20:50PM +0100, Pete Batard wrote: >> Some Linux kernels (e.g. Debian) require "bcm,bcm2835-usb" to be present in > > Is the typo here or in the code? ('bcm,' vs. 'brcm,') Sorry, should have been 'brcm,bcm2835-usb' above. As mentioned in the cover letter, we're basically adding to the compatible string list so that: compatible = "brcm,bcm2708-usb"; becomes: compatible = "brcm,bcm2708-usb", "brcm,bcm2835-usb"; So the part before the comma should always be "brcm", and it's only the part after that should be "bcm" (which, alas, makes it easy to introduce typos). In other words, the typo is in the commit message only. I did validate the changes proposed by this patch on real hardware, so I can vouch for the code being correct, insofar as the compatible strings there are concerned. > If here, I can fix up on committing. If you can fix the typo in the commit message, that would be great. Regards, /Pete > > / > Leif > >> the list of compatible properties for the "usb" node, else they are unable >> to handle some USB devices. >> >> This patch ensures that the compatible property is added if not present. >> >> Signed-off-by: Pete Batard >> --- >> Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c | 75 ++++++++++++++++++++ >> 1 file changed, 75 insertions(+) >> >> diff --git a/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c b/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c >> index 45ffe2e394a2..eb8048930c30 100644 >> --- a/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c >> +++ b/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c >> @@ -135,6 +135,76 @@ UpdateMacAddress ( >> return EFI_SUCCESS; >> } >> >> +// >> +// Add "bcm2835-usb" to the USB compatible property list, if not present. >> +// Required because some Linux kernels can't handle USB devices otherwise. >> +// >> +STATIC >> +EFI_STATUS >> +AddUsbCompatibleProperty ( >> + VOID >> + ) >> +{ >> + CONST CHAR8 Prop[] = "brcm,bcm2708-usb"; >> + CONST CHAR8 NewProp[] = "brcm,bcm2835-usb"; >> + CONST CHAR8 *List; >> + CHAR8 *NewList; >> + INT32 ListSize; >> + INTN Node; >> + INTN Retval; >> + >> + // Locate the node that the 'usb' alias refers to >> + Node = fdt_path_offset (mFdtImage, "usb"); >> + if (Node < 0) { >> + DEBUG ((DEBUG_ERROR, "%a: failed to locate 'usb' alias\n", __FUNCTION__)); >> + return EFI_NOT_FOUND; >> + } >> + >> + // Get the property list. This is a list of NUL terminated strings. >> + List = fdt_getprop (mFdtImage, Node, "compatible", &ListSize); >> + if (List == NULL) { >> + DEBUG ((DEBUG_ERROR, "%a: failed to locate properties\n", __FUNCTION__)); >> + return EFI_NOT_FOUND; >> + } >> + >> + // Check if the compatible value we plan to add is already present >> + if (fdt_stringlist_contains (List, ListSize, NewProp)) { >> + DEBUG ((DEBUG_INFO, "%a: property '%a' is already set.\n", >> + __FUNCTION__, NewProp)); >> + return EFI_SUCCESS; >> + } >> + >> + // Make sure the compatible device is what we expect >> + if (!fdt_stringlist_contains (List, ListSize, Prop)) { >> + DEBUG ((DEBUG_ERROR, "%a: property '%a' is missing!\n", >> + __FUNCTION__, Prop)); >> + return EFI_NOT_FOUND; >> + } >> + >> + // Add the new NUL terminated entry to our list >> + DEBUG ((DEBUG_INFO, "%a: adding '%a' to the properties\n", >> + __FUNCTION__, NewProp)); >> + >> + NewList = AllocatePool (ListSize + sizeof (NewProp)); >> + if (NewList == NULL) { >> + DEBUG ((DEBUG_ERROR, "%a: failed to allocate memory\n", __FUNCTION__)); >> + return EFI_OUT_OF_RESOURCES;; >> + } >> + CopyMem (NewList, List, ListSize); >> + CopyMem (&NewList[ListSize], NewProp, sizeof (NewProp)); >> + >> + Retval = fdt_setprop (mFdtImage, Node, "compatible", NewList, >> + ListSize + sizeof (NewProp)); >> + FreePool (NewList); >> + if (Retval != 0) { >> + DEBUG ((DEBUG_ERROR, "%a: failed to update properties (%d)\n", >> + __FUNCTION__, Retval)); >> + return EFI_NOT_FOUND; >> + } >> + >> + return EFI_SUCCESS; >> +} >> + >> STATIC >> EFI_STATUS >> CleanMemoryNodes ( >> @@ -486,6 +556,11 @@ FdtDxeInitialize ( >> Print (L"Failed to update MAC address: %r\n", Status); >> } >> >> + Status = AddUsbCompatibleProperty (); >> + if (EFI_ERROR (Status)) { >> + Print (L"Failed to update USB compatible properties: %r\n", Status); >> + } >> + >> if (Internal) { >> /* >> * A GPU-provided DTB already has the full command line. >> -- >> 2.21.0.windows.1 >>