From nobody Sun Dec 28 09:58:33 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41F5FC4167B for ; Fri, 8 Dec 2023 23:41:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234109AbjLHXlu (ORCPT ); Fri, 8 Dec 2023 18:41:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229525AbjLHXlp (ORCPT ); Fri, 8 Dec 2023 18:41:45 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C57F01712 for ; Fri, 8 Dec 2023 15:41:51 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-db53fec212aso3442713276.2 for ; Fri, 08 Dec 2023 15:41:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702078911; x=1702683711; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=k7GsY6GT/+tnbArErtPc1f6cs5/DzWiGNX1GnrooOm8=; b=K8gDe7e+NlM5dXA3tekfmsM6qM9+PqKWF1pdarRSKxNQLp6Zmo234R6MPjNiZTC7Bd Sy2givuIttjJG13JBSjEv1tei319RBdaOfFkhvN8v6DWnaTFFUNds0wcmRjCsalowXot OMyFpWUQAzQAR1novnmJ9Vmk6H4Y2rId/IgpkewJqXu8y0YzmDJkNFmYqMUcA8eKo7ZF SgDcmELPbDV/IHo/muYmi/NejnD6ff1fSUFLKhWavBao4W+HfVUs/e8v4u0ibVnbvXxb 0UpLfwUZFTrZYw11OAh/MZBCS91Nwa7wpYrcPnUYawdqHqhVSWGEfnyOTmnu+JO79LS1 Y9Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702078911; x=1702683711; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=k7GsY6GT/+tnbArErtPc1f6cs5/DzWiGNX1GnrooOm8=; b=OxSWdNFKJlqm+lQgZPtl0T1kPDlyew5PRY41kFcWI2sKWcOX6waRgKOSOD4010qsG8 FbN/BWjbY9gMEpgxr/XUUR4RDHXt2CgsDjJgDmfA0DDthKLG7f3BKAPX1OLudLDKW3rq hYLu+bbLPEmZthSX284VD390r1bvOPQRr1gu546A3ygvvM0paDNIRxmfL8ZxCgqeio/F M8c/GltcnS0CX+e63HVHm1f2zn51y0YLmhOPU3iiW8q5GcCQcIgq5li5n78artnL5WRk a2Ta4sp/b+jkxcTNisTqpQLoblCsCmnItt5AmXYqnbRgDJy4Y1VlXL5gWPDookOQMQUW 8N8A== X-Gm-Message-State: AOJu0YwbaPPY10uVltwvtmTvteTJKU/kIqiGt83Aj3V60QF5oU+pRI7n qPiKhhBDnpeYGxapJ32IsQW89rxUhA+hGSgXf8He2Q== X-Google-Smtp-Source: AGHT+IHGOJeWukTVNuH3xvDlUiPgdeVPjjFBrpqw0bilGbylCV43u5Ik4f0j+Oum1gYfbgenTrdwcI2XwBEmlFpybrySNQ== X-Received: from isaacmanjarres.irv.corp.google.com ([2620:15c:2d:3:4a64:6d71:c7b8:4fc3]) (user=isaacmanjarres job=sendgmr) by 2002:a25:76c8:0:b0:db7:d315:6643 with SMTP id r191-20020a2576c8000000b00db7d3156643mr6416ybc.6.1702078911016; Fri, 08 Dec 2023 15:41:51 -0800 (PST) Date: Fri, 8 Dec 2023 15:41:40 -0800 Mime-Version: 1.0 X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231208234141.2356157-1-isaacmanjarres@google.com> Subject: [PATCH v1] iommu/dma: Trace bounce buffer usage when mapping buffers From: "Isaac J. Manjarres" To: Robin Murphy , Joerg Roedel , Will Deacon , Tom Murphy , Lu Baolu Cc: "Isaac J. Manjarres" , stable@vger.kernel.org, Saravana Kannan , kernel-team@android.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When commit 82612d66d51d ("iommu: Allow the dma-iommu api to use bounce buffers") was introduced, it did not add the logic for tracing the bounce buffer usage from iommu_dma_map_page(). All of the users of swiotlb_tbl_map_single() trace their bounce buffer usage, except iommu_dma_map_page(). This makes it difficult to track SWIOTLB usage from that function. Thus, trace bounce buffer usage from iommu_dma_map_page(). Fixes: 82612d66d51d ("iommu: Allow the dma-iommu api to use bounce buffers") Cc: stable@vger.kernel.org # v5.15+ Cc: Tom Murphy Cc: Lu Baolu Cc: Saravana Kannan Signed-off-by: Isaac J. Manjarres --- drivers/iommu/dma-iommu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 85163a83df2f..037fcf826407 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -29,6 +29,7 @@ #include #include #include +#include =20 #include "dma-iommu.h" =20 @@ -1156,6 +1157,8 @@ static dma_addr_t iommu_dma_map_page(struct device *d= ev, struct page *page, return DMA_MAPPING_ERROR; } =20 + trace_swiotlb_bounced(dev, phys, size); + aligned_size =3D iova_align(iovad, size); phys =3D swiotlb_tbl_map_single(dev, phys, size, aligned_size, iova_mask(iovad), dir, attrs); --=20 2.43.0.472.g3155946c3a-goog