Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3426205imm; Fri, 25 May 2018 05:38:10 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqMTCklKtjVYrKxRhFrtor4QillB8p8vxRshKFPi3nl1fzZ5zTaJObo6+olM56/zKfH+1Fk X-Received: by 2002:a63:a312:: with SMTP id s18-v6mr1865488pge.187.1527251890542; Fri, 25 May 2018 05:38:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527251890; cv=none; d=google.com; s=arc-20160816; b=DgG3zbjGKoZgU7qCeKxJ4Ch7EESB7OCsDGnsa5IbG2gX51BZRAtu7F+H6vjR0Z6vZd HYeBxVFUfVnEBjPs7+rjLsOYxwKqQf04JmxUt16TNPRzDLxe2/d9/n3yU5quQztUbSqG yXs5ULj1FzNRSUlsbZcsrIXsQ3fxjwheHU9XIKJqJkyd3IkdopFVPUzVqRDU6M7fyCev wd1nPJe6ArEe2g9qfIx79dqAveMETP6GAkhbvMm/Jabi+OxW1fRaIwBDp0wIK9qj0jc3 urlDuTNpyoMlCX1q1ndrq6nZclcLddNtYIznM2+/QDLSmEufQUID+u4fn8i8xn3uHVbs zP8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=aEz2Achy49TmAySG0Cpgey8+rnk9UGi/FsGj/74PeZE=; b=iOETgD8KS6c0AIkl5IN/0r4d0xkoRAlUKLLzzeC4Bmi1dzzG57wf6HutIZ+0rbBu/n rNDZ+0UFyGcI4F3M+uPIySSlZBqGNQuQX/quA95ZBQJYwdQ7zU8OAfGJHhpyRv6LMRfk Hct3y3Pq13wvrXO3niFdOIj/VeFf4SZ9dMfYpAMFtOAHv356zKqU2pFfCsUqzchtQLz/ cKrJL7Q33H2OBz8B1LSUGy0Cdcx9/jhy6DUIOp3s4W36mRjtQysu2NLLVa4ClsU8QqYm m8VuH9g0txs6gXyV+dpGei+BlVaoIZ+YiUaqS1xl0vSPDtXP7wns3p6x1SrFpQ+pn3ZM y0qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XgyYY19T; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l81-v6si24195048pfj.127.2018.05.25.05.37.55; Fri, 25 May 2018 05:38:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XgyYY19T; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934251AbeEYMhC (ORCPT + 99 others); Fri, 25 May 2018 08:37:02 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:40204 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933100AbeEYMhA (ORCPT ); Fri, 25 May 2018 08:37:00 -0400 Received: by mail-wr0-f194.google.com with SMTP id l41-v6so8990990wre.7 for ; Fri, 25 May 2018 05:36:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=aEz2Achy49TmAySG0Cpgey8+rnk9UGi/FsGj/74PeZE=; b=XgyYY19T6nTuT7lkQglkMJy3EVEJ7TxTJk+W6ZyQ5ITqEPdlaYQwSN1b5Pb/wTZ4AI oORKClTAFT3q6AAncOjxtPufchRDpaaRjgecRv5VE0fdw9DiV2Q1jl70bw4cfNKu0FGr FsgZDSks5zKHP+Hsq23fH3CoL/IV3vJdgj+II= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=aEz2Achy49TmAySG0Cpgey8+rnk9UGi/FsGj/74PeZE=; b=TYsNsRptBaIv2bq+Dw2DM5PAIhAfA9/W3RUXejlXT194o4g3abHzA8Q1G23AC6Kxpj /uEn++KejBpQW3EWqHevP0dp1fjX5GbK8Ur6xX5LmqwDQsiBau9ySFGwWjqFdpolEW1N 2TocXv5geI8CGBZTC3FcS84cqtnFBOuj5ovU+VzNNAF0lDr9+0gLWlpAkbeiKT0kKMOk lbUvUHq6jloWHryP2ThWj54GPNTd/NTLYOUQWO1mzhhkHy1v6hRxLLXcg4sdqsaHO3gr l4sPl9pwCh2gsDOHeL1oun/b4Tn0YRtTH4eJx78SjD4r4f98O+OKA8hjTN16cqGZ5VmN ZQkQ== X-Gm-Message-State: ALKqPwelTgYkMqvRaspA10SJ6W8b6qkCmH2w5T9sGKjLssXwKp3sfx35 YdCVC3cCTRFyk5JZurhWxE5xtA== X-Received: by 2002:a19:be53:: with SMTP id o80-v6mr1426325lff.140.1527251819028; Fri, 25 May 2018 05:36:59 -0700 (PDT) Received: from localhost.localdomain (h-229-118.A785.priv.bahnhof.se. [5.150.229.118]) by smtp.gmail.com with ESMTPSA id p24-v6sm1553057lfj.83.2018.05.25.05.36.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 May 2018 05:36:58 -0700 (PDT) Date: Fri, 25 May 2018 14:36:56 +0200 From: Niklas Cassel To: Bob Copeland Cc: Adrian Chadd , Kalle Valo , David Miller , ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, Linux Kernel Mailing List Subject: Re: [PATCH] ath10k: transmit queued frames after waking queues Message-ID: <20180525123656.GB8780@localhost.localdomain> References: <20180517231512.13085-1-niklas.cassel@linaro.org> <20180521203701.GA7619@localhost.localdomain> <20180524155034.xse7cfm5figfktuj@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180524155034.xse7cfm5figfktuj@localhost> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 24, 2018 at 11:50:34AM -0400, Bob Copeland wrote: > On Mon, May 21, 2018 at 10:37:01PM +0200, Niklas Cassel wrote: > > On Thu, May 17, 2018 at 03:26:25PM -0700, Adrian Chadd wrote: > > > On Thu, 17 May 2018 at 16:16, Niklas Cassel > > > wrote: > > > > > > > diff --git a/drivers/net/wireless/ath/ath10k/txrx.c > > > b/drivers/net/wireless/ath/ath10k/txrx.c > > > > index cda164f6e9f6..1d3b2d2c3fee 100644 > > > > --- a/drivers/net/wireless/ath/ath10k/txrx.c > > > > +++ b/drivers/net/wireless/ath/ath10k/txrx.c > > > > @@ -95,6 +95,9 @@ int ath10k_txrx_tx_unref(struct ath10k_htt *htt, > > > > wake_up(&htt->empty_tx_wq); > > > > spin_unlock_bh(&htt->tx_lock); > > > > > > > + if (htt->num_pending_tx <= 3 && !list_empty(&ar->txqs)) > > > > + ath10k_mac_tx_push_pending(ar); > > > > + > > > > > > Just sanity checking - what's protecting htt->num_pending_tx? or is it > > > serialised some other way? > [...] > > I can't see that any of the examples applies, but let's add READ_ONCE(), > > to make sure that the compiler doesn't try to optimize this. > > Couldn't you just move the num_pending_tx read inside tx_lock which is 2 lines > above? I think all the other manipulations are protected by tx_lock. Hello Bob, There is both a V2 and V3 of this patchset, V3 moves this to a sdio.c and calls ath10k_mac_tx_push_pending() unconditionally. But to answer your question, it shouldn't matter if the read is done while holding the lock or not. Sure, the compiler could do things so that the code path is always or never executed, but that is why I added READ_ONCE() in V2. A spin lock does have the advantage of ordering: memory operations issued before the spin_unlock_bh() will be completed before the spin_unlock_bh() operation has completed. However, ath10k_htt_tx_dec_pending() was called earlier in the same function, which decreases htt->num_pending_tx, so that write will be completed before our read. That is the only ordering we care about here (if we should call ath10k_mac_tx_push_pending() or not). Kind regards, Niklas