Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp10723lqh; Mon, 6 May 2024 09:40:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWIYFyr3cONEUmV7yQmfddI32VNnZn1nqA8p7KwK5plaRVtWwajN2RkmOKjfLMufo/6xo5Bq0VKfmTKaGS9Q7m/g3rst/DEt8cCdmtjCw== X-Google-Smtp-Source: AGHT+IHtcANkvgqbIQwYe/3uGGOw868mkESRXXiZztN7Qx84o2XsQ+sIcdKAtDy8stzfonYDrnta X-Received: by 2002:a17:907:720a:b0:a59:c963:830 with SMTP id dr10-20020a170907720a00b00a59c9630830mr3356107ejc.58.1715013619408; Mon, 06 May 2024 09:40:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715013619; cv=pass; d=google.com; s=arc-20160816; b=EhT5Cgf0VcDfI+0Wc17L9WVDmlVQkqPyT7dlm/ISrs5hFsVnu5orMv6o2eEQyRQ8S/ Gn3Gllftk93Uz0q60M0bEs1yhcXpzlccCp+IBaiZDFYe3X0vKWlDu9b6WDdA0L16ykI6 R6tUQwR9GiEoqU7qa4WBGaj0p8HNNEa3QhKh+skSSZ6rsiIDFeEPfbmAdVEHfPtR5RmA FuYHZv0l14klWDWdNmgiulBeH335SAiqHhjo827XG3Xop35wAC8YAeT/K+T6GXEsHMrl /bSqDcHAhG4FxBiRe1LG67WFLl+MVBOli/C6u3gTFYCLWN/Xy2cqDSqA5QSzuddAf7d3 HU0g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=mbCxyUl0xXnMrCeHULBRH3fDeDz5G+xM5ZK97knxOjE=; fh=E+YQ4b+2+WmTtGk87IBzixc/CJrsHrS/jDhp8wagL9M=; b=L5vhj5XAa+ihngrOqLao1D+bhHNH5rqdMOlP6BjyJID2z5oU4/vcdfWnJ6aKoxD/LF KkLbLJb16GScz3p62NgEOu+5q9Qq6vcqkJNb6/kNdjbCuM3mt1HmqRd9Xie2LcA+BvMi fCPHW549JMMUG5ch4dLGc5KeuaefXzgW8qaT01AJbvB9NqCfy+jcZodibdRI8Am40551 nK6pMQg0X087WKDqkONU150UwD3GWnBoUOu2HC721gzbwn6X4DOZSNaDl4bBIZTg/d2d k/qsgOmNMhr+yiW7UzItelZLvlvw0VMO3uzYHvr5ZqoqRMgV0ldAV4OhOdYCBv+DflQ/ e57A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=2Wk400gV; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-170182-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170182-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id du6-20020a17090772c600b00a59ae816ca0si3064180ejc.1032.2024.05.06.09.40.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 09:40:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170182-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=2Wk400gV; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-170182-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170182-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 279411F22411 for ; Mon, 6 May 2024 16:40:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 17F36156967; Mon, 6 May 2024 16:40:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="2Wk400gV" Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com [209.85.219.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E624C25569 for ; Mon, 6 May 2024 16:40:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715013608; cv=none; b=Sg4tycrdtv8FCPim738Pr95AiEU7rVD9qADkhHH0Wi35SZX+OOcm0cktRpGsY5ompQIWqccwDMBCVZzJLnHk/nW4exNYFfRzA4h84IwwpyV4meFrHRxn1AhCOrAR8Zv/05OjAeAT64ktrgy0r9H+2TotRk0CxT/pWpr5m/SyZ28= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715013608; c=relaxed/simple; bh=mbCxyUl0xXnMrCeHULBRH3fDeDz5G+xM5ZK97knxOjE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=ofJI7MDpHcavZUNavnVhYkrvQPVz+sk4jL70ElE4YWWGoPQQKz3bMi7qcn/aoigGxUB5fqbINl6efwZ4054V0o7x2FEEzb4BhC+mGghVcpYA+lSEZU2V7eP+ODlTl2WM4pg+4JFh557PDV+ZTjrJx12LHqlyMlvNRhh+eeYxR4Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=2Wk400gV; arc=none smtp.client-ip=209.85.219.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-yb1-f176.google.com with SMTP id 3f1490d57ef6-dcc71031680so2202491276.2 for ; Mon, 06 May 2024 09:40:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715013606; x=1715618406; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=mbCxyUl0xXnMrCeHULBRH3fDeDz5G+xM5ZK97knxOjE=; b=2Wk400gVLHv1uH1+oNzd/L5K9GJxlua1f9bGeziUL8iTcDdvMIN8B7NC4cZBTop1rZ zYVRKOkpTGR84qdRXgUUcaCcdXsq4tNYgRRFSsdzKQ9uw9CKzjviGTRm1gZ1OgqwGOkr QY1+CC4eg27bDDREgl0mNUrbHE043/4uncFUDvoY52QoCCdOw2y1B49tsxckkb6+aCpo Al6/UD3G7/8UdYQITwgr6jyhLSp3+MQA/GVInrF3zeO2hKMtulP+1dcbGj1CCtF0rYCM 3vlp/lgAaTeAM6maK9LNY+JENU/UxjSIGa4rxCQ4pammKgYe2mIlvWMj3PYTAMzRlkzp /gkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715013606; x=1715618406; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mbCxyUl0xXnMrCeHULBRH3fDeDz5G+xM5ZK97knxOjE=; b=GA4acYPxTl1rDJq1ASOIrFZXz+l6GRay49M7KLFkF54o92BKlLre0CZf1P3dwmm37P MEF/Ij50lVgYbVhgRJYxiGXuJZg0/uZ+Qf3aXAkCCXOjuJ9Qyt02MzgPAdVuTfPVjG8M au6meHjcStruhyYKqIRlF0gIoLjA8FywkNXtJbbCko88nOzT5Am8mup7/g+miRVBy7VQ sz2DLrakO167Ar66FQiI5sUn01gOdWgmxF6m8RnJVN7j1pBnwVC5TkTgHmQOs2QwT5+1 fO93uFtO0jUvBoXWcCT9cFRewwjdklD3H0GfaQnPFt69b1vLJW3fRUsPJ/C98Da6Vh0a M50Q== X-Forwarded-Encrypted: i=1; AJvYcCXq5IAzYNoqjog3aX+4tPZbjL/Pn4C8gsBPDKzKlKhcbuxS7tAHKwpBS7wZ40TpIibHVxW4fCQiAWUlxhOWpH1RI+JnOEEnsNRBKnhr X-Gm-Message-State: AOJu0YzZsEdccnFlfRksJfitXUtg59r43RE8bScL/wYXEJLOcBcpJ/t9 GcXYUMqcvbLIgN4N40o7XYTme244RuF8gbJp+RmG/MdXJ2X4P4IplhQcZ/mUT2BfHxT3bMuvClN qCxIYTwVZVg6agvND4DVBGtMwvDvSMV69b5Ey X-Received: by 2002:a05:6902:2085:b0:de5:9c4b:dd5c with SMTP id di5-20020a056902208500b00de59c4bdd5cmr12126324ybb.23.1715013605681; Mon, 06 May 2024 09:40:05 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240503183713.1557480-1-tjmercier@google.com> <20240506052955.GA4923@lst.de> <20240506160244.GA16248@lst.de> <20240506161906.GA17237@lst.de> In-Reply-To: <20240506161906.GA17237@lst.de> From: "T.J. Mercier" Date: Mon, 6 May 2024 09:39:53 -0700 Message-ID: Subject: Re: [PATCH] dma-direct: Set SG_DMA_SWIOTLB flag for dma-direct To: Christoph Hellwig Cc: Marek Szyprowski , Robin Murphy , isaacmanjarres@google.com, Catalin Marinas , iommu@lists.linux.dev, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, May 6, 2024 at 9:19=E2=80=AFAM Christoph Hellwig wrote= : > > On Mon, May 06, 2024 at 09:10:40AM -0700, T.J. Mercier wrote: > > I want to reject mapping a dma_buf for a device if any of the pages > > that back the buffer require SWIOTLB. AFAICT there's no way to know > > whether SWIOTLB is used until after calling dma_map_sg, so afterwards > > I'm trying to check. > > You should not check, you simply must handle it by doing the proper > DMA API based ownership management. That doesn't really work for uncached buffers. Since the SWIOTLB bounces are in the sync functions, and avoiding CMO is the point of uncached buffers, it doesn't make sense to try to map uncached buffers that would require SWIOTLB. So unless we can get the DMA API to fail the map in this case (look for DMA_ATTR_SKIP_CPU_SYNC + SWIOTLB?) I'm not sure how else this should be done.