Skip to content

Commit

Permalink
SAME70 driver xTXDescriptorSemaphore issue (FreeRTOS#1033)
Browse files Browse the repository at this point in the history
* Fixes and issue with the SAME70 port where and error in gmac_dev_write() causes the counting  xTXDescriptorSemaphore to not be returned and eventually exhausting it.

* fix formatting

* Allows release of the network buffer if gmac_dev_write() fails and the ero-copy driver is being used.
Thanks @htibosch

* Fix typo

---------

Co-authored-by: Emil Popov <epopov@cardinalkinetic.com>
Co-authored-by: tony-josi-aws <tonyjosi@amazon.com>
Co-authored-by: ActoryOu <jay2002824@gmail.com>
  • Loading branch information
4 people authored Oct 25, 2023
1 parent 2131f01 commit 8761f51
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions source/portable/NetworkInterface/DriverSAM/NetworkInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -651,12 +651,22 @@ static BaseType_t prvSAM_NetworkInterfaceOutput( NetworkInterface_t * pxInterfac
if( ulResult != GMAC_OK )
{
TX_STAT_INCREMENT( tx_write_fail );

/* On a successful write to GMAC, the ownership of the TX descriptor will eventually get returned back to the network
* driver and prvEMACHandlerTask will give back the xTXDescriptorSemaphore counting semaphore. In this case however,
* writing to the GMAC failed, so there will be no EMAC_IF_TX_EVENT sent to prvEMACHandlerTask and the counting
* semaphore will not be given back. Give it back now. */
xSemaphoreGive( xTXDescriptorSemaphore );
}

#if ( ipconfigZERO_COPY_TX_DRIVER != 0 )
{
/* Confirm that the pxDescriptor may be kept by the driver. */
bReleaseAfterSend = pdFALSE;
if( ulResult == GMAC_OK )
{
/* The message was send in a zero-copy way.
* It will be released after a successful transmission. */
bReleaseAfterSend = pdFALSE;
}
}
#endif /* ipconfigZERO_COPY_TX_DRIVER */
/* Not interested in a call-back after TX. */
Expand Down

0 comments on commit 8761f51

Please sign in to comment.