enable rt2860 power management code

adjust to fit netbsd:
make suspend,resume functions match desired pmf* prototypes
remove wakeup/activate wrapper functions

avoid jumping to NULL on resume by initializing if_stop

the problem machine has other issues on resume, so there might be further
issues, but it's an improvement over a jump to NULL.

tested by Riccardo Mottola
This commit is contained in:
maya 2017-07-25 23:17:20 +00:00
parent 79eedfcd84
commit 74b72ff7da
3 changed files with 23 additions and 69 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: rt2860.c,v 1.27 2017/07/20 18:17:25 maya Exp $ */
/* $NetBSD: rt2860.c,v 1.28 2017/07/25 23:17:20 maya Exp $ */
/* $OpenBSD: rt2860.c,v 1.90 2016/04/13 10:49:26 mpi Exp $ */
/* $FreeBSD: head/sys/dev/ral/rt2860.c 306591 2016-10-02 20:35:55Z avos $ */
@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rt2860.c,v 1.27 2017/07/20 18:17:25 maya Exp $");
__KERNEL_RCSID(0, "$NetBSD: rt2860.c,v 1.28 2017/07/25 23:17:20 maya Exp $");
#include <sys/param.h>
#include <sys/sockio.h>
@ -74,6 +74,8 @@ int rt2860_debug = 0;
#define MAXQS 6 /* Tx (4 EDCAs + HCCA + Mgt) and Rx rings */
static void rt2860_attachhook(device_t);
static bool rt2860_suspend(device_t self, const pmf_qual_t *qual);
static bool rt2860_wakeup(device_t self, const pmf_qual_t *qual);
static int rt2860_alloc_tx_ring(struct rt2860_softc *,
struct rt2860_tx_ring *);
static void rt2860_reset_tx_ring(struct rt2860_softc *,
@ -394,6 +396,7 @@ rt2860_attachhook(device_t self)
ifp->if_init = rt2860_init;
ifp->if_ioctl = rt2860_ioctl;
ifp->if_start = rt2860_start;
ifp->if_stop = rt2860_stop;
ifp->if_watchdog = rt2860_watchdog;
IFQ_SET_READY(&ifp->if_snd);
memcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ);
@ -434,7 +437,7 @@ rt2860_attachhook(device_t self)
ieee80211_announce(ic);
if (pmf_device_register(sc->sc_dev, NULL, NULL))
if (pmf_device_register(sc->sc_dev, rt2860_wakeup, rt2860_suspend))
pmf_class_network_register(sc->sc_dev, ifp);
else
aprint_error_dev(sc->sc_dev,
@ -471,24 +474,31 @@ rt2860_detach(void *xsc)
return 0;
}
void
rt2860_suspend(void *xsc)
static bool
rt2860_suspend(device_t self, const pmf_qual_t *qual)
{
struct rt2860_softc *sc = xsc;
struct rt2860_softc *sc = device_private(self);
struct ifnet *ifp = &sc->sc_if;
if (ifp->if_flags & IFF_RUNNING)
rt2860_stop(ifp, 1);
return true;
}
void
rt2860_wakeup(void *xsc)
static bool
rt2860_wakeup(device_t self, const pmf_qual_t *qual)
{
struct rt2860_softc *sc = xsc;
struct rt2860_softc *sc = device_private(self);
struct ifnet *ifp = &sc->sc_if;
int s;
s = splnet();
if (ifp->if_flags & IFF_UP)
rt2860_init(ifp);
splx(s);
return true;
}
static int

View File

@ -1,4 +1,4 @@
/* $NetBSD: rt2860var.h,v 1.4 2017/02/02 10:05:35 nonaka Exp $ */
/* $NetBSD: rt2860var.h,v 1.5 2017/07/25 23:17:20 maya Exp $ */
/* $OpenBSD: rt2860var.h,v 1.23 2016/03/21 21:16:30 stsp Exp $ */
/*-
@ -212,6 +212,4 @@ struct rt2860_softc {
int rt2860_attach(void *, int);
int rt2860_detach(void *);
void rt2860_suspend(void *);
void rt2860_wakeup(void *);
int rt2860_intr(void *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ral_pci.c,v 1.23 2016/07/06 14:28:51 christos Exp $ */
/* $NetBSD: if_ral_pci.c,v 1.24 2017/07/25 23:17:20 maya Exp $ */
/* $OpenBSD: if_ral_pci.c,v 1.24 2015/11/24 17:11:39 mpi Exp $ */
/*-
@ -21,7 +21,7 @@
* PCI front-end for the Ralink RT2560/RT2561/RT2860/RT3090 driver.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_ral_pci.c,v 1.23 2016/07/06 14:28:51 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_ral_pci.c,v 1.24 2017/07/25 23:17:20 maya Exp $");
#include <sys/param.h>
@ -56,42 +56,24 @@ __KERNEL_RCSID(0, "$NetBSD: if_ral_pci.c,v 1.23 2016/07/06 14:28:51 christos Exp
#include <dev/pci/pcivar.h>
#include <dev/pci/pcidevs.h>
#define RAL_POWER_MANAGEMENT 0 /* Disabled for now */
static struct ral_opns {
int (*attach)(void *, int);
int (*detach)(void *);
#if RAL_POWER_MANAGEMENT
void (*suspend)(void *);
void (*wakeup)(void *);
#endif
int (*intr)(void *);
} ral_rt2560_opns = {
rt2560_attach,
rt2560_detach,
#if RAL_POWER_MANAGEMENT
rt2560_suspend,
rt2560_wakeup,
#endif
rt2560_intr
}, ral_rt2661_opns = {
rt2661_attach,
rt2661_detach,
#if RAL_POWER_MANAGEMENT
rt2661_suspend,
rt2661_wakeup,
#endif
rt2661_intr
}, ral_rt2860_opns = {
rt2860_attach,
rt2860_detach,
#if RAL_POWER_MANAGEMENT
rt2860_suspend,
rt2860_wakeup,
#endif
rt2860_intr
};
@ -116,15 +98,9 @@ struct ral_pci_softc {
int ral_pci_match(device_t, cfdata_t, void *);
void ral_pci_attach(device_t, device_t, void *);
int ral_pci_detach(device_t, int);
#if RAL_POWER_MANAGEMENT
int ral_pci_activate(struct device *, devact_t);
void ral_pci_wakeup(struct ral_pci_softc *);
#else
#define ral_pci_activate NULL
#endif
CFATTACH_DECL_NEW(ral_pci, sizeof (struct ral_pci_softc),
ral_pci_match, ral_pci_attach, ral_pci_detach, ral_pci_activate);
ral_pci_match, ral_pci_attach, ral_pci_detach, NULL);
static const struct ral_pci_matchid {
pci_vendor_id_t ral_vendor;
@ -276,33 +252,3 @@ ral_pci_detach(device_t self, int flags)
return 0;
}
#if RAL_POWER_MANAGEMENT
int
ral_pci_activate(struct device *self, devact_t act)
{
struct ral_pci_softc *psc = (struct ral_pci_softc *)self;
struct rt2560_softc *sc = &psc->sc_sc;
switch (act) {
case DVACT_SUSPEND:
(*psc->sc_opns->suspend)(sc);
break;
case DVACT_WAKEUP:
ral_pci_wakeup(psc);
break;
}
return 0;
}
void
ral_pci_wakeup(struct ral_pci_softc *psc)
{
struct rt2560_softc *sc = &psc->sc_sc;
int s;
s = splnet();
(*psc->sc_opns->wakeup)(sc);
splx(s);
}
#endif