Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb move the check against un_phyno from usbnet back...
details: https://anonhg.NetBSD.org/src/rev/68af05bff94f
branches: trunk
changeset: 453598:68af05bff94f
user: mrg <mrg%NetBSD.org@localhost>
date: Mon Aug 19 07:33:37 2019 +0000
description:
move the check against un_phyno from usbnet back into the drivers
that do this (axe, axen, mue, smsc, ure.) it made mii scanning
only work for phy 0, and aue needs it for at least one device.
fix smsc to return usbd_status not -1 on failure. XXX smsc was
writing to '*val' even in error cases, it does not now.
remove a double call to IFQ_SET_READY() (noticed by chuq).
avoid unlock+instant relock by using usbnet_lock_mii_un_locked().
diffstat:
sys/dev/usb/if_axe.c | 10 ++++++++--
sys/dev/usb/if_axen.c | 12 +++++++++---
sys/dev/usb/if_mue.c | 10 ++++++++--
sys/dev/usb/if_smsc.c | 24 ++++++++++++------------
sys/dev/usb/if_ure.c | 14 ++++++++++++--
sys/dev/usb/usbnet.c | 23 +++++++++++------------
6 files changed, 60 insertions(+), 33 deletions(-)
diffs (truncated from 313 to 300 lines):
diff -r 1a014c37b433 -r 68af05bff94f sys/dev/usb/if_axe.c
--- a/sys/dev/usb/if_axe.c Mon Aug 19 07:20:07 2019 +0000
+++ b/sys/dev/usb/if_axe.c Mon Aug 19 07:33:37 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_axe.c,v 1.116 2019/08/16 08:29:20 mrg Exp $ */
+/* $NetBSD: if_axe.c,v 1.117 2019/08/19 07:33:37 mrg Exp $ */
/* $OpenBSD: if_axe.c,v 1.137 2016/04/13 11:03:37 mpi Exp $ */
/*
@@ -87,7 +87,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.116 2019/08/16 08:29:20 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.117 2019/08/19 07:33:37 mrg Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -323,6 +323,9 @@
DPRINTFN(30, "phy 0x%jx reg 0x%jx\n", phy, reg, 0, 0);
+ if (un->un_phyno != phy)
+ return USBD_INVAL;
+
axe_cmd(sc, AXE_CMD_MII_OPMODE_SW, 0, 0, NULL);
err = axe_cmd(sc, AXE_CMD_MII_READ_REG, reg, phy, &data);
@@ -356,6 +359,9 @@
usbd_status err;
uint16_t aval;
+ if (un->un_phyno != phy)
+ return USBD_INVAL;
+
aval = htole16(val);
axe_cmd(sc, AXE_CMD_MII_OPMODE_SW, 0, 0, NULL);
diff -r 1a014c37b433 -r 68af05bff94f sys/dev/usb/if_axen.c
--- a/sys/dev/usb/if_axen.c Mon Aug 19 07:20:07 2019 +0000
+++ b/sys/dev/usb/if_axen.c Mon Aug 19 07:33:37 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_axen.c,v 1.64 2019/08/15 05:52:23 mrg Exp $ */
+/* $NetBSD: if_axen.c,v 1.65 2019/08/19 07:33:37 mrg Exp $ */
/* $OpenBSD: if_axen.c,v 1.3 2013/10/21 10:10:22 yuo Exp $ */
/*
@@ -23,7 +23,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.64 2019/08/15 05:52:23 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.65 2019/08/19 07:33:37 mrg Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -135,8 +135,11 @@
axen_mii_read_reg(struct usbnet *un, int phy, int reg, uint16_t *val)
{
uint16_t data;
+
+ if (un->un_phyno != phy)
+ return USBD_INVAL;
+
usbd_status err = axen_cmd(un, AXEN_CMD_MII_READ_REG, reg, phy, &data);
-
if (!err) {
*val = le16toh(data);
@@ -152,6 +155,9 @@
{
uint16_t uval = htole16(val);
+ if (un->un_phyno != phy)
+ return USBD_INVAL;
+
return axen_cmd(un, AXEN_CMD_MII_WRITE_REG, reg, phy, &uval);
}
diff -r 1a014c37b433 -r 68af05bff94f sys/dev/usb/if_mue.c
--- a/sys/dev/usb/if_mue.c Mon Aug 19 07:20:07 2019 +0000
+++ b/sys/dev/usb/if_mue.c Mon Aug 19 07:33:37 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_mue.c,v 1.52 2019/08/15 08:02:32 mrg Exp $ */
+/* $NetBSD: if_mue.c,v 1.53 2019/08/19 07:33:37 mrg Exp $ */
/* $OpenBSD: if_mue.c,v 1.3 2018/08/04 16:42:46 jsg Exp $ */
/*
@@ -20,7 +20,7 @@
/* Driver for Microchip LAN7500/LAN7800 chipsets. */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_mue.c,v 1.52 2019/08/15 08:02:32 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mue.c,v 1.53 2019/08/19 07:33:37 mrg Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -217,6 +217,9 @@
usbnet_isowned_mii(un);
+ if (un->un_phyno != phy)
+ return USBD_INVAL;
+
if (MUE_WAIT_CLR(un, MUE_MII_ACCESS, MUE_MII_ACCESS_BUSY, 0)) {
MUE_PRINTF(un, "not ready\n");
return USBD_IN_USE;
@@ -242,6 +245,9 @@
{
usbnet_isowned_mii(un);
+ if (un->un_phyno != phy)
+ return USBD_INVAL;
+
if (MUE_WAIT_CLR(un, MUE_MII_ACCESS, MUE_MII_ACCESS_BUSY, 0)) {
MUE_PRINTF(un, "not ready\n");
return USBD_IN_USE;
diff -r 1a014c37b433 -r 68af05bff94f sys/dev/usb/if_smsc.c
--- a/sys/dev/usb/if_smsc.c Mon Aug 19 07:20:07 2019 +0000
+++ b/sys/dev/usb/if_smsc.c Mon Aug 19 07:33:37 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_smsc.c,v 1.58 2019/08/15 05:52:23 mrg Exp $ */
+/* $NetBSD: if_smsc.c,v 1.59 2019/08/19 07:33:37 mrg Exp $ */
/* $OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $ */
/* $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_smsc.c,v 1.58 2019/08/15 05:52:23 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_smsc.c,v 1.59 2019/08/19 07:33:37 mrg Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -279,14 +279,15 @@
{
uint32_t addr;
uint32_t data = 0;
- int rv = 0;
usbnet_isowned_mii(un);
+ if (un->un_phyno != phy)
+ return USBD_INVAL;
+
if (smsc_wait_for_bits(un, SMSC_MII_ADDR, SMSC_MII_BUSY) != 0) {
smsc_warn_printf(un, "MII is busy\n");
- rv = -1;
- goto done;
+ return USBD_TIMEOUT;
}
addr = (phy << 11) | (reg << 6) | SMSC_MII_READ;
@@ -294,14 +295,13 @@
if (smsc_wait_for_bits(un, SMSC_MII_ADDR, SMSC_MII_BUSY) != 0) {
smsc_warn_printf(un, "MII read timeout\n");
- rv = ETIMEDOUT;
+ return USBD_TIMEOUT;
}
smsc_readreg(un, SMSC_MII_DATA, &data);
-done:
*val = data & 0xffff;
- return rv;
+ return USBD_NORMAL_COMPLETION;
}
usbd_status
@@ -312,11 +312,11 @@
usbnet_isowned_mii(un);
if (un->un_phyno != phy)
- return -1;
+ return USBD_INVAL;
if (smsc_wait_for_bits(un, SMSC_MII_ADDR, SMSC_MII_BUSY) != 0) {
smsc_warn_printf(un, "MII is busy\n");
- return -1;
+ return USBD_TIMEOUT;
}
smsc_writereg(un, SMSC_MII_DATA, val);
@@ -326,10 +326,10 @@
if (smsc_wait_for_bits(un, SMSC_MII_ADDR, SMSC_MII_BUSY) != 0) {
smsc_warn_printf(un, "MII write timeout\n");
- return ETIMEDOUT;
+ return USBD_TIMEOUT;
}
- return 0;
+ return USBD_NORMAL_COMPLETION;
}
void
diff -r 1a014c37b433 -r 68af05bff94f sys/dev/usb/if_ure.c
--- a/sys/dev/usb/if_ure.c Mon Aug 19 07:20:07 2019 +0000
+++ b/sys/dev/usb/if_ure.c Mon Aug 19 07:33:37 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ure.c,v 1.28 2019/08/16 08:29:20 mrg Exp $ */
+/* $NetBSD: if_ure.c,v 1.29 2019/08/19 07:33:37 mrg Exp $ */
/* $OpenBSD: if_ure.c,v 1.10 2018/11/02 21:32:30 jcs Exp $ */
/*-
@@ -30,7 +30,7 @@
/* RealTek RTL8152/RTL8153 10/100/Gigabit USB Ethernet device */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ure.c,v 1.28 2019/08/16 08:29:20 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ure.c,v 1.29 2019/08/19 07:33:37 mrg Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -271,6 +271,11 @@
static usbd_status
ure_mii_read_reg(struct usbnet *un, int phy, int reg, uint16_t *val)
{
+ usbnet_isowned_mii(un);
+
+ if (un->un_phyno != phy)
+ return USBD_INVAL;
+
/* Let the rgephy driver read the URE_PLA_PHYSTATUS register. */
if (reg == RTK_GMEDIASTAT) {
*val = ure_read_1(un, URE_PLA_PHYSTATUS, URE_MCU_TYPE_PLA);
@@ -285,6 +290,11 @@
static usbd_status
ure_mii_write_reg(struct usbnet *un, int phy, int reg, uint16_t val)
{
+ usbnet_isowned_mii(un);
+
+ if (un->un_phyno != phy)
+ return USBD_INVAL;
+
ure_ocp_reg_write(un, URE_OCP_BASE_MII + reg * 2, val);
return USBD_NORMAL_COMPLETION;
diff -r 1a014c37b433 -r 68af05bff94f sys/dev/usb/usbnet.c
--- a/sys/dev/usb/usbnet.c Mon Aug 19 07:20:07 2019 +0000
+++ b/sys/dev/usb/usbnet.c Mon Aug 19 07:33:37 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: usbnet.c,v 1.19 2019/08/19 06:35:14 mrg Exp $ */
+/* $NetBSD: usbnet.c,v 1.20 2019/08/19 07:33:37 mrg Exp $ */
/*
* Copyright (c) 2019 Matthew R. Green
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.19 2019/08/19 06:35:14 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.20 2019/08/19 07:33:37 mrg Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -869,13 +869,13 @@
usbd_status err;
mutex_enter(&unp->unp_lock);
- if (unp->unp_dying || un->un_phyno != phy) {
+ if (unp->unp_dying) {
mutex_exit(&unp->unp_lock);
return EIO;
}
+
+ usbnet_lock_mii_un_locked(un);
mutex_exit(&unp->unp_lock);
-
- usbnet_lock_mii(un);
err = uno_read_reg(un, phy, reg, val);
usbnet_unlock_mii(un);
@@ -896,13 +896,13 @@
usbd_status err;
mutex_enter(&unp->unp_lock);
- if (unp->unp_dying || un->un_phyno != phy) {
+ if (unp->unp_dying) {
mutex_exit(&unp->unp_lock);
return EIO;
}
+
+ usbnet_lock_mii_un_locked(un);
mutex_exit(&unp->unp_lock);
-
- usbnet_lock_mii(un);
err = uno_write_reg(un, phy, reg, val);
usbnet_unlock_mii(un);
@@ -1087,8 +1087,9 @@
if (cd->uncd_tx_cnt > 0) {
err = usbd_abort_pipe(unp->unp_ep[USBNET_ENDPT_TX]);
- aprint_error_dev(un->un_dev, "pipe abort failed: %s\n",
- usbd_errstr(err));
+ if (err)
+ aprint_error_dev(un->un_dev, "pipe abort failed: %s\n",
- Prev by Date:
[src/trunk]: src/sys/dev/usb move the call to rnd_attach_source() earlier and...
- Next by Date:
[src/trunk]: src/sys/dev/usb axe, udav, url, cue, kue, smsc, udav[*], upl, ur...
- Previous by Thread:
[src/trunk]: src/sys/dev/usb move the call to rnd_attach_source() earlier and...
- Next by Thread:
[src/trunk]: src/sys/dev/usb axe, udav, url, cue, kue, smsc, udav[*], upl, ur...
- Indexes:
Home |
Main Index |
Thread Index |
Old Index