From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@semihalf-com.20150623.gappssmtp.com header.s=20150623 header.b=LwgUNKeZ; spf=none, err=SPF record not found (domain: semihalf.com, ip: 209.85.167.65, mailfrom: mw@semihalf.com) Received: from mail-lf1-f65.google.com (mail-lf1-f65.google.com [209.85.167.65]) by groups.io with SMTP; Sun, 06 Oct 2019 17:02:47 -0700 Received: by mail-lf1-f65.google.com with SMTP id r2so7948074lfn.8 for ; Sun, 06 Oct 2019 17:02:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=gV1kh46cMju4O34CvyngR1WnkGbIrkplCZxm4Qw2by4=; b=LwgUNKeZKbrsF4ACoSdfO8DFL0zk8jDfGxG7KVYPIApM2RtISX1nEco+0+EtjS64Jn 4LKnIjNG2DYtph3IyZPF93QBgc7MBQ36LAShlUJFGjMU80BXatb7Exf+dhcwUjW88B+Q kIcZV6/Dem63Xk0PMN0qai0FWgPs0KqLDFL2DcifOnCk9Wgy3024ma4TLwYq21a96NMf tI8Z5Sx1dA/6CnIUOiZfx+X8dUVSkPn21rVvcKCBhAvF0foUtwuDBwe/3OpFjVIBRybr LFGFTuK3vTMzpQStph2FxNiywt/NaNC6uFL8idWErYXOO5BBd/p58p1pw4RQnBVup+0L ZBJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=gV1kh46cMju4O34CvyngR1WnkGbIrkplCZxm4Qw2by4=; b=T29AEOoo6XmBI6qdEuFzVQXgHbAzLHdlXp/MoEzQIGLvYg0Zf6j1VhkXAstQHpr2BV hF6k4NZa9MCOfq3qk4Y1A5oYtC3iI85joV7sgKsB0gAYPltQWxADDUcoajlJviwig57/ qUfO9M+gLJVE5T19O+Rcp8FjvpcaO/sqxz5J0TVriz2FYdoo7RM503URLaTVdv38bM7g ncVhoINv86Rx/T1Q9MHAb5dMxjq7BpNQsNMYLtbdGFiTFq2A9S7KYEQk+t5SzuBsAyNm DF6BbNYr8394dTCJSjlHC5ySPK8PcJ8S8a1QpILHPlEUUKqol1bPfw6HvL4KX/MVpN9c fSJQ== X-Gm-Message-State: APjAAAVVj5qS6dvukETcRWPJnyG5B5P7KpOdiYpHaRKIuQWjrSZ6BxVt mY4AeBe3h2pZED5fxe9DlV930eo++F5OIA== X-Google-Smtp-Source: APXvYqyVvGu9AI41n3xnJa1bEuJRNQIxv9fg2a9PccV3oozGlyV1VVUgQRwZG005fgUE6FxTRqrTOw== X-Received: by 2002:a19:4bd7:: with SMTP id y206mr15354533lfa.9.1570406564525; Sun, 06 Oct 2019 17:02:44 -0700 (PDT) Return-Path: Received: from gilgamesh.semihalf.com (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id m6sm2755149ljj.3.2019.10.06.17.02.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 06 Oct 2019 17:02:43 -0700 (PDT) From: "Marcin Wojtas" To: devel@edk2.groups.io Cc: leif.lindholm@linaro.org, ard.biesheuvel@linaro.org, mw@semihalf.com, jsd@semihalf.com, jaz@semihalf.com Subject: [edk2-platforms: PATCH] Marvell/Drivers: MvPhyDxe: Execute proper initialization callback Date: Mon, 7 Oct 2019 02:02:26 +0200 Message-Id: <1570406546-15715-1-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 Hitherto code was executing by mistake the first possible initialization routine (valid for 88E1512 PHY), regardless the setting in gMarvellTokenSpaceGuid.PcdPhyDeviceIds. Fix this. Signed-off-by: Marcin Wojtas --- Silicon/Marvell/Drivers/Net/MvPhyDxe/MvPhyDxe.h | 3 ++- Silicon/Marvell/Drivers/Net/MvPhyDxe/MvPhyDxe.c | 28 +++++++++----------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/Silicon/Marvell/Drivers/Net/MvPhyDxe/MvPhyDxe.h b/Silicon/Marvell/Drivers/Net/MvPhyDxe/MvPhyDxe.h index 908b768..4d8aacf 100644 --- a/Silicon/Marvell/Drivers/Net/MvPhyDxe/MvPhyDxe.h +++ b/Silicon/Marvell/Drivers/Net/MvPhyDxe/MvPhyDxe.h @@ -49,7 +49,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent typedef enum { MV_PHY_DEVICE_1512, - MV_PHY_DEVICE_1112 + MV_PHY_DEVICE_1112, + MV_PHY_DEVICE_ID_MAX } MV_PHY_DEVICE_ID; typedef diff --git a/Silicon/Marvell/Drivers/Net/MvPhyDxe/MvPhyDxe.c b/Silicon/Marvell/Drivers/Net/MvPhyDxe/MvPhyDxe.c index 2d2aad7..6e4a715 100644 --- a/Silicon/Marvell/Drivers/Net/MvPhyDxe/MvPhyDxe.c +++ b/Silicon/Marvell/Drivers/Net/MvPhyDxe/MvPhyDxe.c @@ -396,7 +396,7 @@ MvPhyInit ( PHY_DEVICE *PhyDev; UINT8 *DeviceIds; UINT8 MdioIndex; - INTN i; + UINT8 PhyId; Status = gBS->LocateProtocol ( &gMarvellMdioProtocolGuid, @@ -415,6 +415,17 @@ MvPhyInit ( return EFI_INVALID_PARAMETER; } + DeviceIds = PcdGetPtr (PcdPhyDeviceIds); + PhyId = DeviceIds[PhyIndex]; + if (PhyId >= MV_PHY_DEVICE_ID_MAX) { + DEBUG ((DEBUG_ERROR, + "%a, Incorrect PHY ID (0x%x) for PHY#%d\n", + __FUNCTION__, + PhyId, + PhyIndex)); + return EFI_INVALID_PARAMETER; + } + /* perform setup common for all PHYs */ PhyDev = AllocateZeroPool (sizeof (PHY_DEVICE)); PhyDev->Addr = PhySmiAddresses[PhyIndex]; @@ -427,20 +438,7 @@ MvPhyInit ( PhyConnection)); *OutPhyDev = PhyDev; - DeviceIds = PcdGetPtr (PcdPhyDeviceIds); - for (i = 0; i < PcdGetSize (PcdPhyDeviceIds); i++) { - /* find MvPhyDevices fitting entry */ - if (MvPhyDevices[i].DevId == DeviceIds[i]) { - ASSERT (MvPhyDevices[i].DevInit != NULL); - /* proceed with PHY-specific initialization */ - return MvPhyDevices[i].DevInit (Snp, PhyDev); - } - } - - /* if we are here, no matching DevId was found */ - Status = EFI_INVALID_PARAMETER; - FreePool (PhyDev); - return Status; + return MvPhyDevices[PhyId].DevInit (Snp, PhyDev); } EFI_STATUS -- 2.7.4