From patchwork Tue Jun 25 10:29:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11015245 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F39FC14B6 for ; Tue, 25 Jun 2019 10:30:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E334028BA0 for ; Tue, 25 Jun 2019 10:30:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7A3828BE1; Tue, 25 Jun 2019 10:30:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A7A628BC1 for ; Tue, 25 Jun 2019 10:30:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731957AbfFYK3n (ORCPT ); Tue, 25 Jun 2019 06:29:43 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:48604 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731939AbfFYK3j (ORCPT ); Tue, 25 Jun 2019 06:29:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=6PRfHQ3NGRfwo8k6M0Ah5l3x8Qxa9hRyvFNjcHO4MeQ=; b=cgIu0kcyYdKVV/eHSTd/1vuMCG vw9Ww6uPJv3WwC5FyAIr2oKa78ZjAZbMJHoIWrrkiR3ksjpNBpMuVVf21RvuitABoj8Mkd4dhSrN5 Zkri+jSdEsAqqtBh16WQ8MZowcPJTDHN/sJI4HoDXvg7SFQiVyTKfpkAd3gV/YOzz6eklgsAxjLfo Xu/nqaWkLHcFOAj3g8rkxGWUcTm0X85lSHIjrRwoXroqjrX2BJ8l0NuLpBVbBGV7sDYUpAq/Gq5qD ldbmwkfw52OOvExsW/OL5ez9vRCG6WDu/MkWyHPItHwh6P8Z7ruxUgs32KO6pYdcpIykCQmOSBePP 1ZgTjRqQ==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hfihl-0005Su-UF; Tue, 25 Jun 2019 10:29:38 +0000 From: Christoph Hellwig To: Larry Finger , Kalle Valo Cc: b43-dev@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] b43legacy: remove b43legacy_dma_set_mask Date: Tue, 25 Jun 2019 12:29:29 +0200 Message-Id: <20190625102932.32257-2-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190625102932.32257-1-hch@lst.de> References: <20190625102932.32257-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP These days drivers are not required to fallback to smaller DMA masks, but can just set the largest mask they support, removing the need for this trial and error logic. Signed-off-by: Christoph Hellwig Tested-by: Larry Finger --- drivers/net/wireless/broadcom/b43legacy/dma.c | 39 +------------------ 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/drivers/net/wireless/broadcom/b43legacy/dma.c b/drivers/net/wireless/broadcom/b43legacy/dma.c index 2ce1537d983c..0c2de20622e3 100644 --- a/drivers/net/wireless/broadcom/b43legacy/dma.c +++ b/drivers/net/wireless/broadcom/b43legacy/dma.c @@ -797,43 +797,6 @@ void b43legacy_dma_free(struct b43legacy_wldev *dev) dma->tx_ring0 = NULL; } -static int b43legacy_dma_set_mask(struct b43legacy_wldev *dev, u64 mask) -{ - u64 orig_mask = mask; - bool fallback = false; - int err; - - /* Try to set the DMA mask. If it fails, try falling back to a - * lower mask, as we can always also support a lower one. */ - while (1) { - err = dma_set_mask_and_coherent(dev->dev->dma_dev, mask); - if (!err) - break; - if (mask == DMA_BIT_MASK(64)) { - mask = DMA_BIT_MASK(32); - fallback = true; - continue; - } - if (mask == DMA_BIT_MASK(32)) { - mask = DMA_BIT_MASK(30); - fallback = true; - continue; - } - b43legacyerr(dev->wl, "The machine/kernel does not support " - "the required %u-bit DMA mask\n", - (unsigned int)dma_mask_to_engine_type(orig_mask)); - return -EOPNOTSUPP; - } - if (fallback) { - b43legacyinfo(dev->wl, "DMA mask fallback from %u-bit to %u-" - "bit\n", - (unsigned int)dma_mask_to_engine_type(orig_mask), - (unsigned int)dma_mask_to_engine_type(mask)); - } - - return 0; -} - int b43legacy_dma_init(struct b43legacy_wldev *dev) { struct b43legacy_dma *dma = &dev->dma; @@ -844,7 +807,7 @@ int b43legacy_dma_init(struct b43legacy_wldev *dev) dmamask = supported_dma_mask(dev); type = dma_mask_to_engine_type(dmamask); - err = b43legacy_dma_set_mask(dev, dmamask); + err = dma_set_mask_and_coherent(dev->dev->dma_dev, dmamask); if (err) { #ifdef CONFIG_B43LEGACY_PIO b43legacywarn(dev->wl, "DMA for this device not supported. " From patchwork Tue Jun 25 10:29:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11015247 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 767211575 for ; Tue, 25 Jun 2019 10:30:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69EEF28BC8 for ; Tue, 25 Jun 2019 10:30:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C0F528BCE; Tue, 25 Jun 2019 10:30:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC547285E5 for ; Tue, 25 Jun 2019 10:30:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728085AbfFYKaN (ORCPT ); Tue, 25 Jun 2019 06:30:13 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:48646 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731567AbfFYK3l (ORCPT ); Tue, 25 Jun 2019 06:29:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=rkl/uuobm6HdnQQiw4phyXCzZ7W1wU0AW7nL80/+SRc=; b=r48n87qmXKWVn7chb2eV1XCzLB cKzby3GZvg/e0AP+Nru9toZGD5Y/W/LsFXXaB3xwLygLHlgMEqih+ubEWFgG4PhyvhOERcbVJ0aCD YtKW9/3ei1uS8N1Uad6SFFmAy49fBXdg1yLJHofljw4XSKPiFrLRJWqjTQFfRXM+g2cgoGQGoJEBq 2ycDHs+76zQIdvfdv2eYv+O0SRRJKhH4A3uLNiDr9UOmF7L4G7C+QUEbWkeHJDyRq7tPgEGkcVnBC cGlfXuaa9YNfO4K5HFdwMDaoLVsOGUAzyMMZs1gdyofAS3ge9bIhgI4qbwVwWPs6l7b3z2ByG3gHh NwHSReaA==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hfiho-0005TL-5H; Tue, 25 Jun 2019 10:29:40 +0000 From: Christoph Hellwig To: Larry Finger , Kalle Valo Cc: b43-dev@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] b43legacy: simplify engine type / DMA mask selection Date: Tue, 25 Jun 2019 12:29:30 +0200 Message-Id: <20190625102932.32257-3-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190625102932.32257-1-hch@lst.de> References: <20190625102932.32257-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Return the engine type from the function looking at the registers, and just derive the DMA mask from that in the one place we care. Signed-off-by: Christoph Hellwig --- drivers/net/wireless/broadcom/b43legacy/dma.c | 20 +++---------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/drivers/net/wireless/broadcom/b43legacy/dma.c b/drivers/net/wireless/broadcom/b43legacy/dma.c index 0c2de20622e3..e66d05ae2466 100644 --- a/drivers/net/wireless/broadcom/b43legacy/dma.c +++ b/drivers/net/wireless/broadcom/b43legacy/dma.c @@ -616,7 +616,7 @@ static void free_all_descbuffers(struct b43legacy_dmaring *ring) } } -static u64 supported_dma_mask(struct b43legacy_wldev *dev) +static enum b43legacy_dmatype b43legacy_engine_type(struct b43legacy_wldev *dev) { u32 tmp; u16 mmio_base; @@ -628,18 +628,7 @@ static u64 supported_dma_mask(struct b43legacy_wldev *dev) tmp = b43legacy_read32(dev, mmio_base + B43legacy_DMA32_TXCTL); if (tmp & B43legacy_DMA32_TXADDREXT_MASK) - return DMA_BIT_MASK(32); - - return DMA_BIT_MASK(30); -} - -static enum b43legacy_dmatype dma_mask_to_engine_type(u64 dmamask) -{ - if (dmamask == DMA_BIT_MASK(30)) - return B43legacy_DMA_30BIT; - if (dmamask == DMA_BIT_MASK(32)) return B43legacy_DMA_32BIT; - B43legacy_WARN_ON(1); return B43legacy_DMA_30BIT; } @@ -801,13 +790,10 @@ int b43legacy_dma_init(struct b43legacy_wldev *dev) { struct b43legacy_dma *dma = &dev->dma; struct b43legacy_dmaring *ring; + enum b43legacy_dmatype type = b43legacy_engine_type(dev); int err; - u64 dmamask; - enum b43legacy_dmatype type; - dmamask = supported_dma_mask(dev); - type = dma_mask_to_engine_type(dmamask); - err = dma_set_mask_and_coherent(dev->dev->dma_dev, dmamask); + err = dma_set_mask_and_coherent(dev->dev->dma_dev, DMA_BIT_MASK(type)); if (err) { #ifdef CONFIG_B43LEGACY_PIO b43legacywarn(dev->wl, "DMA for this device not supported. " From patchwork Tue Jun 25 10:29:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11015237 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A0E3A14B6 for ; Tue, 25 Jun 2019 10:30:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93D5E28BE4 for ; Tue, 25 Jun 2019 10:30:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 876A928BE5; Tue, 25 Jun 2019 10:30:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F277C28BDD for ; Tue, 25 Jun 2019 10:30:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731983AbfFYK3r (ORCPT ); Tue, 25 Jun 2019 06:29:47 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:49112 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731939AbfFYK3q (ORCPT ); Tue, 25 Jun 2019 06:29:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=0y+EkNmxmNFKoAnJ+llx9gsPNEjWrfJ32e7lcmuW1Qk=; b=AQTn+w72W/klcp4DMDBpwA3Bhy 5DmYdjJzY3eqHj5wbpQDqJa4gwhJsgBSDKrd6qqFd03GdIv4/BCqsHPjQSK2ZaWG7y7PpGSlD8cc+ NRRo2RpvSLk0OpAlWtSyEqnJYNtbtkGIpm8mqh3shzx/ruc7DmV1w63ZS+VfhjweJgDSl4LUE2tJC HBQzrwVWzI6NrUU+ppxbg+D+xEJbeWPgtfmsZF9JIwb6FSKtwk5g5ALzsctiur6jcoVDzcrmpccJg WabVtfau/MV8V/Rjmni0Bbtj2VoWSYOq4s88gzAVn29ciKQz+MJwMnPjd8dDtfCVPgQm/kKdTwRDw diR8YfgQ==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hfihq-0005UB-KE; Tue, 25 Jun 2019 10:29:43 +0000 From: Christoph Hellwig To: Larry Finger , Kalle Valo Cc: b43-dev@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] b43: remove b43_dma_set_mask Date: Tue, 25 Jun 2019 12:29:31 +0200 Message-Id: <20190625102932.32257-4-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190625102932.32257-1-hch@lst.de> References: <20190625102932.32257-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP These days drivers are not required to fallback to smaller DMA masks, but can just set the largest mask they support, removing the need for this trial and error logic. Signed-off-by: Christoph Hellwig --- drivers/net/wireless/broadcom/b43/dma.c | 43 +++---------------------- 1 file changed, 5 insertions(+), 38 deletions(-) diff --git a/drivers/net/wireless/broadcom/b43/dma.c b/drivers/net/wireless/broadcom/b43/dma.c index b34e51933257..1d5ace4d3372 100644 --- a/drivers/net/wireless/broadcom/b43/dma.c +++ b/drivers/net/wireless/broadcom/b43/dma.c @@ -1056,42 +1056,6 @@ void b43_dma_free(struct b43_wldev *dev) destroy_ring(dma, tx_ring_mcast); } -static int b43_dma_set_mask(struct b43_wldev *dev, u64 mask) -{ - u64 orig_mask = mask; - bool fallback = false; - int err; - - /* Try to set the DMA mask. If it fails, try falling back to a - * lower mask, as we can always also support a lower one. */ - while (1) { - err = dma_set_mask_and_coherent(dev->dev->dma_dev, mask); - if (!err) - break; - if (mask == DMA_BIT_MASK(64)) { - mask = DMA_BIT_MASK(32); - fallback = true; - continue; - } - if (mask == DMA_BIT_MASK(32)) { - mask = DMA_BIT_MASK(30); - fallback = true; - continue; - } - b43err(dev->wl, "The machine/kernel does not support " - "the required %u-bit DMA mask\n", - (unsigned int)dma_mask_to_engine_type(orig_mask)); - return -EOPNOTSUPP; - } - if (fallback) { - b43info(dev->wl, "DMA mask fallback from %u-bit to %u-bit\n", - (unsigned int)dma_mask_to_engine_type(orig_mask), - (unsigned int)dma_mask_to_engine_type(mask)); - } - - return 0; -} - /* Some hardware with 64-bit DMA seems to be bugged and looks for translation * bit in low address word instead of high one. */ @@ -1120,9 +1084,12 @@ int b43_dma_init(struct b43_wldev *dev) dmamask = supported_dma_mask(dev); type = dma_mask_to_engine_type(dmamask); - err = b43_dma_set_mask(dev, dmamask); - if (err) + err = dma_set_mask_and_coherent(dev->dev->dma_dev, dmamask); + if (err) { + b43err(dev->wl, "The machine/kernel does not support " + "the required %u-bit DMA mask\n", type); return err; + } switch (dev->dev->bus_type) { #ifdef CONFIG_B43_BCMA From patchwork Tue Jun 25 10:29:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11015229 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1661E1575 for ; Tue, 25 Jun 2019 10:30:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 08D6C285E5 for ; Tue, 25 Jun 2019 10:30:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F146B28BDB; Tue, 25 Jun 2019 10:30:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 858D128BC6 for ; Tue, 25 Jun 2019 10:30:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732013AbfFYK3v (ORCPT ); Tue, 25 Jun 2019 06:29:51 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:49418 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731939AbfFYK3t (ORCPT ); Tue, 25 Jun 2019 06:29:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=89G6EnwERirS4pDlPNUguptOr/aOmuUOxBTr3VXKKtI=; b=EYAj5n9Onzxz1XWV3DkgWAEsti mDpDQPPYiczl1tyYrHvdfWc/Y4kWdwSyqrQT/RJQkf8d8R/AQH3y2i9/e6Cu/9yvaBv9dquWTHb3D bJhW3gA7ZT2uR3QnNGqKK/Tu6u8ePt84doINubL+ydG58jP87rb13seIQPKE1/SKTgl0VFGT7LhfJ eMDjhH++IhhTS4h3BLAsTRQIJpREN3rO3NQ0lsZu+d1tt+/rMqLXJV1jNNUiMoJmYMGzyZdiEWgNZ TTTydT0pg7vZfddzox44QpDBJ3XeSJplhzvneQpcXeTGrKvJpyHBuXSkDJwEcxVQG+FqnTjwBQG2d ABfUns2g==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hfihs-0005Xp-VP; Tue, 25 Jun 2019 10:29:45 +0000 From: Christoph Hellwig To: Larry Finger , Kalle Valo Cc: b43-dev@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] b43: simplify engine type / DMA mask selection Date: Tue, 25 Jun 2019 12:29:32 +0200 Message-Id: <20190625102932.32257-5-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190625102932.32257-1-hch@lst.de> References: <20190625102932.32257-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Return the engine type from the function looking at the registers, and just derive the DMA mask from that in the one place we care. Signed-off-by: Christoph Hellwig --- drivers/net/wireless/broadcom/b43/dma.c | 28 ++++++------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/drivers/net/wireless/broadcom/b43/dma.c b/drivers/net/wireless/broadcom/b43/dma.c index 1d5ace4d3372..e8958edb9094 100644 --- a/drivers/net/wireless/broadcom/b43/dma.c +++ b/drivers/net/wireless/broadcom/b43/dma.c @@ -810,7 +810,7 @@ static void free_all_descbuffers(struct b43_dmaring *ring) } } -static u64 supported_dma_mask(struct b43_wldev *dev) +static enum b43_dmatype b43_engine_type(struct b43_wldev *dev) { u32 tmp; u16 mmio_base; @@ -820,14 +820,14 @@ static u64 supported_dma_mask(struct b43_wldev *dev) case B43_BUS_BCMA: tmp = bcma_aread32(dev->dev->bdev, BCMA_IOST); if (tmp & BCMA_IOST_DMA64) - return DMA_BIT_MASK(64); + return B43_DMA_64BIT; break; #endif #ifdef CONFIG_B43_SSB case B43_BUS_SSB: tmp = ssb_read32(dev->dev->sdev, SSB_TMSHIGH); if (tmp & SSB_TMSHIGH_DMA64) - return DMA_BIT_MASK(64); + return B43_DMA_64BIT; break; #endif } @@ -836,20 +836,7 @@ static u64 supported_dma_mask(struct b43_wldev *dev) b43_write32(dev, mmio_base + B43_DMA32_TXCTL, B43_DMA32_TXADDREXT_MASK); tmp = b43_read32(dev, mmio_base + B43_DMA32_TXCTL); if (tmp & B43_DMA32_TXADDREXT_MASK) - return DMA_BIT_MASK(32); - - return DMA_BIT_MASK(30); -} - -static enum b43_dmatype dma_mask_to_engine_type(u64 dmamask) -{ - if (dmamask == DMA_BIT_MASK(30)) - return B43_DMA_30BIT; - if (dmamask == DMA_BIT_MASK(32)) return B43_DMA_32BIT; - if (dmamask == DMA_BIT_MASK(64)) - return B43_DMA_64BIT; - B43_WARN_ON(1); return B43_DMA_30BIT; } @@ -1078,13 +1065,10 @@ static bool b43_dma_translation_in_low_word(struct b43_wldev *dev, int b43_dma_init(struct b43_wldev *dev) { struct b43_dma *dma = &dev->dma; + enum b43_dmatype type = b43_engine_type(dev); int err; - u64 dmamask; - enum b43_dmatype type; - dmamask = supported_dma_mask(dev); - type = dma_mask_to_engine_type(dmamask); - err = dma_set_mask_and_coherent(dev->dev->dma_dev, dmamask); + err = dma_set_mask_and_coherent(dev->dev->dma_dev, DMA_BIT_MASK(type)); if (err) { b43err(dev->wl, "The machine/kernel does not support " "the required %u-bit DMA mask\n", type); @@ -1793,7 +1777,7 @@ void b43_dma_direct_fifo_rx(struct b43_wldev *dev, enum b43_dmatype type; u16 mmio_base; - type = dma_mask_to_engine_type(supported_dma_mask(dev)); + type = b43_engine_type(dev); mmio_base = b43_dmacontroller_base(type, engine_index); direct_fifo_rx(dev, type, mmio_base, enable);