Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1989032lqz; Tue, 2 Apr 2024 04:10:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUVY6W40yCGrVwbJJxAbjnY5ll+pd+oX7BUJbCFn7Ov0iPaZCvTs1SIh8esHEmBJnzskGNTR8aGdDmye6IQrGiiZyqc4c3qOzZlxD2ftA== X-Google-Smtp-Source: AGHT+IEFK5AkS8BbuPUzBDlVL2SXcB7tizXev7V/9LG7tKznA55SjIXGdu/fpCD7aXQENxJoaqUN X-Received: by 2002:a17:906:2b1b:b0:a4e:946a:3b0a with SMTP id a27-20020a1709062b1b00b00a4e946a3b0amr90939ejg.34.1712056240137; Tue, 02 Apr 2024 04:10:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712056240; cv=pass; d=google.com; s=arc-20160816; b=hArj9JrO6LA+L98t62LoP50XrLK1XC7VXGfwo4JQ0zvQLmCsduuFhVLOu4K4IeqoZy N7JFBSTiIcYSDULSiCVRKU/tLqvrbb0hUzmgBfvUR7mzPZrKCGRD6NAjdvE86Jw0cfva fYHKcDs/SZdwiV5ytF/AK9iKuj8gTRZ1tB6ez/ZFm3PuEInEdXekbu+q/NkZoaUJuo73 t2tVBaq76ul2KwED9PIVkVL2aehZhwdgtwlfyTuNwcDBDfedppvASCoDFW10CupMtQln fWV9NlLJuHEVUbA6REaV2Gj7hRVUfqZjKVeXq/31H5XeNbuseskE8pAdrwYtffI5D+aU ZiAQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=OiOC7/jI7nyQDrQG5FxISTh1jru6sM8Zhjq9KWvgL/0=; fh=F9Pioar3zpFEDJ0RDTgA2UahXs1x2etdBjLYZ82NwqE=; b=hPCS92cnmR/5RdJi4rW40N7JXsCtfRo5m+TymYfODu+hEPOVoRiTqderFYMW0p7xwS 2usg83e3nVQiYg9GETpOuB9q42mvW2xi88AdaPteBINcueyLr/J6w2EvdW6v+0Ng5TCd XbFYtZqrH+01NGhF9cfnT+9cARbs76qVRjMbveGG0qx7o1RHg1IsM7p4CzcMi7dwKddE dBCHvWfWC8XifSO581/IF9pTHukuTdlua/rnd9ofQ+XAaBx6peluo749PLKbjhEmuV45 0yYTfCfTQZA6NpEG2nLDKodqA9UAgCwb36KZbkFdtikogqe9QO8jRt5/quCQO82pN1+F F6cw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=KrIKQob8; arc=pass (i=1 spf=pass spfdomain=crapouillou.net dkim=pass dkdomain=crapouillou.net dmarc=pass fromdomain=crapouillou.net); spf=pass (google.com: domain of linux-kernel+bounces-127827-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127827-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id g24-20020a1709063b1800b00a47484f15e9si5515555ejf.241.2024.04.02.04.10.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 04:10:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-127827-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=@crapouillou.net header.s=mail header.b=KrIKQob8; arc=pass (i=1 spf=pass spfdomain=crapouillou.net dkim=pass dkdomain=crapouillou.net dmarc=pass fromdomain=crapouillou.net); spf=pass (google.com: domain of linux-kernel+bounces-127827-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127827-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net 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 A1A5C1F242C4 for ; Tue, 2 Apr 2024 11:10:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3D72F6997B; Tue, 2 Apr 2024 11:10:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=crapouillou.net header.i=@crapouillou.net header.b="KrIKQob8" Received: from aposti.net (aposti.net [89.234.176.197]) (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 B9BFC61691; Tue, 2 Apr 2024 11:10:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=89.234.176.197 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712056216; cv=none; b=RrNJHnJUBJKB3kd8icpJioRwp+y/zQI0U0kRF8Qrl7vzoehwVYniefo1RGdKhTh7euSC819pI1Df1l18P9TQ9bkQUNIrhlM6PJVh3KJtbtAsXx20QDOc2q3eQxe/AFEAlOxjZqggcc9USrobm0XNeLJ1pY9fdFQGW0E9i+CKNRo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712056216; c=relaxed/simple; bh=fBTA8zMJl2WQBKgJqrEBQVJgbaPzDh69waHmvvtjuQM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JTPvYSTDXBcOSTGS0nI44sH8hepYDNCTiIXfcp2k0pW9IVbrpzqCyVMY6dpHMw9YNfDT+ebfNExlP9ZW6IuhffihxWv4+V7S98X4RYpPHhBafGqz74bhqwZpKpp6qRvY2IKQu8f5GXjlPjn/atrJPBH655IYMhfh0BTb0fMCnZY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=crapouillou.net; spf=pass smtp.mailfrom=crapouillou.net; dkim=pass (1024-bit key) header.d=crapouillou.net header.i=@crapouillou.net header.b=KrIKQob8; arc=none smtp.client-ip=89.234.176.197 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=crapouillou.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=crapouillou.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1712056198; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OiOC7/jI7nyQDrQG5FxISTh1jru6sM8Zhjq9KWvgL/0=; b=KrIKQob8dxamqWB3MJ/bkESgmOypnrXE8IJQ0r5of1Cr8y9Tj2fN7O0qfxX44iv1eiRM5J UYP794m8VoRi2Bf8T0i/0f/6ncwi1rWEK9dOrh26Uz9uiSF5vW/4SBAy0aESELyT4/L2dh a2gt4xo8AQbjd3L2ENtWHM5POVeA0bg= From: Paul Cercueil To: Greg Kroah-Hartman Cc: =?UTF-8?q?Christian=20K=C3=B6nig?= , Daniel Vetter , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Paul Cercueil Subject: [PATCH 1/2] usb: gadget: functionfs: Fix inverted DMA fence direction Date: Tue, 2 Apr 2024 13:09:50 +0200 Message-ID: <20240402110951.16376-2-paul@crapouillou.net> In-Reply-To: <20240402110951.16376-1-paul@crapouillou.net> References: <20240402110951.16376-1-paul@crapouillou.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit A "read" fence was installed when the DMABUF was to be written to, and a "write" fence was installed when the DMABUF was to be read from. Besides, dma_resv_usage_rw() should only be used when waiting for fences. Fixes: 7b07a2a7ca02 ("usb: gadget: functionfs: Add DMABUF import interface") Signed-off-by: Paul Cercueil --- drivers/usb/gadget/function/f_fs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index bffbc1dc651f..70e8532127ad 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -1578,6 +1578,7 @@ static int ffs_dmabuf_transfer(struct file *file, struct ffs_dmabuf_priv *priv; struct ffs_dma_fence *fence; struct usb_request *usb_req; + enum dma_resv_usage resv_dir; struct dma_buf *dmabuf; struct ffs_ep *ep; bool cookie; @@ -1665,8 +1666,9 @@ static int ffs_dmabuf_transfer(struct file *file, dma_fence_init(&fence->base, &ffs_dmabuf_fence_ops, &priv->lock, priv->context, seqno); - dma_resv_add_fence(dmabuf->resv, &fence->base, - dma_resv_usage_rw(epfile->in)); + resv_dir = epfile->in ? DMA_RESV_USAGE_WRITE : DMA_RESV_USAGE_READ; + + dma_resv_add_fence(dmabuf->resv, &fence->base, resv_dir); dma_resv_unlock(dmabuf->resv); /* Now that the dma_fence is in place, queue the transfer. */ -- 2.43.0