From patchwork Tue Feb 18 01:10:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 3666461 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DB73D9F390 for ; Tue, 18 Feb 2014 01:10:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D49AB2020F for ; Tue, 18 Feb 2014 01:10:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0B346201FE for ; Tue, 18 Feb 2014 01:10:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753556AbaBRBKq (ORCPT ); Mon, 17 Feb 2014 20:10:46 -0500 Received: from mail-ee0-f53.google.com ([74.125.83.53]:35814 "EHLO mail-ee0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753125AbaBRBKo (ORCPT ); Mon, 17 Feb 2014 20:10:44 -0500 Received: by mail-ee0-f53.google.com with SMTP id t10so7325434eei.26 for ; Mon, 17 Feb 2014 17:10:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tjG/VJN0VmiXANWvMxhjiv/CmLUzYRDCJdCM5YGrqxs=; b=b5HaR75R1rm+HkPF/MAn6giLfiWFjs03sHxORpGvpAg1i/uQO/3eI0DzwWysBIfb3C oOxlv+1fWQ4YM3Ovh22ZF0prhYnhvIbLxHE7vEryki9XBaL0TM458sfC4SbQIryeGCg4 YE0leu/E+mIUD0bOa4nrgqxo3TClf7IN0OGzM27rge1mCfMcJgHvvotAYQvTykZhbaDG +ac1fsTqfbOW5jZkiKMEh2CCNn04nnVRNVdMEzzgotHhSDoO5nulk8dklmYXD5aPY/Ds HCTJGreUHHTtQBvFIGxCnuQaoCFt8Ka2jqFAwOqDc9EtTQ7QcYjPj5XZn3DKc3ToRj+l oTAQ== X-Received: by 10.14.181.134 with SMTP id l6mr30644543eem.8.1392685843347; Mon, 17 Feb 2014 17:10:43 -0800 (PST) Received: from localhost.localdomain ([95.237.125.26]) by mx.google.com with ESMTPSA id j41sm63723093eeg.10.2014.02.17.17.10.41 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 17 Feb 2014 17:10:42 -0800 (PST) From: Andrea Merello To: linville@tuxdriver.com Cc: linux-wireless@vger.kernel.org, Larry.Finger@lwfinger.net, bernhard@schiffner-limbach.de, dan.carpenter@oracle.com, liuhq11@mails.tsinghua.edu.cn, andrea merello Subject: [PATCH 6/7] rtl818x: Make sure the TX descriptor "valid" flag is written by last Date: Tue, 18 Feb 2014 02:10:45 +0100 Message-Id: <1392685846-10116-7-git-send-email-andrea.merello@gmail.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1392685846-10116-1-git-send-email-andrea.merello@gmail.com> References: <1392685846-10116-1-git-send-email-andrea.merello@gmail.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 From: andrea merello The TX descriptors are consumed by the HW using DMA. Even if in the driver code the memory write that sets the "valid" flag appears after all other writes, the CPU may reorder writes, causing the HW to consider as valid a not-fully-written yet descriptor. This may cause HW incorrect behaviour. This can happen because (AFAIK) the HW may attempt DMA asynchronously without waiting to be kicked by the following register write. This patch adds a write memory barrier to enforce writes ordering. Reported-by: Dan Carpenter Signed-off-by: Andrea Merello --- drivers/net/wireless/rtl818x/rtl8180/dev.c | 5 +++++ 1 file changed, 5 insertions(+) 1.8.3.2 -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/wireless/rtl818x/rtl8180/dev.c b/drivers/net/wireless/rtl818x/rtl8180/dev.c index be9a8a1..7027cb7 100644 --- a/drivers/net/wireless/rtl818x/rtl8180/dev.c +++ b/drivers/net/wireless/rtl818x/rtl8180/dev.c @@ -335,7 +335,11 @@ static void rtl8180_tx(struct ieee80211_hw *dev, entry->flags2 = info->control.rates[1].idx >= 0 ? ieee80211_get_alt_retry_rate(dev, info, 0)->bitrate << 4 : 0; entry->retry_limit = info->control.rates[0].count; + + /* We must be sure that tx_flags is written last because the HW + * looks at it to check if the rest of data is valid or not + */ + wmb(); entry->flags = cpu_to_le32(tx_flags); __skb_queue_tail(&ring->queue, skb); if (ring->entries - skb_queue_len(&ring->queue) < 2) --