Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp19203pxb; Wed, 18 Aug 2021 14:48:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxC2hciuxjC8NvZC26nqiwWNeoaX3YetFZpKAFNv37rbBv+4HG1q6m7YpRrPIKgt6BCVLAh X-Received: by 2002:a5e:d60e:: with SMTP id w14mr8775764iom.135.1629323296760; Wed, 18 Aug 2021 14:48:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629323296; cv=none; d=google.com; s=arc-20160816; b=nlqBcPpod7OQehklCrACpvjlFhviui1ew57mg4yT5h3fpopCYQHw4PptZueG74i7bO 5Pu3cBReW8MPcQwMw//SlmHIa8nC99OsjqBvbVa3FkTjRqi0RFMWD2H9JegZC6+87Tp2 bTgf2cHeYbBa/vnsiazjMXQO162VDD61kMIkkILMKQ2hs+ngnnISRE9DBg+h9K6JSmDS NTotZkBcCP26meLX+V5n+Ukni3VswiZqpCk84N6KG0Zc9saent57mYssg57eaGlMMqhZ 3Ms+jHFBCclkjyLsipCXkr4JcJpEqCJvCdVFLii6Uv5+LdYcdS+gOw8dIraw/O5DHyx7 5ETA== 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=NWf6JmEEvSLlYTGA0z2y6P2/u/8zsC+hN4OppuKmJws=; b=i4gwbtmc+dFivIxjo7/hOCbtXH3EEoxQhN9SYsUP01YydHwv3woK934a4aMJnodGIC /KQsPPo4QzHopYg1poBbxn0wiM6uFdgitTpX1lUkUjIP6AyAwYok6/y1An+3ROXbuXQY MP6kVmLI5jwDNK0SK1INcSHUF280BscttT0PWN10/GEsqoL8Vbl6ULMzR7dib152OyBT 9pic+V8EeVCE4VoaBHfC4R5S3dHoqwYUnDsxMMwYvfcFa6nFJKnK0nION2zGCbIyKk+m kGo9vsrKAB6F6PuizUt2Qwa6aIVknPxqQupEIhmHVmQSwSLlZtsq9I12Z6a1dIknHkJm 4b6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b=g9DrdKzL; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i13si990671ilk.122.2021.08.18.14.47.49; Wed, 18 Aug 2021 14:48:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b=g9DrdKzL; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234115AbhHRVpm (ORCPT + 99 others); Wed, 18 Aug 2021 17:45:42 -0400 Received: from phobos.denx.de ([85.214.62.61]:44286 "EHLO phobos.denx.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234045AbhHRVpl (ORCPT ); Wed, 18 Aug 2021 17:45:41 -0400 Received: from localhost.localdomain (unknown [IPv6:2804:14c:485:504a:609d:5443:34fc:77bc]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: festevam@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 101F6804E7; Wed, 18 Aug 2021 23:45:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1629323104; bh=NWf6JmEEvSLlYTGA0z2y6P2/u/8zsC+hN4OppuKmJws=; h=From:To:Cc:Subject:Date:From; b=g9DrdKzLPX2kUCBeXLVWp1Awj6Ryu9tl4IGW4B8whjo0syjPVskhO9IVRlcaWPvFm M2F5Cin+EYacL8PV2RNC4C1CQKK1VOKpkBeYQ+IKekju9SNatoEzJcrwJPElu6lZv1 iQtOzbmlpt8sCfAylHt0lnXRayXyNLwYtcZfUt/JL7FAmJulWGq03ThJht7h260lCn TCfaH6VQ+eFksvGyrnSlzRLDuN7GHHYy4z0g0UQlVNzTph9MmvW8TkRDp3uqNUcX9J egTvS06H8LNi6UgMcJyWO2hN+UsEsmlocce/boTQjOMp3GSCXkv5Ug11YypNwx8PD6 Z5f5n+4Iw/yPw== From: Fabio Estevam To: kvalo@codeaurora.org Cc: ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, hch@lst.de, erik.stromdahl@gmail.com, peter.oh@eero.com, aspriel@gmail.com, marex@denx.de, Fabio Estevam Subject: [PATCH v2] ath10k: Do not call dma_alloc_coherent() for SDIO and USB Date: Wed, 18 Aug 2021 18:44:51 -0300 Message-Id: <20210818214451.1969739-1-festevam@denx.de> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org When running the "hostapd" application on a i.MX7-based board with an ath10k device connected via SDIO, the following warning is seen: ------------[ cut here ]------------ WARNING: CPU: 0 PID: 489 at kernel/dma/mapping.c:427 dma_alloc_attrs+0xd0/0x114 Modules linked in: ath10k_sdio ath10k_core ath CPU: 0 PID: 489 Comm: hostapd Not tainted 5.10.48-stable-standard #1 Hardware name: Freescale i.MX7 Dual (Device Tree) [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [] (show_stack) from [] (dump_stack+0xdc/0x104) [] (dump_stack) from [] (__warn+0xd8/0x114) [] (__warn) from [] (warn_slowpath_fmt+0x60/0xbc) [] (warn_slowpath_fmt) from [] (dma_alloc_attrs+0xd0/0x114) [] (dma_alloc_attrs) from [] (ath10k_add_interface+0x2f0/0x1094 [ath10k_core]) [] (ath10k_add_interface [ath10k_core]) from [] (drv_add_interface+0x88/0x2fc) As explained by Christoph Hellwig: "Looking at the ath10k code ar->dev is set by ath10k_core_create, which has multiple callers. For ath10k_pci_probe it is a pci_dev, which should always have a dma_mask. For ath10k_ahb_probe is a device tree probed platform_device, which should have a dma mask. For ath10k_sdio_probe it is a sdio_func, which from my understanding is a virtual device can't do DMA itself. For ath10k_snoc_probe it is a platform device with an explicit dma_set_mask_and_coherent and above so the dma_mask is set. For ath10k_usb_probe it is an usb device which can't do USB." Fix the problem by not calling dma_alloc_coherent() when the device is not DMA capable, such as SDIO and USB. Signed-off-by: Fabio Estevam --- Changes since v1: - Simplify the check by comparing against ATH10K_DEV_TYPE_HL drivers/net/wireless/ath/ath10k/mac.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c index c272b290fa73..e85c3f107d2e 100644 --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c @@ -5576,15 +5576,17 @@ static int ath10k_add_interface(struct ieee80211_hw *hw, if (vif->type == NL80211_IFTYPE_ADHOC || vif->type == NL80211_IFTYPE_MESH_POINT || vif->type == NL80211_IFTYPE_AP) { - arvif->beacon_buf = dma_alloc_coherent(ar->dev, - IEEE80211_MAX_FRAME_LEN, - &arvif->beacon_paddr, - GFP_ATOMIC); - if (!arvif->beacon_buf) { - ret = -ENOMEM; - ath10k_warn(ar, "failed to allocate beacon buffer: %d\n", - ret); - goto err; + if (ar->bus_param.dev_type != ATH10K_DEV_TYPE_HL) { + arvif->beacon_buf = dma_alloc_coherent(ar->dev, + IEEE80211_MAX_FRAME_LEN, + &arvif->beacon_paddr, + GFP_ATOMIC); + if (!arvif->beacon_buf) { + ret = -ENOMEM; + ath10k_warn(ar, "failed to allocate beacon buffer: %d\n", + ret); + goto err; + } } } if (test_bit(ATH10K_FLAG_HW_CRYPTO_DISABLED, &ar->dev_flags)) -- 2.25.1