From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4001:c0b::242; helo=mail-it0-x242.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-it0-x242.google.com (mail-it0-x242.google.com [IPv6:2607:f8b0:4001:c0b::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id DDF96202E53EB for ; Thu, 28 Jun 2018 03:54:25 -0700 (PDT) Received: by mail-it0-x242.google.com with SMTP id p17-v6so6931188itc.2 for ; Thu, 28 Jun 2018 03:54:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=h2R87iWJqbHJXSP6eYibHuy9xIqgBEDSXYdc3eQQcBY=; b=jma2H7XGmqGktSMSg7sPtyhpbLNAuFxkq+ZIC21I5HkmZzxQWYXLpwUiwutPJdv7IY JxPiBwmDixnCe0I6PpbH3zC8INucF2GjhHHcziACOSmU/jirVWOj2XyKZcDS7skckpww Dg58JVMw26lE865vErmXV2aH6LyK/bWq3wQpY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=h2R87iWJqbHJXSP6eYibHuy9xIqgBEDSXYdc3eQQcBY=; b=K8umzJjE99qRvmFIwCf3lfYfe2bf5FNwFDpZL0191STabPTxeTthM0f+ODQPe06+yU bIKBfLDkywVvV97b582HS2cKZYayfFxsX14So35eJwZwU+7E8JaUst4nIq1DlT4JRvjb n8uCKKbZAZ282FzVMTIXU6eFs+y8p7+bQWWqfFwMW3Bb7gE+lrhi7rzIlkM7zbeOI2YQ kP0E/ke+qtDGUDvOBrqGHEHeQBtFXPhb+YW8hABbqdAaZTS+83H9ZtmdfqcTL8vaHA25 z+dZsRJjUm8LQJMHXDOeLKNciU8/kOHp/4JlEKgXddG+OBAQBKrgFAlrIDnDAWSg2jzX ODXQ== X-Gm-Message-State: APt69E1oEzx4+hsivkveV50OIr3hsm6rbkPjca35To7yxg1IL9gXXxzi 4EV8DkzFK6yQkPNERmizKGuR9tcWeG2/GaalS/DSmQ== X-Google-Smtp-Source: AAOMgpf9bOG/YDB7w97ely6yF/8cM8MTlKMC3qk/BGCC46pzvjSNlej5fTPjz+yvr6kf01msHt3yotjinjmDf3yauDI= X-Received: by 2002:a02:4187:: with SMTP id n7-v6mr8216705jad.86.1530183264555; Thu, 28 Jun 2018 03:54:24 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:bbc7:0:0:0:0:0 with HTTP; Thu, 28 Jun 2018 03:54:24 -0700 (PDT) In-Reply-To: References: <20180627070443.42886-1-ming.huang@linaro.org> <20180627070443.42886-5-ming.huang@linaro.org> From: Ard Biesheuvel Date: Thu, 28 Jun 2018 12:54:24 +0200 Message-ID: To: Ming Cc: Leif Lindholm , linaro-uefi , "edk2-devel@lists.01.org" , Graeme Gregory , guoheyi@huawei.com, wanghuiqiang , huangming , Jason Zhang , huangdaode@hisilicon.com, John Garry , Heyi Guo Subject: Re: [PATCH edk2-platforms v1 4/6] Hisilicon/D05: Add PlatformMiscDxe driver X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jun 2018 10:54:26 -0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On 28 June 2018 at 04:26, Ming wrote: > > > =E5=9C=A8 2018/6/27 15:33, Ard Biesheuvel =E5=86=99=E9=81=93: >> On 27 June 2018 at 09:04, Ming Huang wrote: >>> Fix the issue of onboard Nic not work kerenl with AMD GPU and >>> NVME SSD in board. The GPU don't support 64 MSI, so need to >>> allocate INTx, but the default interrupt number 255 is invalid, >>> so Change all the PCI Device interrupt number to 0. >>> >> >> Could you please try to explain in more detail what the problem is you >> are solving, and why you think it should be solved in the firmware? >> What does '64 MSI' mean? And where does the default of 255 come from? >> >> > > With AMD GPU and NVMe in board, the onboard Nic(hns-nic) can not work in = ubuntu os. > The AMD GPU has two devices: > PCI device amdgpu 000d:33:00.0, snd_hda_intel 000d:33:00.1 > The MSI is 64bit address in D05, and snd_hda_intel don't support 64bit MS= I address, Legacy PCIe endpoints are permitted to only implement support for 32-bit addressing of the MSI doorbell register, which is why it is generally a good idea to put that below 4 GB in the physical address space. So how is this implemented on D05? How are the PCIe host bridge inbound windows configured? Any chance you could fix this by remapping inbound transactions so the MSI doorbell appears at a 32-bit addressable offset? > so snd_hda_intel use the 255 irq. The onboard Nic register 255 irq failed= . > The 255 is the default value of PCI_INTERRUPT_LINE reg (0x3C). > There is not a proper solution in kernel.This patch is a workaround in fi= rmware. > > error log in kernel: > Mar 1 00:27:07 ubuntu kernel: [ 25.581265] snd_hda_intel 000d:33:00.1= : Device has broken 64-bit MSI but arch tried to assign one above 4Gl > > Mar 1 00:36:39 ubuntu kernel: [ 600.751276] genirq: Flags mismatch irq = 255. 00000001 (enahisic2i0-tx1) vs. 00000081 (snd_hda_intel:card0) > > Mar 1 00:36:39 ubuntu kernel: [ 600.761137] hns-nic HISI00C2:00 enahisi= c2i0: request irq(255) fail > > Thanks. > >> >>> Contributed-under: TianoCore Contribution Agreement 1.1 >>> Signed-off-by: Ming Huang >>> Signed-off-by: Heyi Guo >>> --- >>> Platform/Hisilicon/D05/D05.dsc | = 1 + >>> Platform/Hisilicon/D05/D05.fdf | = 1 + >>> Platform/Hisilicon/D05/Drivers/PlatformMiscDxe/PlatformMiscDxe.c | 9= 9 ++++++++++++++++++++ >>> Platform/Hisilicon/D05/Drivers/PlatformMiscDxe/PlatformMiscDxe.inf | 4= 7 ++++++++++ >>> 4 files changed, 148 insertions(+) >>> >>> diff --git a/Platform/Hisilicon/D05/D05.dsc b/Platform/Hisilicon/D05/D0= 5.dsc >>> index b6e1a9d98a..0e6d5912a0 100644 >>> --- a/Platform/Hisilicon/D05/D05.dsc >>> +++ b/Platform/Hisilicon/D05/D05.dsc >>> @@ -629,6 +629,7 @@ >>> >>> >>> Silicon/Hisilicon/Drivers/Smbios/ProcessorSubClassDxe/ProcessorSubCl= assDxe.inf >>> + Platform/Hisilicon/D05/Drivers/PlatformMiscDxe/PlatformMiscDxe.inf >>> >>> # >>> # Memory test >>> diff --git a/Platform/Hisilicon/D05/D05.fdf b/Platform/Hisilicon/D05/D0= 5.fdf >>> index 37d9cc0c18..32374e245e 100644 >>> --- a/Platform/Hisilicon/D05/D05.fdf >>> +++ b/Platform/Hisilicon/D05/D05.fdf >>> @@ -358,6 +358,7 @@ READ_LOCK_STATUS =3D TRUE >>> INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf >>> INF IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.i= nf >>> INF Platform/Hisilicon/D05/EarlyConfigPeim/EarlyConfigPeimD05.inf >>> + INF Platform/Hisilicon/D05/Drivers/PlatformMiscDxe/PlatformMiscDxe.i= nf >>> >>> INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf >>> >>> diff --git a/Platform/Hisilicon/D05/Drivers/PlatformMiscDxe/PlatformMis= cDxe.c b/Platform/Hisilicon/D05/Drivers/PlatformMiscDxe/PlatformMiscDxe.c >>> new file mode 100644 >>> index 0000000000..8519b7139d >>> --- /dev/null >>> +++ b/Platform/Hisilicon/D05/Drivers/PlatformMiscDxe/PlatformMiscDxe.c >>> @@ -0,0 +1,99 @@ >>> +/** @file >>> +* >>> +* Copyright (c) 2018, Hisilicon Limited. All rights reserved. >>> +* Copyright (c) 2016, Linaro Limited. All rights reserved. >>> +* >>> +* This program and the accompanying materials >>> +* are licensed and made available under the terms and conditions of t= he BSD License >>> +* which accompanies this distribution. The full text of the license = may be found at >>> +* http://opensource.org/licenses/bsd-license.php >>> +* >>> +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASI= S, >>> +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS O= R IMPLIED. >>> +* >>> +**/ >>> + >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> + >>> +VOID >>> +SetIntLine ( >>> + ) >>> +{ >>> + EFI_STATUS Status; >>> + UINTN HandleIndex; >>> + EFI_HANDLE *HandleBuffer; >>> + UINTN HandleCount; >>> + EFI_PCI_IO_PROTOCOL *PciIo; >>> + UINT8 INTLine; >>> + UINTN Segment; >>> + UINTN Bus; >>> + UINTN Device; >>> + UINTN Fun; >>> + >>> + Status =3D gBS->LocateHandleBuffer ( >>> + ByProtocol, >>> + &gEfiPciIoProtocolGuid, >>> + NULL, >>> + &HandleCount, >>> + &HandleBuffer >>> + ); >>> + if (EFI_ERROR (Status)) { >>> + DEBUG ((DEBUG_ERROR, " Locate gEfiPciIoProtocol Failed.\n")); >>> + gBS->FreePool ((VOID *)HandleBuffer); >>> + return; >>> + } >>> + >>> + for (HandleIndex =3D 0; HandleIndex < HandleCount; HandleIndex++) { >>> + Status =3D gBS->HandleProtocol ( >>> + HandleBuffer[HandleIndex], >>> + &gEfiPciIoProtocolGuid, >>> + (VOID **)&PciIo >>> + ); >>> + if (EFI_ERROR (Status)) { >>> + continue; >>> + } >>> + >>> + INTLine =3D 0; >>> + (VOID)PciIo->Pci.Write ( >>> + PciIo, >>> + EfiPciIoWidthUint8, >>> + PCI_INT_LINE_OFFSET, >>> + 1, >>> + &INTLine); >>> + (VOID)PciIo->GetLocation (PciIo, &Segment, &Bus, &Device, &Fun); >>> + DEBUG ((DEBUG_INFO, "Set BDF(%x-%x-%x) IntLine to 0\n", Bus, Dev= ice, Fun)); >>> + } >>> + >>> + gBS->FreePool ((VOID *)HandleBuffer); >>> + return; >>> +} >>> + >>> +EFI_STATUS >>> +EFIAPI >>> +PlatformMiscDxeEntry ( >>> + IN EFI_HANDLE ImageHandle, >>> + IN EFI_SYSTEM_TABLE *SystemTable >>> + ) >>> +{ >>> + EFI_STATUS Status; >>> + EFI_EVENT Event; >>> + >>> + Status =3D gBS->CreateEventEx ( >>> + EVT_NOTIFY_SIGNAL, >>> + TPL_CALLBACK, >>> + SetIntLine, >>> + NULL, >>> + &gEfiEventReadyToBootGuid, >>> + &Event >>> + ); >>> + if (EFI_ERROR (Status)) { >>> + DEBUG ((DEBUG_ERROR, "Create event for SetIntLine, %r!\n", Status)= ); >>> + } >>> + >>> + return EFI_SUCCESS; >>> +} >>> + >>> diff --git a/Platform/Hisilicon/D05/Drivers/PlatformMiscDxe/PlatformMis= cDxe.inf b/Platform/Hisilicon/D05/Drivers/PlatformMiscDxe/PlatformMiscDxe.i= nf >>> new file mode 100644 >>> index 0000000000..0b365e7a53 >>> --- /dev/null >>> +++ b/Platform/Hisilicon/D05/Drivers/PlatformMiscDxe/PlatformMiscDxe.in= f >>> @@ -0,0 +1,47 @@ >>> +#/** @file >>> +# >>> +# Copyright (c) 2018, Hisilicon Limited. All rights reserved. >>> +# Copyright (c) 2016, Linaro Limited. All rights reserved. >>> +# >>> +# This program and the accompanying materials >>> +# are licensed and made available under the terms and conditions of= the BSD License >>> +# which accompanies this distribution. The full text of the license= may be found at >>> +# http://opensource.org/licenses/bsd-license.php >>> +# >>> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BA= SIS, >>> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS= OR IMPLIED. >>> +# >>> +#**/ >>> + >>> +[Defines] >>> + INF_VERSION =3D 0x0001001A >>> + BASE_NAME =3D PlatformMiscDxe >>> + FILE_GUID =3D a48f7a09-253f-468b-87c6-caf78baf4= 7bb >>> + MODULE_TYPE =3D DXE_DRIVER >>> + VERSION_STRING =3D 1.0 >>> + ENTRY_POINT =3D PlatformMiscDxeEntry >>> + >>> +[Sources.common] >>> + PlatformMiscDxe.c >>> + >>> +[Packages] >>> + MdeModulePkg/MdeModulePkg.dec >>> + MdePkg/MdePkg.dec >>> + Silicon/Hisilicon/HisiPkg.dec >>> + >>> +[Guids] >>> + gEfiEventReadyToBootGuid >>> + >>> +[Protocols] >>> + gEfiPciIoProtocolGuid >>> + >>> +[LibraryClasses] >>> + BaseLib >>> + DebugLib >>> + UefiBootServicesTableLib >>> + UefiDriverEntryPoint >>> + >>> +[FixedPcd] >>> + >>> +[Depex] >>> + TRUE >>> -- >>> 2.17.0 >>>