wok-current annotate broadcom-wl64/stuff/018-linux59.patch @ rev 25701

Fix dep for libglamoregl.so (libepoxy), and miss file for amdgpu (thanks alanyih)
author Stanislas Leduc <shann@slitaz.org>
date Fri Apr 19 12:48:51 2024 +0000 (2 months ago)
parents
children
rev   line source
shann@25673 1 From f3d652840f8dd959395065a1cf67ca40b04ec69b Mon Sep 17 00:00:00 2001
shann@25673 2 From: Joan Bruguera <joanbrugueram@gmail.com>
shann@25673 3 Date: Tue, 13 Oct 2020 19:35:55 +0200
shann@25673 4 Subject: [PATCH] Get rid of get_fs/set_fs calls in Broadcom WL driver.
shann@25673 5
shann@25673 6 Tentative patch for broadcom-wl 6.30.223.271 driver for Linux 5.10 (tested -rc1 up to 5.10.1)
shann@25673 7
shann@25673 8 Applies on top of all the patches applied to broadcom-wl-dkms 6.30.223.271-23 on Arch Linux.
shann@25673 9
shann@25673 10 NB: Some checks in wlc_ioctl_internal are likely superfluous,
shann@25673 11 but I'm not familiar enough with the driver to remove them with confidence.
shann@25673 12
shann@25673 13 See also: https://lwn.net/Articles/722267/
shann@25673 14 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=47058bb54b57962b3958a936ddbc59355e4c5504
shann@25673 15 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5e6e9852d6f76e01b2e6803c74258afa5b432bc5
shann@25673 16
shann@25673 17 Signed-off-by: Joan Bruguera <joanbrugueram@gmail.com>
shann@25673 18 ---
shann@25673 19 src/wl/sys/wl_cfg80211_hybrid.c | 25 ++-------------------
shann@25673 20 src/wl/sys/wl_iw.c | 25 ++-------------------
shann@25673 21 src/wl/sys/wl_linux.c | 40 ++++++++++++++++++++++++++++-----
shann@25673 22 src/wl/sys/wl_linux.h | 2 ++
shann@25673 23 src/wl/sys/wlc_pub.h | 1 +
shann@25673 24 5 files changed, 42 insertions(+), 51 deletions(-)
shann@25673 25
shann@25673 26 diff --git a/src/wl/sys/wl_cfg80211_hybrid.c b/src/wl/sys/wl_cfg80211_hybrid.c
shann@25673 27 index 7b606e0..1e0adb7 100644
shann@25673 28 --- a/src/wl/sys/wl_cfg80211_hybrid.c
shann@25673 29 +++ b/src/wl/sys/wl_cfg80211_hybrid.c
shann@25673 30 @@ -38,6 +38,7 @@
shann@25673 31 #include <wlioctl.h>
shann@25673 32 #include <proto/802.11.h>
shann@25673 33 #include <wl_cfg80211_hybrid.h>
shann@25673 34 +#include <wl_linux.h>
shann@25673 35
shann@25673 36 #define EVENT_TYPE(e) dtoh32((e)->event_type)
shann@25673 37 #define EVENT_FLAGS(e) dtoh16((e)->flags)
shann@25673 38 @@ -435,30 +436,7 @@ static void key_endian_to_host(struct wl_wsec_key *key)
shann@25673 39 static s32
shann@25673 40 wl_dev_ioctl(struct net_device *dev, u32 cmd, void *arg, u32 len)
shann@25673 41 {
shann@25673 42 - struct ifreq ifr;
shann@25673 43 - struct wl_ioctl ioc;
shann@25673 44 - mm_segment_t fs;
shann@25673 45 - s32 err = 0;
shann@25673 46 -
shann@25673 47 - BUG_ON(len < sizeof(int));
shann@25673 48 -
shann@25673 49 - memset(&ioc, 0, sizeof(ioc));
shann@25673 50 - ioc.cmd = cmd;
shann@25673 51 - ioc.buf = arg;
shann@25673 52 - ioc.len = len;
shann@25673 53 - strcpy(ifr.ifr_name, dev->name);
shann@25673 54 - ifr.ifr_data = (caddr_t)&ioc;
shann@25673 55 -
shann@25673 56 - fs = get_fs();
shann@25673 57 - set_fs(get_ds());
shann@25673 58 -#if defined(WL_USE_NETDEV_OPS)
shann@25673 59 - err = dev->netdev_ops->ndo_do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
shann@25673 60 -#else
shann@25673 61 - err = dev->do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
shann@25673 62 -#endif
shann@25673 63 - set_fs(fs);
shann@25673 64 -
shann@25673 65 - return err;
shann@25673 66 + return wlc_ioctl_internal(dev, cmd, arg, len);
shann@25673 67 }
shann@25673 68
shann@25673 69 static s32
shann@25673 70 diff --git a/src/wl/sys/wl_iw.c b/src/wl/sys/wl_iw.c
shann@25673 71 index c4c610b..e346b15 100644
shann@25673 72 --- a/src/wl/sys/wl_iw.c
shann@25673 73 +++ b/src/wl/sys/wl_iw.c
shann@25673 74 @@ -37,6 +37,7 @@ typedef const struct si_pub si_t;
shann@25673 75
shann@25673 76 #include <wl_dbg.h>
shann@25673 77 #include <wl_iw.h>
shann@25673 78 +#include <wl_linux.h>
shann@25673 79
shann@25673 80 extern bool wl_iw_conn_status_str(uint32 event_type, uint32 status,
shann@25673 81 uint32 reason, char* stringBuf, uint buflen);
shann@25673 82 @@ -103,29 +104,7 @@ dev_wlc_ioctl(
shann@25673 83 int len
shann@25673 84 )
shann@25673 85 {
shann@25673 86 - struct ifreq ifr;
shann@25673 87 - wl_ioctl_t ioc;
shann@25673 88 - mm_segment_t fs;
shann@25673 89 - int ret;
shann@25673 90 -
shann@25673 91 - memset(&ioc, 0, sizeof(ioc));
shann@25673 92 - ioc.cmd = cmd;
shann@25673 93 - ioc.buf = arg;
shann@25673 94 - ioc.len = len;
shann@25673 95 -
shann@25673 96 - strcpy(ifr.ifr_name, dev->name);
shann@25673 97 - ifr.ifr_data = (caddr_t) &ioc;
shann@25673 98 -
shann@25673 99 - fs = get_fs();
shann@25673 100 - set_fs(get_ds());
shann@25673 101 -#if defined(WL_USE_NETDEV_OPS)
shann@25673 102 - ret = dev->netdev_ops->ndo_do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
shann@25673 103 -#else
shann@25673 104 - ret = dev->do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
shann@25673 105 -#endif
shann@25673 106 - set_fs(fs);
shann@25673 107 -
shann@25673 108 - return ret;
shann@25673 109 + return wlc_ioctl_internal(dev, cmd, arg, len);
shann@25673 110 }
shann@25673 111
shann@25673 112 static int
shann@25673 113 diff --git a/src/wl/sys/wl_linux.c b/src/wl/sys/wl_linux.c
shann@25673 114 index 947cef3..f04c148 100644
shann@25673 115 --- a/src/wl/sys/wl_linux.c
shann@25673 116 +++ b/src/wl/sys/wl_linux.c
shann@25673 117 @@ -1643,10 +1643,7 @@ wl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
shann@25673 118 goto done2;
shann@25673 119 }
shann@25673 120
shann@25673 121 - if (segment_eq(get_fs(), KERNEL_DS))
shann@25673 122 - buf = ioc.buf;
shann@25673 123 -
shann@25673 124 - else if (ioc.buf) {
shann@25673 125 + if (ioc.buf) {
shann@25673 126 if (!(buf = (void *) MALLOC(wl->osh, MAX(ioc.len, WLC_IOCTL_MAXLEN)))) {
shann@25673 127 bcmerror = BCME_NORESOURCE;
shann@25673 128 goto done2;
shann@25673 129 @@ -1667,7 +1664,7 @@ wl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
shann@25673 130 WL_UNLOCK(wl);
shann@25673 131
shann@25673 132 done1:
shann@25673 133 - if (ioc.buf && (ioc.buf != buf)) {
shann@25673 134 + if (ioc.buf) {
shann@25673 135 if (copy_to_user(ioc.buf, buf, ioc.len))
shann@25673 136 bcmerror = BCME_BADADDR;
shann@25673 137 MFREE(wl->osh, buf, MAX(ioc.len, WLC_IOCTL_MAXLEN));
shann@25673 138 @@ -1680,6 +1677,39 @@ done2:
shann@25673 139 return (OSL_ERROR(bcmerror));
shann@25673 140 }
shann@25673 141
shann@25673 142 +int
shann@25673 143 +wlc_ioctl_internal(struct net_device *dev, int cmd, void *buf, int len)
shann@25673 144 +{
shann@25673 145 + wl_info_t *wl;
shann@25673 146 + wl_if_t *wlif;
shann@25673 147 + int bcmerror;
shann@25673 148 +
shann@25673 149 + if (!dev)
shann@25673 150 + return -ENETDOWN;
shann@25673 151 +
shann@25673 152 + wl = WL_INFO(dev);
shann@25673 153 + wlif = WL_DEV_IF(dev);
shann@25673 154 + if (wlif == NULL || wl == NULL || wl->dev == NULL)
shann@25673 155 + return -ENETDOWN;
shann@25673 156 +
shann@25673 157 + bcmerror = 0;
shann@25673 158 +
shann@25673 159 + WL_TRACE(("wl%d: wlc_ioctl_internal: cmd 0x%x\n", wl->pub->unit, cmd));
shann@25673 160 +
shann@25673 161 + WL_LOCK(wl);
shann@25673 162 + if (!capable(CAP_NET_ADMIN)) {
shann@25673 163 + bcmerror = BCME_EPERM;
shann@25673 164 + } else {
shann@25673 165 + bcmerror = wlc_ioctl(wl->wlc, cmd, buf, len, wlif->wlcif);
shann@25673 166 + }
shann@25673 167 + WL_UNLOCK(wl);
shann@25673 168 +
shann@25673 169 + ASSERT(VALID_BCMERROR(bcmerror));
shann@25673 170 + if (bcmerror != 0)
shann@25673 171 + wl->pub->bcmerror = bcmerror;
shann@25673 172 + return (OSL_ERROR(bcmerror));
shann@25673 173 +}
shann@25673 174 +
shann@25673 175 static struct net_device_stats*
shann@25673 176 wl_get_stats(struct net_device *dev)
shann@25673 177 {
shann@25673 178 diff --git a/src/wl/sys/wl_linux.h b/src/wl/sys/wl_linux.h
shann@25673 179 index 5b1048e..c8c1f41 100644
shann@25673 180 --- a/src/wl/sys/wl_linux.h
shann@25673 181 +++ b/src/wl/sys/wl_linux.h
shann@25673 182 @@ -22,6 +22,7 @@
shann@25673 183 #define _wl_linux_h_
shann@25673 184
shann@25673 185 #include <wlc_types.h>
shann@25673 186 +#include <wlc_pub.h>
shann@25673 187
shann@25673 188 typedef struct wl_timer {
shann@25673 189 struct timer_list timer;
shann@25673 190 @@ -187,6 +188,7 @@ extern irqreturn_t wl_isr(int irq, void *dev_id, struct pt_regs *ptregs);
shann@25673 191 extern int __devinit wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
shann@25673 192 extern void wl_free(wl_info_t *wl);
shann@25673 193 extern int wl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
shann@25673 194 +extern int wlc_ioctl_internal(struct net_device *dev, int cmd, void *buf, int len);
shann@25673 195 extern struct net_device * wl_netdev_get(wl_info_t *wl);
shann@25673 196
shann@25673 197 #endif
shann@25673 198 diff --git a/src/wl/sys/wlc_pub.h b/src/wl/sys/wlc_pub.h
shann@25673 199 index 53a98b8..2b5a029 100644
shann@25673 200 --- a/src/wl/sys/wlc_pub.h
shann@25673 201 +++ b/src/wl/sys/wlc_pub.h
shann@25673 202 @@ -24,6 +24,7 @@
shann@25673 203
shann@25673 204 #include <wlc_types.h>
shann@25673 205 #include <wlc_utils.h>
shann@25673 206 +#include <siutils.h>
shann@25673 207 #include "proto/802.11.h"
shann@25673 208 #include "proto/bcmevent.h"
shann@25673 209
shann@25673 210 --
shann@25673 211 2.28.0