cpufreq: add support for intermediate (stable) frequencies

Douglas Anderson, recently pointed out an interesting problem due to which
udelay() was expiring earlier than it should.

While transitioning between frequencies few platforms may temporarily switch to
a stable frequency, waiting for the main PLL to stabilize.

For example: When we transition between very low frequencies on exynos, like
between 200MHz and 300MHz, we may temporarily switch to a PLL running at 800MHz.
No CPUFREQ notification is sent for that. That means there's a period of time
when we're running at 800MHz but loops_per_jiffy is calibrated at between 200MHz
and 300MHz. And so udelay behaves badly.

To get this fixed in a generic way, introduce another set of callbacks
get_intermediate() and target_intermediate(), only for drivers with
target_index() and CPUFREQ_ASYNC_NOTIFICATION unset.

get_intermediate() should return a stable intermediate frequency platform wants
to switch to, and target_intermediate() should set CPU to that frequency,
before jumping to the frequency corresponding to 'index'. Core will take care of
sending notifications and driver doesn't have to handle them in
target_intermediate() or target_index().

NOTE: ->target_index() should restore to policy->restore_freq in case of
failures as core would send notifications for that.

Tested-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Doug Anderson <dianders@chromium.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
cpufreq: Tegra: implement intermediate frequency callbacks

Tegra has been switching to intermediate frequency (pll_p_clk) forever.
CPUFreq core has better support for handling notifications for these
frequencies and so we can adapt Tegra's driver to it.

Also do a WARN() if clk_set_parent() fails while moving back to pll_x
as we should have atleast restored to earlier frequency on error.

Tested-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Doug Anderson <dianders@chromium.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
gianfar: Call netif_carrier_off() prior to registration

Quoting David Miller:
"At the moment you call register_netdev() the device is visible, notifications
are sent to userspace, and userland tools can try to bring the interface up
and see the incorrect link state, before you do the netif_carrier_off().

Said another way, between the register_netdev() and netif_carrier_off() call,
userspace can see the device in an inconsistent state."

So call netif_carrier_off() prior to register_netdev().

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
MPLS: Use mpls_features to activate software MPLS GSO segmentation

If an MPLS packet requires segmentation then use mpls_features
to determine if the software implementation should be used.

As no driver advertises MPLS GSO segmentation this will always be
the case.

I had not noticed that this was necessary before as software MPLS GSO
segmentation was already being used in my test environment. I believe that
the reason for that is the skbs in question always had fragments and the
driver I used does not advertise NETIF_F_FRAGLIST (which seems to be the
case for most drivers). Thus software segmentation was activated by
skb_gso_ok().

This introduces the overhead of an extra call to skb_network_protocol()
in the case where where CONFIG_NET_MPLS_GSO is set and
skb->ip_summed == CHECKSUM_NONE.

Thanks to Jesse Gross for prompting me to investigate this.

Signed-off-by: Simon Horman <horms@verge.net.au>
Acked-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
qlcnic: Initialize mailbox cmd structure to zero

o Uninitialzed fields in mailbox command structure
  caused commands to time out randomly due to garbage
  values so initialize it to zero.

Signed-off-by: Rajesh Borundia <rajesh.borundia@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
xen-netback: Fix handling of skbs requiring too many slots

