Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp10712633rwd; Thu, 22 Jun 2023 03:58:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4HFzm+iOMyHOJx4v7w2iWMc8C/pXmtPVjlCph3G/vy6jKiK8Ke+8pttXADI+Mn11q/1Lyz X-Received: by 2002:a17:902:d488:b0:1b6:86ff:9363 with SMTP id c8-20020a170902d48800b001b686ff9363mr6679110plg.41.1687431493344; Thu, 22 Jun 2023 03:58:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687431493; cv=none; d=google.com; s=arc-20160816; b=sD7j1PPkZzUJJassmKuvecMeP/eIPJ9xFVKLwnRZyzyDHcN5WtTbpWHr4j8qbNcoOb 99oDM1TcbK7OwFxwPJMF+9bxBCwS8F1aX8wRBdvciCCsI7nxDZJ3jzYstwAVgkilteR1 w4S95pMieZDdje1P3UYNd1nhXlLJocxsdccusGrbyyZpqlcjWqjBcHRljX/wfBUtEqd4 8zrDiIjeeervGXdkf6pnnKgrRztJHWbXVNiGhzARYWZUC8Wv30aobVDUw1mZdRmF38v5 YqHudHjWKlCFN/YNdKJktcLxObFHjlc+cZTuN+uRbvfzD/ixN2WsB4NaQiwGd1cZUi1A gSEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=1zzttlWXfsxj9H3My5iFEILenU7bbsVoocMBHe2d+kU=; b=bgWPjADgPd5ipwPa7le06jTR/NJ/ePJorzR4ogT9Nn002hKjXDFabBq5plTbu0FkHw UqUP4lC/X+GN36cp5MZt3VcMiuxUeml9cWCdt1vS4YgTvZLEcseH4n9/xs49bVnxEFd+ HFfwrW6/EFMj4/PMw+c0mqkZtPlspkNYlRHkHo1M3vlfnfWNTL1Wk93+npD0tftTG84V wnL6BqH6sLvqJGIbfp1itemVCScsNXN1Zvm25FoBdIuPphmeyEIH5dRNmyIDojz/axGY HU8M8AhkrKStaVa+qwWYOf0tmlZI4ZgrLYLhG/UGZQU2b1Z5Sk8AdCdIVAVHhN7eaqZ8 aQDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aAFUIIEI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t3-20020a17090340c300b001b3c40cae6dsi1740916pld.342.2023.06.22.03.58.01; Thu, 22 Jun 2023 03:58:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aAFUIIEI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229954AbjFVKMo (ORCPT + 99 others); Thu, 22 Jun 2023 06:12:44 -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: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 integer of different size [-Werror=pointer-to-int-cast] 110 | tx_data->dev_addr = (dma_addr_t)i2s->reg_base + LS_I2S_TX_DATA; | ^ sound/soc/loongson/loongson_i2s_pci.c:113:29: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast] 113 | rx_data->dev_addr = (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/loongson_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 *pdev, tx_data = &i2s->tx_dma_data; rx_data = &i2s->rx_dma_data; - tx_data->dev_addr = (dma_addr_t)i2s->reg_base + LS_I2S_TX_DATA; + tx_data->dev_addr = pci_resource_start(pdev, 0) + LS_I2S_TX_DATA; tx_data->order_addr = i2s->reg_base + LS_I2S_TX_ORDER; - rx_data->dev_addr = (dma_addr_t)i2s->reg_base + LS_I2S_RX_DATA; + rx_data->dev_addr = pci_resource_start(pdev, 0) + LS_I2S_RX_DATA; rx_data->order_addr = i2s->reg_base + LS_I2S_RX_ORDER; tx_data->irq = fwnode_irq_get_byname(fwnode, "tx"); -- 2.39.2