From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Miller Subject: Re: [PATCH net-next] net: thunderbolt: Clear finished Tx frame bus address in tbnet_tx_callback() Date: Sat, 11 Nov 2017 19:21:24 +0900 (KST) Message-ID: <20171111.192124.1886178021388114448.davem@davemloft.net> References: <20171109104628.63979-1-mika.westerberg@linux.intel.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: michael.jamet@intel.com, yehezkel.bernat@intel.com, netdev@vger.kernel.org To: mika.westerberg@linux.intel.com Return-path: Received: from shards.monkeyblade.net ([184.105.139.130]:46304 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751336AbdKKKV0 (ORCPT ); Sat, 11 Nov 2017 05:21:26 -0500 In-Reply-To: <20171109104628.63979-1-mika.westerberg@linux.intel.com> Sender: netdev-owner@vger.kernel.org List-ID: From: Mika Westerberg Date: Thu, 9 Nov 2017 13:46:28 +0300 > When Thunderbolt network interface is disabled or when the cable is > unplugged the driver releases all allocated buffers by calling > tbnet_free_buffers() for each ring. This function then calls > dma_unmap_page() for each buffer it finds where bus address is non-zero. > Now, we only clear this bus address when the Tx buffer is sent to the > hardware so it is possible that the function finds an entry that has > already been unmapped. > > Enabling DMA-API debugging catches this as well: > > thunderbolt 0000:06:00.0: DMA-API: device driver tries to free DMA > memory it has not allocated [device address=0x0000000068321000] [size=4096 bytes] > > Fix this by clearing the bus address of a Tx frame right after we have > unmapped the buffer. > > Signed-off-by: Mika Westerberg Applied, but assuming zero is a non-valid DMA address is never a good idea. That's why we have the DMA error code signaling abstracted.