A recent commit (a02eb4 "xen-netback: worse-case estimate in xenvif_rx_action is
underestimating") capped the slot estimation to MAX_SKB_FRAGS, but that triggers
the next BUG_ON a few lines down, as the packet consumes more slots than
estimated.
This patch introduces full_coalesce on the skb callback buffer, which is used in
start_new_rx_buffer() to decide whether netback needs coalescing more
aggresively. By doing that, no packet should need more than
(XEN_NETIF_MAX_TX_SIZE + 1) / PAGE_SIZE data slots (excluding the optional GSO
slot, it doesn't carry data, therefore irrelevant in this case), as the provided
buffers are fully utilized.

Signed-off-by: Zoltan Kiss <zoltan.kiss@citrix.com>
Cc: Paul Durrant <paul.durrant@citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: David Vrabel <david.vrabel@citrix.com>
Reviewed-by: Paul Durrant <paul.durrant@gmail.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
dm9000: acquire irq flags from device tree

The DM9000 supports both active high interrupts and active low interrupts.
This is configured via the attached EEPROM.  In the device-tree case, make sure
that the DM9000 driver passes the correct flags to request_irq.

Signed-off-by: Andrew Ruder <andrew.ruder@elecsyscorp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
dm9000: clean up reset code

* Change a hard-coded 0x3 to NCR_RST | NCR_MAC_LBK in dm9000_reset

* Every single place where dm9000_init_dm9000 was ran, a dm9000_reset
  was called immediately before-hand.  Bring dm9000_reset into
  dm9000_init_dm9000.

* The following commit updated the dm9000_probe reset routine to use NCR_RST
  | NCR_MAC_LBK:

    6741f40 DM9000B: driver initialization upgrade

  and a later commit added a bug-fix to always reset the chip twice:

    09ee9f8 dm9000: Implement full reset of DM9000 network device

  Unfortunately, since the changes in 6741f40 were made by replacing the
  dm9000_probe dm9000_reset with the adjusted iow(), the changes in
  09ee9f8 were not incorporated into the dm9000_probe reset.
  Furthermore, it bypassed the requisite reset-delay causing some boards
  to get at least one "read wrong id ..." dev_err message during
  dm9000_probe.

Signed-off-by: Andrew Ruder <andrew.ruder@elecsyscorp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
dm9000: clean up edge-triggered irq compatibility

DM9000 uses level-triggered interrupts.  Some systems (PXA270) only
support edge-triggered interrupts on GPIOs.  Some changes are necessary
to ensure that interrupts are not triggered while the GPIO interrupt is
masked or we will miss the interrupt forever.

* Make some helper functions called dm9000_mask_interrupts() and
  dm9000_unmask_interrupts() for readability.

* dm9000_init_dm9000(): ensure that this function always leaves interrupts
  masked regardless of the state when it entered the function.  This is
  primarily to support the situation in dm9000_open where the logic used
  to go:

    dm9000_open()
        dm9000_init_dm9000()
            unmask interrupts
        request_irq()

  If an interrupt occurred between unmasking the interrupt and
  requesting the irq, it would be missed forever as the edge event would
  never be seen by the GPIO hardware in the PXA270.  This allows us to
  change the logic to:

    dm9000_open()
        dm9000_init_dm9000()
            dm9000_mask_interrupts()
        request_irq()
        dm9000_unmask_interrupts()

* dm9000_timeout(), dm9000_drv_resume(): Add the missing
  dm9000_unmask_interrupts() now required by the change above.

* dm9000_shutdown(): Use mask helper function

* dm9000_interrupt(): Use mask/unmask helper functions

Signed-off-by: Andrew Ruder <andrew.ruder@elecsyscorp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
dm9000: remove redundant ISR status clear

Since dm9000_interrupt() is already reading/clearing every set bit in
DM9000_ISR, this additional clear in dm9000_rx() (which is only called
by dm9000_interrupt()) is unnecessary and can be removed.

Signed-off-by: Andrew Ruder <andrew.ruder@elecsyscorp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
dm9000: handle initial link status

On the DM9000A/DM9000B force the initial check of the link status.  The
DM9000A/B has a link status changed event and this interrupt bit isn't
always set out of reset when a cable is plugged in.  This results in the
driver not seeing the cable attached link status until the cable is
removed and plugged in again.

Signed-off-by: Andrew Ruder <andrew.ruder@elecsyscorp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
dm9000: avoid sleeping in dm9000_timeout callback

On the DM9000B, dm9000_msleep() is called during the dm9000_timeout()
routine.  Since dm9000_timeout() holds the main spinlock through the
entire routine, mdelay() needs to be used rather than msleep().
Furthermore, the mutex_lock()/mutex_unlock() should be avoided so as to
not sleep with spinlocks held.

Signed-off-by: Andrew Ruder <andrew.ruder@elecsyscorp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Merge branch 'dm9000-next'

Andrew Ruder says:

====================
miscellaneous dm9000 driver fixes

This is a collection of changes discovered while bringing a PXA270 based board
(Arcom ZEUS) with a Davicom DM9000A/B up to a more recent kernel (from 2.6.xx).
This addresses all of my earlier issues (August 2013) listed here:

http://marc.info/?l=linux-netdev&m=137598605603324&w=2
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
mvme147: fix ram size in comment

The order of ram pages is 3, so the ram size is 2^3 * 4K = 32K.

Signed-off-by: Amos Kong <akong@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
hplance: fix ram size in comment

drivers/net/ethernet/amd/hplance.h:
 #define HPLANCE_MEMOFF 0x8000   /* struct lance_init_block */
 #define HPLANCE_NVRAMOFF 0xC008 /* etheraddress as one *nibble* per byte */

The offset of RAM start is 0x8000, the offset of RAM end is 0xC008,
so the RAM size is 16392 bytes.

Signed-off-by: Amos Kong <akong@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
bridge: Fix incorrect judgment of promisc

br_manage_promisc() incorrectly expects br_auto_port() to return only 0
or 1, while it actually returns flags, i.e., a subset of BR_AUTO_MASK.

Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
Signed-off-by: David S. Miller <davem@davemloft.net>
amd-xgbe: AMD 10GbE device bindings documentation

This patch provides the documentation of the device bindings
for the AMD 10GbE platform driver.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
amd-xgbe: Initial AMD 10GbE platform driver

This patch provides the initial platform driver for the AMD
10GbE device.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
amd-xgbe: Initial AMD 10GbE phylib driver

This patch provides the initial phylib driver in support
of the AMD 10GbE device.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
amd-xgbe: Configuration and build support

This patch provides the Kconfig and Makefile changes needed
to configure and build the AMD 10GbE platform driver and the
AMD 10GbE phylib driver.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: David S. Miller <davem@davemloft.net>