Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2760779imm; Thu, 9 Aug 2018 20:23:21 -0700 (PDT) X-Google-Smtp-Source: AA+uWPw8rjJVsARN0DXohPkPsjSoGM8XJHoBrSUs/GYACtM7lh/eaRV6zGVAyfhyLQlvNhwfUKtm X-Received: by 2002:a62:768f:: with SMTP id r137-v6mr5102730pfc.250.1533871400954; Thu, 09 Aug 2018 20:23:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533871400; cv=none; d=google.com; s=arc-20160816; b=nGX7rUob8O40/Z5arxxXC9TJh2RA4kL7ymyojvnQAM2inlMwEHfr3kNL2dLqHVWigY nQDdjjtOjdCcAKUrJjjOkHNrKo4+URTgXLnNUVBI8OCLZyFH0NpchfFf3gCodM0gOXKu ZMorDpK+thMP/GMIY4hTW9qvVxbYdXWjCDqWUU2cDMNtfa2+U3234v89BxqisYVkruiF lSzLy+VdN2g+duMk+wRWl0rpfJIJhGdJ1A6KcaADUyKNDu9rcLGHvjQzKy4e4WFz6dzK 4mg2w2fIICn/zpMmV5RLlJ6y1rvn8DVU1PN8YyKSVqYeAGHgP0y8mamWn2nDqL9V3zfo 1Ayw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=TNmYLqAxTb3jeW0Q6N6Ne0QZTGyVHkNhmPFxBrYsNj0=; b=VugYHuXWOlSfZdAntTjySnXYayGdmwRFCLHCzu7QZyolhIY+O4F/a+sqr7Vyh+2ye/ Gfg61nikl2MeYgJM8dA7koypPT1zJ7drhHy8QgXlF1Z/txMKbeNzihiUYYUqNEnXMCwM kPnQR7o9fqNOJ42pBmPtpc0ta8iFMBfAkCFBlUIQi0sEFact1XbKX/P5AXAPzcsi0pM7 6NunMHFS0rLOnOMjVkEYq8ZuyN6i1SpvWE4C4rQZr1xwaotoeZBVVwxzECBkp9Bgi8F/ Xp9BxrK3NxHWTLhWRS6BdqiUaPiCc2iqPSERCk6crPktWLN8YupJvYhmpuV1/hL24/on JYHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IoOOy+py; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ca2-v6si7825407plb.305.2018.08.09.20.23.05; Thu, 09 Aug 2018 20:23:20 -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=@gmail.com header.s=20161025 header.b=IoOOy+py; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727626AbeHJFt3 (ORCPT + 99 others); Fri, 10 Aug 2018 01:49:29 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:44394 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727069AbeHJFt0 (ORCPT ); Fri, 10 Aug 2018 01:49:26 -0400 Received: by mail-pf1-f196.google.com with SMTP id k21-v6so3815926pff.11 for ; Thu, 09 Aug 2018 20:21:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TNmYLqAxTb3jeW0Q6N6Ne0QZTGyVHkNhmPFxBrYsNj0=; b=IoOOy+pypujUuhhIsSn/x4pWAF+qllGoGcP+NyGiZ8HpgQXluX8sczlKn1+EfQx+jK JzqxUSJ+ky5NXzxX1Y+yrw2UFPQR56BmdQRxBblGh8tas04WNP5z+rvaQuyV/9zQLX5f ikBR0TvI2RciKhGa6y0r3XCfv1yGDiKqkg5Tg/brPHse6gP54CDc8uRUE455v9BsXS6a yHMJ94qyur6SQ/e9q7FL9++ee6goJsRi2ZXa6JFhELeW2xh/o/g71EXF3QHKOALHQMTh N5zgiBaUjaKC3EHXkui6PlhDo9tStMymxf//EwPzPLmHAyH7HKqyxo6l8UTghl9MlH3p L5pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TNmYLqAxTb3jeW0Q6N6Ne0QZTGyVHkNhmPFxBrYsNj0=; b=I+GbCqwYbcny8iQdQpgDdIwGNgcEio/nZamODhgqKaTL9z5tqxAN7VchCd8Iu7DLwb P6Z0t1bgPWp36w+HGxkH4hXYsxQZjJ3Uw+jvBKnjGfOYTvRv0DO+9MoNiUMhcEHf4kvR 3uE3IAQrA8Qn+lfJnCLWAjHhYvriOw2LyCn0hud23WJMoYNmGtE5UVUDhn2DybgrRd9m yg8Iuf3ZhUR+vXjUL8SgDetb3Zf6hS64LmTZcSqwhkQGC/uXxExywumv9LZTXoi+tXDJ H8medqCTNr0cBv38vP0eLFDXKTKaN47On4HbPTYOFo97Ka0lNEPaBaS90VNFE62nDiYO C2zw== X-Gm-Message-State: AOUpUlFIaKuaNaQ48saK8d4Nx0H5EVyPCQuaOrk4AdJ3I+kV5lpBz0XK DA/NA8VpI6fa/8Qkyn8yk18= X-Received: by 2002:a62:d544:: with SMTP id d65-v6mr4995656pfg.107.1533871293181; Thu, 09 Aug 2018 20:21:33 -0700 (PDT) Received: from toddpoynor2.mtv.corp.google.com ([2620:0:1000:3701:7d29:cd13:d903:7908]) by smtp.gmail.com with ESMTPSA id p73-v6sm16130871pfk.186.2018.08.09.20.21.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Aug 2018 20:21:32 -0700 (PDT) From: Todd Poynor To: Rob Springer , John Joseph , Ben Chan , Greg Kroah-Hartman Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Todd Poynor Subject: [PATCH 10/16] staging: gasket: page table: remove extraneous memory barriers Date: Thu, 9 Aug 2018 20:21:05 -0700 Message-Id: <20180810032111.197743-11-toddpoynor@gmail.com> X-Mailer: git-send-email 2.18.0.597.ga71716f1ad-goog In-Reply-To: <20180810032111.197743-1-toddpoynor@gmail.com> References: <20180810032111.197743-1-toddpoynor@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Todd Poynor Some explicit memory barriers in the page table code are not necessary, either because: (a) The barrier follows a non-relaxed MMIO access that already performs a read or write memory barrier. (b) The barrier follows DMA API calls for which the device-visible effects of IOMMU programming are guaranteed to be flushed to the IOMMU prior to the call returning, and doesn't need to sync with normal memory access. Signed-off-by: Todd Poynor --- drivers/staging/gasket/gasket_page_table.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index 4d2499269499b..53492f4fad6aa 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -317,8 +317,6 @@ static void gasket_free_extended_subtable(struct gasket_page_table *pg_tbl, /* Release the page table from the device */ writeq(0, slot); - /* Force sync around the address release. */ - mb(); if (pte->dma_addr) dma_unmap_page(pg_tbl->device, pte->dma_addr, PAGE_SIZE, @@ -504,8 +502,6 @@ static int gasket_perform_mapping(struct gasket_page_table *pg_tbl, (void *)page_to_phys(page)); return -1; } - /* Wait until the page is mapped. */ - mb(); } /* Make the DMA-space address available to the device. */ @@ -604,12 +600,13 @@ static void gasket_perform_unmapping(struct gasket_page_table *pg_tbl, */ for (i = 0; i < num_pages; i++) { /* release the address from the device, */ - if (is_simple_mapping || ptes[i].status == PTE_INUSE) + if (is_simple_mapping || ptes[i].status == PTE_INUSE) { writeq(0, &slots[i]); - else + } else { ((u64 __force *)slots)[i] = 0; - /* Force sync around the address release. */ - mb(); + /* sync above PTE update before updating mappings */ + wmb(); + } /* release the address from the driver, */ if (ptes[i].status == PTE_INUSE) { @@ -898,8 +895,6 @@ static int gasket_alloc_extended_subtable(struct gasket_page_table *pg_tbl, /* Map the page into DMA space. */ pte->dma_addr = dma_map_page(pg_tbl->device, pte->page, 0, PAGE_SIZE, DMA_BIDIRECTIONAL); - /* Wait until the page is mapped. */ - mb(); /* make the addresses available to the device */ dma_addr = (pte->dma_addr + pte->offset) | GASKET_VALID_SLOT_FLAG; -- 2.18.0.597.ga71716f1ad-goog