hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/drivers/net/wireless/broadcom/b43legacy/dma.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23
34 Broadcom B43legacy wireless driver
....@@ -10,20 +11,6 @@
1011 Copyright (C) 2002 David S. Miller
1112 Copyright (C) Pekka Pietikainen
1213
13
- This program is free software; you can redistribute it and/or modify
14
- it under the terms of the GNU General Public License as published by
15
- the Free Software Foundation; either version 2 of the License, or
16
- (at your option) any later version.
17
-
18
- This program is distributed in the hope that it will be useful,
19
- but WITHOUT ANY WARRANTY; without even the implied warranty of
20
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
- GNU General Public License for more details.
22
-
23
- You should have received a copy of the GNU General Public License
24
- along with this program; see the file COPYING. If not, write to
25
- the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
26
- Boston, MA 02110-1301, USA.
2714
2815 */
2916
....@@ -202,7 +189,7 @@
202189 switch (queue_priority) {
203190 default:
204191 B43legacy_WARN_ON(1);
205
- /* fallthrough */
192
+ fallthrough;
206193 case 0:
207194 ring = dev->dma.tx_ring3;
208195 break;
....@@ -331,9 +318,9 @@
331318 static int alloc_ringmemory(struct b43legacy_dmaring *ring)
332319 {
333320 /* GFP flags must match the flags in free_ringmemory()! */
334
- ring->descbase = dma_zalloc_coherent(ring->dev->dev->dma_dev,
335
- B43legacy_DMA_RINGMEMSIZE,
336
- &(ring->dmabase), GFP_KERNEL);
321
+ ring->descbase = dma_alloc_coherent(ring->dev->dev->dma_dev,
322
+ B43legacy_DMA_RINGMEMSIZE,
323
+ &(ring->dmabase), GFP_KERNEL);
337324 if (!ring->descbase)
338325 return -ENOMEM;
339326
....@@ -616,7 +603,7 @@
616603 }
617604 }
618605
619
-static u64 supported_dma_mask(struct b43legacy_wldev *dev)
606
+static enum b43legacy_dmatype b43legacy_engine_type(struct b43legacy_wldev *dev)
620607 {
621608 u32 tmp;
622609 u16 mmio_base;
....@@ -628,18 +615,7 @@
628615 tmp = b43legacy_read32(dev, mmio_base +
629616 B43legacy_DMA32_TXCTL);
630617 if (tmp & B43legacy_DMA32_TXADDREXT_MASK)
631
- return DMA_BIT_MASK(32);
632
-
633
- return DMA_BIT_MASK(30);
634
-}
635
-
636
-static enum b43legacy_dmatype dma_mask_to_engine_type(u64 dmamask)
637
-{
638
- if (dmamask == DMA_BIT_MASK(30))
639
- return B43legacy_DMA_30BIT;
640
- if (dmamask == DMA_BIT_MASK(32))
641618 return B43legacy_DMA_32BIT;
642
- B43legacy_WARN_ON(1);
643619 return B43legacy_DMA_30BIT;
644620 }
645621
....@@ -797,54 +773,14 @@
797773 dma->tx_ring0 = NULL;
798774 }
799775
800
-static int b43legacy_dma_set_mask(struct b43legacy_wldev *dev, u64 mask)
801
-{
802
- u64 orig_mask = mask;
803
- bool fallback = false;
804
- int err;
805
-
806
- /* Try to set the DMA mask. If it fails, try falling back to a
807
- * lower mask, as we can always also support a lower one. */
808
- while (1) {
809
- err = dma_set_mask_and_coherent(dev->dev->dma_dev, mask);
810
- if (!err)
811
- break;
812
- if (mask == DMA_BIT_MASK(64)) {
813
- mask = DMA_BIT_MASK(32);
814
- fallback = true;
815
- continue;
816
- }
817
- if (mask == DMA_BIT_MASK(32)) {
818
- mask = DMA_BIT_MASK(30);
819
- fallback = true;
820
- continue;
821
- }
822
- b43legacyerr(dev->wl, "The machine/kernel does not support "
823
- "the required %u-bit DMA mask\n",
824
- (unsigned int)dma_mask_to_engine_type(orig_mask));
825
- return -EOPNOTSUPP;
826
- }
827
- if (fallback) {
828
- b43legacyinfo(dev->wl, "DMA mask fallback from %u-bit to %u-"
829
- "bit\n",
830
- (unsigned int)dma_mask_to_engine_type(orig_mask),
831
- (unsigned int)dma_mask_to_engine_type(mask));
832
- }
833
-
834
- return 0;
835
-}
836
-
837776 int b43legacy_dma_init(struct b43legacy_wldev *dev)
838777 {
839778 struct b43legacy_dma *dma = &dev->dma;
840779 struct b43legacy_dmaring *ring;
780
+ enum b43legacy_dmatype type = b43legacy_engine_type(dev);
841781 int err;
842
- u64 dmamask;
843
- enum b43legacy_dmatype type;
844782
845
- dmamask = supported_dma_mask(dev);
846
- type = dma_mask_to_engine_type(dmamask);
847
- err = b43legacy_dma_set_mask(dev, dmamask);
783
+ err = dma_set_mask_and_coherent(dev->dev->dma_dev, DMA_BIT_MASK(type));
848784 if (err) {
849785 #ifdef CONFIG_B43LEGACY_PIO
850786 b43legacywarn(dev->wl, "DMA for this device not supported. "
....@@ -1149,7 +1085,7 @@
11491085 return -ENOSPC;
11501086 }
11511087
1152
- if (unlikely(WARN_ON(free_slots(ring) < SLOTS_PER_PACKET))) {
1088
+ if (WARN_ON(free_slots(ring) < SLOTS_PER_PACKET)) {
11531089 /* If we get here, we have a real error with the queue
11541090 * full, but queues not stopped. */
11551091 b43legacyerr(dev->wl, "DMA queue overflow\n");