From patchwork Tue Apr 21 21:33:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Malcolm Priestley X-Patchwork-Id: 6253861 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C5624BF4A6 for ; Tue, 21 Apr 2015 21:33:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EBFD720340 for ; Tue, 21 Apr 2015 21:33:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2223E20306 for ; Tue, 21 Apr 2015 21:33:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933746AbbDUVd3 (ORCPT ); Tue, 21 Apr 2015 17:33:29 -0400 Received: from mail-wi0-f178.google.com ([209.85.212.178]:36780 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932620AbbDUVd1 (ORCPT ); Tue, 21 Apr 2015 17:33:27 -0400 Received: by wizk4 with SMTP id k4so155283398wiz.1; Tue, 21 Apr 2015 14:33:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=Uq4AWcU7yLNdy3WErJiB7C0wgvBuZEaMFemlqwAiNhk=; b=0XWvZyxh0jgxLVRfVIRE2u4D8Q45z51pAXt+shYpVfZY7eTvoJmV4DuQ7Q/wej7Dtq VFVUS0pfA5PCH1zKCPAwh+DGt8Nwuh2oUxM3HlKh4Lldxz6cqCUcDxNovldz3quTcxi8 4vvf2SkgW5fyvOdsUxUG/f+m9wzYm3yMzsBrawnae51pEMVeyMlgr5mSXNyya2PRcsDx fO/qAw0Szaqzu4/EqtHshF3tGZ4blU04mshOrLo6onOsfVXo4lFZRmw70x9O2URpl2xi /yk2u2+VXejvO+EgKgfsvuI9TVQYehmJYLUG8+wG4f1YNT1nFZhF6e1NvnPWh9fOeIyG ZZbA== X-Received: by 10.194.238.161 with SMTP id vl1mr31362677wjc.144.1429652006280; Tue, 21 Apr 2015 14:33:26 -0700 (PDT) Received: from tipsey.3.home (94.197.45.248.threembb.co.uk. [94.197.45.248]) by mx.google.com with ESMTPSA id fs9sm4336352wjc.34.2015.04.21.14.33.21 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Apr 2015 14:33:25 -0700 (PDT) From: Malcolm Priestley To: gregkh@linuxfoundation.org Cc: linux-wireless@vger.kernel.org, Malcolm Priestley , Subject: [PATCH 1/3] staging: vt6655: vnt_tx_packet Correct TX order of OWNED_BY_NIC Date: Tue, 21 Apr 2015 22:33:00 +0100 Message-Id: <1429651982-4352-1-git-send-email-tvboxspy@gmail.com> X-Mailer: git-send-email 2.1.4 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The state of m_td0TD0.f1Owner should change after the buff_addr has been filled otherwise the device grabs the buffer too early. m_td0TD0.f1Owner is protected by memory barriers on both sides of change. iTDUsed is best incremented after MACvTransmit. It appears that f1Owner actually polls to do the memory transfer. A back port patch will be needed for v3.19 Signed-off-by: Malcolm Priestley Cc: # v4.0+ --- drivers/staging/vt6655/device_main.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index c5f8233..ed90b6f 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -1201,14 +1201,6 @@ static int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb) if (dma_idx == TYPE_AC0DMA) head_td->pTDInfo->byFlags = TD_FLAGS_NETIF_SKB; - priv->iTDUsed[dma_idx]++; - - /* Take ownership */ - wmb(); - head_td->m_td0TD0.f1Owner = OWNED_BY_NIC; - - /* get Next */ - wmb(); priv->apCurrTD[dma_idx] = head_td->next; spin_unlock_irqrestore(&priv->lock, flags); @@ -1229,11 +1221,18 @@ static int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb) head_td->buff_addr = cpu_to_le32(head_td->pTDInfo->skb_dma); + /* Poll Transmit the adapter */ + wmb(); + head_td->m_td0TD0.f1Owner = OWNED_BY_NIC; + wmb(); /* second memory barrier */ + if (head_td->pTDInfo->byFlags & TD_FLAGS_NETIF_SKB) MACvTransmitAC0(priv->PortOffset); else MACvTransmit0(priv->PortOffset); + priv->iTDUsed[dma_idx]++; + spin_unlock_irqrestore(&priv->lock, flags); return 0;