Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2839889lqz; Wed, 3 Apr 2024 09:59:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUtvo7Di0OgpQySnyvM1Rq/vrmrMxNZ/JuM9wWFwD43TOrkwcTfjpAsSxV5sGEHskSF5LtGv67901E0ik5nQA8/awHjMeIO0s4yPC1Plw== X-Google-Smtp-Source: AGHT+IHiD5NbXy8ldgR1/rEDdZNf8Cnwgw+CWy2n5VslO0LuH7925WPALndUIOhuvKQy9Wyg0q/I X-Received: by 2002:a05:6214:62a:b0:699:3003:b72f with SMTP id a10-20020a056214062a00b006993003b72fmr115514qvx.48.1712163556802; Wed, 03 Apr 2024 09:59:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712163556; cv=pass; d=google.com; s=arc-20160816; b=hUL2SkGZuFpMznVeTyPHrnoUxHRUvxc84hQRuhCUCZFNc5eMIKSC0+w07ZtdSrS3Sn BwWGy2lwBY7EXV4c1LAGitMfgsj2fMIMryeUM1HFampAYEJITZePFHXjrZmpHvaCJT+o 9wJzmeawL01dek2QzCCh8xBVS/581RM2MpUNm3nmiIsBobBLDp+KcnkL7+0hEZRlV8Ds cIStxtIyBX1hT8EdEgMD5JBVBVbGalSF+jvn4qTwnj/25Xm04SZ/IWIp2nzgLJJaXyTH 2HMDS+Maex26OPl9G3raDcsoE3pNMw1Ds6s3VCYRMXpOlGDXaiJDJrTYUayZ3WC9PDQA /lPA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=5A2rAaj0jSetY3O8zhCQcdlIfXDhy/8qTsCKrp5ejMU=; fh=xnNeM6/qtYtcvHka6fSO7qT0iFVJILLHDNVdhc1uKm4=; b=t9mG4kRlAbiXWaJS3vyhtUFSpNk4HYQm/26siZmfjbRx+mrdjydFCx5ZKaPu7YEyWr naidJ+EhprMShbHPwbHtI95Ecd2N/Yo1VvRRuG/xWOCAy41MuHF3dJzIMUIGcrIigIqR CReP2LSYq63qlTE+XDef5/CCd93JupbnufU5K3VQithUIUCrijXAZqWIdU2FyoDJT6hR RRClsB9iKWiYLUZjNaFdBlQtPv2BrnlQByPGR8zhbrGi2fA05BNFDSXoMBRKCQojvn9f 2K/2QfOwPcSZTwWy7sT8SN8TaD0vcgslz+9r9AH2ztBl8qgE+ZMSn1MAT8Pt7/+R4/CN lPkg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-130235-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130235-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ne17-20020a056214425100b006991ec4536asi3626628qvb.7.2024.04.03.09.59.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 09:59:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-130235-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-130235-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130235-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 8074B1C219C7 for ; Wed, 3 Apr 2024 16:59:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8643C152171; Wed, 3 Apr 2024 16:58:53 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8E73E1514F6 for ; Wed, 3 Apr 2024 16:58:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712163533; cv=none; b=AKP4gz36UaZ1FZM3cZq/DF/P5mxSYLkeD/cyhqW8y6qs9xB6uUDAnusukDtDDn+rvJ/Q+N4imQaZDXR+tflThBeEA5+9kuscsX/yZCbWxB1NoR9MX81qF8PcR9b/UvhpbytRIAUkBxg/UoX52EF01xQ94sV7xwJfNH086by8zTQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712163533; c=relaxed/simple; bh=7VwqYKFNF/DpXJhubaLW94Yg1HPcTUhPVuRncO3Zdrw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=VyGLufumIOMaDyYbn2h2MCTE4EDMVUetQrwXcUktkT+U/yl6wBVl1R/9SLd/++9Hr/ZcFYUHZ8LFpH4LGp22t15fgfNvGCRDVqx1/Ynu6wUrGq4HLvpCNqnpBxbdoKaXJnqQb1qOwakfsrNMwGxVl4qhlfwtKOlSsOoOu+FjWKY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 06E011688; Wed, 3 Apr 2024 09:59:22 -0700 (PDT) Received: from [10.57.54.62] (unknown [10.57.54.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4F5373F64C; Wed, 3 Apr 2024 09:58:49 -0700 (PDT) Message-ID: <69d3bcc5-5b5b-4b52-93fe-4a095e7ccdc6@arm.com> Date: Wed, 3 Apr 2024 17:58:47 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [EXTERNAL] Re: [PATCH 1/1] swiotlb: add a KUnit test suite Content-Language: en-GB To: Linu Cherian , =?UTF-8?B?UGV0ciBUZXNhxZnDrWs=?= Cc: Petr Tesarik , Christoph Hellwig , Marek Szyprowski , open list , "open list:DMA MAPPING HELPERS" , Will Deacon , Michael Kelley , Roberto Sassu References: <20240313092740.192-1-petrtesarik@huaweicloud.com> <20240326030851.GA64024@hyd1403.caveonetworks.com> <20240326130635.64fb3a98@meshulam.tesarici.cz> From: Robin Murphy In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2024-04-03 3:19 pm, Linu Cherian wrote: [...] >>> Should we not try this on a buffer that is mapped with DMA_FROM_DEVICE ? >> >> I'm afraid I don't follow. >> >> AFAICT the direction is a property of the sync operation. In fact, >> swiotlb_tbl_map_single() does not even use its direction parameter at all. >> Removing that parameter is already on my TODO list of cleanups. >> > > Okay. Got it. > >> swiotlb_map() uses its direction parameter only to perform the initial arch >> sync if DMA is non-coherent. >> >> OTOH I may be missing some high-level logical concepts which do not >> correspond to any actual code in the swiotlb implementation, so my use is still >> wrong. >> > > Just thought that the keeping the DMA direction consistent for the map and sync would be more aligned to typical use case. > For example, a buffer used for transmit in case of networking. OTOH, since the API by itself doesn't have such constraints on the direction parameter, may be it makes sense to test those scenarios. Right, SWIOTLB exists to serve the DMA API, so it makes more sense to me to test it in the context of valid DMA API usage than to make up scenarios that aren't representative of real-world usage. The direction is a property of the whole DMA mapping itself, and thus must be passed consistently for every operation on a given mapping. Yes, there is some internal trickery once we get down to the level of calling swiotlb_bounce() itself, but if we're driving the tests through the higher-level public interface then I'd prefer to see that used as expected. Given the whole partial-write-transparency business, the most significant effect of direction should just be that of DMA_TO_DEVICE skipping the copy-out for unmap and sync_for_cpu, so for the sake of coverage you may as well just use DMA_BIDIRECTIONAL everywhere. Thanks, Robin.