From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f195.google.com (mail-qt1-f195.google.com [209.85.160.195]) by mx.groups.io with SMTP id smtpd.web11.9195.1591358082453677154 for ; Fri, 05 Jun 2020 04:54:42 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@semihalf-com.20150623.gappssmtp.com header.s=20150623 header.b=bp92VD7n; spf=none, err=SPF record not found (domain: semihalf.com, ip: 209.85.160.195, mailfrom: mw@semihalf.com) Received: by mail-qt1-f195.google.com with SMTP id c12so8127879qtq.11 for ; Fri, 05 Jun 2020 04:54:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=2NeVeau+juwbxISSoM5cuvsgITH1WovXoU77PiPA2c4=; b=bp92VD7nQBjRCtPsbVlnrlmCqZpcD+KO4If/yl9yLnjvygMme5yKujzp19oXfF/1mA pDMvkU1y2Fa3QFId0+NrbAwpMx8uQ2/xKJwwsVsItvQqUr77PrTmZXbeg+5nr3V8kl+q vbK9Tiv9vjP1FjM+6s1G8ekNJAcvaaUL/8rtz9OWyc0ZhyZ8k4/5e+MTef0NnocyFsiK 4T5cwHibRkMV7W4ZaadLaro+ekgUve8ha7zVR88MD3wcNqZL1eZpFiucoy/TRpM7cflD RnxcjwCtPybLJaVoHSTYWyYAasOIqBTyjY4zwsU+7cZ5ZvKsUy5Lw3YRA6vpGAJQ4X6O lAuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=2NeVeau+juwbxISSoM5cuvsgITH1WovXoU77PiPA2c4=; b=eEjBuxgID38XKH5L6plMSHkTdRhO6654duemQeEYX0RePuSbe3xQRmrRHdnSE1/lTQ ba3f8uhSwOv1twCG3td9RBw11kjhVDS4M6B7lZIzwNOCObmpC2qbjvAIJaqmZznMVSxc VA89kphU9DOXb7YkFxVQ3Rh5itP1JkX1FJx2ThAGL6sCrPYc5qf/OVo6mUOat4V1DZnD wxMBJmorCI8Kx0BoIgVOVfp1qxA2rWFIb25cVX35CSKrTZvZVKBuMfuqjo+DhomqFHtu 3OH7YEXyko72vr3yh/JvTa55WLNCf76DkCa5GFfLEinlSoAT1fXCfLHYHqd3OXLgql9S h9gQ== X-Gm-Message-State: AOAM531HxXnHz8lBUpiHMkcQ50JdlSdOy8l+aEFEc+KC5z8H2U508xHq RK5xG0cQMVHArySVSzztCmMsovojQ9IL8puo0LrHZQ== X-Google-Smtp-Source: ABdhPJyKLMr8aPHIbTABVR852HVXOrqODuZ1wyW+cszev7ePtkb0sNoOKVYYIvjTgZ3qzkn5tgSeqiQr5BCuBJ6lOiE= X-Received: by 2002:ac8:42c3:: with SMTP id g3mr9238735qtm.313.1591358081454; Fri, 05 Jun 2020 04:54:41 -0700 (PDT) MIME-Version: 1.0 References: <20200604213544.279976-1-ard.biesheuvel@arm.com> In-Reply-To: <20200604213544.279976-1-ard.biesheuvel@arm.com> From: "Marcin Wojtas" Date: Fri, 5 Jun 2020 13:54:30 +0200 Message-ID: Subject: Re: [RFT PATCH edk2-platforms] Silicon/Marvell/MvI2cDxe: connect all I2C masters at EndOfDxe To: Ard Biesheuvel Cc: edk2-devel-groups-io , Leif Lindholm Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Ard, czw., 4 cze 2020 o 23:35 Ard Biesheuvel napisa=C5= =82(a): > > To ensure that platforms incorporating MvI2cDxe will keep working > as intended once the platform BDS code stops calling ConnectAll(), > connect the I2C masters explicitly at EndOfDxe. > > Signed-off-by: Ard Biesheuvel > --- > Build tested only. > > Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.inf | 3 ++ > Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.h | 1 + > Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.c | 54 +++++++++++++++++= +-- > 3 files changed, 55 insertions(+), 3 deletions(-) > > diff --git a/Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.inf b/Silicon/= Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.inf > index e59fee0ac1b5..f631fbe797fc 100755 > --- a/Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.inf > +++ b/Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.inf > @@ -45,5 +45,8 @@ [Pcd] > gMarvellTokenSpaceGuid.PcdI2cBaudRate > gMarvellTokenSpaceGuid.PcdI2cBusCount > > +[Guids] > + gEfiEndOfDxeEventGroupGuid > + > [Depex] > TRUE > diff --git a/Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.h b/Silicon/Ma= rvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.h > index f5c2cdd8ab3a..6caaa45cece0 100644 > --- a/Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.h > +++ b/Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.h > @@ -80,6 +80,7 @@ typedef struct { > > typedef struct { > VENDOR_DEVICE_PATH Guid; > + UINTN Instance; > EFI_DEVICE_PATH_PROTOCOL End; > } MV_I2C_DEVICE_PATH; > > diff --git a/Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.c b/Silicon/Ma= rvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.c > index b13ab8f02c99..dfe8da9891a5 100755 > --- a/Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.c > +++ b/Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.c > @@ -30,12 +30,13 @@ STATIC MV_I2C_DEVICE_PATH MvI2cDevicePathProtocol =3D= { > HARDWARE_DEVICE_PATH, > HW_VENDOR_DP, > { > - (UINT8) (sizeof(VENDOR_DEVICE_PATH)), > - (UINT8) (sizeof(VENDOR_DEVICE_PATH) >> 8), > + (UINT8) (OFFSET_OF (MV_I2C_DEVICE_PATH, End)), > + (UINT8) (OFFSET_OF (MV_I2C_DEVICE_PATH, End) >> 8), > }, > }, > EFI_CALLER_ID_GUID > }, > + 0, // Instance > { > END_DEVICE_PATH_TYPE, > END_ENTIRE_DEVICE_PATH_SUBTYPE, > @@ -86,7 +87,7 @@ MvI2cInitialiseController ( > DEBUG((DEBUG_ERROR, "MvI2cDxe: I2C device path allocation failed\n")= ); > return EFI_OUT_OF_RESOURCES; > } > - DevicePath->Guid.Guid.Data4[0] =3D Bus; > + DevicePath->Instance =3D Bus; > > /* if attachment succeeds, this gets freed at ExitBootServices */ > I2cMasterContext =3D AllocateZeroPool (sizeof (I2C_MASTER_CONTEXT)); > @@ -139,6 +140,47 @@ MvI2cInitialiseController ( > return Status; > } > > +STATIC > +VOID > +EFIAPI > +OnEndOfDxe ( > + IN EFI_EVENT Event, > + IN VOID *Context > + ) > +{ > + MV_I2C_DEVICE_PATH *DevicePath; > + EFI_DEVICE_PATH_PROTOCOL *DevicePathPointer; > + EFI_HANDLE DeviceHandle; > + EFI_STATUS Status; > + > + gBS->CloseEvent (Event); > + > + DevicePath =3D AllocateCopyPool (sizeof (MvI2cDevicePathProtocol), > + &MvI2cDevicePathProtocol); > + if (DevicePath =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "MvI2cDxe: I2C device path allocation failed\n"= )); > + return; > + } > + > + do { > + DevicePathPointer =3D (EFI_DEVICE_PATH_PROTOCOL *)DevicePath; > + Status =3D gBS->LocateDevicePath (&gEfiI2cMasterProtocolGuid, > + &DevicePathPointer, &DeviceHandle); > + if (EFI_ERROR (Status)) { > + break; > + } > + > + Status =3D gBS->ConnectController (DeviceHandle, NULL, NULL, TRUE); > + DEBUG ((DEBUG_INFO, "%a: ConnectController () returned %r\n", > + __FUNCTION__, Status)); > + > + DevicePath->Instance++; > + } while (TRUE); > + > + gBS->FreePool (DevicePath); > +} > + > + > EFI_STATUS > EFIAPI > MvI2cInitialise ( > @@ -150,6 +192,8 @@ MvI2cInitialise ( > MV_BOARD_I2C_DESC *Desc; > EFI_STATUS Status; > UINTN Index; > + EFI_EVENT EndOfDxeEvent; > + > > /* Obtain list of available controllers */ > Status =3D gBS->LocateProtocol (&gMarvellBoardDescProtocolGuid, > @@ -177,6 +221,10 @@ MvI2cInitialise ( > > BoardDescProtocol->BoardDescFree (Desc); > > + Status =3D gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_CALLBACK, OnEndO= fDxe, > + NULL, &gEfiEndOfDxeEventGroupGuid, &EndOfDxeEvent); > + ASSERT_EFI_ERROR (Status); > + > return EFI_SUCCESS; > } > > -- > 2.26.2 > This change works as planned, so you can add my: Tested-by: Marcin Wojtas I pushed this patch with slightly improved style to: https://github.com/Semihalf/edk2-platforms/commits/i2c-end-of-dxe Best regards, Marcin