wok-current diff broadcom-wl/stuff/018-linux59.patch @ rev 25673

Up broadcom-wl drivers, add miss driver for mesa-dri (iris, crocus, virtio)
author Stanislas Leduc <shann@slitaz.org>
date Mon Mar 04 16:57:21 2024 +0000 (4 months ago)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/broadcom-wl/stuff/018-linux59.patch	Mon Mar 04 16:57:21 2024 +0000
     1.3 @@ -0,0 +1,211 @@
     1.4 +From f3d652840f8dd959395065a1cf67ca40b04ec69b Mon Sep 17 00:00:00 2001
     1.5 +From: Joan Bruguera <joanbrugueram@gmail.com>
     1.6 +Date: Tue, 13 Oct 2020 19:35:55 +0200
     1.7 +Subject: [PATCH] Get rid of get_fs/set_fs calls in Broadcom WL driver.
     1.8 +
     1.9 +Tentative patch for broadcom-wl 6.30.223.271 driver for Linux 5.10 (tested -rc1 up to 5.10.1)
    1.10 +
    1.11 +Applies on top of all the patches applied to broadcom-wl-dkms 6.30.223.271-23 on Arch Linux.
    1.12 +
    1.13 +NB: Some checks in wlc_ioctl_internal are likely superfluous,
    1.14 +    but I'm not familiar enough with the driver to remove them with confidence.
    1.15 +
    1.16 +See also: https://lwn.net/Articles/722267/
    1.17 +          https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=47058bb54b57962b3958a936ddbc59355e4c5504
    1.18 +          https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5e6e9852d6f76e01b2e6803c74258afa5b432bc5
    1.19 +
    1.20 +Signed-off-by: Joan Bruguera <joanbrugueram@gmail.com>
    1.21 +---
    1.22 + src/wl/sys/wl_cfg80211_hybrid.c | 25 ++-------------------
    1.23 + src/wl/sys/wl_iw.c              | 25 ++-------------------
    1.24 + src/wl/sys/wl_linux.c           | 40 ++++++++++++++++++++++++++++-----
    1.25 + src/wl/sys/wl_linux.h           |  2 ++
    1.26 + src/wl/sys/wlc_pub.h            |  1 +
    1.27 + 5 files changed, 42 insertions(+), 51 deletions(-)
    1.28 +
    1.29 +diff --git a/src/wl/sys/wl_cfg80211_hybrid.c b/src/wl/sys/wl_cfg80211_hybrid.c
    1.30 +index 7b606e0..1e0adb7 100644
    1.31 +--- a/src/wl/sys/wl_cfg80211_hybrid.c
    1.32 ++++ b/src/wl/sys/wl_cfg80211_hybrid.c
    1.33 +@@ -38,6 +38,7 @@
    1.34 + #include <wlioctl.h>
    1.35 + #include <proto/802.11.h>
    1.36 + #include <wl_cfg80211_hybrid.h>
    1.37 ++#include <wl_linux.h>
    1.38 + 
    1.39 + #define EVENT_TYPE(e) dtoh32((e)->event_type)
    1.40 + #define EVENT_FLAGS(e) dtoh16((e)->flags)
    1.41 +@@ -435,30 +436,7 @@ static void key_endian_to_host(struct wl_wsec_key *key)
    1.42 + static s32
    1.43 + wl_dev_ioctl(struct net_device *dev, u32 cmd, void *arg, u32 len)
    1.44 + {
    1.45 +-	struct ifreq ifr;
    1.46 +-	struct wl_ioctl ioc;
    1.47 +-	mm_segment_t fs;
    1.48 +-	s32 err = 0;
    1.49 +-
    1.50 +-	BUG_ON(len < sizeof(int));
    1.51 +-
    1.52 +-	memset(&ioc, 0, sizeof(ioc));
    1.53 +-	ioc.cmd = cmd;
    1.54 +-	ioc.buf = arg;
    1.55 +-	ioc.len = len;
    1.56 +-	strcpy(ifr.ifr_name, dev->name);
    1.57 +-	ifr.ifr_data = (caddr_t)&ioc;
    1.58 +-
    1.59 +-	fs = get_fs();
    1.60 +-	set_fs(get_ds());
    1.61 +-#if defined(WL_USE_NETDEV_OPS)
    1.62 +-	err = dev->netdev_ops->ndo_do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
    1.63 +-#else
    1.64 +-	err = dev->do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
    1.65 +-#endif
    1.66 +-	set_fs(fs);
    1.67 +-
    1.68 +-	return err;
    1.69 ++	return wlc_ioctl_internal(dev, cmd, arg, len);
    1.70 + }
    1.71 + 
    1.72 + static s32
    1.73 +diff --git a/src/wl/sys/wl_iw.c b/src/wl/sys/wl_iw.c
    1.74 +index c4c610b..e346b15 100644
    1.75 +--- a/src/wl/sys/wl_iw.c
    1.76 ++++ b/src/wl/sys/wl_iw.c
    1.77 +@@ -37,6 +37,7 @@ typedef const struct si_pub	si_t;
    1.78 + 
    1.79 + #include <wl_dbg.h>
    1.80 + #include <wl_iw.h>
    1.81 ++#include <wl_linux.h>
    1.82 + 
    1.83 + extern bool wl_iw_conn_status_str(uint32 event_type, uint32 status,
    1.84 + 	uint32 reason, char* stringBuf, uint buflen);
    1.85 +@@ -103,29 +104,7 @@ dev_wlc_ioctl(
    1.86 + 	int len
    1.87 + )
    1.88 + {
    1.89 +-	struct ifreq ifr;
    1.90 +-	wl_ioctl_t ioc;
    1.91 +-	mm_segment_t fs;
    1.92 +-	int ret;
    1.93 +-
    1.94 +-	memset(&ioc, 0, sizeof(ioc));
    1.95 +-	ioc.cmd = cmd;
    1.96 +-	ioc.buf = arg;
    1.97 +-	ioc.len = len;
    1.98 +-
    1.99 +-	strcpy(ifr.ifr_name, dev->name);
   1.100 +-	ifr.ifr_data = (caddr_t) &ioc;
   1.101 +-
   1.102 +-	fs = get_fs();
   1.103 +-	set_fs(get_ds());
   1.104 +-#if defined(WL_USE_NETDEV_OPS)
   1.105 +-	ret = dev->netdev_ops->ndo_do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
   1.106 +-#else
   1.107 +-	ret = dev->do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
   1.108 +-#endif
   1.109 +-	set_fs(fs);
   1.110 +-
   1.111 +-	return ret;
   1.112 ++	return wlc_ioctl_internal(dev, cmd, arg, len);
   1.113 + }
   1.114 + 
   1.115 + static int
   1.116 +diff --git a/src/wl/sys/wl_linux.c b/src/wl/sys/wl_linux.c
   1.117 +index 947cef3..f04c148 100644
   1.118 +--- a/src/wl/sys/wl_linux.c
   1.119 ++++ b/src/wl/sys/wl_linux.c
   1.120 +@@ -1643,10 +1643,7 @@ wl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
   1.121 + 		goto done2;
   1.122 + 	}
   1.123 + 
   1.124 +-	if (segment_eq(get_fs(), KERNEL_DS))
   1.125 +-		buf = ioc.buf;
   1.126 +-
   1.127 +-	else if (ioc.buf) {
   1.128 ++	if (ioc.buf) {
   1.129 + 		if (!(buf = (void *) MALLOC(wl->osh, MAX(ioc.len, WLC_IOCTL_MAXLEN)))) {
   1.130 + 			bcmerror = BCME_NORESOURCE;
   1.131 + 			goto done2;
   1.132 +@@ -1667,7 +1664,7 @@ wl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
   1.133 + 	WL_UNLOCK(wl);
   1.134 + 
   1.135 + done1:
   1.136 +-	if (ioc.buf && (ioc.buf != buf)) {
   1.137 ++	if (ioc.buf) {
   1.138 + 		if (copy_to_user(ioc.buf, buf, ioc.len))
   1.139 + 			bcmerror = BCME_BADADDR;
   1.140 + 		MFREE(wl->osh, buf, MAX(ioc.len, WLC_IOCTL_MAXLEN));
   1.141 +@@ -1680,6 +1677,39 @@ done2:
   1.142 + 	return (OSL_ERROR(bcmerror));
   1.143 + }
   1.144 + 
   1.145 ++int
   1.146 ++wlc_ioctl_internal(struct net_device *dev, int cmd, void *buf, int len)
   1.147 ++{
   1.148 ++	wl_info_t *wl;
   1.149 ++	wl_if_t *wlif;
   1.150 ++	int bcmerror;
   1.151 ++
   1.152 ++	if (!dev)
   1.153 ++		return -ENETDOWN;
   1.154 ++
   1.155 ++	wl = WL_INFO(dev);
   1.156 ++	wlif = WL_DEV_IF(dev);
   1.157 ++	if (wlif == NULL || wl == NULL || wl->dev == NULL)
   1.158 ++		return -ENETDOWN;
   1.159 ++
   1.160 ++	bcmerror = 0;
   1.161 ++
   1.162 ++	WL_TRACE(("wl%d: wlc_ioctl_internal: cmd 0x%x\n", wl->pub->unit, cmd));
   1.163 ++
   1.164 ++	WL_LOCK(wl);
   1.165 ++	if (!capable(CAP_NET_ADMIN)) {
   1.166 ++		bcmerror = BCME_EPERM;
   1.167 ++	} else {
   1.168 ++		bcmerror = wlc_ioctl(wl->wlc, cmd, buf, len, wlif->wlcif);
   1.169 ++	}
   1.170 ++	WL_UNLOCK(wl);
   1.171 ++
   1.172 ++	ASSERT(VALID_BCMERROR(bcmerror));
   1.173 ++	if (bcmerror != 0)
   1.174 ++		wl->pub->bcmerror = bcmerror;
   1.175 ++	return (OSL_ERROR(bcmerror));
   1.176 ++}
   1.177 ++
   1.178 + static struct net_device_stats*
   1.179 + wl_get_stats(struct net_device *dev)
   1.180 + {
   1.181 +diff --git a/src/wl/sys/wl_linux.h b/src/wl/sys/wl_linux.h
   1.182 +index 5b1048e..c8c1f41 100644
   1.183 +--- a/src/wl/sys/wl_linux.h
   1.184 ++++ b/src/wl/sys/wl_linux.h
   1.185 +@@ -22,6 +22,7 @@
   1.186 + #define _wl_linux_h_
   1.187 + 
   1.188 + #include <wlc_types.h>
   1.189 ++#include <wlc_pub.h>
   1.190 + 
   1.191 + typedef struct wl_timer {
   1.192 + 	struct timer_list 	timer;
   1.193 +@@ -187,6 +188,7 @@ extern irqreturn_t wl_isr(int irq, void *dev_id, struct pt_regs *ptregs);
   1.194 + extern int __devinit wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
   1.195 + extern void wl_free(wl_info_t *wl);
   1.196 + extern int  wl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
   1.197 ++extern int wlc_ioctl_internal(struct net_device *dev, int cmd, void *buf, int len);
   1.198 + extern struct net_device * wl_netdev_get(wl_info_t *wl);
   1.199 + 
   1.200 + #endif 
   1.201 +diff --git a/src/wl/sys/wlc_pub.h b/src/wl/sys/wlc_pub.h
   1.202 +index 53a98b8..2b5a029 100644
   1.203 +--- a/src/wl/sys/wlc_pub.h
   1.204 ++++ b/src/wl/sys/wlc_pub.h
   1.205 +@@ -24,6 +24,7 @@
   1.206 + 
   1.207 + #include <wlc_types.h>
   1.208 + #include <wlc_utils.h>
   1.209 ++#include <siutils.h>
   1.210 + #include "proto/802.11.h"
   1.211 + #include "proto/bcmevent.h"
   1.212 + 
   1.213 +--
   1.214 +2.28.0