Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2601157lqb; Tue, 28 May 2024 05:17:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVA/+jaUBheFVxWucwC8YcasCaP0MEWRNw8jvqX3fGO/G2SosjZRpkurcniaPx8d7PEcKz/N+OVlPCXgE3SnLRtgl2FSPG6N6hPXSr1Dw== X-Google-Smtp-Source: AGHT+IG/hOIiC69UX51W8Km7Z4HGAb1LkVO7V6LfHIegUyuVzCLxwt9mnA58pz0lhigEmvej78nM X-Received: by 2002:a05:6359:1409:b0:192:5306:23b with SMTP id e5c5f4694b2df-197e5454976mr1640168655d.22.1716898652393; Tue, 28 May 2024 05:17:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716898652; cv=pass; d=google.com; s=arc-20160816; b=mh8kLSJ1nxgj8uRI4RSkND8gx5L8A4PI6rBlzwjjRGjSDchiw1eClgDxVv5UbN66wf zqtNzLyEMWDlPFMl9f3spW95B+MgviSbvhRAFdAUAyXC2Mvex1Mo+9Hr0YCTyxfJlikt qJL6I/+BVENXeo+FGp8OEbqKMcmek4/7eTvF3Zq4l7p7NIqtJaTpMFq3eCGkMsHjHoqo fXlL5L650OoMyH6Q2YbBB+Rl+Gl/Wybt6rtPCPbC+QGxGPFx+qz0Y2jYN7ajkM0zmOZm OAB7iKFhT3k3MFEdWTB8UVBubYpGBdwwem/LmFKVcO7WMiISciy/17rvHGGOKHO/pm0+ gqpg== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=jBkxtLujRP3ruRd84X2CuQMfz+FawoX/VqJcDfor/6I=; fh=e89vzdRr+BbwdlNVLFW2+IXcC5LYOsoQpcJ2f55a7AQ=; b=KG/puxzjOn0qVCXmehGTvpS4W8cHzSKvpj/grYfUoXxtrHXxHanyqftyOZnaPAnhA2 Knh6lIR20tsm0to13jZ/zns6grJzsbjBdKE0vFVmRxISXQStjOsfBs0oz4x2ld0ORgEY 8QKRMp5IzxytEgH3pCJ00tq1j0jCrLDNp+IgIBslxZAQOdXVxWHsivDastNxMKitHAjn +vu3DRfAjeA9L3JgoIB3wmBBQ9OnFS/ecrAXbDty7+qLfM0uHVD4vNjGmPgDGRC+sogA V8CxE9/hUPPMbcvSjv/GUArq3jj9NqLM4G6ocNGIEdYtmidkSt11zNhsJ4q3JERYjOWR yPQA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CXU1iqvM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-192235-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192235-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6822779bd0fsi8547081a12.306.2024.05.28.05.17.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 05:17:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-192235-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CXU1iqvM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-192235-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192235-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 75640B237AD for ; Tue, 28 May 2024 11:58:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3CCAE16D32C; Tue, 28 May 2024 11:58:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CXU1iqvM" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 651E84C97; Tue, 28 May 2024 11:58:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716897487; cv=none; b=jbloxPblioVcOsZv8HKT+TP7pGublWq3GpygqhukfzOOWkiAUDufz3y5/WlPzve0A5PjM0hrMT24ZsVX1egb0dpxUG2EdIs/ohF11KSTrA4ZI78d8XGHz20g8Gp9tqcntGElfEq0Ixs9VFvlWG7l7C+krlovnnnbFNqzXLVEdbs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716897487; c=relaxed/simple; bh=bVWQAYUpyK9YpqqeaTrdId8lboSQEV0GEqaTP7AtzUE=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=dzRvJa6PQudTgE76uTEM4NNBYaplPjTV4gl4712Gtklk5BPiX1VwvviC/R0bB42HxrDvdw+PlH7+MPahQrfmDGs4M4U6grpeUtUd+STCNzolSyjLNWFRavVM5Fl4M20fsiFko58EDmPXO7aET8TTjkOyfwzlMCPMqyfjQD2YQlY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CXU1iqvM; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3EB8EC32781; Tue, 28 May 2024 11:58:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716897486; bh=bVWQAYUpyK9YpqqeaTrdId8lboSQEV0GEqaTP7AtzUE=; h=From:To:Cc:Subject:Date:From; b=CXU1iqvM+KwXqCpsUvZtg6Y8tNJw5XYuUy08OnzwXBOjyYEw+FGW74BFx5kZRTNKw 4o5LU2x8cTaP67/NM4+gjjuslV0zUxfch+averONwsCxuf9dnpAHJgEW3zZJHyFhTZ 7P6q1SE4rYcp8hgS3vnQcMXI/ZBH0WfzNcsjGOqy8LG6cI+hxcHTSSL9p+TnKOgfog thzn53aOXA3xVj0+BAYSv+AjGzECRB/e78/BEsu6S7epcAbm6WZXq7YFn73l8pCg7r WP8u8sIMeaYp+cB7vB2y4q7gBYS9twwdlLB2MjLcsUNJxHdbnviMtskw9md6cOm8aj 2iKo+s02eoo2g== From: Arnd Bergmann To: Srinivas Pandruvada , Jiri Kosina , Benjamin Tissoires , Zhang Lixu Cc: Arnd Bergmann , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] HID: intel-ish-hid: fix cache management mistake Date: Tue, 28 May 2024 13:57:53 +0200 Message-Id: <20240528115802.3122955-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Arnd Bergmann The low-level cache operation on a coherent buffer is incorrect, as coherent DMA memory may not actually be cached. Instead, use a DMA barrier that ensures that the data is visible to the DMA master before the address is and move the memcpy() before the reference. Fixes: 579a267e4617 ("HID: intel-ish-hid: Implement loading firmware from host feature") Signed-off-by: Arnd Bergmann --- I noticed this one while looking at the bug that was fixed in 236049723826 ("HID: intel-ish-hid: Fix build error for COMPILE_TEST") --- drivers/hid/intel-ish-hid/ishtp/loader.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/hid/intel-ish-hid/ishtp/loader.c b/drivers/hid/intel-ish-hid/ishtp/loader.c index 2785b04a2f5a..062d1b25eaa7 100644 --- a/drivers/hid/intel-ish-hid/ishtp/loader.c +++ b/drivers/hid/intel-ish-hid/ishtp/loader.c @@ -33,7 +33,6 @@ #define dev_fmt(fmt) "ISH loader: " fmt -#include #include #include #include @@ -175,10 +174,11 @@ static int prepare_dma_bufs(struct ishtp_device *dev, return -ENOMEM; fragment->fragment_tbl[i].ddr_adrs = cpu_to_le64(dma_addr); + + memcpy(dma_bufs[i], ish_fw->data + offset, fragment->fragment_tbl[i].length); + dma_wmb(); fragment->fragment_tbl[i].length = clamp(ish_fw->size - offset, 0, fragment_size); fragment->fragment_tbl[i].fw_off = offset; - memcpy(dma_bufs[i], ish_fw->data + offset, fragment->fragment_tbl[i].length); - clflush_cache_range(dma_bufs[i], fragment_size); offset += fragment->fragment_tbl[i].length; } -- 2.39.2