Skip to content

Commit

Permalink
Version 2.5.0d0 - Reworked descriptor memory allocation strategy. Kee…
Browse files Browse the repository at this point in the history
…p ownership of h/w during sleep to fix problems with sleep on I21xLM with AMT.
  • Loading branch information
Mieze committed Dec 1, 2018
1 parent 7be90f7 commit f3c69ce
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 52 deletions.
8 changes: 4 additions & 4 deletions IntelMausiEthernet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MACOSX_DEPLOYMENT_TARGET = 10.14;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
Expand Down Expand Up @@ -398,7 +398,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MACOSX_DEPLOYMENT_TARGET = 10.14;
SDKROOT = macosx;
};
name = Release;
Expand All @@ -420,7 +420,7 @@
GCC_PREFIX_HEADER = "IntelMausiEthernet/IntelMausiEthernetV2-Prefix.pch";
INFOPLIST_FILE = "IntelMausiEthernet/IntelMausiEthernet-Info.plist";
MODULE_NAME = com.insanelymac.IntelMausiEthernet;
MODULE_VERSION = 2.4.0;
MODULE_VERSION = 2.5.0d0;
PRODUCT_BUNDLE_IDENTIFIER = "com.insanelymac.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = IntelMausiEthernet;
SDKROOT = macosx;
Expand All @@ -445,7 +445,7 @@
GCC_PREFIX_HEADER = "IntelMausiEthernet/IntelMausiEthernetV2-Prefix.pch";
INFOPLIST_FILE = "IntelMausiEthernet/IntelMausiEthernet-Info.plist";
MODULE_NAME = com.insanelymac.IntelMausiEthernet;
MODULE_VERSION = 2.4.0;
MODULE_VERSION = 2.5.0d0;
PRODUCT_BUNDLE_IDENTIFIER = "com.insanelymac.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = IntelMausiEthernet;
SDKROOT = macosx;
Expand Down
67 changes: 37 additions & 30 deletions IntelMausiEthernet/IntelMausiEthernet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,14 @@ bool IntelMausi::start(IOService *provider)
}
commandGate->retain();

if (!setupDMADescriptors()) {
IOLog("Ethernet [IntelMausi]: Error allocating DMA descriptors.\n");
goto error3;
}

if (!initEventSources(provider)) {
IOLog("Ethernet [IntelMausi]: initEventSources() failed.\n");
goto error3;
goto error4;
}

result = attachInterface(reinterpret_cast<IONetworkInterface**>(&netif));
Expand All @@ -295,6 +300,9 @@ bool IntelMausi::start(IOService *provider)
done:
return result;

error4:
freeDMADescriptors();

error3:
RELEASE(commandGate);

Expand All @@ -310,8 +318,13 @@ bool IntelMausi::start(IOService *provider)
void IntelMausi::stop(IOService *provider)
{
UInt32 i;

if (netif) {
/*
* Let the firmware know that the network interface is now closed.
*/
e1000e_release_hw_control(&adapterData);

detachInterface(netif);
netif = NULL;
}
Expand Down Expand Up @@ -400,11 +413,10 @@ void IntelMausi::systemWillShutdown(IOOptionBits specifier)
/* Restore the original MAC address. */
adapterData.hw.mac.ops.rar_set(&adapterData.hw, adapterData.hw.mac.perm_addr, 0);

/* If AMT is enabled, let the firmware know that the network
* interface is now closed
/*
* Let the firmware know that the network interface is now closed
*/
if ((adapterData.flags & FLAG_HAS_AMT))
e1000e_release_hw_control(&adapterData);
e1000e_release_hw_control(&adapterData);
}

DebugLog("systemWillShutdown() <===\n");
Expand Down Expand Up @@ -432,13 +444,9 @@ IOReturn IntelMausi::enable(IONetworkInterface *netif)
}
pciDevice->open(this);

if (!setupDMADescriptors()) {
IOLog("Ethernet [IntelMausi]: Error allocating DMA descriptors.\n");
goto done;
}
intelEnable();

/* In case we are using an msi the interrupt hasn't been enabled by start(). */
/* As we are using an msi the interrupt hasn't been enabled by start(). */
interruptSource->enable();

