From nobody Sat Feb 7 21:52:52 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58A96EB64D8 for ; Thu, 22 Jun 2023 10:12:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229862AbjFVKMp (ORCPT ); Thu, 22 Jun 2023 06:12:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229830AbjFVKMm (ORCPT ); Thu, 22 Jun 2023 06:12:42 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D7AFE2 for ; Thu, 22 Jun 2023 03:12:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 19FA66179B for ; Thu, 22 Jun 2023 10:12:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8630C433C8; Thu, 22 Jun 2023 10:12:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687428760; bh=xfE+SfdZbVenJR/6vTIRquflwQen9M2hQvN+u8qWUMU=; h=From:To:Cc:Subject:Date:From; b=aAFUIIEIxnNtlXlzMa5qj5LivneC/3DsagG3gKQvdrLByGh+pLn65NP6NqL1sd09q Xwbxw5hJOHt/ZPc/mN2q8fz52Z7j3xDSaYvptczL5PQZ6BYYeo1LsvF+p2+99x4ldK Au9G6Z8UWRGtKHP5lIE8CZqg2xbaC7MkZcHOmfKrYOWvCRKQa6L2ctbNqQg1Kk+4NU Ettls9pSe+NKL1hLa1FRjsUZfAtpDw+T0e5tU0pYGhEZegWl20K7IgY6r+lFnl7RBA TMZAhxjjz1UHI03Sy2ZHAfx+w85+7CwiyTDxD6NXAKGK5v+m9GTtk1ku3X5ZLtjgqz +PYKcUp3+shAg== From: Arnd Bergmann To: Mark Brown , Yingkun Meng Cc: Arnd Bergmann , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH] ASoC: loongson: fix address space confusion Date: Thu, 22 Jun 2023 12:12:22 +0200 Message-Id: <20230622101235.3230941-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Arnd Bergmann The i2s driver uses the mapped __iomem address of the FIFO as the DMA address for the device. This apparently works on loongarch because of the way it handles __iomem pointers as aliases of physical addresses, but this is not portable to other architectures and causes a compiler warning when dma addresses are not the same size as pointers: sound/soc/loongson/loongson_i2s_pci.c: In function 'loongson_i2s_pci_probe': sound/soc/loongson/loongson_i2s_pci.c:110:29: error: cast from pointer to i= nteger of different size [-Werror=3Dpointer-to-int-cast] 110 | tx_data->dev_addr =3D (dma_addr_t)i2s->reg_base + LS_I2S_TX= _DATA; | ^ sound/soc/loongson/loongson_i2s_pci.c:113:29: error: cast from pointer to i= nteger of different size [-Werror=3Dpointer-to-int-cast] 113 | rx_data->dev_addr =3D (dma_addr_t)i2s->reg_base + LS_I2S_RX= _DATA; | ^ Change the driver to instead use the physical address as stored in the PCI BAR resource directly. Since 'dev_addr' is a 32-bit address, I think this results in the same truncated address on loongarch but is otherwise closer to portable code and avoids the warning. Fixes: d84881e06836d ("ASoC: Add support for Loongson I2S controller") Signed-off-by: Arnd Bergmann --- This is only build tested and I don't understand the loongarch specifics that well, please review or test for actual hardware requirements. --- sound/soc/loongson/loongson_i2s_pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/loongson/loongson_i2s_pci.c b/sound/soc/loongson/loo= ngson_i2s_pci.c index 6dcfb17d3276d..fa90361865c6c 100644 --- a/sound/soc/loongson/loongson_i2s_pci.c +++ b/sound/soc/loongson/loongson_i2s_pci.c @@ -107,10 +107,10 @@ static int loongson_i2s_pci_probe(struct pci_dev *pde= v, tx_data =3D &i2s->tx_dma_data; rx_data =3D &i2s->rx_dma_data; =20 - tx_data->dev_addr =3D (dma_addr_t)i2s->reg_base + LS_I2S_TX_DATA; + tx_data->dev_addr =3D pci_resource_start(pdev, 0) + LS_I2S_TX_DATA; tx_data->order_addr =3D i2s->reg_base + LS_I2S_TX_ORDER; =20 - rx_data->dev_addr =3D (dma_addr_t)i2s->reg_base + LS_I2S_RX_DATA; + rx_data->dev_addr =3D pci_resource_start(pdev, 0) + LS_I2S_RX_DATA; rx_data->order_addr =3D i2s->reg_base + LS_I2S_RX_ORDER; =20 tx_data->irq =3D fwnode_irq_get_byname(fwnode, "tx"); --=20 2.39.2