From patchwork Wed Mar 30 09:14:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shivamurthy Shastri X-Patchwork-Id: 64654 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp2477952lbc; Wed, 30 Mar 2016 02:14:41 -0700 (PDT) X-Received: by 10.98.17.78 with SMTP id z75mr11400803pfi.40.1459329281400; Wed, 30 Mar 2016 02:14:41 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id bt1si5109871pad.191.2016.03.30.02.14.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Mar 2016 02:14:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 6A8081A1F8D; Wed, 30 Mar 2016 02:15:10 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-pa0-x236.google.com (mail-pa0-x236.google.com [IPv6:2607:f8b0:400e:c03::236]) (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 34F371A1F88 for ; Wed, 30 Mar 2016 02:15:09 -0700 (PDT) Received: by mail-pa0-x236.google.com with SMTP id fe3so35860563pab.1 for ; Wed, 30 Mar 2016 02:14:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=UA87N/dPdnd8V/C3ClPXf8+aMcN30VClwwHDEYUgoSM=; b=Jm3veGxzUoB0qdQu5/7p9CyUbIS6a/ewxndx7hUcDRowq9RKOxPdGfK7wx57uLYZct auJGKm+nfKHBzYNWdqy/Qy/yC4w7a+ljGDl/hGhrLUXMZyzgNQRT99nAEFLIlezac0zX rEdrmoeNpM52Hjbir9//BbuWG00FKta+Ljt5Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=UA87N/dPdnd8V/C3ClPXf8+aMcN30VClwwHDEYUgoSM=; b=ERepR3qlqb94QQN4ziiPxnDxu9onQ7892hvLnY2Kxzu7TbtzFDvd8pDRMwjeJkHJo2 vaRTDaCZj9Gszyj7ZjJ9TrPr0kUjXBe5d3oxL07dk3Nz3uyorPKSgVMV1gpq6JXgSHHo ndtYrjmCcgkLTRtX5CGS2xLnB0NfthA2yawGlHP/u6m9mEkIdQ2rpI/XKfFCEJXeBaxm PM7AWTKYPQTP5k0r3exmoIBE04L5fyG5kE1apkbPNS+HkgESy9Q0T8s9gCWdUxgMixav Bli1pBVruVd1yoKSpK4MG6rUf2IwGFtE8yTOIVstU1jxLSxx/MaeKJ89CAj5siEnvU2h Nwmw== X-Gm-Message-State: AD7BkJIHVJxKXPJm/LmwXS7zIcN40v4Q4V3bXXDMIGgK6c9SeeCqindBurKu1qOoujR6YI9b X-Received: by 10.66.246.165 with SMTP id xx5mr11249838pac.87.1459329279216; Wed, 30 Mar 2016 02:14:39 -0700 (PDT) Received: from localhost.localdomain ([106.51.27.234]) by smtp.gmail.com with ESMTPSA id tn5sm4173587pac.32.2016.03.30.02.14.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 30 Mar 2016 02:14:38 -0700 (PDT) From: Shivamurthy Shastri To: ruiyu.ni@intel.com Date: Wed, 30 Mar 2016 14:44:14 +0530 Message-Id: <1459329254-1551-1-git-send-email-shivamurthy.shastri@linaro.org> X-Mailer: git-send-email 1.9.1 Subject: [edk2] [PATCH v2] OptionRomPkg: Ax88772b: Fixing register access issue in Apple Eth Adapter X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: fathi.boudra@linaro.org, edk2-devel@lists.01.org MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" The USB command CMD_RXQTC ("RX Queue Cascade Threshold Control") tries to access the register and is always failing when using the Apple Ethernet adapter. It is fixed by checking flag before sending command. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Shivamurthy Shastri --- .../Bus/Usb/UsbNetworking/Ax88772b/Ax88772.c | 19 ++++++----- .../Bus/Usb/UsbNetworking/Ax88772b/Ax88772.h | 4 ++- .../Bus/Usb/UsbNetworking/Ax88772b/DriverBinding.c | 37 ++++++++++++++++++++++ 3 files changed, 51 insertions(+), 9 deletions(-) -- 1.9.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.c b/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.c index 45ba3e5..e014d52 100644 --- a/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.c +++ b/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.c @@ -625,15 +625,18 @@ Ax88772Reset ( if (EFI_ERROR(Status)) goto err; - SetupMsg.RequestType = USB_REQ_TYPE_VENDOR - | USB_TARGET_DEVICE; - SetupMsg.Request = CMD_RXQTC; - SetupMsg.Value = 0x8000; - SetupMsg.Index = 0x8001; - SetupMsg.Length = 0; - Status = Ax88772UsbCommand ( pNicDevice, + if (pNicDevice->Flags != FLAG_TYPE_AX88772) { + SetupMsg.RequestType = USB_REQ_TYPE_VENDOR + | USB_TARGET_DEVICE; + SetupMsg.Request = CMD_RXQTC; + SetupMsg.Value = 0x8000; + SetupMsg.Index = 0x8001; + SetupMsg.Length = 0; + Status = Ax88772UsbCommand ( pNicDevice, &SetupMsg, - NULL ); + NULL ); + } + err: return Status; } diff --git a/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.h b/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.h index a2109cf..92ac64d 100644 --- a/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.h +++ b/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.h @@ -404,7 +404,9 @@ typedef struct { RX_PKT * pFirstFill; UINTN PktCntInQueue; UINT8 * pBulkInBuff; - + + INT32 Flags; + } NIC_DEVICE; #define DEV_FROM_SIMPLE_NETWORK(a) CR (a, NIC_DEVICE, SimpleNetwork, DEV_SIGNATURE) ///< Locate NIC_DEVICE from Simple Network Protocol diff --git a/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/DriverBinding.c b/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/DriverBinding.c index d64bc73..bf05c74 100644 --- a/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/DriverBinding.c +++ b/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/DriverBinding.c @@ -124,6 +124,8 @@ DriverStart ( UINTN LengthInBytes; EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath = NULL; MAC_ADDR_DEVICE_PATH MacDeviceNode; + EFI_USB_DEVICE_DESCRIPTOR Device; + UINT32 Index; // // Allocate the device structure @@ -178,6 +180,41 @@ DriverStart ( goto EXIT; } + Status = pNicDevice->pUsbIo->UsbGetDeviceDescriptor ( pNicDevice->pUsbIo, &Device ); + if (EFI_ERROR ( Status )) { + gBS->CloseProtocol ( + Controller, + &gEfiUsbIoProtocolGuid, + pThis->DriverBindingHandle, + Controller + ); + gBS->FreePool ( pNicDevice ); + goto EXIT; + } else { + // + // Validate the adapter + // + for (Index = 0; ASIX_DONGLES[Index].VendorId != 0; Index++) { + if (ASIX_DONGLES[Index].VendorId == Device.IdVendor && + ASIX_DONGLES[Index].ProductId == Device.IdProduct) { + break; + } + } + + if (ASIX_DONGLES[Index].VendorId == 0) { + gBS->CloseProtocol ( + Controller, + &gEfiUsbIoProtocolGuid, + pThis->DriverBindingHandle, + Controller + ); + gBS->FreePool ( pNicDevice ); + goto EXIT; + } + + pNicDevice->Flags = ASIX_DONGLES[Index].Flags; + } + // // Set Device Path //