rxPacketHead = rxPacketTail = NULL;
Expand Down Expand Up @@ -480,7 +488,7 @@ IOReturn IntelMausi::disable(IONetworkInterface *netif)
timerSource->cancelTimeout();
txDescDoneCount = txDescDoneLast = 0;

/* In case we are using msi disable the interrupt. */
/* We are using MSI so that we have to disable the interrupt. */
interruptSource->disable();

intelDisable();
Expand All @@ -493,8 +501,6 @@ IOReturn IntelMausi::disable(IONetworkInterface *netif)
if (pciDevice && pciDevice->isOpen())
pciDevice->close(this);

freeDMADescriptors();

DebugLog("disable() <===\n");

done:
Expand Down Expand Up @@ -1353,14 +1359,15 @@ IOReturn IntelMausi::setInputPacketPollingEnable(IONetworkInterface *interface,
{
//DebugLog("setInputPacketPollingEnable() ===>\n");

if (enabled) {
intelWriteMem32(E1000_IMC, ~(E1000_ICR_LSC | E1000_IMS_RXSEQ));
intelFlush();
} else {
intelEnableIRQ(intrMask);
if (isEnabled) {
if (enabled) {
intelWriteMem32(E1000_IMC, ~(E1000_ICR_LSC | E1000_IMS_RXSEQ));
intelFlush();
} else {
intelEnableIRQ(intrMask);
}
polling = enabled;
}
polling = enabled;

//DebugLog("input polling %s.\n", enabled ? "enabled" : "disabled");

//DebugLog("setInputPacketPollingEnable() <===\n");
Expand All @@ -1372,10 +1379,12 @@ void IntelMausi::pollInputPackets(IONetworkInterface *interface, uint32_t maxCou
{
//DebugLog("pollInputPackets() ===>\n");

rxInterrupt(interface, maxCount, pollQueue, context);

/* Finally cleanup the transmitter ring. */
txInterrupt();
if (polling) {
rxInterrupt(interface, maxCount, pollQueue, context);

/* Finally cleanup the transmitter ring. */
txInterrupt();
}

//DebugLog("pollInputPackets() <===\n");
}
Expand Down Expand Up @@ -1814,12 +1823,10 @@ bool IntelMausi::intelStart()
/* reset the hardware with the new settings */
intelReset(&adapterData);

/* If the controller has AMT, do not set DRV_LOAD until the interface
* is up. For all other cases, let the f/w know that the h/w is now
* under the control of the driver.
/* Let the f/w know that the h/w is now under the control of the driver
* even in case the device has AMT in order to avoid problems after wakeup.
*/
if (!(adapterData.flags & FLAG_HAS_AMT))
e1000e_get_hw_control(&adapterData);
e1000e_get_hw_control(&adapterData);

intrMask = IMS_ENABLE_MASK;

Expand Down
18 changes: 0 additions & 18 deletions IntelMausiEthernet/IntelMausiHardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,6 @@ void IntelMausi::intelEnable()

e1000e_power_up_phy(&adapterData);

/* If AMT is enabled, let the firmware know that the network
* interface is now open and reset the part to a known state.
*/
if (adapterData.flags & FLAG_HAS_AMT) {
e1000e_get_hw_control(&adapterData);
}
intelReset(&adapterData);

#if DISABLED_CODE
Expand Down Expand Up @@ -379,12 +373,6 @@ void IntelMausi::intelDisable()
}
hw->phy.ops.release(hw);
}

/* If AMT is enabled, let the firmware know that the network
* interface is now closed
*/
if (adapterData.flags & FLAG_HAS_AMT)
e1000e_release_hw_control(&adapterData);

if (linkUp) {
linkUp = false;
Expand Down Expand Up @@ -865,12 +853,6 @@ void IntelMausi::intelReset(struct e1000_adapter *adapter)
/* Allow time for pending master requests to run */
mac->ops.reset_hw(hw);

/* For parts with AMT enabled, let the firmware know
* that the network interface is in control
*/
if (adapter->flags & FLAG_HAS_AMT)
e1000e_get_hw_control(adapter);

intelWriteMem32(E1000_WUC, 0);

if (mac->ops.init_hw(hw))
Expand Down

0 comments on commit f3c69ce

Please sign in to comment.