From db888aed7e83559d61cff04bf002d0fb80ecbfa7 Mon Sep 17 00:00:00 2001 From: Ulrich Kunitz Date: Tue, 29 Aug 2006 23:50:29 +0100 Subject: [PATCH] zd1211rw: Fix of signal strength and quality measurement Caused by a documentation issue I mixed up fields of the zd_status structure. This patch fixes it and improves also the average computation, which is now using only measurements of packets sent by the access point. Signed-off-by: Ulrich Kunitz Signed-off-by: Daniel Drake Signed-off-by: John W. Linville --- drivers/net/wireless/zd1211rw/zd_chip.c | 61 +++++++++++++++++++++++++-------- drivers/net/wireless/zd1211rw/zd_mac.c | 43 ++++++++++++++++++----- drivers/net/wireless/zd1211rw/zd_mac.h | 11 +++--- 3 files changed, 88 insertions(+), 27 deletions(-) (limited to 'drivers') diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c index da9d06bdb818..aa792821854e 100644 --- a/drivers/net/wireless/zd1211rw/zd_chip.c +++ b/drivers/net/wireless/zd1211rw/zd_chip.c @@ -1430,9 +1430,43 @@ static int ofdm_qual_db(u8 status_quality, u8 rate, unsigned int size) break; } + switch (rate) { + case ZD_OFDM_RATE_6M: + case ZD_OFDM_RATE_9M: + i += 3; + break; + case ZD_OFDM_RATE_12M: + case ZD_OFDM_RATE_18M: + i += 5; + break; + case ZD_OFDM_RATE_24M: + case ZD_OFDM_RATE_36M: + i += 9; + break; + case ZD_OFDM_RATE_48M: + case ZD_OFDM_RATE_54M: + i += 15; + break; + default: + return -EINVAL; + } + return i; } +static int ofdm_qual_percent(u8 status_quality, u8 rate, unsigned int size) +{ + int r; + + r = ofdm_qual_db(status_quality, rate, size); + ZD_ASSERT(r >= 0); + if (r < 0) + r = 0; + + r = (r * 100)/29; + return r <= 100 ? r : 100; +} + static unsigned int log10times100(unsigned int x) { static const u8 log10[] = { @@ -1476,31 +1510,28 @@ static int cck_snr_db(u8 status_quality) return r; } -static int rx_qual_db(const void *rx_frame, unsigned int size, - const struct rx_status *status) +static int cck_qual_percent(u8 status_quality) { - return (status->frame_status&ZD_RX_OFDM) ? - ofdm_qual_db(status->signal_quality_ofdm, - zd_ofdm_plcp_header_rate(rx_frame), - size) : - cck_snr_db(status->signal_quality_cck); + int r; + + r = cck_snr_db(status_quality); + r = (100*r)/17; + return r <= 100 ? r : 100; } u8 zd_rx_qual_percent(const void *rx_frame, unsigned int size, const struct rx_status *status) { - int r = rx_qual_db(rx_frame, size, status); - if (r < 0) - r = 0; - r = (r * 100) / 14; - if (r > 100) - r = 100; - return r; + return (status->frame_status&ZD_RX_OFDM) ? + ofdm_qual_percent(status->signal_quality_ofdm, + zd_ofdm_plcp_header_rate(rx_frame), + size) : + cck_qual_percent(status->signal_quality_cck); } u8 zd_rx_strength_percent(u8 rssi) { - int r = (rssi*100) / 30; + int r = (rssi*100) / 41; if (r > 100) r = 100; return (u8) r; diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c index d6f3e02a0b54..a9bd80a08613 100644 --- a/drivers/net/wireless/zd1211rw/zd_mac.c +++ b/drivers/net/wireless/zd1211rw/zd_mac.c @@ -816,13 +816,25 @@ static int filter_rx(struct ieee80211_device *ieee, return -EINVAL; } -static void update_qual_rssi(struct zd_mac *mac, u8 qual_percent, u8 rssi) +static void update_qual_rssi(struct zd_mac *mac, + const u8 *buffer, unsigned int length, + u8 qual_percent, u8 rssi_percent) { unsigned long flags; + struct ieee80211_hdr_3addr *hdr; + int i; + + hdr = (struct ieee80211_hdr_3addr *)buffer; + if (length < offsetof(struct ieee80211_hdr_3addr, addr3)) + return; + if (memcmp(hdr->addr2, zd_mac_to_ieee80211(mac)->bssid, ETH_ALEN) != 0) + return; spin_lock_irqsave(&mac->lock, flags); - mac->qual_average = (7 * mac->qual_average + qual_percent) / 8; - mac->rssi_average = (7 * mac->rssi_average + rssi) / 8; + i = mac->stats_count % ZD_MAC_STATS_BUFFER_SIZE; + mac->qual_buffer[i] = qual_percent; + mac->rssi_buffer[i] = rssi_percent; + mac->stats_count++; spin_unlock_irqrestore(&mac->lock, flags); } @@ -853,7 +865,6 @@ static int fill_rx_stats(struct ieee80211_rx_stats *stats, if (stats->rate) stats->mask |= IEEE80211_STATMASK_RATE; - update_qual_rssi(mac, stats->signal, stats->rssi); return 0; } @@ -877,6 +888,8 @@ int zd_mac_rx(struct zd_mac *mac, const u8 *buffer, unsigned int length) sizeof(struct rx_status); buffer += ZD_PLCP_HEADER_SIZE; + update_qual_rssi(mac, buffer, length, stats.signal, stats.rssi); + r = filter_rx(ieee, buffer, length, &stats); if (r <= 0) return r; @@ -981,17 +994,31 @@ struct iw_statistics *zd_mac_get_wireless_stats(struct net_device *ndev) { struct zd_mac *mac = zd_netdev_mac(ndev); struct iw_statistics *iw_stats = &mac->iw_stats; + unsigned int i, count, qual_total, rssi_total; memset(iw_stats, 0, sizeof(struct iw_statistics)); /* We are not setting the status, because ieee->state is not updated * at all and this driver doesn't track authentication state. */ spin_lock_irq(&mac->lock); - iw_stats->qual.qual = mac->qual_average; - iw_stats->qual.level = mac->rssi_average; - iw_stats->qual.updated = IW_QUAL_QUAL_UPDATED|IW_QUAL_LEVEL_UPDATED| - IW_QUAL_NOISE_INVALID; + count = mac->stats_count < ZD_MAC_STATS_BUFFER_SIZE ? + mac->stats_count : ZD_MAC_STATS_BUFFER_SIZE; + qual_total = rssi_total = 0; + for (i = 0; i < count; i++) { + qual_total += mac->qual_buffer[i]; + rssi_total += mac->rssi_buffer[i]; + } spin_unlock_irq(&mac->lock); + iw_stats->qual.updated = IW_QUAL_NOISE_INVALID; + if (count > 0) { + iw_stats->qual.qual = qual_total / count; + iw_stats->qual.level = rssi_total / count; + iw_stats->qual.updated |= + IW_QUAL_QUAL_UPDATED|IW_QUAL_LEVEL_UPDATED; + } else { + iw_stats->qual.updated |= + IW_QUAL_QUAL_INVALID|IW_QUAL_LEVEL_INVALID; + } /* TODO: update counter */ return iw_stats; } diff --git a/drivers/net/wireless/zd1211rw/zd_mac.h b/drivers/net/wireless/zd1211rw/zd_mac.h index 71e382c589ee..b3ba49b84634 100644 --- a/drivers/net/wireless/zd1211rw/zd_mac.h +++ b/drivers/net/wireless/zd1211rw/zd_mac.h @@ -1,4 +1,4 @@ -/* zd_mac.c +/* zd_mac.h * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -87,9 +87,9 @@ struct rx_length_info { #define RX_LENGTH_INFO_TAG 0x697e struct rx_status { + u8 signal_quality_cck; /* rssi */ u8 signal_strength; - u8 signal_quality_cck; u8 signal_quality_ofdm; u8 decryption_type; u8 frame_status; @@ -120,14 +120,17 @@ enum mac_flags { MAC_FIXED_CHANNEL = 0x01, }; +#define ZD_MAC_STATS_BUFFER_SIZE 16 + struct zd_mac { struct net_device *netdev; struct zd_chip chip; spinlock_t lock; /* Unlocked reading possible */ struct iw_statistics iw_stats; - u8 qual_average; - u8 rssi_average; + unsigned int stats_count; + u8 qual_buffer[ZD_MAC_STATS_BUFFER_SIZE]; + u8 rssi_buffer[ZD_MAC_STATS_BUFFER_SIZE]; u8 regdomain; u8 default_regdomain; u8 requested_channel; -- cgit v1.2.2 From 6a9516989f94df10d9a27ba543c6b53b3e69c84a Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Mon, 11 Sep 2006 14:00:21 -0700 Subject: [PATCH] e1000: fix TX timout hang regression for 82542rev3 Commit 581d708eb47cccb5f41bc0817e50c9b004011ba8 (oct. 5 2005) introduced partial Multiqueue support for e1000 which broke macro smartness in setting up head/tail registers for 82542 rev3 chipsets, making these adapters completely non-working since 2.6.15. This commit sets the proper head and tail registers for read and write descriptor rings. Ths fix was tested on an 82542 rev3 NIC and newer NICs. Signed-off-by: Auke Kok Signed-off-by: Jeff Garzik --- drivers/net/e1000/e1000_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c index 726f43d55937..98ef9f85482f 100644 --- a/drivers/net/e1000/e1000_main.c +++ b/drivers/net/e1000/e1000_main.c @@ -1433,8 +1433,8 @@ e1000_configure_tx(struct e1000_adapter *adapter) E1000_WRITE_REG(hw, TDBAL, (tdba & 0x00000000ffffffffULL)); E1000_WRITE_REG(hw, TDT, 0); E1000_WRITE_REG(hw, TDH, 0); - adapter->tx_ring[0].tdh = E1000_TDH; - adapter->tx_ring[0].tdt = E1000_TDT; + adapter->tx_ring[0].tdh = ((hw->mac_type >= e1000_82543) ? E1000_TDH : E1000_82542_TDH); + adapter->tx_ring[0].tdt = ((hw->mac_type >= e1000_82543) ? E1000_TDT : E1000_82542_TDT); break; } @@ -1840,8 +1840,8 @@ e1000_configure_rx(struct e1000_adapter *adapter) E1000_WRITE_REG(hw, RDBAL, (rdba & 0x00000000ffffffffULL)); E1000_WRITE_REG(hw, RDT, 0); E1000_WRITE_REG(hw, RDH, 0); - adapter->rx_ring[0].rdh = E1000_RDH; - adapter->rx_ring[0].rdt = E1000_RDT; + adapter->rx_ring[0].rdh = ((hw->mac_type >= e1000_82543) ? E1000_RDH : E1000_82542_RDH); + adapter->rx_ring[0].rdt = ((hw->mac_type >= e1000_82543) ? E1000_RDT : E1000_82542_RDT); break; } -- cgit v1.2.2 From a4f5749ba6e3f23ae4a137cee10324830db4d081 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 12 Sep 2006 20:35:49 -0700 Subject: [PATCH] libata: ignore CFA signature while sanity-checking an ATAPI device 0x848a in ID word 0 indicates CFA device iff the ID data is obtained from IDENTIFY DEVICE. For ATAPI devices, 0x848a in ID work 0 indicates valid ATAPI device. Fix sanity check in ata_dev_read_id() such that ATAPI devices reporting 0x848a in ID word 0 is not handled as error. The problem is identified by J.A. Magallon with HL-DT-ST DVDRAM GSA-4120B. Signed-off-by: Tejun Helo Cc: J.A. Magallon Acked-by: Jeff Garzik Acked-by: Alan Cox Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/scsi/libata-core.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 73dd6c8deede..427b73a3886a 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -1256,10 +1256,15 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, swap_buf_le16(id, ATA_ID_WORDS); /* sanity check */ - if ((class == ATA_DEV_ATA) != (ata_id_is_ata(id) | ata_id_is_cfa(id))) { - rc = -EINVAL; - reason = "device reports illegal type"; - goto err_out; + rc = -EINVAL; + reason = "device reports illegal type"; + + if (class == ATA_DEV_ATA) { + if (!ata_id_is_ata(id) && !ata_id_is_cfa(id)) + goto err_out; + } else { + if (ata_id_is_ata(id)) + goto err_out; } if (post_reset && class == ATA_DEV_ATA) { -- cgit v1.2.2 From e11db063d86d0ef9d7903cb463bb542b5d4e9ddd Mon Sep 17 00:00:00 2001 From: Michael De Backer Date: Tue, 12 Sep 2006 20:35:53 -0700 Subject: [PATCH] alim15x3.c: M5229 (rev c8) support for DMA cd-writer Configuration bits are not set properly for DMA on some chipset revisions. It has already been corrected for M5229 (rev c7) but not for M5229 (rev c8). This leads to the bug described at http://bugzilla.kernel.org/show_bug.cgi?id=5786 (lost interrupt + ide bus hangs). Signed-off-by: Michael De Backer Acked-by: Alan Cox Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/ide/pci/alim15x3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c index 351dab2fcacf..d419e4bb54f4 100644 --- a/drivers/ide/pci/alim15x3.c +++ b/drivers/ide/pci/alim15x3.c @@ -730,7 +730,7 @@ static unsigned int __devinit ata66_ali15x3 (ide_hwif_t *hwif) if(m5229_revision <= 0x20) tmpbyte = (tmpbyte & (~0x02)) | 0x01; - else if (m5229_revision == 0xc7) + else if (m5229_revision == 0xc7 || m5229_revision == 0xc8) tmpbyte |= 0x03; else tmpbyte |= 0x01; -- cgit v1.2.2 From 7fbb36451a91de6e8f9ece4f1f1ee9bd8ebf838a Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Tue, 12 Sep 2006 20:35:54 -0700 Subject: [PATCH] SCSI: lockdep annotation in scsi_send_eh_cmnd Fixup for lockdep enabled kernels: Annotate an on-stack completion. Signed-off-by: Stefan Richter Acked-by: Ingo Molnar Cc: James Bottomley Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/scsi/scsi_error.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index a8ed5a22009d..3d355d054612 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -466,7 +466,7 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd, struct scsi_device *sdev = scmd->device; struct Scsi_Host *shost = sdev->host; int old_result = scmd->result; - DECLARE_COMPLETION(done); + DECLARE_COMPLETION_ONSTACK(done); unsigned long timeleft; unsigned long flags; unsigned char old_cmnd[MAX_COMMAND_SIZE]; -- cgit v1.2.2 From 1883c5aba9973331e3ff0050e05707fe8e84fe0d Mon Sep 17 00:00:00 2001 From: Mike Miller Date: Tue, 12 Sep 2006 20:36:07 -0700 Subject: [PATCH] cciss: version update, new hw Add support for new hardware and bumps the version to 3.6.10. It seems there were several changes introduced including soft_irq. I decided to bump the major number to reflect these changes. Since we're still supporting older vendor kernels I need some way differentiate between kernel versions <=2.6.10 and newer kernels >=2.6.16. Signed-off-by: Mike Miller Cc: Jens Axboe Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/block/cciss.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index 7b0eca703a67..2cd3391ff878 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -48,14 +48,14 @@ #include #define CCISS_DRIVER_VERSION(maj,min,submin) ((maj<<16)|(min<<8)|(submin)) -#define DRIVER_NAME "HP CISS Driver (v 2.6.10)" -#define DRIVER_VERSION CCISS_DRIVER_VERSION(2,6,10) +#define DRIVER_NAME "HP CISS Driver (v 3.6.10)" +#define DRIVER_VERSION CCISS_DRIVER_VERSION(3,6,10) /* Embedded module documentation macros - see modules.h */ MODULE_AUTHOR("Hewlett-Packard Company"); -MODULE_DESCRIPTION("Driver for HP Controller SA5xxx SA6xxx version 2.6.10"); +MODULE_DESCRIPTION("Driver for HP Controller SA5xxx SA6xxx version 3.6.10"); MODULE_SUPPORTED_DEVICE("HP SA5i SA5i+ SA532 SA5300 SA5312 SA641 SA642 SA6400" - " SA6i P600 P800 P400 P400i E200 E200i"); + " SA6i P600 P800 P400 P400i E200 E200i E500"); MODULE_LICENSE("GPL"); #include "cciss_cmd.h" @@ -82,6 +82,7 @@ static const struct pci_device_id cciss_pci_device_id[] = { {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103C, 0x3213}, {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103C, 0x3214}, {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103C, 0x3215}, + {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, 0x103C, 0x3233}, {0,} }; @@ -110,6 +111,7 @@ static struct board_type products[] = { {0x3213103C, "Smart Array E200i", &SA5_access}, {0x3214103C, "Smart Array E200i", &SA5_access}, {0x3215103C, "Smart Array E200i", &SA5_access}, + {0x3233103C, "Smart Array E500", &SA5_access}, }; /* How long to wait (in milliseconds) for board to go into simple mode */ -- cgit v1.2.2 From 71d28725548be203e8b8f6ad63b1f64fd7f02d4d Mon Sep 17 00:00:00 2001 From: Dale Farnsworth Date: Wed, 13 Sep 2006 09:21:08 -0700 Subject: [PATCH] mv643xx_eth: Unmap DMA buffers in receive path Fix a missing call to dma_unmap_single() in the receive path. Without this call, errors have been observed on non-cache-coherent systems. Signed-off-by Dale Farnsworth Signed-off-by: Jeff Garzik --- drivers/net/mv643xx_eth.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c index 760c61b98867..eeab1df5bef3 100644 --- a/drivers/net/mv643xx_eth.c +++ b/drivers/net/mv643xx_eth.c @@ -385,6 +385,8 @@ static int mv643xx_eth_receive_queue(struct net_device *dev, int budget) struct pkt_info pkt_info; while (budget-- > 0 && eth_port_receive(mp, &pkt_info) == ETH_OK) { + dma_unmap_single(NULL, pkt_info.buf_ptr, RX_SKB_SIZE, + DMA_FROM_DEVICE); mp->rx_desc_count--; received_packets++; -- cgit v1.2.2 From add7afc756eddd5d02fd986d19e6300b3e1a5ae8 Mon Sep 17 00:00:00 2001 From: Ishai Rabinovitz Date: Thu, 7 Sep 2006 15:00:01 +0300 Subject: IB/srp: Don't schedule reconnect from srp If there is a problem in the connection, the SCSI mid-layer will eventually call srp_reset_host(), which will call srp_reconnect(), so we do not need to schedule a call to srp_reconnect_work() from srp_completion(). Removing this prevents srp_reset_host() from failing if a reconnect scheduled from srp_completion() is already in progress, which in turn was causing crashes as both SCSI midlayer and srp_reconnect() were cancelling commands. Signed-off-by: Ishai Rabinovitz Signed-off-by: Michael S. Tsirkin Signed-off-by: Roland Dreier --- drivers/infiniband/ulp/srp/ib_srp.c | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'drivers') diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 8257d5a2c8f8..fd8344cdc0db 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -799,13 +799,6 @@ static void srp_process_rsp(struct srp_target_port *target, struct srp_rsp *rsp) spin_unlock_irqrestore(target->scsi_host->host_lock, flags); } -static void srp_reconnect_work(void *target_ptr) -{ - struct srp_target_port *target = target_ptr; - - srp_reconnect_target(target); -} - static void srp_handle_recv(struct srp_target_port *target, struct ib_wc *wc) { struct srp_iu *iu; @@ -858,7 +851,6 @@ static void srp_completion(struct ib_cq *cq, void *target_ptr) { struct srp_target_port *target = target_ptr; struct ib_wc wc; - unsigned long flags; ib_req_notify_cq(cq, IB_CQ_NEXT_COMP); while (ib_poll_cq(cq, 1, &wc) > 0) { @@ -866,10 +858,6 @@ static void srp_completion(struct ib_cq *cq, void *target_ptr) printk(KERN_ERR PFX "failed %s status %d\n", wc.wr_id & SRP_OP_RECV ? "receive" : "send", wc.status); - spin_lock_irqsave(target->scsi_host->host_lock, flags); - if (target->state == SRP_TARGET_LIVE) - schedule_work(&target->work); - spin_unlock_irqrestore(target->scsi_host->host_lock, flags); break; } @@ -1705,8 +1693,6 @@ static ssize_t srp_create_target(struct class_device *class_dev, target->scsi_host = target_host; target->srp_host = host; - INIT_WORK(&target->work, srp_reconnect_work, target); - INIT_LIST_HEAD(&target->free_reqs); INIT_LIST_HEAD(&target->req_queue); for (i = 0; i < SRP_SQ_SIZE; ++i) { -- cgit v1.2.2 From c11bd42a7676b49d41c780f2ede3709204f8da83 Mon Sep 17 00:00:00 2001 From: Eli Cohen Date: Thu, 14 Sep 2006 13:51:41 -0700 Subject: IPoIB: Retry failed send-only multicast group joins When a send-only multicast group join fails, mcast->query must be set to NULL. Otherwise, IPoIB will never retry the join and the multicast group will never be reachable. Signed-off-by: Eli Cohen Signed-off-by: Michael S. Tsirkin Signed-off-by: Roland Dreier --- drivers/infiniband/ulp/ipoib/ipoib_multicast.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c index b5e6a7be603d..ec356ce7cdcd 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c @@ -326,6 +326,7 @@ ipoib_mcast_sendonly_join_complete(int status, /* Clear the busy flag so we try again */ clear_bit(IPOIB_MCAST_FLAG_BUSY, &mcast->flags); + mcast->query = NULL; } complete(&mcast->done); -- cgit v1.2.2 From d5bb75999cb5733ad936ff000023221fe7a13c59 Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Wed, 13 Sep 2006 15:01:54 +0300 Subject: RDMA/cma: Increase the IB CM retry count in CMA 3 seems like a low number of IB Communication Manager retries to set; we see connections failing under stress, and in any case 3 just looks like an arbitrary number. 15 is the max value allowed by the InfiniBand spec. Signed-off-by: Michael S. Tsirkin Acked-by: Sean Hefty Signed-off-by: Roland Dreier --- drivers/infiniband/core/cma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index d6f99d5720fc..5d625a81193f 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -49,7 +49,7 @@ MODULE_DESCRIPTION("Generic RDMA CM Agent"); MODULE_LICENSE("Dual BSD/GPL"); #define CMA_CM_RESPONSE_TIMEOUT 20 -#define CMA_MAX_CM_RETRIES 3 +#define CMA_MAX_CM_RETRIES 15 static void cma_add_one(struct ib_device *device); static void cma_remove_one(struct ib_device *device); -- cgit v1.2.2 From 55ebcc38a5f6d40e4c41447e413ef842b803980f Mon Sep 17 00:00:00 2001 From: Arnaud Patard Date: Sat, 16 Sep 2006 12:15:36 -0700 Subject: [PATCH] IPMI: Fix oops on ipmi_msghandler removal for non ipmi systems When the ipmi_si module is loaded on a system without any ipmi device, it fails with nodev. It would be fine if all resources were freed. A call to device_unregister() is missing, resulting to a oops when you remove the ipmi_msghandler. Signed-off-by: Arnaud Patard Acked-by: Corey Minyard Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/ipmi/ipmi_si_intf.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index f57eba0bf253..31b59403b632 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c @@ -2481,6 +2481,7 @@ static __devinit int init_ipmi_si(void) #ifdef CONFIG_PCI pci_unregister_driver(&ipmi_pci_driver); #endif + driver_unregister(&ipmi_driver); printk("ipmi_si: Unable to find any System Interface(s)\n"); return -ENODEV; } else { -- cgit v1.2.2 From b64074e46a9c2a7d5c66eff066a7c0b58377a143 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Sat, 16 Sep 2006 12:15:38 -0700 Subject: [PATCH] hvc_console suspend fix Fix http://bugzilla.kernel.org/show_bug.cgi?id=7152 Cc: Michael Tautschnig Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/hvc_console.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c index ca2f538e549e..613d67f1c7f0 100644 --- a/drivers/char/hvc_console.c +++ b/drivers/char/hvc_console.c @@ -668,6 +668,7 @@ int khvcd(void *unused) do { poll_mask = 0; hvc_kicked = 0; + try_to_freeze(); wmb(); if (cpus_empty(cpus_in_xmon)) { spin_lock(&hvc_structs_lock); -- cgit v1.2.2 From 4064d5ef26a04d9e34e4c0f348e30f14ab6828d8 Mon Sep 17 00:00:00 2001 From: Corey Minyard Date: Sat, 16 Sep 2006 12:15:41 -0700 Subject: [PATCH] IPMI: fix handling of OEM flags If one of the OEM flags becomes set in the flags from the hardware, the driver could hang if no OEM handler was set. Fix the code to handle this. This was tested by setting the flags by hand after they were fetched. Signed-off-by: Corey Minyard Ackde-by: Matt Domsch Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/ipmi/ipmi_si_intf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index 31b59403b632..abca98beac14 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c @@ -402,10 +402,10 @@ static void handle_flags(struct smi_info *smi_info) smi_info->curr_msg->data, smi_info->curr_msg->data_size); smi_info->si_state = SI_GETTING_EVENTS; - } else if (smi_info->msg_flags & OEM_DATA_AVAIL) { - if (smi_info->oem_data_avail_handler) - if (smi_info->oem_data_avail_handler(smi_info)) - goto retry; + } else if (smi_info->msg_flags & OEM_DATA_AVAIL && + smi_info->oem_data_avail_handler) { + if (smi_info->oem_data_avail_handler(smi_info)) + goto retry; } else { smi_info->si_state = SI_NORMAL; } -- cgit v1.2.2 From 96da96065bd66164acc3c8a1ea6db4ee765537e9 Mon Sep 17 00:00:00 2001 From: Vitaly Wool Date: Sat, 16 Sep 2006 12:15:58 -0700 Subject: [PATCH] MTD NAND: OOB buffer offset fixups In the case of data-pad-ecc-pad-data... layout the oob start position has to be sizeof(data) in nand_write_oob_syndrom(). In nand_fill_oob() we need to copy to buf + buffer offset instead of buf + write offset. Signed-off-by: Vitaly Wool Signed-off-by: Thomas Gleixner Signed-off-by: David Woodhouse Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/mtd/nand/nand_base.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index c8cbc00243fe..0a54d003ef34 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -1204,7 +1204,7 @@ static int nand_write_oob_syndrome(struct mtd_info *mtd, pos = steps * (eccsize + chunk); steps = 0; } else - pos = eccsize + chunk; + pos = eccsize; chip->cmdfunc(mtd, NAND_CMD_SEQIN, pos, page); for (i = 0; i < steps; i++) { @@ -1567,7 +1567,7 @@ static uint8_t *nand_fill_oob(struct nand_chip *chip, uint8_t *oob, bytes = min_t(size_t, len, free->length); boffs = free->offset; } - memcpy(chip->oob_poi + woffs, oob, bytes); + memcpy(chip->oob_poi + boffs, oob, bytes); oob += bytes; } return oob; -- cgit v1.2.2 From 4c7ae6ea595aef732d029647d708eaeac7238036 Mon Sep 17 00:00:00 2001 From: Frank Pavlic Date: Fri, 15 Sep 2006 16:25:03 +0200 Subject: [PATCH] s390: minor s390 network driver fixes Hi Jeff, this is a RESEND of the nine s390 network driver patches. I finally found that my kmail corrupted almost every patch I sent the last time. Please apply these 9 patches and forget about my first attempt! Sorry for the delay, I had some fights with sendmail, IMAP and mutt configuration. Frank [RESEND PATCH 1/9] s390: minor s390 network driver fixes From: Frank Pavlic - iucv driver: use do { } while (0) constructs instead of empty defines to avoid compile bugs. - ctc driver: missing lock initialization added - lcs driver: BUG_ON usage was removed accidently with the last lcs patch. Put them back in place. Signed-off-by: Frank Pavlic Signed-off-by: Jeff Garzik --- drivers/s390/net/ctcmain.c | 3 +++ drivers/s390/net/iucv.c | 4 ++-- drivers/s390/net/lcs.c | 13 +++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/s390/net/ctcmain.c b/drivers/s390/net/ctcmain.c index 8a4b58120146..3257c22dd79c 100644 --- a/drivers/s390/net/ctcmain.c +++ b/drivers/s390/net/ctcmain.c @@ -1714,6 +1714,9 @@ add_channel(struct ccw_device *cdev, enum channel_types type) kfree(ch); return 0; } + + spin_lock_init(&ch->collect_lock); + fsm_settimer(ch->fsm, &ch->timer); skb_queue_head_init(&ch->io_queue); skb_queue_head_init(&ch->collect_queue); diff --git a/drivers/s390/net/iucv.c b/drivers/s390/net/iucv.c index 0e863df4027a..821dde86e240 100644 --- a/drivers/s390/net/iucv.c +++ b/drivers/s390/net/iucv.c @@ -335,8 +335,8 @@ do { \ #else -#define iucv_debug(lvl, fmt, args...) -#define iucv_dumpit(title, buf, len) +#define iucv_debug(lvl, fmt, args...) do { } while (0) +#define iucv_dumpit(title, buf, len) do { } while (0) #endif diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c index 2eded55ae88d..16ac68c27a27 100644 --- a/drivers/s390/net/lcs.c +++ b/drivers/s390/net/lcs.c @@ -670,9 +670,8 @@ lcs_ready_buffer(struct lcs_channel *channel, struct lcs_buffer *buffer) int index, rc; LCS_DBF_TEXT(5, trace, "rdybuff"); - if (buffer->state != BUF_STATE_LOCKED && - buffer->state != BUF_STATE_PROCESSED) - BUG(); + BUG_ON(buffer->state != BUF_STATE_LOCKED && + buffer->state != BUF_STATE_PROCESSED); spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags); buffer->state = BUF_STATE_READY; index = buffer - channel->iob; @@ -696,8 +695,7 @@ __lcs_processed_buffer(struct lcs_channel *channel, struct lcs_buffer *buffer) int index, prev, next; LCS_DBF_TEXT(5, trace, "prcsbuff"); - if (buffer->state != BUF_STATE_READY) - BUG(); + BUG_ON(buffer->state != BUF_STATE_READY); buffer->state = BUF_STATE_PROCESSED; index = buffer - channel->iob; prev = (index - 1) & (LCS_NUM_BUFFS - 1); @@ -729,9 +727,8 @@ lcs_release_buffer(struct lcs_channel *channel, struct lcs_buffer *buffer) unsigned long flags; LCS_DBF_TEXT(5, trace, "relbuff"); - if (buffer->state != BUF_STATE_LOCKED && - buffer->state != BUF_STATE_PROCESSED) - BUG(); + BUG_ON(buffer->state != BUF_STATE_LOCKED && + buffer->state != BUF_STATE_PROCESSED); spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags); buffer->state = BUF_STATE_EMPTY; spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags); -- cgit v1.2.2 From 16a83b30772ad9f20d4233f8872405ad52165cd0 Mon Sep 17 00:00:00 2001 From: Frank Pavlic Date: Fri, 15 Sep 2006 16:25:19 +0200 Subject: [PATCH] s390: netiucv driver fixes [PATCH 2/9] s390: netiucv driver fixes From: Frank Pavlic - missing lock initialization added - avoid duplicate iucv-interfaces to the same peer - rw-lock added for manipulating the list of defined iucv connections Signed-off-by: Frank Pavlic Signed-off-by: Jeff Garzik --- drivers/s390/net/netiucv.c | 80 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 64 insertions(+), 16 deletions(-) (limited to 'drivers') diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c index 5d6e6cbfa360..d7d1cc0a5c8e 100644 --- a/drivers/s390/net/netiucv.c +++ b/drivers/s390/net/netiucv.c @@ -112,7 +112,12 @@ struct iucv_connection { /** * Linked list of all connection structs. */ -static struct iucv_connection *iucv_connections; +struct iucv_connection_struct { + struct iucv_connection *iucv_connections; + rwlock_t iucv_rwlock; +}; + +static struct iucv_connection_struct iucv_conns; /** * Representation of event-data for the @@ -1368,8 +1373,10 @@ user_write (struct device *dev, struct device_attribute *attr, const char *buf, struct net_device *ndev = priv->conn->netdev; char *p; char *tmp; - char username[10]; + char username[9]; int i; + struct iucv_connection **clist = &iucv_conns.iucv_connections; + unsigned long flags; IUCV_DBF_TEXT(trace, 3, __FUNCTION__); if (count>9) { @@ -1382,7 +1389,7 @@ user_write (struct device *dev, struct device_attribute *attr, const char *buf, tmp = strsep((char **) &buf, "\n"); for (i=0, p=tmp; i<8 && *p; i++, p++) { if (isalnum(*p) || (*p == '$')) - username[i]= *p; + username[i]= toupper(*p); else if (*p == '\n') { /* trailing lf, grr */ break; @@ -1395,11 +1402,11 @@ user_write (struct device *dev, struct device_attribute *attr, const char *buf, return -EINVAL; } } - while (i<9) + while (i<8) username[i++] = ' '; - username[9] = '\0'; + username[8] = '\0'; - if (memcmp(username, priv->conn->userid, 8)) { + if (memcmp(username, priv->conn->userid, 9)) { /* username changed */ if (ndev->flags & (IFF_UP | IFF_RUNNING)) { PRINT_WARN( @@ -1410,6 +1417,19 @@ user_write (struct device *dev, struct device_attribute *attr, const char *buf, return -EBUSY; } } + read_lock_irqsave(&iucv_conns.iucv_rwlock, flags); + while (*clist) { + if (!strncmp(username, (*clist)->userid, 9) || + ((*clist)->netdev != ndev)) + break; + clist = &((*clist)->next); + } + read_unlock_irqrestore(&iucv_conns.iucv_rwlock, flags); + if (*clist) { + PRINT_WARN("netiucv: Connection to %s already exists\n", + username); + return -EEXIST; + } memcpy(priv->conn->userid, username, 9); return count; @@ -1781,13 +1801,15 @@ netiucv_unregister_device(struct device *dev) static struct iucv_connection * netiucv_new_connection(struct net_device *dev, char *username) { - struct iucv_connection **clist = &iucv_connections; + unsigned long flags; + struct iucv_connection **clist = &iucv_conns.iucv_connections; struct iucv_connection *conn = kzalloc(sizeof(struct iucv_connection), GFP_KERNEL); if (conn) { skb_queue_head_init(&conn->collect_queue); skb_queue_head_init(&conn->commit_queue); + spin_lock_init(&conn->collect_lock); conn->max_buffsize = NETIUCV_BUFSIZE_DEFAULT; conn->netdev = dev; @@ -1822,8 +1844,10 @@ netiucv_new_connection(struct net_device *dev, char *username) fsm_newstate(conn->fsm, CONN_STATE_STOPPED); } + write_lock_irqsave(&iucv_conns.iucv_rwlock, flags); conn->next = *clist; *clist = conn; + write_unlock_irqrestore(&iucv_conns.iucv_rwlock, flags); } return conn; } @@ -1835,14 +1859,17 @@ netiucv_new_connection(struct net_device *dev, char *username) static void netiucv_remove_connection(struct iucv_connection *conn) { - struct iucv_connection **clist = &iucv_connections; + struct iucv_connection **clist = &iucv_conns.iucv_connections; + unsigned long flags; IUCV_DBF_TEXT(trace, 3, __FUNCTION__); if (conn == NULL) return; + write_lock_irqsave(&iucv_conns.iucv_rwlock, flags); while (*clist) { if (*clist == conn) { *clist = conn->next; + write_unlock_irqrestore(&iucv_conns.iucv_rwlock, flags); if (conn->handle) { iucv_unregister_program(conn->handle); conn->handle = NULL; @@ -1855,6 +1882,7 @@ netiucv_remove_connection(struct iucv_connection *conn) } clist = &((*clist)->next); } + write_unlock_irqrestore(&iucv_conns.iucv_rwlock, flags); } /** @@ -1947,9 +1975,11 @@ static ssize_t conn_write(struct device_driver *drv, const char *buf, size_t count) { char *p; - char username[10]; + char username[9]; int i, ret; struct net_device *dev; + struct iucv_connection **clist = &iucv_conns.iucv_connections; + unsigned long flags; IUCV_DBF_TEXT(trace, 3, __FUNCTION__); if (count>9) { @@ -1960,7 +1990,7 @@ conn_write(struct device_driver *drv, const char *buf, size_t count) for (i=0, p=(char *)buf; i<8 && *p; i++, p++) { if (isalnum(*p) || (*p == '$')) - username[i]= *p; + username[i]= toupper(*p); else if (*p == '\n') { /* trailing lf, grr */ break; @@ -1971,9 +2001,22 @@ conn_write(struct device_driver *drv, const char *buf, size_t count) return -EINVAL; } } - while (i<9) + while (i<8) username[i++] = ' '; - username[9] = '\0'; + username[8] = '\0'; + + read_lock_irqsave(&iucv_conns.iucv_rwlock, flags); + while (*clist) { + if (!strncmp(username, (*clist)->userid, 9)) + break; + clist = &((*clist)->next); + } + read_unlock_irqrestore(&iucv_conns.iucv_rwlock, flags); + if (*clist) { + PRINT_WARN("netiucv: Connection to %s already exists\n", + username); + return -EEXIST; + } dev = netiucv_init_netdevice(username); if (!dev) { PRINT_WARN( @@ -2015,7 +2058,8 @@ DRIVER_ATTR(connection, 0200, NULL, conn_write); static ssize_t remove_write (struct device_driver *drv, const char *buf, size_t count) { - struct iucv_connection **clist = &iucv_connections; + struct iucv_connection **clist = &iucv_conns.iucv_connections; + unsigned long flags; struct net_device *ndev; struct netiucv_priv *priv; struct device *dev; @@ -2026,7 +2070,7 @@ remove_write (struct device_driver *drv, const char *buf, size_t count) IUCV_DBF_TEXT(trace, 3, __FUNCTION__); if (count >= IFNAMSIZ) - count = IFNAMSIZ-1; + count = IFNAMSIZ - 1;; for (i=0, p=(char *)buf; inetdev; priv = (struct netiucv_priv*)ndev->priv; @@ -2047,6 +2092,7 @@ remove_write (struct device_driver *drv, const char *buf, size_t count) clist = &((*clist)->next); continue; } + read_unlock_irqrestore(&iucv_conns.iucv_rwlock, flags); if (ndev->flags & (IFF_UP | IFF_RUNNING)) { PRINT_WARN( "netiucv: net device %s active with peer %s\n", @@ -2060,6 +2106,7 @@ remove_write (struct device_driver *drv, const char *buf, size_t count) netiucv_unregister_device(dev); return count; } + read_unlock_irqrestore(&iucv_conns.iucv_rwlock, flags); PRINT_WARN("netiucv: net device %s unknown\n", name); IUCV_DBF_TEXT(data, 2, "remove_write: unknown device\n"); return -EINVAL; @@ -2077,8 +2124,8 @@ static void __exit netiucv_exit(void) { IUCV_DBF_TEXT(trace, 3, __FUNCTION__); - while (iucv_connections) { - struct net_device *ndev = iucv_connections->netdev; + while (iucv_conns.iucv_connections) { + struct net_device *ndev = iucv_conns.iucv_connections->netdev; struct netiucv_priv *priv = (struct netiucv_priv*)ndev->priv; struct device *dev = priv->dev; @@ -2120,6 +2167,7 @@ netiucv_init(void) if (!ret) { ret = driver_create_file(&netiucv_driver, &driver_attr_remove); netiucv_banner(); + rwlock_init(&iucv_conns.iucv_rwlock); } else { PRINT_ERR("NETIUCV: failed to add driver attribute.\n"); IUCV_DBF_TEXT_(setup, 2, "ret %d from driver_create_file\n", ret); -- cgit v1.2.2 From f449c565ea324397f83adb65e9d0b599cfbc7dab Mon Sep 17 00:00:00 2001 From: Frank Pavlic Date: Fri, 15 Sep 2006 16:25:39 +0200 Subject: [PATCH] s390: Makefile cleanup [PATCH 3/9] s390: Makefile cleanup From: Frank Pavlic remove CONFIG_MPC from Makefile which was introduced accidently in the past. Signed-off-by: Frank Pavlic Signed-off-by: Jeff Garzik --- drivers/s390/net/Makefile | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers') diff --git a/drivers/s390/net/Makefile b/drivers/s390/net/Makefile index 6775a837d646..4777e36a922f 100644 --- a/drivers/s390/net/Makefile +++ b/drivers/s390/net/Makefile @@ -10,7 +10,6 @@ obj-$(CONFIG_SMSGIUCV) += smsgiucv.o obj-$(CONFIG_CTC) += ctc.o fsm.o cu3088.o obj-$(CONFIG_LCS) += lcs.o cu3088.o obj-$(CONFIG_CLAW) += claw.o cu3088.o -obj-$(CONFIG_MPC) += ctcmpc.o fsm.o cu3088.o qeth-y := qeth_main.o qeth_mpc.o qeth_sys.o qeth_eddp.o qeth-$(CONFIG_PROC_FS) += qeth_proc.o obj-$(CONFIG_QETH) += qeth.o -- cgit v1.2.2 From 330b636908b44e73c714fb2632602ddd96f72c01 Mon Sep 17 00:00:00 2001 From: Frank Pavlic Date: Fri, 15 Sep 2006 16:25:56 +0200 Subject: [PATCH] s390: qeth driver fixes [1/6] [PATCH 4/9] s390: qeth driver fixes [1/6] From: Frank Pavlic - Drop incoming packets with vlan_tag set if card->vlangrp is not set. - use always vlan_hwaccel_rx to pass vlan frames to the stack. - fix recovery problem. Device was recovered properly but still not working. netif_carrier_on call right before recovery start fixes it. Signed-off-by: Frank Pavlic Signed-off-by: Jeff Garzik --- drivers/s390/net/qeth_main.c | 49 +++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 26 deletions(-) (limited to 'drivers') diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c index e1327b8fce00..ffff7a12b54d 100644 --- a/drivers/s390/net/qeth_main.c +++ b/drivers/s390/net/qeth_main.c @@ -1708,6 +1708,7 @@ qeth_check_ipa_data(struct qeth_card *card, struct qeth_cmd_buffer *iob) "IP address reset.\n", QETH_CARD_IFNAME(card), card->info.chpid); + netif_carrier_on(card->dev); qeth_schedule_recovery(card); return NULL; case IPA_CMD_MODCCID: @@ -2464,24 +2465,6 @@ qeth_rebuild_skb_fake_ll(struct qeth_card *card, struct sk_buff *skb, qeth_rebuild_skb_fake_ll_eth(card, skb, hdr); } -static inline void -qeth_rebuild_skb_vlan(struct qeth_card *card, struct sk_buff *skb, - struct qeth_hdr *hdr) -{ -#ifdef CONFIG_QETH_VLAN - u16 *vlan_tag; - - if (hdr->hdr.l3.ext_flags & - (QETH_HDR_EXT_VLAN_FRAME | QETH_HDR_EXT_INCLUDE_VLAN_TAG)) { - vlan_tag = (u16 *) skb_push(skb, VLAN_HLEN); - *vlan_tag = (hdr->hdr.l3.ext_flags & QETH_HDR_EXT_VLAN_FRAME)? - hdr->hdr.l3.vlan_id : *((u16 *)&hdr->hdr.l3.dest_addr[12]); - *(vlan_tag + 1) = skb->protocol; - skb->protocol = __constant_htons(ETH_P_8021Q); - } -#endif /* CONFIG_QETH_VLAN */ -} - static inline __u16 qeth_layer2_rebuild_skb(struct qeth_card *card, struct sk_buff *skb, struct qeth_hdr *hdr) @@ -2510,15 +2493,16 @@ qeth_layer2_rebuild_skb(struct qeth_card *card, struct sk_buff *skb, return vlan_id; } -static inline void +static inline __u16 qeth_rebuild_skb(struct qeth_card *card, struct sk_buff *skb, struct qeth_hdr *hdr) { + unsigned short vlan_id = 0; #ifdef CONFIG_QETH_IPV6 if (hdr->hdr.l3.flags & QETH_HDR_PASSTHRU) { skb->pkt_type = PACKET_HOST; skb->protocol = qeth_type_trans(skb, card->dev); - return; + return 0; } #endif /* CONFIG_QETH_IPV6 */ skb->protocol = htons((hdr->hdr.l3.flags & QETH_HDR_IPV6)? ETH_P_IPV6 : @@ -2540,7 +2524,13 @@ qeth_rebuild_skb(struct qeth_card *card, struct sk_buff *skb, default: skb->pkt_type = PACKET_HOST; } - qeth_rebuild_skb_vlan(card, skb, hdr); + + if (hdr->hdr.l3.ext_flags & + (QETH_HDR_EXT_VLAN_FRAME | QETH_HDR_EXT_INCLUDE_VLAN_TAG)) { + vlan_id = (hdr->hdr.l3.ext_flags & QETH_HDR_EXT_VLAN_FRAME)? + hdr->hdr.l3.vlan_id : *((u16 *)&hdr->hdr.l3.dest_addr[12]); + } + if (card->options.fake_ll) qeth_rebuild_skb_fake_ll(card, skb, hdr); else @@ -2556,6 +2546,7 @@ qeth_rebuild_skb(struct qeth_card *card, struct sk_buff *skb, else skb->ip_summed = SW_CHECKSUMMING; } + return vlan_id; } static inline void @@ -2568,6 +2559,7 @@ qeth_process_inbound_buffer(struct qeth_card *card, int offset; int rxrc; __u16 vlan_tag = 0; + __u16 *vlan_addr; /* get first element of current buffer */ element = (struct qdio_buffer_element *)&buf->buffer->element[0]; @@ -2581,7 +2573,7 @@ qeth_process_inbound_buffer(struct qeth_card *card, if (hdr->hdr.l2.id == QETH_HEADER_TYPE_LAYER2) vlan_tag = qeth_layer2_rebuild_skb(card, skb, hdr); else if (hdr->hdr.l3.id == QETH_HEADER_TYPE_LAYER3) - qeth_rebuild_skb(card, skb, hdr); + vlan_tag = qeth_rebuild_skb(card, skb, hdr); else { /*in case of OSN*/ skb_push(skb, sizeof(struct qeth_hdr)); memcpy(skb->data, hdr, sizeof(struct qeth_hdr)); @@ -2591,14 +2583,19 @@ qeth_process_inbound_buffer(struct qeth_card *card, dev_kfree_skb_any(skb); continue; } + if (card->info.type == QETH_CARD_TYPE_OSN) + rxrc = card->osn_info.data_cb(skb); + else #ifdef CONFIG_QETH_VLAN if (vlan_tag) - vlan_hwaccel_rx(skb, card->vlangrp, vlan_tag); + if (card->vlangrp) + vlan_hwaccel_rx(skb, card->vlangrp, vlan_tag); + else { + dev_kfree_skb_any(skb); + continue; + } else #endif - if (card->info.type == QETH_CARD_TYPE_OSN) - rxrc = card->osn_info.data_cb(skb); - else rxrc = netif_rx(skb); card->dev->last_rx = jiffies; card->stats.rx_packets++; -- cgit v1.2.2 From 1fda1a120b7dcddf382ad105b4783a69e81c7a2b Mon Sep 17 00:00:00 2001 From: Frank Pavlic Date: Fri, 15 Sep 2006 16:26:07 +0200 Subject: [PATCH] s390: qeth driver fixes [2/6] [PATCH 5/9] s390: qeth driver fixes [2/6] From: Frank Pavlic - fixed error handling in create_device_attributes - fixed some minor bugs in IPv4 and IPv6 address checking Signed-off-by: Frank Pavlic Signed-off-by: Jeff Garzik --- drivers/s390/net/qeth.h | 25 ++++++++++++++++--------- drivers/s390/net/qeth_sys.c | 22 ++++++++++++++++------ 2 files changed, 32 insertions(+), 15 deletions(-) (limited to 'drivers') diff --git a/drivers/s390/net/qeth.h b/drivers/s390/net/qeth.h index 619f4a0c7160..e8bd8c5ced1f 100644 --- a/drivers/s390/net/qeth.h +++ b/drivers/s390/net/qeth.h @@ -1096,10 +1096,11 @@ qeth_string_to_ipaddr4(const char *buf, __u8 *addr) { int count = 0, rc = 0; int in[4]; + char c; - rc = sscanf(buf, "%d.%d.%d.%d%n", - &in[0], &in[1], &in[2], &in[3], &count); - if (rc != 4 || count<=0) + rc = sscanf(buf, "%u.%u.%u.%u%c", + &in[0], &in[1], &in[2], &in[3], &c); + if (rc != 4 && (rc != 5 || c != '\n')) return -EINVAL; for (count = 0; count < 4; count++) { if (in[count] > 255) @@ -1123,24 +1124,28 @@ qeth_ipaddr6_to_string(const __u8 *addr, char *buf) static inline int qeth_string_to_ipaddr6(const char *buf, __u8 *addr) { - char *end, *start; + const char *end, *end_tmp, *start; __u16 *in; char num[5]; int num2, cnt, out, found, save_cnt; unsigned short in_tmp[8] = {0, }; cnt = out = found = save_cnt = num2 = 0; - end = start = (char *) buf; + end = start = buf; in = (__u16 *) addr; memset(in, 0, 16); - while (end) { - end = strchr(end,':'); + while (*end) { + end = strchr(start,':'); if (end == NULL) { - end = (char *)buf + (strlen(buf)); - out = 1; + end = buf + strlen(buf); + if ((end_tmp = strchr(start, '\n')) != NULL) + end = end_tmp; + out = 1; } if ((end - start)) { memset(num, 0, 5); + if ((end - start) > 4) + return -EINVAL; memcpy(num, start, end - start); if (!qeth_isxdigit(num)) return -EINVAL; @@ -1158,6 +1163,8 @@ qeth_string_to_ipaddr6(const char *buf, __u8 *addr) } start = ++end; } + if (cnt + save_cnt > 8) + return -EINVAL; cnt = 7; while (save_cnt) in[cnt--] = in_tmp[--save_cnt]; diff --git a/drivers/s390/net/qeth_sys.c b/drivers/s390/net/qeth_sys.c index 001497bbea16..c1f3187f37ea 100644 --- a/drivers/s390/net/qeth_sys.c +++ b/drivers/s390/net/qeth_sys.c @@ -1110,12 +1110,12 @@ qeth_parse_ipatoe(const char* buf, enum qeth_prot_versions proto, { const char *start, *end; char *tmp; - char buffer[49] = {0, }; + char buffer[40] = {0, }; start = buf; /* get address string */ end = strchr(start, '/'); - if (!end || (end-start >= 49)){ + if (!end || (end - start >= 40)){ PRINT_WARN("Invalid format for ipato_addx/delx. " "Use /\n"); return -EINVAL; @@ -1127,7 +1127,12 @@ qeth_parse_ipatoe(const char* buf, enum qeth_prot_versions proto, } start = end + 1; *mask_bits = simple_strtoul(start, &tmp, 10); - + if (!strlen(start) || + (tmp == start) || + (*mask_bits > ((proto == QETH_PROT_IPV4) ? 32 : 128))) { + PRINT_WARN("Invalid mask bits for ipato_addx/delx !\n"); + return -EINVAL; + } return 0; } @@ -1698,11 +1703,16 @@ qeth_create_device_attributes(struct device *dev) sysfs_remove_group(&dev->kobj, &qeth_device_attr_group); sysfs_remove_group(&dev->kobj, &qeth_device_ipato_group); sysfs_remove_group(&dev->kobj, &qeth_device_vipa_group); + return ret; } - if ((ret = sysfs_create_group(&dev->kobj, &qeth_device_blkt_group))) + if ((ret = sysfs_create_group(&dev->kobj, &qeth_device_blkt_group))){ + sysfs_remove_group(&dev->kobj, &qeth_device_attr_group); + sysfs_remove_group(&dev->kobj, &qeth_device_ipato_group); + sysfs_remove_group(&dev->kobj, &qeth_device_vipa_group); + sysfs_remove_group(&dev->kobj, &qeth_device_rxip_group); return ret; - - return ret; + } + return 0; } void -- cgit v1.2.2 From f7b65d70a3e6f1c97eb614964270816992d0d4b4 Mon Sep 17 00:00:00 2001 From: Frank Pavlic Date: Fri, 15 Sep 2006 16:26:19 +0200 Subject: [PATCH] s390: qeth driver fixes [3/6] [PATCH 6/9] s390: qeth driver fixes [3/6] From: Frank Pavlic fixed kernel panic caused by qeth driver: Using a bonding device qeth driver will realloc headroom for every skb coming from the bond device. Once this happens qeth frees the original skb and set the skb pointer to the new realloced skb. Under heavy transmit workload (e.g.UDP streams) through bond network device the qdio output queue might get full. In this case we return with EBUSY from qeth_send_packet. Returning to qeth_hard_start_xmit routine the skb address on the stack still points to the old address, which has been freed before. Returning from qeth_hard_start_xmit with EBUSY results in requeuing the skb. In this case it corrupts the qdisc queue and results in kernel panic. Signed-off-by: Frank Pavlic Signed-off-by: Jeff Garzik --- drivers/s390/net/qeth.h | 35 ++++---- drivers/s390/net/qeth_main.c | 193 ++++++++++++++++++++++--------------------- drivers/s390/net/qeth_tso.h | 2 +- 3 files changed, 114 insertions(+), 116 deletions(-) (limited to 'drivers') diff --git a/drivers/s390/net/qeth.h b/drivers/s390/net/qeth.h index e8bd8c5ced1f..c04ee915dc1b 100644 --- a/drivers/s390/net/qeth.h +++ b/drivers/s390/net/qeth.h @@ -859,23 +859,18 @@ qeth_get_ipa_adp_type(enum qeth_link_types link_type) } } -static inline int -qeth_realloc_headroom(struct qeth_card *card, struct sk_buff **skb, int size) +static inline struct sk_buff * +qeth_realloc_headroom(struct qeth_card *card, struct sk_buff *skb, int size) { - struct sk_buff *new_skb = NULL; - - if (skb_headroom(*skb) < size){ - new_skb = skb_realloc_headroom(*skb, size); - if (!new_skb) { - PRINT_ERR("qeth_prepare_skb: could " - "not realloc headroom for qeth_hdr " - "on interface %s", QETH_CARD_IFNAME(card)); - return -ENOMEM; - } - kfree_skb(*skb); - *skb = new_skb; - } - return 0; + struct sk_buff *new_skb = skb; + + if (skb_headroom(skb) >= size) + return skb; + new_skb = skb_realloc_headroom(skb, size); + if (!new_skb) + PRINT_ERR("Could not realloc headroom for qeth_hdr " + "on interface %s", QETH_CARD_IFNAME(card)); + return new_skb; } static inline struct sk_buff * @@ -885,16 +880,15 @@ qeth_pskb_unshare(struct sk_buff *skb, int pri) if (!skb_cloned(skb)) return skb; nskb = skb_copy(skb, pri); - kfree_skb(skb); /* free our shared copy */ return nskb; } static inline void * -qeth_push_skb(struct qeth_card *card, struct sk_buff **skb, int size) +qeth_push_skb(struct qeth_card *card, struct sk_buff *skb, int size) { void *hdr; - hdr = (void *) skb_push(*skb, size); + hdr = (void *) skb_push(skb, size); /* * sanity check, the Linux memory allocation scheme should * never present us cases like this one (the qdio header size plus @@ -903,8 +897,7 @@ qeth_push_skb(struct qeth_card *card, struct sk_buff **skb, int size) if ((((unsigned long) hdr) & (~(PAGE_SIZE - 1))) != (((unsigned long) hdr + size + QETH_IP_HEADER_SIZE) & (~(PAGE_SIZE - 1)))) { - PRINT_ERR("qeth_prepare_skb: misaligned " - "packet on interface %s. Discarded.", + PRINT_ERR("Misaligned packet on interface %s. Discarded.", QETH_CARD_IFNAME(card)); return NULL; } diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c index ffff7a12b54d..522fb9dd551e 100644 --- a/drivers/s390/net/qeth_main.c +++ b/drivers/s390/net/qeth_main.c @@ -3919,49 +3919,59 @@ qeth_get_ip_version(struct sk_buff *skb) } } -static inline int -qeth_prepare_skb(struct qeth_card *card, struct sk_buff **skb, - struct qeth_hdr **hdr, int ipv) +static inline struct qeth_hdr * +__qeth_prepare_skb(struct qeth_card *card, struct sk_buff *skb, int ipv) { - int rc = 0; #ifdef CONFIG_QETH_VLAN u16 *tag; -#endif - - QETH_DBF_TEXT(trace, 6, "prepskb"); - if (card->info.type == QETH_CARD_TYPE_OSN) { - *hdr = (struct qeth_hdr *)(*skb)->data; - return rc; - } - rc = qeth_realloc_headroom(card, skb, sizeof(struct qeth_hdr)); - if (rc) - return rc; -#ifdef CONFIG_QETH_VLAN - if (card->vlangrp && vlan_tx_tag_present(*skb) && + if (card->vlangrp && vlan_tx_tag_present(skb) && ((ipv == 6) || card->options.layer2) ) { /* * Move the mac addresses (6 bytes src, 6 bytes dest) * to the beginning of the new header. We are using three * memcpys instead of one memmove to save cycles. */ - skb_push(*skb, VLAN_HLEN); - memcpy((*skb)->data, (*skb)->data + 4, 4); - memcpy((*skb)->data + 4, (*skb)->data + 8, 4); - memcpy((*skb)->data + 8, (*skb)->data + 12, 4); - tag = (u16 *)((*skb)->data + 12); + skb_push(skb, VLAN_HLEN); + memcpy(skb->data, skb->data + 4, 4); + memcpy(skb->data + 4, skb->data + 8, 4); + memcpy(skb->data + 8, skb->data + 12, 4); + tag = (u16 *)(skb->data + 12); /* * first two bytes = ETH_P_8021Q (0x8100) * second two bytes = VLANID */ *tag = __constant_htons(ETH_P_8021Q); - *(tag + 1) = htons(vlan_tx_tag_get(*skb)); + *(tag + 1) = htons(vlan_tx_tag_get(skb)); } #endif - *hdr = (struct qeth_hdr *) - qeth_push_skb(card, skb, sizeof(struct qeth_hdr)); - if (*hdr == NULL) - return -EINVAL; - return 0; + return ((struct qeth_hdr *) + qeth_push_skb(card, skb, sizeof(struct qeth_hdr))); +} + +static inline void +__qeth_free_new_skb(struct sk_buff *orig_skb, struct sk_buff *new_skb) +{ + if (orig_skb != new_skb) + dev_kfree_skb_any(new_skb); +} + +static inline struct sk_buff * +qeth_prepare_skb(struct qeth_card *card, struct sk_buff *skb, + struct qeth_hdr **hdr, int ipv) +{ + struct sk_buff *new_skb; + + QETH_DBF_TEXT(trace, 6, "prepskb"); + + new_skb = qeth_realloc_headroom(card, skb, sizeof(struct qeth_hdr)); + if (new_skb == NULL) + return NULL; + *hdr = __qeth_prepare_skb(card, new_skb, ipv); + if (*hdr == NULL) { + __qeth_free_new_skb(skb, new_skb); + return NULL; + } + return new_skb; } static inline u8 @@ -4242,21 +4252,15 @@ qeth_do_send_packet_fast(struct qeth_card *card, struct qeth_qdio_out_q *queue, * check if buffer is empty to make sure that we do not 'overtake' * ourselves and try to fill a buffer that is already primed */ - if (atomic_read(&buffer->state) != QETH_QDIO_BUF_EMPTY) { - card->stats.tx_dropped++; - atomic_set(&queue->state, QETH_OUT_Q_UNLOCKED); - return -EBUSY; - } + if (atomic_read(&buffer->state) != QETH_QDIO_BUF_EMPTY) + goto out; if (ctx == NULL) queue->next_buf_to_fill = (queue->next_buf_to_fill + 1) % QDIO_MAX_BUFFERS_PER_Q; else { buffers_needed = qeth_eddp_check_buffers_for_context(queue,ctx); - if (buffers_needed < 0) { - card->stats.tx_dropped++; - atomic_set(&queue->state, QETH_OUT_Q_UNLOCKED); - return -EBUSY; - } + if (buffers_needed < 0) + goto out; queue->next_buf_to_fill = (queue->next_buf_to_fill + buffers_needed) % QDIO_MAX_BUFFERS_PER_Q; @@ -4271,6 +4275,9 @@ qeth_do_send_packet_fast(struct qeth_card *card, struct qeth_qdio_out_q *queue, qeth_flush_buffers(queue, 0, index, flush_cnt); } return 0; +out: + atomic_set(&queue->state, QETH_OUT_Q_UNLOCKED); + return -EBUSY; } static inline int @@ -4296,8 +4303,7 @@ qeth_do_send_packet(struct qeth_card *card, struct qeth_qdio_out_q *queue, * check if buffer is empty to make sure that we do not 'overtake' * ourselves and try to fill a buffer that is already primed */ - if (atomic_read(&buffer->state) != QETH_QDIO_BUF_EMPTY){ - card->stats.tx_dropped++; + if (atomic_read(&buffer->state) != QETH_QDIO_BUF_EMPTY) { atomic_set(&queue->state, QETH_OUT_Q_UNLOCKED); return -EBUSY; } @@ -4320,7 +4326,6 @@ qeth_do_send_packet(struct qeth_card *card, struct qeth_qdio_out_q *queue, * again */ if (atomic_read(&buffer->state) != QETH_QDIO_BUF_EMPTY){ - card->stats.tx_dropped++; qeth_flush_buffers(queue, 0, start_index, flush_count); atomic_set(&queue->state, QETH_OUT_Q_UNLOCKED); return -EBUSY; @@ -4331,7 +4336,6 @@ qeth_do_send_packet(struct qeth_card *card, struct qeth_qdio_out_q *queue, * free buffers) to handle eddp context */ if (qeth_eddp_check_buffers_for_context(queue,ctx) < 0){ printk("eddp tx_dropped 1\n"); - card->stats.tx_dropped++; rc = -EBUSY; goto out; } @@ -4343,7 +4347,6 @@ qeth_do_send_packet(struct qeth_card *card, struct qeth_qdio_out_q *queue, tmp = qeth_eddp_fill_buffer(queue,ctx,queue->next_buf_to_fill); if (tmp < 0) { printk("eddp tx_dropped 2\n"); - card->stats.tx_dropped++; rc = - EBUSY; goto out; } @@ -4391,21 +4394,21 @@ qeth_get_elements_no(struct qeth_card *card, void *hdr, { int elements_needed = 0; - if (skb_shinfo(skb)->nr_frags > 0) { + if (skb_shinfo(skb)->nr_frags > 0) elements_needed = (skb_shinfo(skb)->nr_frags + 1); - } - if (elements_needed == 0 ) + if (elements_needed == 0) elements_needed = 1 + (((((unsigned long) hdr) % PAGE_SIZE) + skb->len) >> PAGE_SHIFT); if ((elements_needed + elems) > QETH_MAX_BUFFER_ELEMENTS(card)){ - PRINT_ERR("qeth_do_send_packet: invalid size of " - "IP packet (Number=%d / Length=%d). Discarded.\n", + PRINT_ERR("Invalid size of IP packet " + "(Number=%d / Length=%d). Discarded.\n", (elements_needed+elems), skb->len); return 0; } return elements_needed; } + static inline int qeth_send_packet(struct qeth_card *card, struct sk_buff *skb) { @@ -4421,108 +4424,110 @@ qeth_send_packet(struct qeth_card *card, struct sk_buff *skb) unsigned short nr_frags = skb_shinfo(skb)->nr_frags; unsigned short tso_size = skb_shinfo(skb)->gso_size; #endif + struct sk_buff *new_skb, *new_skb2; int rc; QETH_DBF_TEXT(trace, 6, "sendpkt"); + new_skb = skb; + if ((card->info.type == QETH_CARD_TYPE_OSN) && + (skb->protocol == htons(ETH_P_IPV6))) + return -EPERM; + cast_type = qeth_get_cast_type(card, skb); + if ((cast_type == RTN_BROADCAST) && + (card->info.broadcast_capable == 0)) + return -EPERM; + queue = card->qdio.out_qs + [qeth_get_priority_queue(card, skb, ipv, cast_type)]; if (!card->options.layer2) { ipv = qeth_get_ip_version(skb); if ((card->dev->hard_header == qeth_fake_header) && ipv) { - if ((skb = qeth_pskb_unshare(skb,GFP_ATOMIC)) == NULL) { - card->stats.tx_dropped++; - dev_kfree_skb_irq(skb); - return 0; - } + new_skb = qeth_pskb_unshare(skb, GFP_ATOMIC); + if (!new_skb) + return -ENOMEM; if(card->dev->type == ARPHRD_IEEE802_TR){ - skb_pull(skb, QETH_FAKE_LL_LEN_TR); + skb_pull(new_skb, QETH_FAKE_LL_LEN_TR); } else { - skb_pull(skb, QETH_FAKE_LL_LEN_ETH); + skb_pull(new_skb, QETH_FAKE_LL_LEN_ETH); } } } - if ((card->info.type == QETH_CARD_TYPE_OSN) && - (skb->protocol == htons(ETH_P_IPV6))) { - dev_kfree_skb_any(skb); - return 0; - } - cast_type = qeth_get_cast_type(card, skb); - if ((cast_type == RTN_BROADCAST) && - (card->info.broadcast_capable == 0)){ - card->stats.tx_dropped++; - card->stats.tx_errors++; - dev_kfree_skb_any(skb); - return NETDEV_TX_OK; - } - queue = card->qdio.out_qs - [qeth_get_priority_queue(card, skb, ipv, cast_type)]; - if (skb_is_gso(skb)) large_send = card->options.large_send; - - /*are we able to do TSO ? If so ,prepare and send it from here */ + /* check on OSN device*/ + if (card->info.type == QETH_CARD_TYPE_OSN) + hdr = (struct qeth_hdr *)new_skb->data; + /*are we able to do TSO ? */ if ((large_send == QETH_LARGE_SEND_TSO) && (cast_type == RTN_UNSPEC)) { - rc = qeth_tso_prepare_packet(card, skb, ipv, cast_type); + rc = qeth_tso_prepare_packet(card, new_skb, ipv, cast_type); if (rc) { - card->stats.tx_dropped++; - card->stats.tx_errors++; - dev_kfree_skb_any(skb); - return NETDEV_TX_OK; + __qeth_free_new_skb(skb, new_skb); + return rc; } elements_needed++; - } else { - if ((rc = qeth_prepare_skb(card, &skb, &hdr, ipv))) { - QETH_DBF_TEXT_(trace, 4, "pskbe%d", rc); - return rc; + } else if (card->info.type != QETH_CARD_TYPE_OSN) { + new_skb2 = qeth_prepare_skb(card, new_skb, &hdr, ipv); + if (!new_skb2) { + __qeth_free_new_skb(skb, new_skb); + return -EINVAL; } - if (card->info.type != QETH_CARD_TYPE_OSN) - qeth_fill_header(card, hdr, skb, ipv, cast_type); + if (new_skb != skb) + __qeth_free_new_skb(new_skb2, new_skb); + new_skb = new_skb2; + qeth_fill_header(card, hdr, new_skb, ipv, cast_type); } - if (large_send == QETH_LARGE_SEND_EDDP) { - ctx = qeth_eddp_create_context(card, skb, hdr); + ctx = qeth_eddp_create_context(card, new_skb, hdr); if (ctx == NULL) { + __qeth_free_new_skb(skb, new_skb); PRINT_WARN("could not create eddp context\n"); return -EINVAL; } } else { - int elems = qeth_get_elements_no(card,(void*) hdr, skb, + int elems = qeth_get_elements_no(card,(void*) hdr, new_skb, elements_needed); - if (!elems) + if (!elems) { + __qeth_free_new_skb(skb, new_skb); return -EINVAL; + } elements_needed += elems; } if (card->info.type != QETH_CARD_TYPE_IQD) - rc = qeth_do_send_packet(card, queue, skb, hdr, + rc = qeth_do_send_packet(card, queue, new_skb, hdr, elements_needed, ctx); else - rc = qeth_do_send_packet_fast(card, queue, skb, hdr, + rc = qeth_do_send_packet_fast(card, queue, new_skb, hdr, elements_needed, ctx); - if (!rc){ + if (!rc) { card->stats.tx_packets++; card->stats.tx_bytes += tx_bytes; + if (new_skb != skb) + dev_kfree_skb_any(skb); #ifdef CONFIG_QETH_PERF_STATS if (tso_size && !(large_send == QETH_LARGE_SEND_NO)) { card->perf_stats.large_send_bytes += tx_bytes; card->perf_stats.large_send_cnt++; } - if (nr_frags > 0){ + if (nr_frags > 0) { card->perf_stats.sg_skbs_sent++; /* nr_frags + skb->data */ card->perf_stats.sg_frags_sent += nr_frags + 1; } #endif /* CONFIG_QETH_PERF_STATS */ + } else { + card->stats.tx_dropped++; + __qeth_free_new_skb(skb, new_skb); } if (ctx != NULL) { /* drop creator's reference */ qeth_eddp_put_context(ctx); /* free skb; it's not referenced by a buffer */ - if (rc == 0) - dev_kfree_skb_any(skb); - + if (!rc) + dev_kfree_skb_any(new_skb); } return rc; } diff --git a/drivers/s390/net/qeth_tso.h b/drivers/s390/net/qeth_tso.h index 593f298142c1..14504afb044e 100644 --- a/drivers/s390/net/qeth_tso.h +++ b/drivers/s390/net/qeth_tso.h @@ -24,7 +24,7 @@ static inline struct qeth_hdr_tso * qeth_tso_prepare_skb(struct qeth_card *card, struct sk_buff **skb) { QETH_DBF_TEXT(trace, 5, "tsoprsk"); - return qeth_push_skb(card, skb, sizeof(struct qeth_hdr_tso)); + return qeth_push_skb(card, *skb, sizeof(struct qeth_hdr_tso)); } /** -- cgit v1.2.2 From 09d2d38a152419467f764c0f730821e896766c1f Mon Sep 17 00:00:00 2001 From: Frank Pavlic Date: Fri, 15 Sep 2006 16:26:34 +0200 Subject: [PATCH] s390: qeth driver fixes [4/6] [PATCH 7/9] s390: qeth driver fixes [4/6] From: Frank Pavlic - fix kernel crash due to race, set card->state to SOFTSETUP after card and card->dev are initialized properly. - remove CONFIG_QETH_PERF_STATS, use sysfs attribute instead, as we want to have the ability to turn on/off the statistics at runtime. Signed-off-by: Frank Pavlic Signed-off-by: Jeff Garzik --- drivers/s390/net/Kconfig | 9 --- drivers/s390/net/qeth.h | 10 ++- drivers/s390/net/qeth_eddp.c | 5 +- drivers/s390/net/qeth_main.c | 147 ++++++++++++++++++++----------------------- drivers/s390/net/qeth_proc.c | 23 ++++--- drivers/s390/net/qeth_sys.c | 42 +++++++++++++ 6 files changed, 128 insertions(+), 108 deletions(-) (limited to 'drivers') diff --git a/drivers/s390/net/Kconfig b/drivers/s390/net/Kconfig index 548854754921..1a93fa684e9f 100644 --- a/drivers/s390/net/Kconfig +++ b/drivers/s390/net/Kconfig @@ -92,15 +92,6 @@ config QETH_VLAN If CONFIG_QETH is switched on, this option will include IEEE 802.1q VLAN support in the qeth device driver. -config QETH_PERF_STATS - bool "Performance statistics in /proc" - depends on QETH - help - When switched on, this option will add a file in the proc-fs - (/proc/qeth_perf_stats) containing performance statistics. It - may slightly impact performance, so this is only recommended for - internal tuning of the device driver. - config CCWGROUP tristate default (LCS || CTC || QETH) diff --git a/drivers/s390/net/qeth.h b/drivers/s390/net/qeth.h index c04ee915dc1b..22a7ffbcaa42 100644 --- a/drivers/s390/net/qeth.h +++ b/drivers/s390/net/qeth.h @@ -176,7 +176,6 @@ extern struct ccwgroup_driver qeth_ccwgroup_driver; /** * card stuff */ -#ifdef CONFIG_QETH_PERF_STATS struct qeth_perf_stats { unsigned int bufs_rec; unsigned int bufs_sent; @@ -211,8 +210,10 @@ struct qeth_perf_stats { unsigned int large_send_cnt; unsigned int sg_skbs_sent; unsigned int sg_frags_sent; + /* initial values when measuring starts */ + unsigned long initial_rx_packets; + unsigned long initial_tx_packets; }; -#endif /* CONFIG_QETH_PERF_STATS */ /* Routing stuff */ struct qeth_routing_info { @@ -767,6 +768,7 @@ struct qeth_card_options { int fake_ll; int layer2; enum qeth_large_send_types large_send; + int performance_stats; }; /* @@ -819,9 +821,7 @@ struct qeth_card { struct list_head cmd_waiter_list; /* QDIO buffer handling */ struct qeth_qdio_info qdio; -#ifdef CONFIG_QETH_PERF_STATS struct qeth_perf_stats perf_stats; -#endif /* CONFIG_QETH_PERF_STATS */ int use_hard_stop; int (*orig_hard_header)(struct sk_buff *,struct net_device *, unsigned short,void *,void *,unsigned); @@ -1049,13 +1049,11 @@ qeth_get_arphdr_type(int cardtype, int linktype) } } -#ifdef CONFIG_QETH_PERF_STATS static inline int qeth_get_micros(void) { return (int) (get_clock() >> 12); } -#endif static inline int qeth_get_qdio_q_format(struct qeth_card *card) diff --git a/drivers/s390/net/qeth_eddp.c b/drivers/s390/net/qeth_eddp.c index 8491598f9149..a363721cf28d 100644 --- a/drivers/s390/net/qeth_eddp.c +++ b/drivers/s390/net/qeth_eddp.c @@ -179,9 +179,8 @@ out_check: flush_cnt++; } } else { -#ifdef CONFIG_QETH_PERF_STATS - queue->card->perf_stats.skbs_sent_pack++; -#endif + if (queue->card->options.performance_stats) + queue->card->perf_stats.skbs_sent_pack++; QETH_DBF_TEXT(trace, 6, "fillbfpa"); if (buf->next_element_to_fill >= QETH_MAX_BUFFER_ELEMENTS(queue->card)) { diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c index 522fb9dd551e..0bc55a327907 100644 --- a/drivers/s390/net/qeth_main.c +++ b/drivers/s390/net/qeth_main.c @@ -1073,6 +1073,7 @@ qeth_set_intial_options(struct qeth_card *card) card->options.layer2 = 1; else card->options.layer2 = 0; + card->options.performance_stats = 1; } /** @@ -2564,9 +2565,8 @@ qeth_process_inbound_buffer(struct qeth_card *card, /* get first element of current buffer */ element = (struct qdio_buffer_element *)&buf->buffer->element[0]; offset = 0; -#ifdef CONFIG_QETH_PERF_STATS - card->perf_stats.bufs_rec++; -#endif + if (card->options.performance_stats) + card->perf_stats.bufs_rec++; while((skb = qeth_get_next_skb(card, buf->buffer, &element, &offset, &hdr))) { skb->dev = card->dev; @@ -2623,7 +2623,7 @@ qeth_init_input_buffer(struct qeth_card *card, struct qeth_qdio_buffer *buf) { struct qeth_buffer_pool_entry *pool_entry; int i; - + pool_entry = qeth_get_buffer_pool_entry(card); /* * since the buffer is accessed only from the input_tasklet @@ -2697,17 +2697,18 @@ qeth_queue_input_buffer(struct qeth_card *card, int index) * 'index') un-requeued -> this buffer is the first buffer that * will be requeued the next time */ -#ifdef CONFIG_QETH_PERF_STATS - card->perf_stats.inbound_do_qdio_cnt++; - card->perf_stats.inbound_do_qdio_start_time = qeth_get_micros(); -#endif + if (card->options.performance_stats) { + card->perf_stats.inbound_do_qdio_cnt++; + card->perf_stats.inbound_do_qdio_start_time = + qeth_get_micros(); + } rc = do_QDIO(CARD_DDEV(card), QDIO_FLAG_SYNC_INPUT | QDIO_FLAG_UNDER_INTERRUPT, 0, queue->next_buf_to_init, count, NULL); -#ifdef CONFIG_QETH_PERF_STATS - card->perf_stats.inbound_do_qdio_time += qeth_get_micros() - - card->perf_stats.inbound_do_qdio_start_time; -#endif + if (card->options.performance_stats) + card->perf_stats.inbound_do_qdio_time += + qeth_get_micros() - + card->perf_stats.inbound_do_qdio_start_time; if (rc){ PRINT_WARN("qeth_queue_input_buffer's do_QDIO " "return %i (device %s).\n", @@ -2743,10 +2744,10 @@ qeth_qdio_input_handler(struct ccw_device * ccwdev, unsigned int status, QETH_DBF_TEXT(trace, 6, "qdinput"); card = (struct qeth_card *) card_ptr; net_dev = card->dev; -#ifdef CONFIG_QETH_PERF_STATS - card->perf_stats.inbound_cnt++; - card->perf_stats.inbound_start_time = qeth_get_micros(); -#endif + if (card->options.performance_stats) { + card->perf_stats.inbound_cnt++; + card->perf_stats.inbound_start_time = qeth_get_micros(); + } if (status & QDIO_STATUS_LOOK_FOR_ERROR) { if (status & QDIO_STATUS_ACTIVATE_CHECK_CONDITION){ QETH_DBF_TEXT(trace, 1,"qdinchk"); @@ -2768,10 +2769,9 @@ qeth_qdio_input_handler(struct ccw_device * ccwdev, unsigned int status, qeth_put_buffer_pool_entry(card, buffer->pool_entry); qeth_queue_input_buffer(card, index); } -#ifdef CONFIG_QETH_PERF_STATS - card->perf_stats.inbound_time += qeth_get_micros() - - card->perf_stats.inbound_start_time; -#endif + if (card->options.performance_stats) + card->perf_stats.inbound_time += qeth_get_micros() - + card->perf_stats.inbound_start_time; } static inline int @@ -2861,10 +2861,11 @@ qeth_flush_buffers(struct qeth_qdio_out_q *queue, int under_int, } queue->card->dev->trans_start = jiffies; -#ifdef CONFIG_QETH_PERF_STATS - queue->card->perf_stats.outbound_do_qdio_cnt++; - queue->card->perf_stats.outbound_do_qdio_start_time = qeth_get_micros(); -#endif + if (queue->card->options.performance_stats) { + queue->card->perf_stats.outbound_do_qdio_cnt++; + queue->card->perf_stats.outbound_do_qdio_start_time = + qeth_get_micros(); + } if (under_int) rc = do_QDIO(CARD_DDEV(queue->card), QDIO_FLAG_SYNC_OUTPUT | QDIO_FLAG_UNDER_INTERRUPT, @@ -2872,10 +2873,10 @@ qeth_flush_buffers(struct qeth_qdio_out_q *queue, int under_int, else rc = do_QDIO(CARD_DDEV(queue->card), QDIO_FLAG_SYNC_OUTPUT, queue->queue_no, index, count, NULL); -#ifdef CONFIG_QETH_PERF_STATS - queue->card->perf_stats.outbound_do_qdio_time += qeth_get_micros() - - queue->card->perf_stats.outbound_do_qdio_start_time; -#endif + if (queue->card->options.performance_stats) + queue->card->perf_stats.outbound_do_qdio_time += + qeth_get_micros() - + queue->card->perf_stats.outbound_do_qdio_start_time; if (rc){ QETH_DBF_TEXT(trace, 2, "flushbuf"); QETH_DBF_TEXT_(trace, 2, " err%d", rc); @@ -2887,9 +2888,8 @@ qeth_flush_buffers(struct qeth_qdio_out_q *queue, int under_int, return; } atomic_add(count, &queue->used_buffers); -#ifdef CONFIG_QETH_PERF_STATS - queue->card->perf_stats.bufs_sent += count; -#endif + if (queue->card->options.performance_stats) + queue->card->perf_stats.bufs_sent += count; } /* @@ -2904,9 +2904,8 @@ qeth_switch_to_packing_if_needed(struct qeth_qdio_out_q *queue) >= QETH_HIGH_WATERMARK_PACK){ /* switch non-PACKING -> PACKING */ QETH_DBF_TEXT(trace, 6, "np->pack"); -#ifdef CONFIG_QETH_PERF_STATS - queue->card->perf_stats.sc_dp_p++; -#endif + if (queue->card->options.performance_stats) + queue->card->perf_stats.sc_dp_p++; queue->do_pack = 1; } } @@ -2929,9 +2928,8 @@ qeth_switch_to_nonpacking_if_needed(struct qeth_qdio_out_q *queue) <= QETH_LOW_WATERMARK_PACK) { /* switch PACKING -> non-PACKING */ QETH_DBF_TEXT(trace, 6, "pack->np"); -#ifdef CONFIG_QETH_PERF_STATS - queue->card->perf_stats.sc_p_dp++; -#endif + if (queue->card->options.performance_stats) + queue->card->perf_stats.sc_p_dp++; queue->do_pack = 0; /* flush packing buffers */ buffer = &queue->bufs[queue->next_buf_to_fill]; @@ -2943,7 +2941,7 @@ qeth_switch_to_nonpacking_if_needed(struct qeth_qdio_out_q *queue) queue->next_buf_to_fill = (queue->next_buf_to_fill + 1) % QDIO_MAX_BUFFERS_PER_Q; - } + } } } return flush_count; @@ -2999,11 +2997,10 @@ qeth_check_outbound_queue(struct qeth_qdio_out_q *queue) !atomic_read(&queue->set_pci_flags_count)) flush_cnt += qeth_flush_buffers_on_no_pci(queue); -#ifdef CONFIG_QETH_PERF_STATS - if (q_was_packing) + if (queue->card->options.performance_stats && + q_was_packing) queue->card->perf_stats.bufs_sent_pack += flush_cnt; -#endif if (flush_cnt) qeth_flush_buffers(queue, 1, index, flush_cnt); atomic_set(&queue->state, QETH_OUT_Q_UNLOCKED); @@ -3033,10 +3030,11 @@ qeth_qdio_output_handler(struct ccw_device * ccwdev, unsigned int status, return; } } -#ifdef CONFIG_QETH_PERF_STATS - card->perf_stats.outbound_handler_cnt++; - card->perf_stats.outbound_handler_start_time = qeth_get_micros(); -#endif + if (card->options.performance_stats) { + card->perf_stats.outbound_handler_cnt++; + card->perf_stats.outbound_handler_start_time = + qeth_get_micros(); + } for(i = first_element; i < (first_element + count); ++i){ buffer = &queue->bufs[i % QDIO_MAX_BUFFERS_PER_Q]; /*we only handle the KICK_IT error by doing a recovery */ @@ -3055,10 +3053,9 @@ qeth_qdio_output_handler(struct ccw_device * ccwdev, unsigned int status, qeth_check_outbound_queue(queue); netif_wake_queue(queue->card->dev); -#ifdef CONFIG_QETH_PERF_STATS - card->perf_stats.outbound_handler_time += qeth_get_micros() - - card->perf_stats.outbound_handler_start_time; -#endif + if (card->options.performance_stats) + card->perf_stats.outbound_handler_time += qeth_get_micros() - + card->perf_stats.outbound_handler_start_time; } static void @@ -3684,10 +3681,10 @@ qeth_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) /* return OK; otherwise ksoftirqd goes to 100% */ return NETDEV_TX_OK; } -#ifdef CONFIG_QETH_PERF_STATS - card->perf_stats.outbound_cnt++; - card->perf_stats.outbound_start_time = qeth_get_micros(); -#endif + if (card->options.performance_stats) { + card->perf_stats.outbound_cnt++; + card->perf_stats.outbound_start_time = qeth_get_micros(); + } netif_stop_queue(dev); if ((rc = qeth_send_packet(card, skb))) { if (rc == -EBUSY) { @@ -3701,10 +3698,9 @@ qeth_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) } } netif_wake_queue(dev); -#ifdef CONFIG_QETH_PERF_STATS - card->perf_stats.outbound_time += qeth_get_micros() - - card->perf_stats.outbound_start_time; -#endif + if (card->options.performance_stats) + card->perf_stats.outbound_time += qeth_get_micros() - + card->perf_stats.outbound_start_time; return rc; } @@ -4213,9 +4209,8 @@ qeth_fill_buffer(struct qeth_qdio_out_q *queue, flush_cnt = 1; } else { QETH_DBF_TEXT(trace, 6, "fillbfpa"); -#ifdef CONFIG_QETH_PERF_STATS - queue->card->perf_stats.skbs_sent_pack++; -#endif + if (queue->card->options.performance_stats) + queue->card->perf_stats.skbs_sent_pack++; if (buf->next_element_to_fill >= QETH_MAX_BUFFER_ELEMENTS(queue->card)) { /* @@ -4380,10 +4375,8 @@ out: qeth_flush_buffers(queue, 0, start_index, flush_count); } /* at this point the queue is UNLOCKED again */ -#ifdef CONFIG_QETH_PERF_STATS - if (do_pack) + if (queue->card->options.performance_stats && do_pack) queue->card->perf_stats.bufs_sent_pack += flush_count; -#endif /* CONFIG_QETH_PERF_STATS */ return rc; } @@ -4420,10 +4413,8 @@ qeth_send_packet(struct qeth_card *card, struct sk_buff *skb) enum qeth_large_send_types large_send = QETH_LARGE_SEND_NO; struct qeth_eddp_context *ctx = NULL; int tx_bytes = skb->len; -#ifdef CONFIG_QETH_PERF_STATS unsigned short nr_frags = skb_shinfo(skb)->nr_frags; unsigned short tso_size = skb_shinfo(skb)->gso_size; -#endif struct sk_buff *new_skb, *new_skb2; int rc; @@ -4505,19 +4496,19 @@ qeth_send_packet(struct qeth_card *card, struct sk_buff *skb) card->stats.tx_bytes += tx_bytes; if (new_skb != skb) dev_kfree_skb_any(skb); -#ifdef CONFIG_QETH_PERF_STATS - if (tso_size && - !(large_send == QETH_LARGE_SEND_NO)) { - card->perf_stats.large_send_bytes += tx_bytes; - card->perf_stats.large_send_cnt++; - } - if (nr_frags > 0) { - card->perf_stats.sg_skbs_sent++; - /* nr_frags + skb->data */ - card->perf_stats.sg_frags_sent += - nr_frags + 1; + if (card->options.performance_stats) { + if (tso_size && + !(large_send == QETH_LARGE_SEND_NO)) { + card->perf_stats.large_send_bytes += tx_bytes; + card->perf_stats.large_send_cnt++; + } + if (nr_frags > 0) { + card->perf_stats.sg_skbs_sent++; + /* nr_frags + skb->data */ + card->perf_stats.sg_frags_sent += + nr_frags + 1; + } } -#endif /* CONFIG_QETH_PERF_STATS */ } else { card->stats.tx_dropped++; __qeth_free_new_skb(skb, new_skb); @@ -7878,12 +7869,12 @@ __qeth_set_online(struct ccwgroup_device *gdev, int recovery_mode) QETH_DBF_TEXT_(setup, 2, "5err%d", rc); goto out_remove; } - card->state = CARD_STATE_SOFTSETUP; if ((rc = qeth_init_qdio_queues(card))){ QETH_DBF_TEXT_(setup, 2, "6err%d", rc); goto out_remove; } + card->state = CARD_STATE_SOFTSETUP; netif_carrier_on(card->dev); qeth_set_allowed_threads(card, 0xffffffff, 0); diff --git a/drivers/s390/net/qeth_proc.c b/drivers/s390/net/qeth_proc.c index 66f2da14e6e3..faa768e59257 100644 --- a/drivers/s390/net/qeth_proc.c +++ b/drivers/s390/net/qeth_proc.c @@ -173,7 +173,6 @@ static struct file_operations qeth_procfile_fops = { #define QETH_PERF_PROCFILE_NAME "qeth_perf" static struct proc_dir_entry *qeth_perf_procfile; -#ifdef CONFIG_QETH_PERF_STATS static int qeth_perf_procfile_seq_show(struct seq_file *s, void *it) { @@ -192,14 +191,21 @@ qeth_perf_procfile_seq_show(struct seq_file *s, void *it) CARD_DDEV_ID(card), QETH_CARD_IFNAME(card) ); + if (!card->options.performance_stats) + seq_printf(s, "Performance statistics are deactivated.\n"); seq_printf(s, " Skb's/buffers received : %lu/%u\n" " Skb's/buffers sent : %lu/%u\n\n", - card->stats.rx_packets, card->perf_stats.bufs_rec, - card->stats.tx_packets, card->perf_stats.bufs_sent + card->stats.rx_packets - + card->perf_stats.initial_rx_packets, + card->perf_stats.bufs_rec, + card->stats.tx_packets - + card->perf_stats.initial_tx_packets, + card->perf_stats.bufs_sent ); seq_printf(s, " Skb's/buffers sent without packing : %lu/%u\n" " Skb's/buffers sent with packing : %u/%u\n\n", - card->stats.tx_packets - card->perf_stats.skbs_sent_pack, + card->stats.tx_packets - card->perf_stats.initial_tx_packets + - card->perf_stats.skbs_sent_pack, card->perf_stats.bufs_sent - card->perf_stats.bufs_sent_pack, card->perf_stats.skbs_sent_pack, card->perf_stats.bufs_sent_pack @@ -275,11 +281,6 @@ static struct file_operations qeth_perf_procfile_fops = { .release = seq_release, }; -#define qeth_perf_procfile_created qeth_perf_procfile -#else -#define qeth_perf_procfile_created 1 -#endif /* CONFIG_QETH_PERF_STATS */ - int __init qeth_create_procfs_entries(void) { @@ -288,15 +289,13 @@ qeth_create_procfs_entries(void) if (qeth_procfile) qeth_procfile->proc_fops = &qeth_procfile_fops; -#ifdef CONFIG_QETH_PERF_STATS qeth_perf_procfile = create_proc_entry(QETH_PERF_PROCFILE_NAME, S_IFREG | 0444, NULL); if (qeth_perf_procfile) qeth_perf_procfile->proc_fops = &qeth_perf_procfile_fops; -#endif /* CONFIG_QETH_PERF_STATS */ if (qeth_procfile && - qeth_perf_procfile_created) + qeth_perf_procfile) return 0; else return -ENOMEM; diff --git a/drivers/s390/net/qeth_sys.c b/drivers/s390/net/qeth_sys.c index c1f3187f37ea..5836737ac58f 100644 --- a/drivers/s390/net/qeth_sys.c +++ b/drivers/s390/net/qeth_sys.c @@ -742,6 +742,47 @@ qeth_dev_layer2_store(struct device *dev, struct device_attribute *attr, const c static DEVICE_ATTR(layer2, 0644, qeth_dev_layer2_show, qeth_dev_layer2_store); +static ssize_t +qeth_dev_performance_stats_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct qeth_card *card = dev->driver_data; + + if (!card) + return -EINVAL; + + return sprintf(buf, "%i\n", card->options.performance_stats ? 1:0); +} + +static ssize_t +qeth_dev_performance_stats_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) +{ + struct qeth_card *card = dev->driver_data; + char *tmp; + int i; + + if (!card) + return -EINVAL; + + i = simple_strtoul(buf, &tmp, 16); + if ((i == 0) || (i == 1)) { + if (i == card->options.performance_stats) + return count; + card->options.performance_stats = i; + if (i == 0) + memset(&card->perf_stats, 0, + sizeof(struct qeth_perf_stats)); + card->perf_stats.initial_rx_packets = card->stats.rx_packets; + card->perf_stats.initial_tx_packets = card->stats.tx_packets; + } else { + PRINT_WARN("performance_stats: write 0 or 1 to this file!\n"); + return -EINVAL; + } + return count; +} + +static DEVICE_ATTR(performance_stats, 0644, qeth_dev_performance_stats_show, + qeth_dev_performance_stats_store); + static ssize_t qeth_dev_large_send_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -928,6 +969,7 @@ static struct device_attribute * qeth_device_attrs[] = { &dev_attr_canonical_macaddr, &dev_attr_layer2, &dev_attr_large_send, + &dev_attr_performance_stats, NULL, }; -- cgit v1.2.2 From f956b6902eabbff249000287c7b36cd65761d8b8 Mon Sep 17 00:00:00 2001 From: Frank Pavlic Date: Fri, 15 Sep 2006 16:26:52 +0200 Subject: [PATCH] s390: qeth driver fixes [5/6] [PATCH 8/9] s390: qeth driver fixes [5/6] From: Frank Pavlic fix kernel panic in qdio queue handling. qeth_qdio_clear_card() could be invoked by 2 CPUs simultaneously (for example reboot event and recovery). Signed-off-by: Frank Pavlic Signed-off-by: Jeff Garzik --- drivers/s390/net/qeth.h | 3 +- drivers/s390/net/qeth_main.c | 71 ++++++++++++++++++++++++++------------------ 2 files changed, 44 insertions(+), 30 deletions(-) (limited to 'drivers') diff --git a/drivers/s390/net/qeth.h b/drivers/s390/net/qeth.h index 22a7ffbcaa42..821383d8cbe7 100644 --- a/drivers/s390/net/qeth.h +++ b/drivers/s390/net/qeth.h @@ -463,6 +463,7 @@ enum qeth_qdio_info_states { QETH_QDIO_UNINITIALIZED, QETH_QDIO_ALLOCATED, QETH_QDIO_ESTABLISHED, + QETH_QDIO_CLEANING }; struct qeth_buffer_pool_entry { @@ -537,7 +538,7 @@ struct qeth_qdio_out_q { } __attribute__ ((aligned(256))); struct qeth_qdio_info { - volatile enum qeth_qdio_info_states state; + atomic_t state; /* input */ struct qeth_qdio_q *in_q; struct qeth_qdio_buffer_pool in_buf_pool; diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c index 0bc55a327907..a1b2e6fd38ca 100644 --- a/drivers/s390/net/qeth_main.c +++ b/drivers/s390/net/qeth_main.c @@ -3179,13 +3179,14 @@ qeth_alloc_qdio_buffers(struct qeth_card *card) QETH_DBF_TEXT(setup, 2, "allcqdbf"); - if (card->qdio.state == QETH_QDIO_ALLOCATED) + if (atomic_cmpxchg(&card->qdio.state, QETH_QDIO_UNINITIALIZED, + QETH_QDIO_ALLOCATED) != QETH_QDIO_UNINITIALIZED) return 0; card->qdio.in_q = kmalloc(sizeof(struct qeth_qdio_q), GFP_KERNEL|GFP_DMA); if (!card->qdio.in_q) - return - ENOMEM; + goto out_nomem; QETH_DBF_TEXT(setup, 2, "inq"); QETH_DBF_HEX(setup, 2, &card->qdio.in_q, sizeof(void *)); memset(card->qdio.in_q, 0, sizeof(struct qeth_qdio_q)); @@ -3194,27 +3195,19 @@ qeth_alloc_qdio_buffers(struct qeth_card *card) card->qdio.in_q->bufs[i].buffer = &card->qdio.in_q->qdio_bufs[i]; /* inbound buffer pool */ - if (qeth_alloc_buffer_pool(card)){ - kfree(card->qdio.in_q); - return -ENOMEM; - } + if (qeth_alloc_buffer_pool(card)) + goto out_freeinq; /* outbound */ card->qdio.out_qs = kmalloc(card->qdio.no_out_queues * sizeof(struct qeth_qdio_out_q *), GFP_KERNEL); - if (!card->qdio.out_qs){ - qeth_free_buffer_pool(card); - return -ENOMEM; - } - for (i = 0; i < card->qdio.no_out_queues; ++i){ + if (!card->qdio.out_qs) + goto out_freepool; + for (i = 0; i < card->qdio.no_out_queues; ++i) { card->qdio.out_qs[i] = kmalloc(sizeof(struct qeth_qdio_out_q), GFP_KERNEL|GFP_DMA); - if (!card->qdio.out_qs[i]){ - while (i > 0) - kfree(card->qdio.out_qs[--i]); - kfree(card->qdio.out_qs); - return -ENOMEM; - } + if (!card->qdio.out_qs[i]) + goto out_freeoutq; QETH_DBF_TEXT_(setup, 2, "outq %i", i); QETH_DBF_HEX(setup, 2, &card->qdio.out_qs[i], sizeof(void *)); memset(card->qdio.out_qs[i], 0, sizeof(struct qeth_qdio_out_q)); @@ -3231,8 +3224,19 @@ qeth_alloc_qdio_buffers(struct qeth_card *card) INIT_LIST_HEAD(&card->qdio.out_qs[i]->bufs[j].ctx_list); } } - card->qdio.state = QETH_QDIO_ALLOCATED; return 0; + +out_freeoutq: + while (i > 0) + kfree(card->qdio.out_qs[--i]); + kfree(card->qdio.out_qs); +out_freepool: + qeth_free_buffer_pool(card); +out_freeinq: + kfree(card->qdio.in_q); +out_nomem: + atomic_set(&card->qdio.state, QETH_QDIO_UNINITIALIZED); + return -ENOMEM; } static void @@ -3241,7 +3245,8 @@ qeth_free_qdio_buffers(struct qeth_card *card) int i, j; QETH_DBF_TEXT(trace, 2, "freeqdbf"); - if (card->qdio.state == QETH_QDIO_UNINITIALIZED) + if (atomic_swap(&card->qdio.state, QETH_QDIO_UNINITIALIZED) == + QETH_QDIO_UNINITIALIZED) return; kfree(card->qdio.in_q); /* inbound buffer pool */ @@ -3254,7 +3259,6 @@ qeth_free_qdio_buffers(struct qeth_card *card) kfree(card->qdio.out_qs[i]); } kfree(card->qdio.out_qs); - card->qdio.state = QETH_QDIO_UNINITIALIZED; } static void @@ -3276,7 +3280,7 @@ static void qeth_init_qdio_info(struct qeth_card *card) { QETH_DBF_TEXT(setup, 4, "intqdinf"); - card->qdio.state = QETH_QDIO_UNINITIALIZED; + atomic_set(&card->qdio.state, QETH_QDIO_UNINITIALIZED); /* inbound */ card->qdio.in_buf_size = QETH_IN_BUF_SIZE_DEFAULT; card->qdio.init_pool.buf_count = QETH_IN_BUF_COUNT_DEFAULT; @@ -3339,7 +3343,7 @@ qeth_qdio_establish(struct qeth_card *card) struct qdio_buffer **in_sbal_ptrs; struct qdio_buffer **out_sbal_ptrs; int i, j, k; - int rc; + int rc = 0; QETH_DBF_TEXT(setup, 2, "qdioest"); @@ -3398,8 +3402,10 @@ qeth_qdio_establish(struct qeth_card *card) init_data.input_sbal_addr_array = (void **) in_sbal_ptrs; init_data.output_sbal_addr_array = (void **) out_sbal_ptrs; - if (!(rc = qdio_initialize(&init_data))) - card->qdio.state = QETH_QDIO_ESTABLISHED; + if (atomic_cmpxchg(&card->qdio.state, QETH_QDIO_ALLOCATED, + QETH_QDIO_ESTABLISHED) == QETH_QDIO_ALLOCATED) + if ((rc = qdio_initialize(&init_data))) + atomic_set(&card->qdio.state, QETH_QDIO_ALLOCATED); kfree(out_sbal_ptrs); kfree(in_sbal_ptrs); @@ -3515,13 +3521,20 @@ qeth_qdio_clear_card(struct qeth_card *card, int use_halt) int rc = 0; QETH_DBF_TEXT(trace,3,"qdioclr"); - if (card->qdio.state == QETH_QDIO_ESTABLISHED){ + switch (atomic_cmpxchg(&card->qdio.state, QETH_QDIO_ESTABLISHED, + QETH_QDIO_CLEANING)) { + case QETH_QDIO_ESTABLISHED: if ((rc = qdio_cleanup(CARD_DDEV(card), - (card->info.type == QETH_CARD_TYPE_IQD) ? - QDIO_FLAG_CLEANUP_USING_HALT : - QDIO_FLAG_CLEANUP_USING_CLEAR))) + (card->info.type == QETH_CARD_TYPE_IQD) ? + QDIO_FLAG_CLEANUP_USING_HALT : + QDIO_FLAG_CLEANUP_USING_CLEAR))) QETH_DBF_TEXT_(trace, 3, "1err%d", rc); - card->qdio.state = QETH_QDIO_ALLOCATED; + atomic_set(&card->qdio.state, QETH_QDIO_ALLOCATED); + break; + case QETH_QDIO_CLEANING: + return rc; + default: + break; } if ((rc = qeth_clear_halt_card(card, use_halt))) QETH_DBF_TEXT_(trace, 3, "2err%d", rc); -- cgit v1.2.2 From 8b98a37c4b00f3fbcf162281bd4595777e61241b Mon Sep 17 00:00:00 2001 From: Frank Pavlic Date: Fri, 15 Sep 2006 16:27:02 +0200 Subject: [PATCH] s390: qeth driver fixes [6/6] [PATCH 9/9] s390: qeth driver fixes [6/6] From: Frank Pavlic - Hipersockets has no IPV6 support, thus prevent issueing SETRTG_IPV6 control commands on Hipersockets devices. - fixed error handling in qeth_sysfs_(un)register Signed-off-by: Frank Pavlic Signed-off-by: Jeff Garzik --- drivers/s390/net/qeth_main.c | 59 +++++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 20 deletions(-) (limited to 'drivers') diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c index a1b2e6fd38ca..5613b4564fa2 100644 --- a/drivers/s390/net/qeth_main.c +++ b/drivers/s390/net/qeth_main.c @@ -7344,6 +7344,8 @@ qeth_setrouting_v6(struct qeth_card *card) QETH_DBF_TEXT(trace,3,"setrtg6"); #ifdef CONFIG_QETH_IPV6 + if (!qeth_is_supported(card, IPA_IPV6)) + return 0; qeth_correct_routing_type(card, &card->options.route6.type, QETH_PROT_IPV6); @@ -8544,34 +8546,44 @@ qeth_ipv6_uninit(void) static void qeth_sysfs_unregister(void) { + s390_root_dev_unregister(qeth_root_dev); qeth_remove_driver_attributes(); ccw_driver_unregister(&qeth_ccw_driver); ccwgroup_driver_unregister(&qeth_ccwgroup_driver); - s390_root_dev_unregister(qeth_root_dev); } + /** * register qeth at sysfs */ static int qeth_sysfs_register(void) { - int rc=0; + int rc; rc = ccwgroup_driver_register(&qeth_ccwgroup_driver); if (rc) - return rc; + goto out; + rc = ccw_driver_register(&qeth_ccw_driver); if (rc) - return rc; + goto out_ccw_driver; + rc = qeth_create_driver_attributes(); if (rc) - return rc; + goto out_qeth_attr; + qeth_root_dev = s390_root_dev_register("qeth"); - if (IS_ERR(qeth_root_dev)) { - rc = PTR_ERR(qeth_root_dev); - return rc; - } - return 0; + rc = IS_ERR(qeth_root_dev) ? PTR_ERR(qeth_root_dev) : 0; + if (!rc) + goto out; + + qeth_remove_driver_attributes(); +out_qeth_attr: + ccw_driver_unregister(&qeth_ccw_driver); +out_ccw_driver: + ccwgroup_driver_unregister(&qeth_ccwgroup_driver); +out: + return rc; } /*** @@ -8580,7 +8592,7 @@ qeth_sysfs_register(void) static int __init qeth_init(void) { - int rc=0; + int rc; PRINT_INFO("loading %s\n", version); @@ -8589,20 +8601,26 @@ qeth_init(void) spin_lock_init(&qeth_notify_lock); rwlock_init(&qeth_card_list.rwlock); - if (qeth_register_dbf_views()) + rc = qeth_register_dbf_views(); + if (rc) goto out_err; - if (qeth_sysfs_register()) - goto out_sysfs; + + rc = qeth_sysfs_register(); + if (rc) + goto out_dbf; #ifdef CONFIG_QETH_IPV6 - if (qeth_ipv6_init()) { - PRINT_ERR("Out of memory during ipv6 init.\n"); + rc = qeth_ipv6_init(); + if (rc) { + PRINT_ERR("Out of memory during ipv6 init code = %d\n", rc); goto out_sysfs; } #endif /* QETH_IPV6 */ - if (qeth_register_notifiers()) + rc = qeth_register_notifiers(); + if (rc) goto out_ipv6; - if (qeth_create_procfs_entries()) + rc = qeth_create_procfs_entries(); + if (rc) goto out_notifiers; return rc; @@ -8612,12 +8630,13 @@ out_notifiers: out_ipv6: #ifdef CONFIG_QETH_IPV6 qeth_ipv6_uninit(); -#endif /* QETH_IPV6 */ out_sysfs: +#endif /* QETH_IPV6 */ qeth_sysfs_unregister(); +out_dbf: qeth_unregister_dbf_views(); out_err: - PRINT_ERR("Initialization failed"); + PRINT_ERR("Initialization failed with code %d\n", rc); return rc; } -- cgit v1.2.2 From d730e1033f81fefd3176f53e070b2b64cd146db0 Mon Sep 17 00:00:00 2001 From: Chas Williams Date: Wed, 13 Sep 2006 20:33:40 -0700 Subject: [ATM]: [he] when transmit fails, unmap the dma regions Signed-off-by: Chas Williams Signed-off-by: David S. Miller --- drivers/atm/he.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'drivers') diff --git a/drivers/atm/he.c b/drivers/atm/he.c index d369130f4235..dd96123a2b7f 100644 --- a/drivers/atm/he.c +++ b/drivers/atm/he.c @@ -2282,6 +2282,8 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid) TPDRQ_MASK(he_readl(he_dev, TPDRQ_B_H))); if (new_tail == he_dev->tpdrq_head) { + int slot; + hprintk("tpdrq full (cid 0x%x)\n", cid); /* * FIXME @@ -2289,6 +2291,13 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid) * after service_tbrq, service the backlog * for now, we just drop the pdu */ + for (slot = 0; slot < TPD_MAXIOV; ++slot) { + if (tpd->iovec[slot].addr) + pci_unmap_single(he_dev->pci_dev, + tpd->iovec[slot].addr, + tpd->iovec[slot].len & TPD_LEN_MASK, + PCI_DMA_TODEVICE); + } if (tpd->skb) { if (tpd->vcc->pop) tpd->vcc->pop(tpd->vcc, tpd->skb); -- cgit v1.2.2 From b9b64e6e89fc5a6ef220747115c5b7764614ca3f Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Mon, 18 Sep 2006 01:47:13 -0700 Subject: [OPENPROMIO]: Handle current_node being NULL correctly. If the user tries to traverse to the next node of the last node, we get NULL in current_node and a zero phandle returned. That's fine, but if the user tries to obtain properties in that state, we try to dereference a NULL pointer in the downcall to the of_*() routines. So protect against that. Signed-off-by: David S. Miller --- drivers/sbus/char/openprom.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/sbus/char/openprom.c b/drivers/sbus/char/openprom.c index 293bb2fdb1d5..2f698763ba5d 100644 --- a/drivers/sbus/char/openprom.c +++ b/drivers/sbus/char/openprom.c @@ -145,8 +145,9 @@ static int opromgetprop(void __user *argp, struct device_node *dp, struct openpr void *pval; int len; - pval = of_get_property(dp, op->oprom_array, &len); - if (!pval || len <= 0 || len > bufsize) + if (!dp || + !(pval = of_get_property(dp, op->oprom_array, &len)) || + len <= 0 || len > bufsize) return copyout(argp, op, sizeof(int)); memcpy(op->oprom_array, pval, len); @@ -161,6 +162,8 @@ static int opromnxtprop(void __user *argp, struct device_node *dp, struct openpr struct property *prop; int len; + if (!dp) + return copyout(argp, op, sizeof(int)); if (op->oprom_array[0] == '\0') { prop = dp->properties; if (!prop) @@ -266,9 +269,13 @@ static int oprompci2node(void __user *argp, struct device_node *dp, struct openp static int oprompath2node(void __user *argp, struct device_node *dp, struct openpromio *op, int bufsize, DATA *data) { + phandle ph = 0; + dp = of_find_node_by_path(op->oprom_array); + if (dp) + ph = dp->node; data->current_node = dp; - *((int *)op->oprom_array) = dp->node; + *((int *)op->oprom_array) = ph; op->oprom_size = sizeof(int); return copyout(argp, op, bufsize + sizeof(int)); -- cgit v1.2.2 From 71aa7054d3df0f74d9ffbef3dd1486764c7f592a Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Mon, 18 Sep 2006 13:30:17 +0100 Subject: [ARM] 3793/1: S3C2412: fix wrong serial info struct Patch from Ben Dooks The S3C2440 serial info struct is being passed through the S3C2412 serial info struct probe routine. Signed-off-by: Ben Dooks Signed-off-by: Thomas Glexiner Signed-off-by: Russell King --- drivers/serial/s3c2410.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c index 392bffcf96e8..95738a19cde7 100644 --- a/drivers/serial/s3c2410.c +++ b/drivers/serial/s3c2410.c @@ -1621,7 +1621,7 @@ static struct s3c24xx_uart_info s3c2412_uart_inf = { static int s3c2412_serial_probe(struct platform_device *dev) { dbg("s3c2440_serial_probe: dev=%p\n", dev); - return s3c24xx_serial_probe(dev, &s3c2440_uart_inf); + return s3c24xx_serial_probe(dev, &s3c2412_uart_inf); } static struct platform_driver s3c2412_serial_drv = { -- cgit v1.2.2