Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2241360yba; Fri, 17 May 2019 13:10:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqzAxPBaRYoeCk0MW4Ec+JvU8QXYcv6CvgBuMU6SMc4FZIgM8MwxKINYOzSL0DF8zjc9R1MW X-Received: by 2002:a62:5581:: with SMTP id j123mr63512648pfb.102.1558123814317; Fri, 17 May 2019 13:10:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558123814; cv=none; d=google.com; s=arc-20160816; b=MkN4MIEfNxapqFoAaF8QTGyl5xYhYWy37l/5Nvd2tXk1uIlamYnEzFzyijWyVWoYW4 Mv+jAQP+lxE54dz1iai2inVY4sjo5UpkWz2gA/znzanJjoYdE0NbEkSRGl6djnIMCNcy U8irAqhAsSVXT+n2onmKr/6LiRrXoqOOPRfgOW4OkFi3RIF6PkU+FuJ8QBJsR5yR7n4N x9PWlXtd/xTV33mn31bjeLn8sS226OxFTccZVgPbJsC6JjEG4070fRaiui/Nw5xjA9ls RxoPeazpYnhBbSmngljHUE9rx7o1bwAjnuNiHWteAXVJHbvErESqi4wRUfWifvkkEj3a ftDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=VpbDUS34YEE3/go9H9nTqXvmrFu74UgQef2p9ork8w8=; b=IQ9HZQ4e54fKjqrNuasL55yZ3HGjHeVYbkHPmUWw1M3/iITS8qGPHuk6J3Ew0LfpOn vOJf2cxfIK3NdH/receT5cFhD/SQ3rTgpg5E+EfV9Zn9gIOuINhgRzabXIcdkzPd7rl4 y7sgxY9iTU5oLkmTGK3tkMrWtKmWB5uPnoi37W9mPZvaBqP7Xkqv/kPaS7C+9CQafgY3 uPlDwi3vkIYQQnso8L9OZRwT7qtPEcTzjyATtv4aoRMIKTXI23ZI5W7fbThTPLXEo2wV heGflPPJ+KJvlNzkrZElzT1yZMfaiwoKLuuSVHdyZp7jsxFouybWcwYaCdjuDt0j9CTh E+mg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v61si9730158plb.20.2019.05.17.13.09.58; Fri, 17 May 2019 13:10:14 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728179AbfEQSd5 (ORCPT + 99 others); Fri, 17 May 2019 14:33:57 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:42124 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726974AbfEQSdy (ORCPT ); Fri, 17 May 2019 14:33:54 -0400 Received: by mail-qt1-f195.google.com with SMTP id j53so9109342qta.9 for ; Fri, 17 May 2019 11:33:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=VpbDUS34YEE3/go9H9nTqXvmrFu74UgQef2p9ork8w8=; b=BjgchH44jChZgUAzEnTi25aWaRrc1Nj2s0ULP0ktrzle/uq4W7KiDvwwYFPhR2IoWf D3HA+iJRjkn1RD2kIC7Xn7EbDRNtdoq7/jsfNpcU08M7f3wE/gCzBiPOxWDaWlMrVaz7 9p9n0RXuSKeV4uctGGbfGIXCRCGlDEcrK+9yZF+4GMxGwQZ+nK+nMa0uqybOQ2DOupo/ 2agzpCXyLyqlOJF/WTb/KQQckALiEcUS4nZ0zYyu0O4bYHrfFrOHzg9uiv8mP41fFjeh sHON86dTrYEiydRvB3hMkPDC1fQ5HEByrgNA/FR0FMWbyBkZJm5GrjJtClqkse43OL1x K/9g== X-Gm-Message-State: APjAAAW/pBm0jjwmFw+SFlm14JJbzFpSobjIVDyQS+dZpZLgZQNR7DwD oFintRVu07/7KN7tZrVHY6DDVTAHLQzVIr7Ie5l3eh/c X-Received: by 2002:ac8:2433:: with SMTP id c48mr36064873qtc.18.1558118033332; Fri, 17 May 2019 11:33:53 -0700 (PDT) MIME-Version: 1.0 References: <20190512012508.10608-1-elder@linaro.org> <20190512012508.10608-10-elder@linaro.org> <14a040b6-8187-3fbc-754d-2e267d587858@linaro.org> In-Reply-To: <14a040b6-8187-3fbc-754d-2e267d587858@linaro.org> From: Arnd Bergmann Date: Fri, 17 May 2019 20:33:37 +0200 Message-ID: Subject: Re: [PATCH 09/18] soc: qcom: ipa: GSI transactions To: Alex Elder Cc: David Miller , Bjorn Andersson , Ilias Apalodimas , syadagir@codeaurora.org, mjavid@codeaurora.org, evgreen@chromium.org, Ben Chan , Eric Caruso , abhishek.esse@gmail.com, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 17, 2019 at 8:08 PM Alex Elder wrote: > > On 5/15/19 2:34 AM, Arnd Bergmann wrote: > >> +static void gsi_trans_tre_fill(struct gsi_tre *dest_tre, dma_addr_t addr, > >> + u32 len, bool last_tre, bool bei, > >> + enum ipa_cmd_opcode opcode) > >> +{ > >> + struct gsi_tre tre; > >> + > >> + tre.addr = cpu_to_le64(addr); > >> + tre.len_opcode = gsi_tre_len_opcode(opcode, len); > >> + tre.reserved = 0; > >> + tre.flags = gsi_tre_flags(last_tre, bei, opcode); > >> + > >> + *dest_tre = tre; /* Write TRE as a single (16-byte) unit */ > >> +} > > Have you checked that the atomic write is actually what happens here, > > but looking at the compiler output? You might need to add a 'volatile' > > qualifier to the dest_tre argument so the temporary structure doesn't > > get optimized away here. > > Currently, the assignment *does* become a "stp" instruction. > But I don't know that we can *force* the compiler to write it > as a pair of registers, so I'll soften the comment with > "Attempt to write" or something similar. > > To my knowledge, adding a volatile qualifier only prevents the > compiler from performing funny optimizations, but that has no > effect on whether the 128-bit assignment is made as a single > unit. Do you know otherwise? I don't think it you can force the 128-bit assignment to be atomic, but marking 'dest_tre' should serve to prevent a specific optimization that replaces the function with dest_tre->addr = ... dest_tre->len_opcode = ... dest_tre->reserved = ... dest_tre->flags = ... which it might find more efficient than the stp and is equivalent when the pointer is not marked volatile. We also have the WRITE_ONCE() macro that can help prevent this, but it does not work reliably beyond 64 bit assignments. Arnd