From patchwork Tue Mar 26 19:58:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13604937 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8EE01C6FD1F for ; Tue, 26 Mar 2024 19:58:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wc/FdC5qch0m/SEIno4u4AJXQNjKJf7mNWHqVwoi0Do=; b=ITX5pNrLpyG3yY n045rt6jWajJ0RLRia2kaEA8YCBcDqdtiPUh9iadpiOvUVliMQJVFLmKMe96abp2vUh7uLwCVJKP1 IbL6HF9UGBDtXNNCx9bQo+mhjg0WHS5Rq06bBgFy7MlpjRvDsVVktivzaSWpKL9n26mP4DK+zgXWn F8vzrG8sTjmz3lAg58wZjInXEioCzCG8g7yJbU+kIMtL55MfKCBYtsNBw07fS1uaiwhq3nliXxP6B p1248g2p3Ekz0km7+7Mfi6clhRzXLAaPvUAgkLkpsByXbrb5UnkSm9o6qXasw9wX9Bjv2fxeGcDcu ldqhcP+zzDJFzjPb+4Qw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpCwY-00000006Eh3-0wpd; Tue, 26 Mar 2024 19:58:46 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpCwC-00000006EZ8-2Br8; Tue, 26 Mar 2024 19:58:30 +0000 Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 886A81211; Tue, 26 Mar 2024 20:57:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1711483069; bh=NOOXMotqlANDklHCIQd9xpIBR4UrQSUA1aIhSFEYwl4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cEFgeM1SjYUBwFoJdV8tdgMy4rceDRa5Wtm94TukJo0JhVLwiwq3XVcoPb8RM0cwF pEng6rZl9mmvh9KHXFzbn13fUylazlM+0fHHW2Nss3YSnfJkLzCeoZgqXAUrk9v/iO lWLasM4EAEWwl9gGGpIqsbwL+RXEaedXbwi4g0TI= From: Laurent Pinchart To: devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org Cc: Dave Stevenson , Naushir Patuck , Broadcom internal kernel review list , Conor Dooley , Florian Fainelli , Krzysztof Kozlowski , Nicolas Saenz Julienne , Ray Jui , Rob Herring , Scott Branden , Stefan Wahren Subject: [PATCH v2 2/3] firmware: raspberrypi: Use correct device for DMA mappings Date: Tue, 26 Mar 2024 21:58:06 +0200 Message-ID: <20240326195807.15163-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240326195807.15163-1-laurent.pinchart@ideasonboard.com> References: <20240326195807.15163-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240326_125826_855294_7944EB16 X-CRM114-Status: GOOD ( 11.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The buffer used to transfer data over the mailbox interface is mapped using the client's device. This is incorrect, as the device performing the DMA transfer is the mailbox itself. Fix it by using the mailbox controller device instead. This requires including the mailbox_controller.h header to dereference the mbox_chan and mbox_controller structures. The header is not meant to be included by clients. This could be fixed by extending the client API with a function to access the controller's device. Fixes: 4e3d60656a72 ("ARM: bcm2835: Add the Raspberry Pi firmware driver") Signed-off-by: Laurent Pinchart --- drivers/firmware/raspberrypi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c index 322aada20f74..ac34876a97f8 100644 --- a/drivers/firmware/raspberrypi.c +++ b/drivers/firmware/raspberrypi.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -97,8 +98,8 @@ int rpi_firmware_property_list(struct rpi_firmware *fw, if (size & 3) return -EINVAL; - buf = dma_alloc_coherent(fw->cl.dev, PAGE_ALIGN(size), &bus_addr, - GFP_ATOMIC); + buf = dma_alloc_coherent(fw->chan->mbox->dev, PAGE_ALIGN(size), + &bus_addr, GFP_ATOMIC); if (!buf) return -ENOMEM; @@ -126,7 +127,7 @@ int rpi_firmware_property_list(struct rpi_firmware *fw, ret = -EINVAL; } - dma_free_coherent(fw->cl.dev, PAGE_ALIGN(size), buf, bus_addr); + dma_free_coherent(fw->chan->mbox->dev, PAGE_ALIGN(size), buf, bus_addr); return ret; }