]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
Merge tag 'iio-for-5.13a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23...
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 26 Mar 2021 11:09:47 +0000 (12:09 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 26 Mar 2021 11:09:47 +0000 (12:09 +0100)
Jonathan writes:

1st set of IIO/counter device support, features and cleanup in the 5.13 cycle

Big set in here from Alexandru Ardelean enabling multiple buffer support.
This includes providing a new directory per buffer that combines
what was previously in buffer/ and scan_elements/. Old interfaces still
in place for compatiblity.

Note immuatable branch for scmi patches to allow for some significant
rework going on in that subsystem.  Merge required updating to reflect
some changes in IIO.

Late rebase to fix some wrong fixes tags due to some earlier rebases
made necessary by messing up the immutable branch.

IIO New Device Support
* adi,ad5686
  - Add info to support AD5673R and AD5677R
* bosch,bmi088
  - New driver supporting this accelerometer + gyroscope
* cros_ec_mkbp
  - New driver for this proximity sensor that exposes a 'front'
    sensor. Very simple switch like device, but driver allows it
    to share interface with more sophisticated proximity sensors.
* iio_scmi
  - New driver to support ARM SCMI protocol to expose underlying
    accelerometers and gyroscopes via this firmware interface.
* st,st_magn
  - Add ID for IISMDC magnetometer.
* ti,ads131e0
  - New driver supporting ads131e04, ads131e06 and ads131e08 24 bit ADCs

Counter New Device Support
* IRQ or GPIO based counter
  - New driver for a conceptually simple counter that uses interrupts
    to perform the count.

Features
* core
  - Dual buffer supprt including:
     Various helpers to centralize handling of bufferer related elements.
     Document existing and new IOCTLs
     Register the IIO chrdev only if it can actually be used for anything.
     Rework attribute group creation in the core (lots of patches)
     Merge buffer/ and scan_elements/ entries into one list + maintain
     backwards compatible set.
     Introduce the internal logic and IOCTL to allow multiple buffers
     + access to an anon FD per buffer to actually read from it.
     Tidy up tools/iio/iio_generic_buffer and switch to new interfaces.
     Update ABI docs.
     A few follow up fixes, unsuprising as this was a huge bit of rework.
  - Move common case setting of trig->parent to the core.
  - Provide an iio_read_channel_processed_scale() to avoid loss of
    precision from iio_read_channel_processed() then applying integer
    scale. Use it in ntc_thermistor driver in hwmon.
  - Allow drivers to specify labels from elsewhere than DT. Use it for
    bmc150 and kxcjk-1013 labels related to position on 2 in one tablets.
  - Document label usage for proximity and accelerometer sensors.
  - Some local variable renames for consistency
tools
  - Add -a parameter to iio_event_monitor to allow autoenabling of events.
* acpi_als
  - Add trigger support for devices that don't support notification method.
* adi,ad7124
  - Allow more than 8 channels.  This is a complex little device, but is
    capable of supporting up to 16 channels if the share certain
    configuration settings.
* hrtimer-trigger
  - Support sampling frequency below 1Hz.
* mediatek,mt8195-auxadc
  - Add compatible to binding docs (always also includes mt8173)
* st,stm32-adc
  - Enable timetamps when not using DMA.
* vishay,vcnl3020
  - Sampling frequency control.

Cleanup and minor fixes:
* treewide
  - Use some getter and setter functions instead of opencoding.
  - Set of fixes for pointless casts in various drivers.
  - Avoid wrong kernel-doc marking on comment blocks.
  - Fix various other minor kernel-doc issues shown by W=1
* core
  - Use a signed temporary for IIO_VAL_FRACTIONAL_LOG2 to avoid odd casts.
  - Fix IIO_VAL_FRACTIONAL_LOG2 for values between -1.0 and 0.0
  - Add unit tests for iio_format_value()
* docs
  - Fix formatting/typos in iio_configfs.rst and buffers.rst
  - Add documentation of index in buffers.rst
  - Fix scan element description
  - Avoid some issues with HTML generation from ABI docs by moving
    duplicated defintions to more generic files.
  - Drop reference to long dead mailing list.
* 104-quad
  - Remove left over deprecated IIO counter ABI.
* adi,adi-axi-adc
  - Fix wrong bit of docs.
* adi,ad5791
  - Typos
* adi,ad9834
   - Switch to device managed functions in probe.
* adi,adis*
  - Add and use helpers for locking to reduced duplication.
* adi,adis16480
  - Fix calculation of sampling frequency when using pulse per second input.
* adi,adis16475
  - Calculate the IMU scaled internal sampling rate and runtime depending
    on sysfs based configuration rather than getting from DT. Drop now
    unnecessary property from DT bindings doc.
* cros_ec
   - Fix result of a series of recent changes that means extended buffer
     attributes turn up in the wrong place. Too complex to revert the
     various patches unfortunately so this is a bit messy.
* fsl,mma3452
  - Indentation cleanup.
* hid-sensors
  - Size of storage needs to increase for some parts when using quaternions.
  - Move the get sensistivity attribute to hid-sensors-common to reduce
    duplication.  Enable it for more device types.
  - Correctly handle relative sensitivity if reported that way including
    documenting the new ABI.
* maxim,max517
  - Use device managed functions in probe.
* mediatek,mt6360-adc
  - Use asm/unaligned.h instead of directly including
    unaligned/be_byteshift.h
* novuton,npcm-adc
  - Local lock instead of missusing mlock.
* semtech,sx9500
  - Typos
* st,sensor
  - typo fix
* st,spear-adc
  - Local lock instead of missusing mlock.
* st,stm32-adc
  - Long standing HAS_IOMEM dependency fix.
* st,stm32-counter
  - Remove left over deprecated IIO counter ABI.
* ti,palmas-adc
  - Local lock instead of missusing mlock.
* ti,tmp007
  - Switch to device managed functions in probe.

Other
* MAINTAINERS
  - Move Peter Meerwald-Stadler to Credits at his request

* tag 'iio-for-5.13a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (119 commits)
  iio: acpi_als: Add trigger support
  iio: acpi_als: Add local variable dev in probe
  iio: acpi_als: Add timestamp channel
  iio: adc: ad7292: Modify the bool initialization assignment
  iio: cros: unify hw fifo attributes without API changes
  iio: kfifo: add devm_iio_triggered_buffer_setup_ext variant
  iio: event_monitor: Enable events before monitoring
  dt-bindings: iio: adc: Add compatible for Mediatek MT8195
  iio:magnetometer: Add Support for ST IIS2MDC
  dt-bindings: iio: st,st-sensors add IIS2MDC.
  staging: iio: ad9832: kernel-doc fixes
  iio:dac:max517.c: Use devm_iio_device_register()
  iio:cros_ec_sensors: Fix a wrong function name in kernel doc.
  iio: buffer: kfifo_buf: kernel-doc, typo in function name.
  iio: accel: sca3000: kernel-doc fixes. Missing - and wrong function names.
  iio: adc: adi-axi-adc: Drop false marking for kernel-doc
  iio: adc: cpcap-adc: kernel-doc fix - that should be _ in structure name
  iio: dac: ad5504: fix wrong part number in kernel-doc structure name.
  iio: dac: ad5770r: kernel-doc fix case of letter R wrong in structure name
  iio: adc: ti-adc084s021: kernel-doc fixes, missing function names
  ...

1270 files changed:
Documentation/ABI/testing/sysfs-fs-xfs
Documentation/devicetree/bindings/interrupt-controller/ingenic,intc.yaml
Documentation/devicetree/bindings/sound/fsl,spdif.yaml
Documentation/gpu/todo.rst
Documentation/networking/bonding.rst
Documentation/networking/netdev-FAQ.rst
Documentation/process/stable-kernel-rules.rst
Documentation/process/submitting-patches.rst
Documentation/virt/kvm/api.rst
MAINTAINERS
Makefile
arch/Kconfig
arch/arm/Kconfig
arch/arm/xen/p2m.c
arch/arm64/Kconfig
arch/arm64/include/asm/kvm_asm.h
arch/arm64/include/asm/kvm_hyp.h
arch/arm64/include/asm/memory.h
arch/arm64/include/asm/mmu_context.h
arch/arm64/include/asm/pgtable-prot.h
arch/arm64/include/asm/pgtable.h
arch/arm64/include/asm/sysreg.h
arch/arm64/kernel/head.S
arch/arm64/kernel/idreg-override.c
arch/arm64/kernel/image-vars.h
arch/arm64/kernel/perf_event.c
arch/arm64/kvm/arm.c
arch/arm64/kvm/hyp/entry.S
arch/arm64/kvm/hyp/include/hyp/switch.h
arch/arm64/kvm/hyp/nvhe/debug-sr.c
arch/arm64/kvm/hyp/nvhe/host.S
arch/arm64/kvm/hyp/nvhe/hyp-main.c
arch/arm64/kvm/hyp/nvhe/switch.c
arch/arm64/kvm/hyp/nvhe/tlb.c
arch/arm64/kvm/hyp/pgtable.c
arch/arm64/kvm/hyp/vgic-v3-sr.c
arch/arm64/kvm/hyp/vhe/tlb.c
arch/arm64/kvm/mmu.c
arch/arm64/kvm/perf.c
arch/arm64/kvm/pmu-emul.c
arch/arm64/kvm/reset.c
arch/arm64/kvm/vgic/vgic-v3.c
arch/arm64/mm/init.c
arch/arm64/mm/mmu.c
arch/csky/kernel/probes/ftrace.c
arch/ia64/include/asm/syscall.h
arch/ia64/kernel/ptrace.c
arch/m68k/include/asm/page_mm.h
arch/m68k/include/asm/page_no.h
arch/mips/boot/compressed/decompress.c
arch/mips/crypto/Makefile
arch/mips/include/asm/traps.h
arch/mips/kernel/cpu-probe.c
arch/mips/kernel/cpu-r3k-probe.c
arch/mips/kernel/traps.c
arch/mips/kernel/vmlinux.lds.S
arch/parisc/Kconfig
arch/parisc/kernel/ptrace.c
arch/powerpc/include/asm/code-patching.h
arch/powerpc/include/asm/cpu_has_feature.h
arch/powerpc/include/asm/dcr-native.h
arch/powerpc/include/asm/interrupt.h
arch/powerpc/include/asm/mmu.h
arch/powerpc/include/asm/ptrace.h
arch/powerpc/include/asm/switch_to.h
arch/powerpc/include/asm/vio.h
arch/powerpc/kernel/exceptions-64s.S
arch/powerpc/kernel/head_book3s_32.S
arch/powerpc/kernel/interrupt.c
arch/powerpc/kernel/traps.c
arch/powerpc/kernel/vdso32/gettimeofday.S
arch/powerpc/lib/sstep.c
arch/powerpc/perf/core-book3s.c
arch/powerpc/platforms/pseries/msi.c
arch/powerpc/platforms/pseries/vio.c
arch/riscv/Kconfig
arch/riscv/Kconfig.socs
arch/riscv/include/asm/asm-prototypes.h
arch/riscv/include/asm/irq.h
arch/riscv/include/asm/processor.h
arch/riscv/include/asm/ptrace.h
arch/riscv/include/asm/sbi.h
arch/riscv/include/asm/timex.h
arch/riscv/kernel/Makefile
arch/riscv/kernel/probes/ftrace.c
arch/riscv/kernel/probes/kprobes.c
arch/riscv/kernel/process.c
arch/riscv/kernel/sbi.c
arch/riscv/kernel/setup.c
arch/riscv/kernel/time.c
arch/riscv/kernel/traps.c
arch/riscv/mm/kasan_init.c
arch/s390/configs/debug_defconfig
arch/s390/configs/defconfig
arch/s390/configs/zfcpdump_defconfig
arch/s390/include/asm/idle.h
arch/s390/include/asm/pci.h
arch/s390/include/asm/timex.h
arch/s390/include/uapi/asm/hwctrset.h [new file with mode: 0644]
arch/s390/include/uapi/asm/perf_cpum_cf_diag.h [deleted file]
arch/s390/kernel/idle.c
arch/s390/kernel/perf_cpum_cf.c
arch/s390/kernel/perf_cpum_cf_diag.c
arch/s390/kernel/time.c
arch/s390/kernel/topology.c
arch/s390/kernel/vtime.c
arch/s390/kvm/interrupt.c
arch/s390/pci/pci.c
arch/s390/pci/pci_event.c
arch/sparc/configs/sparc64_defconfig
arch/sparc/include/asm/elf_64.h
arch/sparc/include/asm/extable.h [new file with mode: 0644]
arch/sparc/include/asm/extable_64.h [deleted file]
arch/sparc/include/asm/processor_32.h
arch/sparc/include/asm/thread_info_64.h
arch/sparc/include/asm/uaccess.h
arch/sparc/include/asm/uaccess_32.h
arch/sparc/include/asm/uaccess_64.h
arch/sparc/kernel/head_32.S
arch/sparc/kernel/head_64.S
arch/sparc/kernel/process_32.c
arch/sparc/kernel/setup_32.c
arch/sparc/kernel/setup_64.c
arch/sparc/kernel/traps_64.c
arch/sparc/kernel/unaligned_32.c
arch/sparc/lib/checksum_32.S
arch/sparc/lib/copy_user.S
arch/sparc/lib/memset.S
arch/sparc/mm/Makefile
arch/sparc/mm/extable.c [deleted file]
arch/sparc/mm/fault_32.c
arch/sparc/mm/mm_32.h
arch/x86/entry/common.c
arch/x86/entry/entry_64_compat.S
arch/x86/events/core.c
arch/x86/events/intel/core.c
arch/x86/events/intel/ds.c
arch/x86/include/asm/insn-eval.h
arch/x86/include/asm/kvm_host.h
arch/x86/include/asm/processor.h
arch/x86/include/asm/proto.h
arch/x86/include/asm/ptrace.h
arch/x86/include/asm/smap.h
arch/x86/include/asm/thread_info.h
arch/x86/kernel/apic/apic.c
arch/x86/kernel/apic/io_apic.c
arch/x86/kernel/kprobes/ftrace.c
arch/x86/kernel/kvm.c
arch/x86/kernel/kvmclock.c
arch/x86/kernel/sev-es.c
arch/x86/kernel/signal.c
arch/x86/kernel/traps.c
arch/x86/kernel/unwind_orc.c
arch/x86/kvm/hyperv.c
arch/x86/kvm/hyperv.h
arch/x86/kvm/lapic.c
arch/x86/kvm/mmu/mmu_internal.h
arch/x86/kvm/mmu/tdp_iter.c
arch/x86/kvm/mmu/tdp_iter.h
arch/x86/kvm/mmu/tdp_mmu.c
arch/x86/kvm/svm/svm.c
arch/x86/kvm/vmx/vmx.c
arch/x86/kvm/x86.c
arch/x86/lib/insn-eval.c
arch/x86/net/bpf_jit_comp.c
arch/x86/platform/iris/iris.c
arch/x86/xen/p2m.c
block/bio.c
block/blk-cgroup-rwstat.c
block/blk-crypto-fallback.c
block/blk-lib.c
block/blk-map.c
block/blk-zoned.c
block/bounce.c
block/genhd.c
crypto/Kconfig
drivers/atm/eni.c
drivers/atm/fore200e.c
drivers/atm/idt77105.c
drivers/atm/lanai.c
drivers/atm/uPD98402.c
drivers/base/power/runtime.c
drivers/base/swnode.c
drivers/block/drbd/drbd_int.h
drivers/block/floppy.c
drivers/block/rsxx/core.c
drivers/block/umem.c
drivers/block/zram/zram_drv.c
drivers/bluetooth/btrsi.c
drivers/char/applicom.c
drivers/char/hw_random/pseries-rng.c
drivers/char/toshiba.c
drivers/char/tpm/tpm_ibmvtpm.c
drivers/counter/stm32-timer-cnt.c
drivers/cpufreq/cpufreq-dt-platdev.c
drivers/cpufreq/qcom-cpufreq-hw.c
drivers/crypto/nx/nx-842-pseries.c
drivers/crypto/nx/nx.c
drivers/firmware/efi/efi.c
drivers/firmware/efi/libstub/arm64-stub.c
drivers/firmware/efi/libstub/efi-stub.c
drivers/firmware/efi/vars.c
drivers/gpio/gpio-pca953x.c
drivers/gpio/gpiolib-acpi.c
drivers/gpio/gpiolib.c
drivers/gpu/drm/Kconfig
drivers/gpu/drm/amd/amdgpu/amdgpu.h
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
drivers/gpu/drm/amd/display/dc/core/dc_link.c
drivers/gpu/drm/amd/display/dc/dc.h
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hubp.c
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubp.c
drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_cm_common.c
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hubp.c
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c
drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c
drivers/gpu/drm/amd/display/dc/inc/hw/hubp.h
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_hwmgr.c
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c
drivers/gpu/drm/drm_fb_helper.c
drivers/gpu/drm/drm_gem_shmem_helper.c
drivers/gpu/drm/drm_ioc32.c
drivers/gpu/drm/i915/gt/intel_engine_cs.c
drivers/gpu/drm/i915/i915_cmd_parser.c
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/i915_perf.c
drivers/gpu/drm/i915/i915_reg.h
drivers/gpu/drm/i915/intel_pm.c
drivers/gpu/drm/meson/meson_drv.c
drivers/gpu/drm/nouveau/nouveau_bo.c
drivers/gpu/drm/omapdrm/dss/dsi.c
drivers/gpu/drm/qxl/qxl_display.c
drivers/gpu/drm/qxl/qxl_release.c
drivers/gpu/drm/radeon/radeon.h
drivers/gpu/drm/radeon/radeon_gem.c
drivers/gpu/drm/radeon/radeon_prime.c
drivers/gpu/drm/tiny/gm12u320.c
drivers/gpu/drm/ttm/ttm_bo.c
drivers/gpu/drm/ttm/ttm_pool.c
drivers/gpu/drm/udl/udl_drv.c
drivers/gpu/drm/udl/udl_drv.h
drivers/gpu/drm/udl/udl_main.c
drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
drivers/iio/adc/Kconfig
drivers/iio/adc/ab8500-gpadc.c
drivers/iio/adc/ad7949.c
drivers/iio/adc/qcom-spmi-vadc.c
drivers/iio/gyro/mpu3050-core.c
drivers/iio/humidity/hid-sensor-humidity.c
drivers/iio/imu/adis16400.c
drivers/iio/light/hid-sensor-prox.c
drivers/iio/temperature/hid-sensor-temperature.c
drivers/input/joydev.c
drivers/iommu/amd/init.c
drivers/iommu/tegra-smmu.c
drivers/irqchip/Kconfig
drivers/irqchip/irq-ingenic-tcu.c
drivers/irqchip/irq-ingenic.c
drivers/leds/trigger/ledtrig-tty.c
drivers/md/bcache/super.c
drivers/md/dm-crypt.c
drivers/md/dm-writecache.c
drivers/md/raid5-cache.c
drivers/md/raid5-ppl.c
drivers/media/firewire/firedtv-fw.c
drivers/media/pci/cx18/cx18-alsa-main.c
drivers/media/pci/cx18/cx18-driver.c
drivers/media/pci/cx25821/cx25821-alsa.c
drivers/media/pci/cx88/cx88-alsa.c
drivers/media/pci/ivtv/ivtv-alsa-main.c
drivers/media/pci/ivtv/ivtv-driver.c
drivers/media/pci/sta2x11/sta2x11_vip.c
drivers/media/platform/atmel/atmel-isi.c
drivers/media/platform/atmel/atmel-sama5d2-isc.c
drivers/media/platform/marvell-ccic/cafe-driver.c
drivers/media/platform/rockchip/rkisp1/rkisp1-params.c
drivers/media/platform/stm32/stm32-dcmi.c
drivers/media/platform/vsp1/vsp1_drm.c
drivers/media/rc/Makefile
drivers/media/rc/keymaps/Makefile
drivers/media/rc/keymaps/rc-cec.c
drivers/media/rc/rc-main.c
drivers/media/usb/cpia2/cpia2_v4l.c
drivers/media/usb/tm6000/tm6000-alsa.c
drivers/media/usb/tm6000/tm6000-dvb.c
drivers/media/usb/usbtv/usbtv-audio.c
drivers/misc/fastrpc.c
drivers/misc/habanalabs/common/debugfs.c
drivers/misc/habanalabs/common/device.c
drivers/misc/habanalabs/common/habanalabs.h
drivers/misc/habanalabs/common/habanalabs_ioctl.c
drivers/misc/habanalabs/common/irq.c
drivers/misc/habanalabs/common/mmu/mmu.c
drivers/misc/ibmvmc.c
drivers/misc/pvpanic.c
drivers/mmc/core/bus.c
drivers/mmc/core/mmc.c
drivers/mmc/host/mmci.c
drivers/most/Kconfig
drivers/most/Makefile
drivers/most/most_snd.c [new file with mode: 0644]
drivers/mtd/maps/sun_uflash.c
drivers/net/Kconfig
drivers/net/bonding/bond_main.c
drivers/net/can/flexcan.c
drivers/net/can/m_can/tcan4x5x-core.c
drivers/net/can/peak_canfd/peak_pciefd_main.c
drivers/net/can/sja1000/ems_pci.c
drivers/net/can/sja1000/ems_pcmcia.c
drivers/net/can/sja1000/kvaser_pci.c
drivers/net/can/sja1000/peak_pci.c
drivers/net/can/sja1000/peak_pcmcia.c
drivers/net/can/sja1000/plx_pci.c
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
drivers/net/can/usb/peak_usb/pcan_usb.c
drivers/net/can/usb/peak_usb/pcan_usb_fd.c
drivers/net/can/usb/peak_usb/pcan_usb_pro.c
drivers/net/dsa/bcm_sf2.c
drivers/net/dsa/mt7530.c
drivers/net/dsa/sja1105/sja1105_main.c
drivers/net/dsa/xrs700x/xrs700x.c
drivers/net/ethernet/atheros/alx/main.c
drivers/net/ethernet/broadcom/bcm4908_enet.c
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/cadence/macb_main.c
drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c
drivers/net/ethernet/davicom/dm9000.c
drivers/net/ethernet/freescale/enetc/enetc.c
drivers/net/ethernet/freescale/enetc/enetc.h
drivers/net/ethernet/freescale/enetc/enetc_hw.h
drivers/net/ethernet/freescale/enetc/enetc_pf.c
drivers/net/ethernet/freescale/enetc/enetc_vf.c
drivers/net/ethernet/freescale/fec_ptp.c
drivers/net/ethernet/freescale/gianfar.c
drivers/net/ethernet/hisilicon/hns/hns_enet.c
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
drivers/net/ethernet/ibm/ibmveth.c
drivers/net/ethernet/ibm/ibmvnic.c
drivers/net/ethernet/intel/iavf/iavf_main.c
drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
drivers/net/ethernet/intel/ixgbevf/ipsec.c
drivers/net/ethernet/marvell/octeontx2/af/cgx.c
drivers/net/ethernet/mediatek/mtk_star_emac.c
drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
drivers/net/ethernet/mellanox/mlx4/en_netdev.c
drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
drivers/net/ethernet/mellanox/mlxsw/reg.h
drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
drivers/net/ethernet/mellanox/mlxsw/switchx2.c
drivers/net/ethernet/microchip/lan743x_main.c
drivers/net/ethernet/mscc/Kconfig
drivers/net/ethernet/mscc/ocelot_flower.c
drivers/net/ethernet/realtek/r8169_main.c
drivers/net/ethernet/renesas/sh_eth.c
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c
drivers/net/ethernet/stmicro/stmmac/enh_desc.c
drivers/net/ethernet/stmicro/stmmac/hwif.h
drivers/net/ethernet/stmicro/stmmac/norm_desc.c
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
drivers/net/ethernet/sun/niu.c
drivers/net/ethernet/tehuti/tehuti.c
drivers/net/hamradio/6pack.c
drivers/net/hamradio/scc.c
drivers/net/hyperv/hyperv_net.h
drivers/net/hyperv/netvsc_drv.c
drivers/net/hyperv/rndis_filter.c
drivers/net/netdevsim/netdev.c
drivers/net/phy/dp83822.c
drivers/net/phy/dp83tc811.c
drivers/net/phy/phy.c
drivers/net/phy/phy_device.c
drivers/net/usb/cdc_ncm.c
drivers/net/usb/qmi_wwan.c
drivers/net/usb/r8152.c
drivers/net/usb/usbnet.c
drivers/net/wan/fsl_ucc_hdlc.c
drivers/net/wan/lapbether.c
drivers/net/wireless/admtek/adm8211.c
drivers/net/wireless/ath/ath11k/mac.c
drivers/net/wireless/ath/ath11k/qmi.c
drivers/net/wireless/ath/ath5k/base.c
drivers/net/wireless/ath/ath9k/ath9k.h
drivers/net/wireless/ath/ath9k/hw.c
drivers/net/wireless/ath/ath9k/init.c
drivers/net/wireless/ath/ath9k/xmit.c
drivers/net/wireless/atmel/atmel.c
drivers/net/wireless/atmel/atmel_cs.c
drivers/net/wireless/atmel/atmel_pci.c
drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.c
drivers/net/wireless/broadcom/brcm80211/brcmutil/utils.c
drivers/net/wireless/cisco/airo.c
drivers/net/wireless/cisco/airo_cs.c
drivers/net/wireless/intel/iwlwifi/fw/pnvm.c
drivers/net/wireless/intel/iwlwifi/iwl-op-mode.h
drivers/net/wireless/intel/iwlwifi/mvm/fw.c
drivers/net/wireless/intel/iwlwifi/pcie/drv.c
drivers/net/wireless/intel/iwlwifi/pcie/rx.c
drivers/net/wireless/intersil/hostap/hostap_cs.c
drivers/net/wireless/intersil/hostap/hostap_pci.c
drivers/net/wireless/intersil/hostap/hostap_plx.c
drivers/net/wireless/mediatek/mt76/dma.c
drivers/net/wireless/mediatek/mt76/mt7915/mac.c
drivers/net/wireless/mediatek/mt76/mt7915/testmode.c
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
drivers/net/wireless/ralink/rt2x00/rt2400pci.c
drivers/net/wireless/ralink/rt2x00/rt2500pci.c
drivers/net/wireless/ralink/rt2x00/rt2500usb.c
drivers/net/wireless/ralink/rt2x00/rt2800pci.c
drivers/net/wireless/ralink/rt2x00/rt2800usb.c
drivers/net/wireless/ralink/rt2x00/rt61pci.c
drivers/net/wireless/ralink/rt2x00/rt73usb.c
drivers/net/wireless/rsi/rsi_91x_main.c
drivers/net/wireless/rsi/rsi_91x_sdio.c
drivers/net/wireless/rsi/rsi_91x_usb.c
drivers/net/xen-netback/netback.c
drivers/nvme/host/core.c
drivers/nvme/host/fabrics.h
drivers/nvme/host/fc.c
drivers/nvme/host/pci.c
drivers/nvme/host/rdma.c
drivers/nvme/host/tcp.c
drivers/nvme/host/zns.c
drivers/nvme/target/core.c
drivers/nvme/target/loop.c
drivers/nvme/target/passthru.c
drivers/nvme/target/rdma.c
drivers/nvme/target/tcp.c
drivers/opp/core.c
drivers/opp/opp.h
drivers/parport/parport_amiga.c
drivers/parport/parport_atari.c
drivers/parport/parport_gsc.c
drivers/parport/parport_mfc3.c
drivers/parport/parport_sunbpp.c
drivers/pci/hotplug/rpadlpar_sysfs.c
drivers/pci/hotplug/s390_pci_hpc.c
drivers/pci/xen-pcifront.c
drivers/perf/arm_dmc620_pmu.c
drivers/regulator/mt6315-regulator.c
drivers/regulator/pca9450-regulator.c
drivers/regulator/qcom-rpmh-regulator.c
drivers/regulator/rt4831-regulator.c
drivers/s390/block/dasd.c
drivers/s390/char/tty3270.c
drivers/s390/char/zcore.c
drivers/s390/cio/device_fsm.c
drivers/s390/cio/vfio_ccw_ops.c
drivers/s390/crypto/vfio_ap_ops.c
drivers/s390/net/qeth_core.h
drivers/s390/net/qeth_core_main.c
drivers/sbus/char/display7seg.c
drivers/scsi/hpsa.c
drivers/scsi/ibmvscsi/ibmvfc.c
drivers/scsi/ibmvscsi/ibmvscsi.c
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
drivers/scsi/lpfc/lpfc_debugfs.c
drivers/scsi/mpt3sas/mpt3sas_scsih.c
drivers/scsi/myrs.c
drivers/scsi/pcmcia/nsp_cs.c
drivers/scsi/qla2xxx/qla_target.h
drivers/scsi/sd_zbc.c
drivers/scsi/smartpqi/smartpqi_init.c
drivers/scsi/st.c
drivers/scsi/ufs/ufs-mediatek.c
drivers/scsi/ufs/ufs-qcom.c
drivers/scsi/ufs/ufshcd.c
drivers/scsi/vmw_pvscsi.c
drivers/scsi/vmw_pvscsi.h
drivers/sh/maple/maple.c
drivers/spi/spi-cadence-quadspi.c
drivers/staging/Kconfig
drivers/staging/Makefile
drivers/staging/comedi/drivers/addi_apci_1032.c
drivers/staging/comedi/drivers/addi_apci_1500.c
drivers/staging/comedi/drivers/adv_pci1710.c
drivers/staging/comedi/drivers/amplc_pc236_common.c
drivers/staging/comedi/drivers/cb_pcidas.c
drivers/staging/comedi/drivers/cb_pcidas64.c
drivers/staging/comedi/drivers/comedi_parport.c
drivers/staging/comedi/drivers/das6402.c
drivers/staging/comedi/drivers/das800.c
drivers/staging/comedi/drivers/dmm32at.c
drivers/staging/comedi/drivers/me4000.c
drivers/staging/comedi/drivers/ni_6527.c
drivers/staging/comedi/drivers/ni_65xx.c
drivers/staging/comedi/drivers/pcl711.c
drivers/staging/comedi/drivers/pcl726.c
drivers/staging/comedi/drivers/pcl818.c
drivers/staging/comedi/drivers/vmk80xx.c
drivers/staging/gasket/Kconfig [deleted file]
drivers/staging/gasket/Makefile [deleted file]
drivers/staging/gasket/TODO [deleted file]
drivers/staging/gasket/apex.h [deleted file]
drivers/staging/gasket/apex_driver.c [deleted file]
drivers/staging/gasket/gasket.h [deleted file]
drivers/staging/gasket/gasket_constants.h [deleted file]
drivers/staging/gasket/gasket_core.c [deleted file]
drivers/staging/gasket/gasket_core.h [deleted file]
drivers/staging/gasket/gasket_interrupt.c [deleted file]
drivers/staging/gasket/gasket_interrupt.h [deleted file]
drivers/staging/gasket/gasket_ioctl.c [deleted file]
drivers/staging/gasket/gasket_ioctl.h [deleted file]
drivers/staging/gasket/gasket_page_table.c [deleted file]
drivers/staging/gasket/gasket_page_table.h [deleted file]
drivers/staging/gasket/gasket_sysfs.c [deleted file]
drivers/staging/gasket/gasket_sysfs.h [deleted file]
drivers/staging/ks7010/ks_wlan_net.c
drivers/staging/most/Kconfig
drivers/staging/most/Makefile
drivers/staging/most/sound/Kconfig [deleted file]
drivers/staging/most/sound/Makefile [deleted file]
drivers/staging/most/sound/sound.c [deleted file]
drivers/staging/nvec/nvec_ps2.c
drivers/staging/octeon-usb/octeon-hcd.c
drivers/staging/qlge/qlge_main.c
drivers/staging/rtl8188eu/core/rtw_ap.c
drivers/staging/rtl8188eu/core/rtw_debug.c
drivers/staging/rtl8188eu/core/rtw_ieee80211.c
drivers/staging/rtl8188eu/core/rtw_mlme.c
drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
drivers/staging/rtl8188eu/core/rtw_pwrctrl.c
drivers/staging/rtl8188eu/core/rtw_recv.c
drivers/staging/rtl8188eu/core/rtw_xmit.c
drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c
drivers/staging/rtl8188eu/include/osdep_intf.h
drivers/staging/rtl8188eu/include/osdep_service.h
drivers/staging/rtl8188eu/include/wifi.h
drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
drivers/staging/rtl8188eu/os_dep/os_intfs.c
drivers/staging/rtl8188eu/os_dep/osdep_service.c
drivers/staging/rtl8188eu/os_dep/rtw_android.c
drivers/staging/rtl8188eu/os_dep/usb_intf.c
drivers/staging/rtl8188eu/os_dep/xmit_linux.c
drivers/staging/rtl8192e/Kconfig
drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
drivers/staging/rtl8192u/r8192U.h
drivers/staging/rtl8192u/r8192U_wx.c
drivers/staging/rtl8712/rtl8712_xmit.h
drivers/staging/rtl8712/rtl871x_cmd.c
drivers/staging/rtl8712/rtl871x_ioctl_linux.c
drivers/staging/rtl8712/rtl871x_mlme.c
drivers/staging/rtl8723bs/TODO
drivers/staging/rtl8723bs/core/rtw_ap.c
drivers/staging/rtl8723bs/core/rtw_cmd.c
drivers/staging/rtl8723bs/core/rtw_efuse.c
drivers/staging/rtl8723bs/core/rtw_ieee80211.c
drivers/staging/rtl8723bs/core/rtw_ioctl_set.c
drivers/staging/rtl8723bs/core/rtw_mlme.c
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
drivers/staging/rtl8723bs/core/rtw_odm.c
drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
drivers/staging/rtl8723bs/core/rtw_recv.c
drivers/staging/rtl8723bs/core/rtw_security.c
drivers/staging/rtl8723bs/core/rtw_wlan_util.c
drivers/staging/rtl8723bs/core/rtw_xmit.c
drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c
drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.h
drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c
drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.h
drivers/staging/rtl8723bs/hal/HalBtcOutSrc.h
drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c
drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.h
drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.c
drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.h
drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c
drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.h
drivers/staging/rtl8723bs/hal/HalPhyRf.c
drivers/staging/rtl8723bs/hal/HalPhyRf.h
drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c
drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.h
drivers/staging/rtl8723bs/hal/HalPwrSeqCmd.c
drivers/staging/rtl8723bs/hal/hal_btcoex.c
drivers/staging/rtl8723bs/hal/hal_com.c
drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
drivers/staging/rtl8723bs/hal/hal_intf.c
drivers/staging/rtl8723bs/hal/hal_pwr_seq.c
drivers/staging/rtl8723bs/hal/odm.c
drivers/staging/rtl8723bs/hal/odm.h
drivers/staging/rtl8723bs/hal/odm_CfoTracking.c
drivers/staging/rtl8723bs/hal/odm_CfoTracking.h
drivers/staging/rtl8723bs/hal/odm_DIG.c
drivers/staging/rtl8723bs/hal/odm_DIG.h
drivers/staging/rtl8723bs/hal/odm_DynamicBBPowerSaving.c
drivers/staging/rtl8723bs/hal/odm_DynamicBBPowerSaving.h
drivers/staging/rtl8723bs/hal/odm_DynamicTxPower.c
drivers/staging/rtl8723bs/hal/odm_EdcaTurboCheck.c
drivers/staging/rtl8723bs/hal/odm_EdcaTurboCheck.h
drivers/staging/rtl8723bs/hal/odm_HWConfig.c
drivers/staging/rtl8723bs/hal/odm_HWConfig.h
drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.c
drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.h
drivers/staging/rtl8723bs/hal/odm_PathDiv.c
drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.c
drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.h
drivers/staging/rtl8723bs/hal/odm_debug.c
drivers/staging/rtl8723bs/hal/odm_debug.h
drivers/staging/rtl8723bs/hal/odm_interface.h
drivers/staging/rtl8723bs/hal/odm_types.h
drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c
drivers/staging/rtl8723bs/hal/rtl8723b_dm.c
drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c
drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c
drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
drivers/staging/rtl8723bs/hal/sdio_halinit.c
drivers/staging/rtl8723bs/hal/sdio_ops.c
drivers/staging/rtl8723bs/include/HalPwrSeqCmd.h
drivers/staging/rtl8723bs/include/HalVerDef.h
drivers/staging/rtl8723bs/include/autoconf.h
drivers/staging/rtl8723bs/include/basic_types.h
drivers/staging/rtl8723bs/include/drv_conf.h
drivers/staging/rtl8723bs/include/drv_types.h
drivers/staging/rtl8723bs/include/drv_types_sdio.h
drivers/staging/rtl8723bs/include/hal_btcoex.h
drivers/staging/rtl8723bs/include/hal_com.h
drivers/staging/rtl8723bs/include/hal_com_h2c.h
drivers/staging/rtl8723bs/include/hal_com_phycfg.h
drivers/staging/rtl8723bs/include/hal_com_reg.h
drivers/staging/rtl8723bs/include/hal_data.h
drivers/staging/rtl8723bs/include/hal_intf.h
drivers/staging/rtl8723bs/include/hal_phy.h
drivers/staging/rtl8723bs/include/hal_phy_cfg.h
drivers/staging/rtl8723bs/include/hal_pwr_seq.h
drivers/staging/rtl8723bs/include/ieee80211.h
drivers/staging/rtl8723bs/include/ioctl_cfg80211.h
drivers/staging/rtl8723bs/include/osdep_intf.h
drivers/staging/rtl8723bs/include/osdep_service.h
drivers/staging/rtl8723bs/include/osdep_service_linux.h
drivers/staging/rtl8723bs/include/recv_osdep.h
drivers/staging/rtl8723bs/include/rtl8723b_cmd.h
drivers/staging/rtl8723bs/include/rtl8723b_hal.h
drivers/staging/rtl8723bs/include/rtl8723b_recv.h
drivers/staging/rtl8723bs/include/rtl8723b_rf.h
drivers/staging/rtl8723bs/include/rtl8723b_spec.h
drivers/staging/rtl8723bs/include/rtl8723b_xmit.h
drivers/staging/rtl8723bs/include/rtw_cmd.h
drivers/staging/rtl8723bs/include/rtw_eeprom.h
drivers/staging/rtl8723bs/include/rtw_efuse.h
drivers/staging/rtl8723bs/include/rtw_event.h
drivers/staging/rtl8723bs/include/rtw_ht.h
drivers/staging/rtl8723bs/include/rtw_io.h
drivers/staging/rtl8723bs/include/rtw_ioctl_set.h
drivers/staging/rtl8723bs/include/rtw_mlme.h
drivers/staging/rtl8723bs/include/rtw_mlme_ext.h
drivers/staging/rtl8723bs/include/rtw_mp.h
drivers/staging/rtl8723bs/include/rtw_pwrctrl.h
drivers/staging/rtl8723bs/include/rtw_recv.h
drivers/staging/rtl8723bs/include/rtw_rf.h
drivers/staging/rtl8723bs/include/rtw_security.h
drivers/staging/rtl8723bs/include/rtw_wifi_regd.h
drivers/staging/rtl8723bs/include/rtw_xmit.h
drivers/staging/rtl8723bs/include/sdio_ops.h
drivers/staging/rtl8723bs/include/sta_info.h
drivers/staging/rtl8723bs/include/wifi.h
drivers/staging/rtl8723bs/include/wlan_bssdef.h
drivers/staging/rtl8723bs/include/xmit_osdep.h
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
drivers/staging/rtl8723bs/os_dep/mlme_linux.c
drivers/staging/rtl8723bs/os_dep/os_intfs.c
drivers/staging/rtl8723bs/os_dep/osdep_service.c
drivers/staging/rtl8723bs/os_dep/recv_linux.c
drivers/staging/rtl8723bs/os_dep/sdio_intf.c
drivers/staging/rtl8723bs/os_dep/wifi_regd.c
drivers/staging/rtl8723bs/os_dep/xmit_linux.c
drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
drivers/staging/vt6655/baseband.c
drivers/staging/vt6655/channel.c
drivers/staging/vt6655/rxtx.h
drivers/staging/wfx/bh.c
drivers/staging/wfx/bh.h
drivers/staging/wfx/bus.h
drivers/staging/wfx/bus_sdio.c
drivers/staging/wfx/bus_spi.c
drivers/staging/wfx/data_rx.c
drivers/staging/wfx/data_tx.c
drivers/staging/wfx/data_tx.h
drivers/staging/wfx/debug.c
drivers/staging/wfx/fwio.c
drivers/staging/wfx/hif_api_cmd.h
drivers/staging/wfx/hif_api_general.h
drivers/staging/wfx/hif_tx.c
drivers/staging/wfx/hif_tx_mib.c
drivers/staging/wfx/hwio.c
drivers/staging/wfx/hwio.h
drivers/staging/wfx/key.c
drivers/staging/wfx/key.h
drivers/staging/wfx/main.c
drivers/staging/wfx/main.h
drivers/staging/wfx/queue.c
drivers/staging/wfx/queue.h
drivers/staging/wfx/scan.h
drivers/staging/wfx/sta.c
drivers/staging/wfx/sta.h
drivers/staging/wfx/traces.h
drivers/staging/wfx/wfx.h
drivers/staging/wimax/Documentation/i2400m.rst [deleted file]
drivers/staging/wimax/Documentation/index.rst [deleted file]
drivers/staging/wimax/Documentation/wimax.rst [deleted file]
drivers/staging/wimax/Kconfig [deleted file]
drivers/staging/wimax/Makefile [deleted file]
drivers/staging/wimax/TODO [deleted file]
drivers/staging/wimax/debug-levels.h [deleted file]
drivers/staging/wimax/debugfs.c [deleted file]
drivers/staging/wimax/i2400m/Kconfig [deleted file]
drivers/staging/wimax/i2400m/Makefile [deleted file]
drivers/staging/wimax/i2400m/control.c [deleted file]
drivers/staging/wimax/i2400m/debug-levels.h [deleted file]
drivers/staging/wimax/i2400m/debugfs.c [deleted file]
drivers/staging/wimax/i2400m/driver.c [deleted file]
drivers/staging/wimax/i2400m/fw.c [deleted file]
drivers/staging/wimax/i2400m/i2400m-usb.h [deleted file]
drivers/staging/wimax/i2400m/i2400m.h [deleted file]
drivers/staging/wimax/i2400m/linux-wimax-i2400m.h [deleted file]
drivers/staging/wimax/i2400m/netdev.c [deleted file]
drivers/staging/wimax/i2400m/op-rfkill.c [deleted file]
drivers/staging/wimax/i2400m/rx.c [deleted file]
drivers/staging/wimax/i2400m/sysfs.c [deleted file]
drivers/staging/wimax/i2400m/tx.c [deleted file]
drivers/staging/wimax/i2400m/usb-debug-levels.h [deleted file]
drivers/staging/wimax/i2400m/usb-fw.c [deleted file]
drivers/staging/wimax/i2400m/usb-notif.c [deleted file]
drivers/staging/wimax/i2400m/usb-rx.c [deleted file]
drivers/staging/wimax/i2400m/usb-tx.c [deleted file]
drivers/staging/wimax/i2400m/usb.c [deleted file]
drivers/staging/wimax/id-table.c [deleted file]
drivers/staging/wimax/linux-wimax-debug.h [deleted file]
drivers/staging/wimax/linux-wimax.h [deleted file]
drivers/staging/wimax/net-wimax.h [deleted file]
drivers/staging/wimax/op-msg.c [deleted file]
drivers/staging/wimax/op-reset.c [deleted file]
drivers/staging/wimax/op-rfkill.c [deleted file]
drivers/staging/wimax/op-state-get.c [deleted file]
drivers/staging/wimax/stack.c [deleted file]
drivers/staging/wimax/wimax-internal.h [deleted file]
drivers/tee/optee/core.c
drivers/thermal/thermal_sysfs.c
drivers/thunderbolt/switch.c
drivers/thunderbolt/tb.c
drivers/tty/hvc/hvcs.c
drivers/tty/pty.c
drivers/tty/serial/icom.c
drivers/tty/serial/jsm/jsm_driver.c
drivers/tty/serial/max310x.c
drivers/tty/tty_io.c
drivers/usb/cdns3/cdnsp-ring.c
drivers/usb/class/cdc-acm.c
drivers/usb/class/usblp.c
drivers/usb/core/usb.c
drivers/usb/dwc3/dwc3-qcom.c
drivers/usb/dwc3/gadget.c
drivers/usb/gadget/configfs.c
drivers/usb/gadget/function/f_uac1.c
drivers/usb/gadget/function/f_uac2.c
drivers/usb/gadget/function/u_ether_configfs.h
drivers/usb/gadget/udc/s3c2410_udc.c
drivers/usb/host/xhci-pci.c
drivers/usb/host/xhci-ring.c
drivers/usb/host/xhci.c
drivers/usb/host/xhci.h
drivers/usb/misc/ldusb.c
drivers/usb/renesas_usbhs/pipe.c
drivers/usb/serial/ch341.c
drivers/usb/serial/cp210x.c
drivers/usb/serial/io_edgeport.c
drivers/usb/serial/xr_serial.c
drivers/usb/storage/transport.c
drivers/usb/storage/unusual_devs.h
drivers/usb/typec/tcpm/tcpm.c
drivers/usb/typec/tps6598x.c
drivers/usb/usbip/stub_dev.c
drivers/usb/usbip/vhci_sysfs.c
drivers/usb/usbip/vudc_sysfs.c
drivers/vdpa/ifcvf/ifcvf_main.c
drivers/vdpa/mlx5/net/mlx5_vnet.c
drivers/vdpa/vdpa.c
drivers/vdpa/vdpa_sim/vdpa_sim.c
drivers/vdpa/vdpa_sim/vdpa_sim_net.c
drivers/vfio/Kconfig
drivers/vfio/platform/Kconfig
drivers/vfio/vfio_iommu_type1.c
drivers/vhost/vdpa.c
drivers/vhost/vhost.c
drivers/video/fbdev/aty/atyfb.h
drivers/video/fbdev/aty/atyfb_base.c
drivers/virt/acrn/hsm.c
drivers/virt/acrn/irqfd.c
drivers/virtio/virtio.c
drivers/virtio/virtio_mmio.c
drivers/watchdog/cpu5wdt.c
drivers/watchdog/cpwd.c
drivers/watchdog/riowd.c
drivers/xen/events/events_2l.c
drivers/xen/events/events_base.c
drivers/xen/events/events_fifo.c
drivers/xen/events/events_internal.h
drivers/xen/gntdev.c
fs/Kconfig
fs/afs/dir.c
fs/afs/file.c
fs/afs/fs_operation.c
fs/afs/inode.c
fs/afs/internal.h
fs/afs/mntpt.c
fs/afs/xattr.c
fs/binfmt_misc.c
fs/block_dev.c
fs/btrfs/ctree.c
fs/btrfs/extent-tree.c
fs/btrfs/extent_io.c
fs/btrfs/inode.c
fs/btrfs/reada.c
fs/btrfs/scrub.c
fs/btrfs/tree-log.c
fs/cifs/cifs_debug.c
fs/cifs/cifs_swn.c
fs/cifs/cifsacl.c
fs/cifs/cifsfs.c
fs/cifs/cifsglob.h
fs/cifs/connect.c
fs/cifs/fs_context.c
fs/cifs/inode.c
fs/cifs/sess.c
fs/cifs/smb2inode.c
fs/cifs/smb2misc.c
fs/cifs/smb2ops.c
fs/cifs/smb2pdu.c
fs/cifs/smb2proto.h
fs/cifs/transport.c
fs/configfs/file.c
fs/crypto/bio.c
fs/erofs/data.c
fs/erofs/zdata.c
fs/ext4/balloc.c
fs/ext4/ext4.h
fs/ext4/extents.c
fs/ext4/fast_commit.c
fs/ext4/inode.c
fs/ext4/mballoc.c
fs/ext4/namei.c
fs/ext4/page-io.c
fs/ext4/super.c
fs/ext4/sysfs.c
fs/ext4/verity.c
fs/ext4/xattr.c
fs/f2fs/checkpoint.c
fs/f2fs/data.c
fs/f2fs/segment.c
fs/f2fs/segment.h
fs/f2fs/super.c
fs/fuse/dev.c
fs/fuse/fuse_i.h
fs/fuse/virtio_fs.c
fs/gfs2/log.c
fs/gfs2/lops.c
fs/gfs2/ops_fstype.c
fs/gfs2/super.c
fs/gfs2/super.h
fs/gfs2/trans.c
fs/gfs2/util.c
fs/io-wq.c
fs/io-wq.h
fs/io_uring.c
fs/iomap/buffered-io.c
fs/iomap/direct-io.c
fs/iomap/swapfile.c
fs/locks.c
fs/mpage.c
fs/nfs/Kconfig
fs/nfs/dir.c
fs/nfs/inode.c
fs/nfs/internal.h
fs/nfs/nfs3xdr.c
fs/nfs/nfs42proc.c
fs/nfs/nfs4proc.c
fs/nfs/unlink.c
fs/nfs/write.c
fs/nfsd/Kconfig
fs/nfsd/filecache.c
fs/nfsd/nfs4callback.c
fs/nfsd/nfs4proc.c
fs/nfsd/nfs4state.c
fs/nilfs2/segbuf.c
fs/pnode.h
fs/proc/task_mmu.c
fs/select.c
fs/squashfs/block.c
fs/xfs/xfs_inode.c
fs/xfs/xfs_itable.c
fs/xfs/xfs_mount.c
fs/xfs/xfs_symlink.c
fs/zonefs/super.c
include/drm/ttm/ttm_bo_api.h
include/kvm/arm_pmu.h
include/linux/acpi.h
include/linux/amba/bus.h
include/linux/atmdev.h
include/linux/bio.h
include/linux/can/skb.h
include/linux/compiler-clang.h
include/linux/compiler-version.h [new file with mode: 0644]
include/linux/cpu.h
include/linux/efi.h
include/linux/gpio/consumer.h
include/linux/io_uring.h
include/linux/irqdomain.h
include/linux/kconfig.h
include/linux/memblock.h
include/linux/memcontrol.h
include/linux/mm.h
include/linux/mm_types.h
include/linux/module.h
include/linux/netdevice.h
include/linux/perf_event.h
include/linux/pgtable.h
include/linux/property.h
include/linux/regulator/pca9450.h
include/linux/restart_block.h
include/linux/sched/mm.h
include/linux/seqlock.h
include/linux/stop_machine.h
include/linux/sunrpc/svc_rdma.h
include/linux/textsearch.h
include/linux/thread_info.h
include/linux/u64_stats_sync.h
include/linux/usb.h
include/linux/usb_usual.h
include/linux/vdpa.h
include/linux/virtio.h
include/linux/virtio_net.h
include/linux/ww_mutex.h
include/media/rc-map.h
include/trace/events/workqueue.h
include/uapi/linux/bpf.h
include/uapi/linux/fuse.h
include/uapi/linux/l2tp.h
include/uapi/linux/netfilter/nfnetlink_cthelper.h
include/xen/grant_table.h
include/xen/xenbus.h
init/Kconfig
kernel/bpf/btf.c
kernel/bpf/core.c
kernel/bpf/verifier.c
kernel/events/core.c
kernel/fork.c
kernel/freezer.c
kernel/futex.c
kernel/irq/irq_sim.c
kernel/irq/irqdomain.c
kernel/irq/manage.c
kernel/jump_label.c
kernel/locking/mutex.c
kernel/reboot.c
kernel/sched/core.c
kernel/sched/membarrier.c
kernel/signal.c
kernel/static_call.c
kernel/sys.c
kernel/time/alarmtimer.c
kernel/time/hrtimer.c
kernel/time/posix-cpu-timers.c
lib/Kconfig.kasan
lib/extable.c
mm/highmem.c
mm/huge_memory.c
mm/hugetlb.c
mm/internal.h
mm/kfence/report.c
mm/madvise.c
mm/memcontrol.c
mm/memory.c
mm/memory_hotplug.c
mm/page_alloc.c
mm/slab.c
mm/slub.c
net/9p/client.c
net/batman-adv/main.c
net/core/rtnetlink.c
net/core/skbuff.c
net/dsa/Kconfig
net/dsa/dsa_priv.h
net/dsa/slave.c
net/dsa/tag_mtk.c
net/dsa/tag_rtl4_a.c
net/ethtool/channels.c
net/ipv4/cipso_ipv4.c
net/ipv4/inetpeer.c
net/ipv4/ip_tunnel.c
net/ipv4/ip_vti.c
net/ipv4/nexthop.c
net/ipv4/tcp.c
net/ipv4/udp_offload.c
net/ipv6/calipso.c
net/ipv6/ip6_gre.c
net/ipv6/ip6_tunnel.c
net/ipv6/ip6_vti.c
net/ipv6/sit.c
net/l2tp/l2tp_core.c
net/l2tp/l2tp_core.h
net/l2tp/l2tp_netlink.c
net/mpls/mpls_gso.c
net/mptcp/protocol.c
net/mptcp/protocol.h
net/mptcp/subflow.c
net/netfilter/nf_conntrack_helper.c
net/netfilter/nf_conntrack_proto_tcp.c
net/netfilter/nf_nat_proto.c
net/netfilter/nf_tables_api.c
net/netfilter/x_tables.c
net/netlabel/netlabel_cipso_v4.c
net/qrtr/qrtr.c
net/sched/sch_api.c
net/sctp/tsnmap.c
net/sunrpc/auth_gss/svcauth_gss.c
net/sunrpc/sched.c
net/sunrpc/svc.c
net/sunrpc/svc_xprt.c
net/sunrpc/xprtrdma/svc_rdma_backchannel.c
net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
samples/bpf/xdpsock_user.c
scripts/Makefile.lib
scripts/dummy-tools/gcc
scripts/gcc-plugins/Makefile
scripts/ld-version.sh
security/commoncap.c
sound/drivers/aloop.c
sound/drivers/dummy.c
sound/drivers/mtpav.c
sound/drivers/mts64.c
sound/drivers/pcsp/pcsp.c
sound/drivers/portman2x4.c
sound/drivers/serial-u16550.c
sound/drivers/virmidi.c
sound/firewire/dice/dice-stream.c
sound/hda/intel-nhlt.c
sound/isa/ad1816a/ad1816a.c
sound/isa/ad1848/ad1848.c
sound/isa/als100.c
sound/isa/azt2320.c
sound/isa/cmi8330.c
sound/isa/cs423x/cs4231.c
sound/isa/cs423x/cs4236.c
sound/isa/es1688/es1688.c
sound/isa/es18xx.c
sound/isa/gus/gusclassic.c
sound/isa/gus/gusextreme.c
sound/isa/gus/gusmax.c
sound/isa/gus/interwave.c
sound/isa/opl3sa2.c
sound/isa/opti9xx/miro.c
sound/isa/opti9xx/opti92x-ad1848.c
sound/isa/sb/jazz16.c
sound/isa/sb/sb16.c
sound/isa/sb/sb8.c
sound/isa/sc6000.c
sound/isa/wavefront/wavefront.c
sound/mips/sgio2audio.c
sound/pci/ad1889.c
sound/pci/ali5451/ali5451.c
sound/pci/als300.c
sound/pci/als4000.c
sound/pci/atiixp.c
sound/pci/atiixp_modem.c
sound/pci/au88x0/au88x0.c
sound/pci/azt3328.c
sound/pci/bt87x.c
sound/pci/ca0106/ca0106_main.c
sound/pci/cmipci.c
sound/pci/cs4281.c
sound/pci/cs46xx/cs46xx.c
sound/pci/cs5535audio/cs5535audio.c
sound/pci/ctxfi/xfi.c
sound/pci/echoaudio/echoaudio.c
sound/pci/emu10k1/emu10k1.c
sound/pci/emu10k1/emu10k1x.c
sound/pci/ens1370.c
sound/pci/es1938.c
sound/pci/es1968.c
sound/pci/fm801.c
sound/pci/hda/hda_bind.c
sound/pci/hda/hda_controller.c
sound/pci/hda/hda_generic.c
sound/pci/hda/hda_intel.c
sound/pci/hda/patch_ca0132.c
sound/pci/hda/patch_conexant.c
sound/pci/hda/patch_hdmi.c
sound/pci/hda/patch_realtek.c
sound/pci/ice1712/ice1712.c
sound/pci/ice1712/ice1724.c
sound/pci/intel8x0.c
sound/pci/intel8x0m.c
sound/pci/korg1212/korg1212.c
sound/pci/lola/lola.c
sound/pci/lx6464es/lx6464es.c
sound/pci/maestro3.c
sound/pci/mixart/mixart.c
sound/pci/nm256/nm256.c
sound/pci/oxygen/oxygen.c
sound/pci/oxygen/se6x.c
sound/pci/oxygen/virtuoso.c
sound/pci/pcxhr/pcxhr.c
sound/pci/riptide/riptide.c
sound/pci/rme32.c
sound/pci/rme96.c
sound/pci/rme9652/hdsp.c
sound/pci/rme9652/hdspm.c
sound/pci/rme9652/rme9652.c
sound/pci/sis7019.c
sound/pci/sonicvibes.c
sound/pci/trident/trident.c
sound/pci/via82xx.c
sound/pci/via82xx_modem.c
sound/pci/vx222/vx222.c
sound/pci/ymfpci/ymfpci.c
sound/pcmcia/pdaudiocf/pdaudiocf.c
sound/pcmcia/vx/vxpocket.c
sound/ppc/powermac.c
sound/sh/aica.c
sound/sh/sh_dac_audio.c
sound/soc/codecs/Kconfig
sound/soc/codecs/ak4458.c
sound/soc/codecs/ak5558.c
sound/soc/codecs/cs42l42.c
sound/soc/codecs/cs42l42.h
sound/soc/codecs/es8316.c
sound/soc/codecs/lpass-rx-macro.c
sound/soc/codecs/lpass-va-macro.c
sound/soc/codecs/lpass-wsa-macro.c
sound/soc/codecs/rt1015.c
sound/soc/codecs/rt5640.c
sound/soc/codecs/rt5651.c
sound/soc/codecs/rt5659.c
sound/soc/codecs/rt5670.c
sound/soc/codecs/rt5670.h
sound/soc/codecs/rt711.c
sound/soc/codecs/sgtl5000.c
sound/soc/codecs/sirf-audio-codec.h [deleted file]
sound/soc/codecs/wcd934x.c
sound/soc/fsl/fsl_ssi.c
sound/soc/generic/simple-card-utils.c
sound/soc/intel/boards/bytcr_rt5640.c
sound/soc/mediatek/mt8192/mt8192-dai-tdm.c
sound/soc/mediatek/mt8192/mt8192-reg.h
sound/soc/qcom/lpass-cpu.c
sound/soc/qcom/sdm845.c
sound/soc/soc-core.c
sound/soc/sof/intel/hda-dsp.c
sound/soc/sof/intel/hda.c
sound/sparc/amd7930.c
sound/sparc/cs4231.c
sound/sparc/dbri.c
sound/usb/6fire/chip.c
sound/usb/caiaq/device.c
sound/usb/card.c
sound/usb/hiface/chip.c
sound/usb/misc/ua101.c
sound/usb/mixer_quirks.c
sound/usb/quirks.c
sound/usb/usbaudio.h
sound/usb/usx2y/usbusx2y.c
sound/x86/intel_hdmi_audio.c
sound/xen/xen_snd_front.c
tools/arch/s390/include/uapi/asm/ptrace.h
tools/arch/x86/include/asm/cpufeatures.h
tools/arch/x86/include/uapi/asm/kvm.h
tools/arch/x86/include/uapi/asm/vmx.h
tools/bpf/resolve_btfids/main.c
tools/build/Makefile
tools/include/linux/coresight-pmu.h
tools/include/uapi/drm/drm.h
tools/include/uapi/drm/i915_drm.h
tools/include/uapi/linux/bpf.h
tools/include/uapi/linux/kvm.h
tools/include/uapi/linux/mount.h
tools/include/uapi/linux/openat2.h
tools/lib/bpf/xsk.c
tools/lib/perf/evlist.c
tools/lib/perf/include/internal/evlist.h
tools/objtool/check.c
tools/perf/Documentation/perf-evlist.txt
tools/perf/Documentation/perf-ftrace.txt
tools/perf/Documentation/perf-kallsyms.txt
tools/perf/Documentation/perf-trace.txt
tools/perf/Makefile.perf
tools/perf/arch/arm/util/cs-etm.c
tools/perf/arch/powerpc/entry/syscalls/syscall.tbl
tools/perf/arch/s390/entry/syscalls/syscall.tbl
tools/perf/arch/x86/Makefile
tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
tools/perf/arch/x86/include/arch-tests.h
tools/perf/arch/x86/tests/Build
tools/perf/arch/x86/tests/arch-tests.c
tools/perf/arch/x86/tests/insn-x86.c
tools/perf/arch/x86/tests/sample-parsing.c [new file with mode: 0644]
tools/perf/arch/x86/util/archinsn.c
tools/perf/bench/numa.c
tools/perf/bench/sched-messaging.c
tools/perf/bench/sched-pipe.c
tools/perf/bench/syscall.c
tools/perf/builtin-daemon.c
tools/perf/builtin-diff.c
tools/perf/builtin-trace.c
tools/perf/perf-archive.sh
tools/perf/tests/attr.c
tools/perf/tests/code-reading.c
tools/perf/tests/cpumap.c
tools/perf/tests/keep-tracking.c
tools/perf/tests/mmap-basic.c
tools/perf/tests/perf-time-to-tsc.c
tools/perf/tests/sample-parsing.c
tools/perf/tests/shell/daemon.sh
tools/perf/tests/sw-clock.c
tools/perf/tests/switch-tracking.c
tools/perf/tests/task-exit.c
tools/perf/tests/thread-map.c
tools/perf/util/evlist.c
tools/perf/util/evsel.c
tools/perf/util/evsel.h
tools/perf/util/header.c
tools/perf/util/map.c
tools/perf/util/parse-events.y
tools/perf/util/python-ext-sources
tools/perf/util/sort.c
tools/perf/util/stat-display.c
tools/perf/util/stat.c
tools/perf/util/trace-event-read.c
tools/testing/selftests/arm64/fp/sve-ptrace.c
tools/testing/selftests/bpf/progs/netif_receive_skb.c
tools/testing/selftests/bpf/progs/test_global_func11.c
tools/testing/selftests/bpf/progs/test_tunnel_kern.c
tools/testing/selftests/bpf/verifier/array_access.c
tools/testing/selftests/bpf/verifier/atomic_and.c
tools/testing/selftests/bpf/verifier/atomic_cmpxchg.c
tools/testing/selftests/bpf/verifier/atomic_or.c
tools/testing/selftests/gpio/.gitignore
tools/testing/selftests/kvm/.gitignore
tools/testing/selftests/kvm/Makefile
tools/testing/selftests/kvm/include/kvm_util.h
tools/testing/selftests/kvm/lib/kvm_util.c
tools/testing/selftests/kvm/lib/kvm_util_internal.h
tools/testing/selftests/kvm/x86_64/get_msr_index_features.c [new file with mode: 0644]
tools/testing/selftests/kvm/x86_64/hyperv_clock.c [new file with mode: 0644]
tools/testing/selftests/kvm/x86_64/set_boot_cpu_id.c [new file with mode: 0644]
tools/testing/selftests/net/fib_nexthops.sh
tools/testing/selftests/net/forwarding/mirror_gre_bridge_1d_vlan.sh
tools/testing/selftests/net/ipsec.c
tools/testing/selftests/netfilter/Makefile
tools/testing/selftests/netfilter/nf_nat_edemux.sh [new file with mode: 0755]

index ea0cc8c42093fdf86edc48e7cdd9f00362079359..f704925f6fe93b2a89a48fff0d48c3d9ee672d86 100644 (file)
@@ -33,7 +33,7 @@ Contact:      xfs@oss.sgi.com
 Description:
                The current state of the log write grant head. It
                represents the total log reservation of all currently
-               oustanding transactions, including regrants due to
+               outstanding transactions, including regrants due to
                rolling transactions. The grant head is exported in
                "cycle:bytes" format.
 Users:         xfstests
index 0a046be8d1cdae5fd7689c7d6d8c2796c7e215fd..0358a7739c8e273b6ab8e95bb9b410df6aff2380 100644 (file)
@@ -23,6 +23,7 @@ properties:
           - enum:
               - ingenic,jz4775-intc
               - ingenic,jz4770-intc
+              - ingenic,jz4760b-intc
           - const: ingenic,jz4760-intc
       - items:
           - const: ingenic,x1000-intc
index 50449b6d10484f3e723909cb8cde9323f078b7ef..4454aca34d56d23fec27bfe8c733b36a3b5ef53b 100644 (file)
@@ -21,6 +21,10 @@ properties:
       - fsl,vf610-spdif
       - fsl,imx6sx-spdif
       - fsl,imx8qm-spdif
+      - fsl,imx8qxp-spdif
+      - fsl,imx8mq-spdif
+      - fsl,imx8mm-spdif
+      - fsl,imx8mn-spdif
 
   reg:
     maxItems: 1
index 40ccac61137e27f936128d037e1fe4c52dc721fd..22ce801e3a8d94ca0db6e21289a0c475df7437d5 100644 (file)
@@ -613,6 +613,27 @@ Some of these date from the very introduction of KMS in 2008 ...
 
 Level: Intermediate
 
+Remove automatic page mapping from dma-buf importing
+----------------------------------------------------
+
+When importing dma-bufs, the dma-buf and PRIME frameworks automatically map
+imported pages into the importer's DMA area. drm_gem_prime_fd_to_handle() and
+drm_gem_prime_handle_to_fd() require that importers call dma_buf_attach()
+even if they never do actual device DMA, but only CPU access through
+dma_buf_vmap(). This is a problem for USB devices, which do not support DMA
+operations.
+
+To fix the issue, automatic page mappings should be removed from the
+buffer-sharing code. Fixing this is a bit more involved, since the import/export
+cache is also tied to &drm_gem_object.import_attach. Meanwhile we paper over
+this problem for USB devices by fishing out the USB host controller device, as
+long as that supports DMA. Otherwise importing can still needlessly fail.
+
+Contact: Thomas Zimmermann <tzimmermann@suse.de>, Daniel Vetter
+
+Level: Advanced
+
+
 Better Testing
 ==============
 
index 5f690f0ad0e4f136b29da05e4475af0830eabf4f..62f2aab8eaec0b65a7c4be0178241a74562bd93f 100644 (file)
@@ -1988,7 +1988,7 @@ netif_carrier.
 If use_carrier is 0, then the MII monitor will first query the
 device's (via ioctl) MII registers and check the link state.  If that
 request fails (not just that it returns carrier down), then the MII
-monitor will make an ethtool ETHOOL_GLINK request to attempt to obtain
+monitor will make an ethtool ETHTOOL_GLINK request to attempt to obtain
 the same information.  If both methods fail (i.e., the driver either
 does not support or had some error in processing both the MII register
 and ethtool requests), then the MII monitor will assume the link is
index a64c01b52b4c55286632a05b1578c4b6b833d8be..91b2cf7128012826ea3cddf526b8aafbd7955abf 100644 (file)
@@ -142,73 +142,13 @@ Please send incremental versions on top of what has been merged in order to fix
 the patches the way they would look like if your latest patch series was to be
 merged.
 
-How can I tell what patches are queued up for backporting to the various stable releases?
------------------------------------------------------------------------------------------
-Normally Greg Kroah-Hartman collects stable commits himself, but for
-networking, Dave collects up patches he deems critical for the
-networking subsystem, and then hands them off to Greg.
-
-There is a patchworks queue that you can see here:
-
-  https://patchwork.kernel.org/bundle/netdev/stable/?state=*
-
-It contains the patches which Dave has selected, but not yet handed off
-to Greg.  If Greg already has the patch, then it will be here:
-
-  https://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git
-
-A quick way to find whether the patch is in this stable-queue is to
-simply clone the repo, and then git grep the mainline commit ID, e.g.
-::
-
-  stable-queue$ git grep -l 284041ef21fdf2e
-  releases/3.0.84/ipv6-fix-possible-crashes-in-ip6_cork_release.patch
-  releases/3.4.51/ipv6-fix-possible-crashes-in-ip6_cork_release.patch
-  releases/3.9.8/ipv6-fix-possible-crashes-in-ip6_cork_release.patch
-  stable/stable-queue$
-
-I see a network patch and I think it should be backported to stable. Should I request it via stable@vger.kernel.org like the references in the kernel's Documentation/process/stable-kernel-rules.rst file say?
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-No, not for networking.  Check the stable queues as per above first
-to see if it is already queued.  If not, then send a mail to netdev,
-listing the upstream commit ID and why you think it should be a stable
-candidate.
-
-Before you jump to go do the above, do note that the normal stable rules
-in :ref:`Documentation/process/stable-kernel-rules.rst <stable_kernel_rules>`
-still apply.  So you need to explicitly indicate why it is a critical
-fix and exactly what users are impacted.  In addition, you need to
-convince yourself that you *really* think it has been overlooked,
-vs. having been considered and rejected.
-
-Generally speaking, the longer it has had a chance to "soak" in
-mainline, the better the odds that it is an OK candidate for stable.  So
-scrambling to request a commit be added the day after it appears should
-be avoided.
-
-I have created a network patch and I think it should be backported to stable. Should I add a Cc: stable@vger.kernel.org like the references in the kernel's Documentation/ directory say?
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-No.  See above answer.  In short, if you think it really belongs in
-stable, then ensure you write a decent commit log that describes who
-gets impacted by the bug fix and how it manifests itself, and when the
-bug was introduced.  If you do that properly, then the commit will get
-handled appropriately and most likely get put in the patchworks stable
-queue if it really warrants it.
-
-If you think there is some valid information relating to it being in
-stable that does *not* belong in the commit log, then use the three dash
-marker line as described in
-:ref:`Documentation/process/submitting-patches.rst <the_canonical_patch_format>`
-to temporarily embed that information into the patch that you send.
-
-Are all networking bug fixes backported to all stable releases?
+Are there special rules regarding stable submissions on netdev?
 ---------------------------------------------------------------
-Due to capacity, Dave could only take care of the backports for the
-last two stable releases. For earlier stable releases, each stable
-branch maintainer is supposed to take care of them. If you find any
-patch is missing from an earlier stable branch, please notify
-stable@vger.kernel.org with either a commit ID or a formal patch
-backported, and CC Dave and other relevant networking developers.
+While it used to be the case that netdev submissions were not supposed
+to carry explicit ``CC: stable@vger.kernel.org`` tags that is no longer
+the case today. Please follow the standard stable rules in
+:ref:`Documentation/process/stable-kernel-rules.rst <stable_kernel_rules>`,
+and make sure you include appropriate Fixes tags!
 
 Is the comment style convention different for the networking content?
 ---------------------------------------------------------------------
index 3973556250e17050a32309edd7b225554c81e394..003c865e9c212342ecac53c42eddd6848077de4f 100644 (file)
@@ -35,12 +35,6 @@ Rules on what kind of patches are accepted, and which ones are not, into the
 Procedure for submitting patches to the -stable tree
 ----------------------------------------------------
 
- - If the patch covers files in net/ or drivers/net please follow netdev stable
-   submission guidelines as described in
-   :ref:`Documentation/networking/netdev-FAQ.rst <netdev-FAQ>`
-   after first checking the stable networking queue at
-   https://patchwork.kernel.org/bundle/netdev/stable/?state=*
-   to ensure the requested patch is not already queued up.
  - Security patches should not be handled (solely) by the -stable review
    process but should follow the procedures in
    :ref:`Documentation/admin-guide/security-bugs.rst <securitybugs>`.
index 8c991c8636280e47fc80be27f08479b3e13f5b56..91de63b201c126ed19551cb2a35c9c29f9d55fe4 100644 (file)
@@ -250,11 +250,6 @@ should also read
 :ref:`Documentation/process/stable-kernel-rules.rst <stable_kernel_rules>`
 in addition to this file.
 
-Note, however, that some subsystem maintainers want to come to their own
-conclusions on which patches should go to the stable trees.  The networking
-maintainer, in particular, would rather not see individual developers
-adding lines like the above to their patches.
-
 If changes affect userland-kernel interfaces, please send the MAN-PAGES
 maintainer (as listed in the MAINTAINERS file) a man-pages patch, or at
 least a notification of the change, so that some information makes its way
index 1a2b5210cdbf58508c047a5b64d908a3da0e1d99..307f2fcf1b021239c505eed0f066bc69a1b983c3 100644 (file)
@@ -182,6 +182,9 @@ is dependent on the CPU capability and the kernel configuration. The limit can
 be retrieved using KVM_CAP_ARM_VM_IPA_SIZE of the KVM_CHECK_EXTENSION
 ioctl() at run-time.
 
+Creation of the VM will fail if the requested IPA size (whether it is
+implicit or explicit) is unsupported on the host.
+
 Please note that configuring the IPA size does not affect the capability
 exposed by the guest CPUs in ID_AA64MMFR0_EL1[PARange]. It only affects
 size of the address translated by the stage2 level (guest physical to
@@ -1492,7 +1495,8 @@ Fails if any VCPU has already been created.
 
 Define which vcpu is the Bootstrap Processor (BSP).  Values are the same
 as the vcpu id in KVM_CREATE_VCPU.  If this ioctl is not called, the default
-is vcpu 0.
+is vcpu 0. This ioctl has to be called before vcpu creation,
+otherwise it will return EBUSY error.
 
 
 4.42 KVM_GET_XSAVE
@@ -4803,8 +4807,10 @@ If an MSR access is not permitted through the filtering, it generates a
 allows user space to deflect and potentially handle various MSR accesses
 into user space.
 
-If a vCPU is in running state while this ioctl is invoked, the vCPU may
-experience inconsistent filtering behavior on MSR accesses.
+Note, invoking this ioctl with a vCPU is running is inherently racy.  However,
+KVM does guarantee that vCPUs will see either the previous filter or the new
+filter, e.g. MSRs with identical settings in both the old and new filter will
+have deterministic behavior.
 
 4.127 KVM_XEN_HVM_SET_ATTR
 --------------------------
index 9a9bf18bba005cf20149d2176b9fd2e7c52f44a7..00272c2f5393f28725a7d049139846c4552238b3 100644 (file)
@@ -261,8 +261,8 @@ ABI/API
 L:     linux-api@vger.kernel.org
 F:     include/linux/syscalls.h
 F:     kernel/sys_ni.c
-F:     include/uapi/
-F:     arch/*/include/uapi/
+X:     include/uapi/
+X:     arch/*/include/uapi/
 
 ABIT UGURU 1,2 HARDWARE MONITOR DRIVER
 M:     Hans de Goede <hdegoede@redhat.com>
@@ -1180,7 +1180,7 @@ M:        Joel Fernandes <joel@joelfernandes.org>
 M:     Christian Brauner <christian@brauner.io>
 M:     Hridya Valsaraju <hridya@google.com>
 M:     Suren Baghdasaryan <surenb@google.com>
-L:     devel@driverdev.osuosl.org
+L:     linux-kernel@vger.kernel.org
 S:     Supported
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
 F:     drivers/android/
@@ -5834,7 +5834,7 @@ M:        David Airlie <airlied@linux.ie>
 M:     Daniel Vetter <daniel@ffwll.ch>
 L:     dri-devel@lists.freedesktop.org
 S:     Maintained
-B:     https://bugs.freedesktop.org/
+B:     https://gitlab.freedesktop.org/drm
 C:     irc://chat.freenode.net/dri-devel
 T:     git git://anongit.freedesktop.org/drm/drm
 F:     Documentation/devicetree/bindings/display/
@@ -7384,14 +7384,6 @@ F:       Documentation/hwmon/gsc-hwmon.rst
 F:     drivers/hwmon/gsc-hwmon.c
 F:     include/linux/platform_data/gsc_hwmon.h
 
-GASKET DRIVER FRAMEWORK
-M:     Rob Springer <rspringer@google.com>
-M:     Todd Poynor <toddpoynor@google.com>
-M:     Ben Chan <benchan@chromium.org>
-M:     Richard Yeh <rcy@google.com>
-S:     Maintained
-F:     drivers/staging/gasket/
-
 GCC PLUGINS
 M:     Kees Cook <keescook@chromium.org>
 L:     linux-hardening@vger.kernel.org
@@ -8115,7 +8107,6 @@ F:        drivers/crypto/hisilicon/sec2/sec_main.c
 
 HISILICON STAGING DRIVERS FOR HIKEY 960/970
 M:     Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-L:     devel@driverdev.osuosl.org
 S:     Maintained
 F:     drivers/staging/hikey9xx/
 
@@ -10727,7 +10718,8 @@ F:      drivers/net/ethernet/marvell/mvpp2/
 
 MARVELL MWIFIEX WIRELESS DRIVER
 M:     Amitkumar Karwar <amitkarwar@gmail.com>
-M:     Ganapathi Bhat <ganapathi.bhat@nxp.com>
+M:     Ganapathi Bhat <ganapathi017@gmail.com>
+M:     Sharvari Harisangam <sharvari.harisangam@nxp.com>
 M:     Xinming Hu <huxinming820@gmail.com>
 L:     linux-wireless@vger.kernel.org
 S:     Maintained
@@ -17050,7 +17042,7 @@ F:      drivers/staging/vt665?/
 
 STAGING SUBSYSTEM
 M:     Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-L:     devel@driverdev.osuosl.org
+L:     linux-staging@lists.linux.dev
 S:     Supported
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
 F:     drivers/staging/
@@ -19152,7 +19144,7 @@ VME SUBSYSTEM
 M:     Martyn Welch <martyn@welchs.me.uk>
 M:     Manohar Vanga <manohar.vanga@gmail.com>
 M:     Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-L:     devel@driverdev.osuosl.org
+L:     linux-kernel@vger.kernel.org
 S:     Maintained
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
 F:     Documentation/driver-api/vme.rst
@@ -19183,7 +19175,7 @@ S:      Maintained
 F:     drivers/infiniband/hw/vmw_pvrdma/
 
 VMware PVSCSI driver
-M:     Jim Gill <jgill@vmware.com>
+M:     Vishal Bhakta <vbhakta@vmware.com>
 M:     VMware PV-Drivers <pv-drivers@vmware.com>
 L:     linux-scsi@vger.kernel.org
 S:     Maintained
index 31dcdb3d61fa5a32514ef3281efb4524439f9e07..d4784d18112313f04e0ca4243478658824dec761 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
 VERSION = 5
 PATCHLEVEL = 12
 SUBLEVEL = 0
-EXTRAVERSION = -rc2
+EXTRAVERSION = -rc4
 NAME = Frozen Wasteland
 
 # *DOCUMENTATION*
@@ -264,7 +264,8 @@ no-dot-config-targets := $(clean-targets) \
                         $(version_h) headers headers_% archheaders archscripts \
                         %asm-generic kernelversion %src-pkg dt_binding_check \
                         outputmakefile
-no-sync-config-targets := $(no-dot-config-targets) %install kernelrelease
+no-sync-config-targets := $(no-dot-config-targets) %install kernelrelease \
+                         image_name
 single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/
 
 config-build   :=
@@ -478,6 +479,7 @@ USERINCLUDE    := \
                -I$(objtree)/arch/$(SRCARCH)/include/generated/uapi \
                -I$(srctree)/include/uapi \
                -I$(objtree)/include/generated/uapi \
+                -include $(srctree)/include/linux/compiler-version.h \
                 -include $(srctree)/include/linux/kconfig.h
 
 # Use LINUXINCLUDE when you must reference the include/ directory.
index 2bb30673d8e6fbd5e7c3d41e8fe0800020c0f779..ecfd3520b676b014ee9d1dbddd181b4fd37e73bb 100644 (file)
@@ -632,13 +632,12 @@ config HAS_LTO_CLANG
        def_bool y
        # Clang >= 11: https://github.com/ClangBuiltLinux/linux/issues/510
        depends on CC_IS_CLANG && CLANG_VERSION >= 110000 && LD_IS_LLD
-       depends on $(success,test $(LLVM) -eq 1)
        depends on $(success,test $(LLVM_IAS) -eq 1)
        depends on $(success,$(NM) --help | head -n 1 | grep -qi llvm)
        depends on $(success,$(AR) --help | head -n 1 | grep -qi llvm)
        depends on ARCH_SUPPORTS_LTO_CLANG
        depends on !FTRACE_MCOUNT_USE_RECORDMCOUNT
-       depends on !KASAN
+       depends on !KASAN || KASAN_HW_TAGS
        depends on !GCOV_KERNEL
        help
          The compiler and Kconfig options support building with Clang's
index 853aab5ab327a430c250d4d77552e1d99ebe6071..5da96f5df48f356b39e40dc8e5b8bf1b84d72e76 100644 (file)
@@ -348,6 +348,7 @@ config ARCH_EP93XX
        select ARM_AMBA
        imply ARM_PATCH_PHYS_VIRT
        select ARM_VIC
+       select GENERIC_IRQ_MULTI_HANDLER
        select AUTO_ZRELADDR
        select CLKDEV_LOOKUP
        select CLKSRC_MMIO
index acb464547a54f45d90a05437517ce14e5448f21a..84a1cea1f43b9a3331b35093e4c57cb78d670815 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <xen/xen.h>
 #include <xen/interface/memory.h>
+#include <xen/grant_table.h>
 #include <xen/page.h>
 #include <xen/swiotlb-xen.h>
 
@@ -109,7 +110,7 @@ int set_foreign_p2m_mapping(struct gnttab_map_grant_ref *map_ops,
                map_ops[i].status = GNTST_general_error;
                unmap.host_addr = map_ops[i].host_addr,
                unmap.handle = map_ops[i].handle;
-               map_ops[i].handle = ~0;
+               map_ops[i].handle = INVALID_GRANT_HANDLE;
                if (map_ops[i].flags & GNTMAP_device_map)
                        unmap.dev_bus_addr = map_ops[i].dev_bus_addr;
                else
@@ -130,7 +131,6 @@ int set_foreign_p2m_mapping(struct gnttab_map_grant_ref *map_ops,
 
        return 0;
 }
-EXPORT_SYMBOL_GPL(set_foreign_p2m_mapping);
 
 int clear_foreign_p2m_mapping(struct gnttab_unmap_grant_ref *unmap_ops,
                              struct gnttab_unmap_grant_ref *kunmap_ops,
@@ -145,7 +145,6 @@ int clear_foreign_p2m_mapping(struct gnttab_unmap_grant_ref *unmap_ops,
 
        return 0;
 }
-EXPORT_SYMBOL_GPL(clear_foreign_p2m_mapping);
 
 bool __set_phys_to_machine_multi(unsigned long pfn,
                unsigned long mfn, unsigned long nr_pages)
index 1f212b47a48a1033d1799c946f0bb0b9dca96fd2..5656e7aacd698436c8b8046d9d01280ea02fda3e 100644 (file)
@@ -1055,8 +1055,6 @@ config HW_PERF_EVENTS
 config SYS_SUPPORTS_HUGETLBFS
        def_bool y
 
-config ARCH_WANT_HUGE_PMD_SHARE
-
 config ARCH_HAS_CACHE_LINE_SIZE
        def_bool y
 
@@ -1157,8 +1155,8 @@ config XEN
 
 config FORCE_MAX_ZONEORDER
        int
-       default "14" if (ARM64_64K_PAGES && TRANSPARENT_HUGEPAGE)
-       default "12" if (ARM64_16K_PAGES && TRANSPARENT_HUGEPAGE)
+       default "14" if ARM64_64K_PAGES
+       default "12" if ARM64_16K_PAGES
        default "11"
        help
          The kernel memory allocator divides physically contiguous memory
@@ -1855,12 +1853,6 @@ config CMDLINE_FROM_BOOTLOADER
          the boot loader doesn't provide any, the default kernel command
          string provided in CMDLINE will be used.
 
-config CMDLINE_EXTEND
-       bool "Extend bootloader kernel arguments"
-       help
-         The command-line arguments provided by the boot loader will be
-         appended to the default kernel command string.
-
 config CMDLINE_FORCE
        bool "Always use the default kernel command string"
        help
index 22d933e9b59e524cdef76eeb7fa98f69e0211a90..a7ab84f781f73d96006ff1cd4b66bffc97aa31bd 100644 (file)
 #define __KVM_HOST_SMCCC_FUNC___kvm_flush_vm_context           2
 #define __KVM_HOST_SMCCC_FUNC___kvm_tlb_flush_vmid_ipa         3
 #define __KVM_HOST_SMCCC_FUNC___kvm_tlb_flush_vmid             4
-#define __KVM_HOST_SMCCC_FUNC___kvm_tlb_flush_local_vmid       5
+#define __KVM_HOST_SMCCC_FUNC___kvm_flush_cpu_context          5
 #define __KVM_HOST_SMCCC_FUNC___kvm_timer_set_cntvoff          6
 #define __KVM_HOST_SMCCC_FUNC___kvm_enable_ssbs                        7
-#define __KVM_HOST_SMCCC_FUNC___vgic_v3_get_ich_vtr_el2                8
+#define __KVM_HOST_SMCCC_FUNC___vgic_v3_get_gic_config         8
 #define __KVM_HOST_SMCCC_FUNC___vgic_v3_read_vmcr              9
 #define __KVM_HOST_SMCCC_FUNC___vgic_v3_write_vmcr             10
 #define __KVM_HOST_SMCCC_FUNC___vgic_v3_init_lrs               11
@@ -183,16 +183,16 @@ DECLARE_KVM_HYP_SYM(__bp_harden_hyp_vecs);
 #define __bp_harden_hyp_vecs   CHOOSE_HYP_SYM(__bp_harden_hyp_vecs)
 
 extern void __kvm_flush_vm_context(void);
+extern void __kvm_flush_cpu_context(struct kvm_s2_mmu *mmu);
 extern void __kvm_tlb_flush_vmid_ipa(struct kvm_s2_mmu *mmu, phys_addr_t ipa,
                                     int level);
 extern void __kvm_tlb_flush_vmid(struct kvm_s2_mmu *mmu);
-extern void __kvm_tlb_flush_local_vmid(struct kvm_s2_mmu *mmu);
 
 extern void __kvm_timer_set_cntvoff(u64 cntvoff);
 
 extern int __kvm_vcpu_run(struct kvm_vcpu *vcpu);
 
-extern u64 __vgic_v3_get_ich_vtr_el2(void);
+extern u64 __vgic_v3_get_gic_config(void);
 extern u64 __vgic_v3_read_vmcr(void);
 extern void __vgic_v3_write_vmcr(u32 vmcr);
 extern void __vgic_v3_init_lrs(void);
index c0450828378b528280f4dcc2f472e5694fc462c2..32ae676236b6b4dc85d101be97976fecc3f2fcf8 100644 (file)
@@ -83,6 +83,11 @@ void sysreg_restore_guest_state_vhe(struct kvm_cpu_context *ctxt);
 void __debug_switch_to_guest(struct kvm_vcpu *vcpu);
 void __debug_switch_to_host(struct kvm_vcpu *vcpu);
 
+#ifdef __KVM_NVHE_HYPERVISOR__
+void __debug_save_host_buffers_nvhe(struct kvm_vcpu *vcpu);
+void __debug_restore_host_buffers_nvhe(struct kvm_vcpu *vcpu);
+#endif
+
 void __fpsimd_save_state(struct user_fpsimd_state *fp_regs);
 void __fpsimd_restore_state(struct user_fpsimd_state *fp_regs);
 
@@ -97,7 +102,8 @@ bool kvm_host_psci_handler(struct kvm_cpu_context *host_ctxt);
 
 void __noreturn hyp_panic(void);
 #ifdef __KVM_NVHE_HYPERVISOR__
-void __noreturn __hyp_do_panic(bool restore_host, u64 spsr, u64 elr, u64 par);
+void __noreturn __hyp_do_panic(struct kvm_cpu_context *host_ctxt, u64 spsr,
+                              u64 elr, u64 par);
 #endif
 
 #endif /* __ARM64_KVM_HYP_H__ */
index c759faf7a1ff9a59299e4aad27af246f4c228cec..0aabc3be9a75953fe02b48d535198cc9eed7f6bf 100644 (file)
@@ -328,6 +328,11 @@ static inline void *phys_to_virt(phys_addr_t x)
 #define ARCH_PFN_OFFSET                ((unsigned long)PHYS_PFN_OFFSET)
 
 #if !defined(CONFIG_SPARSEMEM_VMEMMAP) || defined(CONFIG_DEBUG_VIRTUAL)
+#define page_to_virt(x)        ({                                              \
+       __typeof__(x) __page = x;                                       \
+       void *__addr = __va(page_to_phys(__page));                      \
+       (void *)__tag_set((const void *)__addr, page_kasan_tag(__page));\
+})
 #define virt_to_page(x)                pfn_to_page(virt_to_pfn(x))
 #else
 #define page_to_virt(x)        ({                                              \
index 70ce8c1d2b078b0431d7e4ce519b386a1a5f3c0f..bd02e99b1a4c54972f871ebe4d0c81650b965abb 100644 (file)
@@ -63,23 +63,6 @@ static inline void cpu_switch_mm(pgd_t *pgd, struct mm_struct *mm)
 extern u64 idmap_t0sz;
 extern u64 idmap_ptrs_per_pgd;
 
-static inline bool __cpu_uses_extended_idmap(void)
-{
-       if (IS_ENABLED(CONFIG_ARM64_VA_BITS_52))
-               return false;
-
-       return unlikely(idmap_t0sz != TCR_T0SZ(VA_BITS));
-}
-
-/*
- * True if the extended ID map requires an extra level of translation table
- * to be configured.
- */
-static inline bool __cpu_uses_extended_idmap_level(void)
-{
-       return ARM64_HW_PGTABLE_LEVELS(64 - idmap_t0sz) > CONFIG_PGTABLE_LEVELS;
-}
-
 /*
  * Ensure TCR.T0SZ is set to the provided value.
  */
index 046be789fbb479967067cbc13e55693701f394fd..9a65fb5281100a7e08b29ee380c91b84cd887ca6 100644 (file)
@@ -66,7 +66,6 @@ extern bool arm64_use_ng_mappings;
 #define _PAGE_DEFAULT          (_PROT_DEFAULT | PTE_ATTRINDX(MT_NORMAL))
 
 #define PAGE_KERNEL            __pgprot(PROT_NORMAL)
-#define PAGE_KERNEL_TAGGED     __pgprot(PROT_NORMAL_TAGGED)
 #define PAGE_KERNEL_RO         __pgprot((PROT_NORMAL & ~PTE_WRITE) | PTE_RDONLY)
 #define PAGE_KERNEL_ROX                __pgprot((PROT_NORMAL & ~(PTE_WRITE | PTE_PXN)) | PTE_RDONLY)
 #define PAGE_KERNEL_EXEC       __pgprot(PROT_NORMAL & ~PTE_PXN)
index e17b96d0e4b59845f293cb3f3a050b90fc596520..47027796c2f934a0207013044dcaee2f9e58078c 100644 (file)
@@ -486,6 +486,9 @@ static inline pmd_t pmd_mkdevmap(pmd_t pmd)
        __pgprot_modify(prot, PTE_ATTRINDX_MASK, PTE_ATTRINDX(MT_NORMAL_NC) | PTE_PXN | PTE_UXN)
 #define pgprot_device(prot) \
        __pgprot_modify(prot, PTE_ATTRINDX_MASK, PTE_ATTRINDX(MT_DEVICE_nGnRE) | PTE_PXN | PTE_UXN)
+#define pgprot_tagged(prot) \
+       __pgprot_modify(prot, PTE_ATTRINDX_MASK, PTE_ATTRINDX(MT_NORMAL_TAGGED))
+#define pgprot_mhp     pgprot_tagged
 /*
  * DMA allocations for non-coherent devices use what the Arm architecture calls
  * "Normal non-cacheable" memory, which permits speculation, unaligned accesses
index dfd4edbfe36086df7c67bafe532929970c73dcb7..d4a5fca984c3e228594e19a80fa68bc37e43e16c 100644 (file)
 #define ID_AA64MMFR0_PARANGE_48                0x5
 #define ID_AA64MMFR0_PARANGE_52                0x6
 
+#define ID_AA64MMFR0_TGRAN_2_SUPPORTED_DEFAULT 0x0
+#define ID_AA64MMFR0_TGRAN_2_SUPPORTED_NONE    0x1
+#define ID_AA64MMFR0_TGRAN_2_SUPPORTED_MIN     0x2
+#define ID_AA64MMFR0_TGRAN_2_SUPPORTED_MAX     0x7
+
 #ifdef CONFIG_ARM64_PA_BITS_52
 #define ID_AA64MMFR0_PARANGE_MAX       ID_AA64MMFR0_PARANGE_52
 #else
 #define ID_PFR1_PROGMOD_SHIFT          0
 
 #if defined(CONFIG_ARM64_4K_PAGES)
-#define ID_AA64MMFR0_TGRAN_SHIFT       ID_AA64MMFR0_TGRAN4_SHIFT
-#define ID_AA64MMFR0_TGRAN_SUPPORTED   ID_AA64MMFR0_TGRAN4_SUPPORTED
+#define ID_AA64MMFR0_TGRAN_SHIFT               ID_AA64MMFR0_TGRAN4_SHIFT
+#define ID_AA64MMFR0_TGRAN_SUPPORTED_MIN       ID_AA64MMFR0_TGRAN4_SUPPORTED
+#define ID_AA64MMFR0_TGRAN_SUPPORTED_MAX       0x7
 #elif defined(CONFIG_ARM64_16K_PAGES)
-#define ID_AA64MMFR0_TGRAN_SHIFT       ID_AA64MMFR0_TGRAN16_SHIFT
-#define ID_AA64MMFR0_TGRAN_SUPPORTED   ID_AA64MMFR0_TGRAN16_SUPPORTED
+#define ID_AA64MMFR0_TGRAN_SHIFT               ID_AA64MMFR0_TGRAN16_SHIFT
+#define ID_AA64MMFR0_TGRAN_SUPPORTED_MIN       ID_AA64MMFR0_TGRAN16_SUPPORTED
+#define ID_AA64MMFR0_TGRAN_SUPPORTED_MAX       0xF
 #elif defined(CONFIG_ARM64_64K_PAGES)
-#define ID_AA64MMFR0_TGRAN_SHIFT       ID_AA64MMFR0_TGRAN64_SHIFT
-#define ID_AA64MMFR0_TGRAN_SUPPORTED   ID_AA64MMFR0_TGRAN64_SUPPORTED
+#define ID_AA64MMFR0_TGRAN_SHIFT               ID_AA64MMFR0_TGRAN64_SHIFT
+#define ID_AA64MMFR0_TGRAN_SUPPORTED_MIN       ID_AA64MMFR0_TGRAN64_SUPPORTED
+#define ID_AA64MMFR0_TGRAN_SUPPORTED_MAX       0x7
 #endif
 
 #define MVFR2_FPMISC_SHIFT             4
index 66b0e0b66e3122a9ba94a7ce648525b7f048bdca..840bda1869e9ccb0d88b2e6bb0cb63ea1eb1f0c6 100644 (file)
@@ -319,7 +319,7 @@ SYM_FUNC_START_LOCAL(__create_page_tables)
         */
        adrp    x5, __idmap_text_end
        clz     x5, x5
-       cmp     x5, TCR_T0SZ(VA_BITS)   // default T0SZ small enough?
+       cmp     x5, TCR_T0SZ(VA_BITS_MIN) // default T0SZ small enough?
        b.ge    1f                      // .. then skip VA range extension
 
        adr_l   x6, idmap_t0sz
@@ -655,8 +655,10 @@ SYM_FUNC_END(__secondary_too_slow)
 SYM_FUNC_START(__enable_mmu)
        mrs     x2, ID_AA64MMFR0_EL1
        ubfx    x2, x2, #ID_AA64MMFR0_TGRAN_SHIFT, 4
-       cmp     x2, #ID_AA64MMFR0_TGRAN_SUPPORTED
-       b.ne    __no_granule_support
+       cmp     x2, #ID_AA64MMFR0_TGRAN_SUPPORTED_MIN
+       b.lt    __no_granule_support
+       cmp     x2, #ID_AA64MMFR0_TGRAN_SUPPORTED_MAX
+       b.gt    __no_granule_support
        update_early_cpu_boot_status 0, x2, x3
        adrp    x2, idmap_pg_dir
        phys_to_ttbr x1, x1
index dffb16682330e657c6ce3d80f495c7bae48a8425..83f1c4b92095e9a6acf0c2eac454f965228bf040 100644 (file)
@@ -163,33 +163,36 @@ static __init void __parse_cmdline(const char *cmdline, bool parse_aliases)
        } while (1);
 }
 
-static __init void parse_cmdline(void)
+static __init const u8 *get_bootargs_cmdline(void)
 {
-       if (!IS_ENABLED(CONFIG_CMDLINE_FORCE)) {
-               const u8 *prop;
-               void *fdt;
-               int node;
+       const u8 *prop;
+       void *fdt;
+       int node;
 
-               fdt = get_early_fdt_ptr();
-               if (!fdt)
-                       goto out;
+       fdt = get_early_fdt_ptr();
+       if (!fdt)
+               return NULL;
 
-               node = fdt_path_offset(fdt, "/chosen");
-               if (node < 0)
-                       goto out;
+       node = fdt_path_offset(fdt, "/chosen");
+       if (node < 0)
+               return NULL;
 
-               prop = fdt_getprop(fdt, node, "bootargs", NULL);
-               if (!prop)
-                       goto out;
+       prop = fdt_getprop(fdt, node, "bootargs", NULL);
+       if (!prop)
+               return NULL;
 
-               __parse_cmdline(prop, true);
+       return strlen(prop) ? prop : NULL;
+}
 
-               if (!IS_ENABLED(CONFIG_CMDLINE_EXTEND))
-                       return;
-       }
+static __init void parse_cmdline(void)
+{
+       const u8 *prop = get_bootargs_cmdline();
 
-out:
-       __parse_cmdline(CONFIG_CMDLINE, true);
+       if (IS_ENABLED(CONFIG_CMDLINE_FORCE) || !prop)
+               __parse_cmdline(CONFIG_CMDLINE, true);
+
+       if (!IS_ENABLED(CONFIG_CMDLINE_FORCE) && prop)
+               __parse_cmdline(prop, true);
 }
 
 /* Keep checkers quiet */
index 23f1a557bd9f04fb61c90d2428fcc12ecca127ac..5aa9ed1e9ec6189af9beede0488e9e982044da0d 100644 (file)
@@ -101,6 +101,9 @@ KVM_NVHE_ALIAS(__stop___kvm_ex_table);
 /* Array containing bases of nVHE per-CPU memory regions. */
 KVM_NVHE_ALIAS(kvm_arm_hyp_percpu_base);
 
+/* PMU available static key */
+KVM_NVHE_ALIAS(kvm_arm_pmu_available);
+
 #endif /* CONFIG_KVM */
 
 #endif /* __ARM64_KERNEL_IMAGE_VARS_H */
index 7d2318f80955cc8ae7d9891edd0e5b06a3b6fe73..4658fcf88c2b4ddff069e3f47858c6443eac0198 100644 (file)
@@ -460,7 +460,7 @@ static inline int armv8pmu_counter_has_overflowed(u32 pmnc, int idx)
        return pmnc & BIT(ARMV8_IDX_TO_COUNTER(idx));
 }
 
-static inline u32 armv8pmu_read_evcntr(int idx)
+static inline u64 armv8pmu_read_evcntr(int idx)
 {
        u32 counter = ARMV8_IDX_TO_COUNTER(idx);
 
index fc4c95dd2d26172cf6ae4a9bd7d401bed5a7b6be..7f06ba76698d843d3b4696c98970865536013a48 100644 (file)
@@ -385,11 +385,16 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
        last_ran = this_cpu_ptr(mmu->last_vcpu_ran);
 
        /*
+        * We guarantee that both TLBs and I-cache are private to each
+        * vcpu. If detecting that a vcpu from the same VM has
+        * previously run on the same physical CPU, call into the
+        * hypervisor code to nuke the relevant contexts.
+        *
         * We might get preempted before the vCPU actually runs, but
         * over-invalidation doesn't affect correctness.
         */
        if (*last_ran != vcpu->vcpu_id) {
-               kvm_call_hyp(__kvm_tlb_flush_local_vmid, mmu);
+               kvm_call_hyp(__kvm_flush_cpu_context, mmu);
                *last_ran = vcpu->vcpu_id;
        }
 
index b0afad7a99c6e81c0f5f8bfb70cd9acfc67ff68c..e831d3dfd50d7cee211d915a7e39f9468ceff154 100644 (file)
@@ -85,8 +85,10 @@ SYM_INNER_LABEL(__guest_exit_panic, SYM_L_GLOBAL)
 
        // If the hyp context is loaded, go straight to hyp_panic
        get_loaded_vcpu x0, x1
-       cbz     x0, hyp_panic
+       cbnz    x0, 1f
+       b       hyp_panic
 
+1:
        // The hyp context is saved so make sure it is restored to allow
        // hyp_panic to run at hyp and, subsequently, panic to run in the host.
        // This makes use of __guest_exit to avoid duplication but sets the
@@ -94,7 +96,7 @@ SYM_INNER_LABEL(__guest_exit_panic, SYM_L_GLOBAL)
        // current state is saved to the guest context but it will only be
        // accurate if the guest had been completely restored.
        adr_this_cpu x0, kvm_hyp_ctxt, x1
-       adr     x1, hyp_panic
+       adr_l   x1, hyp_panic
        str     x1, [x0, #CPU_XREG_OFFSET(30)]
 
        get_vcpu_ptr    x1, x0
@@ -146,7 +148,7 @@ SYM_INNER_LABEL(__guest_exit, SYM_L_GLOBAL)
        // Now restore the hyp regs
        restore_callee_saved_regs x2
 
-       set_loaded_vcpu xzr, x1, x2
+       set_loaded_vcpu xzr, x2, x3
 
 alternative_if ARM64_HAS_RAS_EXTN
        // If we have the RAS extensions we can consume a pending error
index 54f4860cd87c06b1ed701eb3f2664176b6458806..6c1f51f25eb340154247b6381b6b482e1c76ccd4 100644 (file)
@@ -90,15 +90,18 @@ static inline void __activate_traps_common(struct kvm_vcpu *vcpu)
         * counter, which could make a PMXEVCNTR_EL0 access UNDEF at
         * EL1 instead of being trapped to EL2.
         */
-       write_sysreg(0, pmselr_el0);
-       write_sysreg(ARMV8_PMU_USERENR_MASK, pmuserenr_el0);
+       if (kvm_arm_support_pmu_v3()) {
+               write_sysreg(0, pmselr_el0);
+               write_sysreg(ARMV8_PMU_USERENR_MASK, pmuserenr_el0);
+       }
        write_sysreg(vcpu->arch.mdcr_el2, mdcr_el2);
 }
 
 static inline void __deactivate_traps_common(void)
 {
        write_sysreg(0, hstr_el2);
-       write_sysreg(0, pmuserenr_el0);
+       if (kvm_arm_support_pmu_v3())
+               write_sysreg(0, pmuserenr_el0);
 }
 
 static inline void ___activate_traps(struct kvm_vcpu *vcpu)
index 91a711aa8382e1dcb4811a77e55edafd8ea0af50..f401724f12ef754a184c861e08c2b4ad4a4935a0 100644 (file)
@@ -58,16 +58,24 @@ static void __debug_restore_spe(u64 pmscr_el1)
        write_sysreg_s(pmscr_el1, SYS_PMSCR_EL1);
 }
 
-void __debug_switch_to_guest(struct kvm_vcpu *vcpu)
+void __debug_save_host_buffers_nvhe(struct kvm_vcpu *vcpu)
 {
        /* Disable and flush SPE data generation */
        __debug_save_spe(&vcpu->arch.host_debug_state.pmscr_el1);
+}
+
+void __debug_switch_to_guest(struct kvm_vcpu *vcpu)
+{
        __debug_switch_to_guest_common(vcpu);
 }
 
-void __debug_switch_to_host(struct kvm_vcpu *vcpu)
+void __debug_restore_host_buffers_nvhe(struct kvm_vcpu *vcpu)
 {
        __debug_restore_spe(vcpu->arch.host_debug_state.pmscr_el1);
+}
+
+void __debug_switch_to_host(struct kvm_vcpu *vcpu)
+{
        __debug_switch_to_host_common(vcpu);
 }
 
index 6585a7cbbc566212fab4e9409c47a5b96643d708..5d94584840ccfe06b0e11945eeed5bbba7252f50 100644 (file)
@@ -71,7 +71,8 @@ SYM_FUNC_START(__host_enter)
 SYM_FUNC_END(__host_enter)
 
 /*
- * void __noreturn __hyp_do_panic(bool restore_host, u64 spsr, u64 elr, u64 par);
+ * void __noreturn __hyp_do_panic(struct kvm_cpu_context *host_ctxt, u64 spsr,
+ *                               u64 elr, u64 par);
  */
 SYM_FUNC_START(__hyp_do_panic)
        /* Prepare and exit to the host's panic funciton. */
@@ -82,9 +83,11 @@ SYM_FUNC_START(__hyp_do_panic)
        hyp_kimg_va lr, x6
        msr     elr_el2, lr
 
-       /* Set the panic format string. Use the, now free, LR as scratch. */
-       ldr     lr, =__hyp_panic_string
-       hyp_kimg_va lr, x6
+       mov     x29, x0
+
+       /* Load the format string into x0 and arguments into x1-7 */
+       ldr     x0, =__hyp_panic_string
+       hyp_kimg_va x0, x6
 
        /* Load the format arguments into x1-7. */
        mov     x6, x3
@@ -94,9 +97,7 @@ SYM_FUNC_START(__hyp_do_panic)
        mrs     x5, hpfar_el2
 
        /* Enter the host, conditionally restoring the host context. */
-       cmp     x0, xzr
-       mov     x0, lr
-       b.eq    __host_enter_without_restoring
+       cbz     x29, __host_enter_without_restoring
        b       __host_enter_for_panic
 SYM_FUNC_END(__hyp_do_panic)
 
index f012f8665ecc1c6a0510bf25705b738f5660a077..936328207bde02b9e868f3e19153d95aa1fcdfb8 100644 (file)
@@ -46,11 +46,11 @@ static void handle___kvm_tlb_flush_vmid(struct kvm_cpu_context *host_ctxt)
        __kvm_tlb_flush_vmid(kern_hyp_va(mmu));
 }
 
-static void handle___kvm_tlb_flush_local_vmid(struct kvm_cpu_context *host_ctxt)
+static void handle___kvm_flush_cpu_context(struct kvm_cpu_context *host_ctxt)
 {
        DECLARE_REG(struct kvm_s2_mmu *, mmu, host_ctxt, 1);
 
-       __kvm_tlb_flush_local_vmid(kern_hyp_va(mmu));
+       __kvm_flush_cpu_context(kern_hyp_va(mmu));
 }
 
 static void handle___kvm_timer_set_cntvoff(struct kvm_cpu_context *host_ctxt)
@@ -67,9 +67,9 @@ static void handle___kvm_enable_ssbs(struct kvm_cpu_context *host_ctxt)
        write_sysreg_el2(tmp, SYS_SCTLR);
 }
 
-static void handle___vgic_v3_get_ich_vtr_el2(struct kvm_cpu_context *host_ctxt)
+static void handle___vgic_v3_get_gic_config(struct kvm_cpu_context *host_ctxt)
 {
-       cpu_reg(host_ctxt, 1) = __vgic_v3_get_ich_vtr_el2();
+       cpu_reg(host_ctxt, 1) = __vgic_v3_get_gic_config();
 }
 
 static void handle___vgic_v3_read_vmcr(struct kvm_cpu_context *host_ctxt)
@@ -115,10 +115,10 @@ static const hcall_t host_hcall[] = {
        HANDLE_FUNC(__kvm_flush_vm_context),
        HANDLE_FUNC(__kvm_tlb_flush_vmid_ipa),
        HANDLE_FUNC(__kvm_tlb_flush_vmid),
-       HANDLE_FUNC(__kvm_tlb_flush_local_vmid),
+       HANDLE_FUNC(__kvm_flush_cpu_context),
        HANDLE_FUNC(__kvm_timer_set_cntvoff),
        HANDLE_FUNC(__kvm_enable_ssbs),
-       HANDLE_FUNC(__vgic_v3_get_ich_vtr_el2),
+       HANDLE_FUNC(__vgic_v3_get_gic_config),
        HANDLE_FUNC(__vgic_v3_read_vmcr),
        HANDLE_FUNC(__vgic_v3_write_vmcr),
        HANDLE_FUNC(__vgic_v3_init_lrs),
index f3d0e9eca56cd2a62de3f31a77926ee8c478390a..68ab6b4d5141401346bcf4247f05e159f0262a20 100644 (file)
@@ -192,6 +192,14 @@ int __kvm_vcpu_run(struct kvm_vcpu *vcpu)
        pmu_switch_needed = __pmu_switch_to_guest(host_ctxt);
 
        __sysreg_save_state_nvhe(host_ctxt);
+       /*
+        * We must flush and disable the SPE buffer for nVHE, as
+        * the translation regime(EL1&0) is going to be loaded with
+        * that of the guest. And we must do this before we change the
+        * translation regime to EL2 (via MDCR_EL2_E2PB == 0) and
+        * before we load guest Stage1.
+        */
+       __debug_save_host_buffers_nvhe(vcpu);
 
        __adjust_pc(vcpu);
 
@@ -234,11 +242,12 @@ int __kvm_vcpu_run(struct kvm_vcpu *vcpu)
        if (vcpu->arch.flags & KVM_ARM64_FP_ENABLED)
                __fpsimd_save_fpexc32(vcpu);
 
+       __debug_switch_to_host(vcpu);
        /*
         * This must come after restoring the host sysregs, since a non-VHE
         * system may enable SPE here and make use of the TTBRs.
         */
-       __debug_switch_to_host(vcpu);
+       __debug_restore_host_buffers_nvhe(vcpu);
 
        if (pmu_switch_needed)
                __pmu_switch_to_host(host_ctxt);
@@ -257,7 +266,6 @@ void __noreturn hyp_panic(void)
        u64 spsr = read_sysreg_el2(SYS_SPSR);
        u64 elr = read_sysreg_el2(SYS_ELR);
        u64 par = read_sysreg_par();
-       bool restore_host = true;
        struct kvm_cpu_context *host_ctxt;
        struct kvm_vcpu *vcpu;
 
@@ -271,7 +279,7 @@ void __noreturn hyp_panic(void)
                __sysreg_restore_state_nvhe(host_ctxt);
        }
 
-       __hyp_do_panic(restore_host, spsr, elr, par);
+       __hyp_do_panic(host_ctxt, spsr, elr, par);
        unreachable();
 }
 
index fbde89a2c6e838d0ad9cbcb9029130b789bf2360..229b06748c20849df4b85c6d656eea2f3403853d 100644 (file)
@@ -123,7 +123,7 @@ void __kvm_tlb_flush_vmid(struct kvm_s2_mmu *mmu)
        __tlb_switch_to_host(&cxt);
 }
 
-void __kvm_tlb_flush_local_vmid(struct kvm_s2_mmu *mmu)
+void __kvm_flush_cpu_context(struct kvm_s2_mmu *mmu)
 {
        struct tlb_inv_context cxt;
 
@@ -131,6 +131,7 @@ void __kvm_tlb_flush_local_vmid(struct kvm_s2_mmu *mmu)
        __tlb_switch_to_guest(mmu, &cxt);
 
        __tlbi(vmalle1);
+       asm volatile("ic iallu");
        dsb(nsh);
        isb();
 
index 4d177ce1d536f3d719887a3e69d08fc2dd3dec22..926fc07074f57b27294082cf2a274abe4c0bc983 100644 (file)
@@ -223,6 +223,7 @@ static inline int __kvm_pgtable_visit(struct kvm_pgtable_walk_data *data,
                goto out;
 
        if (!table) {
+               data->addr = ALIGN_DOWN(data->addr, kvm_granule_size(level));
                data->addr += kvm_granule_size(level);
                goto out;
        }
index 80406f463c28fdebad45a1c4d4b09cf3e1bf8144..ee3682b9873c44f00c3a2c965987289610caf5d5 100644 (file)
@@ -405,9 +405,45 @@ void __vgic_v3_init_lrs(void)
                __gic_v3_set_lr(0, i);
 }
 
-u64 __vgic_v3_get_ich_vtr_el2(void)
+/*
+ * Return the GIC CPU configuration:
+ * - [31:0]  ICH_VTR_EL2
+ * - [62:32] RES0
+ * - [63]    MMIO (GICv2) capable
+ */
+u64 __vgic_v3_get_gic_config(void)
 {
-       return read_gicreg(ICH_VTR_EL2);
+       u64 val, sre = read_gicreg(ICC_SRE_EL1);
+       unsigned long flags = 0;
+
+       /*
+        * To check whether we have a MMIO-based (GICv2 compatible)
+        * CPU interface, we need to disable the system register
+        * view. To do that safely, we have to prevent any interrupt
+        * from firing (which would be deadly).
+        *
+        * Note that this only makes sense on VHE, as interrupts are
+        * already masked for nVHE as part of the exception entry to
+        * EL2.
+        */
+       if (has_vhe())
+               flags = local_daif_save();
+
+       write_gicreg(0, ICC_SRE_EL1);
+       isb();
+
+       val = read_gicreg(ICC_SRE_EL1);
+
+       write_gicreg(sre, ICC_SRE_EL1);
+       isb();
+
+       if (has_vhe())
+               local_daif_restore(flags);
+
+       val  = (val & ICC_SRE_EL1_SRE) ? 0 : (1ULL << 63);
+       val |= read_gicreg(ICH_VTR_EL2);
+
+       return val;
 }
 
 u64 __vgic_v3_read_vmcr(void)
index fd7895945bbc6f22b5c687220781a177e7af709a..66f17349f0c36923266b60ca03318e4729d7b1f7 100644 (file)
@@ -127,7 +127,7 @@ void __kvm_tlb_flush_vmid(struct kvm_s2_mmu *mmu)
        __tlb_switch_to_host(&cxt);
 }
 
-void __kvm_tlb_flush_local_vmid(struct kvm_s2_mmu *mmu)
+void __kvm_flush_cpu_context(struct kvm_s2_mmu *mmu)
 {
        struct tlb_inv_context cxt;
 
@@ -135,6 +135,7 @@ void __kvm_tlb_flush_local_vmid(struct kvm_s2_mmu *mmu)
        __tlb_switch_to_guest(mmu, &cxt);
 
        __tlbi(vmalle1);
+       asm volatile("ic iallu");
        dsb(nsh);
        isb();
 
index 77cb2d28f2a43a96dd0114ef7d10f2fa60a48b96..8711894db8c2248e3b9953d6550ec81230e490da 100644 (file)
@@ -1312,8 +1312,7 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,
         * Prevent userspace from creating a memory region outside of the IPA
         * space addressable by the KVM guest IPA space.
         */
-       if (memslot->base_gfn + memslot->npages >=
-           (kvm_phys_size(kvm) >> PAGE_SHIFT))
+       if ((memslot->base_gfn + memslot->npages) > (kvm_phys_size(kvm) >> PAGE_SHIFT))
                return -EFAULT;
 
        mmap_read_lock(current->mm);
index d45b8b9a44151810e1ac9e4ba77c41b7053c6375..739164324afedb9dc54b87c131761abff6d7b72f 100644 (file)
@@ -11,6 +11,8 @@
 
 #include <asm/kvm_emulate.h>
 
+DEFINE_STATIC_KEY_FALSE(kvm_arm_pmu_available);
+
 static int kvm_is_in_guest(void)
 {
         return kvm_get_running_vcpu() != NULL;
@@ -48,6 +50,14 @@ static struct perf_guest_info_callbacks kvm_guest_cbs = {
 
 int kvm_perf_init(void)
 {
+       /*
+        * Check if HW_PERF_EVENTS are supported by checking the number of
+        * hardware performance counters. This could ensure the presence of
+        * a physical PMU and CONFIG_PERF_EVENT is selected.
+        */
+       if (IS_ENABLED(CONFIG_ARM_PMU) && perf_num_counters() > 0)
+               static_branch_enable(&kvm_arm_pmu_available);
+
        return perf_register_guest_info_callbacks(&kvm_guest_cbs);
 }
 
index e9ec08b0b070337d476ec0d00a28d62efa0af89e..e32c6e139a09d39f2d904f1aca8c2648ab097238 100644 (file)
@@ -823,16 +823,6 @@ u64 kvm_pmu_get_pmceid(struct kvm_vcpu *vcpu, bool pmceid1)
        return val & mask;
 }
 
-bool kvm_arm_support_pmu_v3(void)
-{
-       /*
-        * Check if HW_PERF_EVENTS are supported by checking the number of
-        * hardware performance counters. This could ensure the presence of
-        * a physical PMU and CONFIG_PERF_EVENT is selected.
-        */
-       return (perf_num_counters() > 0);
-}
-
 int kvm_arm_pmu_v3_enable(struct kvm_vcpu *vcpu)
 {
        if (!kvm_vcpu_has_pmu(vcpu))
index 47f3f035f3eac5aaf9b4d590e25ebbff7eb8dd95..bd354cd45d2860e4595109c3375395f716f6c911 100644 (file)
@@ -311,23 +311,24 @@ int kvm_set_ipa_limit(void)
        }
 
        switch (cpuid_feature_extract_unsigned_field(mmfr0, tgran_2)) {
-       default:
-       case 1:
+       case ID_AA64MMFR0_TGRAN_2_SUPPORTED_NONE:
                kvm_err("PAGE_SIZE not supported at Stage-2, giving up\n");
                return -EINVAL;
-       case 0:
+       case ID_AA64MMFR0_TGRAN_2_SUPPORTED_DEFAULT:
                kvm_debug("PAGE_SIZE supported at Stage-2 (default)\n");
                break;
-       case 2:
+       case ID_AA64MMFR0_TGRAN_2_SUPPORTED_MIN ... ID_AA64MMFR0_TGRAN_2_SUPPORTED_MAX:
                kvm_debug("PAGE_SIZE supported at Stage-2 (advertised)\n");
                break;
+       default:
+               kvm_err("Unsupported value for TGRAN_2, giving up\n");
+               return -EINVAL;
        }
 
        kvm_ipa_limit = id_aa64mmfr0_parange_to_phys_shift(parange);
-       WARN(kvm_ipa_limit < KVM_PHYS_SHIFT,
-            "KVM IPA Size Limit (%d bits) is smaller than default size\n",
-            kvm_ipa_limit);
-       kvm_info("IPA Size Limit: %d bits\n", kvm_ipa_limit);
+       kvm_info("IPA Size Limit: %d bits%s\n", kvm_ipa_limit,
+                ((kvm_ipa_limit < KVM_PHYS_SHIFT) ?
+                 " (Reduced IPA size, limited VM/VMM compatibility)" : ""));
 
        return 0;
 }
@@ -356,6 +357,11 @@ int kvm_arm_setup_stage2(struct kvm *kvm, unsigned long type)
                        return -EINVAL;
        } else {
                phys_shift = KVM_PHYS_SHIFT;
+               if (phys_shift > kvm_ipa_limit) {
+                       pr_warn_once("%s using unsupported default IPA limit, upgrade your VMM\n",
+                                    current->comm);
+                       return -EINVAL;
+               }
        }
 
        mmfr0 = read_sanitised_ftr_reg(SYS_ID_AA64MMFR0_EL1);
index 52915b34235143a3248ec2f958f9a6dc7c486f2c..6f530925a23144dca5159f579e709da1119fcac0 100644 (file)
@@ -574,9 +574,13 @@ early_param("kvm-arm.vgic_v4_enable", early_gicv4_enable);
  */
 int vgic_v3_probe(const struct gic_kvm_info *info)
 {
-       u32 ich_vtr_el2 = kvm_call_hyp_ret(__vgic_v3_get_ich_vtr_el2);
+       u64 ich_vtr_el2 = kvm_call_hyp_ret(__vgic_v3_get_gic_config);
+       bool has_v2;
        int ret;
 
+       has_v2 = ich_vtr_el2 >> 63;
+       ich_vtr_el2 = (u32)ich_vtr_el2;
+
        /*
         * The ListRegs field is 5 bits, but there is an architectural
         * maximum of 16 list registers. Just ignore bit 4...
@@ -594,13 +598,15 @@ int vgic_v3_probe(const struct gic_kvm_info *info)
                         gicv4_enable ? "en" : "dis");
        }
 
+       kvm_vgic_global_state.vcpu_base = 0;
+
        if (!info->vcpu.start) {
                kvm_info("GICv3: no GICV resource entry\n");
-               kvm_vgic_global_state.vcpu_base = 0;
+       } else if (!has_v2) {
+               pr_warn(FW_BUG "CPU interface incapable of MMIO access\n");
        } else if (!PAGE_ALIGNED(info->vcpu.start)) {
                pr_warn("GICV physical address 0x%llx not page aligned\n",
                        (unsigned long long)info->vcpu.start);
-               kvm_vgic_global_state.vcpu_base = 0;
        } else {
                kvm_vgic_global_state.vcpu_base = info->vcpu.start;
                kvm_vgic_global_state.can_emulate_gicv2 = true;
index 0ace5e68efba0ea05b32c989ac6ae987364fc89c..3685e12aba9b62b170cbd285dae412c339cae350 100644 (file)
@@ -219,17 +219,40 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max)
 
 int pfn_valid(unsigned long pfn)
 {
-       phys_addr_t addr = pfn << PAGE_SHIFT;
+       phys_addr_t addr = PFN_PHYS(pfn);
 
-       if ((addr >> PAGE_SHIFT) != pfn)
+       /*
+        * Ensure the upper PAGE_SHIFT bits are clear in the
+        * pfn. Else it might lead to false positives when
+        * some of the upper bits are set, but the lower bits
+        * match a valid pfn.
+        */
+       if (PHYS_PFN(addr) != pfn)
                return 0;
 
 #ifdef CONFIG_SPARSEMEM
+{
+       struct mem_section *ms;
+
        if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS)
                return 0;
 
-       if (!valid_section(__pfn_to_section(pfn)))
+       ms = __pfn_to_section(pfn);
+       if (!valid_section(ms))
                return 0;
+
+       /*
+        * ZONE_DEVICE memory does not have the memblock entries.
+        * memblock_is_map_memory() check for ZONE_DEVICE based
+        * addresses will always fail. Even the normal hotplugged
+        * memory will never have MEMBLOCK_NOMAP flag set in their
+        * memblock entries. Skip memblock search for all non early
+        * memory sections covering all of hotplug memory including
+        * both normal and ZONE_DEVICE based.
+        */
+       if (!early_section(ms))
+               return pfn_section_valid(ms, pfn);
+}
 #endif
        return memblock_is_map_memory(addr);
 }
index 3802cfbdd20d12e93388cb8f5f2029eafdc9f60f..7484ea4f6ba07300a25a4c0689309f9332e9913a 100644 (file)
@@ -40,7 +40,7 @@
 #define NO_BLOCK_MAPPINGS      BIT(0)
 #define NO_CONT_MAPPINGS       BIT(1)
 
-u64 idmap_t0sz = TCR_T0SZ(VA_BITS);
+u64 idmap_t0sz = TCR_T0SZ(VA_BITS_MIN);
 u64 idmap_ptrs_per_pgd = PTRS_PER_PGD;
 
 u64 __section(".mmuoff.data.write") vabits_actual;
@@ -512,7 +512,8 @@ static void __init map_mem(pgd_t *pgdp)
                 * if MTE is present. Otherwise, it has the same attributes as
                 * PAGE_KERNEL.
                 */
-               __map_memblock(pgdp, start, end, PAGE_KERNEL_TAGGED, flags);
+               __map_memblock(pgdp, start, end, pgprot_tagged(PAGE_KERNEL),
+                              flags);
        }
 
        /*
index ae2b1c7b3b5cb0209d45872def3c4905e079f710..ef2bb9bd9605fc2203d4c21aa24ba4771d16b24c 100644 (file)
@@ -9,7 +9,7 @@ int arch_check_ftrace_location(struct kprobe *p)
        return 0;
 }
 
-/* Ftrace callback handler for kprobes -- called under preepmt disabed */
+/* Ftrace callback handler for kprobes -- called under preepmt disabled */
 void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
                           struct ftrace_ops *ops, struct ftrace_regs *fregs)
 {
index 6c6f16e409a877722269841162a4c7e8bc68b7eb..0d23c00493018951e6d8e691fcc7016a80d4c447 100644 (file)
@@ -32,7 +32,7 @@ static inline void syscall_rollback(struct task_struct *task,
 static inline long syscall_get_error(struct task_struct *task,
                                     struct pt_regs *regs)
 {
-       return regs->r10 == -1 ? regs->r8:0;
+       return regs->r10 == -1 ? -regs->r8:0;
 }
 
 static inline long syscall_get_return_value(struct task_struct *task,
index c3490ee2daa58642a9b83eeb9daefc6e942962c3..e14f5653393ac865ffd0f144352befec2f932c74 100644 (file)
@@ -2013,27 +2013,39 @@ static void syscall_get_set_args_cb(struct unw_frame_info *info, void *data)
 {
        struct syscall_get_set_args *args = data;
        struct pt_regs *pt = args->regs;
-       unsigned long *krbs, cfm, ndirty;
+       unsigned long *krbs, cfm, ndirty, nlocals, nouts;
        int i, count;
 
        if (unw_unwind_to_user(info) < 0)
                return;
 
+       /*
+        * We get here via a few paths:
+        * - break instruction: cfm is shared with caller.
+        *   syscall args are in out= regs, locals are non-empty.
+        * - epsinstruction: cfm is set by br.call
+        *   locals don't exist.
+        *
+        * For both cases argguments are reachable in cfm.sof - cfm.sol.
+        * CFM: [ ... | sor: 17..14 | sol : 13..7 | sof : 6..0 ]
+        */
        cfm = pt->cr_ifs;
+       nlocals = (cfm >> 7) & 0x7f; /* aka sol */
+       nouts = (cfm & 0x7f) - nlocals; /* aka sof - sol */
        krbs = (unsigned long *)info->task + IA64_RBS_OFFSET/8;
        ndirty = ia64_rse_num_regs(krbs, krbs + (pt->loadrs >> 19));
 
        count = 0;
        if (in_syscall(pt))
-               count = min_t(int, args->n, cfm & 0x7f);
+               count = min_t(int, args->n, nouts);
 
+       /* Iterate over outs. */
        for (i = 0; i < count; i++) {
+               int j = ndirty + nlocals + i + args->i;
                if (args->rw)
-                       *ia64_rse_skip_regs(krbs, ndirty + i + args->i) =
-                               args->args[i];
+                       *ia64_rse_skip_regs(krbs, j) = args->args[i];
                else
-                       args->args[i] = *ia64_rse_skip_regs(krbs,
-                               ndirty + i + args->i);
+                       args->args[i] = *ia64_rse_skip_regs(krbs, j);
        }
 
        if (!args->rw) {
index 7f5912af2a52ea0a033ca4155d8604d2fc53df51..9e8f0cc30a2ccb9d2459228f1fef4ae28d4ca0ff 100644 (file)
@@ -171,7 +171,7 @@ static inline __attribute_const__ int __virt_to_node_shift(void)
 #include <asm-generic/memory_model.h>
 #endif
 
-#define virt_addr_valid(kaddr) ((void *)(kaddr) >= (void *)PAGE_OFFSET && (void *)(kaddr) < high_memory)
+#define virt_addr_valid(kaddr) ((unsigned long)(kaddr) >= PAGE_OFFSET && (unsigned long)(kaddr) < (unsigned long)high_memory)
 #define pfn_valid(pfn)         virt_addr_valid(pfn_to_virt(pfn))
 
 #endif /* __ASSEMBLY__ */
index 6bbe52025de3c5c68518371a7d41e23003b6ece1..8d0f862ee9d7953236fc315f840e5c98db21d36c 100644 (file)
@@ -30,8 +30,8 @@ extern unsigned long memory_end;
 #define page_to_pfn(page)      virt_to_pfn(page_to_virt(page))
 #define pfn_valid(pfn)         ((pfn) < max_mapnr)
 
-#define        virt_addr_valid(kaddr)  (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
-                               ((void *)(kaddr) < (void *)memory_end))
+#define        virt_addr_valid(kaddr)  (((unsigned long)(kaddr) >= PAGE_OFFSET) && \
+                               ((unsigned long)(kaddr) < memory_end))
 
 #endif /* __ASSEMBLY__ */
 
index e3946b06e840a6b2e6c5a297e81f16db50a4c914..3d70d15ada286cbb8928befdcf966e1723c380f8 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <asm/addrspace.h>
 #include <asm/unaligned.h>
+#include <asm-generic/vmlinux.lds.h>
 
 /*
  * These two variables specify the free mem region
@@ -120,6 +121,13 @@ void decompress_kernel(unsigned long boot_heap_start)
                /* last four bytes is always image size in little endian */
                image_size = get_unaligned_le32((void *)&__image_end - 4);
 
+               /* The device tree's address must be properly aligned  */
+               image_size = ALIGN(image_size, STRUCT_ALIGNMENT);
+
+               puts("Copy device tree to address  ");
+               puthex(VMLINUX_LOAD_ADDRESS_ULL + image_size);
+               puts("\n");
+
                /* copy dtb to where the booted kernel will expect it */
                memcpy((void *)VMLINUX_LOAD_ADDRESS_ULL + image_size,
                       __appended_dtb, dtb_size);
index 8e1deaf00e0c0b7722ba48b5b9bf1d9582b03298..5e4105cccf9fa9dde2b3f495b89156e3700c04de 100644 (file)
@@ -12,8 +12,8 @@ AFLAGS_chacha-core.o += -O2 # needed to fill branch delay slots
 obj-$(CONFIG_CRYPTO_POLY1305_MIPS) += poly1305-mips.o
 poly1305-mips-y := poly1305-core.o poly1305-glue.o
 
-perlasm-flavour-$(CONFIG_CPU_MIPS32) := o32
-perlasm-flavour-$(CONFIG_CPU_MIPS64) := 64
+perlasm-flavour-$(CONFIG_32BIT) := o32
+perlasm-flavour-$(CONFIG_64BIT) := 64
 
 quiet_cmd_perlasm = PERLASM $@
       cmd_perlasm = $(PERL) $(<) $(perlasm-flavour-y) $(@)
index 6aa8f126a43d89b3e71747a4ce3a295c798025c4..b710e76c9c658f7baaef01601cef79277020d7ef 100644 (file)
@@ -24,8 +24,11 @@ extern void (*board_ebase_setup)(void);
 extern void (*board_cache_error_setup)(void);
 
 extern int register_nmi_notifier(struct notifier_block *nb);
+extern void reserve_exception_space(phys_addr_t addr, unsigned long size);
 extern char except_vec_nmi[];
 
+#define VECTORSPACING 0x100    /* for EI/VI mode */
+
 #define nmi_notifier(fn, pri)                                          \
 ({                                                                     \
        static struct notifier_block fn##_nb = {                        \
index 9a89637b4ecfa8331a496f89c653ba1d1fcd6d68..b71892064f2733cfad153c4834e89f29517cb231 100644 (file)
@@ -26,6 +26,7 @@
 #include <asm/elf.h>
 #include <asm/pgtable-bits.h>
 #include <asm/spram.h>
+#include <asm/traps.h>
 #include <linux/uaccess.h>
 
 #include "fpu-probe.h"
@@ -1628,6 +1629,7 @@ static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
                c->cputype = CPU_BMIPS3300;
                __cpu_name[cpu] = "Broadcom BMIPS3300";
                set_elf_platform(cpu, "bmips3300");
+               reserve_exception_space(0x400, VECTORSPACING * 64);
                break;
        case PRID_IMP_BMIPS43XX: {
                int rev = c->processor_id & PRID_REV_MASK;
@@ -1638,6 +1640,7 @@ static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
                        __cpu_name[cpu] = "Broadcom BMIPS4380";
                        set_elf_platform(cpu, "bmips4380");
                        c->options |= MIPS_CPU_RIXI;
+                       reserve_exception_space(0x400, VECTORSPACING * 64);
                } else {
                        c->cputype = CPU_BMIPS4350;
                        __cpu_name[cpu] = "Broadcom BMIPS4350";
@@ -1654,6 +1657,7 @@ static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
                        __cpu_name[cpu] = "Broadcom BMIPS5000";
                set_elf_platform(cpu, "bmips5000");
                c->options |= MIPS_CPU_ULRI | MIPS_CPU_RIXI;
+               reserve_exception_space(0x1000, VECTORSPACING * 64);
                break;
        }
 }
@@ -2133,6 +2137,8 @@ void cpu_probe(void)
        if (cpu == 0)
                __ua_limit = ~((1ull << cpu_vmbits) - 1);
 #endif
+
+       reserve_exception_space(0, 0x1000);
 }
 
 void cpu_report(void)
index abdbbe8c5a43a98b3c41474f33f3a240aba668aa..af654771918cdd0873b5046310c5a0fc77253075 100644 (file)
@@ -21,6 +21,7 @@
 #include <asm/fpu.h>
 #include <asm/mipsregs.h>
 #include <asm/elf.h>
+#include <asm/traps.h>
 
 #include "fpu-probe.h"
 
@@ -158,6 +159,8 @@ void cpu_probe(void)
                cpu_set_fpu_opts(c);
        else
                cpu_set_nofpu_opts(c);
+
+       reserve_exception_space(0, 0x400);
 }
 
 void cpu_report(void)
index e0352958e2f720be5b9bd407e208f249716f7cad..808b8b61ded155195f57d6b21140beaaa30fc746 100644 (file)
@@ -2009,13 +2009,16 @@ void __noreturn nmi_exception_handler(struct pt_regs *regs)
        nmi_exit();
 }
 
-#define VECTORSPACING 0x100    /* for EI/VI mode */
-
 unsigned long ebase;
 EXPORT_SYMBOL_GPL(ebase);
 unsigned long exception_handlers[32];
 unsigned long vi_handlers[64];
 
+void reserve_exception_space(phys_addr_t addr, unsigned long size)
+{
+       memblock_reserve(addr, size);
+}
+
 void __init *set_except_vector(int n, void *addr)
 {
        unsigned long handler = (unsigned long) addr;
@@ -2367,10 +2370,7 @@ void __init trap_init(void)
 
        if (!cpu_has_mips_r2_r6) {
                ebase = CAC_BASE;
-               ebase_pa = virt_to_phys((void *)ebase);
                vec_size = 0x400;
-
-               memblock_reserve(ebase_pa, vec_size);
        } else {
                if (cpu_has_veic || cpu_has_vint)
                        vec_size = 0x200 + VECTORSPACING*64;
index c1c345be04ffd5c08e47ab0c474341c57c1eb225..1f98947fe715daca0f6a68b11e1ecd1a3d7647a8 100644 (file)
@@ -145,6 +145,7 @@ SECTIONS
        }
 
 #ifdef CONFIG_MIPS_ELF_APPENDED_DTB
+       STRUCT_ALIGN();
        .appended_dtb : AT(ADDR(.appended_dtb) - LOAD_OFFSET) {
                *(.appended_dtb)
                KEEP(*(.appended_dtb))
@@ -172,6 +173,11 @@ SECTIONS
 #endif
 
 #ifdef CONFIG_MIPS_RAW_APPENDED_DTB
+       .fill : {
+               FILL(0);
+               BYTE(0);
+               STRUCT_ALIGN();
+       }
        __appended_dtb = .;
        /* leave space for appended DTB */
        . += 0x100000;
index 4e53ac46e857e5d9485ce8fcd2d011eea5cd0dae..afc3b8d03572684d649e7fe82ef88839c0e0714e 100644 (file)
@@ -203,9 +203,12 @@ config PREFETCH
        def_bool y
        depends on PA8X00 || PA7200
 
+config PARISC_HUGE_KERNEL
+       def_bool y if !MODULES || UBSAN || FTRACE || COMPILE_TEST
+
 config MLONGCALLS
-       def_bool y if !MODULES || UBSAN || FTRACE
-       bool "Enable the -mlong-calls compiler option for big kernels" if MODULES && !UBSAN && !FTRACE
+       def_bool y if PARISC_HUGE_KERNEL
+       bool "Enable the -mlong-calls compiler option for big kernels" if !PARISC_HUGE_KERNEL
        depends on PA8X00
        help
          If you configure the kernel to include many drivers built-in instead
index 2127974982df9a029b9c8819a257debb30bb5f0c..65de6c4c9354d6754091435943146acc8a726483 100644 (file)
@@ -567,8 +567,6 @@ static const struct user_regset_view user_parisc_native_view = {
 };
 
 #ifdef CONFIG_64BIT
-#include <linux/compat.h>
-
 static int gpr32_get(struct task_struct *target,
                     const struct user_regset *regset,
                     struct membuf to)
index eacc9102c2515cdc3eaab8d7447a4971c6282df0..f1d029bf906e59b52506624eb77539d90d652726 100644 (file)
@@ -73,9 +73,10 @@ void __patch_exception(int exc, unsigned long addr);
 #endif
 
 #define OP_RT_RA_MASK  0xffff0000UL
-#define LIS_R2         0x3c020000UL
-#define ADDIS_R2_R12   0x3c4c0000UL
-#define ADDI_R2_R2     0x38420000UL
+#define LIS_R2         (PPC_INST_ADDIS | __PPC_RT(R2))
+#define ADDIS_R2_R12   (PPC_INST_ADDIS | __PPC_RT(R2) | __PPC_RA(R12))
+#define ADDI_R2_R2     (PPC_INST_ADDI  | __PPC_RT(R2) | __PPC_RA(R2))
+
 
 static inline unsigned long ppc_function_entry(void *func)
 {
index 7897d16e09904c4ebbd63bbf85ae3cd7d1e24d7e..727d4b32193799ecdc3bbd7c6befb679f02e5d9f 100644 (file)
@@ -7,7 +7,7 @@
 #include <linux/bug.h>
 #include <asm/cputable.h>
 
-static inline bool early_cpu_has_feature(unsigned long feature)
+static __always_inline bool early_cpu_has_feature(unsigned long feature)
 {
        return !!((CPU_FTRS_ALWAYS & feature) ||
                  (CPU_FTRS_POSSIBLE & cur_cpu_spec->cpu_features & feature));
@@ -46,7 +46,7 @@ static __always_inline bool cpu_has_feature(unsigned long feature)
        return static_branch_likely(&cpu_feature_keys[i]);
 }
 #else
-static inline bool cpu_has_feature(unsigned long feature)
+static __always_inline bool cpu_has_feature(unsigned long feature)
 {
        return early_cpu_has_feature(feature);
 }
index 7141ccea8c94e6b2ba571607999a0384ce60a7bd..a92059964579b877334e683177593588b7144429 100644 (file)
@@ -53,8 +53,8 @@ static inline void mtdcrx(unsigned int reg, unsigned int val)
 #define mfdcr(rn)                                              \
        ({unsigned int rval;                                    \
        if (__builtin_constant_p(rn) && rn < 1024)              \
-               asm volatile("mfdcr %0," __stringify(rn)        \
-                             : "=r" (rval));                   \
+               asm volatile("mfdcr %0, %1" : "=r" (rval)       \
+                             : "n" (rn));                      \
        else if (likely(cpu_has_feature(CPU_FTR_INDEXED_DCR)))  \
                rval = mfdcrx(rn);                              \
        else                                                    \
@@ -64,8 +64,8 @@ static inline void mtdcrx(unsigned int reg, unsigned int val)
 #define mtdcr(rn, v)                                           \
 do {                                                           \
        if (__builtin_constant_p(rn) && rn < 1024)              \
-               asm volatile("mtdcr " __stringify(rn) ",%0"     \
-                             : : "r" (v));                     \
+               asm volatile("mtdcr %0, %1"                     \
+                             : : "n" (rn), "r" (v));           \
        else if (likely(cpu_has_feature(CPU_FTR_INDEXED_DCR)))  \
                mtdcrx(rn, v);                                  \
        else                                                    \
index aedfba29e43a5e0a39b52fa406eabf4dcda82e2e..e8d09a841373b708c729e6ea4d4d63cf62654b48 100644 (file)
@@ -410,7 +410,6 @@ DECLARE_INTERRUPT_HANDLER(altivec_assist_exception);
 DECLARE_INTERRUPT_HANDLER(CacheLockingException);
 DECLARE_INTERRUPT_HANDLER(SPEFloatingPointException);
 DECLARE_INTERRUPT_HANDLER(SPEFloatingPointRoundException);
-DECLARE_INTERRUPT_HANDLER(unrecoverable_exception);
 DECLARE_INTERRUPT_HANDLER(WatchdogException);
 DECLARE_INTERRUPT_HANDLER(kernel_bad_stack);
 
@@ -437,6 +436,8 @@ DECLARE_INTERRUPT_HANDLER_NMI(hmi_exception_realmode);
 
 DECLARE_INTERRUPT_HANDLER_ASYNC(TAUException);
 
+void unrecoverable_exception(struct pt_regs *regs);
+
 void replay_system_reset(void);
 void replay_soft_interrupts(void);
 
index 80b27f5d96486227206c4503d388892821e569cd..607168b1aef46a936540a43601960ae6b17eb5bb 100644 (file)
@@ -228,7 +228,7 @@ enum {
 #define MMU_FTRS_ALWAYS                0
 #endif
 
-static inline bool early_mmu_has_feature(unsigned long feature)
+static __always_inline bool early_mmu_has_feature(unsigned long feature)
 {
        if (MMU_FTRS_ALWAYS & feature)
                return true;
@@ -286,7 +286,7 @@ static inline void mmu_feature_keys_init(void)
 
 }
 
-static inline bool mmu_has_feature(unsigned long feature)
+static __always_inline bool mmu_has_feature(unsigned long feature)
 {
        return early_mmu_has_feature(feature);
 }
index 975ba260006a46755670884e9f15363ac4683c30..1499e928ea6a62663b44d8116c2114a974e4b235 100644 (file)
@@ -195,7 +195,7 @@ static inline void regs_set_return_value(struct pt_regs *regs, unsigned long rc)
 #define TRAP_FLAGS_MASK                0x11
 #define TRAP(regs)             ((regs)->trap & ~TRAP_FLAGS_MASK)
 #define FULL_REGS(regs)                (((regs)->trap & 1) == 0)
-#define SET_FULL_REGS(regs)    ((regs)->trap |= 1)
+#define SET_FULL_REGS(regs)    ((regs)->trap &= ~1)
 #endif
 #define CHECK_FULL_REGS(regs)  BUG_ON(!FULL_REGS(regs))
 #define NV_REG_POISON          0xdeadbeefdeadbeefUL
@@ -210,7 +210,7 @@ static inline void regs_set_return_value(struct pt_regs *regs, unsigned long rc)
 #define TRAP_FLAGS_MASK                0x1F
 #define TRAP(regs)             ((regs)->trap & ~TRAP_FLAGS_MASK)
 #define FULL_REGS(regs)                (((regs)->trap & 1) == 0)
-#define SET_FULL_REGS(regs)    ((regs)->trap |= 1)
+#define SET_FULL_REGS(regs)    ((regs)->trap &= ~1)
 #define IS_CRITICAL_EXC(regs)  (((regs)->trap & 2) != 0)
 #define IS_MCHECK_EXC(regs)    (((regs)->trap & 4) != 0)
 #define IS_DEBUG_EXC(regs)     (((regs)->trap & 8) != 0)
index fdab934283721f3033304a646fe44636425765c1..9d1fbd8be1c74277ce69c3c095755659aa8a3340 100644 (file)
@@ -71,6 +71,16 @@ static inline void disable_kernel_vsx(void)
 {
        msr_check_and_clear(MSR_FP|MSR_VEC|MSR_VSX);
 }
+#else
+static inline void enable_kernel_vsx(void)
+{
+       BUILD_BUG();
+}
+
+static inline void disable_kernel_vsx(void)
+{
+       BUILD_BUG();
+}
 #endif
 
 #ifdef CONFIG_SPE
index 0cf52746531bedb28ae6b0b439ea483b3b06f3fa..721c0d6715ac8f7599740355b312d397adc28894 100644 (file)
@@ -113,7 +113,7 @@ struct vio_driver {
        const char *name;
        const struct vio_device_id *id_table;
        int (*probe)(struct vio_dev *dev, const struct vio_device_id *id);
-       int (*remove)(struct vio_dev *dev);
+       void (*remove)(struct vio_dev *dev);
        /* A driver must have a get_desired_dma() function to
         * be loaded in a CMO environment if it uses DMA.
         */
index 60d3051a8bc8ad3638d9d0696441311f08fd9e89..8082b690e87468b92b33238549ea50426560202c 100644 (file)
@@ -466,7 +466,7 @@ DEFINE_FIXED_SYMBOL(\name\()_common_real)
 
        ld      r10,PACAKMSR(r13)       /* get MSR value for kernel */
        /* MSR[RI] is clear iff using SRR regs */
-       .if IHSRR == EXC_HV_OR_STD
+       .if IHSRR_IF_HVMODE
        BEGIN_FTR_SECTION
        xori    r10,r10,MSR_RI
        END_FTR_SECTION_IFCLR(CPU_FTR_HVMODE)
index 727fdab557c9b70ab6c2dc350b8ba9b786da0adb..565e84e20a7214c5485fa143b33755e22ab0542a 100644 (file)
@@ -457,11 +457,12 @@ InstructionTLBMiss:
        cmplw   0,r1,r3
 #endif
        mfspr   r2, SPRN_SDR1
-       li      r1,_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_EXEC
+       li      r1,_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_EXEC | _PAGE_USER
        rlwinm  r2, r2, 28, 0xfffff000
 #ifdef CONFIG_MODULES
        bgt-    112f
        lis     r2, (swapper_pg_dir - PAGE_OFFSET)@ha   /* if kernel address, use */
+       li      r1,_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_EXEC
        addi    r2, r2, (swapper_pg_dir - PAGE_OFFSET)@l        /* kernel page table */
 #endif
 112:   rlwimi  r2,r3,12,20,29          /* insert top 10 bits of address */
@@ -520,10 +521,11 @@ DataLoadTLBMiss:
        lis     r1, TASK_SIZE@h         /* check if kernel address */
        cmplw   0,r1,r3
        mfspr   r2, SPRN_SDR1
-       li      r1, _PAGE_PRESENT | _PAGE_ACCESSED
+       li      r1, _PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_USER
        rlwinm  r2, r2, 28, 0xfffff000
        bgt-    112f
        lis     r2, (swapper_pg_dir - PAGE_OFFSET)@ha   /* if kernel address, use */
+       li      r1, _PAGE_PRESENT | _PAGE_ACCESSED
        addi    r2, r2, (swapper_pg_dir - PAGE_OFFSET)@l        /* kernel page table */
 112:   rlwimi  r2,r3,12,20,29          /* insert top 10 bits of address */
        lwz     r2,0(r2)                /* get pmd entry */
@@ -597,10 +599,11 @@ DataStoreTLBMiss:
        lis     r1, TASK_SIZE@h         /* check if kernel address */
        cmplw   0,r1,r3
        mfspr   r2, SPRN_SDR1
-       li      r1, _PAGE_RW | _PAGE_DIRTY | _PAGE_PRESENT | _PAGE_ACCESSED
+       li      r1, _PAGE_RW | _PAGE_DIRTY | _PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_USER
        rlwinm  r2, r2, 28, 0xfffff000
        bgt-    112f
        lis     r2, (swapper_pg_dir - PAGE_OFFSET)@ha   /* if kernel address, use */
+       li      r1, _PAGE_RW | _PAGE_DIRTY | _PAGE_PRESENT | _PAGE_ACCESSED
        addi    r2, r2, (swapper_pg_dir - PAGE_OFFSET)@l        /* kernel page table */
 112:   rlwimi  r2,r3,12,20,29          /* insert top 10 bits of address */
        lwz     r2,0(r2)                /* get pmd entry */
index 398cd86b6ada15514774666dbcfcebc7bd178a33..c475a229a42ac492298313b485684e8d541a4139 100644 (file)
@@ -149,7 +149,7 @@ notrace long system_call_exception(long r3, long r4, long r5,
  * enabled when the interrupt handler returns (indicating a process-context /
  * synchronous interrupt) then irqs_enabled should be true.
  */
-static notrace inline bool __prep_irq_for_enabled_exit(bool clear_ri)
+static notrace __always_inline bool __prep_irq_for_enabled_exit(bool clear_ri)
 {
        /* This must be done with RI=1 because tracing may touch vmaps */
        trace_hardirqs_on();
@@ -436,7 +436,6 @@ again:
        return ret;
 }
 
-void unrecoverable_exception(struct pt_regs *regs);
 void preempt_schedule_irq(void);
 
 notrace unsigned long interrupt_exit_kernel_prepare(struct pt_regs *regs, unsigned long msr)
index 1583fd1c60103c2d2a230fff481b8d81fa147260..a44a30b0688ca5957a8a1265ab23a0add1ebc13e 100644 (file)
@@ -2170,7 +2170,7 @@ DEFINE_INTERRUPT_HANDLER(SPEFloatingPointRoundException)
  * in the MSR is 0.  This indicates that SRR0/1 are live, and that
  * we therefore lost state by taking this exception.
  */
-DEFINE_INTERRUPT_HANDLER(unrecoverable_exception)
+void unrecoverable_exception(struct pt_regs *regs)
 {
        pr_emerg("Unrecoverable exception %lx at %lx (msr=%lx)\n",
                 regs->trap, regs->nip, regs->msr);
index a6e29f880e0e3d7c5c1b6c66f35c70de83e2e238..d21d08140a5eba1fa03abf691d431bfb3076cf66 100644 (file)
@@ -65,3 +65,14 @@ V_FUNCTION_END(__kernel_clock_getres)
 V_FUNCTION_BEGIN(__kernel_time)
        cvdso_call_time __c_kernel_time
 V_FUNCTION_END(__kernel_time)
+
+/* Routines for restoring integer registers, called by the compiler.  */
+/* Called with r11 pointing to the stack header word of the caller of the */
+/* function, just beyond the end of the integer restore area.  */
+_GLOBAL(_restgpr_31_x)
+_GLOBAL(_rest32gpr_31_x)
+       lwz     r0,4(r11)
+       lwz     r31,-4(r11)
+       mtlr    r0
+       mr      r1,r11
+       blr
index bb5c20d4ca91c2423869372306d3d12e95d576fe..c6aebc149d14129ca17a23a1d289bb8cde827131 100644 (file)
@@ -904,7 +904,7 @@ static nokprobe_inline int do_vsx_load(struct instruction_op *op,
        if (!address_ok(regs, ea, size) || copy_mem_in(mem, ea, size, regs))
                return -EFAULT;
 
-       nr_vsx_regs = size / sizeof(__vector128);
+       nr_vsx_regs = max(1ul, size / sizeof(__vector128));
        emulate_vsx_load(op, buf, mem, cross_endian);
        preempt_disable();
        if (reg < 32) {
@@ -951,7 +951,7 @@ static nokprobe_inline int do_vsx_store(struct instruction_op *op,
        if (!address_ok(regs, ea, size))
                return -EFAULT;
 
-       nr_vsx_regs = size / sizeof(__vector128);
+       nr_vsx_regs = max(1ul, size / sizeof(__vector128));
        preempt_disable();
        if (reg < 32) {
                /* FP regs + extensions */
index 6817331e22ffcbea822fa293fbe122c73e5fbd02..766f064f00fbf25322016546e2bd0c81fe3466eb 100644 (file)
@@ -222,7 +222,7 @@ static inline void perf_get_data_addr(struct perf_event *event, struct pt_regs *
        if (!(mmcra & MMCRA_SAMPLE_ENABLE) || sdar_valid)
                *addrp = mfspr(SPRN_SDAR);
 
-       if (is_kernel_addr(mfspr(SPRN_SDAR)) && perf_allow_kernel(&event->attr) != 0)
+       if (is_kernel_addr(mfspr(SPRN_SDAR)) && event->attr.exclude_kernel)
                *addrp = 0;
 }
 
@@ -507,7 +507,7 @@ static void power_pmu_bhrb_read(struct perf_event *event, struct cpu_hw_events *
                         * addresses, hence include a check before filtering code
                         */
                        if (!(ppmu->flags & PPMU_ARCH_31) &&
-                               is_kernel_addr(addr) && perf_allow_kernel(&event->attr) != 0)
+                           is_kernel_addr(addr) && event->attr.exclude_kernel)
                                continue;
 
                        /* Branches are read most recent first (ie. mfbhrb 0 is
index b3ac2455faadc51cdfcb45a251dc112d1df0a5d4..637300330507fe5a678a5f98d28c94ec5d8e8c77 100644 (file)
@@ -4,6 +4,7 @@
  * Copyright 2006-2007 Michael Ellerman, IBM Corp.
  */
 
+#include <linux/crash_dump.h>
 #include <linux/device.h>
 #include <linux/irq.h>
 #include <linux/msi.h>
@@ -458,8 +459,28 @@ again:
                        return hwirq;
                }
 
-               virq = irq_create_mapping_affinity(NULL, hwirq,
-                                                  entry->affinity);
+               /*
+                * Depending on the number of online CPUs in the original
+                * kernel, it is likely for CPU #0 to be offline in a kdump
+                * kernel. The associated IRQs in the affinity mappings
+                * provided by irq_create_affinity_masks() are thus not
+                * started by irq_startup(), as per-design for managed IRQs.
+                * This can be a problem with multi-queue block devices driven
+                * by blk-mq : such a non-started IRQ is very likely paired
+                * with the single queue enforced by blk-mq during kdump (see
+                * blk_mq_alloc_tag_set()). This causes the device to remain
+                * silent and likely hangs the guest at some point.
+                *
+                * We don't really care for fine-grained affinity when doing
+                * kdump actually : simply ignore the pre-computed affinity
+                * masks in this case and let the default mask with all CPUs
+                * be used when creating the IRQ mappings.
+                */
+               if (is_kdump_kernel())
+                       virq = irq_create_mapping(NULL, hwirq);
+               else
+                       virq = irq_create_mapping_affinity(NULL, hwirq,
+                                                          entry->affinity);
 
                if (!virq) {
                        pr_debug("rtas_msi: Failed mapping hwirq %d\n", hwirq);
index b2797cfe4e2b087535a23c13b2132f4e08324419..9cb4fc839fd5d89b3ec9426cfce7fe82742757d6 100644 (file)
@@ -1261,7 +1261,6 @@ static int vio_bus_remove(struct device *dev)
        struct vio_dev *viodev = to_vio_dev(dev);
        struct vio_driver *viodrv = to_vio_driver(dev->driver);
        struct device *devptr;
-       int ret = 1;
 
        /*
         * Hold a reference to the device after the remove function is called
@@ -1270,13 +1269,13 @@ static int vio_bus_remove(struct device *dev)
        devptr = get_device(dev);
 
        if (viodrv->remove)
-               ret = viodrv->remove(viodev);
+               viodrv->remove(viodev);
 
-       if (!ret && firmware_has_feature(FW_FEATURE_CMO))
+       if (firmware_has_feature(FW_FEATURE_CMO))
                vio_cmo_bus_remove(viodev);
 
        put_device(devptr);
-       return ret;
+       return 0;
 }
 
 /**
index 85d626b8ce5e07667bac85e76dd3c1a2eaaf9453..87d7b52f278f0c36df89414ac93f9cec9d25afbc 100644 (file)
@@ -93,7 +93,6 @@ config RISCV
        select PCI_MSI if PCI
        select RISCV_INTC
        select RISCV_TIMER if RISCV_SBI
-       select SPARSEMEM_STATIC if 32BIT
        select SPARSE_IRQ
        select SYSCTL_EXCEPTION_TRACE
        select THREAD_INFO_IN_TASK
@@ -154,7 +153,8 @@ config ARCH_FLATMEM_ENABLE
 config ARCH_SPARSEMEM_ENABLE
        def_bool y
        depends on MMU
-       select SPARSEMEM_VMEMMAP_ENABLE
+       select SPARSEMEM_STATIC if 32BIT && SPARSMEM
+       select SPARSEMEM_VMEMMAP_ENABLE if 64BIT
 
 config ARCH_SELECT_MEMORY_MODEL
        def_bool ARCH_SPARSEMEM_ENABLE
index 7efcece8896cfe7dd361f97b9850c1da9f4665cb..e1b2690b6e45d978730be6a9cf8aba2f76399ec9 100644 (file)
@@ -31,6 +31,8 @@ config SOC_CANAAN
        select SIFIVE_PLIC
        select ARCH_HAS_RESET_CONTROLLER
        select PINCTRL
+       select COMMON_CLK
+       select COMMON_CLK_K210
        help
          This enables support for Canaan Kendryte K210 SoC platform hardware.
 
index 27e005fca5849e059bc920d937250bdb251ff35c..2a652b0c987d59174719d5462857c87e137c8acf 100644 (file)
@@ -9,4 +9,20 @@ long long __lshrti3(long long a, int b);
 long long __ashrti3(long long a, int b);
 long long __ashlti3(long long a, int b);
 
+
+#define DECLARE_DO_ERROR_INFO(name)    asmlinkage void name(struct pt_regs *regs)
+
+DECLARE_DO_ERROR_INFO(do_trap_unknown);
+DECLARE_DO_ERROR_INFO(do_trap_insn_misaligned);
+DECLARE_DO_ERROR_INFO(do_trap_insn_fault);
+DECLARE_DO_ERROR_INFO(do_trap_insn_illegal);
+DECLARE_DO_ERROR_INFO(do_trap_load_fault);
+DECLARE_DO_ERROR_INFO(do_trap_load_misaligned);
+DECLARE_DO_ERROR_INFO(do_trap_store_misaligned);
+DECLARE_DO_ERROR_INFO(do_trap_store_fault);
+DECLARE_DO_ERROR_INFO(do_trap_ecall_u);
+DECLARE_DO_ERROR_INFO(do_trap_ecall_s);
+DECLARE_DO_ERROR_INFO(do_trap_ecall_m);
+DECLARE_DO_ERROR_INFO(do_trap_break);
+
 #endif /* _ASM_RISCV_PROTOTYPES_H */
index 9807ad164015e5a08d4d2e90e407f5fc78c87a7f..e4c435509983e544f73150ef4f6e7bd5a7267c85 100644 (file)
@@ -12,4 +12,6 @@
 
 #include <asm-generic/irq.h>
 
+extern void __init init_IRQ(void);
+
 #endif /* _ASM_RISCV_IRQ_H */
index 3a240037bde26e1c3a135f373d17805d0b471679..021ed64ee608f2c470d040f92d7403377f8cc10f 100644 (file)
@@ -71,6 +71,7 @@ int riscv_of_processor_hartid(struct device_node *node);
 int riscv_of_parent_hartid(struct device_node *node);
 
 extern void riscv_fill_hwcap(void);
+extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
 
 #endif /* __ASSEMBLY__ */
 
index cb4abb639e8d6876ca77b2d255e9875f1946945b..09ad4e923510a3d52a5fbf57b9ddacea82aa4be6 100644 (file)
@@ -119,6 +119,11 @@ extern int regs_query_register_offset(const char *name);
 extern unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs,
                                               unsigned int n);
 
+void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr,
+                          unsigned long frame_pointer);
+int do_syscall_trace_enter(struct pt_regs *regs);
+void do_syscall_trace_exit(struct pt_regs *regs);
+
 /**
  * regs_get_register() - get register value from its offset
  * @regs:      pt_regs from which register value is gotten
index 99895d9c3bddb06469b690b062cdb76631cb0547..d7027411dde838aca73bc876e91e0f3da2359d53 100644 (file)
@@ -51,10 +51,10 @@ enum sbi_ext_rfence_fid {
        SBI_EXT_RFENCE_REMOTE_FENCE_I = 0,
        SBI_EXT_RFENCE_REMOTE_SFENCE_VMA,
        SBI_EXT_RFENCE_REMOTE_SFENCE_VMA_ASID,
-       SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA,
        SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA_VMID,
-       SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA,
+       SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA,
        SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA_ASID,
+       SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA,
 };
 
 enum sbi_ext_hsm_fid {
index 81de51e6aa32b3e6690bad5bb7ed6ebe206029cd..507cae273bc62cec5ff052cc78a7b67e4854aa87 100644 (file)
@@ -88,4 +88,6 @@ static inline int read_current_timer(unsigned long *timer_val)
        return 0;
 }
 
+extern void time_init(void);
+
 #endif /* _ASM_RISCV_TIMEX_H */
index 3dc0abde988a27cb89f55b68d2e0d00207b346d7..647a47f5484a18274ac9696e6aa9ef29d14e55e9 100644 (file)
@@ -8,6 +8,7 @@ CFLAGS_REMOVE_ftrace.o  = $(CC_FLAGS_FTRACE)
 CFLAGS_REMOVE_patch.o  = $(CC_FLAGS_FTRACE)
 CFLAGS_REMOVE_sbi.o    = $(CC_FLAGS_FTRACE)
 endif
+CFLAGS_syscall_table.o += $(call cc-option,-Wno-override-init,)
 
 extra-y += head.o
 extra-y += vmlinux.lds
index e6372490aa0baf276bf1f46da6933f7dafc45dfc..17ca5e923bb0dfbef53cbf4fcc5d33f05e61b9ec 100644 (file)
@@ -2,39 +2,41 @@
 
 #include <linux/kprobes.h>
 
-/* Ftrace callback handler for kprobes -- called under preepmt disabed */
+/* Ftrace callback handler for kprobes -- called under preepmt disabled */
 void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
-                          struct ftrace_ops *ops, struct ftrace_regs *regs)
+                          struct ftrace_ops *ops, struct ftrace_regs *fregs)
 {
        struct kprobe *p;
+       struct pt_regs *regs;
        struct kprobe_ctlblk *kcb;
 
        p = get_kprobe((kprobe_opcode_t *)ip);
        if (unlikely(!p) || kprobe_disabled(p))
                return;
 
+       regs = ftrace_get_regs(fregs);
        kcb = get_kprobe_ctlblk();
        if (kprobe_running()) {
                kprobes_inc_nmissed_count(p);
        } else {
-               unsigned long orig_ip = instruction_pointer(&(regs->regs));
+               unsigned long orig_ip = instruction_pointer(regs);
 
-               instruction_pointer_set(&(regs->regs), ip);
+               instruction_pointer_set(regs, ip);
 
                __this_cpu_write(current_kprobe, p);
                kcb->kprobe_status = KPROBE_HIT_ACTIVE;
-               if (!p->pre_handler || !p->pre_handler(p, &(regs->regs))) {
+               if (!p->pre_handler || !p->pre_handler(p, regs)) {
                        /*
                         * Emulate singlestep (and also recover regs->pc)
                         * as if there is a nop
                         */
-                       instruction_pointer_set(&(regs->regs),
+                       instruction_pointer_set(regs,
                                (unsigned long)p->addr + MCOUNT_INSN_SIZE);
                        if (unlikely(p->post_handler)) {
                                kcb->kprobe_status = KPROBE_HIT_SSDONE;
-                               p->post_handler(p, &(regs->regs), 0);
+                               p->post_handler(p, regs, 0);
                        }
-                       instruction_pointer_set(&(regs->regs), orig_ip);
+                       instruction_pointer_set(regs, orig_ip);
                }
 
                /*
index a2ec18662fee09a7a7bbc41c8263751763b0af6d..7e2c78e2ca6b0bc93b19e1a7011648d0e4afc2c6 100644 (file)
@@ -256,8 +256,7 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, unsigned int trapnr)
                 * normal page fault.
                 */
                regs->epc = (unsigned long) cur->addr;
-               if (!instruction_pointer(regs))
-                       BUG();
+               BUG_ON(!instruction_pointer(regs));
 
                if (kcb->kprobe_status == KPROBE_REENTER)
                        restore_previous_kprobe(kcb);
index 6f728e731bedf56020516cbdc0076e53ce518b85..f9cd57c9c67d2d46c8002002beb83e2e1fb1a2f2 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/cpu.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
+#include <linux/sched/debug.h>
 #include <linux/sched/task_stack.h>
 #include <linux/tick.h>
 #include <linux/ptrace.h>
index f4a7db3d309e69f4928b423532da1b96b762275d..d3bf756321a5b0e0b6d552dcb338ae28167e0737 100644 (file)
@@ -116,7 +116,7 @@ void sbi_clear_ipi(void)
 EXPORT_SYMBOL(sbi_clear_ipi);
 
 /**
- * sbi_set_timer_v01() - Program the timer for next timer event.
+ * __sbi_set_timer_v01() - Program the timer for next timer event.
  * @stime_value: The value after which next timer event should fire.
  *
  * Return: None
index e85bacff1b5075ee3b704f7a65e40d102d0a9de3..f8f15332caa20263e995a31d1d588e923786eb1d 100644 (file)
@@ -147,7 +147,8 @@ static void __init init_resources(void)
        bss_res.end = __pa_symbol(__bss_stop) - 1;
        bss_res.flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY;
 
-       mem_res_sz = (memblock.memory.cnt + memblock.reserved.cnt) * sizeof(*mem_res);
+       /* + 1 as memblock_alloc() might increase memblock.reserved.cnt */
+       mem_res_sz = (memblock.memory.cnt + memblock.reserved.cnt + 1) * sizeof(*mem_res);
        mem_res = memblock_alloc(mem_res_sz, SMP_CACHE_BYTES);
        if (!mem_res)
                panic("%s: Failed to allocate %zu bytes\n", __func__, mem_res_sz);
index 8a5cf99c07762403ebd55ba6f54e03005e28b7e4..1b432264f7ef86be3dd201d2babe5d7fa9327fcf 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/delay.h>
 #include <asm/sbi.h>
 #include <asm/processor.h>
+#include <asm/timex.h>
 
 unsigned long riscv_timebase;
 EXPORT_SYMBOL_GPL(riscv_timebase);
index 3ed2c23601a02959fe15230c192e70bb3d686a5d..0879b5df11b92c21a10e5b796618a72ba2934fdd 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/module.h>
 #include <linux/irq.h>
 
+#include <asm/asm-prototypes.h>
 #include <asm/bug.h>
 #include <asm/processor.h>
 #include <asm/ptrace.h>
index 3fc18f469efbc6f1e3b05f8fbba71bc9345315fa..4f85c6d0ddf8b31ba6c44a8ad34ea185946da540 100644 (file)
@@ -155,7 +155,7 @@ static void __init kasan_populate(void *start, void *end)
        memset(start, KASAN_SHADOW_INIT, end - start);
 }
 
-void __init kasan_shallow_populate(void *start, void *end)
+static void __init kasan_shallow_populate(void *start, void *end)
 {
        unsigned long vaddr = (unsigned long)start & PAGE_MASK;
        unsigned long vend = PAGE_ALIGN((unsigned long)end);
@@ -187,6 +187,8 @@ void __init kasan_shallow_populate(void *start, void *end)
                }
                vaddr += PAGE_SIZE;
        }
+
+       local_flush_tlb_all();
 }
 
 void __init kasan_init(void)
index 02056b024091eb95ade5612922fa1616e9077b3d..dc0b69058ac47556b91846f1aae702d05b8e52e6 100644 (file)
@@ -275,9 +275,9 @@ CONFIG_IP_VS_DH=m
 CONFIG_IP_VS_SH=m
 CONFIG_IP_VS_SED=m
 CONFIG_IP_VS_NQ=m
+CONFIG_IP_VS_TWOS=m
 CONFIG_IP_VS_FTP=m
 CONFIG_IP_VS_PE_SIP=m
-CONFIG_NF_TABLES_IPV4=y
 CONFIG_NFT_FIB_IPV4=m
 CONFIG_NF_TABLES_ARP=y
 CONFIG_IP_NF_IPTABLES=m
@@ -298,7 +298,6 @@ CONFIG_IP_NF_SECURITY=m
 CONFIG_IP_NF_ARPTABLES=m
 CONFIG_IP_NF_ARPFILTER=m
 CONFIG_IP_NF_ARP_MANGLE=m
-CONFIG_NF_TABLES_IPV6=y
 CONFIG_NFT_FIB_IPV6=m
 CONFIG_IP6_NF_IPTABLES=m
 CONFIG_IP6_NF_MATCH_AH=m
@@ -481,7 +480,6 @@ CONFIG_NLMON=m
 # CONFIG_NET_VENDOR_AQUANTIA is not set
 # CONFIG_NET_VENDOR_ARC is not set
 # CONFIG_NET_VENDOR_ATHEROS is not set
-# CONFIG_NET_VENDOR_AURORA is not set
 # CONFIG_NET_VENDOR_BROADCOM is not set
 # CONFIG_NET_VENDOR_BROCADE is not set
 # CONFIG_NET_VENDOR_CADENCE is not set
@@ -581,7 +579,6 @@ CONFIG_VIRTIO_BALLOON=m
 CONFIG_VIRTIO_INPUT=y
 CONFIG_VHOST_NET=m
 CONFIG_VHOST_VSOCK=m
-# CONFIG_SURFACE_PLATFORMS is not set
 CONFIG_S390_CCW_IOMMU=y
 CONFIG_S390_AP_IOMMU=y
 CONFIG_EXT4_FS=y
@@ -635,6 +632,7 @@ CONFIG_NTFS_RW=y
 CONFIG_PROC_KCORE=y
 CONFIG_TMPFS=y
 CONFIG_TMPFS_POSIX_ACL=y
+CONFIG_TMPFS_INODE64=y
 CONFIG_HUGETLBFS=y
 CONFIG_CONFIGFS_FS=m
 CONFIG_ECRYPT_FS=m
@@ -714,12 +712,8 @@ CONFIG_CRYPTO_VMAC=m
 CONFIG_CRYPTO_CRC32=m
 CONFIG_CRYPTO_BLAKE2S=m
 CONFIG_CRYPTO_MICHAEL_MIC=m
-CONFIG_CRYPTO_RMD128=m
 CONFIG_CRYPTO_RMD160=m
-CONFIG_CRYPTO_RMD256=m
-CONFIG_CRYPTO_RMD320=m
 CONFIG_CRYPTO_SHA3=m
-CONFIG_CRYPTO_TGR192=m
 CONFIG_CRYPTO_WP512=m
 CONFIG_CRYPTO_AES_TI=m
 CONFIG_CRYPTO_ANUBIS=m
@@ -731,7 +725,6 @@ CONFIG_CRYPTO_CAST6=m
 CONFIG_CRYPTO_DES=m
 CONFIG_CRYPTO_FCRYPT=m
 CONFIG_CRYPTO_KHAZAD=m
-CONFIG_CRYPTO_SALSA20=m
 CONFIG_CRYPTO_SEED=m
 CONFIG_CRYPTO_SERPENT=m
 CONFIG_CRYPTO_SM4=m
@@ -796,12 +789,9 @@ CONFIG_DEBUG_OBJECTS_RCU_HEAD=y
 CONFIG_DEBUG_OBJECTS_PERCPU_COUNTER=y
 CONFIG_SLUB_DEBUG_ON=y
 CONFIG_SLUB_STATS=y
-CONFIG_DEBUG_KMEMLEAK=y
-CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF=y
 CONFIG_DEBUG_STACK_USAGE=y
 CONFIG_DEBUG_VM=y
 CONFIG_DEBUG_VM_VMACACHE=y
-CONFIG_DEBUG_VM_RB=y
 CONFIG_DEBUG_VM_PGFLAGS=y
 CONFIG_DEBUG_MEMORY_INIT=y
 CONFIG_MEMORY_NOTIFIER_ERROR_INJECT=m
@@ -838,6 +828,7 @@ CONFIG_BPF_KPROBE_OVERRIDE=y
 CONFIG_HIST_TRIGGERS=y
 CONFIG_FTRACE_STARTUP_TEST=y
 # CONFIG_EVENT_TRACE_STARTUP_TEST is not set
+CONFIG_DEBUG_ENTRY=y
 CONFIG_NOTIFIER_ERROR_INJECTION=m
 CONFIG_NETDEV_NOTIFIER_ERROR_INJECT=m
 CONFIG_FAULT_INJECTION=y
@@ -861,4 +852,3 @@ CONFIG_PERCPU_TEST=m
 CONFIG_ATOMIC64_SELFTEST=y
 CONFIG_TEST_BITOPS=m
 CONFIG_TEST_BPF=m
-CONFIG_DEBUG_ENTRY=y
index bac721a501da16a47313922369f4a61fff427a18..320379da96d97536fe563a5c09c0aa53acc642ef 100644 (file)
@@ -266,9 +266,9 @@ CONFIG_IP_VS_DH=m
 CONFIG_IP_VS_SH=m
 CONFIG_IP_VS_SED=m
 CONFIG_IP_VS_NQ=m
+CONFIG_IP_VS_TWOS=m
 CONFIG_IP_VS_FTP=m
 CONFIG_IP_VS_PE_SIP=m
-CONFIG_NF_TABLES_IPV4=y
 CONFIG_NFT_FIB_IPV4=m
 CONFIG_NF_TABLES_ARP=y
 CONFIG_IP_NF_IPTABLES=m
@@ -289,7 +289,6 @@ CONFIG_IP_NF_SECURITY=m
 CONFIG_IP_NF_ARPTABLES=m
 CONFIG_IP_NF_ARPFILTER=m
 CONFIG_IP_NF_ARP_MANGLE=m
-CONFIG_NF_TABLES_IPV6=y
 CONFIG_NFT_FIB_IPV6=m
 CONFIG_IP6_NF_IPTABLES=m
 CONFIG_IP6_NF_MATCH_AH=m
@@ -473,7 +472,6 @@ CONFIG_NLMON=m
 # CONFIG_NET_VENDOR_AQUANTIA is not set
 # CONFIG_NET_VENDOR_ARC is not set
 # CONFIG_NET_VENDOR_ATHEROS is not set
-# CONFIG_NET_VENDOR_AURORA is not set
 # CONFIG_NET_VENDOR_BROADCOM is not set
 # CONFIG_NET_VENDOR_BROCADE is not set
 # CONFIG_NET_VENDOR_CADENCE is not set
@@ -573,7 +571,6 @@ CONFIG_VIRTIO_BALLOON=m
 CONFIG_VIRTIO_INPUT=y
 CONFIG_VHOST_NET=m
 CONFIG_VHOST_VSOCK=m
-# CONFIG_SURFACE_PLATFORMS is not set
 CONFIG_S390_CCW_IOMMU=y
 CONFIG_S390_AP_IOMMU=y
 CONFIG_EXT4_FS=y
@@ -623,6 +620,7 @@ CONFIG_NTFS_RW=y
 CONFIG_PROC_KCORE=y
 CONFIG_TMPFS=y
 CONFIG_TMPFS_POSIX_ACL=y
+CONFIG_TMPFS_INODE64=y
 CONFIG_HUGETLBFS=y
 CONFIG_CONFIGFS_FS=m
 CONFIG_ECRYPT_FS=m
@@ -703,12 +701,8 @@ CONFIG_CRYPTO_VMAC=m
 CONFIG_CRYPTO_CRC32=m
 CONFIG_CRYPTO_BLAKE2S=m
 CONFIG_CRYPTO_MICHAEL_MIC=m
-CONFIG_CRYPTO_RMD128=m
 CONFIG_CRYPTO_RMD160=m
-CONFIG_CRYPTO_RMD256=m
-CONFIG_CRYPTO_RMD320=m
 CONFIG_CRYPTO_SHA3=m
-CONFIG_CRYPTO_TGR192=m
 CONFIG_CRYPTO_WP512=m
 CONFIG_CRYPTO_AES_TI=m
 CONFIG_CRYPTO_ANUBIS=m
@@ -720,7 +714,6 @@ CONFIG_CRYPTO_CAST6=m
 CONFIG_CRYPTO_DES=m
 CONFIG_CRYPTO_FCRYPT=m
 CONFIG_CRYPTO_KHAZAD=m
-CONFIG_CRYPTO_SALSA20=m
 CONFIG_CRYPTO_SEED=m
 CONFIG_CRYPTO_SERPENT=m
 CONFIG_CRYPTO_SM4=m
index acf982a2ae4c5eb1e86bdc837243adfa6da41274..76123a4b26ab06f221c209734b1b97b38cc1e46a 100644 (file)
@@ -26,7 +26,6 @@ CONFIG_CRASH_DUMP=y
 # CONFIG_SECCOMP is not set
 # CONFIG_GCC_PLUGINS is not set
 CONFIG_PARTITION_ADVANCED=y
-CONFIG_IBM_PARTITION=y
 # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
 # CONFIG_COMPACTION is not set
 # CONFIG_MIGRATION is not set
@@ -61,11 +60,9 @@ CONFIG_RAW_DRIVER=y
 # CONFIG_HID is not set
 # CONFIG_VIRTIO_MENU is not set
 # CONFIG_VHOST_MENU is not set
-# CONFIG_SURFACE_PLATFORMS is not set
 # CONFIG_IOMMU_SUPPORT is not set
 # CONFIG_DNOTIFY is not set
 # CONFIG_INOTIFY_USER is not set
-CONFIG_CONFIGFS_FS=y
 # CONFIG_MISC_FILESYSTEMS is not set
 # CONFIG_NETWORK_FILESYSTEMS is not set
 CONFIG_LSM="yama,loadpin,safesetid,integrity"
index b04f6a794cdfb5d696c9c9dc29e9e35f66e3a00b..5cea629c548e2d53635b4a1a6e175e98e38ca908 100644 (file)
 
 struct s390_idle_data {
        seqcount_t seqcount;
-       unsigned long long idle_count;
-       unsigned long long idle_time;
-       unsigned long long clock_idle_enter;
-       unsigned long long clock_idle_exit;
-       unsigned long long timer_idle_enter;
-       unsigned long long timer_idle_exit;
+       unsigned long idle_count;
+       unsigned long idle_time;
+       unsigned long clock_idle_enter;
+       unsigned long clock_idle_exit;
+       unsigned long timer_idle_enter;
+       unsigned long timer_idle_exit;
        unsigned long mt_cycles_enter[8];
 };
 
index 053fe8b8dec7143ea18201c8e41d4d463f6a3e6d..a75d94a9bcb2f4265cbacc1d04a2580412666e94 100644 (file)
@@ -202,7 +202,7 @@ extern unsigned int s390_pci_no_rid;
 ----------------------------------------------------------------------------- */
 /* Base stuff */
 int zpci_create_device(u32 fid, u32 fh, enum zpci_state state);
-void zpci_remove_device(struct zpci_dev *zdev);
+void zpci_remove_device(struct zpci_dev *zdev, bool set_error);
 int zpci_enable_device(struct zpci_dev *);
 int zpci_disable_device(struct zpci_dev *);
 int zpci_register_ioat(struct zpci_dev *, u8, u64, u64, u64);
index c4e23e92566546ffe7d082202e33c3fc576d6bc5..f6326c6d2abe83536a340f0829b95cdd6cdb4f7b 100644 (file)
@@ -98,10 +98,10 @@ extern unsigned char ptff_function_mask[16];
 
 /* Query TOD offset result */
 struct ptff_qto {
-       unsigned long long physical_clock;
-       unsigned long long tod_offset;
-       unsigned long long logical_tod_offset;
-       unsigned long long tod_epoch_difference;
+       unsigned long physical_clock;
+       unsigned long tod_offset;
+       unsigned long logical_tod_offset;
+       unsigned long tod_epoch_difference;
 } __packed;
 
 static inline int ptff_query(unsigned int nr)
@@ -151,9 +151,9 @@ struct ptff_qui {
        rc;                                                             \
 })
 
-static inline unsigned long long local_tick_disable(void)
+static inline unsigned long local_tick_disable(void)
 {
-       unsigned long long old;
+       unsigned long old;
 
        old = S390_lowcore.clock_comparator;
        S390_lowcore.clock_comparator = clock_comparator_max;
@@ -161,7 +161,7 @@ static inline unsigned long long local_tick_disable(void)
        return old;
 }
 
-static inline void local_tick_enable(unsigned long long comp)
+static inline void local_tick_enable(unsigned long comp)
 {
        S390_lowcore.clock_comparator = comp;
        set_clock_comparator(S390_lowcore.clock_comparator);
@@ -169,9 +169,9 @@ static inline void local_tick_enable(unsigned long long comp)
 
 #define CLOCK_TICK_RATE                1193180 /* Underlying HZ */
 
-typedef unsigned long long cycles_t;
+typedef unsigned long cycles_t;
 
-static inline unsigned long long get_tod_clock(void)
+static inline unsigned long get_tod_clock(void)
 {
        union tod_clock clk;
 
@@ -179,10 +179,10 @@ static inline unsigned long long get_tod_clock(void)
        return clk.tod;
 }
 
-static inline unsigned long long get_tod_clock_fast(void)
+static inline unsigned long get_tod_clock_fast(void)
 {
 #ifdef CONFIG_HAVE_MARCH_Z9_109_FEATURES
-       unsigned long long clk;
+       unsigned long clk;
 
        asm volatile("stckf %0" : "=Q" (clk) : : "cc");
        return clk;
@@ -208,9 +208,9 @@ extern union tod_clock tod_clock_base;
  * Therefore preemption must be disabled, otherwise the returned
  * value is not guaranteed to be monotonic.
  */
-static inline unsigned long long get_tod_clock_monotonic(void)
+static inline unsigned long get_tod_clock_monotonic(void)
 {
-       unsigned long long tod;
+       unsigned long tod;
 
        preempt_disable_notrace();
        tod = get_tod_clock() - tod_clock_base.tod;
@@ -237,7 +237,7 @@ static inline unsigned long long get_tod_clock_monotonic(void)
  * -> ns = (th * 125) + ((tl * 125) >> 9);
  *
  */
-static inline unsigned long long tod_to_ns(unsigned long long todval)
+static inline unsigned long tod_to_ns(unsigned long todval)
 {
        return ((todval >> 9) * 125) + (((todval & 0x1ff) * 125) >> 9);
 }
@@ -249,10 +249,10 @@ static inline unsigned long long tod_to_ns(unsigned long long todval)
  *
  * Returns: true if a is later than b
  */
-static inline int tod_after(unsigned long long a, unsigned long long b)
+static inline int tod_after(unsigned long a, unsigned long b)
 {
        if (MACHINE_HAS_SCC)
-               return (long long) a > (long long) b;
+               return (long) a > (long) b;
        return a > b;
 }
 
@@ -263,10 +263,10 @@ static inline int tod_after(unsigned long long a, unsigned long long b)
  *
  * Returns: true if a is later than b
  */
-static inline int tod_after_eq(unsigned long long a, unsigned long long b)
+static inline int tod_after_eq(unsigned long a, unsigned long b)
 {
        if (MACHINE_HAS_SCC)
-               return (long long) a >= (long long) b;
+               return (long) a >= (long) b;
        return a >= b;
 }
 
diff --git a/arch/s390/include/uapi/asm/hwctrset.h b/arch/s390/include/uapi/asm/hwctrset.h
new file mode 100644 (file)
index 0000000..3d8284b
--- /dev/null
@@ -0,0 +1,51 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * Copyright IBM Corp. 2021
+ * Interface implementation for communication with the CPU Measurement
+ * counter facility device driver.
+ *
+ * Author(s): Thomas Richter <tmricht@linux.ibm.com>
+ *
+ * Define for ioctl() commands to communicate with the CPU Measurement
+ * counter facility device driver.
+ */
+
+#ifndef _PERF_CPUM_CF_DIAG_H
+#define _PERF_CPUM_CF_DIAG_H
+
+#include <linux/ioctl.h>
+#include <linux/types.h>
+
+#define S390_HWCTR_DEVICE              "hwctr"
+#define S390_HWCTR_START_VERSION       1
+
+struct s390_ctrset_start {             /* Set CPUs to operate on */
+       __u64 version;                  /* Version of interface */
+       __u64 data_bytes;               /* # of bytes required */
+       __u64 cpumask_len;              /* Length of CPU mask in bytes */
+       __u64 *cpumask;                 /* Pointer to CPU mask */
+       __u64 counter_sets;             /* Bit mask of counter sets to get */
+};
+
+struct s390_ctrset_setdata {           /* Counter set data */
+       __u32 set;                      /* Counter set number */
+       __u32 no_cnts;                  /* # of counters stored in cv[] */
+       __u64 cv[0];                    /* Counter values (variable length) */
+};
+
+struct s390_ctrset_cpudata {           /* Counter set data per CPU */
+       __u32 cpu_nr;                   /* CPU number */
+       __u32 no_sets;                  /* # of counters sets in data[] */
+       struct s390_ctrset_setdata data[0];
+};
+
+struct s390_ctrset_read {              /* Structure to get all ctr sets */
+       __u64 no_cpus;                  /* Total # of CPUs data taken from */
+       struct s390_ctrset_cpudata data[0];
+};
+
+#define S390_HWCTR_MAGIC       'C'     /* Random magic # for ioctls */
+#define        S390_HWCTR_START        _IOWR(S390_HWCTR_MAGIC, 1, struct s390_ctrset_start)
+#define        S390_HWCTR_STOP         _IO(S390_HWCTR_MAGIC, 2)
+#define        S390_HWCTR_READ         _IOWR(S390_HWCTR_MAGIC, 3, struct s390_ctrset_read)
+#endif
diff --git a/arch/s390/include/uapi/asm/perf_cpum_cf_diag.h b/arch/s390/include/uapi/asm/perf_cpum_cf_diag.h
deleted file mode 100644 (file)
index 3d8284b..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-/*
- * Copyright IBM Corp. 2021
- * Interface implementation for communication with the CPU Measurement
- * counter facility device driver.
- *
- * Author(s): Thomas Richter <tmricht@linux.ibm.com>
- *
- * Define for ioctl() commands to communicate with the CPU Measurement
- * counter facility device driver.
- */
-
-#ifndef _PERF_CPUM_CF_DIAG_H
-#define _PERF_CPUM_CF_DIAG_H
-
-#include <linux/ioctl.h>
-#include <linux/types.h>
-
-#define S390_HWCTR_DEVICE              "hwctr"
-#define S390_HWCTR_START_VERSION       1
-
-struct s390_ctrset_start {             /* Set CPUs to operate on */
-       __u64 version;                  /* Version of interface */
-       __u64 data_bytes;               /* # of bytes required */
-       __u64 cpumask_len;              /* Length of CPU mask in bytes */
-       __u64 *cpumask;                 /* Pointer to CPU mask */
-       __u64 counter_sets;             /* Bit mask of counter sets to get */
-};
-
-struct s390_ctrset_setdata {           /* Counter set data */
-       __u32 set;                      /* Counter set number */
-       __u32 no_cnts;                  /* # of counters stored in cv[] */
-       __u64 cv[0];                    /* Counter values (variable length) */
-};
-
-struct s390_ctrset_cpudata {           /* Counter set data per CPU */
-       __u32 cpu_nr;                   /* CPU number */
-       __u32 no_sets;                  /* # of counters sets in data[] */
-       struct s390_ctrset_setdata data[0];
-};
-
-struct s390_ctrset_read {              /* Structure to get all ctr sets */
-       __u64 no_cpus;                  /* Total # of CPUs data taken from */
-       struct s390_ctrset_cpudata data[0];
-};
-
-#define S390_HWCTR_MAGIC       'C'     /* Random magic # for ioctls */
-#define        S390_HWCTR_START        _IOWR(S390_HWCTR_MAGIC, 1, struct s390_ctrset_start)
-#define        S390_HWCTR_STOP         _IO(S390_HWCTR_MAGIC, 2)
-#define        S390_HWCTR_READ         _IOWR(S390_HWCTR_MAGIC, 3, struct s390_ctrset_read)
-#endif
index 812073ea073ee23e571041d12e528ab2769c4395..4bf1ee293f2b31ee3d5ae06cbe9afd7baa6d37db 100644 (file)
@@ -47,7 +47,7 @@ void account_idle_time_irq(void)
 void arch_cpu_idle(void)
 {
        struct s390_idle_data *idle = this_cpu_ptr(&s390_idle);
-       unsigned long long idle_time;
+       unsigned long idle_time;
        unsigned long psw_mask;
 
        /* Wait for external, I/O or machine check interrupt. */
@@ -73,7 +73,7 @@ static ssize_t show_idle_count(struct device *dev,
                                struct device_attribute *attr, char *buf)
 {
        struct s390_idle_data *idle = &per_cpu(s390_idle, dev->id);
-       unsigned long long idle_count;
+       unsigned long idle_count;
        unsigned int seq;
 
        do {
@@ -82,14 +82,14 @@ static ssize_t show_idle_count(struct device *dev,
                if (READ_ONCE(idle->clock_idle_enter))
                        idle_count++;
        } while (read_seqcount_retry(&idle->seqcount, seq));
-       return sprintf(buf, "%llu\n", idle_count);
+       return sprintf(buf, "%lu\n", idle_count);
 }
 DEVICE_ATTR(idle_count, 0444, show_idle_count, NULL);
 
 static ssize_t show_idle_time(struct device *dev,
                                struct device_attribute *attr, char *buf)
 {
-       unsigned long long now, idle_time, idle_enter, idle_exit, in_idle;
+       unsigned long now, idle_time, idle_enter, idle_exit, in_idle;
        struct s390_idle_data *idle = &per_cpu(s390_idle, dev->id);
        unsigned int seq;
 
@@ -109,14 +109,14 @@ static ssize_t show_idle_time(struct device *dev,
                }
        }
        idle_time += in_idle;
-       return sprintf(buf, "%llu\n", idle_time >> 12);
+       return sprintf(buf, "%lu\n", idle_time >> 12);
 }
 DEVICE_ATTR(idle_time_us, 0444, show_idle_time, NULL);
 
 u64 arch_cpu_idle_time(int cpu)
 {
        struct s390_idle_data *idle = &per_cpu(s390_idle, cpu);
-       unsigned long long now, idle_enter, idle_exit, in_idle;
+       unsigned long now, idle_enter, idle_exit, in_idle;
        unsigned int seq;
 
        do {
index 0eb1d1cc53a88380421468f5daa6ec1f842328e2..b3beef64d3d48776667c5d8d851d83ff98f545d2 100644 (file)
@@ -269,7 +269,7 @@ static int __hw_perf_event_init(struct perf_event *event, unsigned int type)
        case CPUMF_CTR_SET_MAX:
                /* The counter could not be associated to a counter set */
                return -EINVAL;
-       };
+       }
 
        /* Initialize for using the CPU-measurement counter facility */
        if (!atomic_inc_not_zero(&num_events)) {
index db4877bbb9aa5626702bf6068de92accdaa9e81a..2e3e7edbe3a0c93117d5caec50a200677370cb55 100644 (file)
 #include <asm/timex.h>
 #include <asm/debug.h>
 
-#include <asm/perf_cpum_cf_diag.h>
+#include <asm/hwctrset.h>
 
 #define        CF_DIAG_CTRSET_DEF              0xfeef  /* Counter set header mark */
-#define CF_DIAG_MIN_INTERVAL           60      /* Minimum counter set read */
                                                /* interval in seconds */
-static unsigned long cf_diag_interval = CF_DIAG_MIN_INTERVAL;
 static unsigned int cf_diag_cpu_speed;
 static debug_info_t *cf_diag_dbg;
 
@@ -729,7 +727,6 @@ static DEFINE_MUTEX(cf_diag_ctrset_mutex);
 static struct cf_diag_ctrset {
        unsigned long ctrset;           /* Bit mask of counter set to read */
        cpumask_t mask;                 /* CPU mask to read from */
-       time64_t lastread;              /* Epoch counter set last read */
 } cf_diag_ctrset;
 
 static void cf_diag_ctrset_clear(void)
@@ -866,27 +863,16 @@ static int cf_diag_all_read(unsigned long arg)
 {
        struct cf_diag_call_on_cpu_parm p;
        cpumask_var_t mask;
-       time64_t now;
-       int rc = 0;
+       int rc;
 
        debug_sprintf_event(cf_diag_dbg, 5, "%s\n", __func__);
        if (!alloc_cpumask_var(&mask, GFP_KERNEL))
                return -ENOMEM;
-       now = ktime_get_seconds();
-       if (cf_diag_ctrset.lastread + cf_diag_interval > now) {
-               debug_sprintf_event(cf_diag_dbg, 5, "%s now %lld "
-                                   " lastread %lld\n", __func__, now,
-                                   cf_diag_ctrset.lastread);
-               rc = -EAGAIN;
-               goto out;
-       } else {
-               cf_diag_ctrset.lastread = now;
-       }
+
        p.sets = cf_diag_ctrset.ctrset;
        cpumask_and(mask, &cf_diag_ctrset.mask, cpu_online_mask);
        on_each_cpu_mask(mask, cf_diag_cpu_read, &p, 1);
        rc = cf_diag_all_copy(arg, mask);
-out:
        free_cpumask_var(mask);
        debug_sprintf_event(cf_diag_dbg, 5, "%s rc %d\n", __func__, rc);
        return rc;
@@ -982,7 +968,7 @@ static int cf_diag_all_start(void)
  */
 static size_t cf_diag_needspace(unsigned int sets)
 {
-       struct cpu_cf_events *cpuhw = this_cpu_ptr(&cpu_cf_events);
+       struct cpu_cf_events *cpuhw = get_cpu_ptr(&cpu_cf_events);
        size_t bytes = 0;
        int i;
 
@@ -998,6 +984,7 @@ static size_t cf_diag_needspace(unsigned int sets)
                     sizeof(((struct s390_ctrset_cpudata *)0)->no_sets));
        debug_sprintf_event(cf_diag_dbg, 5, "%s bytes %ld\n", __func__,
                            bytes);
+       put_cpu_ptr(&cpu_cf_events);
        return bytes;
 }
 
index 06bcfa6366384e3145e4dd469d4dfa6641a7d924..165da961f9019adf641c6568a2cc4c853862a007 100644 (file)
@@ -68,10 +68,10 @@ EXPORT_SYMBOL(s390_epoch_delta_notifier);
 
 unsigned char ptff_function_mask[16];
 
-static unsigned long long lpar_offset;
-static unsigned long long initial_leap_seconds;
-static unsigned long long tod_steering_end;
-static long long tod_steering_delta;
+static unsigned long lpar_offset;
+static unsigned long initial_leap_seconds;
+static unsigned long tod_steering_end;
+static long tod_steering_delta;
 
 /*
  * Get time offsets with PTFF
@@ -96,7 +96,7 @@ void __init time_early_init(void)
 
        /* get initial leap seconds */
        if (ptff_query(PTFF_QUI) && ptff(&qui, sizeof(qui), PTFF_QUI) == 0)
-               initial_leap_seconds = (unsigned long long)
+               initial_leap_seconds = (unsigned long)
                        ((long) qui.old_leap * 4096000000L);
 }
 
@@ -222,7 +222,7 @@ void __init read_persistent_wall_and_boot_offset(struct timespec64 *wall_time,
 
 static u64 read_tod_clock(struct clocksource *cs)
 {
-       unsigned long long now, adj;
+       unsigned long now, adj;
 
        preempt_disable(); /* protect from changes to steering parameters */
        now = get_tod_clock();
@@ -362,7 +362,7 @@ static inline int check_sync_clock(void)
  * Apply clock delta to the global data structures.
  * This is called once on the CPU that performed the clock sync.
  */
-static void clock_sync_global(unsigned long long delta)
+static void clock_sync_global(unsigned long delta)
 {
        unsigned long now, adj;
        struct ptff_qto qto;
@@ -378,7 +378,7 @@ static void clock_sync_global(unsigned long long delta)
                        -(adj >> 15) : (adj >> 15);
        tod_steering_delta += delta;
        if ((abs(tod_steering_delta) >> 48) != 0)
-               panic("TOD clock sync offset %lli is too large to drift\n",
+               panic("TOD clock sync offset %li is too large to drift\n",
                      tod_steering_delta);
        tod_steering_end = now + (abs(tod_steering_delta) << 15);
        vdso_data->arch_data.tod_steering_end = tod_steering_end;
@@ -394,7 +394,7 @@ static void clock_sync_global(unsigned long long delta)
  * Apply clock delta to the per-CPU data structures of this CPU.
  * This is called for each online CPU after the call to clock_sync_global.
  */
-static void clock_sync_local(unsigned long long delta)
+static void clock_sync_local(unsigned long delta)
 {
        /* Add the delta to the clock comparator. */
        if (S390_lowcore.clock_comparator != clock_comparator_max) {
@@ -418,7 +418,7 @@ static void __init time_init_wq(void)
 struct clock_sync_data {
        atomic_t cpus;
        int in_sync;
-       unsigned long long clock_delta;
+       unsigned long clock_delta;
 };
 
 /*
@@ -538,7 +538,7 @@ static int stpinfo_valid(void)
 static int stp_sync_clock(void *data)
 {
        struct clock_sync_data *sync = data;
-       unsigned long long clock_delta, flags;
+       u64 clock_delta, flags;
        static int first;
        int rc;
 
@@ -720,8 +720,8 @@ static ssize_t ctn_id_show(struct device *dev,
 
        mutex_lock(&stp_mutex);
        if (stpinfo_valid())
-               ret = sprintf(buf, "%016llx\n",
-                             *(unsigned long long *) stp_info.ctnid);
+               ret = sprintf(buf, "%016lx\n",
+                             *(unsigned long *) stp_info.ctnid);
        mutex_unlock(&stp_mutex);
        return ret;
 }
@@ -794,7 +794,7 @@ static ssize_t leap_seconds_scheduled_show(struct device *dev,
        if (!stzi.lsoib.p)
                return sprintf(buf, "0,0\n");
 
-       return sprintf(buf, "%llu,%d\n",
+       return sprintf(buf, "%lu,%d\n",
                       tod_to_ns(stzi.lsoib.nlsout - TOD_UNIX_EPOCH) / NSEC_PER_SEC,
                       stzi.lsoib.nlso - stzi.lsoib.also);
 }
index e7ce447651b905c20dce60dfc41555ee359d5d55..bfcc327acc6b2ebfec38f7fe0e3a3bd39e73f4f6 100644 (file)
@@ -76,8 +76,6 @@ static void cpu_group_map(cpumask_t *dst, struct mask_info *info, unsigned int c
                        }
                        info = info->next;
                }
-               if (cpumask_empty(&mask))
-                       cpumask_copy(&mask, cpumask_of(cpu));
                break;
        case TOPOLOGY_MODE_PACKAGE:
                cpumask_copy(&mask, cpu_present_mask);
index 73c7afcc0527a457d25b2a68543c8369f0395995..f216a1b2f82570de92365007e5da8158ebbd0714 100644 (file)
@@ -214,7 +214,7 @@ void vtime_flush(struct task_struct *tsk)
        avg_steal = S390_lowcore.avg_steal_timer / 2;
        if ((s64) steal > 0) {
                S390_lowcore.steal_timer = 0;
-               account_steal_time(steal);
+               account_steal_time(cputime_to_nsecs(steal));
                avg_steal += steal;
        }
        S390_lowcore.avg_steal_timer = avg_steal;
index e3183bd059107a04f7695ee707da18f1bea2153d..d548d60caed252021c6abb532e546a79184741fb 100644 (file)
@@ -1287,7 +1287,7 @@ static u64 __calculate_sltime(struct kvm_vcpu *vcpu)
                        /* already expired? */
                        if (cputm >> 63)
                                return 0;
-                       return min(sltime, tod_to_ns(cputm));
+                       return min_t(u64, sltime, tod_to_ns(cputm));
                }
        } else if (cpu_timer_interrupts_enabled(vcpu)) {
                sltime = kvm_s390_get_cpu_timer(vcpu);
index 600881d894dd04b7b4e05e4d83d808d8ac4bd1c7..91064077526df01128b78a677d2b1fdec02737e9 100644 (file)
@@ -682,16 +682,36 @@ int zpci_disable_device(struct zpci_dev *zdev)
 }
 EXPORT_SYMBOL_GPL(zpci_disable_device);
 
-void zpci_remove_device(struct zpci_dev *zdev)
+/* zpci_remove_device - Removes the given zdev from the PCI core
+ * @zdev: the zdev to be removed from the PCI core
+ * @set_error: if true the device's error state is set to permanent failure
+ *
+ * Sets a zPCI device to a configured but offline state; the zPCI
+ * device is still accessible through its hotplug slot and the zPCI
+ * API but is removed from the common code PCI bus, making it
+ * no longer available to drivers.
+ */
+void zpci_remove_device(struct zpci_dev *zdev, bool set_error)
 {
        struct zpci_bus *zbus = zdev->zbus;
        struct pci_dev *pdev;
 
+       if (!zdev->zbus->bus)
+               return;
+
        pdev = pci_get_slot(zbus->bus, zdev->devfn);
        if (pdev) {
-               if (pdev->is_virtfn)
-                       return zpci_iov_remove_virtfn(pdev, zdev->vfn);
+               if (set_error)
+                       pdev->error_state = pci_channel_io_perm_failure;
+               if (pdev->is_virtfn) {
+                       zpci_iov_remove_virtfn(pdev, zdev->vfn);
+                       /* balance pci_get_slot */
+                       pci_dev_put(pdev);
+                       return;
+               }
                pci_stop_and_remove_bus_device_locked(pdev);
+               /* balance pci_get_slot */
+               pci_dev_put(pdev);
        }
 }
 
@@ -765,7 +785,7 @@ void zpci_release_device(struct kref *kref)
        struct zpci_dev *zdev = container_of(kref, struct zpci_dev, kref);
 
        if (zdev->zbus->bus)
-               zpci_remove_device(zdev);
+               zpci_remove_device(zdev, false);
 
        switch (zdev->state) {
        case ZPCI_FN_STATE_ONLINE:
index b4162da4e8a20899cafa2f7cb9d78d5185e1532d..ac0c65cdd69d928480aab918ae6026681fdc847f 100644 (file)
@@ -76,13 +76,10 @@ void zpci_event_error(void *data)
 static void __zpci_event_availability(struct zpci_ccdf_avail *ccdf)
 {
        struct zpci_dev *zdev = get_zdev_by_fid(ccdf->fid);
-       struct pci_dev *pdev = NULL;
        enum zpci_state state;
+       struct pci_dev *pdev;
        int ret;
 
-       if (zdev && zdev->zbus->bus)
-               pdev = pci_get_slot(zdev->zbus->bus, zdev->devfn);
-
        zpci_err("avail CCDF:\n");
        zpci_err_hex(ccdf, sizeof(*ccdf));
 
@@ -124,8 +121,7 @@ static void __zpci_event_availability(struct zpci_ccdf_avail *ccdf)
        case 0x0303: /* Deconfiguration requested */
                if (!zdev)
                        break;
-               if (pdev)
-                       zpci_remove_device(zdev);
+               zpci_remove_device(zdev, false);
 
                ret = zpci_disable_device(zdev);
                if (ret)
@@ -140,12 +136,10 @@ static void __zpci_event_availability(struct zpci_ccdf_avail *ccdf)
        case 0x0304: /* Configured -> Standby|Reserved */
                if (!zdev)
                        break;
-               if (pdev) {
-                       /* Give the driver a hint that the function is
-                        * already unusable. */
-                       pdev->error_state = pci_channel_io_perm_failure;
-                       zpci_remove_device(zdev);
-               }
+               /* Give the driver a hint that the function is
+                * already unusable.
+                */
+               zpci_remove_device(zdev, true);
 
                zdev->fh = ccdf->fh;
                zpci_disable_device(zdev);
index 148f44b33890e220039f1f345b8ccfaf4a9f0006..12a4fb0bd52aa41d2865e49450b7c4b6ad4b1656 100644 (file)
@@ -93,7 +93,7 @@ CONFIG_NETDEVICES=y
 CONFIG_NET_ETHERNET=y
 CONFIG_MII=m
 CONFIG_SUNLANCE=m
-CONFIG_HAPPYMEAL=m
+CONFIG_HAPPYMEAL=y
 CONFIG_SUNGEM=m
 CONFIG_SUNVNET=m
 CONFIG_LDMVSW=m
@@ -234,9 +234,7 @@ CONFIG_CRYPTO_TWOFISH=m
 CONFIG_CRC16=m
 CONFIG_LIBCRC32C=m
 CONFIG_VCC=m
-CONFIG_ATA=y
 CONFIG_PATA_CMD64X=y
-CONFIG_HAPPYMEAL=y
 CONFIG_IP_PNP=y
 CONFIG_IP_PNP_DHCP=y
 CONFIG_DEVTMPFS=y
index 7e078bc73ef5616d8f0a94f070246d203c4f6e14..8fb09eec8c3e796a9a79aa0a7877842ceb7ea6d3 100644 (file)
@@ -8,7 +8,6 @@
 
 #include <asm/ptrace.h>
 #include <asm/processor.h>
-#include <asm/extable_64.h>
 #include <asm/spitfire.h>
 #include <asm/adi.h>
 
diff --git a/arch/sparc/include/asm/extable.h b/arch/sparc/include/asm/extable.h
new file mode 100644 (file)
index 0000000..554a9dc
--- /dev/null
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __ASM_EXTABLE_H
+#define __ASM_EXTABLE_H
+/*
+ * The exception table consists of pairs of addresses: the first is the
+ * address of an instruction that is allowed to fault, and the second is
+ * the address at which the program should continue.  No registers are
+ * modified, so it is entirely up to the continuation code to figure out
+ * what to do.
+ *
+ * All the routines below use bits of fixup code that are out of line
+ * with the main instruction path.  This means when everything is well,
+ * we don't even have to jump over them.  Further, they do not intrude
+ * on our cache or tlb entries.
+ */
+
+struct exception_table_entry {
+        unsigned int insn, fixup;
+};
+
+#endif
diff --git a/arch/sparc/include/asm/extable_64.h b/arch/sparc/include/asm/extable_64.h
deleted file mode 100644 (file)
index 5a01719..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef __ASM_EXTABLE64_H
-#define __ASM_EXTABLE64_H
-/*
- * The exception table consists of pairs of addresses: the first is the
- * address of an instruction that is allowed to fault, and the second is
- * the address at which the program should continue.  No registers are
- * modified, so it is entirely up to the continuation code to figure out
- * what to do.
- *
- * All the routines below use bits of fixup code that are out of line
- * with the main instruction path.  This means when everything is well,
- * we don't even have to jump over them.  Further, they do not intrude
- * on our cache or tlb entries.
- */
-
-struct exception_table_entry {
-        unsigned int insn, fixup;
-};
-
-#endif
index 3c4bc2189092d350b7b6e2c794714f6c7249f692..b6242f7771e9e845ab9a24720e99f66a86c8ae51 100644 (file)
@@ -50,16 +50,12 @@ struct thread_struct {
        unsigned long   fsr;
        unsigned long   fpqdepth;
        struct fpq      fpqueue[16];
-       unsigned long flags;
        mm_segment_t current_ds;
 };
 
-#define SPARC_FLAG_KTHREAD      0x1    /* task is a kernel thread */
-#define SPARC_FLAG_UNALIGNED    0x2    /* is allowed to do unaligned accesses */
-
 #define INIT_THREAD  { \
-       .flags = SPARC_FLAG_KTHREAD, \
        .current_ds = KERNEL_DS, \
+       .kregs = (struct pt_regs *)(init_stack+THREAD_SIZE)-1 \
 }
 
 /* Do necessary setup to start up a newly executed thread. */
index 42cd4cd3892e32a9adacad7ba1d4fb208369691c..8047a9caab2fc86a35e684a98e2c1deff54e923a 100644 (file)
@@ -118,6 +118,7 @@ struct thread_info {
        .task           =       &tsk,                   \
        .current_ds     =       ASI_P,                  \
        .preempt_count  =       INIT_PREEMPT_COUNT,     \
+       .kregs          =       (struct pt_regs *)(init_stack+THREAD_SIZE)-1 \
 }
 
 /* how to get the thread information struct from C */
index dd85bc2c2cad5211c19695362bba874e0ce17b3c..390094200fc44212187f7909d74b3079ed639d6e 100644 (file)
@@ -1,6 +1,9 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #ifndef ___ASM_SPARC_UACCESS_H
 #define ___ASM_SPARC_UACCESS_H
+
+#include <asm/extable.h>
+
 #if defined(__sparc__) && defined(__arch64__)
 #include <asm/uaccess_64.h>
 #else
index 0a2d3ebc4bb86d349bf5455bc05d7868f6da495e..4a12346bb69c335d06bc4e30b98244ced13a46e3 100644 (file)
@@ -13,9 +13,6 @@
 
 #include <asm/processor.h>
 
-#define ARCH_HAS_SORT_EXTABLE
-#define ARCH_HAS_SEARCH_EXTABLE
-
 /* Sparc is not segmented, however we need to be able to fool access_ok()
  * when doing system calls from kernel mode legitimately.
  *
 #define __access_ok(addr, size) (__user_ok((addr) & get_fs().seg, (size)))
 #define access_ok(addr, size) __access_ok((unsigned long)(addr), size)
 
-/*
- * The exception table consists of pairs of addresses: the first is the
- * address of an instruction that is allowed to fault, and the second is
- * the address at which the program should continue.  No registers are
- * modified, so it is entirely up to the continuation code to figure out
- * what to do.
- *
- * All the routines below use bits of fixup code that are out of line
- * with the main instruction path.  This means when everything is well,
- * we don't even have to jump over them.  Further, they do not intrude
- * on our cache or tlb entries.
- *
- * There is a special way how to put a range of potentially faulting
- * insns (like twenty ldd/std's with now intervening other instructions)
- * You specify address of first in insn and 0 in fixup and in the next
- * exception_table_entry you specify last potentially faulting insn + 1
- * and in fixup the routine which should handle the fault.
- * That fixup code will get
- * (faulting_insn_address - first_insn_in_the_range_address)/4
- * in %g2 (ie. index of the faulting instruction in the range).
- */
-
-struct exception_table_entry
-{
-        unsigned long insn, fixup;
-};
-
-/* Returns 0 if exception not found and fixup otherwise.  */
-unsigned long search_extables_range(unsigned long addr, unsigned long *g2);
-
 /* Uh, these should become the main single-value transfer routines..
  * They automatically use the right size if we just have the right
  * pointer type..
@@ -252,12 +219,7 @@ static inline unsigned long __clear_user(void __user *addr, unsigned long size)
        unsigned long ret;
 
        __asm__ __volatile__ (
-               ".section __ex_table,#alloc\n\t"
-               ".align 4\n\t"
-               ".word 1f,3\n\t"
-               ".previous\n\t"
                "mov %2, %%o1\n"
-               "1:\n\t"
                "call __bzero\n\t"
                " mov %1, %%o0\n\t"
                "mov %%o0, %0\n"
index 698cf69f74e9984d54bca056bcd6470df7b88c1e..30eb4c6414d1baf9ae792726bf8c652d6085e61e 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/string.h>
 #include <asm/asi.h>
 #include <asm/spitfire.h>
-#include <asm/extable_64.h>
 
 #include <asm/processor.h>
 
index be30c8d4cc7373490ed5f8c2ff716aae22f56574..6044b82b976751a8ccbe43ac424bafe8de36af42 100644 (file)
@@ -515,7 +515,7 @@ continue_boot:
 
                /* I want a kernel stack NOW! */
                set     init_thread_union, %g1
-               set     (THREAD_SIZE - STACKFRAME_SZ), %g2
+               set     (THREAD_SIZE - STACKFRAME_SZ - TRACEREG_SZ), %g2
                add     %g1, %g2, %sp
                mov     0, %fp                  /* And for good luck */
 
index c5ff2472b3d9d4e53385da0536802b387f123f75..72a5bdc833ea22f0800663c354cba188fad83243 100644 (file)
@@ -706,7 +706,7 @@ tlb_fixup_done:
        wr      %g0, ASI_P, %asi
        mov     1, %g1
        sllx    %g1, THREAD_SHIFT, %g1
-       sub     %g1, (STACKFRAME_SZ + STACK_BIAS), %g1
+       sub     %g1, (STACKFRAME_SZ + STACK_BIAS + TRACEREG_SZ), %g1
        add     %g6, %g1, %sp
 
        /* Set per-cpu pointer initially to zero, this makes
index b91e88058e0ce39675eb095c9c4876e4ea44ad97..3b9794978e5bc97c3cc4c536dc43e2dacb6d5a58 100644 (file)
@@ -216,16 +216,6 @@ void flush_thread(void)
                clear_thread_flag(TIF_USEDFPU);
 #endif
        }
-
-       /* This task is no longer a kernel thread. */
-       if (current->thread.flags & SPARC_FLAG_KTHREAD) {
-               current->thread.flags &= ~SPARC_FLAG_KTHREAD;
-
-               /* We must fixup kregs as well. */
-               /* XXX This was not fixed for ti for a while, worked. Unused? */
-               current->thread.kregs = (struct pt_regs *)
-                   (task_stack_page(current) + (THREAD_SIZE - TRACEREG_SZ));
-       }
 }
 
 static inline struct sparc_stackf __user *
@@ -313,7 +303,6 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, unsigned long arg,
                extern int nwindows;
                unsigned long psr;
                memset(new_stack, 0, STACKFRAME_SZ + TRACEREG_SZ);
-               p->thread.flags |= SPARC_FLAG_KTHREAD;
                p->thread.current_ds = KERNEL_DS;
                ti->kpc = (((unsigned long) ret_from_kernel_thread) - 0x8);
                childregs->u_regs[UREG_G1] = sp; /* function */
@@ -325,7 +314,6 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, unsigned long arg,
        }
        memcpy(new_stack, (char *)regs - STACKFRAME_SZ, STACKFRAME_SZ + TRACEREG_SZ);
        childregs->u_regs[UREG_FP] = sp;
-       p->thread.flags &= ~SPARC_FLAG_KTHREAD;
        p->thread.current_ds = USER_DS;
        ti->kpc = (((unsigned long) ret_from_fork) - 0x8);
        ti->kpsr = current->thread.fork_kpsr | PSR_PIL;
index eea43a1aef1b9a6fd1e4139dbf118d8e4eafc2ee..c8e0dd99f3700e73851878ca44102f1c7d24fe8f 100644 (file)
@@ -266,7 +266,6 @@ static __init void leon_patch(void)
 }
 
 struct tt_entry *sparc_ttable;
-static struct pt_regs fake_swapper_regs;
 
 /* Called from head_32.S - before we have setup anything
  * in the kernel. Be very careful with what you do here.
@@ -363,8 +362,6 @@ void __init setup_arch(char **cmdline_p)
                (*(linux_dbvec->teach_debugger))();
        }
 
-       init_task.thread.kregs = &fake_swapper_regs;
-
        /* Run-time patch instructions to match the cpu model */
        per_cpu_patch();
 
index d87244197d5cbb56fec92223c3b5c7ead0352b63..48abee4eee29d8589d9452029f109e102f63f91a 100644 (file)
@@ -165,8 +165,6 @@ extern int root_mountflags;
 
 char reboot_command[COMMAND_LINE_SIZE];
 
-static struct pt_regs fake_swapper_regs = { { 0, }, 0, 0, 0, 0 };
-
 static void __init per_cpu_patch(void)
 {
        struct cpuid_patch_entry *p;
@@ -661,8 +659,6 @@ void __init setup_arch(char **cmdline_p)
        rd_image_start = ram_flags & RAMDISK_IMAGE_START_MASK;
 #endif
 
-       task_thread_info(&init_task)->kregs = &fake_swapper_regs;
-
 #ifdef CONFIG_IP_PNP
        if (!ic_set_manually) {
                phandle chosen = prom_finddevice("/chosen");
index d92e5eaa4c1d704be7115f3ab23785153fde1194..a850dccd78ea19c8a9e30f9140884d3d0091b82a 100644 (file)
@@ -275,14 +275,13 @@ bool is_no_fault_exception(struct pt_regs *regs)
                        asi = (regs->tstate >> 24); /* saved %asi       */
                else
                        asi = (insn >> 5);          /* immediate asi    */
-               if ((asi & 0xf2) == ASI_PNF) {
-                       if (insn & 0x1000000) {     /* op3[5:4]=3       */
-                               handle_ldf_stq(insn, regs);
-                               return true;
-                       } else if (insn & 0x200000) { /* op3[2], stores */
+               if ((asi & 0xf6) == ASI_PNF) {
+                       if (insn & 0x200000)        /* op3[2], stores   */
                                return false;
-                       }
-                       handle_ld_nf(insn, regs);
+                       if (insn & 0x1000000)       /* op3[5:4]=3 (fp)  */
+                               handle_ldf_stq(insn, regs);
+                       else
+                               handle_ld_nf(insn, regs);
                        return true;
                }
        }
index 83db94c0b43189e4c938d30878368ee2cbf41c08..ef5c5207c9ffbbee5ef2b339cb0d073d1cc55d2a 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/uaccess.h>
 #include <linux/smp.h>
 #include <linux/perf_event.h>
+#include <linux/extable.h>
 
 #include <asm/setup.h>
 
@@ -213,10 +214,10 @@ static inline int ok_for_kernel(unsigned int insn)
 
 static void kernel_mna_trap_fault(struct pt_regs *regs, unsigned int insn)
 {
-       unsigned long g2 = regs->u_regs [UREG_G2];
-       unsigned long fixup = search_extables_range(regs->pc, &g2);
+       const struct exception_table_entry *entry;
 
-       if (!fixup) {
+       entry = search_exception_tables(regs->pc);
+       if (!entry) {
                unsigned long address = compute_effective_address(regs, insn);
                if(address < PAGE_SIZE) {
                        printk(KERN_ALERT "Unable to handle kernel NULL pointer dereference in mna handler");
@@ -232,9 +233,8 @@ static void kernel_mna_trap_fault(struct pt_regs *regs, unsigned int insn)
                die_if_kernel("Oops", regs);
                /* Not reached */
        }
-       regs->pc = fixup;
+       regs->pc = entry->fixup;
        regs->npc = regs->pc + 4;
-       regs->u_regs [UREG_G2] = g2;
 }
 
 asmlinkage void kernel_unaligned_trap(struct pt_regs *regs, unsigned int insn)
@@ -274,103 +274,9 @@ asmlinkage void kernel_unaligned_trap(struct pt_regs *regs, unsigned int insn)
        }
 }
 
-static inline int ok_for_user(struct pt_regs *regs, unsigned int insn,
-                             enum direction dir)
-{
-       unsigned int reg;
-       int size = ((insn >> 19) & 3) == 3 ? 8 : 4;
-
-       if ((regs->pc | regs->npc) & 3)
-               return 0;
-
-       /* Must access_ok() in all the necessary places. */
-#define WINREG_ADDR(regnum) \
-       ((void __user *)(((unsigned long *)regs->u_regs[UREG_FP])+(regnum)))
-
-       reg = (insn >> 25) & 0x1f;
-       if (reg >= 16) {
-               if (!access_ok(WINREG_ADDR(reg - 16), size))
-                       return -EFAULT;
-       }
-       reg = (insn >> 14) & 0x1f;
-       if (reg >= 16) {
-               if (!access_ok(WINREG_ADDR(reg - 16), size))
-                       return -EFAULT;
-       }
-       if (!(insn & 0x2000)) {
-               reg = (insn & 0x1f);
-               if (reg >= 16) {
-                       if (!access_ok(WINREG_ADDR(reg - 16), size))
-                               return -EFAULT;
-               }
-       }
-#undef WINREG_ADDR
-       return 0;
-}
-
-static void user_mna_trap_fault(struct pt_regs *regs, unsigned int insn)
+asmlinkage void user_unaligned_trap(struct pt_regs *regs, unsigned int insn)
 {
        send_sig_fault(SIGBUS, BUS_ADRALN,
                       (void __user *)safe_compute_effective_address(regs, insn),
                       0, current);
 }
-
-asmlinkage void user_unaligned_trap(struct pt_regs *regs, unsigned int insn)
-{
-       enum direction dir;
-
-       if(!(current->thread.flags & SPARC_FLAG_UNALIGNED) ||
-          (((insn >> 30) & 3) != 3))
-               goto kill_user;
-       dir = decode_direction(insn);
-       if(!ok_for_user(regs, insn, dir)) {
-               goto kill_user;
-       } else {
-               int err, size = decode_access_size(insn);
-               unsigned long addr;
-
-               if(floating_point_load_or_store_p(insn)) {
-                       printk("User FPU load/store unaligned unsupported.\n");
-                       goto kill_user;
-               }
-
-               addr = compute_effective_address(regs, insn);
-               perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, regs, addr);
-               switch(dir) {
-               case load:
-                       err = do_int_load(fetch_reg_addr(((insn>>25)&0x1f),
-                                                        regs),
-                                         size, (unsigned long *) addr,
-                                         decode_signedness(insn));
-                       break;
-
-               case store:
-                       err = do_int_store(((insn>>25)&0x1f), size,
-                                          (unsigned long *) addr, regs);
-                       break;
-
-               case both:
-                       /*
-                        * This was supported in 2.4. However, we question
-                        * the value of SWAP instruction across word boundaries.
-                        */
-                       printk("Unaligned SWAP unsupported.\n");
-                       err = -EFAULT;
-                       break;
-
-               default:
-                       unaligned_panic("Impossible user unaligned trap.");
-                       goto out;
-               }
-               if (err)
-                       goto kill_user;
-               else
-                       advance(regs);
-               goto out;
-       }
-
-kill_user:
-       user_mna_trap_fault(regs, insn);
-out:
-       ;
-}
index 7488d130faf730d6e96414ce987ff4a5e8b37ca6..781e39b3c009f9b27e886f6a6e07e6d2f5545108 100644 (file)
@@ -155,13 +155,6 @@ cpout:     retl                                            ! get outta here
         .text;                                  \
         .align  4
 
-#define EXT(start,end)                         \
-        .section __ex_table,ALLOC;             \
-        .align  4;                              \
-        .word   start, 0, end, cc_fault;         \
-        .text;                                  \
-        .align  4
-
        /* This aligned version executes typically in 8.5 superscalar cycles, this
         * is the best I can do.  I say 8.5 because the final add will pair with
         * the next ldd in the main unrolled loop.  Thus the pipe is always full.
@@ -169,20 +162,20 @@ cpout:    retl                                            ! get outta here
         * please check the fixup code below as well.
         */
 #define CSUMCOPY_BIGCHUNK_ALIGNED(src, dst, sum, off, t0, t1, t2, t3, t4, t5, t6, t7)  \
-       ldd     [src + off + 0x00], t0;                                                 \
-       ldd     [src + off + 0x08], t2;                                                 \
+       EX(ldd  [src + off + 0x00], t0);                                                \
+       EX(ldd  [src + off + 0x08], t2);                                                \
        addxcc  t0, sum, sum;                                                           \
-       ldd     [src + off + 0x10], t4;                                                 \
+       EX(ldd  [src + off + 0x10], t4);                                                \
        addxcc  t1, sum, sum;                                                           \
-       ldd     [src + off + 0x18], t6;                                                 \
+       EX(ldd  [src + off + 0x18], t6);                                                \
        addxcc  t2, sum, sum;                                                           \
-       std     t0, [dst + off + 0x00];                                                 \
+       EX(std  t0, [dst + off + 0x00]);                                                \
        addxcc  t3, sum, sum;                                                           \
-       std     t2, [dst + off + 0x08];                                                 \
+       EX(std  t2, [dst + off + 0x08]);                                                \
        addxcc  t4, sum, sum;                                                           \
-       std     t4, [dst + off + 0x10];                                                 \
+       EX(std  t4, [dst + off + 0x10]);                                                \
        addxcc  t5, sum, sum;                                                           \
-       std     t6, [dst + off + 0x18];                                                 \
+       EX(std  t6, [dst + off + 0x18]);                                                \
        addxcc  t6, sum, sum;                                                           \
        addxcc  t7, sum, sum;
 
@@ -191,39 +184,39 @@ cpout:    retl                                            ! get outta here
         * Viking MXCC into streaming mode.  Ho hum...
         */
 #define CSUMCOPY_BIGCHUNK(src, dst, sum, off, t0, t1, t2, t3, t4, t5, t6, t7)  \
-       ldd     [src + off + 0x00], t0;                                         \
-       ldd     [src + off + 0x08], t2;                                         \
-       ldd     [src + off + 0x10], t4;                                         \
-       ldd     [src + off + 0x18], t6;                                         \
-       st      t0, [dst + off + 0x00];                                         \
+       EX(ldd  [src + off + 0x00], t0);                                        \
+       EX(ldd  [src + off + 0x08], t2);                                        \
+       EX(ldd  [src + off + 0x10], t4);                                        \
+       EX(ldd  [src + off + 0x18], t6);                                        \
+       EX(st   t0, [dst + off + 0x00]);                                        \
        addxcc  t0, sum, sum;                                                   \
-       st      t1, [dst + off + 0x04];                                         \
+       EX(st   t1, [dst + off + 0x04]);                                        \
        addxcc  t1, sum, sum;                                                   \
-       st      t2, [dst + off + 0x08];                                         \
+       EX(st   t2, [dst + off + 0x08]);                                        \
        addxcc  t2, sum, sum;                                                   \
-       st      t3, [dst + off + 0x0c];                                         \
+       EX(st   t3, [dst + off + 0x0c]);                                        \
        addxcc  t3, sum, sum;                                                   \
-       st      t4, [dst + off + 0x10];                                         \
+       EX(st   t4, [dst + off + 0x10]);                                        \
        addxcc  t4, sum, sum;                                                   \
-       st      t5, [dst + off + 0x14];                                         \
+       EX(st   t5, [dst + off + 0x14]);                                        \
        addxcc  t5, sum, sum;                                                   \
-       st      t6, [dst + off + 0x18];                                         \
+       EX(st   t6, [dst + off + 0x18]);                                        \
        addxcc  t6, sum, sum;                                                   \
-       st      t7, [dst + off + 0x1c];                                         \
+       EX(st   t7, [dst + off + 0x1c]);                                        \
        addxcc  t7, sum, sum;
 
        /* Yuck, 6 superscalar cycles... */
 #define CSUMCOPY_LASTCHUNK(src, dst, sum, off, t0, t1, t2, t3) \
-       ldd     [src - off - 0x08], t0;                         \
-       ldd     [src - off - 0x00], t2;                         \
+       EX(ldd  [src - off - 0x08], t0);                        \
+       EX(ldd  [src - off - 0x00], t2);                        \
        addxcc  t0, sum, sum;                                   \
-       st      t0, [dst - off - 0x08];                         \
+       EX(st   t0, [dst - off - 0x08]);                        \
        addxcc  t1, sum, sum;                                   \
-       st      t1, [dst - off - 0x04];                         \
+       EX(st   t1, [dst - off - 0x04]);                        \
        addxcc  t2, sum, sum;                                   \
-       st      t2, [dst - off - 0x00];                         \
+       EX(st   t2, [dst - off - 0x00]);                        \
        addxcc  t3, sum, sum;                                   \
-       st      t3, [dst - off + 0x04];
+       EX(st   t3, [dst - off + 0x04]);
 
        /* Handle the end cruft code out of band for better cache patterns. */
 cc_end_cruft:
@@ -331,7 +324,6 @@ __csum_partial_copy_sparc_generic:
        CSUMCOPY_BIGCHUNK(%o0,%o1,%g7,0x20,%o4,%o5,%g2,%g3,%g4,%g5,%o2,%o3)
        CSUMCOPY_BIGCHUNK(%o0,%o1,%g7,0x40,%o4,%o5,%g2,%g3,%g4,%g5,%o2,%o3)
        CSUMCOPY_BIGCHUNK(%o0,%o1,%g7,0x60,%o4,%o5,%g2,%g3,%g4,%g5,%o2,%o3)
-10:    EXT(5b, 10b)                    ! note for exception handling
        sub     %g1, 128, %g1           ! detract from length
        addx    %g0, %g7, %g7           ! add in last carry bit
        andcc   %g1, 0xffffff80, %g0    ! more to csum?
@@ -356,8 +348,7 @@ cctbl:      CSUMCOPY_LASTCHUNK(%o0,%o1,%g7,0x68,%g2,%g3,%g4,%g5)
        CSUMCOPY_LASTCHUNK(%o0,%o1,%g7,0x28,%g2,%g3,%g4,%g5)
        CSUMCOPY_LASTCHUNK(%o0,%o1,%g7,0x18,%g2,%g3,%g4,%g5)
        CSUMCOPY_LASTCHUNK(%o0,%o1,%g7,0x08,%g2,%g3,%g4,%g5)
-12:    EXT(cctbl, 12b)                 ! note for exception table handling
-       addx    %g0, %g7, %g7
+12:    addx    %g0, %g7, %g7
        andcc   %o3, 0xf, %g0           ! check for low bits set
 ccte:  bne     cc_end_cruft            ! something left, handle it out of band
         andcc  %o3, 8, %g0             ! begin checks for that code
@@ -367,7 +358,6 @@ ccdbl:      CSUMCOPY_BIGCHUNK_ALIGNED(%o0,%o1,%g7,0x00,%o4,%o5,%g2,%g3,%g4,%g5,%o2,%o
        CSUMCOPY_BIGCHUNK_ALIGNED(%o0,%o1,%g7,0x20,%o4,%o5,%g2,%g3,%g4,%g5,%o2,%o3)
        CSUMCOPY_BIGCHUNK_ALIGNED(%o0,%o1,%g7,0x40,%o4,%o5,%g2,%g3,%g4,%g5,%o2,%o3)
        CSUMCOPY_BIGCHUNK_ALIGNED(%o0,%o1,%g7,0x60,%o4,%o5,%g2,%g3,%g4,%g5,%o2,%o3)
-11:    EXT(ccdbl, 11b)                 ! note for exception table handling
        sub     %g1, 128, %g1           ! detract from length
        addx    %g0, %g7, %g7           ! add in last carry bit
        andcc   %g1, 0xffffff80, %g0    ! more to csum?
index dc72f2b970b7b3328b0ccc1566c2d64951669abf..954572c78539aeff5a84fedd211d3dfb4465bfea 100644 (file)
 /* Work around cpp -rob */
 #define ALLOC #alloc
 #define EXECINSTR #execinstr
+
+#define EX_ENTRY(l1, l2)                       \
+       .section __ex_table,ALLOC;              \
+       .align  4;                              \
+       .word   l1, l2;                         \
+       .text;
+
 #define EX(x,y,a,b)                            \
 98:    x,y;                                    \
        .section .fixup,ALLOC,EXECINSTR;        \
        .align  4;                              \
-99:    ba fixupretl;                           \
-        a, b, %g3;                             \
-       .section __ex_table,ALLOC;              \
-       .align  4;                              \
-       .word   98b, 99b;                       \
-       .text;                                  \
-       .align  4
+99:    retl;                                   \
+        a, b, %o0;                             \
+       EX_ENTRY(98b, 99b)
 
 #define EX2(x,y,c,d,e,a,b)                     \
 98:    x,y;                                    \
        .section .fixup,ALLOC,EXECINSTR;        \
        .align  4;                              \
 99:    c, d, e;                                \
-       ba fixupretl;                           \
-        a, b, %g3;                             \
-       .section __ex_table,ALLOC;              \
-       .align  4;                              \
-       .word   98b, 99b;                       \
-       .text;                                  \
-       .align  4
+       retl;                                   \
+        a, b, %o0;                             \
+       EX_ENTRY(98b, 99b)
 
 #define EXO2(x,y)                              \
 98:    x, y;                                   \
-       .section __ex_table,ALLOC;              \
-       .align  4;                              \
-       .word   98b, 97f;                       \
-       .text;                                  \
-       .align  4
+       EX_ENTRY(98b, 97f)
 
-#define EXT(start,end,handler)                 \
-       .section __ex_table,ALLOC;              \
-       .align  4;                              \
-       .word   start, 0, end, handler;         \
-       .text;                                  \
-       .align  4
+#define LD(insn, src, offset, reg, label)      \
+98:    insn [%src + (offset)], %reg;           \
+       .section .fixup,ALLOC,EXECINSTR;        \
+99:    ba      label;                          \
+        mov    offset, %g5;                    \
+       EX_ENTRY(98b, 99b)
 
-/* Please do not change following macros unless you change logic used
- * in .fixup at the end of this file as well
- */
+#define ST(insn, dst, offset, reg, label)      \
+98:    insn %reg, [%dst + (offset)];           \
+       .section .fixup,ALLOC,EXECINSTR;        \
+99:    ba      label;                          \
+        mov    offset, %g5;                    \
+       EX_ENTRY(98b, 99b)
 
 /* Both these macros have to start with exactly the same insn */
+/* left: g7 + (g1 % 128) - offset */
 #define MOVE_BIGCHUNK(src, dst, offset, t0, t1, t2, t3, t4, t5, t6, t7) \
-       ldd     [%src + (offset) + 0x00], %t0; \
-       ldd     [%src + (offset) + 0x08], %t2; \
-       ldd     [%src + (offset) + 0x10], %t4; \
-       ldd     [%src + (offset) + 0x18], %t6; \
-       st      %t0, [%dst + (offset) + 0x00]; \
-       st      %t1, [%dst + (offset) + 0x04]; \
-       st      %t2, [%dst + (offset) + 0x08]; \
-       st      %t3, [%dst + (offset) + 0x0c]; \
-       st      %t4, [%dst + (offset) + 0x10]; \
-       st      %t5, [%dst + (offset) + 0x14]; \
-       st      %t6, [%dst + (offset) + 0x18]; \
-       st      %t7, [%dst + (offset) + 0x1c];
-
+       LD(ldd, src, offset + 0x00, t0, bigchunk_fault) \
+       LD(ldd, src, offset + 0x08, t2, bigchunk_fault) \
+       LD(ldd, src, offset + 0x10, t4, bigchunk_fault) \
+       LD(ldd, src, offset + 0x18, t6, bigchunk_fault) \
+       ST(st, dst, offset + 0x00, t0, bigchunk_fault)  \
+       ST(st, dst, offset + 0x04, t1, bigchunk_fault)  \
+       ST(st, dst, offset + 0x08, t2, bigchunk_fault)  \
+       ST(st, dst, offset + 0x0c, t3, bigchunk_fault)  \
+       ST(st, dst, offset + 0x10, t4, bigchunk_fault)  \
+       ST(st, dst, offset + 0x14, t5, bigchunk_fault)  \
+       ST(st, dst, offset + 0x18, t6, bigchunk_fault)  \
+       ST(st, dst, offset + 0x1c, t7, bigchunk_fault)
+
+/* left: g7 + (g1 % 128) - offset */
 #define MOVE_BIGALIGNCHUNK(src, dst, offset, t0, t1, t2, t3, t4, t5, t6, t7) \
-       ldd     [%src + (offset) + 0x00], %t0; \
-       ldd     [%src + (offset) + 0x08], %t2; \
-       ldd     [%src + (offset) + 0x10], %t4; \
-       ldd     [%src + (offset) + 0x18], %t6; \
-       std     %t0, [%dst + (offset) + 0x00]; \
-       std     %t2, [%dst + (offset) + 0x08]; \
-       std     %t4, [%dst + (offset) + 0x10]; \
-       std     %t6, [%dst + (offset) + 0x18];
+       LD(ldd, src, offset + 0x00, t0, bigchunk_fault) \
+       LD(ldd, src, offset + 0x08, t2, bigchunk_fault) \
+       LD(ldd, src, offset + 0x10, t4, bigchunk_fault) \
+       LD(ldd, src, offset + 0x18, t6, bigchunk_fault) \
+       ST(std, dst, offset + 0x00, t0, bigchunk_fault) \
+       ST(std, dst, offset + 0x08, t2, bigchunk_fault) \
+       ST(std, dst, offset + 0x10, t4, bigchunk_fault) \
+       ST(std, dst, offset + 0x18, t6, bigchunk_fault)
 
+       .section .fixup,#alloc,#execinstr
+bigchunk_fault:
+       sub     %g7, %g5, %o0
+       and     %g1, 127, %g1
+       retl
+        add    %o0, %g1, %o0
+
+/* left: offset + 16 + (g1 % 16) */
 #define MOVE_LASTCHUNK(src, dst, offset, t0, t1, t2, t3) \
-       ldd     [%src - (offset) - 0x10], %t0; \
-       ldd     [%src - (offset) - 0x08], %t2; \
-       st      %t0, [%dst - (offset) - 0x10]; \
-       st      %t1, [%dst - (offset) - 0x0c]; \
-       st      %t2, [%dst - (offset) - 0x08]; \
-       st      %t3, [%dst - (offset) - 0x04];
+       LD(ldd, src, -(offset + 0x10), t0, lastchunk_fault)     \
+       LD(ldd, src, -(offset + 0x08), t2, lastchunk_fault)     \
+       ST(st, dst, -(offset + 0x10), t0, lastchunk_fault)      \
+       ST(st, dst, -(offset + 0x0c), t1, lastchunk_fault)      \
+       ST(st, dst, -(offset + 0x08), t2, lastchunk_fault)      \
+       ST(st, dst, -(offset + 0x04), t3, lastchunk_fault)
 
-#define MOVE_HALFCHUNK(src, dst, offset, t0, t1, t2, t3) \
-       lduh    [%src + (offset) + 0x00], %t0; \
-       lduh    [%src + (offset) + 0x02], %t1; \
-       lduh    [%src + (offset) + 0x04], %t2; \
-       lduh    [%src + (offset) + 0x06], %t3; \
-       sth     %t0, [%dst + (offset) + 0x00]; \
-       sth     %t1, [%dst + (offset) + 0x02]; \
-       sth     %t2, [%dst + (offset) + 0x04]; \
-       sth     %t3, [%dst + (offset) + 0x06];
+       .section .fixup,#alloc,#execinstr
+lastchunk_fault:
+       and     %g1, 15, %g1
+       retl
+        sub    %g1, %g5, %o0
 
+/* left: o3 + (o2 % 16) - offset */
+#define MOVE_HALFCHUNK(src, dst, offset, t0, t1, t2, t3) \
+       LD(lduh, src, offset + 0x00, t0, halfchunk_fault)       \
+       LD(lduh, src, offset + 0x02, t1, halfchunk_fault)       \
+       LD(lduh, src, offset + 0x04, t2, halfchunk_fault)       \
+       LD(lduh, src, offset + 0x06, t3, halfchunk_fault)       \
+       ST(sth, dst, offset + 0x00, t0, halfchunk_fault)        \
+       ST(sth, dst, offset + 0x02, t1, halfchunk_fault)        \
+       ST(sth, dst, offset + 0x04, t2, halfchunk_fault)        \
+       ST(sth, dst, offset + 0x06, t3, halfchunk_fault)
+
+/* left: o3 + (o2 % 16) + offset + 2 */
 #define MOVE_SHORTCHUNK(src, dst, offset, t0, t1) \
-       ldub    [%src - (offset) - 0x02], %t0; \
-       ldub    [%src - (offset) - 0x01], %t1; \
-       stb     %t0, [%dst - (offset) - 0x02]; \
-       stb     %t1, [%dst - (offset) - 0x01];
+       LD(ldub, src, -(offset + 0x02), t0, halfchunk_fault)    \
+       LD(ldub, src, -(offset + 0x01), t1, halfchunk_fault)    \
+       ST(stb, dst, -(offset + 0x02), t0, halfchunk_fault)     \
+       ST(stb, dst, -(offset + 0x01), t1, halfchunk_fault)
+
+       .section .fixup,#alloc,#execinstr
+halfchunk_fault:
+       and     %o2, 15, %o2
+       sub     %o3, %g5, %o3
+       retl
+        add    %o2, %o3, %o0
+
+/* left: offset + 2 + (o2 % 2) */
+#define MOVE_LAST_SHORTCHUNK(src, dst, offset, t0, t1) \
+       LD(ldub, src, -(offset + 0x02), t0, last_shortchunk_fault)      \
+       LD(ldub, src, -(offset + 0x01), t1, last_shortchunk_fault)      \
+       ST(stb, dst, -(offset + 0x02), t0, last_shortchunk_fault)       \
+       ST(stb, dst, -(offset + 0x01), t1, last_shortchunk_fault)
+
+       .section .fixup,#alloc,#execinstr
+last_shortchunk_fault:
+       and     %o2, 1, %o2
+       retl
+        sub    %o2, %g5, %o0
 
        .text
        .align  4
@@ -182,8 +218,6 @@ __copy_user:        /* %o0=dst %o1=src %o2=len */
        MOVE_BIGCHUNK(o1, o0, 0x20, o2, o3, o4, o5, g2, g3, g4, g5)
        MOVE_BIGCHUNK(o1, o0, 0x40, o2, o3, o4, o5, g2, g3, g4, g5)
        MOVE_BIGCHUNK(o1, o0, 0x60, o2, o3, o4, o5, g2, g3, g4, g5)
-80:
-       EXT(5b, 80b, 50f)
        subcc   %g7, 128, %g7
        add     %o1, 128, %o1
        bne     5b
@@ -201,7 +235,6 @@ __copy_user:        /* %o0=dst %o1=src %o2=len */
        jmpl    %o5 + %lo(copy_user_table_end), %g0
         add    %o0, %g7, %o0
 
-copy_user_table:
        MOVE_LASTCHUNK(o1, o0, 0x60, g2, g3, g4, g5)
        MOVE_LASTCHUNK(o1, o0, 0x50, g2, g3, g4, g5)
        MOVE_LASTCHUNK(o1, o0, 0x40, g2, g3, g4, g5)
@@ -210,7 +243,6 @@ copy_user_table:
        MOVE_LASTCHUNK(o1, o0, 0x10, g2, g3, g4, g5)
        MOVE_LASTCHUNK(o1, o0, 0x00, g2, g3, g4, g5)
 copy_user_table_end:
-       EXT(copy_user_table, copy_user_table_end, 51f)
        be      copy_user_last7
         andcc  %g1, 4, %g0
 
@@ -250,8 +282,6 @@ ldd_std:
        MOVE_BIGALIGNCHUNK(o1, o0, 0x20, o2, o3, o4, o5, g2, g3, g4, g5)
        MOVE_BIGALIGNCHUNK(o1, o0, 0x40, o2, o3, o4, o5, g2, g3, g4, g5)
        MOVE_BIGALIGNCHUNK(o1, o0, 0x60, o2, o3, o4, o5, g2, g3, g4, g5)
-81:
-       EXT(ldd_std, 81b, 52f)
        subcc   %g7, 128, %g7
        add     %o1, 128, %o1
        bne     ldd_std
@@ -290,8 +320,6 @@ cannot_optimize:
 10:
        MOVE_HALFCHUNK(o1, o0, 0x00, g2, g3, g4, g5)
        MOVE_HALFCHUNK(o1, o0, 0x08, g2, g3, g4, g5)
-82:
-       EXT(10b, 82b, 53f)
        subcc   %o3, 0x10, %o3
        add     %o1, 0x10, %o1
        bne     10b
@@ -308,8 +336,6 @@ byte_chunk:
        MOVE_SHORTCHUNK(o1, o0, -0x0c, g2, g3)
        MOVE_SHORTCHUNK(o1, o0, -0x0e, g2, g3)
        MOVE_SHORTCHUNK(o1, o0, -0x10, g2, g3)
-83:
-       EXT(byte_chunk, 83b, 54f)
        subcc   %o3, 0x10, %o3
        add     %o1, 0x10, %o1
        bne     byte_chunk
@@ -325,16 +351,14 @@ short_end:
        add     %o1, %o3, %o1
        jmpl    %o5 + %lo(short_table_end), %g0
         andcc  %o2, 1, %g0
-84:
-       MOVE_SHORTCHUNK(o1, o0, 0x0c, g2, g3)
-       MOVE_SHORTCHUNK(o1, o0, 0x0a, g2, g3)
-       MOVE_SHORTCHUNK(o1, o0, 0x08, g2, g3)
-       MOVE_SHORTCHUNK(o1, o0, 0x06, g2, g3)
-       MOVE_SHORTCHUNK(o1, o0, 0x04, g2, g3)
-       MOVE_SHORTCHUNK(o1, o0, 0x02, g2, g3)
-       MOVE_SHORTCHUNK(o1, o0, 0x00, g2, g3)
+       MOVE_LAST_SHORTCHUNK(o1, o0, 0x0c, g2, g3)
+       MOVE_LAST_SHORTCHUNK(o1, o0, 0x0a, g2, g3)
+       MOVE_LAST_SHORTCHUNK(o1, o0, 0x08, g2, g3)
+       MOVE_LAST_SHORTCHUNK(o1, o0, 0x06, g2, g3)
+       MOVE_LAST_SHORTCHUNK(o1, o0, 0x04, g2, g3)
+       MOVE_LAST_SHORTCHUNK(o1, o0, 0x02, g2, g3)
+       MOVE_LAST_SHORTCHUNK(o1, o0, 0x00, g2, g3)
 short_table_end:
-       EXT(84b, short_table_end, 55f)
        be      1f
         nop
        EX(ldub [%o1], %g2, add %g0, 1)
@@ -363,123 +387,8 @@ short_aligned_end:
        .section .fixup,#alloc,#execinstr
        .align  4
 97:
-       mov     %o2, %g3
-fixupretl:
        retl
-        mov    %g3, %o0
-
-/* exception routine sets %g2 to (broken_insn - first_insn)>>2 */
-50:
-/* This magic counts how many bytes are left when crash in MOVE_BIGCHUNK
- * happens. This is derived from the amount ldd reads, st stores, etc.
- * x = g2 % 12;
- * g3 = g1 + g7 - ((g2 / 12) * 32 + (x < 4) ? 0 : (x - 4) * 4);
- * o0 += (g2 / 12) * 32;
- */
-       cmp     %g2, 12
-       add     %o0, %g7, %o0
-       bcs     1f
-        cmp    %g2, 24
-       bcs     2f
-        cmp    %g2, 36
-       bcs     3f
-        nop
-       sub     %g2, 12, %g2
-       sub     %g7, 32, %g7
-3:     sub     %g2, 12, %g2
-       sub     %g7, 32, %g7
-2:     sub     %g2, 12, %g2
-       sub     %g7, 32, %g7
-1:     cmp     %g2, 4
-       bcs,a   60f
-        clr    %g2
-       sub     %g2, 4, %g2
-       sll     %g2, 2, %g2
-60:    and     %g1, 0x7f, %g3
-       sub     %o0, %g7, %o0
-       add     %g3, %g7, %g3
-       ba      fixupretl
-        sub    %g3, %g2, %g3
-51:
-/* i = 41 - g2; j = i % 6;
- * g3 = (g1 & 15) + (i / 6) * 16 + (j < 4) ? (j + 1) * 4 : 16;
- * o0 -= (i / 6) * 16 + 16;
- */
-       neg     %g2
-       and     %g1, 0xf, %g1
-       add     %g2, 41, %g2
-       add     %o0, %g1, %o0
-1:     cmp     %g2, 6
-       bcs,a   2f
-        cmp    %g2, 4
-       add     %g1, 16, %g1
-       b       1b
-        sub    %g2, 6, %g2
-2:     bcc,a   2f
-        mov    16, %g2
-       inc     %g2
-       sll     %g2, 2, %g2
-2:     add     %g1, %g2, %g3
-       ba      fixupretl
-        sub    %o0, %g3, %o0
-52:
-/* g3 = g1 + g7 - (g2 / 8) * 32 + (g2 & 4) ? (g2 & 3) * 8 : 0;
-   o0 += (g2 / 8) * 32 */
-       andn    %g2, 7, %g4
-       add     %o0, %g7, %o0
-       andcc   %g2, 4, %g0
-       and     %g2, 3, %g2
-       sll     %g4, 2, %g4
-       sll     %g2, 3, %g2
-       bne     60b
-        sub    %g7, %g4, %g7
-       ba      60b
-        clr    %g2
-53:
-/* g3 = o3 + (o2 & 15) - (g2 & 8) - (g2 & 4) ? (g2 & 3) * 2 : 0;
-   o0 += (g2 & 8) */
-       and     %g2, 3, %g4
-       andcc   %g2, 4, %g0
-       and     %g2, 8, %g2
-       sll     %g4, 1, %g4
-       be      1f
-        add    %o0, %g2, %o0
-       add     %g2, %g4, %g2
-1:     and     %o2, 0xf, %g3
-       add     %g3, %o3, %g3
-       ba      fixupretl
-        sub    %g3, %g2, %g3
-54:
-/* g3 = o3 + (o2 & 15) - (g2 / 4) * 2 - (g2 & 2) ? (g2 & 1) : 0;
-   o0 += (g2 / 4) * 2 */
-       srl     %g2, 2, %o4
-       and     %g2, 1, %o5
-       srl     %g2, 1, %g2
-       add     %o4, %o4, %o4
-       and     %o5, %g2, %o5
-       and     %o2, 0xf, %o2
-       add     %o0, %o4, %o0
-       sub     %o3, %o5, %o3
-       sub     %o2, %o4, %o2
-       ba      fixupretl
-        add    %o2, %o3, %g3
-55:
-/* i = 27 - g2;
-   g3 = (o2 & 1) + i / 4 * 2 + !(i & 3);
-   o0 -= i / 4 * 2 + 1 */
-       neg     %g2
-       and     %o2, 1, %o2
-       add     %g2, 27, %g2
-       srl     %g2, 2, %o5
-       andcc   %g2, 3, %g0
-       mov     1, %g2
-       add     %o5, %o5, %o5
-       be,a    1f
-        clr    %g2
-1:     add     %g2, %o5, %g3
-       sub     %o0, %g3, %o0
-       ba      fixupretl
-        add    %g3, %o2, %g3
+        mov    %o2, %o0
 
        .globl  __copy_user_end
 __copy_user_end:
index f427f34b8b79bd6798fb90f756035d8f989d3909..eaff68213fdf58b86fb297d2ab844ad858da5dc0 100644 (file)
@@ -19,7 +19,7 @@
 98:    x,y;                                    \
        .section .fixup,ALLOC,EXECINSTR;        \
        .align  4;                              \
-99:    ba 30f;                                 \
+99:    retl;                                   \
         a, b, %o0;                             \
        .section __ex_table,ALLOC;              \
        .align  4;                              \
        .text;                                  \
        .align  4
 
-#define EXT(start,end,handler)                         \
+#define STORE(source, base, offset, n)         \
+98:    std source, [base + offset + n];        \
+       .section .fixup,ALLOC,EXECINSTR;        \
+       .align  4;                              \
+99:    ba 30f;                                 \
+        sub %o3, n - offset, %o3;              \
        .section __ex_table,ALLOC;              \
        .align  4;                              \
-       .word   start, 0, end, handler;         \
+       .word   98b, 99b;                       \
        .text;                                  \
-       .align  4
+       .align  4;
+
+#define STORE_LAST(source, base, offset, n)    \
+       EX(std source, [base - offset - n],     \
+          add %o1, offset + n);
 
 /* Please don't change these macros, unless you change the logic
  * in the .fixup section below as well.
  * Store 64 bytes at (BASE + OFFSET) using value SOURCE. */
-#define ZERO_BIG_BLOCK(base, offset, source)    \
-       std     source, [base + offset + 0x00]; \
-       std     source, [base + offset + 0x08]; \
-       std     source, [base + offset + 0x10]; \
-       std     source, [base + offset + 0x18]; \
-       std     source, [base + offset + 0x20]; \
-       std     source, [base + offset + 0x28]; \
-       std     source, [base + offset + 0x30]; \
-       std     source, [base + offset + 0x38];
+#define ZERO_BIG_BLOCK(base, offset, source)   \
+       STORE(source, base, offset, 0x00);      \
+       STORE(source, base, offset, 0x08);      \
+       STORE(source, base, offset, 0x10);      \
+       STORE(source, base, offset, 0x18);      \
+       STORE(source, base, offset, 0x20);      \
+       STORE(source, base, offset, 0x28);      \
+       STORE(source, base, offset, 0x30);      \
+       STORE(source, base, offset, 0x38);
 
 #define ZERO_LAST_BLOCKS(base, offset, source) \
-       std     source, [base - offset - 0x38]; \
-       std     source, [base - offset - 0x30]; \
-       std     source, [base - offset - 0x28]; \
-       std     source, [base - offset - 0x20]; \
-       std     source, [base - offset - 0x18]; \
-       std     source, [base - offset - 0x10]; \
-       std     source, [base - offset - 0x08]; \
-       std     source, [base - offset - 0x00];
+       STORE_LAST(source, base, offset, 0x38); \
+       STORE_LAST(source, base, offset, 0x30); \
+       STORE_LAST(source, base, offset, 0x28); \
+       STORE_LAST(source, base, offset, 0x20); \
+       STORE_LAST(source, base, offset, 0x18); \
+       STORE_LAST(source, base, offset, 0x10); \
+       STORE_LAST(source, base, offset, 0x08); \
+       STORE_LAST(source, base, offset, 0x00);
 
        .text
        .align 4
@@ -68,8 +77,6 @@ __bzero_begin:
        .globl  memset
        EXPORT_SYMBOL(__bzero)
        EXPORT_SYMBOL(memset)
-       .globl  __memset_start, __memset_end
-__memset_start:
 memset:
        mov     %o0, %g1
        mov     1, %g4
@@ -122,8 +129,6 @@ __bzero:
        ZERO_BIG_BLOCK(%o0, 0x00, %g2)
        subcc   %o3, 128, %o3
        ZERO_BIG_BLOCK(%o0, 0x40, %g2)
-11:
-       EXT(10b, 11b, 20f)
        bne     10b
         add    %o0, 128, %o0
 
@@ -138,11 +143,9 @@ __bzero:
        jmp     %o4
         add    %o0, %o2, %o0
 
-12:
        ZERO_LAST_BLOCKS(%o0, 0x48, %g2)
        ZERO_LAST_BLOCKS(%o0, 0x08, %g2)
 13:
-       EXT(12b, 13b, 21f)
        be      8f
         andcc  %o1, 4, %g0
 
@@ -182,37 +185,13 @@ __bzero:
 5:
        retl
         clr    %o0
-__memset_end:
 
        .section .fixup,#alloc,#execinstr
        .align  4
-20:
-       cmp     %g2, 8
-       bleu    1f
-        and    %o1, 0x7f, %o1
-       sub     %g2, 9, %g2
-       add     %o3, 64, %o3
-1:
-       sll     %g2, 3, %g2
-       add     %o3, %o1, %o0
-       b 30f
-        sub    %o0, %g2, %o0
-21:
-       mov     8, %o0
-       and     %o1, 7, %o1
-       sub     %o0, %g2, %o0
-       sll     %o0, 3, %o0
-       b 30f
-        add    %o0, %o1, %o0
 30:
-/* %o4 is faulting address, %o5 is %pc where fault occurred */
-       save    %sp, -104, %sp
-       mov     %i5, %o0
-       mov     %i7, %o1
-       call    lookup_fault
-        mov    %i4, %o2
-       ret
-        restore
+       and     %o1, 0x7f, %o1
+       retl
+        add    %o3, %o1, %o0
 
        .globl __bzero_end
 __bzero_end:
index 68db1f859b02857e979539d0b4408a6b0d26fe64..871354aa3c002b875defade17825d7600066fee4 100644 (file)
@@ -8,7 +8,7 @@ ccflags-y := -Werror
 obj-$(CONFIG_SPARC64)   += ultra.o tlb.o tsb.o
 obj-y                   += fault_$(BITS).o
 obj-y                   += init_$(BITS).o
-obj-$(CONFIG_SPARC32)   += extable.o srmmu.o iommu.o io-unit.o
+obj-$(CONFIG_SPARC32)   += srmmu.o iommu.o io-unit.o
 obj-$(CONFIG_SPARC32)   += srmmu_access.o
 obj-$(CONFIG_SPARC32)   += hypersparc.o viking.o tsunami.o swift.o
 obj-$(CONFIG_SPARC32)   += leon_mm.o
diff --git a/arch/sparc/mm/extable.c b/arch/sparc/mm/extable.c
deleted file mode 100644 (file)
index 241b406..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * linux/arch/sparc/mm/extable.c
- */
-
-#include <linux/module.h>
-#include <linux/extable.h>
-#include <linux/uaccess.h>
-
-void sort_extable(struct exception_table_entry *start,
-                 struct exception_table_entry *finish)
-{
-}
-
-/* Caller knows they are in a range if ret->fixup == 0 */
-const struct exception_table_entry *
-search_extable(const struct exception_table_entry *base,
-              const size_t num,
-              unsigned long value)
-{
-       int i;
-
-       /* Single insn entries are encoded as:
-        *      word 1: insn address
-        *      word 2: fixup code address
-        *
-        * Range entries are encoded as:
-        *      word 1: first insn address
-        *      word 2: 0
-        *      word 3: last insn address + 4 bytes
-        *      word 4: fixup code address
-        *
-        * Deleted entries are encoded as:
-        *      word 1: unused
-        *      word 2: -1
-        *
-        * See asm/uaccess.h for more details.
-        */
-
-       /* 1. Try to find an exact match. */
-       for (i = 0; i < num; i++) {
-               if (base[i].fixup == 0) {
-                       /* A range entry, skip both parts. */
-                       i++;
-                       continue;
-               }
-
-               /* A deleted entry; see trim_init_extable */
-               if (base[i].fixup == -1)
-                       continue;
-
-               if (base[i].insn == value)
-                       return &base[i];
-       }
-
-       /* 2. Try to find a range match. */
-       for (i = 0; i < (num - 1); i++) {
-               if (base[i].fixup)
-                       continue;
-
-               if (base[i].insn <= value && base[i + 1].insn > value)
-                       return &base[i];
-
-               i++;
-       }
-
-        return NULL;
-}
-
-#ifdef CONFIG_MODULES
-/* We could memmove them around; easier to mark the trimmed ones. */
-void trim_init_extable(struct module *m)
-{
-       unsigned int i;
-       bool range;
-
-       for (i = 0; i < m->num_exentries; i += range ? 2 : 1) {
-               range = m->extable[i].fixup == 0;
-
-               if (within_module_init(m->extable[i].insn, m)) {
-                       m->extable[i].fixup = -1;
-                       if (range)
-                               m->extable[i+1].fixup = -1;
-               }
-               if (range)
-                       i++;
-       }
-}
-#endif /* CONFIG_MODULES */
-
-/* Special extable search, which handles ranges.  Returns fixup */
-unsigned long search_extables_range(unsigned long addr, unsigned long *g2)
-{
-       const struct exception_table_entry *entry;
-
-       entry = search_exception_tables(addr);
-       if (!entry)
-               return 0;
-
-       /* Inside range?  Fix g2 and return correct fixup */
-       if (!entry->fixup) {
-               *g2 = (addr - entry->insn) / 4;
-               return (entry + 1)->fixup;
-       }
-
-       return entry->fixup;
-}
index 40ce087dfecf24709ea6e5a5e6694970cbac1340..de2031c2b2d7982ebe39af78654e463c1cbfc5cd 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/interrupt.h>
 #include <linux/kdebug.h>
 #include <linux/uaccess.h>
+#include <linux/extable.h>
 
 #include <asm/page.h>
 #include <asm/openprom.h>
@@ -54,54 +55,6 @@ static void __noreturn unhandled_fault(unsigned long address,
        die_if_kernel("Oops", regs);
 }
 
-asmlinkage int lookup_fault(unsigned long pc, unsigned long ret_pc,
-                           unsigned long address)
-{
-       struct pt_regs regs;
-       unsigned long g2;
-       unsigned int insn;
-       int i;
-
-       i = search_extables_range(ret_pc, &g2);
-       switch (i) {
-       case 3:
-               /* load & store will be handled by fixup */
-               return 3;
-
-       case 1:
-               /* store will be handled by fixup, load will bump out */
-               /* for _to_ macros */
-               insn = *((unsigned int *) pc);
-               if ((insn >> 21) & 1)
-                       return 1;
-               break;
-
-       case 2:
-               /* load will be handled by fixup, store will bump out */
-               /* for _from_ macros */
-               insn = *((unsigned int *) pc);
-               if (!((insn >> 21) & 1) || ((insn>>19)&0x3f) == 15)
-                       return 2;
-               break;
-
-       default:
-               break;
-       }
-
-       memset(&regs, 0, sizeof(regs));
-       regs.pc = pc;
-       regs.npc = pc + 4;
-       __asm__ __volatile__(
-               "rd %%psr, %0\n\t"
-               "nop\n\t"
-               "nop\n\t"
-               "nop\n" : "=r" (regs.psr));
-       unhandled_fault(address, current, &regs);
-
-       /* Not reached */
-       return 0;
-}
-
 static inline void
 show_signal_msg(struct pt_regs *regs, int sig, int code,
                unsigned long address, struct task_struct *tsk)
@@ -162,8 +115,6 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write,
        struct vm_area_struct *vma;
        struct task_struct *tsk = current;
        struct mm_struct *mm = tsk->mm;
-       unsigned int fixup;
-       unsigned long g2;
        int from_user = !(regs->psr & PSR_PS);
        int code;
        vm_fault_t fault;
@@ -281,30 +232,19 @@ bad_area_nosemaphore:
 
        /* Is this in ex_table? */
 no_context:
-       g2 = regs->u_regs[UREG_G2];
        if (!from_user) {
-               fixup = search_extables_range(regs->pc, &g2);
-               /* Values below 10 are reserved for other things */
-               if (fixup > 10) {
-                       extern const unsigned int __memset_start[];
-                       extern const unsigned int __memset_end[];
+               const struct exception_table_entry *entry;
 
+               entry = search_exception_tables(regs->pc);
 #ifdef DEBUG_EXCEPTIONS
-                       printk("Exception: PC<%08lx> faddr<%08lx>\n",
-                              regs->pc, address);
-                       printk("EX_TABLE: insn<%08lx> fixup<%08x> g2<%08lx>\n",
-                               regs->pc, fixup, g2);
+               printk("Exception: PC<%08lx> faddr<%08lx>\n",
+                      regs->pc, address);
+               printk("EX_TABLE: insn<%08lx> fixup<%08x>\n",
+                       regs->pc, entry->fixup);
 #endif
-                       if ((regs->pc >= (unsigned long)__memset_start &&
-                            regs->pc < (unsigned long)__memset_end)) {
-                               regs->u_regs[UREG_I4] = address;
-                               regs->u_regs[UREG_I5] = regs->pc;
-                       }
-                       regs->u_regs[UREG_G2] = g2;
-                       regs->pc = fixup;
-                       regs->npc = regs->pc + 4;
-                       return;
-               }
+               regs->pc = entry->fixup;
+               regs->npc = regs->pc + 4;
+               return;
        }
 
        unhandled_fault(address, tsk, regs);
index ce750a99eea96bb968bea7b2f4414dac752a7922..ee55f10806343aa07fa405b4452fc591c5ab22b6 100644 (file)
@@ -1,7 +1,5 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /* fault_32.c - visible as they are called from assembler */
-asmlinkage int lookup_fault(unsigned long pc, unsigned long ret_pc,
-                            unsigned long address);
 asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write,
                                unsigned long address);
 
index a2433ae8a65e764028e37e9d87bc0b0a7e93cbd0..4efd39aacb9f28366f3bbafb17f59a3ec181cbed 100644 (file)
@@ -128,7 +128,8 @@ static noinstr bool __do_fast_syscall_32(struct pt_regs *regs)
                regs->ax = -EFAULT;
 
                instrumentation_end();
-               syscall_exit_to_user_mode(regs);
+               local_irq_disable();
+               irqentry_exit_to_user_mode(regs);
                return false;
        }
 
index 541fdaf6404533bd2d2558bd0ebc426324f2c96c..0051cf5c792d1aeccb7800ba4c02b354c24f885c 100644 (file)
@@ -210,6 +210,8 @@ SYM_CODE_START(entry_SYSCALL_compat)
        /* Switch to the kernel stack */
        movq    PER_CPU_VAR(cpu_current_top_of_stack), %rsp
 
+SYM_INNER_LABEL(entry_SYSCALL_compat_safe_stack, SYM_L_GLOBAL)
+
        /* Construct struct pt_regs on stack */
        pushq   $__USER32_DS            /* pt_regs->ss */
        pushq   %r8                     /* pt_regs->sp */
index 6ddeed3cd2acb1b02de96a8d78724ecb11c2cc5d..18df1712969554ce3d58b6e65c311cfc283bfa00 100644 (file)
@@ -81,7 +81,11 @@ DEFINE_STATIC_CALL_NULL(x86_pmu_swap_task_ctx, *x86_pmu.swap_task_ctx);
 DEFINE_STATIC_CALL_NULL(x86_pmu_drain_pebs,   *x86_pmu.drain_pebs);
 DEFINE_STATIC_CALL_NULL(x86_pmu_pebs_aliases, *x86_pmu.pebs_aliases);
 
-DEFINE_STATIC_CALL_NULL(x86_pmu_guest_get_msrs,  *x86_pmu.guest_get_msrs);
+/*
+ * This one is magic, it will get called even when PMU init fails (because
+ * there is no PMU), in which case it should simply return NULL.
+ */
+DEFINE_STATIC_CALL_RET0(x86_pmu_guest_get_msrs, *x86_pmu.guest_get_msrs);
 
 u64 __read_mostly hw_cache_event_ids
                                [PERF_COUNT_HW_CACHE_MAX]
@@ -1944,13 +1948,6 @@ static void _x86_pmu_read(struct perf_event *event)
        x86_perf_event_update(event);
 }
 
-static inline struct perf_guest_switch_msr *
-perf_guest_get_msrs_nop(int *nr)
-{
-       *nr = 0;
-       return NULL;
-}
-
 static int __init init_hw_perf_events(void)
 {
        struct x86_pmu_quirk *quirk;
@@ -2025,7 +2022,7 @@ static int __init init_hw_perf_events(void)
                x86_pmu.read = _x86_pmu_read;
 
        if (!x86_pmu.guest_get_msrs)
-               x86_pmu.guest_get_msrs = perf_guest_get_msrs_nop;
+               x86_pmu.guest_get_msrs = (void *)&__static_call_return0;
 
        x86_pmu_static_call_update();
 
index 5bac48d5c18e86251f205213412052d39c6aacec..37ce38403cb8d8bd2b741337d0badd0ebaaf4542 100644 (file)
@@ -3659,11 +3659,16 @@ static int intel_pmu_hw_config(struct perf_event *event)
                return ret;
 
        if (event->attr.precise_ip) {
+               if ((event->attr.config & INTEL_ARCH_EVENT_MASK) == INTEL_FIXED_VLBR_EVENT)
+                       return -EINVAL;
+
                if (!(event->attr.freq || (event->attr.wakeup_events && !event->attr.watermark))) {
                        event->hw.flags |= PERF_X86_EVENT_AUTO_RELOAD;
                        if (!(event->attr.sample_type &
-                             ~intel_pmu_large_pebs_flags(event)))
+                             ~intel_pmu_large_pebs_flags(event))) {
                                event->hw.flags |= PERF_X86_EVENT_LARGE_PEBS;
+                               event->attach_state |= PERF_ATTACH_SCHED_CB;
+                       }
                }
                if (x86_pmu.pebs_aliases)
                        x86_pmu.pebs_aliases(event);
@@ -3676,6 +3681,7 @@ static int intel_pmu_hw_config(struct perf_event *event)
                ret = intel_pmu_setup_lbr_filter(event);
                if (ret)
                        return ret;
+               event->attach_state |= PERF_ATTACH_SCHED_CB;
 
                /*
                 * BTS is set up earlier in this path, so don't account twice
index 7ebae18264033c73293d0293504fd3439303c83e..d32b302719fe56dc7302fa49049bca7b2e06ae6e 100644 (file)
@@ -2010,7 +2010,7 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs, struct perf_sample_d
                 */
                if (!pebs_status && cpuc->pebs_enabled &&
                        !(cpuc->pebs_enabled & (cpuc->pebs_enabled-1)))
-                       pebs_status = cpuc->pebs_enabled;
+                       pebs_status = p->status = cpuc->pebs_enabled;
 
                bit = find_first_bit((unsigned long *)&pebs_status,
                                        x86_pmu.max_pebs_events);
index a0f839aa144d9eeb347247e7f79e07683b5564f8..98b4dae5e8bc8a93398682080ab180982b33280f 100644 (file)
@@ -23,6 +23,8 @@ unsigned long insn_get_seg_base(struct pt_regs *regs, int seg_reg_idx);
 int insn_get_code_seg_params(struct pt_regs *regs);
 int insn_fetch_from_user(struct pt_regs *regs,
                         unsigned char buf[MAX_INSN_SIZE]);
+int insn_fetch_from_user_inatomic(struct pt_regs *regs,
+                                 unsigned char buf[MAX_INSN_SIZE]);
 bool insn_decode(struct insn *insn, struct pt_regs *regs,
                 unsigned char buf[MAX_INSN_SIZE], int buf_size);
 
index 877a4025d8da081316f9805eede414e8a11cd5f7..3768819693e5c8a59da539b8f2907c1c75c729db 100644 (file)
@@ -884,12 +884,29 @@ struct kvm_hv_syndbg {
        u64 options;
 };
 
+/* Current state of Hyper-V TSC page clocksource */
+enum hv_tsc_page_status {
+       /* TSC page was not set up or disabled */
+       HV_TSC_PAGE_UNSET = 0,
+       /* TSC page MSR was written by the guest, update pending */
+       HV_TSC_PAGE_GUEST_CHANGED,
+       /* TSC page MSR was written by KVM userspace, update pending */
+       HV_TSC_PAGE_HOST_CHANGED,
+       /* TSC page was properly set up and is currently active  */
+       HV_TSC_PAGE_SET,
+       /* TSC page is currently being updated and therefore is inactive */
+       HV_TSC_PAGE_UPDATING,
+       /* TSC page was set up with an inaccessible GPA */
+       HV_TSC_PAGE_BROKEN,
+};
+
 /* Hyper-V emulation context */
 struct kvm_hv {
        struct mutex hv_lock;
        u64 hv_guest_os_id;
        u64 hv_hypercall;
        u64 hv_tsc_page;
+       enum hv_tsc_page_status hv_tsc_page_status;
 
        /* Hyper-v based guest crash (NT kernel bugcheck) parameters */
        u64 hv_crash_param[HV_X64_MSR_CRASH_PARAMS];
@@ -931,6 +948,12 @@ enum kvm_irqchip_mode {
        KVM_IRQCHIP_SPLIT,        /* created with KVM_CAP_SPLIT_IRQCHIP */
 };
 
+struct kvm_x86_msr_filter {
+       u8 count;
+       bool default_allow:1;
+       struct msr_bitmap_range ranges[16];
+};
+
 #define APICV_INHIBIT_REASON_DISABLE    0
 #define APICV_INHIBIT_REASON_HYPERV     1
 #define APICV_INHIBIT_REASON_NESTED     2
@@ -963,7 +986,7 @@ struct kvm_arch {
        struct kvm_pit *vpit;
        atomic_t vapics_in_nmi_mode;
        struct mutex apic_map_lock;
-       struct kvm_apic_map *apic_map;
+       struct kvm_apic_map __rcu *apic_map;
        atomic_t apic_map_dirty;
 
        bool apic_access_page_done;
@@ -1025,18 +1048,13 @@ struct kvm_arch {
        bool guest_can_read_msr_platform_info;
        bool exception_payload_enabled;
 
+       bool bus_lock_detection_enabled;
+
        /* Deflect RDMSR and WRMSR to user space when they trigger a #GP */
        u32 user_space_msr_mask;
+       struct kvm_x86_msr_filter __rcu *msr_filter;
 
-       struct {
-               u8 count;
-               bool default_allow:1;
-               struct msr_bitmap_range ranges[16];
-       } msr_filter;
-
-       bool bus_lock_detection_enabled;
-
-       struct kvm_pmu_event_filter *pmu_event_filter;
+       struct kvm_pmu_event_filter __rcu *pmu_event_filter;
        struct task_struct *nx_lpage_recovery_thread;
 
 #ifdef CONFIG_X86_64
index dc6d149bf851fa911c7c7915fbe68e39f1016b4c..f1b9ed5efaa9016275cbd520e310a8f74e1801d9 100644 (file)
@@ -551,15 +551,6 @@ static inline void arch_thread_struct_whitelist(unsigned long *offset,
        *size = fpu_kernel_xstate_size;
 }
 
-/*
- * Thread-synchronous status.
- *
- * This is different from the flags in that nobody else
- * ever touches our thread-synchronous status, so we don't
- * have to worry about atomic accesses.
- */
-#define TS_COMPAT              0x0002  /* 32bit syscall active (64BIT)*/
-
 static inline void
 native_load_sp0(unsigned long sp0)
 {
index 2c35f1c01a2df103854215bdba3bec992fe2e177..b6a9d51d1d7911894fa6b831b2f01a05f1daf57f 100644 (file)
@@ -25,6 +25,7 @@ void __end_SYSENTER_singlestep_region(void);
 void entry_SYSENTER_compat(void);
 void __end_entry_SYSENTER_compat(void);
 void entry_SYSCALL_compat(void);
+void entry_SYSCALL_compat_safe_stack(void);
 void entry_INT80_compat(void);
 #ifdef CONFIG_XEN_PV
 void xen_entry_INT80_compat(void);
index d8324a23669610e379078543e3cbed3855aaae3e..409f661481e110c3471b83477a159cae4052b540 100644 (file)
@@ -94,6 +94,8 @@ struct pt_regs {
 #include <asm/paravirt_types.h>
 #endif
 
+#include <asm/proto.h>
+
 struct cpuinfo_x86;
 struct task_struct;
 
@@ -175,6 +177,19 @@ static inline bool any_64bit_mode(struct pt_regs *regs)
 #ifdef CONFIG_X86_64
 #define current_user_stack_pointer()   current_pt_regs()->sp
 #define compat_user_stack_pointer()    current_pt_regs()->sp
+
+static inline bool ip_within_syscall_gap(struct pt_regs *regs)
+{
+       bool ret = (regs->ip >= (unsigned long)entry_SYSCALL_64 &&
+                   regs->ip <  (unsigned long)entry_SYSCALL_64_safe_stack);
+
+#ifdef CONFIG_IA32_EMULATION
+       ret = ret || (regs->ip >= (unsigned long)entry_SYSCALL_compat &&
+                     regs->ip <  (unsigned long)entry_SYSCALL_compat_safe_stack);
+#endif
+
+       return ret;
+}
 #endif
 
 static inline unsigned long kernel_stack_pointer(struct pt_regs *regs)
index 8b58d6975d5d4b4fa3a77e25529caf464b23bbfe..0bc9b0895f33e5a65c9f4304ae6d92fafade2394 100644 (file)
@@ -58,9 +58,8 @@ static __always_inline unsigned long smap_save(void)
        unsigned long flags;
 
        asm volatile ("# smap_save\n\t"
-                     ALTERNATIVE("jmp 1f", "", X86_FEATURE_SMAP)
-                     "pushf; pop %0; " __ASM_CLAC "\n\t"
-                     "1:"
+                     ALTERNATIVE("", "pushf; pop %0; " __ASM_CLAC "\n\t",
+                                 X86_FEATURE_SMAP)
                      : "=rm" (flags) : : "memory", "cc");
 
        return flags;
@@ -69,9 +68,8 @@ static __always_inline unsigned long smap_save(void)
 static __always_inline void smap_restore(unsigned long flags)
 {
        asm volatile ("# smap_restore\n\t"
-                     ALTERNATIVE("jmp 1f", "", X86_FEATURE_SMAP)
-                     "push %0; popf\n\t"
-                     "1:"
+                     ALTERNATIVE("", "push %0; popf\n\t",
+                                 X86_FEATURE_SMAP)
                      : : "g" (flags) : "memory", "cc");
 }
 
index 0d751d5da702ecce8405393b0018272395505583..06b740bae431d2a0b4a163553e548dc5d64d7c0d 100644 (file)
@@ -205,10 +205,23 @@ static inline int arch_within_stack_frames(const void * const stack,
 
 #endif
 
+/*
+ * Thread-synchronous status.
+ *
+ * This is different from the flags in that nobody else
+ * ever touches our thread-synchronous status, so we don't
+ * have to worry about atomic accesses.
+ */
+#define TS_COMPAT              0x0002  /* 32bit syscall active (64BIT)*/
+
+#ifndef __ASSEMBLY__
 #ifdef CONFIG_COMPAT
 #define TS_I386_REGS_POKED     0x0004  /* regs poked by 32-bit ptracer */
+
+#define arch_set_restart_data(restart) \
+       do { restart->arch_data = current_thread_info()->status; } while (0)
+
 #endif
-#ifndef __ASSEMBLY__
 
 #ifdef CONFIG_X86_32
 #define in_ia32_syscall() true
index bda4f2a36868da2bbf8e7788ff2dadae94f3f312..4f26700f314d9ad48c4c57af17831b7f4fdb9d9b 100644 (file)
@@ -2342,6 +2342,11 @@ static int cpuid_to_apicid[] = {
        [0 ... NR_CPUS - 1] = -1,
 };
 
+bool arch_match_cpu_phys_id(int cpu, u64 phys_id)
+{
+       return phys_id == cpuid_to_apicid[cpu];
+}
+
 #ifdef CONFIG_SMP
 /**
  * apic_id_is_primary_thread - Check whether APIC ID belongs to a primary thread
index c3b60c37c728066e2713e49769c35277b6657075..73ff4dd426a8341bcd38654c2856b5d465bed6ba 100644 (file)
@@ -1032,6 +1032,16 @@ static int mp_map_pin_to_irq(u32 gsi, int idx, int ioapic, int pin,
        if (idx >= 0 && test_bit(mp_irqs[idx].srcbus, mp_bus_not_pci)) {
                irq = mp_irqs[idx].srcbusirq;
                legacy = mp_is_legacy_irq(irq);
+               /*
+                * IRQ2 is unusable for historical reasons on systems which
+                * have a legacy PIC. See the comment vs. IRQ2 further down.
+                *
+                * If this gets removed at some point then the related code
+                * in lapic_assign_system_vectors() needs to be adjusted as
+                * well.
+                */
+               if (legacy && irq == PIC_CASCADE_IR)
+                       return -EINVAL;
        }
 
        mutex_lock(&ioapic_mutex);
index 373e5fa3ce1f620de4e079d271be0d4fb4c52622..51c7f5271aee47abf14b83733fa0e0d34c9a9926 100644 (file)
@@ -12,7 +12,7 @@
 
 #include "common.h"
 
-/* Ftrace callback handler for kprobes -- called under preepmt disabed */
+/* Ftrace callback handler for kprobes -- called under preepmt disabled */
 void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
                           struct ftrace_ops *ops, struct ftrace_regs *fregs)
 {
index 5e78e01ca3b46f8eccfd11541850bc08a122b614..78bb0fae39826cff94ac2081f327c91e7d87d8c4 100644 (file)
@@ -836,28 +836,25 @@ static void kvm_kick_cpu(int cpu)
 
 static void kvm_wait(u8 *ptr, u8 val)
 {
-       unsigned long flags;
-
        if (in_nmi())
                return;
 
-       local_irq_save(flags);
-
-       if (READ_ONCE(*ptr) != val)
-               goto out;
-
        /*
         * halt until it's our turn and kicked. Note that we do safe halt
         * for irq enabled case to avoid hang when lock info is overwritten
         * in irq spinlock slowpath and no spurious interrupt occur to save us.
         */
-       if (arch_irqs_disabled_flags(flags))
-               halt();
-       else
-               safe_halt();
+       if (irqs_disabled()) {
+               if (READ_ONCE(*ptr) == val)
+                       halt();
+       } else {
+               local_irq_disable();
 
-out:
-       local_irq_restore(flags);
+               if (READ_ONCE(*ptr) == val)
+                       safe_halt();
+
+               local_irq_enable();
+       }
 }
 
 #ifdef CONFIG_X86_32
index aa593743acf679781bbfd98117bfc269f5c999b4..1fc0962c89c082b5b638a79efc040e4940de9991 100644 (file)
@@ -268,21 +268,20 @@ static void __init kvmclock_init_mem(void)
 
 static int __init kvm_setup_vsyscall_timeinfo(void)
 {
-#ifdef CONFIG_X86_64
-       u8 flags;
+       kvmclock_init_mem();
 
-       if (!per_cpu(hv_clock_per_cpu, 0) || !kvmclock_vsyscall)
-               return 0;
+#ifdef CONFIG_X86_64
+       if (per_cpu(hv_clock_per_cpu, 0) && kvmclock_vsyscall) {
+               u8 flags;
 
-       flags = pvclock_read_flags(&hv_clock_boot[0].pvti);
-       if (!(flags & PVCLOCK_TSC_STABLE_BIT))
-               return 0;
+               flags = pvclock_read_flags(&hv_clock_boot[0].pvti);
+               if (!(flags & PVCLOCK_TSC_STABLE_BIT))
+                       return 0;
 
-       kvm_clock.vdso_clock_mode = VDSO_CLOCKMODE_PVCLOCK;
+               kvm_clock.vdso_clock_mode = VDSO_CLOCKMODE_PVCLOCK;
+       }
 #endif
 
-       kvmclock_init_mem();
-
        return 0;
 }
 early_initcall(kvm_setup_vsyscall_timeinfo);
index 84c1821819afb8fb3da3b09b8d429930bd1d4da3..04a780abb512d01eb246067eff2b27f6e8501c51 100644 (file)
@@ -121,8 +121,18 @@ static void __init setup_vc_stacks(int cpu)
        cea_set_pte((void *)vaddr, pa, PAGE_KERNEL);
 }
 
-static __always_inline bool on_vc_stack(unsigned long sp)
+static __always_inline bool on_vc_stack(struct pt_regs *regs)
 {
+       unsigned long sp = regs->sp;
+
+       /* User-mode RSP is not trusted */
+       if (user_mode(regs))
+               return false;
+
+       /* SYSCALL gap still has user-mode RSP */
+       if (ip_within_syscall_gap(regs))
+               return false;
+
        return ((sp >= __this_cpu_ist_bottom_va(VC)) && (sp < __this_cpu_ist_top_va(VC)));
 }
 
@@ -144,7 +154,7 @@ void noinstr __sev_es_ist_enter(struct pt_regs *regs)
        old_ist = __this_cpu_read(cpu_tss_rw.x86_tss.ist[IST_INDEX_VC]);
 
        /* Make room on the IST stack */
-       if (on_vc_stack(regs->sp))
+       if (on_vc_stack(regs))
                new_ist = ALIGN_DOWN(regs->sp, 8) - sizeof(old_ist);
        else
                new_ist = old_ist - sizeof(old_ist);
@@ -248,7 +258,7 @@ static enum es_result vc_decode_insn(struct es_em_ctxt *ctxt)
        int res;
 
        if (user_mode(ctxt->regs)) {
-               res = insn_fetch_from_user(ctxt->regs, buffer);
+               res = insn_fetch_from_user_inatomic(ctxt->regs, buffer);
                if (!res) {
                        ctxt->fi.vector     = X86_TRAP_PF;
                        ctxt->fi.error_code = X86_PF_INSTR | X86_PF_USER;
@@ -1248,13 +1258,12 @@ static __always_inline bool on_vc_fallback_stack(struct pt_regs *regs)
 DEFINE_IDTENTRY_VC_SAFE_STACK(exc_vmm_communication)
 {
        struct sev_es_runtime_data *data = this_cpu_read(runtime_data);
+       irqentry_state_t irq_state;
        struct ghcb_state state;
        struct es_em_ctxt ctxt;
        enum es_result result;
        struct ghcb *ghcb;
 
-       lockdep_assert_irqs_disabled();
-
        /*
         * Handle #DB before calling into !noinstr code to avoid recursive #DB.
         */
@@ -1263,6 +1272,8 @@ DEFINE_IDTENTRY_VC_SAFE_STACK(exc_vmm_communication)
                return;
        }
 
+       irq_state = irqentry_nmi_enter(regs);
+       lockdep_assert_irqs_disabled();
        instrumentation_begin();
 
        /*
@@ -1325,6 +1336,7 @@ DEFINE_IDTENTRY_VC_SAFE_STACK(exc_vmm_communication)
 
 out:
        instrumentation_end();
+       irqentry_nmi_exit(regs, irq_state);
 
        return;
 
index ea794a083c44ebab56183e3ea100453abffeb154..f306e85a08a641883dc98fb6156df4857480205e 100644 (file)
@@ -766,30 +766,8 @@ handle_signal(struct ksignal *ksig, struct pt_regs *regs)
 
 static inline unsigned long get_nr_restart_syscall(const struct pt_regs *regs)
 {
-       /*
-        * This function is fundamentally broken as currently
-        * implemented.
-        *
-        * The idea is that we want to trigger a call to the
-        * restart_block() syscall and that we want in_ia32_syscall(),
-        * in_x32_syscall(), etc. to match whatever they were in the
-        * syscall being restarted.  We assume that the syscall
-        * instruction at (regs->ip - 2) matches whatever syscall
-        * instruction we used to enter in the first place.
-        *
-        * The problem is that we can get here when ptrace pokes
-        * syscall-like values into regs even if we're not in a syscall
-        * at all.
-        *
-        * For now, we maintain historical behavior and guess based on
-        * stored state.  We could do better by saving the actual
-        * syscall arch in restart_block or (with caveats on x32) by
-        * checking if regs->ip points to 'int $0x80'.  The current
-        * behavior is incorrect if a tracer has a different bitness
-        * than the tracee.
-        */
 #ifdef CONFIG_IA32_EMULATION
-       if (current_thread_info()->status & (TS_COMPAT|TS_I386_REGS_POKED))
+       if (current->restart_block.arch_data & TS_COMPAT)
                return __NR_ia32_restart_syscall;
 #endif
 #ifdef CONFIG_X86_X32_ABI
index 7f5aec758f0eeac2d9bcebcd80963bc9d79e7ab3..ac1874a2a70e8cc41654bc652a8922238192a8ff 100644 (file)
@@ -694,8 +694,7 @@ asmlinkage __visible noinstr struct pt_regs *vc_switch_off_ist(struct pt_regs *r
         * In the SYSCALL entry path the RSP value comes from user-space - don't
         * trust it and switch to the current kernel stack
         */
-       if (regs->ip >= (unsigned long)entry_SYSCALL_64 &&
-           regs->ip <  (unsigned long)entry_SYSCALL_64_safe_stack) {
+       if (ip_within_syscall_gap(regs)) {
                sp = this_cpu_read(cpu_current_top_of_stack);
                goto sync;
        }
index 2a1d47f47eee2b3d1f5034d1828d1faa2ee9e4c0..a1202536fc57cc2b4af2b0bfde3f08fb6f9c034a 100644 (file)
@@ -13,7 +13,7 @@
 
 #define orc_warn_current(args...)                                      \
 ({                                                                     \
-       if (state->task == current)                                     \
+       if (state->task == current && !state->error)                    \
                orc_warn(args);                                         \
 })
 
@@ -367,8 +367,8 @@ static bool deref_stack_regs(struct unwind_state *state, unsigned long addr,
        if (!stack_access_ok(state, addr, sizeof(struct pt_regs)))
                return false;
 
-       *ip = regs->ip;
-       *sp = regs->sp;
+       *ip = READ_ONCE_NOCHECK(regs->ip);
+       *sp = READ_ONCE_NOCHECK(regs->sp);
        return true;
 }
 
@@ -380,8 +380,8 @@ static bool deref_stack_iret_regs(struct unwind_state *state, unsigned long addr
        if (!stack_access_ok(state, addr, IRET_FRAME_SIZE))
                return false;
 
-       *ip = regs->ip;
-       *sp = regs->sp;
+       *ip = READ_ONCE_NOCHECK(regs->ip);
+       *sp = READ_ONCE_NOCHECK(regs->sp);
        return true;
 }
 
@@ -402,12 +402,12 @@ static bool get_reg(struct unwind_state *state, unsigned int reg_off,
                return false;
 
        if (state->full_regs) {
-               *val = ((unsigned long *)state->regs)[reg];
+               *val = READ_ONCE_NOCHECK(((unsigned long *)state->regs)[reg]);
                return true;
        }
 
        if (state->prev_regs) {
-               *val = ((unsigned long *)state->prev_regs)[reg];
+               *val = READ_ONCE_NOCHECK(((unsigned long *)state->prev_regs)[reg]);
                return true;
        }
 
index 58fa8c0298673d6b43a8eaa2b39db5b012748fab..f98370a399361b1104040a4e9d749a167454ebb1 100644 (file)
@@ -520,10 +520,10 @@ static u64 get_time_ref_counter(struct kvm *kvm)
        u64 tsc;
 
        /*
-        * The guest has not set up the TSC page or the clock isn't
-        * stable, fall back to get_kvmclock_ns.
+        * Fall back to get_kvmclock_ns() when TSC page hasn't been set up,
+        * is broken, disabled or being updated.
         */
-       if (!hv->tsc_ref.tsc_sequence)
+       if (hv->hv_tsc_page_status != HV_TSC_PAGE_SET)
                return div_u64(get_kvmclock_ns(kvm), 100);
 
        vcpu = kvm_get_vcpu(kvm, 0);
@@ -1077,6 +1077,21 @@ static bool compute_tsc_page_parameters(struct pvclock_vcpu_time_info *hv_clock,
        return true;
 }
 
+/*
+ * Don't touch TSC page values if the guest has opted for TSC emulation after
+ * migration. KVM doesn't fully support reenlightenment notifications and TSC
+ * access emulation and Hyper-V is known to expect the values in TSC page to
+ * stay constant before TSC access emulation is disabled from guest side
+ * (HV_X64_MSR_TSC_EMULATION_STATUS). KVM userspace is expected to preserve TSC
+ * frequency and guest visible TSC value across migration (and prevent it when
+ * TSC scaling is unsupported).
+ */
+static inline bool tsc_page_update_unsafe(struct kvm_hv *hv)
+{
+       return (hv->hv_tsc_page_status != HV_TSC_PAGE_GUEST_CHANGED) &&
+               hv->hv_tsc_emulation_control;
+}
+
 void kvm_hv_setup_tsc_page(struct kvm *kvm,
                           struct pvclock_vcpu_time_info *hv_clock)
 {
@@ -1087,7 +1102,8 @@ void kvm_hv_setup_tsc_page(struct kvm *kvm,
        BUILD_BUG_ON(sizeof(tsc_seq) != sizeof(hv->tsc_ref.tsc_sequence));
        BUILD_BUG_ON(offsetof(struct ms_hyperv_tsc_page, tsc_sequence) != 0);
 
-       if (!(hv->hv_tsc_page & HV_X64_MSR_TSC_REFERENCE_ENABLE))
+       if (hv->hv_tsc_page_status == HV_TSC_PAGE_BROKEN ||
+           hv->hv_tsc_page_status == HV_TSC_PAGE_UNSET)
                return;
 
        mutex_lock(&hv->hv_lock);
@@ -1101,7 +1117,15 @@ void kvm_hv_setup_tsc_page(struct kvm *kvm,
         */
        if (unlikely(kvm_read_guest(kvm, gfn_to_gpa(gfn),
                                    &tsc_seq, sizeof(tsc_seq))))
+               goto out_err;
+
+       if (tsc_seq && tsc_page_update_unsafe(hv)) {
+               if (kvm_read_guest(kvm, gfn_to_gpa(gfn), &hv->tsc_ref, sizeof(hv->tsc_ref)))
+                       goto out_err;
+
+               hv->hv_tsc_page_status = HV_TSC_PAGE_SET;
                goto out_unlock;
+       }
 
        /*
         * While we're computing and writing the parameters, force the
@@ -1110,15 +1134,15 @@ void kvm_hv_setup_tsc_page(struct kvm *kvm,
        hv->tsc_ref.tsc_sequence = 0;
        if (kvm_write_guest(kvm, gfn_to_gpa(gfn),
                            &hv->tsc_ref, sizeof(hv->tsc_ref.tsc_sequence)))
-               goto out_unlock;
+               goto out_err;
 
        if (!compute_tsc_page_parameters(hv_clock, &hv->tsc_ref))
-               goto out_unlock;
+               goto out_err;
 
        /* Ensure sequence is zero before writing the rest of the struct.  */
        smp_wmb();
        if (kvm_write_guest(kvm, gfn_to_gpa(gfn), &hv->tsc_ref, sizeof(hv->tsc_ref)))
-               goto out_unlock;
+               goto out_err;
 
        /*
         * Now switch to the TSC page mechanism by writing the sequence.
@@ -1131,8 +1155,45 @@ void kvm_hv_setup_tsc_page(struct kvm *kvm,
        smp_wmb();
 
        hv->tsc_ref.tsc_sequence = tsc_seq;
-       kvm_write_guest(kvm, gfn_to_gpa(gfn),
-                       &hv->tsc_ref, sizeof(hv->tsc_ref.tsc_sequence));
+       if (kvm_write_guest(kvm, gfn_to_gpa(gfn),
+                           &hv->tsc_ref, sizeof(hv->tsc_ref.tsc_sequence)))
+               goto out_err;
+
+       hv->hv_tsc_page_status = HV_TSC_PAGE_SET;
+       goto out_unlock;
+
+out_err:
+       hv->hv_tsc_page_status = HV_TSC_PAGE_BROKEN;
+out_unlock:
+       mutex_unlock(&hv->hv_lock);
+}
+
+void kvm_hv_invalidate_tsc_page(struct kvm *kvm)
+{
+       struct kvm_hv *hv = to_kvm_hv(kvm);
+       u64 gfn;
+
+       if (hv->hv_tsc_page_status == HV_TSC_PAGE_BROKEN ||
+           hv->hv_tsc_page_status == HV_TSC_PAGE_UNSET ||
+           tsc_page_update_unsafe(hv))
+               return;
+
+       mutex_lock(&hv->hv_lock);
+
+       if (!(hv->hv_tsc_page & HV_X64_MSR_TSC_REFERENCE_ENABLE))
+               goto out_unlock;
+
+       /* Preserve HV_TSC_PAGE_GUEST_CHANGED/HV_TSC_PAGE_HOST_CHANGED states */
+       if (hv->hv_tsc_page_status == HV_TSC_PAGE_SET)
+               hv->hv_tsc_page_status = HV_TSC_PAGE_UPDATING;
+
+       gfn = hv->hv_tsc_page >> HV_X64_MSR_TSC_REFERENCE_ADDRESS_SHIFT;
+
+       hv->tsc_ref.tsc_sequence = 0;
+       if (kvm_write_guest(kvm, gfn_to_gpa(gfn),
+                           &hv->tsc_ref, sizeof(hv->tsc_ref.tsc_sequence)))
+               hv->hv_tsc_page_status = HV_TSC_PAGE_BROKEN;
+
 out_unlock:
        mutex_unlock(&hv->hv_lock);
 }
@@ -1193,8 +1254,15 @@ static int kvm_hv_set_msr_pw(struct kvm_vcpu *vcpu, u32 msr, u64 data,
        }
        case HV_X64_MSR_REFERENCE_TSC:
                hv->hv_tsc_page = data;
-               if (hv->hv_tsc_page & HV_X64_MSR_TSC_REFERENCE_ENABLE)
+               if (hv->hv_tsc_page & HV_X64_MSR_TSC_REFERENCE_ENABLE) {
+                       if (!host)
+                               hv->hv_tsc_page_status = HV_TSC_PAGE_GUEST_CHANGED;
+                       else
+                               hv->hv_tsc_page_status = HV_TSC_PAGE_HOST_CHANGED;
                        kvm_make_request(KVM_REQ_MASTERCLOCK_UPDATE, vcpu);
+               } else {
+                       hv->hv_tsc_page_status = HV_TSC_PAGE_UNSET;
+               }
                break;
        case HV_X64_MSR_CRASH_P0 ... HV_X64_MSR_CRASH_P4:
                return kvm_hv_msr_set_crash_data(kvm,
@@ -1229,6 +1297,9 @@ static int kvm_hv_set_msr_pw(struct kvm_vcpu *vcpu, u32 msr, u64 data,
                hv->hv_tsc_emulation_control = data;
                break;
        case HV_X64_MSR_TSC_EMULATION_STATUS:
+               if (data && !host)
+                       return 1;
+
                hv->hv_tsc_emulation_status = data;
                break;
        case HV_X64_MSR_TIME_REF_COUNT:
index e951af1fcb2c5929ef7a2d5a119c26b4344f53c7..60547d5cb6d72451e25c8d7ae3df04e0b0267d9a 100644 (file)
@@ -133,6 +133,7 @@ void kvm_hv_process_stimers(struct kvm_vcpu *vcpu);
 
 void kvm_hv_setup_tsc_page(struct kvm *kvm,
                           struct pvclock_vcpu_time_info *hv_clock);
+void kvm_hv_invalidate_tsc_page(struct kvm *kvm);
 
 void kvm_hv_init_vm(struct kvm *kvm);
 void kvm_hv_destroy_vm(struct kvm *kvm);
index 45d40bfacb7cbe35b6deff4359404ccf314ace22..cc369b9ad8f11ccd5a725f0826dcab4f9ab507e7 100644 (file)
@@ -1642,7 +1642,16 @@ static void apic_timer_expired(struct kvm_lapic *apic, bool from_timer_fn)
        }
 
        if (kvm_use_posted_timer_interrupt(apic->vcpu)) {
-               kvm_wait_lapic_expire(vcpu);
+               /*
+                * Ensure the guest's timer has truly expired before posting an
+                * interrupt.  Open code the relevant checks to avoid querying
+                * lapic_timer_int_injected(), which will be false since the
+                * interrupt isn't yet injected.  Waiting until after injecting
+                * is not an option since that won't help a posted interrupt.
+                */
+               if (vcpu->arch.apic->lapic_timer.expired_tscdeadline &&
+                   vcpu->arch.apic->lapic_timer.timer_advance_ns)
+                       __kvm_wait_lapic_expire(vcpu);
                kvm_apic_inject_pending_timer_irqs(apic);
                return;
        }
@@ -2595,6 +2604,7 @@ int kvm_apic_set_state(struct kvm_vcpu *vcpu, struct kvm_lapic_state *s)
 
        apic_update_ppr(apic);
        hrtimer_cancel(&apic->lapic_timer.timer);
+       apic->lapic_timer.expired_tscdeadline = 0;
        apic_update_lvtt(apic);
        apic_manage_nmi_watchdog(apic, kvm_lapic_get_reg(apic, APIC_LVT0));
        update_divide_count(apic);
index ec4fc28b325a04c864b95b884bfc2b3cce37b64b..1f6f98c76bdf10a064dbe41cbe5638af49554d93 100644 (file)
@@ -78,6 +78,11 @@ static inline struct kvm_mmu_page *sptep_to_sp(u64 *sptep)
        return to_shadow_page(__pa(sptep));
 }
 
+static inline int kvm_mmu_page_as_id(struct kvm_mmu_page *sp)
+{
+       return sp->role.smm ? 1 : 0;
+}
+
 static inline bool kvm_vcpu_ad_need_write_protect(struct kvm_vcpu *vcpu)
 {
        /*
index e5f148106e20602d153a7bad815e9e053d5aa6c0..b3ed302c1a359fbe5b46b9aad8f6c0bcc5e7944d 100644 (file)
@@ -20,6 +20,21 @@ static gfn_t round_gfn_for_level(gfn_t gfn, int level)
        return gfn & -KVM_PAGES_PER_HPAGE(level);
 }
 
+/*
+ * Return the TDP iterator to the root PT and allow it to continue its
+ * traversal over the paging structure from there.
+ */
+void tdp_iter_restart(struct tdp_iter *iter)
+{
+       iter->yielded_gfn = iter->next_last_level_gfn;
+       iter->level = iter->root_level;
+
+       iter->gfn = round_gfn_for_level(iter->next_last_level_gfn, iter->level);
+       tdp_iter_refresh_sptep(iter);
+
+       iter->valid = true;
+}
+
 /*
  * Sets a TDP iterator to walk a pre-order traversal of the paging structure
  * rooted at root_pt, starting with the walk to translate next_last_level_gfn.
@@ -31,16 +46,12 @@ void tdp_iter_start(struct tdp_iter *iter, u64 *root_pt, int root_level,
        WARN_ON(root_level > PT64_ROOT_MAX_LEVEL);
 
        iter->next_last_level_gfn = next_last_level_gfn;
-       iter->yielded_gfn = iter->next_last_level_gfn;
        iter->root_level = root_level;
        iter->min_level = min_level;
-       iter->level = root_level;
-       iter->pt_path[iter->level - 1] = (tdp_ptep_t)root_pt;
-
-       iter->gfn = round_gfn_for_level(iter->next_last_level_gfn, iter->level);
-       tdp_iter_refresh_sptep(iter);
+       iter->pt_path[iter->root_level - 1] = (tdp_ptep_t)root_pt;
+       iter->as_id = kvm_mmu_page_as_id(sptep_to_sp(root_pt));
 
-       iter->valid = true;
+       tdp_iter_restart(iter);
 }
 
 /*
@@ -159,8 +170,3 @@ void tdp_iter_next(struct tdp_iter *iter)
        iter->valid = false;
 }
 
-tdp_ptep_t tdp_iter_root_pt(struct tdp_iter *iter)
-{
-       return iter->pt_path[iter->root_level - 1];
-}
-
index 4cc177d75c4aefe3210830f7433c54bb819d60d1..b1748b988d3aef556087b26ffad29accbd2756ff 100644 (file)
@@ -36,6 +36,8 @@ struct tdp_iter {
        int min_level;
        /* The iterator's current level within the paging structure */
        int level;
+       /* The address space ID, i.e. SMM vs. regular. */
+       int as_id;
        /* A snapshot of the value at sptep */
        u64 old_spte;
        /*
@@ -62,6 +64,6 @@ tdp_ptep_t spte_to_child_pt(u64 pte, int level);
 void tdp_iter_start(struct tdp_iter *iter, u64 *root_pt, int root_level,
                    int min_level, gfn_t next_last_level_gfn);
 void tdp_iter_next(struct tdp_iter *iter);
-tdp_ptep_t tdp_iter_root_pt(struct tdp_iter *iter);
+void tdp_iter_restart(struct tdp_iter *iter);
 
 #endif /* __KVM_X86_MMU_TDP_ITER_H */
index c926c6b899a106c704a68b25997209aff05ff3b1..462b1f71c77f94fb0d27370845919cfb1de0522a 100644 (file)
@@ -203,11 +203,6 @@ static void handle_changed_spte(struct kvm *kvm, int as_id, gfn_t gfn,
                                u64 old_spte, u64 new_spte, int level,
                                bool shared);
 
-static int kvm_mmu_page_as_id(struct kvm_mmu_page *sp)
-{
-       return sp->role.smm ? 1 : 0;
-}
-
 static void handle_changed_spte_acc_track(u64 old_spte, u64 new_spte, int level)
 {
        bool pfn_changed = spte_to_pfn(old_spte) != spte_to_pfn(new_spte);
@@ -301,11 +296,16 @@ static void tdp_mmu_unlink_page(struct kvm *kvm, struct kvm_mmu_page *sp,
  *
  * Given a page table that has been removed from the TDP paging structure,
  * iterates through the page table to clear SPTEs and free child page tables.
+ *
+ * Note that pt is passed in as a tdp_ptep_t, but it does not need RCU
+ * protection. Since this thread removed it from the paging structure,
+ * this thread will be responsible for ensuring the page is freed. Hence the
+ * early rcu_dereferences in the function.
  */
-static void handle_removed_tdp_mmu_page(struct kvm *kvm, u64 *pt,
+static void handle_removed_tdp_mmu_page(struct kvm *kvm, tdp_ptep_t pt,
                                        bool shared)
 {
-       struct kvm_mmu_page *sp = sptep_to_sp(pt);
+       struct kvm_mmu_page *sp = sptep_to_sp(rcu_dereference(pt));
        int level = sp->role.level;
        gfn_t base_gfn = sp->gfn;
        u64 old_child_spte;
@@ -318,7 +318,7 @@ static void handle_removed_tdp_mmu_page(struct kvm *kvm, u64 *pt,
        tdp_mmu_unlink_page(kvm, sp, shared);
 
        for (i = 0; i < PT64_ENT_PER_PAGE; i++) {
-               sptep = pt + i;
+               sptep = rcu_dereference(pt) + i;
                gfn = base_gfn + (i * KVM_PAGES_PER_HPAGE(level - 1));
 
                if (shared) {
@@ -337,7 +337,18 @@ static void handle_removed_tdp_mmu_page(struct kvm *kvm, u64 *pt,
                                cpu_relax();
                        }
                } else {
+                       /*
+                        * If the SPTE is not MMU-present, there is no backing
+                        * page associated with the SPTE and so no side effects
+                        * that need to be recorded, and exclusive ownership of
+                        * mmu_lock ensures the SPTE can't be made present.
+                        * Note, zapping MMIO SPTEs is also unnecessary as they
+                        * are guarded by the memslots generation, not by being
+                        * unreachable.
+                        */
                        old_child_spte = READ_ONCE(*sptep);
+                       if (!is_shadow_present_pte(old_child_spte))
+                               continue;
 
                        /*
                         * Marking the SPTE as a removed SPTE is not
@@ -481,10 +492,6 @@ static inline bool tdp_mmu_set_spte_atomic(struct kvm *kvm,
                                           struct tdp_iter *iter,
                                           u64 new_spte)
 {
-       u64 *root_pt = tdp_iter_root_pt(iter);
-       struct kvm_mmu_page *root = sptep_to_sp(root_pt);
-       int as_id = kvm_mmu_page_as_id(root);
-
        lockdep_assert_held_read(&kvm->mmu_lock);
 
        /*
@@ -498,8 +505,8 @@ static inline bool tdp_mmu_set_spte_atomic(struct kvm *kvm,
                      new_spte) != iter->old_spte)
                return false;
 
-       handle_changed_spte(kvm, as_id, iter->gfn, iter->old_spte, new_spte,
-                           iter->level, true);
+       handle_changed_spte(kvm, iter->as_id, iter->gfn, iter->old_spte,
+                           new_spte, iter->level, true);
 
        return true;
 }
@@ -527,7 +534,7 @@ static inline bool tdp_mmu_zap_spte_atomic(struct kvm *kvm,
         * here since the SPTE is going from non-present
         * to non-present.
         */
-       WRITE_ONCE(*iter->sptep, 0);
+       WRITE_ONCE(*rcu_dereference(iter->sptep), 0);
 
        return true;
 }
@@ -553,10 +560,6 @@ static inline void __tdp_mmu_set_spte(struct kvm *kvm, struct tdp_iter *iter,
                                      u64 new_spte, bool record_acc_track,
                                      bool record_dirty_log)
 {
-       tdp_ptep_t root_pt = tdp_iter_root_pt(iter);
-       struct kvm_mmu_page *root = sptep_to_sp(root_pt);
-       int as_id = kvm_mmu_page_as_id(root);
-
        lockdep_assert_held_write(&kvm->mmu_lock);
 
        /*
@@ -570,13 +573,13 @@ static inline void __tdp_mmu_set_spte(struct kvm *kvm, struct tdp_iter *iter,
 
        WRITE_ONCE(*rcu_dereference(iter->sptep), new_spte);
 
-       __handle_changed_spte(kvm, as_id, iter->gfn, iter->old_spte, new_spte,
-                             iter->level, false);
+       __handle_changed_spte(kvm, iter->as_id, iter->gfn, iter->old_spte,
+                             new_spte, iter->level, false);
        if (record_acc_track)
                handle_changed_spte_acc_track(iter->old_spte, new_spte,
                                              iter->level);
        if (record_dirty_log)
-               handle_changed_spte_dirty_log(kvm, as_id, iter->gfn,
+               handle_changed_spte_dirty_log(kvm, iter->as_id, iter->gfn,
                                              iter->old_spte, new_spte,
                                              iter->level);
 }
@@ -648,9 +651,7 @@ static inline bool tdp_mmu_iter_cond_resched(struct kvm *kvm,
 
                WARN_ON(iter->gfn > iter->next_last_level_gfn);
 
-               tdp_iter_start(iter, iter->pt_path[iter->root_level - 1],
-                              iter->root_level, iter->min_level,
-                              iter->next_last_level_gfn);
+               tdp_iter_restart(iter);
 
                return true;
        }
index baee91c1e936432bfedcd218e9f4532c10448a80..58a45bb139f88ab78c4a01e370693379968f0984 100644 (file)
@@ -115,13 +115,6 @@ static const struct svm_direct_access_msrs {
        { .index = MSR_INVALID,                         .always = false },
 };
 
-/* enable NPT for AMD64 and X86 with PAE */
-#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
-bool npt_enabled = true;
-#else
-bool npt_enabled;
-#endif
-
 /*
  * These 2 parameters are used to config the controls for Pause-Loop Exiting:
  * pause_filter_count: On processors that support Pause filtering(indicated
@@ -170,9 +163,12 @@ module_param(pause_filter_count_shrink, ushort, 0444);
 static unsigned short pause_filter_count_max = KVM_SVM_DEFAULT_PLE_WINDOW_MAX;
 module_param(pause_filter_count_max, ushort, 0444);
 
-/* allow nested paging (virtualized MMU) for all guests */
-static int npt = true;
-module_param(npt, int, S_IRUGO);
+/*
+ * Use nested page tables by default.  Note, NPT may get forced off by
+ * svm_hardware_setup() if it's unsupported by hardware or the host kernel.
+ */
+bool npt_enabled = true;
+module_param_named(npt, npt_enabled, bool, 0444);
 
 /* allow nested virtualization in KVM/SVM */
 static int nested = true;
@@ -988,10 +984,15 @@ static __init int svm_hardware_setup(void)
                        goto err;
        }
 
-       if (!boot_cpu_has(X86_FEATURE_NPT))
+       /*
+        * KVM's MMU doesn't support using 2-level paging for itself, and thus
+        * NPT isn't supported if the host is using 2-level paging since host
+        * CR4 is unchanged on VMRUN.
+        */
+       if (!IS_ENABLED(CONFIG_X86_64) && !IS_ENABLED(CONFIG_X86_PAE))
                npt_enabled = false;
 
-       if (npt_enabled && !npt)
+       if (!boot_cpu_has(X86_FEATURE_NPT))
                npt_enabled = false;
 
        kvm_configure_mmu(npt_enabled, get_max_npt_level(), PG_LEVEL_1G);
index 50810d4714628c2f3978847e9068c6106529797a..32cf8287d4a77306bb38da05ee6250441879e6f7 100644 (file)
@@ -6580,8 +6580,8 @@ static void atomic_switch_perf_msrs(struct vcpu_vmx *vmx)
        int i, nr_msrs;
        struct perf_guest_switch_msr *msrs;
 
+       /* Note, nr_msrs may be garbage if perf_guest_get_msrs() returns NULL. */
        msrs = perf_guest_get_msrs(&nr_msrs);
-
        if (!msrs)
                return;
 
index 2a20ce60152ea98e9521ed928c0cae06139317ab..fe806e89421280584e174ad9d6552c40b6418d05 100644 (file)
@@ -1526,35 +1526,44 @@ EXPORT_SYMBOL_GPL(kvm_enable_efer_bits);
 
 bool kvm_msr_allowed(struct kvm_vcpu *vcpu, u32 index, u32 type)
 {
+       struct kvm_x86_msr_filter *msr_filter;
+       struct msr_bitmap_range *ranges;
        struct kvm *kvm = vcpu->kvm;
-       struct msr_bitmap_range *ranges = kvm->arch.msr_filter.ranges;
-       u32 count = kvm->arch.msr_filter.count;
-       u32 i;
-       bool r = kvm->arch.msr_filter.default_allow;
+       bool allowed;
        int idx;
+       u32 i;
 
-       /* MSR filtering not set up or x2APIC enabled, allow everything */
-       if (!count || (index >= 0x800 && index <= 0x8ff))
+       /* x2APIC MSRs do not support filtering. */
+       if (index >= 0x800 && index <= 0x8ff)
                return true;
 
-       /* Prevent collision with set_msr_filter */
        idx = srcu_read_lock(&kvm->srcu);
 
-       for (i = 0; i < count; i++) {
+       msr_filter = srcu_dereference(kvm->arch.msr_filter, &kvm->srcu);
+       if (!msr_filter) {
+               allowed = true;
+               goto out;
+       }
+
+       allowed = msr_filter->default_allow;
+       ranges = msr_filter->ranges;
+
+       for (i = 0; i < msr_filter->count; i++) {
                u32 start = ranges[i].base;
                u32 end = start + ranges[i].nmsrs;
                u32 flags = ranges[i].flags;
                unsigned long *bitmap = ranges[i].bitmap;
 
                if ((index >= start) && (index < end) && (flags & type)) {
-                       r = !!test_bit(index - start, bitmap);
+                       allowed = !!test_bit(index - start, bitmap);
                        break;
                }
        }
 
+out:
        srcu_read_unlock(&kvm->srcu, idx);
 
-       return r;
+       return allowed;
 }
 EXPORT_SYMBOL_GPL(kvm_msr_allowed);
 
@@ -2551,6 +2560,8 @@ static void kvm_gen_update_masterclock(struct kvm *kvm)
        struct kvm_vcpu *vcpu;
        struct kvm_arch *ka = &kvm->arch;
 
+       kvm_hv_invalidate_tsc_page(kvm);
+
        spin_lock(&ka->pvclock_gtod_sync_lock);
        kvm_make_mclock_inprogress_request(kvm);
        /* no guest entries from this point */
@@ -5352,25 +5363,34 @@ split_irqchip_unlock:
        return r;
 }
 
-static void kvm_clear_msr_filter(struct kvm *kvm)
+static struct kvm_x86_msr_filter *kvm_alloc_msr_filter(bool default_allow)
+{
+       struct kvm_x86_msr_filter *msr_filter;
+
+       msr_filter = kzalloc(sizeof(*msr_filter), GFP_KERNEL_ACCOUNT);
+       if (!msr_filter)
+               return NULL;
+
+       msr_filter->default_allow = default_allow;
+       return msr_filter;
+}
+
+static void kvm_free_msr_filter(struct kvm_x86_msr_filter *msr_filter)
 {
        u32 i;
-       u32 count = kvm->arch.msr_filter.count;
-       struct msr_bitmap_range ranges[16];
 
-       mutex_lock(&kvm->lock);
-       kvm->arch.msr_filter.count = 0;
-       memcpy(ranges, kvm->arch.msr_filter.ranges, count * sizeof(ranges[0]));
-       mutex_unlock(&kvm->lock);
-       synchronize_srcu(&kvm->srcu);
+       if (!msr_filter)
+               return;
+
+       for (i = 0; i < msr_filter->count; i++)
+               kfree(msr_filter->ranges[i].bitmap);
 
-       for (i = 0; i < count; i++)
-               kfree(ranges[i].bitmap);
+       kfree(msr_filter);
 }
 
-static int kvm_add_msr_filter(struct kvm *kvm, struct kvm_msr_filter_range *user_range)
+static int kvm_add_msr_filter(struct kvm_x86_msr_filter *msr_filter,
+                             struct kvm_msr_filter_range *user_range)
 {
-       struct msr_bitmap_range *ranges = kvm->arch.msr_filter.ranges;
        struct msr_bitmap_range range;
        unsigned long *bitmap = NULL;
        size_t bitmap_size;
@@ -5404,11 +5424,9 @@ static int kvm_add_msr_filter(struct kvm *kvm, struct kvm_msr_filter_range *user
                goto err;
        }
 
-       /* Everything ok, add this range identifier to our global pool */
-       ranges[kvm->arch.msr_filter.count] = range;
-       /* Make sure we filled the array before we tell anyone to walk it */
-       smp_wmb();
-       kvm->arch.msr_filter.count++;
+       /* Everything ok, add this range identifier. */
+       msr_filter->ranges[msr_filter->count] = range;
+       msr_filter->count++;
 
        return 0;
 err:
@@ -5419,10 +5437,11 @@ err:
 static int kvm_vm_ioctl_set_msr_filter(struct kvm *kvm, void __user *argp)
 {
        struct kvm_msr_filter __user *user_msr_filter = argp;
+       struct kvm_x86_msr_filter *new_filter, *old_filter;
        struct kvm_msr_filter filter;
        bool default_allow;
-       int r = 0;
        bool empty = true;
+       int r = 0;
        u32 i;
 
        if (copy_from_user(&filter, user_msr_filter, sizeof(filter)))
@@ -5435,25 +5454,32 @@ static int kvm_vm_ioctl_set_msr_filter(struct kvm *kvm, void __user *argp)
        if (empty && !default_allow)
                return -EINVAL;
 
-       kvm_clear_msr_filter(kvm);
-
-       kvm->arch.msr_filter.default_allow = default_allow;
+       new_filter = kvm_alloc_msr_filter(default_allow);
+       if (!new_filter)
+               return -ENOMEM;
 
-       /*
-        * Protect from concurrent calls to this function that could trigger
-        * a TOCTOU violation on kvm->arch.msr_filter.count.
-        */
-       mutex_lock(&kvm->lock);
        for (i = 0; i < ARRAY_SIZE(filter.ranges); i++) {
-               r = kvm_add_msr_filter(kvm, &filter.ranges[i]);
-               if (r)
-                       break;
+               r = kvm_add_msr_filter(new_filter, &filter.ranges[i]);
+               if (r) {
+                       kvm_free_msr_filter(new_filter);
+                       return r;
+               }
        }
 
+       mutex_lock(&kvm->lock);
+
+       /* The per-VM filter is protected by kvm->lock... */
+       old_filter = srcu_dereference_check(kvm->arch.msr_filter, &kvm->srcu, 1);
+
+       rcu_assign_pointer(kvm->arch.msr_filter, new_filter);
+       synchronize_srcu(&kvm->srcu);
+
+       kvm_free_msr_filter(old_filter);
+
        kvm_make_all_cpus_request(kvm, KVM_REQ_MSR_FILTER_CHANGED);
        mutex_unlock(&kvm->lock);
 
-       return r;
+       return 0;
 }
 
 long kvm_arch_vm_ioctl(struct file *filp,
@@ -6603,7 +6629,7 @@ static int kvm_emulate_wbinvd_noskip(struct kvm_vcpu *vcpu)
                int cpu = get_cpu();
 
                cpumask_set_cpu(cpu, vcpu->arch.wbinvd_dirty_mask);
-               smp_call_function_many(vcpu->arch.wbinvd_dirty_mask,
+               on_each_cpu_mask(vcpu->arch.wbinvd_dirty_mask,
                                wbinvd_ipi, NULL, 1);
                put_cpu();
                cpumask_clear(vcpu->arch.wbinvd_dirty_mask);
@@ -10601,7 +10627,7 @@ void __user * __x86_set_memory_region(struct kvm *kvm, int id, gpa_t gpa,
                        return (void __user *)hva;
        } else {
                if (!slot || !slot->npages)
-                       return 0;
+                       return NULL;
 
                old_npages = slot->npages;
                hva = slot->userspace_addr;
@@ -10634,8 +10660,6 @@ void kvm_arch_pre_destroy_vm(struct kvm *kvm)
 
 void kvm_arch_destroy_vm(struct kvm *kvm)
 {
-       u32 i;
-
        if (current->mm == kvm->mm) {
                /*
                 * Free memory regions allocated on behalf of userspace,
@@ -10651,8 +10675,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm)
                mutex_unlock(&kvm->slots_lock);
        }
        static_call_cond(kvm_x86_vm_destroy)(kvm);
-       for (i = 0; i < kvm->arch.msr_filter.count; i++)
-               kfree(kvm->arch.msr_filter.ranges[i].bitmap);
+       kvm_free_msr_filter(srcu_dereference_check(kvm->arch.msr_filter, &kvm->srcu, 1));
        kvm_pic_destroy(kvm);
        kvm_ioapic_destroy(kvm);
        kvm_free_vcpus(kvm);
index 4229950a5d78c328a38f185119cc85098a36ce66..bb0b3fe1e0a0251c716ec2568576d8e0ceb13900 100644 (file)
@@ -1415,6 +1415,25 @@ void __user *insn_get_addr_ref(struct insn *insn, struct pt_regs *regs)
        }
 }
 
+static unsigned long insn_get_effective_ip(struct pt_regs *regs)
+{
+       unsigned long seg_base = 0;
+
+       /*
+        * If not in user-space long mode, a custom code segment could be in
+        * use. This is true in protected mode (if the process defined a local
+        * descriptor table), or virtual-8086 mode. In most of the cases
+        * seg_base will be zero as in USER_CS.
+        */
+       if (!user_64bit_mode(regs)) {
+               seg_base = insn_get_seg_base(regs, INAT_SEG_REG_CS);
+               if (seg_base == -1L)
+                       return 0;
+       }
+
+       return seg_base + regs->ip;
+}
+
 /**
  * insn_fetch_from_user() - Copy instruction bytes from user-space memory
  * @regs:      Structure with register values as seen when entering kernel mode
@@ -1431,24 +1450,43 @@ void __user *insn_get_addr_ref(struct insn *insn, struct pt_regs *regs)
  */
 int insn_fetch_from_user(struct pt_regs *regs, unsigned char buf[MAX_INSN_SIZE])
 {
-       unsigned long seg_base = 0;
+       unsigned long ip;
        int not_copied;
 
-       /*
-        * If not in user-space long mode, a custom code segment could be in
-        * use. This is true in protected mode (if the process defined a local
-        * descriptor table), or virtual-8086 mode. In most of the cases
-        * seg_base will be zero as in USER_CS.
-        */
-       if (!user_64bit_mode(regs)) {
-               seg_base = insn_get_seg_base(regs, INAT_SEG_REG_CS);
-               if (seg_base == -1L)
-                       return 0;
-       }
+       ip = insn_get_effective_ip(regs);
+       if (!ip)
+               return 0;
+
+       not_copied = copy_from_user(buf, (void __user *)ip, MAX_INSN_SIZE);
 
+       return MAX_INSN_SIZE - not_copied;
+}
+
+/**
+ * insn_fetch_from_user_inatomic() - Copy instruction bytes from user-space memory
+ *                                   while in atomic code
+ * @regs:      Structure with register values as seen when entering kernel mode
+ * @buf:       Array to store the fetched instruction
+ *
+ * Gets the linear address of the instruction and copies the instruction bytes
+ * to the buf. This function must be used in atomic context.
+ *
+ * Returns:
+ *
+ * Number of instruction bytes copied.
+ *
+ * 0 if nothing was copied.
+ */
+int insn_fetch_from_user_inatomic(struct pt_regs *regs, unsigned char buf[MAX_INSN_SIZE])
+{
+       unsigned long ip;
+       int not_copied;
+
+       ip = insn_get_effective_ip(regs);
+       if (!ip)
+               return 0;
 
-       not_copied = copy_from_user(buf, (void __user *)(seg_base + regs->ip),
-                                   MAX_INSN_SIZE);
+       not_copied = __copy_from_user_inatomic(buf, (void __user *)ip, MAX_INSN_SIZE);
 
        return MAX_INSN_SIZE - not_copied;
 }
index 79e7a0ec1da584c39f6ce8a4d243324ce00a5b6e..6926d0ca6c71797ffcbbf4e3c3e532f80c8244c3 100644 (file)
@@ -1349,6 +1349,7 @@ st:                       if (is_imm8(insn->off))
                            insn->imm == (BPF_XOR | BPF_FETCH)) {
                                u8 *branch_target;
                                bool is64 = BPF_SIZE(insn->code) == BPF_DW;
+                               u32 real_src_reg = src_reg;
 
                                /*
                                 * Can't be implemented with a single x86 insn.
@@ -1357,6 +1358,9 @@ st:                       if (is_imm8(insn->off))
 
                                /* Will need RAX as a CMPXCHG operand so save R0 */
                                emit_mov_reg(&prog, true, BPF_REG_AX, BPF_REG_0);
+                               if (src_reg == BPF_REG_0)
+                                       real_src_reg = BPF_REG_AX;
+
                                branch_target = prog;
                                /* Load old value */
                                emit_ldx(&prog, BPF_SIZE(insn->code),
@@ -1366,9 +1370,9 @@ st:                       if (is_imm8(insn->off))
                                 * put the result in the AUX_REG.
                                 */
                                emit_mov_reg(&prog, is64, AUX_REG, BPF_REG_0);
-                               maybe_emit_mod(&prog, AUX_REG, src_reg, is64);
+                               maybe_emit_mod(&prog, AUX_REG, real_src_reg, is64);
                                EMIT2(simple_alu_opcodes[BPF_OP(insn->imm)],
-                                     add_2reg(0xC0, AUX_REG, src_reg));
+                                     add_2reg(0xC0, AUX_REG, real_src_reg));
                                /* Attempt to swap in new value */
                                err = emit_atomic(&prog, BPF_CMPXCHG,
                                                  dst_reg, AUX_REG, insn->off,
@@ -1381,7 +1385,7 @@ st:                       if (is_imm8(insn->off))
                                 */
                                EMIT2(X86_JNE, -(prog - branch_target) - 2);
                                /* Return the pre-modification value */
-                               emit_mov_reg(&prog, is64, src_reg, BPF_REG_0);
+                               emit_mov_reg(&prog, is64, real_src_reg, BPF_REG_0);
                                /* Restore R0 after clobbering RAX */
                                emit_mov_reg(&prog, true, BPF_REG_0, BPF_REG_AX);
                                break;
index 1ac8578258afb872996d63d27d3a9676155c1c44..b42bfdab01a99ac6163c2527352372af21f24f09 100644 (file)
@@ -27,7 +27,6 @@
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Sébastien Hinderer <Sebastien.Hinderer@ens-lyon.org>");
 MODULE_DESCRIPTION("A power_off handler for Iris devices from EuroBraille");
-MODULE_SUPPORTED_DEVICE("Eurobraille/Iris");
 
 static bool force;
 
index a3cc33091f46c1039d48eeeeda2af6ec648caea7..17d80f751fcb2477fa16799261c6db8823941fcc 100644 (file)
@@ -741,7 +741,7 @@ int set_foreign_p2m_mapping(struct gnttab_map_grant_ref *map_ops,
                map_ops[i].status = GNTST_general_error;
                unmap[0].host_addr = map_ops[i].host_addr,
                unmap[0].handle = map_ops[i].handle;
-               map_ops[i].handle = ~0;
+               map_ops[i].handle = INVALID_GRANT_HANDLE;
                if (map_ops[i].flags & GNTMAP_device_map)
                        unmap[0].dev_bus_addr = map_ops[i].dev_bus_addr;
                else
@@ -751,7 +751,7 @@ int set_foreign_p2m_mapping(struct gnttab_map_grant_ref *map_ops,
                        kmap_ops[i].status = GNTST_general_error;
                        unmap[1].host_addr = kmap_ops[i].host_addr,
                        unmap[1].handle = kmap_ops[i].handle;
-                       kmap_ops[i].handle = ~0;
+                       kmap_ops[i].handle = INVALID_GRANT_HANDLE;
                        if (kmap_ops[i].flags & GNTMAP_device_map)
                                unmap[1].dev_bus_addr = kmap_ops[i].dev_bus_addr;
                        else
@@ -776,7 +776,6 @@ int set_foreign_p2m_mapping(struct gnttab_map_grant_ref *map_ops,
 out:
        return ret;
 }
-EXPORT_SYMBOL_GPL(set_foreign_p2m_mapping);
 
 int clear_foreign_p2m_mapping(struct gnttab_unmap_grant_ref *unmap_ops,
                              struct gnttab_unmap_grant_ref *kunmap_ops,
@@ -802,7 +801,6 @@ int clear_foreign_p2m_mapping(struct gnttab_unmap_grant_ref *unmap_ops,
 
        return ret;
 }
-EXPORT_SYMBOL_GPL(clear_foreign_p2m_mapping);
 
 #ifdef CONFIG_XEN_DEBUG_FS
 #include <linux/debugfs.h>
index a1c4d2900c7a83b0107f06e2a0a6bda0e71d3add..26b7f721cda88b37c991e9e7f9caef3145223b1a 100644 (file)
@@ -33,7 +33,7 @@ static struct biovec_slab {
        { .nr_vecs = 16, .name = "biovec-16" },
        { .nr_vecs = 64, .name = "biovec-64" },
        { .nr_vecs = 128, .name = "biovec-128" },
-       { .nr_vecs = BIO_MAX_PAGES, .name = "biovec-max" },
+       { .nr_vecs = BIO_MAX_VECS, .name = "biovec-max" },
 };
 
 static struct biovec_slab *biovec_slab(unsigned short nr_vecs)
@@ -46,7 +46,7 @@ static struct biovec_slab *biovec_slab(unsigned short nr_vecs)
                return &bvec_slabs[1];
        case 65 ... 128:
                return &bvec_slabs[2];
-       case 129 ... BIO_MAX_PAGES:
+       case 129 ... BIO_MAX_VECS:
                return &bvec_slabs[3];
        default:
                BUG();
@@ -151,9 +151,9 @@ out:
 
 void bvec_free(mempool_t *pool, struct bio_vec *bv, unsigned short nr_vecs)
 {
-       BIO_BUG_ON(nr_vecs > BIO_MAX_PAGES);
+       BIO_BUG_ON(nr_vecs > BIO_MAX_VECS);
 
-       if (nr_vecs == BIO_MAX_PAGES)
+       if (nr_vecs == BIO_MAX_VECS)
                mempool_free(bv, pool);
        else if (nr_vecs > BIO_INLINE_VECS)
                kmem_cache_free(biovec_slab(nr_vecs)->slab, bv);
@@ -186,15 +186,15 @@ struct bio_vec *bvec_alloc(mempool_t *pool, unsigned short *nr_vecs,
        /*
         * Try a slab allocation first for all smaller allocations.  If that
         * fails and __GFP_DIRECT_RECLAIM is set retry with the mempool.
-        * The mempool is sized to handle up to BIO_MAX_PAGES entries.
+        * The mempool is sized to handle up to BIO_MAX_VECS entries.
         */
-       if (*nr_vecs < BIO_MAX_PAGES) {
+       if (*nr_vecs < BIO_MAX_VECS) {
                struct bio_vec *bvl;
 
                bvl = kmem_cache_alloc(bvs->slab, bvec_alloc_gfp(gfp_mask));
                if (likely(bvl) || !(gfp_mask & __GFP_DIRECT_RECLAIM))
                        return bvl;
-               *nr_vecs = BIO_MAX_PAGES;
+               *nr_vecs = BIO_MAX_VECS;
        }
 
        return mempool_alloc(pool, gfp_mask);
index 85d5790ac49b03da55c3439b9b364d8539072843..3304e841df7ce924a1a64c69b5ab9102294d6801 100644 (file)
@@ -109,6 +109,7 @@ void blkg_rwstat_recursive_sum(struct blkcg_gq *blkg, struct blkcg_policy *pol,
 
        lockdep_assert_held(&blkg->q->queue_lock);
 
+       memset(sum, 0, sizeof(*sum));
        rcu_read_lock();
        blkg_for_each_descendant_pre(pos_blkg, pos_css, blkg) {
                struct blkg_rwstat *rwstat;
@@ -122,7 +123,7 @@ void blkg_rwstat_recursive_sum(struct blkcg_gq *blkg, struct blkcg_policy *pol,
                        rwstat = (void *)pos_blkg + off;
 
                for (i = 0; i < BLKG_RWSTAT_NR; i++)
-                       sum->cnt[i] = blkg_rwstat_read_counter(rwstat, i);
+                       sum->cnt[i] += blkg_rwstat_read_counter(rwstat, i);
        }
        rcu_read_unlock();
 }
index c176b7af56a7a57742f65757a3d9901ac9e14497..c322176a1e0995391bcfb358f427f6dc2c5f738e 100644 (file)
@@ -219,7 +219,7 @@ static bool blk_crypto_split_bio_if_needed(struct bio **bio_ptr)
 
        bio_for_each_segment(bv, bio, iter) {
                num_sectors += bv.bv_len >> SECTOR_SHIFT;
-               if (++i == BIO_MAX_PAGES)
+               if (++i == BIO_MAX_VECS)
                        break;
        }
        if (num_sectors < bio_sectors(bio)) {
index 752f9c7220622a9b30ac7f6e23aabdf9f7a7e3e4..7b256131b20bbb221e6500ba655b1dd2e05ddc2c 100644 (file)
@@ -296,7 +296,7 @@ static unsigned int __blkdev_sectors_to_bio_pages(sector_t nr_sects)
 {
        sector_t pages = DIV_ROUND_UP_SECTOR_T(nr_sects, PAGE_SIZE / 512);
 
-       return min(pages, (sector_t)BIO_MAX_PAGES);
+       return min(pages, (sector_t)BIO_MAX_VECS);
 }
 
 static int __blkdev_issue_zero_pages(struct block_device *bdev,
index 369e204d14d013f66e3422444d19361d09a10863..1ffef782fcf2dd96487d398e0499c871cb497c03 100644 (file)
@@ -249,7 +249,7 @@ static int bio_map_user_iov(struct request *rq, struct iov_iter *iter,
        if (!iov_iter_count(iter))
                return -EINVAL;
 
-       bio = bio_kmalloc(gfp_mask, iov_iter_npages(iter, BIO_MAX_PAGES));
+       bio = bio_kmalloc(gfp_mask, iov_iter_npages(iter, BIO_MAX_VECS));
        if (!bio)
                return -ENOMEM;
        bio->bi_opf |= req_op(rq);
index 833978c02e6083fd346784bdce244fe3b7d467c3..c0276b42d9fb7c5c1f6140b38a2864afc955d69a 100644 (file)
@@ -240,7 +240,7 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
                 */
                if (op == REQ_OP_ZONE_RESET &&
                    blkdev_allow_reset_all_zones(bdev, sector, nr_sectors)) {
-                       bio->bi_opf = REQ_OP_ZONE_RESET_ALL;
+                       bio->bi_opf = REQ_OP_ZONE_RESET_ALL | REQ_SYNC;
                        break;
                }
 
@@ -318,6 +318,22 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
        return 0;
 }
 
+static int blkdev_truncate_zone_range(struct block_device *bdev, fmode_t mode,
+                                     const struct blk_zone_range *zrange)
+{
+       loff_t start, end;
+
+       if (zrange->sector + zrange->nr_sectors <= zrange->sector ||
+           zrange->sector + zrange->nr_sectors > get_capacity(bdev->bd_disk))
+               /* Out of range */
+               return -EINVAL;
+
+       start = zrange->sector << SECTOR_SHIFT;
+       end = ((zrange->sector + zrange->nr_sectors) << SECTOR_SHIFT) - 1;
+
+       return truncate_bdev_range(bdev, mode, start, end);
+}
+
 /*
  * BLKRESETZONE, BLKOPENZONE, BLKCLOSEZONE and BLKFINISHZONE ioctl processing.
  * Called from blkdev_ioctl.
@@ -329,6 +345,7 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
        struct request_queue *q;
        struct blk_zone_range zrange;
        enum req_opf op;
+       int ret;
 
        if (!argp)
                return -EINVAL;
@@ -352,6 +369,11 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
        switch (cmd) {
        case BLKRESETZONE:
                op = REQ_OP_ZONE_RESET;
+
+               /* Invalidate the page cache, including dirty pages. */
+               ret = blkdev_truncate_zone_range(bdev, mode, &zrange);
+               if (ret)
+                       return ret;
                break;
        case BLKOPENZONE:
                op = REQ_OP_ZONE_OPEN;
@@ -366,8 +388,20 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
                return -ENOTTY;
        }
 
-       return blkdev_zone_mgmt(bdev, op, zrange.sector, zrange.nr_sectors,
-                               GFP_KERNEL);
+       ret = blkdev_zone_mgmt(bdev, op, zrange.sector, zrange.nr_sectors,
+                              GFP_KERNEL);
+
+       /*
+        * Invalidate the page cache again for zone reset: writes can only be
+        * direct for zoned devices so concurrent writes would not add any page
+        * to the page cache after/during reset. The page cache may be filled
+        * again due to concurrent reads though and dropping the pages for
+        * these is fine.
+        */
+       if (!ret && cmd == BLKRESETZONE)
+               ret = blkdev_truncate_zone_range(bdev, mode, &zrange);
+
+       return ret;
 }
 
 static inline unsigned long *blk_alloc_zone_bitmap(int node,
index 87983a35079c22b821e7aa21bf2a1a3b5a75164b..6c441f4f1cd4aacc0b1b97dd10ee5657d08a166f 100644 (file)
@@ -229,10 +229,10 @@ static struct bio *bounce_clone_bio(struct bio *bio_src)
         *  - The point of cloning the biovec is to produce a bio with a biovec
         *    the caller can modify: bi_idx and bi_bvec_done should be 0.
         *
-        *  - The original bio could've had more than BIO_MAX_PAGES biovecs; if
+        *  - The original bio could've had more than BIO_MAX_VECS biovecs; if
         *    we tried to clone the whole thing bio_alloc_bioset() would fail.
         *    But the clone should succeed as long as the number of biovecs we
-        *    actually need to allocate is fewer than BIO_MAX_PAGES.
+        *    actually need to allocate is fewer than BIO_MAX_VECS.
         *
         *  - Lastly, bi_vcnt should not be looked at or relied upon by code
         *    that does not own the bio - reason being drivers don't use it for
@@ -299,7 +299,7 @@ static void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig,
        int sectors = 0;
 
        bio_for_each_segment(from, *bio_orig, iter) {
-               if (i++ < BIO_MAX_PAGES)
+               if (i++ < BIO_MAX_VECS)
                        sectors += from.bv_len >> 9;
                if (page_to_pfn(from.bv_page) > q->limits.bounce_pfn)
                        bounce = true;
index c55e8f0fced1d830eb27c39dabf54357925e7d74..8c8f543572e64edc09147b4c6f833bc96dfdca9c 100644 (file)
@@ -534,10 +534,8 @@ static void register_disk(struct device *parent, struct gendisk *disk,
                kobject_create_and_add("holders", &ddev->kobj);
        disk->slave_dir = kobject_create_and_add("slaves", &ddev->kobj);
 
-       if (disk->flags & GENHD_FL_HIDDEN) {
-               dev_set_uevent_suppress(ddev, 0);
+       if (disk->flags & GENHD_FL_HIDDEN)
                return;
-       }
 
        disk_scan_partitions(disk);
 
index 15c9c28d9f5333866cd179accc1bb030741aca2d..5809cc198fa7c35dcc087447e8e7c244a41a885a 100644 (file)
@@ -767,7 +767,7 @@ config CRYPTO_POLY1305_X86_64
 
 config CRYPTO_POLY1305_MIPS
        tristate "Poly1305 authenticator algorithm (MIPS optimized)"
-       depends on CPU_MIPS32 || (CPU_MIPS64 && 64BIT)
+       depends on MIPS
        select CRYPTO_ARCH_HAVE_LIB_POLY1305
 
 config CRYPTO_MD4
index 316a9947541fe005fac119697fe93c70f70f9051..b574cce98dc3686ce473b1f2cc132b4de8616ed2 100644 (file)
@@ -2260,7 +2260,8 @@ out:
        return rc;
 
 err_eni_release:
-       eni_do_release(dev);
+       dev->phy = NULL;
+       iounmap(ENI_DEV(dev)->ioaddr);
 err_unregister:
        atm_dev_deregister(dev);
 err_free_consistent:
index 9a70bee841251d881ea43cebdf75e1a1e6b7910d..495fd0a1f040222289def0bf7fecdc64c62f6771 100644 (file)
@@ -100,8 +100,6 @@ static LIST_HEAD(fore200e_boards);
 
 MODULE_AUTHOR("Christophe Lizzi - credits to Uwe Dannowski and Heikki Vatiainen");
 MODULE_DESCRIPTION("FORE Systems 200E-series ATM driver - version " FORE200E_VERSION);
-MODULE_SUPPORTED_DEVICE("PCA-200E, SBA-200E");
-
 
 static const int fore200e_rx_buf_nbr[ BUFFER_SCHEME_NBR ][ BUFFER_MAGN_NBR ] = {
     { BUFFER_S1_NBR, BUFFER_L1_NBR },
index 3c081b6171a8fc39ffd3ac2535533861ffc14d9f..bfca7b8a6f31e8c04b3dd6be960c45bbb8029021 100644 (file)
@@ -262,7 +262,7 @@ static int idt77105_start(struct atm_dev *dev)
 {
        unsigned long flags;
 
-       if (!(dev->dev_data = kmalloc(sizeof(struct idt77105_priv),GFP_KERNEL)))
+       if (!(dev->phy_data = kmalloc(sizeof(struct idt77105_priv),GFP_KERNEL)))
                return -ENOMEM;
        PRIV(dev)->dev = dev;
        spin_lock_irqsave(&idt77105_priv_lock, flags);
@@ -337,7 +337,7 @@ static int idt77105_stop(struct atm_dev *dev)
                 else
                     idt77105_all = walk->next;
                dev->phy = NULL;
-                dev->dev_data = NULL;
+                dev->phy_data = NULL;
                 kfree(walk);
                 break;
             }
index d7277c26e423239e6e6971b7c6ba5f44a9e33d54..32d7aa141d96633dd9198cd1a6a0ded5baf3bcf5 100644 (file)
@@ -2233,6 +2233,7 @@ static int lanai_dev_open(struct atm_dev *atmdev)
        conf1_write(lanai);
 #endif
        iounmap(lanai->base);
+       lanai->base = NULL;
     error_pci:
        pci_disable_device(lanai->pci);
     error:
@@ -2245,6 +2246,8 @@ static int lanai_dev_open(struct atm_dev *atmdev)
 static void lanai_dev_close(struct atm_dev *atmdev)
 {
        struct lanai_dev *lanai = (struct lanai_dev *) atmdev->dev_data;
+       if (lanai->base==NULL)
+               return;
        printk(KERN_INFO DEV_LABEL "(itf %d): shutting down interface\n",
            lanai->number);
        lanai_timed_poll_stop(lanai);
@@ -2552,7 +2555,7 @@ static int lanai_init_one(struct pci_dev *pci,
        struct atm_dev *atmdev;
        int result;
 
-       lanai = kmalloc(sizeof(*lanai), GFP_KERNEL);
+       lanai = kzalloc(sizeof(*lanai), GFP_KERNEL);
        if (lanai == NULL) {
                printk(KERN_ERR DEV_LABEL
                       ": couldn't allocate dev_data structure!\n");
index 7850758b5bb82bb736adf02c8f438076846786f2..239852d855589440f41075bd5e919627bc34fcf1 100644 (file)
@@ -211,7 +211,7 @@ static void uPD98402_int(struct atm_dev *dev)
 static int uPD98402_start(struct atm_dev *dev)
 {
        DPRINTK("phy_start\n");
-       if (!(dev->dev_data = kmalloc(sizeof(struct uPD98402_priv),GFP_KERNEL)))
+       if (!(dev->phy_data = kmalloc(sizeof(struct uPD98402_priv),GFP_KERNEL)))
                return -ENOMEM;
        spin_lock_init(&PRIV(dev)->lock);
        memset(&PRIV(dev)->sonet_stats,0,sizeof(struct k_sonet_stats));
index 18b82427d0cb50f1a23e61f87ded881cf7309416..a46a7e30881b19e00b1bda7b839ab263ec8be3ef 100644 (file)
@@ -325,22 +325,22 @@ static void rpm_put_suppliers(struct device *dev)
 static int __rpm_callback(int (*cb)(struct device *), struct device *dev)
        __releases(&dev->power.lock) __acquires(&dev->power.lock)
 {
-       bool use_links = dev->power.links_count > 0;
-       bool get = false;
        int retval, idx;
-       bool put;
+       bool use_links = dev->power.links_count > 0;
 
        if (dev->power.irq_safe) {
                spin_unlock(&dev->power.lock);
-       } else if (!use_links) {
-               spin_unlock_irq(&dev->power.lock);
        } else {
-               get = dev->power.runtime_status == RPM_RESUMING;
-
                spin_unlock_irq(&dev->power.lock);
 
-               /* Resume suppliers if necessary. */
-               if (get) {
+               /*
+                * Resume suppliers if necessary.
+                *
+                * The device's runtime PM status cannot change until this
+                * routine returns, so it is safe to read the status outside of
+                * the lock.
+                */
+               if (use_links && dev->power.runtime_status == RPM_RESUMING) {
                        idx = device_links_read_lock();
 
                        retval = rpm_get_suppliers(dev);
@@ -355,36 +355,24 @@ static int __rpm_callback(int (*cb)(struct device *), struct device *dev)
 
        if (dev->power.irq_safe) {
                spin_lock(&dev->power.lock);
-               return retval;
-       }
-
-       spin_lock_irq(&dev->power.lock);
-
-       if (!use_links)
-               return retval;
-
-       /*
-        * If the device is suspending and the callback has returned success,
-        * drop the usage counters of the suppliers that have been reference
-        * counted on its resume.
-        *
-        * Do that if the resume fails too.
-        */
-       put = dev->power.runtime_status == RPM_SUSPENDING && !retval;
-       if (put)
-               __update_runtime_status(dev, RPM_SUSPENDED);
-       else
-               put = get && retval;
-
-       if (put) {
-               spin_unlock_irq(&dev->power.lock);
-
-               idx = device_links_read_lock();
+       } else {
+               /*
+                * If the device is suspending and the callback has returned
+                * success, drop the usage counters of the suppliers that have
+                * been reference counted on its resume.
+                *
+                * Do that if resume fails too.
+                */
+               if (use_links
+                   && ((dev->power.runtime_status == RPM_SUSPENDING && !retval)
+                   || (dev->power.runtime_status == RPM_RESUMING && retval))) {
+                       idx = device_links_read_lock();
 
-fail:
-               rpm_put_suppliers(dev);
+ fail:
+                       rpm_put_suppliers(dev);
 
-               device_links_read_unlock(idx);
+                       device_links_read_unlock(idx);
+               }
 
                spin_lock_irq(&dev->power.lock);
        }
index 37179a8b1ceba78fc3b3dd32a42a10aeea7131b0..fa3719ef80e4d12b93655189ed4cec22075a04e0 100644 (file)
@@ -938,6 +938,9 @@ int software_node_register(const struct software_node *node)
        if (software_node_to_swnode(node))
                return -EEXIST;
 
+       if (node->parent && !parent)
+               return -EINVAL;
+
        return PTR_ERR_OR_ZERO(swnode_register(node, parent, 0));
 }
 EXPORT_SYMBOL_GPL(software_node_register);
@@ -1002,25 +1005,33 @@ EXPORT_SYMBOL_GPL(fwnode_remove_software_node);
 /**
  * device_add_software_node - Assign software node to a device
  * @dev: The device the software node is meant for.
- * @swnode: The software node.
+ * @node: The software node.
  *
- * This function will register @swnode and make it the secondary firmware node
- * pointer of @dev. If @dev has no primary node, then @swnode will become the primary
- * node.
+ * This function will make @node the secondary firmware node pointer of @dev. If
+ * @dev has no primary node, then @node will become the primary node. The
+ * function will register @node automatically if it wasn't already registered.
  */
-int device_add_software_node(struct device *dev, const struct software_node *swnode)
+int device_add_software_node(struct device *dev, const struct software_node *node)
 {
+       struct swnode *swnode;
        int ret;
 
        /* Only one software node per device. */
        if (dev_to_swnode(dev))
                return -EBUSY;
 
-       ret = software_node_register(swnode);
-       if (ret)
-               return ret;
+       swnode = software_node_to_swnode(node);
+       if (swnode) {
+               kobject_get(&swnode->kobj);
+       } else {
+               ret = software_node_register(node);
+               if (ret)
+                       return ret;
+
+               swnode = software_node_to_swnode(node);
+       }
 
-       set_secondary_fwnode(dev, software_node_fwnode(swnode));
+       set_secondary_fwnode(dev, &swnode->fwnode);
 
        return 0;
 }
index 7d9cc433b758ae9c29ac3cd76428f7dcc4fc6fac..5d9181382ce1909d7ebdd3c6e52e02044d42202a 100644 (file)
@@ -1324,7 +1324,7 @@ struct bm_extent {
  * A followup commit may allow even bigger BIO sizes,
  * once we thought that through. */
 #define DRBD_MAX_BIO_SIZE (1U << 20)
-#if DRBD_MAX_BIO_SIZE > (BIO_MAX_PAGES << PAGE_SHIFT)
+#if DRBD_MAX_BIO_SIZE > (BIO_MAX_VECS << PAGE_SHIFT)
 #error Architecture not supported: DRBD_MAX_BIO_SIZE > BIO_MAX_SIZE
 #endif
 #define DRBD_MAX_BIO_SIZE_SAFE (1U << 12)       /* Works always = 4k */
index 0b71292d9d5abdb659bba48301087b10887c9035..4aa9683ee0c1aac14e75f48223e69c74898680c6 100644 (file)
@@ -5091,7 +5091,6 @@ module_param(floppy, charp, 0);
 module_param(FLOPPY_IRQ, int, 0);
 module_param(FLOPPY_DMA, int, 0);
 MODULE_AUTHOR("Alain L. Knaff");
-MODULE_SUPPORTED_DEVICE("fd");
 MODULE_LICENSE("GPL");
 
 /* This doesn't actually get used other than for module information */
index 5ac1881396afb135e74867e732be6e8943366afd..227e1be4c6f99e0f9d80615c375286d69333efd4 100644 (file)
@@ -871,6 +871,7 @@ static int rsxx_pci_probe(struct pci_dev *dev,
        card->event_wq = create_singlethread_workqueue(DRIVER_NAME"_event");
        if (!card->event_wq) {
                dev_err(CARD_TO_DEV(card), "Failed card event setup.\n");
+               st = -ENOMEM;
                goto failed_event_handler;
        }
 
index 982732dbe82e6971aeb19e221a0910409fd73735..664280f23bee19f89ff5e5e238e7cc68c0e6d0dc 100644 (file)
@@ -877,6 +877,7 @@ static int mm_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
        if (card->mm_pages[0].desc == NULL ||
            card->mm_pages[1].desc == NULL) {
                dev_printk(KERN_ERR, &card->dev->dev, "alloc failed\n");
+               ret = -ENOMEM;
                goto failed_alloc;
        }
        reset_page(&card->mm_pages[0]);
@@ -888,8 +889,10 @@ static int mm_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
        spin_lock_init(&card->lock);
 
        card->queue = blk_alloc_queue(NUMA_NO_NODE);
-       if (!card->queue)
+       if (!card->queue) {
+               ret = -ENOMEM;
                goto failed_alloc;
+       }
 
        tasklet_init(&card->tasklet, process_page, (unsigned long)card);
 
index a711a2e2a7946bc466913c38585b867b62151748..cf8deecc39efbcda33968186c89861aa62f666d3 100644 (file)
@@ -627,7 +627,7 @@ static ssize_t writeback_store(struct device *dev,
        struct bio_vec bio_vec;
        struct page *page;
        ssize_t ret = len;
-       int mode;
+       int mode, err;
        unsigned long blk_idx = 0;
 
        if (sysfs_streq(buf, "idle"))
@@ -638,8 +638,8 @@ static ssize_t writeback_store(struct device *dev,
                if (strncmp(buf, PAGE_WB_SIG, sizeof(PAGE_WB_SIG) - 1))
                        return -EINVAL;
 
-               ret = kstrtol(buf + sizeof(PAGE_WB_SIG) - 1, 10, &index);
-               if (ret || index >= nr_pages)
+               if (kstrtol(buf + sizeof(PAGE_WB_SIG) - 1, 10, &index) ||
+                               index >= nr_pages)
                        return -EINVAL;
 
                nr_pages = 1;
@@ -663,7 +663,7 @@ static ssize_t writeback_store(struct device *dev,
                goto release_init_lock;
        }
 
-       while (nr_pages--) {
+       for (; nr_pages != 0; index++, nr_pages--) {
                struct bio_vec bvec;
 
                bvec.bv_page = page;
@@ -728,12 +728,17 @@ static ssize_t writeback_store(struct device *dev,
                 * XXX: A single page IO would be inefficient for write
                 * but it would be not bad as starter.
                 */
-               ret = submit_bio_wait(&bio);
-               if (ret) {
+               err = submit_bio_wait(&bio);
+               if (err) {
                        zram_slot_lock(zram, index);
                        zram_clear_flag(zram, index, ZRAM_UNDER_WB);
                        zram_clear_flag(zram, index, ZRAM_IDLE);
                        zram_slot_unlock(zram, index);
+                       /*
+                        * Return last IO error unless every IO were
+                        * not suceeded.
+                        */
+                       ret = err;
                        continue;
                }
 
index 3951f7b23840447030eaabe617d125b97c25495e..bea1595f6432d21c93278b2bf279fb8636904afb 100644 (file)
@@ -194,5 +194,4 @@ module_init(rsi_91x_bt_module_init);
 module_exit(rsi_91x_bt_module_exit);
 MODULE_AUTHOR("Redpine Signals Inc");
 MODULE_DESCRIPTION("RSI BT driver");
-MODULE_SUPPORTED_DEVICE("RSI-BT");
 MODULE_LICENSE("Dual BSD/GPL");
index 14b2d8034c51df0af290641f984ef8eb46bc1a0a..45ac7ab003ce30cb1b2f454c28948643366bb865 100644 (file)
@@ -81,9 +81,6 @@ MODULE_DESCRIPTION("Driver for Applicom Profibus card");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS_MISCDEV(AC_MINOR);
 
-MODULE_SUPPORTED_DEVICE("ac");
-
-
 static struct applicom_board {
        unsigned long PhysIO;
        void __iomem *RamIO;
index 8038a8a9fb581a457dedcc48353b2a092e0b614e..f4949b689bd5ad5a6fe6633a4b812f1d92c8e818 100644 (file)
@@ -54,10 +54,9 @@ static int pseries_rng_probe(struct vio_dev *dev,
        return hwrng_register(&pseries_rng);
 }
 
-static int pseries_rng_remove(struct vio_dev *dev)
+static void pseries_rng_remove(struct vio_dev *dev)
 {
        hwrng_unregister(&pseries_rng);
-       return 0;
 }
 
 static const struct vio_device_id pseries_rng_driver_ids[] = {
index aff0a8e44fffcff0e9f8422e61131459644796f2..776abbfd85d66c35e5bdc4093895667b83af06c8 100644 (file)
@@ -64,7 +64,6 @@
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Jonathan Buzzard <jonathan@buzzard.org.uk>");
 MODULE_DESCRIPTION("Toshiba laptop SMM driver");
-MODULE_SUPPORTED_DEVICE("toshiba");
 
 static DEFINE_MUTEX(tosh_mutex);
 static int tosh_fn;
index 994385bf37c0c044181f0ec2743779d80e09b38b..903604769de99cf2aa98e68145a3caa9f8a23e30 100644 (file)
@@ -343,7 +343,7 @@ static int ibmvtpm_crq_send_init_complete(struct ibmvtpm_dev *ibmvtpm)
  *
  * Return: Always 0.
  */
-static int tpm_ibmvtpm_remove(struct vio_dev *vdev)
+static void tpm_ibmvtpm_remove(struct vio_dev *vdev)
 {
        struct tpm_chip *chip = dev_get_drvdata(&vdev->dev);
        struct ibmvtpm_dev *ibmvtpm = dev_get_drvdata(&chip->dev);
@@ -372,8 +372,6 @@ static int tpm_ibmvtpm_remove(struct vio_dev *vdev)
        kfree(ibmvtpm);
        /* For tpm_ibmvtpm_get_desired_dma */
        dev_set_drvdata(&vdev->dev, NULL);
-
-       return 0;
 }
 
 /**
index ef2a974a2f1050410a982581e7f6b1943493f479..75bc401fdd189f3801be106acc1b527b010ccda9 100644 (file)
@@ -31,7 +31,7 @@ struct stm32_timer_cnt {
        struct counter_device counter;
        struct regmap *regmap;
        struct clk *clk;
-       u32 ceiling;
+       u32 max_arr;
        bool enabled;
        struct stm32_timer_regs bak;
 };
@@ -44,13 +44,14 @@ struct stm32_timer_cnt {
  * @STM32_COUNT_ENCODER_MODE_3: counts on both TI1FP1 and TI2FP2 edges
  */
 enum stm32_count_function {
-       STM32_COUNT_SLAVE_MODE_DISABLED = -1,
+       STM32_COUNT_SLAVE_MODE_DISABLED,
        STM32_COUNT_ENCODER_MODE_1,
        STM32_COUNT_ENCODER_MODE_2,
        STM32_COUNT_ENCODER_MODE_3,
 };
 
 static enum counter_count_function stm32_count_functions[] = {
+       [STM32_COUNT_SLAVE_MODE_DISABLED] = COUNTER_COUNT_FUNCTION_INCREASE,
        [STM32_COUNT_ENCODER_MODE_1] = COUNTER_COUNT_FUNCTION_QUADRATURE_X2_A,
        [STM32_COUNT_ENCODER_MODE_2] = COUNTER_COUNT_FUNCTION_QUADRATURE_X2_B,
        [STM32_COUNT_ENCODER_MODE_3] = COUNTER_COUNT_FUNCTION_QUADRATURE_X4,
@@ -73,8 +74,10 @@ static int stm32_count_write(struct counter_device *counter,
                             const unsigned long val)
 {
        struct stm32_timer_cnt *const priv = counter->priv;
+       u32 ceiling;
 
-       if (val > priv->ceiling)
+       regmap_read(priv->regmap, TIM_ARR, &ceiling);
+       if (val > ceiling)
                return -EINVAL;
 
        return regmap_write(priv->regmap, TIM_CNT, val);
@@ -90,6 +93,9 @@ static int stm32_count_function_get(struct counter_device *counter,
        regmap_read(priv->regmap, TIM_SMCR, &smcr);
 
        switch (smcr & TIM_SMCR_SMS) {
+       case 0:
+               *function = STM32_COUNT_SLAVE_MODE_DISABLED;
+               return 0;
        case 1:
                *function = STM32_COUNT_ENCODER_MODE_1;
                return 0;
@@ -99,9 +105,9 @@ static int stm32_count_function_get(struct counter_device *counter,
        case 3:
                *function = STM32_COUNT_ENCODER_MODE_3;
                return 0;
+       default:
+               return -EINVAL;
        }
-
-       return -EINVAL;
 }
 
 static int stm32_count_function_set(struct counter_device *counter,
@@ -112,6 +118,9 @@ static int stm32_count_function_set(struct counter_device *counter,
        u32 cr1, sms;
 
        switch (function) {
+       case STM32_COUNT_SLAVE_MODE_DISABLED:
+               sms = 0;
+               break;
        case STM32_COUNT_ENCODER_MODE_1:
                sms = 1;
                break;
@@ -122,8 +131,7 @@ static int stm32_count_function_set(struct counter_device *counter,
                sms = 3;
                break;
        default:
-               sms = 0;
-               break;
+               return -EINVAL;
        }
 
        /* Store enable status */
@@ -131,10 +139,6 @@ static int stm32_count_function_set(struct counter_device *counter,
 
        regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_CEN, 0);
 
-       /* TIMx_ARR register shouldn't be buffered (ARPE=0) */
-       regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_ARPE, 0);
-       regmap_write(priv->regmap, TIM_ARR, priv->ceiling);
-
        regmap_update_bits(priv->regmap, TIM_SMCR, TIM_SMCR_SMS, sms);
 
        /* Make sure that registers are updated */
@@ -185,11 +189,13 @@ static ssize_t stm32_count_ceiling_write(struct counter_device *counter,
        if (ret)
                return ret;
 
+       if (ceiling > priv->max_arr)
+               return -ERANGE;
+
        /* TIMx_ARR register shouldn't be buffered (ARPE=0) */
        regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_ARPE, 0);
        regmap_write(priv->regmap, TIM_ARR, ceiling);
 
-       priv->ceiling = ceiling;
        return len;
 }
 
@@ -274,31 +280,36 @@ static int stm32_action_get(struct counter_device *counter,
        size_t function;
        int err;
 
-       /* Default action mode (e.g. STM32_COUNT_SLAVE_MODE_DISABLED) */
-       *action = STM32_SYNAPSE_ACTION_NONE;
-
        err = stm32_count_function_get(counter, count, &function);
        if (err)
-               return 0;
+               return err;
 
        switch (function) {
+       case STM32_COUNT_SLAVE_MODE_DISABLED:
+               /* counts on internal clock when CEN=1 */
+               *action = STM32_SYNAPSE_ACTION_NONE;
+               return 0;
        case STM32_COUNT_ENCODER_MODE_1:
                /* counts up/down on TI1FP1 edge depending on TI2FP2 level */
                if (synapse->signal->id == count->synapses[0].signal->id)
                        *action = STM32_SYNAPSE_ACTION_BOTH_EDGES;
-               break;
+               else
+                       *action = STM32_SYNAPSE_ACTION_NONE;
+               return 0;
        case STM32_COUNT_ENCODER_MODE_2:
                /* counts up/down on TI2FP2 edge depending on TI1FP1 level */
                if (synapse->signal->id == count->synapses[1].signal->id)
                        *action = STM32_SYNAPSE_ACTION_BOTH_EDGES;
-               break;
+               else
+                       *action = STM32_SYNAPSE_ACTION_NONE;
+               return 0;
        case STM32_COUNT_ENCODER_MODE_3:
                /* counts up/down on both TI1FP1 and TI2FP2 edges */
                *action = STM32_SYNAPSE_ACTION_BOTH_EDGES;
-               break;
+               return 0;
+       default:
+               return -EINVAL;
        }
-
-       return 0;
 }
 
 static const struct counter_ops stm32_timer_cnt_ops = {
@@ -359,7 +370,7 @@ static int stm32_timer_cnt_probe(struct platform_device *pdev)
 
        priv->regmap = ddata->regmap;
        priv->clk = ddata->clk;
-       priv->ceiling = ddata->max_arr;
+       priv->max_arr = ddata->max_arr;
 
        priv->counter.name = dev_name(dev);
        priv->counter.parent = dev;
index 3ba2f716fe9783c829e99b6bff345098ba0b477f..5e07065ec22f7420483897314247834567800ae1 100644 (file)
@@ -103,6 +103,8 @@ static const struct of_device_id whitelist[] __initconst = {
 static const struct of_device_id blacklist[] __initconst = {
        { .compatible = "allwinner,sun50i-h6", },
 
+       { .compatible = "arm,vexpress", },
+
        { .compatible = "calxeda,highbank", },
        { .compatible = "calxeda,ecx-2000", },
 
index d3c23447b892d3e87c0fadb25351c5404aa3485b..f86859bf76f11d9f68b8d64a7b33ab75e274f3d5 100644 (file)
@@ -317,9 +317,9 @@ static int qcom_cpufreq_hw_cpu_init(struct cpufreq_policy *policy)
        }
 
        base = ioremap(res->start, resource_size(res));
-       if (IS_ERR(base)) {
+       if (!base) {
                dev_err(dev, "failed to map resource %pR\n", res);
-               ret = PTR_ERR(base);
+               ret = -ENOMEM;
                goto release_region;
        }
 
@@ -374,7 +374,7 @@ static int qcom_cpufreq_hw_cpu_init(struct cpufreq_policy *policy)
 error:
        kfree(data);
 unmap_base:
-       iounmap(data->base);
+       iounmap(base);
 release_region:
        release_mem_region(res->start, resource_size(res));
        return ret;
index 2de5e3672e4233e0ab3673c04627146129ff5d64..cc8dd3072b8b77f0b9acb4971d80a68d1e3718fc 100644 (file)
@@ -1042,7 +1042,7 @@ error:
        return ret;
 }
 
-static int nx842_remove(struct vio_dev *viodev)
+static void nx842_remove(struct vio_dev *viodev)
 {
        struct nx842_devdata *old_devdata;
        unsigned long flags;
@@ -1063,8 +1063,6 @@ static int nx842_remove(struct vio_dev *viodev)
        if (old_devdata)
                kfree(old_devdata->counters);
        kfree(old_devdata);
-
-       return 0;
 }
 
 static const struct vio_device_id nx842_vio_driver_ids[] = {
index 0d2dc5be7f1925f55f930edc651b2e7c8483c56a..1d0e8a1ba160507337f71ebb8d541ec7c09d76e5 100644 (file)
@@ -783,7 +783,7 @@ static int nx_probe(struct vio_dev *viodev, const struct vio_device_id *id)
        return nx_register_algs();
 }
 
-static int nx_remove(struct vio_dev *viodev)
+static void nx_remove(struct vio_dev *viodev)
 {
        dev_dbg(&viodev->dev, "entering nx_remove for UA 0x%x\n",
                viodev->unit_address);
@@ -811,8 +811,6 @@ static int nx_remove(struct vio_dev *viodev)
                nx_unregister_skcipher(&nx_ecb_aes_alg, NX_FC_AES,
                                       NX_MODE_AES_ECB);
        }
-
-       return 0;
 }
 
 
index df3f9bcab581c430df52347c2eba41950811d07e..4b7ee3fa9224ff809a89b88bbae5cea765d9dbeb 100644 (file)
@@ -927,7 +927,7 @@ int __ref efi_mem_reserve_persistent(phys_addr_t addr, u64 size)
        }
 
        /* first try to find a slot in an existing linked list entry */
-       for (prsv = efi_memreserve_root->next; prsv; prsv = rsv->next) {
+       for (prsv = efi_memreserve_root->next; prsv; ) {
                rsv = memremap(prsv, sizeof(*rsv), MEMREMAP_WB);
                index = atomic_fetch_add_unless(&rsv->count, 1, rsv->size);
                if (index < rsv->size) {
@@ -937,6 +937,7 @@ int __ref efi_mem_reserve_persistent(phys_addr_t addr, u64 size)
                        memunmap(rsv);
                        return efi_mem_reserve_iomem(addr, size);
                }
+               prsv = rsv->next;
                memunmap(rsv);
        }
 
index b69d63143e0d833449f5701cd114257987109e4a..7bf0a7acae5e689f8f3470ead6b67dc54ac08f2c 100644 (file)
@@ -24,7 +24,7 @@ efi_status_t check_platform_features(void)
                return EFI_SUCCESS;
 
        tg = (read_cpuid(ID_AA64MMFR0_EL1) >> ID_AA64MMFR0_TGRAN_SHIFT) & 0xf;
-       if (tg != ID_AA64MMFR0_TGRAN_SUPPORTED) {
+       if (tg < ID_AA64MMFR0_TGRAN_SUPPORTED_MIN || tg > ID_AA64MMFR0_TGRAN_SUPPORTED_MAX) {
                if (IS_ENABLED(CONFIG_ARM64_64K_PAGES))
                        efi_err("This 64 KB granular kernel is not supported by your CPU\n");
                else
index ec2f3985bef351b1a389284c1d202646cf699b2c..26e69788f27a42dd1fcbceeeb8bab3085b59a526 100644 (file)
@@ -96,6 +96,18 @@ static void install_memreserve_table(void)
                efi_err("Failed to install memreserve config table!\n");
 }
 
+static u32 get_supported_rt_services(void)
+{
+       const efi_rt_properties_table_t *rt_prop_table;
+       u32 supported = EFI_RT_SUPPORTED_ALL;
+
+       rt_prop_table = get_efi_config_table(EFI_RT_PROPERTIES_TABLE_GUID);
+       if (rt_prop_table)
+               supported &= rt_prop_table->runtime_services_supported;
+
+       return supported;
+}
+
 /*
  * EFI entry point for the arm/arm64 EFI stubs.  This is the entrypoint
  * that is described in the PE/COFF header.  Most of the code is the same
@@ -250,6 +262,10 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
                          (prop_tbl->memory_protection_attribute &
                           EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA);
 
+       /* force efi_novamap if SetVirtualAddressMap() is unsupported */
+       efi_novamap |= !(get_supported_rt_services() &
+                        EFI_RT_SUPPORTED_SET_VIRTUAL_ADDRESS_MAP);
+
        /* hibernation expects the runtime regions to stay in the same place */
        if (!IS_ENABLED(CONFIG_HIBERNATION) && !efi_nokaslr && !flat_va_mapping) {
                /*
index 41c1d00bf933c682d45144880c0ba1099057603b..abdc8a6a396318a915455dd73e26439b88c1b003 100644 (file)
@@ -484,6 +484,10 @@ int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *),
                                }
                        }
 
+                       break;
+               case EFI_UNSUPPORTED:
+                       err = -EOPNOTSUPP;
+                       status = EFI_NOT_FOUND;
                        break;
                case EFI_NOT_FOUND:
                        break;
index 5ea09fd01544482aaadda083a0dae7de0f54a924..c91d0565159661967faa6a73ae0dfc9834fcfada 100644 (file)
@@ -113,8 +113,29 @@ MODULE_DEVICE_TABLE(i2c, pca953x_id);
 #ifdef CONFIG_GPIO_PCA953X_IRQ
 
 #include <linux/dmi.h>
-#include <linux/gpio.h>
-#include <linux/list.h>
+
+static const struct acpi_gpio_params pca953x_irq_gpios = { 0, 0, true };
+
+static const struct acpi_gpio_mapping pca953x_acpi_irq_gpios[] = {
+       { "irq-gpios", &pca953x_irq_gpios, 1, ACPI_GPIO_QUIRK_ABSOLUTE_NUMBER },
+       { }
+};
+
+static int pca953x_acpi_get_irq(struct device *dev)
+{
+       int ret;
+
+       ret = devm_acpi_dev_add_driver_gpios(dev, pca953x_acpi_irq_gpios);
+       if (ret)
+               dev_warn(dev, "can't add GPIO ACPI mapping\n");
+
+       ret = acpi_dev_gpio_irq_get_by(ACPI_COMPANION(dev), "irq-gpios", 0);
+       if (ret < 0)
+               return ret;
+
+       dev_info(dev, "ACPI interrupt quirk (IRQ %d)\n", ret);
+       return ret;
+}
 
 static const struct dmi_system_id pca953x_dmi_acpi_irq_info[] = {
        {
@@ -133,59 +154,6 @@ static const struct dmi_system_id pca953x_dmi_acpi_irq_info[] = {
        },
        {}
 };
-
-#ifdef CONFIG_ACPI
-static int pca953x_acpi_get_pin(struct acpi_resource *ares, void *data)
-{
-       struct acpi_resource_gpio *agpio;
-       int *pin = data;
-
-       if (acpi_gpio_get_irq_resource(ares, &agpio))
-               *pin = agpio->pin_table[0];
-       return 1;
-}
-
-static int pca953x_acpi_find_pin(struct device *dev)
-{
-       struct acpi_device *adev = ACPI_COMPANION(dev);
-       int pin = -ENOENT, ret;
-       LIST_HEAD(r);
-
-       ret = acpi_dev_get_resources(adev, &r, pca953x_acpi_get_pin, &pin);
-       acpi_dev_free_resource_list(&r);
-       if (ret < 0)
-               return ret;
-
-       return pin;
-}
-#else
-static inline int pca953x_acpi_find_pin(struct device *dev) { return -ENXIO; }
-#endif
-
-static int pca953x_acpi_get_irq(struct device *dev)
-{
-       int pin, ret;
-
-       pin = pca953x_acpi_find_pin(dev);
-       if (pin < 0)
-               return pin;
-
-       dev_info(dev, "Applying ACPI interrupt quirk (GPIO %d)\n", pin);
-
-       if (!gpio_is_valid(pin))
-               return -EINVAL;
-
-       ret = gpio_request(pin, "pca953x interrupt");
-       if (ret)
-               return ret;
-
-       ret = gpio_to_irq(pin);
-
-       /* When pin is used as an IRQ, no need to keep it requested */
-       gpio_free(pin);
-
-       return ret;
-}
 #endif
 
 static const struct acpi_device_id pca953x_acpi_ids[] = {
index e37a57d0a2f07f44a2bf4426b3909f97c0ab7e8b..1aacd2a5a1fd53560469dbd3571a7929f4a4e4ca 100644 (file)
@@ -174,7 +174,7 @@ static void acpi_gpiochip_request_irq(struct acpi_gpio_chip *acpi_gpio,
        int ret, value;
 
        ret = request_threaded_irq(event->irq, NULL, event->handler,
-                                  event->irqflags, "ACPI:Event", event);
+                                  event->irqflags | IRQF_ONESHOT, "ACPI:Event", event);
        if (ret) {
                dev_err(acpi_gpio->chip->parent,
                        "Failed to setup interrupt handler for %d\n",
@@ -677,6 +677,7 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data)
        if (!lookup->desc) {
                const struct acpi_resource_gpio *agpio = &ares->data.gpio;
                bool gpioint = agpio->connection_type == ACPI_RESOURCE_GPIO_TYPE_INT;
+               struct gpio_desc *desc;
                u16 pin_index;
 
                if (lookup->info.quirks & ACPI_GPIO_QUIRK_ONLY_GPIOIO && gpioint)
@@ -689,8 +690,12 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data)
                if (pin_index >= agpio->pin_table_length)
                        return 1;
 
-               lookup->desc = acpi_get_gpiod(agpio->resource_source.string_ptr,
+               if (lookup->info.quirks & ACPI_GPIO_QUIRK_ABSOLUTE_NUMBER)
+                       desc = gpio_to_desc(agpio->pin_table[pin_index]);
+               else
+                       desc = acpi_get_gpiod(agpio->resource_source.string_ptr,
                                              agpio->pin_table[pin_index]);
+               lookup->desc = desc;
                lookup->info.pin_config = agpio->pin_config;
                lookup->info.debounce = agpio->debounce_timeout;
                lookup->info.gpioint = gpioint;
@@ -940,8 +945,9 @@ struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode,
 }
 
 /**
- * acpi_dev_gpio_irq_get() - Find GpioInt and translate it to Linux IRQ number
+ * acpi_dev_gpio_irq_get_by() - Find GpioInt and translate it to Linux IRQ number
  * @adev: pointer to a ACPI device to get IRQ from
+ * @name: optional name of GpioInt resource
  * @index: index of GpioInt resource (starting from %0)
  *
  * If the device has one or more GpioInt resources, this function can be
@@ -951,9 +957,12 @@ struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode,
  * The function is idempotent, though each time it runs it will configure GPIO
  * pin direction according to the flags in GpioInt resource.
  *
+ * The function takes optional @name parameter. If the resource has a property
+ * name, then only those will be taken into account.
+ *
  * Return: Linux IRQ number (> %0) on success, negative errno on failure.
  */
-int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
+int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, int index)
 {
        int idx, i;
        unsigned int irq_flags;
@@ -963,7 +972,7 @@ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
                struct acpi_gpio_info info;
                struct gpio_desc *desc;
 
-               desc = acpi_get_gpiod_by_index(adev, NULL, i, &info);
+               desc = acpi_get_gpiod_by_index(adev, name, i, &info);
 
                /* Ignore -EPROBE_DEFER, it only matters if idx matches */
                if (IS_ERR(desc) && PTR_ERR(desc) != -EPROBE_DEFER)
@@ -1008,7 +1017,7 @@ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
        }
        return -ENOENT;
 }
-EXPORT_SYMBOL_GPL(acpi_dev_gpio_irq_get);
+EXPORT_SYMBOL_GPL(acpi_dev_gpio_irq_get_by);
 
 static acpi_status
 acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
index adf55db080d86f1d3c07832972e2a468e53380e3..6367646dce83b3fb30a2b5002ee8de48f77749a5 100644 (file)
@@ -367,22 +367,18 @@ static int gpiochip_set_desc_names(struct gpio_chip *gc)
  *
  * Looks for device property "gpio-line-names" and if it exists assigns
  * GPIO line names for the chip. The memory allocated for the assigned
- * names belong to the underlying software node and should not be released
+ * names belong to the underlying firmware node and should not be released
  * by the caller.
  */
 static int devprop_gpiochip_set_names(struct gpio_chip *chip)
 {
        struct gpio_device *gdev = chip->gpiodev;
-       struct device *dev = chip->parent;
+       struct fwnode_handle *fwnode = dev_fwnode(&gdev->dev);
        const char **names;
        int ret, i;
        int count;
 
-       /* GPIO chip may not have a parent device whose properties we inspect. */
-       if (!dev)
-               return 0;
-
-       count = device_property_string_array_count(dev, "gpio-line-names");
+       count = fwnode_property_string_array_count(fwnode, "gpio-line-names");
        if (count < 0)
                return 0;
 
@@ -396,7 +392,7 @@ static int devprop_gpiochip_set_names(struct gpio_chip *chip)
        if (!names)
                return -ENOMEM;
 
-       ret = device_property_read_string_array(dev, "gpio-line-names",
+       ret = fwnode_property_read_string_array(fwnode, "gpio-line-names",
                                                names, count);
        if (ret < 0) {
                dev_warn(&gdev->dev, "failed to read GPIO line names\n");
@@ -474,9 +470,13 @@ EXPORT_SYMBOL_GPL(gpiochip_line_is_valid);
 
 static void gpiodevice_release(struct device *dev)
 {
-       struct gpio_device *gdev = dev_get_drvdata(dev);
+       struct gpio_device *gdev = container_of(dev, struct gpio_device, dev);
+       unsigned long flags;
 
+       spin_lock_irqsave(&gpio_lock, flags);
        list_del(&gdev->list);
+       spin_unlock_irqrestore(&gpio_lock, flags);
+
        ida_free(&gpio_ida, gdev->id);
        kfree_const(gdev->label);
        kfree(gdev->descs);
@@ -571,6 +571,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
                               struct lock_class_key *lock_key,
                               struct lock_class_key *request_key)
 {
+       struct fwnode_handle *fwnode = gc->parent ? dev_fwnode(gc->parent) : NULL;
        unsigned long   flags;
        int             ret = 0;
        unsigned        i;
@@ -594,6 +595,12 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
 
        of_gpio_dev_init(gc, gdev);
 
+       /*
+        * Assign fwnode depending on the result of the previous calls,
+        * if none of them succeed, assign it to the parent's one.
+        */
+       gdev->dev.fwnode = dev_fwnode(&gdev->dev) ?: fwnode;
+
        gdev->id = ida_alloc(&gpio_ida, GFP_KERNEL);
        if (gdev->id < 0) {
                ret = gdev->id;
@@ -605,7 +612,6 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
                goto err_free_ida;
 
        device_initialize(&gdev->dev);
-       dev_set_drvdata(&gdev->dev, gdev);
        if (gc->parent && gc->parent->driver)
                gdev->owner = gc->parent->driver->owner;
        else if (gc->owner)
@@ -4257,7 +4263,8 @@ static int __init gpiolib_dev_init(void)
                return ret;
        }
 
-       if (driver_register(&gpio_stub_drv) < 0) {
+       ret = driver_register(&gpio_stub_drv);
+       if (ret < 0) {
                pr_err("gpiolib: could not register GPIO stub driver\n");
                bus_unregister(&gpio_bus_type);
                return ret;
index e392a90ca6876cc3dcec88baacb3bc4099bbac6c..85b79a7fee630b708868a1acb43ae61ea8accb10 100644 (file)
@@ -228,6 +228,7 @@ source "drivers/gpu/drm/arm/Kconfig"
 config DRM_RADEON
        tristate "ATI Radeon"
        depends on DRM && PCI && MMU
+       depends on AGP || !AGP
        select FW_LOADER
         select DRM_KMS_HELPER
         select DRM_TTM
index b6879d97c9c9c16fe055fb6c3cfee2f8491ab7fb..49267eb64302d28e010b23d15117d80f68693917 100644 (file)
@@ -180,6 +180,7 @@ extern uint amdgpu_smu_memory_pool_size;
 extern uint amdgpu_dc_feature_mask;
 extern uint amdgpu_dc_debug_mask;
 extern uint amdgpu_dm_abm_level;
+extern int amdgpu_backlight;
 extern struct amdgpu_mgpu_info mgpu_info;
 extern int amdgpu_ras_enable;
 extern uint amdgpu_ras_mask;
index 36a741d63ddcf602ca408e025b7b198b43157d2a..2e9b16fb3fcd149b2063b05a9c936e3f0e5a42f9 100644 (file)
@@ -903,7 +903,7 @@ void amdgpu_acpi_fini(struct amdgpu_device *adev)
  */
 bool amdgpu_acpi_is_s0ix_supported(struct amdgpu_device *adev)
 {
-#if defined(CONFIG_AMD_PMC)
+#if defined(CONFIG_AMD_PMC) || defined(CONFIG_AMD_PMC_MODULE)
        if (acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0) {
                if (adev->flags & AMD_IS_APU)
                        return true;
index 4575192d9b087a0e0336ea3618a6a22b0c557a37..b26e2fd1c538433899a2f9ec8249317c8543e258 100644 (file)
@@ -781,6 +781,10 @@ uint amdgpu_dm_abm_level;
 MODULE_PARM_DESC(abmlevel, "ABM level (0 = off (default), 1-4 = backlight reduction level) ");
 module_param_named(abmlevel, amdgpu_dm_abm_level, uint, 0444);
 
+int amdgpu_backlight = -1;
+MODULE_PARM_DESC(backlight, "Backlight control (0 = pwm, 1 = aux, -1 auto (default))");
+module_param_named(backlight, amdgpu_backlight, bint, 0444);
+
 /**
  * DOC: tmz (int)
  * Trusted Memory Zone (TMZ) is a method to protect data being written
index 51cd49c6f38fd06f58369e3265cafa5367573a3f..24010cacf7d0ec87f37b41a45b1c820f3f85882c 100644 (file)
@@ -146,7 +146,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
        size = mode_cmd->pitches[0] * height;
        aligned_size = ALIGN(size, PAGE_SIZE);
        ret = amdgpu_gem_object_create(adev, aligned_size, 0, domain, flags,
-                                      ttm_bo_type_kernel, NULL, &gobj);
+                                      ttm_bo_type_device, NULL, &gobj);
        if (ret) {
                pr_err("failed to allocate framebuffer (%d)\n", aligned_size);
                return -ENOMEM;
index 3e1fd1e7d09f1d4e3c017d5607bef69c19948a58..573cf17262da4e116154dc0bb199ef2fc9de4add 100644 (file)
@@ -2267,6 +2267,11 @@ static void update_connector_ext_caps(struct amdgpu_dm_connector *aconnector)
            caps->ext_caps->bits.hdr_aux_backlight_control == 1)
                caps->aux_support = true;
 
+       if (amdgpu_backlight == 0)
+               caps->aux_support = false;
+       else if (amdgpu_backlight == 1)
+               caps->aux_support = true;
+
        /* From the specification (CTA-861-G), for calculating the maximum
         * luminance we need to use:
         *      Luminance = 50*2**(CV/32)
@@ -3185,19 +3190,6 @@ static void amdgpu_dm_update_backlight_caps(struct amdgpu_display_manager *dm)
 #endif
 }
 
-static int set_backlight_via_aux(struct dc_link *link, uint32_t brightness)
-{
-       bool rc;
-
-       if (!link)
-               return 1;
-
-       rc = dc_link_set_backlight_level_nits(link, true, brightness,
-                                             AUX_BL_DEFAULT_TRANSITION_TIME_MS);
-
-       return rc ? 0 : 1;
-}
-
 static int get_brightness_range(const struct amdgpu_dm_backlight_caps *caps,
                                unsigned *min, unsigned *max)
 {
@@ -3260,9 +3252,10 @@ static int amdgpu_dm_backlight_update_status(struct backlight_device *bd)
        brightness = convert_brightness_from_user(&caps, bd->props.brightness);
        // Change brightness based on AUX property
        if (caps.aux_support)
-               return set_backlight_via_aux(link, brightness);
-
-       rc = dc_link_set_backlight_level(dm->backlight_link, brightness, 0);
+               rc = dc_link_set_backlight_level_nits(link, true, brightness,
+                                                     AUX_BL_DEFAULT_TRANSITION_TIME_MS);
+       else
+               rc = dc_link_set_backlight_level(dm->backlight_link, brightness, 0);
 
        return rc ? 0 : 1;
 }
@@ -3270,11 +3263,27 @@ static int amdgpu_dm_backlight_update_status(struct backlight_device *bd)
 static int amdgpu_dm_backlight_get_brightness(struct backlight_device *bd)
 {
        struct amdgpu_display_manager *dm = bl_get_data(bd);
-       int ret = dc_link_get_backlight_level(dm->backlight_link);
+       struct amdgpu_dm_backlight_caps caps;
+
+       amdgpu_dm_update_backlight_caps(dm);
+       caps = dm->backlight_caps;
+
+       if (caps.aux_support) {
+               struct dc_link *link = (struct dc_link *)dm->backlight_link;
+               u32 avg, peak;
+               bool rc;
 
-       if (ret == DC_ERROR_UNEXPECTED)
-               return bd->props.brightness;
-       return convert_brightness_to_user(&dm->backlight_caps, ret);
+               rc = dc_link_get_backlight_level_nits(link, &avg, &peak);
+               if (!rc)
+                       return bd->props.brightness;
+               return convert_brightness_to_user(&caps, avg);
+       } else {
+               int ret = dc_link_get_backlight_level(dm->backlight_link);
+
+               if (ret == DC_ERROR_UNEXPECTED)
+                       return bd->props.brightness;
+               return convert_brightness_to_user(&caps, ret);
+       }
 }
 
 static const struct backlight_ops amdgpu_dm_backlight_ops = {
@@ -4716,6 +4725,7 @@ static int fill_dc_plane_attributes(struct amdgpu_device *adev,
        dc_plane_state->global_alpha_value = plane_info.global_alpha_value;
        dc_plane_state->dcc = plane_info.dcc;
        dc_plane_state->layer_index = plane_info.layer_index; // Always returns 0
+       dc_plane_state->flip_int_enabled = true;
 
        /*
         * Always set input transfer function, since plane state is refreshed
index fa5059f71727a16463d990e1ebd54c7fcc480634..bd0101013ec8926307f0fb0b42d536434eb761db 100644 (file)
@@ -2602,7 +2602,6 @@ bool dc_link_set_backlight_level(const struct dc_link *link,
                        if (pipe_ctx->plane_state == NULL)
                                frame_ramp = 0;
                } else {
-                       ASSERT(false);
                        return false;
                }
 
index 4eee3a55fa3018ad0f65bfe50f1e949fbf4de7ac..18ed0d3f247eaec26a0b797603242bbf5e2b9348 100644 (file)
@@ -887,6 +887,7 @@ struct dc_plane_state {
        int layer_index;
 
        union surface_update_flags update_flags;
+       bool flip_int_enabled;
        /* private to DC core */
        struct dc_plane_status status;
        struct dc_context *ctx;
index 9e796dfeac2040ea26699b0505c980aaa504c28e..714c71a5fbde3f34e1e16915b5a00583f99fa221 100644 (file)
@@ -1257,6 +1257,16 @@ void hubp1_soft_reset(struct hubp *hubp, bool reset)
        REG_UPDATE(DCHUBP_CNTL, HUBP_DISABLE, reset ? 1 : 0);
 }
 
+void hubp1_set_flip_int(struct hubp *hubp)
+{
+       struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp);
+
+       REG_UPDATE(DCSURF_SURFACE_FLIP_INTERRUPT,
+               SURFACE_FLIP_INT_MASK, 1);
+
+       return;
+}
+
 void hubp1_init(struct hubp *hubp)
 {
        //do nothing
@@ -1290,6 +1300,7 @@ static const struct hubp_funcs dcn10_hubp_funcs = {
        .dmdata_load = NULL,
        .hubp_soft_reset = hubp1_soft_reset,
        .hubp_in_blank = hubp1_in_blank,
+       .hubp_set_flip_int = hubp1_set_flip_int,
 };
 
 /*****************************************/
index a9a6ed7f4f9932345954fbbdd78dd49760330131..e2f2f6995935f062f09443f73d63dca626badc30 100644 (file)
@@ -74,6 +74,7 @@
        SRI(DCSURF_SURFACE_EARLIEST_INUSE_C, HUBPREQ, id),\
        SRI(DCSURF_SURFACE_EARLIEST_INUSE_HIGH_C, HUBPREQ, id),\
        SRI(DCSURF_SURFACE_CONTROL, HUBPREQ, id),\
+       SRI(DCSURF_SURFACE_FLIP_INTERRUPT, HUBPREQ, id),\
        SRI(HUBPRET_CONTROL, HUBPRET, id),\
        SRI(DCN_EXPANSION_MODE, HUBPREQ, id),\
        SRI(DCHUBP_REQ_SIZE_CONFIG, HUBP, id),\
        uint32_t DCSURF_SURFACE_EARLIEST_INUSE_C; \
        uint32_t DCSURF_SURFACE_EARLIEST_INUSE_HIGH_C; \
        uint32_t DCSURF_SURFACE_CONTROL; \
+       uint32_t DCSURF_SURFACE_FLIP_INTERRUPT; \
        uint32_t HUBPRET_CONTROL; \
        uint32_t DCN_EXPANSION_MODE; \
        uint32_t DCHUBP_REQ_SIZE_CONFIG; \
        HUBP_SF(HUBPREQ0_DCSURF_SURFACE_CONTROL, SECONDARY_META_SURFACE_TMZ_C, mask_sh),\
        HUBP_SF(HUBPREQ0_DCSURF_SURFACE_CONTROL, SECONDARY_SURFACE_DCC_EN, mask_sh),\
        HUBP_SF(HUBPREQ0_DCSURF_SURFACE_CONTROL, SECONDARY_SURFACE_DCC_IND_64B_BLK, mask_sh),\
+       HUBP_SF(HUBPREQ0_DCSURF_SURFACE_FLIP_INTERRUPT, SURFACE_FLIP_INT_MASK, mask_sh),\
        HUBP_SF(HUBPRET0_HUBPRET_CONTROL, DET_BUF_PLANE1_BASE_ADDRESS, mask_sh),\
        HUBP_SF(HUBPRET0_HUBPRET_CONTROL, CROSSBAR_SRC_CB_B, mask_sh),\
        HUBP_SF(HUBPRET0_HUBPRET_CONTROL, CROSSBAR_SRC_CR_R, mask_sh),\
        type PRIMARY_SURFACE_DCC_IND_64B_BLK;\
        type SECONDARY_SURFACE_DCC_EN;\
        type SECONDARY_SURFACE_DCC_IND_64B_BLK;\
+       type SURFACE_FLIP_INT_MASK;\
        type DET_BUF_PLANE1_BASE_ADDRESS;\
        type CROSSBAR_SRC_CB_B;\
        type CROSSBAR_SRC_CR_R;\
@@ -777,4 +781,6 @@ void hubp1_read_state_common(struct hubp *hubp);
 bool hubp1_in_blank(struct hubp *hubp);
 void hubp1_soft_reset(struct hubp *hubp, bool reset);
 
+void hubp1_set_flip_int(struct hubp *hubp);
+
 #endif
index 89912bb5014f86fe5c57d756b6c209ea8eb02155..9ba5c624770ded1cf08683545bddc1bf50c3661d 100644 (file)
@@ -2196,6 +2196,13 @@ static void dcn10_enable_plane(
        if (dc->debug.sanity_checks) {
                hws->funcs.verify_allow_pstate_change_high(dc);
        }
+
+       if (!pipe_ctx->top_pipe
+               && pipe_ctx->plane_state
+               && pipe_ctx->plane_state->flip_int_enabled
+               && pipe_ctx->plane_res.hubp->funcs->hubp_set_flip_int)
+                       pipe_ctx->plane_res.hubp->funcs->hubp_set_flip_int(pipe_ctx->plane_res.hubp);
+
 }
 
 void dcn10_program_gamut_remap(struct pipe_ctx *pipe_ctx)
index 0df0da2e6a4d05f3c3256913273e41d066bf165f..bec7059f6d5d1579ed84b905f4f2bcd993bfd579 100644 (file)
@@ -1597,6 +1597,7 @@ static struct hubp_funcs dcn20_hubp_funcs = {
        .validate_dml_output = hubp2_validate_dml_output,
        .hubp_in_blank = hubp1_in_blank,
        .hubp_soft_reset = hubp1_soft_reset,
+       .hubp_set_flip_int = hubp1_set_flip_int,
 };
 
 
index 0726fb435e2a3c175138262f9f3151223aabf77e..aece1103331dd29e7b1d6516265f9646f36c22e1 100644 (file)
@@ -1146,6 +1146,12 @@ void dcn20_enable_plane(
                pipe_ctx->plane_res.hubp->funcs->hubp_set_vm_system_aperture_settings(pipe_ctx->plane_res.hubp, &apt);
        }
 
+       if (!pipe_ctx->top_pipe
+               && pipe_ctx->plane_state
+               && pipe_ctx->plane_state->flip_int_enabled
+               && pipe_ctx->plane_res.hubp->funcs->hubp_set_flip_int)
+                       pipe_ctx->plane_res.hubp->funcs->hubp_set_flip_int(pipe_ctx->plane_res.hubp);
+
 //     if (dc->debug.sanity_checks) {
 //             dcn10_verify_allow_pstate_change_high(dc);
 //     }
@@ -1501,38 +1507,8 @@ static void dcn20_update_dchubp_dpp(
        if (pipe_ctx->update_flags.bits.enable || pipe_ctx->update_flags.bits.opp_changed
                        || pipe_ctx->stream->update_flags.bits.gamut_remap
                        || pipe_ctx->stream->update_flags.bits.out_csc) {
-               struct mpc *mpc = pipe_ctx->stream_res.opp->ctx->dc->res_pool->mpc;
-
-               if (mpc->funcs->set_gamut_remap) {
-                       int i;
-                       int mpcc_id = hubp->inst;
-                       struct mpc_grph_gamut_adjustment adjust;
-                       bool enable_remap_dpp = false;
-
-                       memset(&adjust, 0, sizeof(adjust));
-                       adjust.gamut_adjust_type = GRAPHICS_GAMUT_ADJUST_TYPE_BYPASS;
-
-                       /* save the enablement of gamut remap for dpp */
-                       enable_remap_dpp = pipe_ctx->stream->gamut_remap_matrix.enable_remap;
-
-                       /* force bypass gamut remap for dpp/cm */
-                       pipe_ctx->stream->gamut_remap_matrix.enable_remap = false;
-                       dc->hwss.program_gamut_remap(pipe_ctx);
-
-                       /* restore gamut remap flag and use this remap into mpc */
-                       pipe_ctx->stream->gamut_remap_matrix.enable_remap = enable_remap_dpp;
-
-                       /* build remap matrix for top plane if enabled */
-                       if (enable_remap_dpp && pipe_ctx->top_pipe == NULL) {
-                                       adjust.gamut_adjust_type = GRAPHICS_GAMUT_ADJUST_TYPE_SW;
-                                       for (i = 0; i < CSC_TEMPERATURE_MATRIX_SIZE; i++)
-                                               adjust.temperature_matrix[i] =
-                                                               pipe_ctx->stream->gamut_remap_matrix.matrix[i];
-                       }
-                       mpc->funcs->set_gamut_remap(mpc, mpcc_id, &adjust);
-               } else
-                       /* dpp/cm gamut remap*/
-                       dc->hwss.program_gamut_remap(pipe_ctx);
+               /* dpp/cm gamut remap*/
+               dc->hwss.program_gamut_remap(pipe_ctx);
 
                /*call the dcn2 method which uses mpc csc*/
                dc->hwss.program_output_csc(dc,
index f9045852728fe5fb0a0b6f8416a0ac188e51a737..b0c9180b808f6cf577bde2704331cad17b173451 100644 (file)
@@ -838,6 +838,7 @@ static struct hubp_funcs dcn21_hubp_funcs = {
        .hubp_set_flip_control_surface_gsl = hubp2_set_flip_control_surface_gsl,
        .hubp_init = hubp21_init,
        .validate_dml_output = hubp21_validate_dml_output,
+       .hubp_set_flip_int = hubp1_set_flip_int,
 };
 
 bool hubp21_construct(
index 072f8c880924366ffd42477a3ffd79886611748a..4a3df13c9e49add02f04e27abdd938b97f653077 100644 (file)
@@ -296,7 +296,7 @@ struct _vcs_dpi_soc_bounding_box_st dcn2_1_soc = {
        .num_banks = 8,
        .num_chans = 4,
        .vmm_page_size_bytes = 4096,
-       .dram_clock_change_latency_us = 11.72,
+       .dram_clock_change_latency_us = 23.84,
        .return_bus_width_bytes = 64,
        .dispclk_dppclk_vco_speed_mhz = 3600,
        .xfc_bus_transport_time_us = 4,
@@ -1062,8 +1062,6 @@ static void patch_bounding_box(struct dc *dc, struct _vcs_dpi_soc_bounding_box_s
 {
        int i;
 
-       DC_FP_START();
-
        if (dc->bb_overrides.sr_exit_time_ns) {
                for (i = 0; i < WM_SET_COUNT; i++) {
                          dc->clk_mgr->bw_params->wm_table.entries[i].sr_exit_time_us =
@@ -1088,8 +1086,6 @@ static void patch_bounding_box(struct dc *dc, struct _vcs_dpi_soc_bounding_box_s
                                dc->bb_overrides.dram_clock_change_latency_ns / 1000.0;
                }
        }
-
-       DC_FP_END();
 }
 
 void dcn21_calculate_wm(
@@ -1339,7 +1335,7 @@ static noinline bool dcn21_validate_bandwidth_fp(struct dc *dc,
        int vlevel = 0;
        int pipe_split_from[MAX_PIPES];
        int pipe_cnt = 0;
-       display_e2e_pipe_params_st *pipes = kzalloc(dc->res_pool->pipe_count * sizeof(display_e2e_pipe_params_st), GFP_KERNEL);
+       display_e2e_pipe_params_st *pipes = kzalloc(dc->res_pool->pipe_count * sizeof(display_e2e_pipe_params_st), GFP_ATOMIC);
        DC_LOGGER_INIT(dc->ctx->logger);
 
        BW_VAL_TRACE_COUNT();
@@ -1599,6 +1595,11 @@ static void update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_param
        dcn2_1_soc.num_chans = bw_params->num_channels;
 
        ASSERT(clk_table->num_entries);
+       /* Copy dcn2_1_soc.clock_limits to clock_limits to avoid copying over null states later */
+       for (i = 0; i < dcn2_1_soc.num_states + 1; i++) {
+               clock_limits[i] = dcn2_1_soc.clock_limits[i];
+       }
+
        for (i = 0; i < clk_table->num_entries; i++) {
                /* loop backwards*/
                for (closest_clk_lvl = 0, j = dcn2_1_soc.num_states - 1; j >= 0; j--) {
index 41a1d0e9b7e207bb855bc268f897eba21078b769..e0df9b0065f9c05a528c7eec66a187ba126d80ed 100644 (file)
@@ -113,6 +113,7 @@ bool cm3_helper_translate_curve_to_hw_format(
        struct pwl_result_data *rgb_resulted;
        struct pwl_result_data *rgb;
        struct pwl_result_data *rgb_plus_1;
+       struct pwl_result_data *rgb_minus_1;
        struct fixed31_32 end_value;
 
        int32_t region_start, region_end;
@@ -140,7 +141,7 @@ bool cm3_helper_translate_curve_to_hw_format(
                region_start = -MAX_LOW_POINT;
                region_end   = NUMBER_REGIONS - MAX_LOW_POINT;
        } else {
-               /* 10 segments
+               /* 11 segments
                 * segment is from 2^-10 to 2^0
                 * There are less than 256 points, for optimization
                 */
@@ -154,9 +155,10 @@ bool cm3_helper_translate_curve_to_hw_format(
                seg_distr[7] = 4;
                seg_distr[8] = 4;
                seg_distr[9] = 4;
+               seg_distr[10] = 1;
 
                region_start = -10;
-               region_end = 0;
+               region_end = 1;
        }
 
        for (i = region_end - region_start; i < MAX_REGIONS_NUMBER ; i++)
@@ -189,6 +191,10 @@ bool cm3_helper_translate_curve_to_hw_format(
        rgb_resulted[hw_points - 1].green = output_tf->tf_pts.green[start_index];
        rgb_resulted[hw_points - 1].blue = output_tf->tf_pts.blue[start_index];
 
+       rgb_resulted[hw_points].red = rgb_resulted[hw_points - 1].red;
+       rgb_resulted[hw_points].green = rgb_resulted[hw_points - 1].green;
+       rgb_resulted[hw_points].blue = rgb_resulted[hw_points - 1].blue;
+
        // All 3 color channels have same x
        corner_points[0].red.x = dc_fixpt_pow(dc_fixpt_from_int(2),
                                             dc_fixpt_from_int(region_start));
@@ -259,15 +265,18 @@ bool cm3_helper_translate_curve_to_hw_format(
 
        rgb = rgb_resulted;
        rgb_plus_1 = rgb_resulted + 1;
+       rgb_minus_1 = rgb;
 
        i = 1;
        while (i != hw_points + 1) {
-               if (dc_fixpt_lt(rgb_plus_1->red, rgb->red))
-                       rgb_plus_1->red = rgb->red;
-               if (dc_fixpt_lt(rgb_plus_1->green, rgb->green))
-                       rgb_plus_1->green = rgb->green;
-               if (dc_fixpt_lt(rgb_plus_1->blue, rgb->blue))
-                       rgb_plus_1->blue = rgb->blue;
+               if (i >= hw_points - 1) {
+                       if (dc_fixpt_lt(rgb_plus_1->red, rgb->red))
+                               rgb_plus_1->red = dc_fixpt_add(rgb->red, rgb_minus_1->delta_red);
+                       if (dc_fixpt_lt(rgb_plus_1->green, rgb->green))
+                               rgb_plus_1->green = dc_fixpt_add(rgb->green, rgb_minus_1->delta_green);
+                       if (dc_fixpt_lt(rgb_plus_1->blue, rgb->blue))
+                               rgb_plus_1->blue = dc_fixpt_add(rgb->blue, rgb_minus_1->delta_blue);
+               }
 
                rgb->delta_red   = dc_fixpt_sub(rgb_plus_1->red,   rgb->red);
                rgb->delta_green = dc_fixpt_sub(rgb_plus_1->green, rgb->green);
@@ -283,6 +292,7 @@ bool cm3_helper_translate_curve_to_hw_format(
                }
 
                ++rgb_plus_1;
+               rgb_minus_1 = rgb;
                ++rgb;
                ++i;
        }
index 88ffa9ff1ed15bd5d7e8e7184832fa6c5bd840e6..f246125232482c894f5440c9c6682924577c7f49 100644 (file)
@@ -511,6 +511,7 @@ static struct hubp_funcs dcn30_hubp_funcs = {
        .hubp_init = hubp3_init,
        .hubp_in_blank = hubp1_in_blank,
        .hubp_soft_reset = hubp1_soft_reset,
+       .hubp_set_flip_int = hubp1_set_flip_int,
 };
 
 bool hubp3_construct(
index 8d0f663489ac5a915330f7f1d689d299daed647f..fb7f1dea3c467e4f33aaf1228a9d62f7e3da2fd3 100644 (file)
@@ -2508,6 +2508,19 @@ static const struct resource_funcs dcn30_res_pool_funcs = {
        .patch_unknown_plane_state = dcn20_patch_unknown_plane_state,
 };
 
+#define CTX ctx
+
+#define REG(reg_name) \
+       (DCN_BASE.instance[0].segment[mm ## reg_name ## _BASE_IDX] + mm ## reg_name)
+
+static uint32_t read_pipe_fuses(struct dc_context *ctx)
+{
+       uint32_t value = REG_READ(CC_DC_PIPE_DIS);
+       /* Support for max 6 pipes */
+       value = value & 0x3f;
+       return value;
+}
+
 static bool dcn30_resource_construct(
        uint8_t num_virtual_links,
        struct dc *dc,
@@ -2517,6 +2530,15 @@ static bool dcn30_resource_construct(
        struct dc_context *ctx = dc->ctx;
        struct irq_service_init_data init_data;
        struct ddc_service_init_data ddc_init_data;
+       uint32_t pipe_fuses = read_pipe_fuses(ctx);
+       uint32_t num_pipes = 0;
+
+       if (!(pipe_fuses == 0 || pipe_fuses == 0x3e)) {
+               BREAK_TO_DEBUGGER();
+               dm_error("DC: Unexpected fuse recipe for navi2x !\n");
+               /* fault to single pipe */
+               pipe_fuses = 0x3e;
+       }
 
        DC_FP_START();
 
@@ -2650,6 +2672,15 @@ static bool dcn30_resource_construct(
        /* PP Lib and SMU interfaces */
        init_soc_bounding_box(dc, pool);
 
+       num_pipes = dcn3_0_ip.max_num_dpp;
+
+       for (i = 0; i < dcn3_0_ip.max_num_dpp; i++)
+               if (pipe_fuses & 1 << i)
+                       num_pipes--;
+
+       dcn3_0_ip.max_num_dpp = num_pipes;
+       dcn3_0_ip.max_num_otg = num_pipes;
+
        dml_init_instance(&dc->dml, &dcn3_0_soc, &dcn3_0_ip, DML_PROJECT_DCN30);
 
        /* IRQ */
index 5d4b2c60192ee49763f318777ce4271cf5554feb..c494235016e09aac6814ab6d2cbcc22659fe9529 100644 (file)
@@ -1619,12 +1619,106 @@ static void dcn301_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *b
        dml_init_instance(&dc->dml, &dcn3_01_soc, &dcn3_01_ip, DML_PROJECT_DCN30);
 }
 
+static void calculate_wm_set_for_vlevel(
+               int vlevel,
+               struct wm_range_table_entry *table_entry,
+               struct dcn_watermarks *wm_set,
+               struct display_mode_lib *dml,
+               display_e2e_pipe_params_st *pipes,
+               int pipe_cnt)
+{
+       double dram_clock_change_latency_cached = dml->soc.dram_clock_change_latency_us;
+
+       ASSERT(vlevel < dml->soc.num_states);
+       /* only pipe 0 is read for voltage and dcf/soc clocks */
+       pipes[0].clks_cfg.voltage = vlevel;
+       pipes[0].clks_cfg.dcfclk_mhz = dml->soc.clock_limits[vlevel].dcfclk_mhz;
+       pipes[0].clks_cfg.socclk_mhz = dml->soc.clock_limits[vlevel].socclk_mhz;
+
+       dml->soc.dram_clock_change_latency_us = table_entry->pstate_latency_us;
+       dml->soc.sr_exit_time_us = table_entry->sr_exit_time_us;
+       dml->soc.sr_enter_plus_exit_time_us = table_entry->sr_enter_plus_exit_time_us;
+
+       wm_set->urgent_ns = get_wm_urgent(dml, pipes, pipe_cnt) * 1000;
+       wm_set->cstate_pstate.cstate_enter_plus_exit_ns = get_wm_stutter_enter_exit(dml, pipes, pipe_cnt) * 1000;
+       wm_set->cstate_pstate.cstate_exit_ns = get_wm_stutter_exit(dml, pipes, pipe_cnt) * 1000;
+       wm_set->cstate_pstate.pstate_change_ns = get_wm_dram_clock_change(dml, pipes, pipe_cnt) * 1000;
+       wm_set->pte_meta_urgent_ns = get_wm_memory_trip(dml, pipes, pipe_cnt) * 1000;
+       wm_set->frac_urg_bw_nom = get_fraction_of_urgent_bandwidth(dml, pipes, pipe_cnt) * 1000;
+       wm_set->frac_urg_bw_flip = get_fraction_of_urgent_bandwidth_imm_flip(dml, pipes, pipe_cnt) * 1000;
+       wm_set->urgent_latency_ns = get_urgent_latency(dml, pipes, pipe_cnt) * 1000;
+       dml->soc.dram_clock_change_latency_us = dram_clock_change_latency_cached;
+
+}
+
+static void dcn301_calculate_wm_and_dlg(
+               struct dc *dc, struct dc_state *context,
+               display_e2e_pipe_params_st *pipes,
+               int pipe_cnt,
+               int vlevel_req)
+{
+       int i, pipe_idx;
+       int vlevel, vlevel_max;
+       struct wm_range_table_entry *table_entry;
+       struct clk_bw_params *bw_params = dc->clk_mgr->bw_params;
+
+       ASSERT(bw_params);
+
+       vlevel_max = bw_params->clk_table.num_entries - 1;
+
+       /* WM Set D */
+       table_entry = &bw_params->wm_table.entries[WM_D];
+       if (table_entry->wm_type == WM_TYPE_RETRAINING)
+               vlevel = 0;
+       else
+               vlevel = vlevel_max;
+       calculate_wm_set_for_vlevel(vlevel, table_entry, &context->bw_ctx.bw.dcn.watermarks.d,
+                                               &context->bw_ctx.dml, pipes, pipe_cnt);
+       /* WM Set C */
+       table_entry = &bw_params->wm_table.entries[WM_C];
+       vlevel = min(max(vlevel_req, 2), vlevel_max);
+       calculate_wm_set_for_vlevel(vlevel, table_entry, &context->bw_ctx.bw.dcn.watermarks.c,
+                                               &context->bw_ctx.dml, pipes, pipe_cnt);
+       /* WM Set B */
+       table_entry = &bw_params->wm_table.entries[WM_B];
+       vlevel = min(max(vlevel_req, 1), vlevel_max);
+       calculate_wm_set_for_vlevel(vlevel, table_entry, &context->bw_ctx.bw.dcn.watermarks.b,
+                                               &context->bw_ctx.dml, pipes, pipe_cnt);
+
+       /* WM Set A */
+       table_entry = &bw_params->wm_table.entries[WM_A];
+       vlevel = min(vlevel_req, vlevel_max);
+       calculate_wm_set_for_vlevel(vlevel, table_entry, &context->bw_ctx.bw.dcn.watermarks.a,
+                                               &context->bw_ctx.dml, pipes, pipe_cnt);
+
+       for (i = 0, pipe_idx = 0; i < dc->res_pool->pipe_count; i++) {
+               if (!context->res_ctx.pipe_ctx[i].stream)
+                       continue;
+
+               pipes[pipe_idx].clks_cfg.dispclk_mhz = get_dispclk_calculated(&context->bw_ctx.dml, pipes, pipe_cnt);
+               pipes[pipe_idx].clks_cfg.dppclk_mhz = get_dppclk_calculated(&context->bw_ctx.dml, pipes, pipe_cnt, pipe_idx);
+
+               if (dc->config.forced_clocks) {
+                       pipes[pipe_idx].clks_cfg.dispclk_mhz = context->bw_ctx.dml.soc.clock_limits[0].dispclk_mhz;
+                       pipes[pipe_idx].clks_cfg.dppclk_mhz = context->bw_ctx.dml.soc.clock_limits[0].dppclk_mhz;
+               }
+               if (dc->debug.min_disp_clk_khz > pipes[pipe_idx].clks_cfg.dispclk_mhz * 1000)
+                       pipes[pipe_idx].clks_cfg.dispclk_mhz = dc->debug.min_disp_clk_khz / 1000.0;
+               if (dc->debug.min_dpp_clk_khz > pipes[pipe_idx].clks_cfg.dppclk_mhz * 1000)
+                       pipes[pipe_idx].clks_cfg.dppclk_mhz = dc->debug.min_dpp_clk_khz / 1000.0;
+
+               pipe_idx++;
+       }
+
+       dcn20_calculate_dlg_params(dc, context, pipes, pipe_cnt, vlevel);
+}
+
 static struct resource_funcs dcn301_res_pool_funcs = {
        .destroy = dcn301_destroy_resource_pool,
        .link_enc_create = dcn301_link_encoder_create,
        .panel_cntl_create = dcn301_panel_cntl_create,
        .validate_bandwidth = dcn30_validate_bandwidth,
-       .calculate_wm_and_dlg = dcn30_calculate_wm_and_dlg,
+       .calculate_wm_and_dlg = dcn301_calculate_wm_and_dlg,
        .populate_dml_pipes = dcn30_populate_dml_pipes_from_context,
        .acquire_idle_pipe_for_layer = dcn20_acquire_idle_pipe_for_layer,
        .add_stream_to_ctx = dcn30_add_stream_to_ctx,
index 22f3f643ed1b865ea64af0aadae66a580271bb35..346dcd87dc10651b28bab509b314f21cb89f4c8e 100644 (file)
@@ -191,6 +191,8 @@ struct hubp_funcs {
        bool (*hubp_in_blank)(struct hubp *hubp);
        void (*hubp_soft_reset)(struct hubp *hubp, bool reset);
 
+       void (*hubp_set_flip_int)(struct hubp *hubp);
+
 };
 
 #endif
index c57dc9ae81f2f4e7af3dc1dd3d9537cca3c18eb3..a2681fe875ed6fb4a7242e5e3d36356f7e012d2e 100644 (file)
@@ -5216,10 +5216,10 @@ static int smu7_set_watermarks_for_clocks_ranges(struct pp_hwmgr *hwmgr,
                for (j = 0; j < dep_sclk_table->count; j++) {
                        valid_entry = false;
                        for (k = 0; k < watermarks->num_wm_sets; k++) {
-                               if (dep_sclk_table->entries[i].clk / 10 >= watermarks->wm_clk_ranges[k].wm_min_eng_clk_in_khz &&
-                                   dep_sclk_table->entries[i].clk / 10 < watermarks->wm_clk_ranges[k].wm_max_eng_clk_in_khz &&
-                                   dep_mclk_table->entries[i].clk / 10 >= watermarks->wm_clk_ranges[k].wm_min_mem_clk_in_khz &&
-                                   dep_mclk_table->entries[i].clk / 10 < watermarks->wm_clk_ranges[k].wm_max_mem_clk_in_khz) {
+                               if (dep_sclk_table->entries[i].clk >= watermarks->wm_clk_ranges[k].wm_min_eng_clk_in_khz / 10 &&
+                                   dep_sclk_table->entries[i].clk < watermarks->wm_clk_ranges[k].wm_max_eng_clk_in_khz / 10 &&
+                                   dep_mclk_table->entries[i].clk >= watermarks->wm_clk_ranges[k].wm_min_mem_clk_in_khz / 10 &&
+                                   dep_mclk_table->entries[i].clk < watermarks->wm_clk_ranges[k].wm_max_mem_clk_in_khz / 10) {
                                        valid_entry = true;
                                        table->DisplayWatermark[i][j] = watermarks->wm_clk_ranges[k].wm_set_id;
                                        break;
index 29c99642d22d407e5613aef1f1264efb9cc30f86..22b636e2b89bed7b7e08ec369e7daf298d318bca 100644 (file)
@@ -1505,6 +1505,48 @@ static int vega10_populate_single_lclk_level(struct pp_hwmgr *hwmgr,
        return 0;
 }
 
+static int vega10_override_pcie_parameters(struct pp_hwmgr *hwmgr)
+{
+       struct amdgpu_device *adev = (struct amdgpu_device *)(hwmgr->adev);
+       struct vega10_hwmgr *data =
+                       (struct vega10_hwmgr *)(hwmgr->backend);
+       uint32_t pcie_gen = 0, pcie_width = 0;
+       PPTable_t *pp_table = &(data->smc_state_table.pp_table);
+       int i;
+
+       if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN4)
+               pcie_gen = 3;
+       else if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3)
+               pcie_gen = 2;
+       else if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2)
+               pcie_gen = 1;
+       else if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN1)
+               pcie_gen = 0;
+
+       if (adev->pm.pcie_mlw_mask & CAIL_PCIE_LINK_WIDTH_SUPPORT_X16)
+               pcie_width = 6;
+       else if (adev->pm.pcie_mlw_mask & CAIL_PCIE_LINK_WIDTH_SUPPORT_X12)
+               pcie_width = 5;
+       else if (adev->pm.pcie_mlw_mask & CAIL_PCIE_LINK_WIDTH_SUPPORT_X8)
+               pcie_width = 4;
+       else if (adev->pm.pcie_mlw_mask & CAIL_PCIE_LINK_WIDTH_SUPPORT_X4)
+               pcie_width = 3;
+       else if (adev->pm.pcie_mlw_mask & CAIL_PCIE_LINK_WIDTH_SUPPORT_X2)
+               pcie_width = 2;
+       else if (adev->pm.pcie_mlw_mask & CAIL_PCIE_LINK_WIDTH_SUPPORT_X1)
+               pcie_width = 1;
+
+       for (i = 0; i < NUM_LINK_LEVELS; i++) {
+               if (pp_table->PcieGenSpeed[i] > pcie_gen)
+                       pp_table->PcieGenSpeed[i] = pcie_gen;
+
+               if (pp_table->PcieLaneCount[i] > pcie_width)
+                       pp_table->PcieLaneCount[i] = pcie_width;
+       }
+
+       return 0;
+}
+
 static int vega10_populate_smc_link_levels(struct pp_hwmgr *hwmgr)
 {
        int result = -1;
@@ -2556,6 +2598,11 @@ static int vega10_init_smc_table(struct pp_hwmgr *hwmgr)
                        "Failed to initialize Link Level!",
                        return result);
 
+       result = vega10_override_pcie_parameters(hwmgr);
+       PP_ASSERT_WITH_CODE(!result,
+                       "Failed to override pcie parameters!",
+                       return result);
+
        result = vega10_populate_all_graphic_levels(hwmgr);
        PP_ASSERT_WITH_CODE(!result,
                        "Failed to initialize Graphics Level!",
@@ -2922,6 +2969,7 @@ static int vega10_start_dpm(struct pp_hwmgr *hwmgr, uint32_t bitmap)
        return 0;
 }
 
+
 static int vega10_enable_disable_PCC_limit_feature(struct pp_hwmgr *hwmgr, bool enable)
 {
        struct vega10_hwmgr *data = hwmgr->backend;
index c0753029a8e2a9f6b1039ab906a2d354b047a463..43e01d880f7ce8bdc1313ef1c0cfb73499238fb5 100644 (file)
@@ -481,6 +481,67 @@ static void vega12_init_dpm_state(struct vega12_dpm_state *dpm_state)
        dpm_state->hard_max_level = 0xffff;
 }
 
+static int vega12_override_pcie_parameters(struct pp_hwmgr *hwmgr)
+{
+       struct amdgpu_device *adev = (struct amdgpu_device *)(hwmgr->adev);
+       struct vega12_hwmgr *data =
+                       (struct vega12_hwmgr *)(hwmgr->backend);
+       uint32_t pcie_gen = 0, pcie_width = 0, smu_pcie_arg, pcie_gen_arg, pcie_width_arg;
+       PPTable_t *pp_table = &(data->smc_state_table.pp_table);
+       int i;
+       int ret;
+
+       if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN4)
+               pcie_gen = 3;
+       else if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3)
+               pcie_gen = 2;
+       else if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2)
+               pcie_gen = 1;
+       else if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN1)
+               pcie_gen = 0;
+
+       if (adev->pm.pcie_mlw_mask & CAIL_PCIE_LINK_WIDTH_SUPPORT_X16)
+               pcie_width = 6;
+       else if (adev->pm.pcie_mlw_mask & CAIL_PCIE_LINK_WIDTH_SUPPORT_X12)
+               pcie_width = 5;
+       else if (adev->pm.pcie_mlw_mask & CAIL_PCIE_LINK_WIDTH_SUPPORT_X8)
+               pcie_width = 4;
+       else if (adev->pm.pcie_mlw_mask & CAIL_PCIE_LINK_WIDTH_SUPPORT_X4)
+               pcie_width = 3;
+       else if (adev->pm.pcie_mlw_mask & CAIL_PCIE_LINK_WIDTH_SUPPORT_X2)
+               pcie_width = 2;
+       else if (adev->pm.pcie_mlw_mask & CAIL_PCIE_LINK_WIDTH_SUPPORT_X1)
+               pcie_width = 1;
+
+       /* Bit 31:16: LCLK DPM level. 0 is DPM0, and 1 is DPM1
+        * Bit 15:8:  PCIE GEN, 0 to 3 corresponds to GEN1 to GEN4
+        * Bit 7:0:   PCIE lane width, 1 to 7 corresponds is x1 to x32
+        */
+       for (i = 0; i < NUM_LINK_LEVELS; i++) {
+               pcie_gen_arg = (pp_table->PcieGenSpeed[i] > pcie_gen) ? pcie_gen :
+                       pp_table->PcieGenSpeed[i];
+               pcie_width_arg = (pp_table->PcieLaneCount[i] > pcie_width) ? pcie_width :
+                       pp_table->PcieLaneCount[i];
+
+               if (pcie_gen_arg != pp_table->PcieGenSpeed[i] || pcie_width_arg !=
+                   pp_table->PcieLaneCount[i]) {
+                       smu_pcie_arg = (i << 16) | (pcie_gen_arg << 8) | pcie_width_arg;
+                       ret = smum_send_msg_to_smc_with_parameter(hwmgr,
+                               PPSMC_MSG_OverridePcieParameters, smu_pcie_arg,
+                               NULL);
+                       PP_ASSERT_WITH_CODE(!ret,
+                               "[OverridePcieParameters] Attempt to override pcie params failed!",
+                               return ret);
+               }
+
+               /* update the pptable */
+               pp_table->PcieGenSpeed[i] = pcie_gen_arg;
+               pp_table->PcieLaneCount[i] = pcie_width_arg;
+       }
+
+       return 0;
+}
+
 static int vega12_get_number_of_dpm_level(struct pp_hwmgr *hwmgr,
                PPCLK_e clk_id, uint32_t *num_of_levels)
 {
@@ -968,6 +1029,11 @@ static int vega12_enable_dpm_tasks(struct pp_hwmgr *hwmgr)
                        "Failed to enable all smu features!",
                        return result);
 
+       result = vega12_override_pcie_parameters(hwmgr);
+       PP_ASSERT_WITH_CODE(!result,
+                       "[EnableDPMTasks] Failed to override pcie parameters!",
+                       return result);
+
        tmp_result = vega12_power_control_set_level(hwmgr);
        PP_ASSERT_WITH_CODE(!tmp_result,
                        "Failed to power control set level!",
index 87811b005b85f314c3c9491533a6867fc3123791..f19964c69a0027aaef02c5419a98d490553aeb45 100644 (file)
@@ -831,7 +831,9 @@ static int vega20_override_pcie_parameters(struct pp_hwmgr *hwmgr)
        struct amdgpu_device *adev = (struct amdgpu_device *)(hwmgr->adev);
        struct vega20_hwmgr *data =
                        (struct vega20_hwmgr *)(hwmgr->backend);
-       uint32_t pcie_gen = 0, pcie_width = 0, smu_pcie_arg;
+       uint32_t pcie_gen = 0, pcie_width = 0, smu_pcie_arg, pcie_gen_arg, pcie_width_arg;
+       PPTable_t *pp_table = &(data->smc_state_table.pp_table);
+       int i;
        int ret;
 
        if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN4)
@@ -860,17 +862,27 @@ static int vega20_override_pcie_parameters(struct pp_hwmgr *hwmgr)
         * Bit 15:8:  PCIE GEN, 0 to 3 corresponds to GEN1 to GEN4
         * Bit 7:0:   PCIE lane width, 1 to 7 corresponds is x1 to x32
         */
-       smu_pcie_arg = (1 << 16) | (pcie_gen << 8) | pcie_width;
-       ret = smum_send_msg_to_smc_with_parameter(hwmgr,
-                       PPSMC_MSG_OverridePcieParameters, smu_pcie_arg,
-                       NULL);
-       PP_ASSERT_WITH_CODE(!ret,
-               "[OverridePcieParameters] Attempt to override pcie params failed!",
-               return ret);
+       for (i = 0; i < NUM_LINK_LEVELS; i++) {
+               pcie_gen_arg = (pp_table->PcieGenSpeed[i] > pcie_gen) ? pcie_gen :
+                       pp_table->PcieGenSpeed[i];
+               pcie_width_arg = (pp_table->PcieLaneCount[i] > pcie_width) ? pcie_width :
+                       pp_table->PcieLaneCount[i];
+
+               if (pcie_gen_arg != pp_table->PcieGenSpeed[i] || pcie_width_arg !=
+                   pp_table->PcieLaneCount[i]) {
+                       smu_pcie_arg = (i << 16) | (pcie_gen_arg << 8) | pcie_width_arg;
+                       ret = smum_send_msg_to_smc_with_parameter(hwmgr,
+                               PPSMC_MSG_OverridePcieParameters, smu_pcie_arg,
+                               NULL);
+                       PP_ASSERT_WITH_CODE(!ret,
+                               "[OverridePcieParameters] Attempt to override pcie params failed!",
+                               return ret);
+               }
 
-       data->pcie_parameters_override = true;
-       data->pcie_gen_level1 = pcie_gen;
-       data->pcie_width_level1 = pcie_width;
+               /* update the pptable */
+               pp_table->PcieGenSpeed[i] = pcie_gen_arg;
+               pp_table->PcieLaneCount[i] = pcie_width_arg;
+       }
 
        return 0;
 }
@@ -3319,9 +3331,7 @@ static int vega20_print_clock_levels(struct pp_hwmgr *hwmgr,
                        data->od8_settings.od8_settings_array;
        OverDriveTable_t *od_table =
                        &(data->smc_state_table.overdrive_table);
-       struct phm_ppt_v3_information *pptable_information =
-               (struct phm_ppt_v3_information *)hwmgr->pptable;
-       PPTable_t *pptable = (PPTable_t *)pptable_information->smc_pptable;
+       PPTable_t *pptable = &(data->smc_state_table.pp_table);
        struct pp_clock_levels_with_latency clocks;
        struct vega20_single_dpm_table *fclk_dpm_table =
                        &(data->dpm_table.fclk_table);
@@ -3420,13 +3430,9 @@ static int vega20_print_clock_levels(struct pp_hwmgr *hwmgr,
                current_lane_width =
                        vega20_get_current_pcie_link_width_level(hwmgr);
                for (i = 0; i < NUM_LINK_LEVELS; i++) {
-                       if (i == 1 && data->pcie_parameters_override) {
-                               gen_speed = data->pcie_gen_level1;
-                               lane_width = data->pcie_width_level1;
-                       } else {
-                               gen_speed = pptable->PcieGenSpeed[i];
-                               lane_width = pptable->PcieLaneCount[i];
-                       }
+                       gen_speed = pptable->PcieGenSpeed[i];
+                       lane_width = pptable->PcieLaneCount[i];
+
                        size += sprintf(buf + size, "%d: %s %s %dMhz %s\n", i,
                                        (gen_speed == 0) ? "2.5GT/s," :
                                        (gen_speed == 1) ? "5.0GT/s," :
index b9a616737c0ee2e90b0cfc3bb3674f1004e7b3e2..f6baa2046124d1d7c8f9db9d34455db8c02bfb1b 100644 (file)
@@ -2048,7 +2048,7 @@ static void drm_fbdev_cleanup(struct drm_fb_helper *fb_helper)
 
        if (shadow)
                vfree(shadow);
-       else
+       else if (fb_helper->buffer)
                drm_client_buffer_vunmap(fb_helper->buffer);
 
        drm_client_framebuffer_delete(fb_helper->buffer);
index 9825c378dfa6dabfe0fcb26e7335134feb2ab03b..6d625cee7a6af2d1b908f0d28708b06d8625a7d5 100644 (file)
@@ -357,13 +357,14 @@ static void drm_gem_shmem_vunmap_locked(struct drm_gem_shmem_object *shmem,
        if (--shmem->vmap_use_count > 0)
                return;
 
-       if (obj->import_attach)
+       if (obj->import_attach) {
                dma_buf_vunmap(obj->import_attach->dmabuf, map);
-       else
+       } else {
                vunmap(shmem->vaddr);
+               drm_gem_shmem_put_pages(shmem);
+       }
 
        shmem->vaddr = NULL;
-       drm_gem_shmem_put_pages(shmem);
 }
 
 /*
@@ -525,14 +526,28 @@ static vm_fault_t drm_gem_shmem_fault(struct vm_fault *vmf)
        struct drm_gem_object *obj = vma->vm_private_data;
        struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj);
        loff_t num_pages = obj->size >> PAGE_SHIFT;
+       vm_fault_t ret;
        struct page *page;
+       pgoff_t page_offset;
 
-       if (vmf->pgoff >= num_pages || WARN_ON_ONCE(!shmem->pages))
-               return VM_FAULT_SIGBUS;
+       /* We don't use vmf->pgoff since that has the fake offset */
+       page_offset = (vmf->address - vma->vm_start) >> PAGE_SHIFT;
 
-       page = shmem->pages[vmf->pgoff];
+       mutex_lock(&shmem->pages_lock);
 
-       return vmf_insert_page(vma, vmf->address, page);
+       if (page_offset >= num_pages ||
+           WARN_ON_ONCE(!shmem->pages) ||
+           shmem->madv < 0) {
+               ret = VM_FAULT_SIGBUS;
+       } else {
+               page = shmem->pages[page_offset];
+
+               ret = vmf_insert_page(vma, vmf->address, page);
+       }
+
+       mutex_unlock(&shmem->pages_lock);
+
+       return ret;
 }
 
 static void drm_gem_shmem_vm_open(struct vm_area_struct *vma)
@@ -581,9 +596,6 @@ int drm_gem_shmem_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
        struct drm_gem_shmem_object *shmem;
        int ret;
 
-       /* Remove the fake offset */
-       vma->vm_pgoff -= drm_vma_node_start(&obj->vma_node);
-
        if (obj->import_attach) {
                /* Drop the reference drm_gem_mmap_obj() acquired.*/
                drm_gem_object_put(obj);
index f86448ab1fe045235b1a13f6e39eb3893fd04555..dc734d4828a179441a41e445962c82779fbf9c1a 100644 (file)
@@ -99,6 +99,8 @@ static int compat_drm_version(struct file *file, unsigned int cmd,
        if (copy_from_user(&v32, (void __user *)arg, sizeof(v32)))
                return -EFAULT;
 
+       memset(&v, 0, sizeof(v));
+
        v = (struct drm_version) {
                .name_len = v32.name_len,
                .name = compat_ptr(v32.name),
@@ -137,6 +139,9 @@ static int compat_drm_getunique(struct file *file, unsigned int cmd,
 
        if (copy_from_user(&uq32, (void __user *)arg, sizeof(uq32)))
                return -EFAULT;
+
+       memset(&uq, 0, sizeof(uq));
+
        uq = (struct drm_unique){
                .unique_len = uq32.unique_len,
                .unique = compat_ptr(uq32.unique),
@@ -265,6 +270,8 @@ static int compat_drm_getclient(struct file *file, unsigned int cmd,
        if (copy_from_user(&c32, argp, sizeof(c32)))
                return -EFAULT;
 
+       memset(&client, 0, sizeof(client));
+
        client.idx = c32.idx;
 
        err = drm_ioctl_kernel(file, drm_getclient, &client, 0);
@@ -852,6 +859,8 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
        if (copy_from_user(&req32, argp, sizeof(req32)))
                return -EFAULT;
 
+       memset(&req, 0, sizeof(req));
+
        req.request.type = req32.request.type;
        req.request.sequence = req32.request.sequence;
        req.request.signal = req32.request.signal;
@@ -889,6 +898,8 @@ static int compat_drm_mode_addfb2(struct file *file, unsigned int cmd,
        struct drm_mode_fb_cmd2 req64;
        int err;
 
+       memset(&req64, 0, sizeof(req64));
+
        if (copy_from_user(&req64, argp,
                           offsetof(drm_mode_fb_cmd232_t, modifier)))
                return -EFAULT;
index fb1b1d09697511ab88338ef8fe460a36e9d80265..9cf555d6842b71e2a99ace195eadc7f1cf0f0068 100644 (file)
@@ -713,9 +713,12 @@ static int engine_setup_common(struct intel_engine_cs *engine)
                goto err_status;
        }
 
+       err = intel_engine_init_cmd_parser(engine);
+       if (err)
+               goto err_cmd_parser;
+
        intel_engine_init_active(engine, ENGINE_PHYSICAL);
        intel_engine_init_execlists(engine);
-       intel_engine_init_cmd_parser(engine);
        intel_engine_init__pm(engine);
        intel_engine_init_retire(engine);
 
@@ -732,6 +735,8 @@ static int engine_setup_common(struct intel_engine_cs *engine)
 
        return 0;
 
+err_cmd_parser:
+       intel_breadcrumbs_free(engine->breadcrumbs);
 err_status:
        cleanup_status_page(engine);
        return err;
index ced9a96d7c34be0bb922240db86eda36b3690965..5f86f5b2caf6f19b1918b91a778c1fc3604cd9d9 100644 (file)
@@ -940,7 +940,7 @@ static void fini_hash_table(struct intel_engine_cs *engine)
  * struct intel_engine_cs based on whether the platform requires software
  * command parsing.
  */
-void intel_engine_init_cmd_parser(struct intel_engine_cs *engine)
+int intel_engine_init_cmd_parser(struct intel_engine_cs *engine)
 {
        const struct drm_i915_cmd_table *cmd_tables;
        int cmd_table_count;
@@ -948,7 +948,7 @@ void intel_engine_init_cmd_parser(struct intel_engine_cs *engine)
 
        if (!IS_GEN(engine->i915, 7) && !(IS_GEN(engine->i915, 9) &&
                                          engine->class == COPY_ENGINE_CLASS))
-               return;
+               return 0;
 
        switch (engine->class) {
        case RENDER_CLASS:
@@ -1013,19 +1013,19 @@ void intel_engine_init_cmd_parser(struct intel_engine_cs *engine)
                break;
        default:
                MISSING_CASE(engine->class);
-               return;
+               goto out;
        }
 
        if (!validate_cmds_sorted(engine, cmd_tables, cmd_table_count)) {
                drm_err(&engine->i915->drm,
                        "%s: command descriptions are not sorted\n",
                        engine->name);
-               return;
+               goto out;
        }
        if (!validate_regs_sorted(engine)) {
                drm_err(&engine->i915->drm,
                        "%s: registers are not sorted\n", engine->name);
-               return;
+               goto out;
        }
 
        ret = init_hash_table(engine, cmd_tables, cmd_table_count);
@@ -1033,10 +1033,17 @@ void intel_engine_init_cmd_parser(struct intel_engine_cs *engine)
                drm_err(&engine->i915->drm,
                        "%s: initialised failed!\n", engine->name);
                fini_hash_table(engine);
-               return;
+               goto out;
        }
 
        engine->flags |= I915_ENGINE_USING_CMD_PARSER;
+
+out:
+       if (intel_engine_requires_cmd_parser(engine) &&
+           !intel_engine_using_cmd_parser(engine))
+               return -EINVAL;
+
+       return 0;
 }
 
 /**
index 26d69d06aa6d131809fb6be42cba048d344e6768..cb62ddba203522f61501fd918179cc053a1eeb6c 100644 (file)
@@ -1952,7 +1952,7 @@ const char *i915_cache_level_str(struct drm_i915_private *i915, int type);
 
 /* i915_cmd_parser.c */
 int i915_cmd_parser_get_version(struct drm_i915_private *dev_priv);
-void intel_engine_init_cmd_parser(struct intel_engine_cs *engine);
+int intel_engine_init_cmd_parser(struct intel_engine_cs *engine);
 void intel_engine_cleanup_cmd_parser(struct intel_engine_cs *engine);
 int intel_engine_cmd_parser(struct intel_engine_cs *engine,
                            struct i915_vma *batch,
index 112ba5f2ce90e9334e0733769dd533901ce9719d..e62ad69606f6e37874b7356623a71dd7a748bcd2 100644 (file)
@@ -603,7 +603,6 @@ static int append_oa_sample(struct i915_perf_stream *stream,
 {
        int report_size = stream->oa_buffer.format_size;
        struct drm_i915_perf_record_header header;
-       u32 sample_flags = stream->sample_flags;
 
        header.type = DRM_I915_PERF_RECORD_SAMPLE;
        header.pad = 0;
@@ -617,10 +616,8 @@ static int append_oa_sample(struct i915_perf_stream *stream,
                return -EFAULT;
        buf += sizeof(header);
 
-       if (sample_flags & SAMPLE_OA_REPORT) {
-               if (copy_to_user(buf, report, report_size))
-                       return -EFAULT;
-       }
+       if (copy_to_user(buf, report, report_size))
+               return -EFAULT;
 
        (*offset) += header.size;
 
@@ -2682,7 +2679,7 @@ static void i915_oa_stream_enable(struct i915_perf_stream *stream)
 
        stream->perf->ops.oa_enable(stream);
 
-       if (stream->periodic)
+       if (stream->sample_flags & SAMPLE_OA_REPORT)
                hrtimer_start(&stream->poll_check_timer,
                              ns_to_ktime(stream->poll_oa_period),
                              HRTIMER_MODE_REL_PINNED);
@@ -2745,7 +2742,7 @@ static void i915_oa_stream_disable(struct i915_perf_stream *stream)
 {
        stream->perf->ops.oa_disable(stream);
 
-       if (stream->periodic)
+       if (stream->sample_flags & SAMPLE_OA_REPORT)
                hrtimer_cancel(&stream->poll_check_timer);
 }
 
@@ -3028,7 +3025,7 @@ static ssize_t i915_perf_read(struct file *file,
         * disabled stream as an error. In particular it might otherwise lead
         * to a deadlock for blocking file descriptors...
         */
-       if (!stream->enabled)
+       if (!stream->enabled || !(stream->sample_flags & SAMPLE_OA_REPORT))
                return -EIO;
 
        if (!(file->f_flags & O_NONBLOCK)) {
index 7146cd0f32560cc1ec248d347a267515899586b6..aaf1f0045b1644ff3bfb9fb90e648dd77344e505 100644 (file)
@@ -3316,7 +3316,18 @@ static inline bool i915_mmio_reg_valid(i915_reg_t reg)
 
 #define ILK_DISPLAY_CHICKEN1   _MMIO(0x42000)
 #define   ILK_FBCQ_DIS         (1 << 22)
-#define          ILK_PABSTRETCH_DIS    (1 << 21)
+#define   ILK_PABSTRETCH_DIS   REG_BIT(21)
+#define   ILK_SABSTRETCH_DIS   REG_BIT(20)
+#define   IVB_PRI_STRETCH_MAX_MASK     REG_GENMASK(21, 20)
+#define   IVB_PRI_STRETCH_MAX_X8       REG_FIELD_PREP(IVB_PRI_STRETCH_MAX_MASK, 0)
+#define   IVB_PRI_STRETCH_MAX_X4       REG_FIELD_PREP(IVB_PRI_STRETCH_MAX_MASK, 1)
+#define   IVB_PRI_STRETCH_MAX_X2       REG_FIELD_PREP(IVB_PRI_STRETCH_MAX_MASK, 2)
+#define   IVB_PRI_STRETCH_MAX_X1       REG_FIELD_PREP(IVB_PRI_STRETCH_MAX_MASK, 3)
+#define   IVB_SPR_STRETCH_MAX_MASK     REG_GENMASK(19, 18)
+#define   IVB_SPR_STRETCH_MAX_X8       REG_FIELD_PREP(IVB_SPR_STRETCH_MAX_MASK, 0)
+#define   IVB_SPR_STRETCH_MAX_X4       REG_FIELD_PREP(IVB_SPR_STRETCH_MAX_MASK, 1)
+#define   IVB_SPR_STRETCH_MAX_X2       REG_FIELD_PREP(IVB_SPR_STRETCH_MAX_MASK, 2)
+#define   IVB_SPR_STRETCH_MAX_X1       REG_FIELD_PREP(IVB_SPR_STRETCH_MAX_MASK, 3)
 
 
 /*
@@ -8039,6 +8050,16 @@ enum {
 
 #define _CHICKEN_PIPESL_1_A    0x420b0
 #define _CHICKEN_PIPESL_1_B    0x420b4
+#define  HSW_PRI_STRETCH_MAX_MASK      REG_GENMASK(28, 27)
+#define  HSW_PRI_STRETCH_MAX_X8                REG_FIELD_PREP(HSW_PRI_STRETCH_MAX_MASK, 0)
+#define  HSW_PRI_STRETCH_MAX_X4                REG_FIELD_PREP(HSW_PRI_STRETCH_MAX_MASK, 1)
+#define  HSW_PRI_STRETCH_MAX_X2                REG_FIELD_PREP(HSW_PRI_STRETCH_MAX_MASK, 2)
+#define  HSW_PRI_STRETCH_MAX_X1                REG_FIELD_PREP(HSW_PRI_STRETCH_MAX_MASK, 3)
+#define  HSW_SPR_STRETCH_MAX_MASK      REG_GENMASK(26, 25)
+#define  HSW_SPR_STRETCH_MAX_X8                REG_FIELD_PREP(HSW_SPR_STRETCH_MAX_MASK, 0)
+#define  HSW_SPR_STRETCH_MAX_X4                REG_FIELD_PREP(HSW_SPR_STRETCH_MAX_MASK, 1)
+#define  HSW_SPR_STRETCH_MAX_X2                REG_FIELD_PREP(HSW_SPR_STRETCH_MAX_MASK, 2)
+#define  HSW_SPR_STRETCH_MAX_X1                REG_FIELD_PREP(HSW_SPR_STRETCH_MAX_MASK, 3)
 #define  HSW_FBCQ_DIS                  (1 << 22)
 #define  BDW_DPRS_MASK_VBLANK_SRD      (1 << 0)
 #define CHICKEN_PIPESL_1(pipe) _MMIO_PIPE(pipe, _CHICKEN_PIPESL_1_A, _CHICKEN_PIPESL_1_B)
index 0c3e63f27c29d8f547bea447e18c1a9320e5b097..97b57acc02e272f4819b24e3175e679992171ed0 100644 (file)
@@ -7245,11 +7245,16 @@ static void bdw_init_clock_gating(struct drm_i915_private *dev_priv)
        intel_uncore_write(&dev_priv->uncore, CHICKEN_PAR1_1,
                   intel_uncore_read(&dev_priv->uncore, CHICKEN_PAR1_1) | DPA_MASK_VBLANK_SRD);
 
-       /* WaPsrDPRSUnmaskVBlankInSRD:bdw */
        for_each_pipe(dev_priv, pipe) {
+               /* WaPsrDPRSUnmaskVBlankInSRD:bdw */
                intel_uncore_write(&dev_priv->uncore, CHICKEN_PIPESL_1(pipe),
                           intel_uncore_read(&dev_priv->uncore, CHICKEN_PIPESL_1(pipe)) |
                           BDW_DPRS_MASK_VBLANK_SRD);
+
+               /* Undocumented but fixes async flip + VT-d corruption */
+               if (intel_vtd_active())
+                       intel_uncore_rmw(&dev_priv->uncore, CHICKEN_PIPESL_1(pipe),
+                                        HSW_PRI_STRETCH_MAX_MASK, HSW_PRI_STRETCH_MAX_X1);
        }
 
        /* WaVSRefCountFullforceMissDisable:bdw */
@@ -7285,11 +7290,20 @@ static void bdw_init_clock_gating(struct drm_i915_private *dev_priv)
 
 static void hsw_init_clock_gating(struct drm_i915_private *dev_priv)
 {
+       enum pipe pipe;
+
        /* WaFbcAsynchFlipDisableFbcQueue:hsw,bdw */
        intel_uncore_write(&dev_priv->uncore, CHICKEN_PIPESL_1(PIPE_A),
                   intel_uncore_read(&dev_priv->uncore, CHICKEN_PIPESL_1(PIPE_A)) |
                   HSW_FBCQ_DIS);
 
+       for_each_pipe(dev_priv, pipe) {
+               /* Undocumented but fixes async flip + VT-d corruption */
+               if (intel_vtd_active())
+                       intel_uncore_rmw(&dev_priv->uncore, CHICKEN_PIPESL_1(pipe),
+                                        HSW_PRI_STRETCH_MAX_MASK, HSW_PRI_STRETCH_MAX_X1);
+       }
+
        /* This is required by WaCatErrorRejectionIssue:hsw */
        intel_uncore_write(&dev_priv->uncore, GEN7_SQ_CHICKEN_MBCUNIT_CONFIG,
                   intel_uncore_read(&dev_priv->uncore, GEN7_SQ_CHICKEN_MBCUNIT_CONFIG) |
index 42c5d3246cfcbd0147a48df83d4aa52c4c352291..453d8b4c5763d9b65665ad8cca3ab0dfd0d8f4b2 100644 (file)
@@ -482,6 +482,16 @@ static int meson_probe_remote(struct platform_device *pdev,
        return count;
 }
 
+static void meson_drv_shutdown(struct platform_device *pdev)
+{
+       struct meson_drm *priv = dev_get_drvdata(&pdev->dev);
+       struct drm_device *drm = priv->drm;
+
+       DRM_DEBUG_DRIVER("\n");
+       drm_kms_helper_poll_fini(drm);
+       drm_atomic_helper_shutdown(drm);
+}
+
 static int meson_drv_probe(struct platform_device *pdev)
 {
        struct component_match *match = NULL;
@@ -553,6 +563,7 @@ static const struct dev_pm_ops meson_drv_pm_ops = {
 
 static struct platform_driver meson_drm_platform_driver = {
        .probe      = meson_drv_probe,
+       .shutdown   = meson_drv_shutdown,
        .driver     = {
                .name   = "meson-drm",
                .of_match_table = dt_match,
index 2375711877cf3ac6ebe4570b3541f25627659f1a..f2720a0061993768ab394ee76393a7603e172a43 100644 (file)
@@ -551,12 +551,17 @@ nouveau_bo_sync_for_device(struct nouveau_bo *nvbo)
 
        if (!ttm_dma)
                return;
+       if (!ttm_dma->pages) {
+               NV_DEBUG(drm, "ttm_dma 0x%p: pages NULL\n", ttm_dma);
+               return;
+       }
 
        /* Don't waste time looping if the object is coherent */
        if (nvbo->force_coherent)
                return;
 
-       for (i = 0; i < ttm_dma->num_pages; ++i) {
+       i = 0;
+       while (i < ttm_dma->num_pages) {
                struct page *p = ttm_dma->pages[i];
                size_t num_pages = 1;
 
@@ -582,12 +587,17 @@ nouveau_bo_sync_for_cpu(struct nouveau_bo *nvbo)
 
        if (!ttm_dma)
                return;
+       if (!ttm_dma->pages) {
+               NV_DEBUG(drm, "ttm_dma 0x%p: pages NULL\n", ttm_dma);
+               return;
+       }
 
        /* Don't waste time looping if the object is coherent */
        if (nvbo->force_coherent)
                return;
 
-       for (i = 0; i < ttm_dma->num_pages; ++i) {
+       i = 0;
+       while (i < ttm_dma->num_pages) {
                struct page *p = ttm_dma->pages[i];
                size_t num_pages = 1;
 
index 8e11612f5fe171e5bde7f22b3ee7d2f3d52da053..b31d750c425acc423ee4207c8f16a7c47b021683 100644 (file)
@@ -2149,11 +2149,12 @@ static int dsi_vc_send_short(struct dsi_data *dsi, int vc,
                             const struct mipi_dsi_msg *msg)
 {
        struct mipi_dsi_packet pkt;
+       int ret;
        u32 r;
 
-       r = mipi_dsi_create_packet(&pkt, msg);
-       if (r < 0)
-               return r;
+       ret = mipi_dsi_create_packet(&pkt, msg);
+       if (ret < 0)
+               return ret;
 
        WARN_ON(!dsi_bus_is_locked(dsi));
 
index 012bce0cdb65c101345e14121d193500d46f0252..10738e04c09b85bfd549ff35dd9bb7c078a2e1aa 100644 (file)
@@ -328,6 +328,7 @@ static void qxl_crtc_update_monitors_config(struct drm_crtc *crtc,
 
        head.id = i;
        head.flags = 0;
+       head.surface_id = 0;
        oldcount = qdev->monitors_config->count;
        if (crtc->state->active) {
                struct drm_display_mode *mode = &crtc->mode;
index 0fcfc952d5e9e24ef1cd397116778b2b0cd976fb..b372455e272986fe09374d66d0fb9be96928cda6 100644 (file)
@@ -321,7 +321,7 @@ int qxl_alloc_release_reserved(struct qxl_device *qdev, unsigned long size,
                                       int type, struct qxl_release **release,
                                       struct qxl_bo **rbo)
 {
-       struct qxl_bo *bo;
+       struct qxl_bo *bo, *free_bo = NULL;
        int idr_ret;
        int ret = 0;
        union qxl_release_info *info;
@@ -347,7 +347,7 @@ int qxl_alloc_release_reserved(struct qxl_device *qdev, unsigned long size,
 
        mutex_lock(&qdev->release_mutex);
        if (qdev->current_release_bo_offset[cur_idx] + 1 >= releases_per_bo[cur_idx]) {
-               qxl_bo_unref(&qdev->current_release_bo[cur_idx]);
+               free_bo = qdev->current_release_bo[cur_idx];
                qdev->current_release_bo_offset[cur_idx] = 0;
                qdev->current_release_bo[cur_idx] = NULL;
        }
@@ -355,6 +355,10 @@ int qxl_alloc_release_reserved(struct qxl_device *qdev, unsigned long size,
                ret = qxl_release_bo_alloc(qdev, &qdev->current_release_bo[cur_idx]);
                if (ret) {
                        mutex_unlock(&qdev->release_mutex);
+                       if (free_bo) {
+                               qxl_bo_unpin(free_bo);
+                               qxl_bo_unref(&free_bo);
+                       }
                        qxl_release_free(qdev, *release);
                        return ret;
                }
@@ -370,6 +374,10 @@ int qxl_alloc_release_reserved(struct qxl_device *qdev, unsigned long size,
                *rbo = bo;
 
        mutex_unlock(&qdev->release_mutex);
+       if (free_bo) {
+               qxl_bo_unpin(free_bo);
+               qxl_bo_unref(&free_bo);
+       }
 
        ret = qxl_release_list_add(*release, bo);
        qxl_bo_unref(&bo);
index f09989bdce9840a5c955d9a53d2fa9e25d2f61ba..3effc8c71494cd1313d49231a1c8ab7086b2759e 100644 (file)
@@ -574,6 +574,8 @@ struct radeon_gem {
        struct list_head        objects;
 };
 
+extern const struct drm_gem_object_funcs radeon_gem_object_funcs;
+
 int radeon_gem_init(struct radeon_device *rdev);
 void radeon_gem_fini(struct radeon_device *rdev);
 int radeon_gem_object_create(struct radeon_device *rdev, unsigned long size,
index 941826923247329b5da554a3d35d10a6083123ff..db14a82a2e4b258befcbde025c37bcdd603bb2a7 100644 (file)
@@ -43,7 +43,7 @@ struct sg_table *radeon_gem_prime_get_sg_table(struct drm_gem_object *obj);
 int radeon_gem_prime_pin(struct drm_gem_object *obj);
 void radeon_gem_prime_unpin(struct drm_gem_object *obj);
 
-static const struct drm_gem_object_funcs radeon_gem_object_funcs;
+const struct drm_gem_object_funcs radeon_gem_object_funcs;
 
 static void radeon_gem_object_free(struct drm_gem_object *gobj)
 {
@@ -227,7 +227,7 @@ static int radeon_gem_handle_lockup(struct radeon_device *rdev, int r)
        return r;
 }
 
-static const struct drm_gem_object_funcs radeon_gem_object_funcs = {
+const struct drm_gem_object_funcs radeon_gem_object_funcs = {
        .free = radeon_gem_object_free,
        .open = radeon_gem_object_open,
        .close = radeon_gem_object_close,
index ab29eb9e8667596cb525ae189b193f2f329a3910..42a87948e28c5bed77428455708c5f5a85b8743d 100644 (file)
@@ -56,6 +56,8 @@ struct drm_gem_object *radeon_gem_prime_import_sg_table(struct drm_device *dev,
        if (ret)
                return ERR_PTR(ret);
 
+       bo->tbo.base.funcs = &radeon_gem_object_funcs;
+
        mutex_lock(&rdev->gem.mutex);
        list_add_tail(&bo->list, &rdev->gem.objects);
        mutex_unlock(&rdev->gem.mutex);
index 33f65f4626e5a3cb2e66722aa20a36300d0044d7..23866a54e3f919ec89af46e365c31dceb15f177d 100644 (file)
@@ -83,6 +83,7 @@ MODULE_PARM_DESC(eco_mode, "Turn on Eco mode (less bright, more silent)");
 
 struct gm12u320_device {
        struct drm_device                dev;
+       struct device                   *dmadev;
        struct drm_simple_display_pipe   pipe;
        struct drm_connector             conn;
        unsigned char                   *cmd_buf;
@@ -601,6 +602,22 @@ static const uint64_t gm12u320_pipe_modifiers[] = {
        DRM_FORMAT_MOD_INVALID
 };
 
+/*
+ * FIXME: Dma-buf sharing requires DMA support by the importing device.
+ *        This function is a workaround to make USB devices work as well.
+ *        See todo.rst for how to fix the issue in the dma-buf framework.
+ */
+static struct drm_gem_object *gm12u320_gem_prime_import(struct drm_device *dev,
+                                                       struct dma_buf *dma_buf)
+{
+       struct gm12u320_device *gm12u320 = to_gm12u320(dev);
+
+       if (!gm12u320->dmadev)
+               return ERR_PTR(-ENODEV);
+
+       return drm_gem_prime_import_dev(dev, dma_buf, gm12u320->dmadev);
+}
+
 DEFINE_DRM_GEM_FOPS(gm12u320_fops);
 
 static const struct drm_driver gm12u320_drm_driver = {
@@ -614,6 +631,7 @@ static const struct drm_driver gm12u320_drm_driver = {
 
        .fops            = &gm12u320_fops,
        DRM_GEM_SHMEM_DRIVER_OPS,
+       .gem_prime_import = gm12u320_gem_prime_import,
 };
 
 static const struct drm_mode_config_funcs gm12u320_mode_config_funcs = {
@@ -640,15 +658,18 @@ static int gm12u320_usb_probe(struct usb_interface *interface,
                                      struct gm12u320_device, dev);
        if (IS_ERR(gm12u320))
                return PTR_ERR(gm12u320);
+       dev = &gm12u320->dev;
+
+       gm12u320->dmadev = usb_intf_get_dma_device(to_usb_interface(dev->dev));
+       if (!gm12u320->dmadev)
+               drm_warn(dev, "buffer sharing not supported"); /* not an error */
 
        INIT_DELAYED_WORK(&gm12u320->fb_update.work, gm12u320_fb_update_work);
        mutex_init(&gm12u320->fb_update.lock);
 
-       dev = &gm12u320->dev;
-
        ret = drmm_mode_config_init(dev);
        if (ret)
-               return ret;
+               goto err_put_device;
 
        dev->mode_config.min_width = GM12U320_USER_WIDTH;
        dev->mode_config.max_width = GM12U320_USER_WIDTH;
@@ -658,15 +679,15 @@ static int gm12u320_usb_probe(struct usb_interface *interface,
 
        ret = gm12u320_usb_alloc(gm12u320);
        if (ret)
-               return ret;
+               goto err_put_device;
 
        ret = gm12u320_set_ecomode(gm12u320);
        if (ret)
-               return ret;
+               goto err_put_device;
 
        ret = gm12u320_conn_init(gm12u320);
        if (ret)
-               return ret;
+               goto err_put_device;
 
        ret = drm_simple_display_pipe_init(&gm12u320->dev,
                                           &gm12u320->pipe,
@@ -676,24 +697,31 @@ static int gm12u320_usb_probe(struct usb_interface *interface,
                                           gm12u320_pipe_modifiers,
                                           &gm12u320->conn);
        if (ret)
-               return ret;
+               goto err_put_device;
 
        drm_mode_config_reset(dev);
 
        usb_set_intfdata(interface, dev);
        ret = drm_dev_register(dev, 0);
        if (ret)
-               return ret;
+               goto err_put_device;
 
        drm_fbdev_generic_setup(dev, 0);
 
        return 0;
+
+err_put_device:
+       put_device(gm12u320->dmadev);
+       return ret;
 }
 
 static void gm12u320_usb_disconnect(struct usb_interface *interface)
 {
        struct drm_device *dev = usb_get_intfdata(interface);
+       struct gm12u320_device *gm12u320 = to_gm12u320(dev);
 
+       put_device(gm12u320->dmadev);
+       gm12u320->dmadev = NULL;
        drm_dev_unplug(dev);
        drm_atomic_helper_shutdown(dev);
 }
index 20a25660b35b8b630687912ef8f46f5959c5b5fd..101a68dc615b6032b8e5dd541c05ba00dc473e69 100644 (file)
@@ -136,7 +136,8 @@ void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo,
        struct ttm_bo_device *bdev = bo->bdev;
        struct ttm_resource_manager *man;
 
-       dma_resv_assert_held(bo->base.resv);
+       if (!bo->deleted)
+               dma_resv_assert_held(bo->base.resv);
 
        if (bo->pin_count) {
                ttm_bo_del_from_lru(bo);
@@ -508,8 +509,11 @@ static void ttm_bo_release(struct kref *kref)
                 * Make pinned bos immediately available to
                 * shrinkers, now that they are queued for
                 * destruction.
+                *
+                * FIXME: QXL is triggering this. Can be removed when the
+                * driver is fixed.
                 */
-               if (WARN_ON(bo->pin_count)) {
+               if (WARN_ON_ONCE(bo->pin_count)) {
                        bo->pin_count = 0;
                        ttm_bo_move_to_lru_tail(bo, &bo->mem, NULL);
                }
index 6e27cb1bf48b2effb0d9f14eac0d21483f712d49..4eb6efb8b8c026d4dc6988c3ea7a20fa8e124bf4 100644 (file)
@@ -268,13 +268,13 @@ static void ttm_pool_type_init(struct ttm_pool_type *pt, struct ttm_pool *pool,
 /* Remove a pool_type from the global shrinker list and free all pages */
 static void ttm_pool_type_fini(struct ttm_pool_type *pt)
 {
-       struct page *p, *tmp;
+       struct page *p;
 
        mutex_lock(&shrinker_lock);
        list_del(&pt->shrinker_list);
        mutex_unlock(&shrinker_lock);
 
-       list_for_each_entry_safe(p, tmp, &pt->pages, lru)
+       while ((p = ttm_pool_type_take(pt)))
                ttm_pool_free_page(pt->pool, pt->caching, pt->order, p);
 }
 
index 9269092697d8ca4faa574fd93fd05fd6d90ffac4..5703277c6f5276197f1d5a4c5d8d6ae76723456b 100644 (file)
@@ -32,6 +32,22 @@ static int udl_usb_resume(struct usb_interface *interface)
        return drm_mode_config_helper_resume(dev);
 }
 
+/*
+ * FIXME: Dma-buf sharing requires DMA support by the importing device.
+ *        This function is a workaround to make USB devices work as well.
+ *        See todo.rst for how to fix the issue in the dma-buf framework.
+ */
+static struct drm_gem_object *udl_driver_gem_prime_import(struct drm_device *dev,
+                                                         struct dma_buf *dma_buf)
+{
+       struct udl_device *udl = to_udl(dev);
+
+       if (!udl->dmadev)
+               return ERR_PTR(-ENODEV);
+
+       return drm_gem_prime_import_dev(dev, dma_buf, udl->dmadev);
+}
+
 DEFINE_DRM_GEM_FOPS(udl_driver_fops);
 
 static const struct drm_driver driver = {
@@ -40,6 +56,7 @@ static const struct drm_driver driver = {
        /* GEM hooks */
        .fops = &udl_driver_fops,
        DRM_GEM_SHMEM_DRIVER_OPS,
+       .gem_prime_import = udl_driver_gem_prime_import,
 
        .name = DRIVER_NAME,
        .desc = DRIVER_DESC,
index 875e73551ae981451501d0b3142bd5e9667ae5f5..cc16a13316e4e1f565331449b6ee17b6cee3b543 100644 (file)
@@ -50,6 +50,7 @@ struct urb_list {
 struct udl_device {
        struct drm_device drm;
        struct device *dev;
+       struct device *dmadev;
 
        struct drm_simple_display_pipe display_pipe;
 
index 0e2a376cb0752a33a659e7236969571077e12c42..853f147036f6b5c5ecda9598c0bbd8d0f010a8d0 100644 (file)
@@ -315,6 +315,10 @@ int udl_init(struct udl_device *udl)
 
        DRM_DEBUG("\n");
 
+       udl->dmadev = usb_intf_get_dma_device(to_usb_interface(dev->dev));
+       if (!udl->dmadev)
+               drm_warn(dev, "buffer sharing not supported"); /* not an error */
+
        mutex_init(&udl->gem_lock);
 
        if (!udl_parse_vendor_descriptor(udl)) {
@@ -343,12 +347,18 @@ int udl_init(struct udl_device *udl)
 err:
        if (udl->urbs.count)
                udl_free_urb_list(dev);
+       put_device(udl->dmadev);
        DRM_ERROR("%d\n", ret);
        return ret;
 }
 
 int udl_drop_usb(struct drm_device *dev)
 {
+       struct udl_device *udl = to_udl(dev);
+
        udl_free_urb_list(dev);
+       put_device(udl->dmadev);
+       udl->dmadev = NULL;
+
        return 0;
 }
index 0a900afc66ffd095b5883e6430243586c2866f8d..45c9c6a7f1d6965b310af7e512856293bcb2191d 100644 (file)
@@ -500,8 +500,6 @@ vm_fault_t vmw_bo_vm_huge_fault(struct vm_fault *vmf,
        vm_fault_t ret;
        pgoff_t fault_page_size;
        bool write = vmf->flags & FAULT_FLAG_WRITE;
-       bool is_cow_mapping =
-               (vma->vm_flags & (VM_SHARED | VM_MAYWRITE)) == VM_MAYWRITE;
 
        switch (pe_size) {
        case PE_SIZE_PMD:
@@ -518,7 +516,7 @@ vm_fault_t vmw_bo_vm_huge_fault(struct vm_fault *vmf,
        }
 
        /* Always do write dirty-tracking and COW on PTE level. */
-       if (write && (READ_ONCE(vbo->dirty) || is_cow_mapping))
+       if (write && (READ_ONCE(vbo->dirty) || is_cow_mapping(vma->vm_flags)))
                return VM_FAULT_FALLBACK;
 
        ret = ttm_bo_vm_reserve(bo, vmf);
index 3c03b1746661a8347bee11561a288fdc68851da5..cb9975889e2ff55c00e18a932d473b002bb9aa8b 100644 (file)
@@ -49,7 +49,7 @@ int vmw_mmap(struct file *filp, struct vm_area_struct *vma)
        vma->vm_ops = &vmw_vm_ops;
 
        /* Use VM_PFNMAP rather than VM_MIXEDMAP if not a COW mapping */
-       if ((vma->vm_flags & (VM_SHARED | VM_MAYWRITE)) != VM_MAYWRITE)
+       if (!is_cow_mapping(vma->vm_flags))
                vma->vm_flags = (vma->vm_flags & ~VM_MIXEDMAP) | VM_PFNMAP;
 
        return 0;
index 769381b05b9ac45ffe6251c291f577333d7cdc5c..d20a3b574af9ccc604acb00116b12a76051717b7 100644 (file)
@@ -266,6 +266,8 @@ config ADI_AXI_ADC
        select IIO_BUFFER
        select IIO_BUFFER_HW_CONSUMER
        select IIO_BUFFER_DMAENGINE
+       depends on HAS_IOMEM
+       depends on OF
        help
          Say yes here to build support for Analog Devices Generic
          AXI ADC IP core. The IP core is used for interfacing with
index 6f9a3e2d5533bc798577094a5d50cd2eca9da5e7..7b5212ba55011f8b6815a433d7617f4e39b14642 100644 (file)
@@ -918,7 +918,7 @@ static int ab8500_gpadc_read_raw(struct iio_dev *indio_dev,
                        return processed;
 
                /* Return millivolt or milliamps or millicentigrades */
-               *val = processed * 1000;
+               *val = processed;
                return IIO_VAL_INT;
        }
 
index 5d597e5050f6820c598777cf6da677196c202322..1b4b3203e42858b7a36e1bdfdcf83696a1b1f809 100644 (file)
@@ -91,7 +91,7 @@ static int ad7949_spi_read_channel(struct ad7949_adc_chip *ad7949_adc, int *val,
        int ret;
        int i;
        int bits_per_word = ad7949_adc->resolution;
-       int mask = GENMASK(ad7949_adc->resolution, 0);
+       int mask = GENMASK(ad7949_adc->resolution - 1, 0);
        struct spi_message msg;
        struct spi_transfer tx[] = {
                {
index 05ff948372b33ff28dcc44662fdadebc82524634..07b1a99381d977b3dce9bcd107a3fb9dce9e02b1 100644 (file)
@@ -597,7 +597,7 @@ static const struct vadc_channels vadc_chans[] = {
        VADC_CHAN_NO_SCALE(P_MUX16_1_3, 1)
 
        VADC_CHAN_NO_SCALE(LR_MUX1_BAT_THERM, 0)
-       VADC_CHAN_NO_SCALE(LR_MUX2_BAT_ID, 0)
+       VADC_CHAN_VOLT(LR_MUX2_BAT_ID, 0, SCALE_DEFAULT)
        VADC_CHAN_NO_SCALE(LR_MUX3_XO_THERM, 0)
        VADC_CHAN_NO_SCALE(LR_MUX4_AMUX_THM1, 0)
        VADC_CHAN_NO_SCALE(LR_MUX5_AMUX_THM2, 0)
index dfa31a23500f0d622f026a9991eec23e1054818a..ac90be03332af86ba35687a76938e6684e8e268e 100644 (file)
@@ -551,6 +551,8 @@ static irqreturn_t mpu3050_trigger_handler(int irq, void *p)
                                               MPU3050_FIFO_R,
                                               &fifo_values[offset],
                                               toread);
+                       if (ret)
+                               goto out_trigger_unlock;
 
                        dev_dbg(mpu3050->dev,
                                "%04x %04x %04x %04x %04x\n",
index ec88ae3f233dea2fe6173f54af20229876c5ad4d..74383abc0d446ead9fdb93c966f5f5229b2d1c35 100644 (file)
 struct hid_humidity_state {
        struct hid_sensor_common common_attributes;
        struct hid_sensor_hub_attribute_info humidity_attr;
-       s32 humidity_data;
+       struct {
+               s32 humidity_data;
+               u64 timestamp __aligned(8);
+       } scan;
        int scale_pre_decml;
        int scale_post_decml;
        int scale_precision;
@@ -129,9 +132,8 @@ static int humidity_proc_event(struct hid_sensor_hub_device *hsdev,
        struct hid_humidity_state *humid_st = iio_priv(indio_dev);
 
        if (atomic_read(&humid_st->common_attributes.data_ready))
-               iio_push_to_buffers_with_timestamp(indio_dev,
-                                       &humid_st->humidity_data,
-                                       iio_get_time_ns(indio_dev));
+               iio_push_to_buffers_with_timestamp(indio_dev, &humid_st->scan,
+                                                  iio_get_time_ns(indio_dev));
 
        return 0;
 }
@@ -146,7 +148,7 @@ static int humidity_capture_sample(struct hid_sensor_hub_device *hsdev,
 
        switch (usage_id) {
        case HID_USAGE_SENSOR_ATMOSPHERIC_HUMIDITY:
-               humid_st->humidity_data = *(s32 *)raw_data;
+               humid_st->scan.humidity_data = *(s32 *)raw_data;
 
                return 0;
        default:
index b1ec14bf439f7a7d2ac9fc013701bda361a9f9cd..768aa493a1a60d36bf240b0abffa671d46b6415b 100644 (file)
@@ -462,8 +462,7 @@ static int adis16400_initial_setup(struct iio_dev *indio_dev)
                if (ret)
                        goto err_ret;
 
-               ret = sscanf(indio_dev->name, "adis%u\n", &device_id);
-               if (ret != 1) {
+               if (sscanf(indio_dev->name, "adis%u\n", &device_id) != 1) {
                        ret = -EINVAL;
                        goto err_ret;
                }
index 4ab285a418d5e7c00d02a6f953885bb4f9729325..17d167c3d595aaec6b78b0f34b4793b4e43d965a 100644 (file)
@@ -23,6 +23,9 @@ struct prox_state {
        struct hid_sensor_common common_attributes;
        struct hid_sensor_hub_attribute_info prox_attr;
        u32 human_presence;
+       int scale_pre_decml;
+       int scale_post_decml;
+       int scale_precision;
 };
 
 static const u32 prox_sensitivity_addresses[] = {
@@ -98,8 +101,9 @@ static int prox_read_raw(struct iio_dev *indio_dev,
                ret_type = IIO_VAL_INT;
                break;
        case IIO_CHAN_INFO_SCALE:
-               *val = prox_state->prox_attr.units;
-               ret_type = IIO_VAL_INT;
+               *val = prox_state->scale_pre_decml;
+               *val2 = prox_state->scale_post_decml;
+               ret_type = prox_state->scale_precision;
                break;
        case IIO_CHAN_INFO_OFFSET:
                *val = hid_sensor_convert_exponent(
index e3d38cbcf354b9c09614ff6d97753a30d3a0b346..dc534ed784c39e76535e2ff234924c5ffe53bb75 100644 (file)
 struct temperature_state {
        struct hid_sensor_common common_attributes;
        struct hid_sensor_hub_attribute_info temperature_attr;
-       s32 temperature_data;
+       struct {
+               s32 temperature_data;
+               u64 timestamp __aligned(8);
+       } scan;
        int scale_pre_decml;
        int scale_post_decml;
        int scale_precision;
@@ -36,7 +39,7 @@ static const struct iio_chan_spec temperature_channels[] = {
                        BIT(IIO_CHAN_INFO_SAMP_FREQ) |
                        BIT(IIO_CHAN_INFO_HYSTERESIS),
        },
-       IIO_CHAN_SOFT_TIMESTAMP(3),
+       IIO_CHAN_SOFT_TIMESTAMP(1),
 };
 
 /* Adjust channel real bits based on report descriptor */
@@ -127,9 +130,8 @@ static int temperature_proc_event(struct hid_sensor_hub_device *hsdev,
        struct temperature_state *temp_st = iio_priv(indio_dev);
 
        if (atomic_read(&temp_st->common_attributes.data_ready))
-               iio_push_to_buffers_with_timestamp(indio_dev,
-                               &temp_st->temperature_data,
-                               iio_get_time_ns(indio_dev));
+               iio_push_to_buffers_with_timestamp(indio_dev, &temp_st->scan,
+                                                  iio_get_time_ns(indio_dev));
 
        return 0;
 }
@@ -144,7 +146,7 @@ static int temperature_capture_sample(struct hid_sensor_hub_device *hsdev,
 
        switch (usage_id) {
        case HID_USAGE_SENSOR_DATA_ENVIRONMENTAL_TEMPERATURE:
-               temp_st->temperature_data = *(s32 *)raw_data;
+               temp_st->scan.temperature_data = *(s32 *)raw_data;
                return 0;
        default:
                return -EINVAL;
index 430dc69750048a88105551979b8e1640e9cf07ac..da8963a9f044cb68e7230c4ec4da450b22e41a7f 100644 (file)
@@ -26,7 +26,6 @@
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
 MODULE_DESCRIPTION("Joystick device interfaces");
-MODULE_SUPPORTED_DEVICE("input/js");
 MODULE_LICENSE("GPL");
 
 #define JOYDEV_MINOR_BASE      0
index 9126efcbaf2c7c3f8d72fe4579ca07e762e82ead..321f5906e6ed3a51413db16c3a601854717f7194 100644 (file)
@@ -2714,7 +2714,6 @@ static int __init early_amd_iommu_init(void)
        struct acpi_table_header *ivrs_base;
        int i, remap_cache_sz, ret;
        acpi_status status;
-       u32 pci_id;
 
        if (!amd_iommu_detected)
                return -ENODEV;
@@ -2804,16 +2803,6 @@ static int __init early_amd_iommu_init(void)
        if (ret)
                goto out;
 
-       /* Disable IOMMU if there's Stoney Ridge graphics */
-       for (i = 0; i < 32; i++) {
-               pci_id = read_pci_config(0, i, 0, 0);
-               if ((pci_id & 0xffff) == 0x1002 && (pci_id >> 16) == 0x98e4) {
-                       pr_info("Disable IOMMU on Stoney Ridge\n");
-                       amd_iommu_disabled = true;
-                       break;
-               }
-       }
-
        /* Disable any previously enabled IOMMUs */
        if (!is_kdump_kernel() || amd_iommu_disabled)
                disable_iommus();
@@ -2880,6 +2869,7 @@ static bool detect_ivrs(void)
 {
        struct acpi_table_header *ivrs_base;
        acpi_status status;
+       int i;
 
        status = acpi_get_table("IVRS", 0, &ivrs_base);
        if (status == AE_NOT_FOUND)
@@ -2892,6 +2882,17 @@ static bool detect_ivrs(void)
 
        acpi_put_table(ivrs_base);
 
+       /* Don't use IOMMU if there is Stoney Ridge graphics */
+       for (i = 0; i < 32; i++) {
+               u32 pci_id;
+
+               pci_id = read_pci_config(0, i, 0, 0);
+               if ((pci_id & 0xffff) == 0x1002 && (pci_id >> 16) == 0x98e4) {
+                       pr_info("Disable IOMMU on Stoney Ridge\n");
+                       return false;
+               }
+       }
+
        /* Make sure ACS will be enabled during PCI probe */
        pci_request_acs();
 
@@ -2918,12 +2919,12 @@ static int __init state_next(void)
                }
                break;
        case IOMMU_IVRS_DETECTED:
-               ret = early_amd_iommu_init();
-               init_state = ret ? IOMMU_INIT_ERROR : IOMMU_ACPI_FINISHED;
-               if (init_state == IOMMU_ACPI_FINISHED && amd_iommu_disabled) {
-                       pr_info("AMD IOMMU disabled\n");
+               if (amd_iommu_disabled) {
                        init_state = IOMMU_CMDLINE_DISABLED;
                        ret = -EINVAL;
+               } else {
+                       ret = early_amd_iommu_init();
+                       init_state = ret ? IOMMU_INIT_ERROR : IOMMU_ACPI_FINISHED;
                }
                break;
        case IOMMU_ACPI_FINISHED:
@@ -3001,8 +3002,11 @@ int __init amd_iommu_prepare(void)
        amd_iommu_irq_remap = true;
 
        ret = iommu_go_to_state(IOMMU_ACPI_FINISHED);
-       if (ret)
+       if (ret) {
+               amd_iommu_irq_remap = false;
                return ret;
+       }
+
        return amd_iommu_irq_remap ? 0 : -ENODEV;
 }
 
index 97eb62f667d22d18b45cabeee90231e7aada3339..602aab98c0794812f94c30c6b7b54f29cddf9ec0 100644 (file)
@@ -849,12 +849,11 @@ static struct iommu_device *tegra_smmu_probe_device(struct device *dev)
                smmu = tegra_smmu_find(args.np);
                if (smmu) {
                        err = tegra_smmu_configure(smmu, dev, &args);
-                       of_node_put(args.np);
 
-                       if (err < 0)
+                       if (err < 0) {
+                               of_node_put(args.np);
                                return ERR_PTR(err);
-
-                       break;
+                       }
                }
 
                of_node_put(args.np);
index e74fa206240a1e93a395c2d404287d7d841f51fe..15536e321df55605694049e74b30c4cc454e23cf 100644 (file)
@@ -8,7 +8,6 @@ config IRQCHIP
 config ARM_GIC
        bool
        select IRQ_DOMAIN_HIERARCHY
-       select GENERIC_IRQ_MULTI_HANDLER
        select GENERIC_IRQ_EFFECTIVE_AFF_MASK
 
 config ARM_GIC_PM
@@ -33,7 +32,6 @@ config GIC_NON_BANKED
 
 config ARM_GIC_V3
        bool
-       select GENERIC_IRQ_MULTI_HANDLER
        select IRQ_DOMAIN_HIERARCHY
        select PARTITION_PERCPU
        select GENERIC_IRQ_EFFECTIVE_AFF_MASK
@@ -64,7 +62,6 @@ config ARM_NVIC
 config ARM_VIC
        bool
        select IRQ_DOMAIN
-       select GENERIC_IRQ_MULTI_HANDLER
 
 config ARM_VIC_NR
        int
@@ -99,14 +96,12 @@ config ATMEL_AIC_IRQ
        bool
        select GENERIC_IRQ_CHIP
        select IRQ_DOMAIN
-       select GENERIC_IRQ_MULTI_HANDLER
        select SPARSE_IRQ
 
 config ATMEL_AIC5_IRQ
        bool
        select GENERIC_IRQ_CHIP
        select IRQ_DOMAIN
-       select GENERIC_IRQ_MULTI_HANDLER
        select SPARSE_IRQ
 
 config I8259
@@ -153,7 +148,6 @@ config DW_APB_ICTL
 config FARADAY_FTINTC010
        bool
        select IRQ_DOMAIN
-       select GENERIC_IRQ_MULTI_HANDLER
        select SPARSE_IRQ
 
 config HISILICON_IRQ_MBIGEN
@@ -169,7 +163,6 @@ config IMGPDC_IRQ
 config IXP4XX_IRQ
        bool
        select IRQ_DOMAIN
-       select GENERIC_IRQ_MULTI_HANDLER
        select SPARSE_IRQ
 
 config MADERA_IRQ
@@ -186,7 +179,6 @@ config CLPS711X_IRQCHIP
        bool
        depends on ARCH_CLPS711X
        select IRQ_DOMAIN
-       select GENERIC_IRQ_MULTI_HANDLER
        select SPARSE_IRQ
        default y
 
@@ -205,7 +197,6 @@ config OMAP_IRQCHIP
 config ORION_IRQCHIP
        bool
        select IRQ_DOMAIN
-       select GENERIC_IRQ_MULTI_HANDLER
 
 config PIC32_EVIC
        bool
index 7a7222d4c19c053d1f3cbcb66a91833c64cab71e..b938d1d04d96ec333c262f8518b47ccb108a5ed5 100644 (file)
@@ -179,5 +179,6 @@ err_free_tcu:
 }
 IRQCHIP_DECLARE(jz4740_tcu_irq, "ingenic,jz4740-tcu", ingenic_tcu_irq_init);
 IRQCHIP_DECLARE(jz4725b_tcu_irq, "ingenic,jz4725b-tcu", ingenic_tcu_irq_init);
+IRQCHIP_DECLARE(jz4760_tcu_irq, "ingenic,jz4760-tcu", ingenic_tcu_irq_init);
 IRQCHIP_DECLARE(jz4770_tcu_irq, "ingenic,jz4770-tcu", ingenic_tcu_irq_init);
 IRQCHIP_DECLARE(x1000_tcu_irq, "ingenic,x1000-tcu", ingenic_tcu_irq_init);
index b61a8901ef72211df72384cd14475267356fa3f4..ea36bb00be80bfd8e578c5b739b99b55c3e89710 100644 (file)
@@ -155,6 +155,7 @@ static int __init intc_2chip_of_init(struct device_node *node,
 {
        return ingenic_intc_of_init(node, 2);
 }
+IRQCHIP_DECLARE(jz4760_intc, "ingenic,jz4760-intc", intc_2chip_of_init);
 IRQCHIP_DECLARE(jz4770_intc, "ingenic,jz4770-intc", intc_2chip_of_init);
 IRQCHIP_DECLARE(jz4775_intc, "ingenic,jz4775-intc", intc_2chip_of_init);
 IRQCHIP_DECLARE(jz4780_intc, "ingenic,jz4780-intc", intc_2chip_of_init);
index d2ab6ab080ac3954b6a56fc41e91e09491413813..f62db7e520b52353a0037cdfddecf313663b095a 100644 (file)
@@ -51,10 +51,8 @@ static ssize_t ttyname_store(struct device *dev,
 
        if (size) {
                ttyname = kmemdup_nul(buf, size, GFP_KERNEL);
-               if (!ttyname) {
-                       ret = -ENOMEM;
-                       goto out_unlock;
-               }
+               if (!ttyname)
+                       return -ENOMEM;
        } else {
                ttyname = NULL;
        }
@@ -69,7 +67,6 @@ static ssize_t ttyname_store(struct device *dev,
 
        trigger_data->ttyname = ttyname;
 
-out_unlock:
        mutex_unlock(&trigger_data->mutex);
 
        if (ttyname && !running)
@@ -125,12 +122,12 @@ static void ledtrig_tty_work(struct work_struct *work)
 
        if (icount.rx != trigger_data->rx ||
            icount.tx != trigger_data->tx) {
-               led_set_brightness(trigger_data->led_cdev, LED_ON);
+               led_set_brightness_sync(trigger_data->led_cdev, LED_ON);
 
                trigger_data->rx = icount.rx;
                trigger_data->tx = icount.tx;
        } else {
-               led_set_brightness(trigger_data->led_cdev, LED_OFF);
+               led_set_brightness_sync(trigger_data->led_cdev, LED_OFF);
        }
 
 out:
index 71691f32959b38adc1f1aab670a371589919023d..03e1fe4de53dea9047f16708686a00c59f20c011 100644 (file)
@@ -965,7 +965,7 @@ static int bcache_device_init(struct bcache_device *d, unsigned int block_size,
        q->limits.max_hw_sectors        = UINT_MAX;
        q->limits.max_sectors           = UINT_MAX;
        q->limits.max_segment_size      = UINT_MAX;
-       q->limits.max_segments          = BIO_MAX_PAGES;
+       q->limits.max_segments          = BIO_MAX_VECS;
        blk_queue_max_discard_sectors(q, UINT_MAX);
        q->limits.discard_granularity   = 512;
        q->limits.io_min                = block_size;
index 11c105ecd165a07f44969d44e58a874fab42a9d3..b0ab080f25676952314d33784de86cd40dc1c600 100644 (file)
@@ -229,7 +229,7 @@ static DEFINE_SPINLOCK(dm_crypt_clients_lock);
 static unsigned dm_crypt_clients_n = 0;
 static volatile unsigned long dm_crypt_pages_per_client;
 #define DM_CRYPT_MEMORY_PERCENT                        2
-#define DM_CRYPT_MIN_PAGES_PER_CLIENT          (BIO_MAX_PAGES * 16)
+#define DM_CRYPT_MIN_PAGES_PER_CLIENT          (BIO_MAX_VECS * 16)
 
 static void clone_init(struct dm_crypt_io *, struct bio *);
 static void kcryptd_queue_crypt(struct dm_crypt_io *io);
@@ -3246,7 +3246,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
                ALIGN(sizeof(struct dm_crypt_io) + cc->dmreq_start + additional_req_size,
                      ARCH_KMALLOC_MINALIGN);
 
-       ret = mempool_init(&cc->page_pool, BIO_MAX_PAGES, crypt_page_alloc, crypt_page_free, cc);
+       ret = mempool_init(&cc->page_pool, BIO_MAX_VECS, crypt_page_alloc, crypt_page_free, cc);
        if (ret) {
                ti->error = "Cannot allocate page mempool";
                goto bad;
@@ -3373,9 +3373,9 @@ static int crypt_map(struct dm_target *ti, struct bio *bio)
        /*
         * Check if bio is too large, split as needed.
         */
-       if (unlikely(bio->bi_iter.bi_size > (BIO_MAX_PAGES << PAGE_SHIFT)) &&
+       if (unlikely(bio->bi_iter.bi_size > (BIO_MAX_VECS << PAGE_SHIFT)) &&
            (bio_data_dir(bio) == WRITE || cc->on_disk_tag_size))
-               dm_accept_partial_bio(bio, ((BIO_MAX_PAGES << PAGE_SHIFT) >> SECTOR_SHIFT));
+               dm_accept_partial_bio(bio, ((BIO_MAX_VECS << PAGE_SHIFT) >> SECTOR_SHIFT));
 
        /*
         * Ensure that bio is a multiple of internal sector encryption size
index 844c4be11768d3dc798f22199ddcfc8142eacb7c..4f72b6f66c3aeb71b1692afbe36e5d56b07683a2 100644 (file)
@@ -1892,10 +1892,10 @@ restart:
                        list_add(&g->lru, &wbl.list);
                        wbl.size++;
                        g->write_in_progress = true;
-                       g->wc_list_contiguous = BIO_MAX_PAGES;
+                       g->wc_list_contiguous = BIO_MAX_VECS;
                        f = g;
                        e->wc_list_contiguous++;
-                       if (unlikely(e->wc_list_contiguous == BIO_MAX_PAGES)) {
+                       if (unlikely(e->wc_list_contiguous == BIO_MAX_VECS)) {
                                if (unlikely(wc->writeback_all)) {
                                        next_node = rb_next(&f->rb_node);
                                        if (likely(next_node))
index 4337ae0e6af2e4c3840ba11040e4c9744da873d1..0b5dcaabbc15595d65e9467a41259464b76cdffb 100644 (file)
@@ -735,7 +735,7 @@ static void r5l_submit_current_io(struct r5l_log *log)
 
 static struct bio *r5l_bio_alloc(struct r5l_log *log)
 {
-       struct bio *bio = bio_alloc_bioset(GFP_NOIO, BIO_MAX_PAGES, &log->bs);
+       struct bio *bio = bio_alloc_bioset(GFP_NOIO, BIO_MAX_VECS, &log->bs);
 
        bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
        bio_set_dev(bio, log->rdev->bdev);
@@ -1634,7 +1634,7 @@ static int r5l_recovery_allocate_ra_pool(struct r5l_log *log,
 {
        struct page *page;
 
-       ctx->ra_bio = bio_alloc_bioset(GFP_KERNEL, BIO_MAX_PAGES, &log->bs);
+       ctx->ra_bio = bio_alloc_bioset(GFP_KERNEL, BIO_MAX_VECS, &log->bs);
        if (!ctx->ra_bio)
                return -ENOMEM;
 
index e8c118e05dfd46edbccddafe109ca42077803c69..3ddc2aa0b5306429613b368e6ad2c24657143bf0 100644 (file)
@@ -496,7 +496,7 @@ static void ppl_submit_iounit(struct ppl_io_unit *io)
                if (!bio_add_page(bio, sh->ppl_page, PAGE_SIZE, 0)) {
                        struct bio *prev = bio;
 
-                       bio = bio_alloc_bioset(GFP_NOIO, BIO_MAX_PAGES,
+                       bio = bio_alloc_bioset(GFP_NOIO, BIO_MAX_VECS,
                                               &ppl_conf->bs);
                        bio->bi_opf = prev->bi_opf;
                        bio->bi_write_hint = prev->bi_write_hint;
index 8a8585261bb803794c42e5f794d1825ce6bb1599..5f6e97a8d1c063a697cadad68142d31552a7c947 100644 (file)
@@ -430,4 +430,3 @@ MODULE_AUTHOR("Andreas Monitzer <andy@monitzer.com>");
 MODULE_AUTHOR("Ben Backx <ben@bbackx.com>");
 MODULE_DESCRIPTION("FireDTV DVB Driver");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("FireDTV DVB");
index 692b95a685d1a68f4da458a5a6baf19acb7fa0fb..9a82e68303b617b964d86906026f981ea44af4d3 100644 (file)
@@ -41,7 +41,6 @@ MODULE_PARM_DESC(debug,
 
 MODULE_AUTHOR("Andy Walls");
 MODULE_DESCRIPTION("CX23418 ALSA Interface");
-MODULE_SUPPORTED_DEVICE("CX23418 MPEG2 encoder");
 MODULE_LICENSE("GPL");
 
 MODULE_VERSION(CX18_VERSION);
index 95aed00f353bd1a039c6d1d9f079e8bf2a4208c6..f2440eb38820bd8f7877f2040907988b4640d3f8 100644 (file)
@@ -232,7 +232,6 @@ MODULE_PARM_DESC(cx18_first_minor,
 
 MODULE_AUTHOR("Hans Verkuil");
 MODULE_DESCRIPTION("CX23418 driver");
-MODULE_SUPPORTED_DEVICE("CX23418 MPEG2 encoder");
 MODULE_LICENSE("GPL");
 
 MODULE_VERSION(CX18_VERSION);
index 608fbaf0f659a244da68f509de472572ded58179..8797d85a6b0a21bfe58aa30d3d2a9e8b5841ea5d 100644 (file)
@@ -104,7 +104,6 @@ MODULE_PARM_DESC(index, "Index value for cx25821 capture interface(s).");
 MODULE_DESCRIPTION("ALSA driver module for cx25821 based capture cards");
 MODULE_AUTHOR("Hiep Huynh");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Conexant,25821}");  /* "{{Conexant,23881}," */
 
 static unsigned int debug;
 module_param(debug, int, 0644);
index 95e0cbb1277dc7a8e92753e55223240933453a70..c83814c052d366949db8176c2dcd95f50d7a1120 100644 (file)
@@ -98,7 +98,6 @@ MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@kernel.org>");
 MODULE_LICENSE("GPL v2");
 MODULE_VERSION(CX88_VERSION);
 
-MODULE_SUPPORTED_DEVICE("{{Conexant,23881},{{Conexant,23882},{{Conexant,23883}");
 static unsigned int debug;
 module_param(debug, int, 0644);
 MODULE_PARM_DESC(debug, "enable debug messages");
index 39029b8e12c9d6ddae3d28b5d655e6bada4b023b..4cefdb2e4d403b8da21b640aa9284e5bd2c3dc97 100644 (file)
@@ -38,7 +38,6 @@ MODULE_PARM_DESC(index,
 
 MODULE_AUTHOR("Andy Walls");
 MODULE_DESCRIPTION("CX23415/CX23416 ALSA Interface");
-MODULE_SUPPORTED_DEVICE("CX23415/CX23416 MPEG2 encoder");
 MODULE_LICENSE("GPL");
 
 MODULE_VERSION(IVTV_VERSION);
index 6e448cb3b51cb3743ef48a98a793d475c0a8f9b3..942b8c266f504c754319a6cb92ec77110405bb07 100644 (file)
@@ -275,9 +275,6 @@ MODULE_PARM_DESC(ivtv_first_minor, "Set device node number assigned to first car
 
 MODULE_AUTHOR("Kevin Thayer, Chris Kennedy, Hans Verkuil");
 MODULE_DESCRIPTION("CX23415/CX23416 driver");
-MODULE_SUPPORTED_DEVICE
-    ("CX23415/CX23416 MPEG2 encoder (WinTV PVR-150/250/350/500,\n"
-               "\t\t\tYuan MPG series and similar)");
 MODULE_LICENSE("GPL");
 
 MODULE_VERSION(IVTV_VERSION);
index 336df65c8af1168dab46661f3937768e60e151a5..524912f20d9f2beb0bd47551e41f1ff9fadcdac7 100644 (file)
@@ -1269,6 +1269,5 @@ late_initcall_sync(sta2x11_vip_init_module);
 MODULE_DESCRIPTION("STA2X11 Video Input Port driver");
 MODULE_AUTHOR("Wind River");
 MODULE_LICENSE("GPL v2");
-MODULE_SUPPORTED_DEVICE("sta2x11 video input");
 MODULE_VERSION(DRV_VERSION);
 MODULE_DEVICE_TABLE(pci, sta2x11_vip_pci_tbl);
index 0514be6153df4c415dcaaa3cc7305eaf155d6277..e392b3efe363322f21a2f2a456b6b3b23777be4a 100644 (file)
@@ -1363,4 +1363,3 @@ module_platform_driver(atmel_isi_driver);
 MODULE_AUTHOR("Josh Wu <josh.wu@atmel.com>");
 MODULE_DESCRIPTION("The V4L2 driver for Atmel Linux");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("video");
index 0b78fecfd2a83a13762fdf8927bda2d5f393c81b..61d9885765f47e78fc50ff8194313f50a44fb109 100644 (file)
@@ -330,4 +330,3 @@ module_platform_driver(atmel_isc_driver);
 MODULE_AUTHOR("Songjun Wu");
 MODULE_DESCRIPTION("The V4L2 driver for Atmel-ISC");
 MODULE_LICENSE("GPL v2");
-MODULE_SUPPORTED_DEVICE("video");
index 9c94a8b58b7c31f4ea84f124cf28ac584fd78052..baac86f3d1530dff948b146eb21ac4941f884aa6 100644 (file)
 MODULE_AUTHOR("Jonathan Corbet <corbet@lwn.net>");
 MODULE_DESCRIPTION("Marvell 88ALP01 CMOS Camera Controller driver");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("Video");
-
-
-
 
 struct cafe_camera {
        int registered;                 /* Fully initialized? */
index aa5f45749543b3cc0282f3180aca8d6157762070..a60c302ef2676bdba97cbaf2325cb042ff5eb1d4 100644 (file)
@@ -1288,7 +1288,6 @@ static void rkisp1_params_config_parameter(struct rkisp1_params *params)
        memset(hst.hist_weight, 0x01, sizeof(hst.hist_weight));
        rkisp1_hst_config(params, &hst);
        rkisp1_param_set_bits(params, RKISP1_CIF_ISP_HIST_PROP,
-                             ~RKISP1_CIF_ISP_HIST_PROP_MODE_MASK |
                              rkisp1_hst_params_default_config.mode);
 
        /* set the  range */
index bbcc2254fa2e69f54db223a070e0dd7c757ed1b8..d9b4ad0abf0c0c24256776e124c4edf16d49de7b 100644 (file)
@@ -2149,4 +2149,3 @@ MODULE_AUTHOR("Yannick Fertre <yannick.fertre@st.com>");
 MODULE_AUTHOR("Hugues Fruchet <hugues.fruchet@st.com>");
 MODULE_DESCRIPTION("STMicroelectronics STM32 Digital Camera Memory Interface driver");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("video");
index 86d5e3f4b1ffce357d57f29da4d50d080ccf4e22..06f74d410973eb3284142f66c261305404deda61 100644 (file)
@@ -245,7 +245,7 @@ static int vsp1_du_pipeline_setup_brx(struct vsp1_device *vsp1,
                brx = &vsp1->bru->entity;
        else if (pipe->brx && !drm_pipe->force_brx_release)
                brx = pipe->brx;
-       else if (!vsp1->bru->entity.pipe)
+       else if (vsp1_feature(vsp1, VSP1_HAS_BRU) && !vsp1->bru->entity.pipe)
                brx = &vsp1->bru->entity;
        else
                brx = &vsp1->brs->entity;
@@ -462,9 +462,9 @@ static int vsp1_du_pipeline_setup_inputs(struct vsp1_device *vsp1,
         * make sure it is present in the pipeline's list of entities if it
         * wasn't already.
         */
-       if (!use_uif) {
+       if (drm_pipe->uif && !use_uif) {
                drm_pipe->uif->pipe = NULL;
-       } else if (!drm_pipe->uif->pipe) {
+       } else if (drm_pipe->uif && !drm_pipe->uif->pipe) {
                drm_pipe->uif->pipe = pipe;
                list_add_tail(&drm_pipe->uif->list_pipe, &pipe->entities);
        }
index 5bb2932ab11954dd51c1a6ffba75c7105a6a9ef6..ff6a8fc4c38e50ed0469032956e62cdddde44477 100644 (file)
@@ -5,6 +5,7 @@ obj-y += keymaps/
 obj-$(CONFIG_RC_CORE) += rc-core.o
 rc-core-y := rc-main.o rc-ir-raw.o
 rc-core-$(CONFIG_LIRC) += lirc_dev.o
+rc-core-$(CONFIG_MEDIA_CEC_RC) += keymaps/rc-cec.o
 rc-core-$(CONFIG_BPF_LIRC_MODE2) += bpf-lirc.o
 obj-$(CONFIG_IR_NEC_DECODER) += ir-nec-decoder.o
 obj-$(CONFIG_IR_RC5_DECODER) += ir-rc5-decoder.o
index b252a1d2ebd66fa158cc99e6301f86f397e6bf3a..cc6662e1903f58923dc0a5ccc35b8b91eb6aab46 100644 (file)
@@ -21,7 +21,6 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \
                        rc-behold.o \
                        rc-behold-columbus.o \
                        rc-budget-ci-old.o \
-                       rc-cec.o \
                        rc-cinergy-1400.o \
                        rc-cinergy.o \
                        rc-d680-dmb.o \
index 3e3bd11092b45d439f8cff6255f1b72210fbc130..068e22aeac8c38166f88d36cf22722a6b84e7b98 100644 (file)
@@ -1,5 +1,15 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 /* Keytable for the CEC remote control
+ *
+ * This keymap is unusual in that it can't be built as a module,
+ * instead it is registered directly in rc-main.c if CONFIG_MEDIA_CEC_RC
+ * is set. This is because it can be called from drm_dp_cec_set_edid() via
+ * cec_register_adapter() in an asynchronous context, and it is not
+ * allowed to use request_module() to load rc-cec.ko in that case.
+ *
+ * Since this keymap is only used if CONFIG_MEDIA_CEC_RC is set, we
+ * just compile this keymap into the rc-core module and never as a
+ * separate module.
  *
  * Copyright (c) 2015 by Kamil Debski
  */
@@ -152,7 +162,7 @@ static struct rc_map_table cec[] = {
        /* 0x77-0xff: Reserved */
 };
 
-static struct rc_map_list cec_map = {
+struct rc_map_list cec_map = {
        .map = {
                .scan           = cec,
                .size           = ARRAY_SIZE(cec),
@@ -160,19 +170,3 @@ static struct rc_map_list cec_map = {
                .name           = RC_MAP_CEC,
        }
 };
-
-static int __init init_rc_map_cec(void)
-{
-       return rc_map_register(&cec_map);
-}
-
-static void __exit exit_rc_map_cec(void)
-{
-       rc_map_unregister(&cec_map);
-}
-
-module_init(init_rc_map_cec);
-module_exit(exit_rc_map_cec);
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Kamil Debski");
index 1fd62c1dac768d705cffa725492d54d477e41f58..8e88dc8ea6c5ee99351dc44457ce3748dbc2d0c7 100644 (file)
@@ -2069,6 +2069,9 @@ static int __init rc_core_init(void)
 
        led_trigger_register_simple("rc-feedback", &led_feedback);
        rc_map_register(&empty_map);
+#ifdef CONFIG_MEDIA_CEC_RC
+       rc_map_register(&cec_map);
+#endif
 
        return 0;
 }
@@ -2078,6 +2081,9 @@ static void __exit rc_core_exit(void)
        lirc_dev_exit();
        class_unregister(&rc_class);
        led_trigger_unregister_simple(led_feedback);
+#ifdef CONFIG_MEDIA_CEC_RC
+       rc_map_unregister(&cec_map);
+#endif
        rc_map_unregister(&empty_map);
 }
 
index e488e7870f42ca26efd2af337fef1352e5708351..69d5c628a7978890ff105209c221d9c377277038 100644 (file)
@@ -56,7 +56,6 @@ MODULE_PARM_DESC(flicker_mode, "Flicker frequency (0 (disabled), " __stringify(5
 
 MODULE_AUTHOR("Steve Miller (STMicroelectronics) <steve.miller@st.com>");
 MODULE_DESCRIPTION("V4L-driver for STMicroelectronics CPiA2 based cameras");
-MODULE_SUPPORTED_DEVICE("video");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(CPIA_VERSION);
 
index 3a2df36ef1db1b127f6720b0d3d1c0a84ed16245..a19a46770c2b1e93d8c1e916007892932fb3c7f2 100644 (file)
@@ -51,7 +51,6 @@ MODULE_PARM_DESC(index, "Index value for tm6000x capture interface(s).");
 MODULE_DESCRIPTION("ALSA driver module for tm5600/tm6000/tm6010 based TV cards");
 MODULE_AUTHOR("Mauro Carvalho Chehab");
 MODULE_LICENSE("GPL v2");
-MODULE_SUPPORTED_DEVICE("{{Trident,tm5600},{{Trident,tm6000},{{Trident,tm6010}");
 static unsigned int debug;
 module_param(debug, int, 0644);
 MODULE_PARM_DESC(debug, "enable debug messages");
index 293a460f4616c406fa647ad17aeaa730622a9bb5..4990fa886d7a78238e7f8cd6714ded5da7d6ea31 100644 (file)
@@ -23,8 +23,6 @@ MODULE_DESCRIPTION("DVB driver extension module for tm5600/6000/6010 based TV ca
 MODULE_AUTHOR("Mauro Carvalho Chehab");
 MODULE_LICENSE("GPL");
 
-MODULE_SUPPORTED_DEVICE("{{Trident, tm5600},{{Trident, tm6000},{{Trident, tm6010}");
-
 static int debug;
 
 module_param(debug, int, 0644);
index b57e94fb19770db90c870640489cb778930dfc59..333bd305a4f9fa387e4e5fcc4dec052caf53f022 100644 (file)
@@ -371,7 +371,7 @@ void usbtv_audio_free(struct usbtv *usbtv)
        cancel_work_sync(&usbtv->snd_trigger);
 
        if (usbtv->snd && usbtv->udev) {
-               snd_card_free(usbtv->snd);
+               snd_card_free_when_closed(usbtv->snd);
                usbtv->snd = NULL;
        }
 }
index f12e909034ac03fde819835d6cfc0186b57d2721..beda610e6b30d139d2ccf53d4fed655ee3952f4b 100644 (file)
@@ -950,6 +950,11 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl,  u32 kernel,
        if (!fl->cctx->rpdev)
                return -EPIPE;
 
+       if (handle == FASTRPC_INIT_HANDLE && !kernel) {
+               dev_warn_ratelimited(fl->sctx->dev, "user app trying to send a kernel RPC message (%d)\n",  handle);
+               return -EPERM;
+       }
+
        ctx = fastrpc_context_alloc(fl, kernel, sc, args);
        if (IS_ERR(ctx))
                return PTR_ERR(ctx);
index df847a6d19f4102308c0c898f482426bb8e9d9fd..9f19bee7b592214e1404efda1b93a3734d9b16b5 100644 (file)
@@ -992,7 +992,6 @@ void hl_debugfs_add_device(struct hl_device *hdev)
        struct hl_dbg_device_entry *dev_entry = &hdev->hl_debugfs;
        int count = ARRAY_SIZE(hl_debugfs_list);
        struct hl_debugfs_entry *entry;
-       struct dentry *ent;
        int i;
 
        dev_entry->hdev = hdev;
@@ -1105,13 +1104,11 @@ void hl_debugfs_add_device(struct hl_device *hdev)
                                &hl_security_violations_fops);
 
        for (i = 0, entry = dev_entry->entry_arr ; i < count ; i++, entry++) {
-
-               ent = debugfs_create_file(hl_debugfs_list[i].name,
+               debugfs_create_file(hl_debugfs_list[i].name,
                                        0444,
                                        dev_entry->root,
                                        entry,
                                        &hl_debugfs_fops);
-               entry->dent = ent;
                entry->info_ent = &hl_debugfs_list[i];
                entry->dev_entry = dev_entry;
        }
index 15fcb5c31c4b5d11023ab2bc86f47cd550c85185..334009e83823677b3779b805add6134c6783889e 100644 (file)
@@ -93,12 +93,19 @@ void hl_hpriv_put(struct hl_fpriv *hpriv)
 static int hl_device_release(struct inode *inode, struct file *filp)
 {
        struct hl_fpriv *hpriv = filp->private_data;
+       struct hl_device *hdev = hpriv->hdev;
+
+       filp->private_data = NULL;
+
+       if (!hdev) {
+               pr_crit("Closing FD after device was removed. Memory leak will occur and it is advised to reboot.\n");
+               put_pid(hpriv->taskpid);
+               return 0;
+       }
 
        hl_cb_mgr_fini(hpriv->hdev, &hpriv->cb_mgr);
        hl_ctx_mgr_fini(hpriv->hdev, &hpriv->ctx_mgr);
 
-       filp->private_data = NULL;
-
        hl_hpriv_put(hpriv);
 
        return 0;
@@ -107,15 +114,20 @@ static int hl_device_release(struct inode *inode, struct file *filp)
 static int hl_device_release_ctrl(struct inode *inode, struct file *filp)
 {
        struct hl_fpriv *hpriv = filp->private_data;
-       struct hl_device *hdev;
+       struct hl_device *hdev = hpriv->hdev;
 
        filp->private_data = NULL;
 
-       hdev = hpriv->hdev;
+       if (!hdev) {
+               pr_err("Closing FD after device was removed\n");
+               goto out;
+       }
 
        mutex_lock(&hdev->fpriv_list_lock);
        list_del(&hpriv->dev_node);
        mutex_unlock(&hdev->fpriv_list_lock);
+out:
+       put_pid(hpriv->taskpid);
 
        kfree(hpriv);
 
@@ -134,8 +146,14 @@ static int hl_device_release_ctrl(struct inode *inode, struct file *filp)
 static int hl_mmap(struct file *filp, struct vm_area_struct *vma)
 {
        struct hl_fpriv *hpriv = filp->private_data;
+       struct hl_device *hdev = hpriv->hdev;
        unsigned long vm_pgoff;
 
+       if (!hdev) {
+               pr_err_ratelimited("Trying to mmap after device was removed! Please close FD\n");
+               return -ENODEV;
+       }
+
        vm_pgoff = vma->vm_pgoff;
        vma->vm_pgoff = HL_MMAP_OFFSET_VALUE_GET(vm_pgoff);
 
@@ -883,6 +901,16 @@ wait_for_processes:
        return -EBUSY;
 }
 
+static void device_disable_open_processes(struct hl_device *hdev)
+{
+       struct hl_fpriv *hpriv;
+
+       mutex_lock(&hdev->fpriv_list_lock);
+       list_for_each_entry(hpriv, &hdev->fpriv_list, dev_node)
+               hpriv->hdev = NULL;
+       mutex_unlock(&hdev->fpriv_list_lock);
+}
+
 /*
  * hl_device_reset - reset the device
  *
@@ -1556,8 +1584,10 @@ void hl_device_fini(struct hl_device *hdev)
                HL_PENDING_RESET_LONG_SEC);
 
        rc = device_kill_open_processes(hdev, HL_PENDING_RESET_LONG_SEC);
-       if (rc)
+       if (rc) {
                dev_crit(hdev->dev, "Failed to kill all open processes\n");
+               device_disable_open_processes(hdev);
+       }
 
        hl_cb_pool_fini(hdev);
 
index d933878b24d133b6a0e61db940a96f94c97b6781..4b321e4f8059f6735a913534662929c0d92c1982 100644 (file)
@@ -1465,12 +1465,10 @@ struct hl_info_list {
 
 /**
  * struct hl_debugfs_entry - debugfs dentry wrapper.
- * @dent: base debugfs entry structure.
  * @info_ent: dentry realted ops.
  * @dev_entry: ASIC specific debugfs manager.
  */
 struct hl_debugfs_entry {
-       struct dentry                   *dent;
        const struct hl_info_list       *info_ent;
        struct hl_dbg_device_entry      *dev_entry;
 };
index 03af61cecd37bbbcbc48f89d24b6a6419486d7cf..083a30969c5f3698acc0151bee28808d1b5b90ef 100644 (file)
@@ -5,6 +5,8 @@
  * All Rights Reserved.
  */
 
+#define pr_fmt(fmt)    "habanalabs: " fmt
+
 #include <uapi/misc/habanalabs.h>
 #include "habanalabs.h"
 
@@ -682,6 +684,11 @@ long hl_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
        const struct hl_ioctl_desc *ioctl = NULL;
        unsigned int nr = _IOC_NR(cmd);
 
+       if (!hdev) {
+               pr_err_ratelimited("Sending ioctl after device was removed! Please close FD\n");
+               return -ENODEV;
+       }
+
        if ((nr >= HL_COMMAND_START) && (nr < HL_COMMAND_END)) {
                ioctl = &hl_ioctls[nr];
        } else {
@@ -700,6 +707,11 @@ long hl_ioctl_control(struct file *filep, unsigned int cmd, unsigned long arg)
        const struct hl_ioctl_desc *ioctl = NULL;
        unsigned int nr = _IOC_NR(cmd);
 
+       if (!hdev) {
+               pr_err_ratelimited("Sending ioctl after device was removed! Please close FD\n");
+               return -ENODEV;
+       }
+
        if (nr == _IOC_NR(HL_IOCTL_INFO)) {
                ioctl = &hl_ioctls_control[nr];
        } else {
index de53fb5f978a8a026d2172794f85ab1343b3af06..44a0522b59b9507e3b4144719a8a9d07bf26c4d2 100644 (file)
@@ -47,7 +47,7 @@ inline u32 hl_cq_inc_ptr(u32 ptr)
  * Increment ptr by 1. If it reaches the number of event queue
  * entries, set it to 0
  */
-inline u32 hl_eq_inc_ptr(u32 ptr)
+static inline u32 hl_eq_inc_ptr(u32 ptr)
 {
        ptr++;
        if (unlikely(ptr == HL_EQ_LENGTH))
index 71703a32350f66c7cd314ecaccd455442deeee01..93c9e5f587e1a476bba17318e532da2e3ecc9bc8 100644 (file)
@@ -499,18 +499,32 @@ static void hl_mmu_pa_page_with_offset(struct hl_ctx *ctx, u64 virt_addr,
        else /* HL_VA_RANGE_TYPE_DRAM */
                p = &prop->dmmu;
 
-       /*
-        * find the correct hop shift field in hl_mmu_properties structure
-        * in order to determine the right maks for the page offset.
-        */
-       hop0_shift_off = offsetof(struct hl_mmu_properties, hop0_shift);
-       p = (char *)p + hop0_shift_off;
-       p = (char *)p + ((hops->used_hops - 1) * sizeof(u64));
-       hop_shift = *(u64 *)p;
-       offset_mask = (1ull << hop_shift) - 1;
-       addr_mask = ~(offset_mask);
-       *phys_addr = (tmp_phys_addr & addr_mask) |
-                                       (virt_addr & offset_mask);
+       if ((hops->range_type == HL_VA_RANGE_TYPE_DRAM) &&
+                       !is_power_of_2(prop->dram_page_size)) {
+               u32 bit;
+               u64 page_offset_mask;
+               u64 phys_addr_mask;
+
+               bit = __ffs64((u64)prop->dram_page_size);
+               page_offset_mask = ((1ull << bit) - 1);
+               phys_addr_mask = ~page_offset_mask;
+               *phys_addr = (tmp_phys_addr & phys_addr_mask) |
+                               (virt_addr & page_offset_mask);
+       } else {
+               /*
+                * find the correct hop shift field in hl_mmu_properties
+                * structure in order to determine the right masks
+                * for the page offset.
+                */
+               hop0_shift_off = offsetof(struct hl_mmu_properties, hop0_shift);
+               p = (char *)p + hop0_shift_off;
+               p = (char *)p + ((hops->used_hops - 1) * sizeof(u64));
+               hop_shift = *(u64 *)p;
+               offset_mask = (1ull << hop_shift) - 1;
+               addr_mask = ~(offset_mask);
+               *phys_addr = (tmp_phys_addr & addr_mask) |
+                               (virt_addr & offset_mask);
+       }
 }
 
 int hl_mmu_va_to_pa(struct hl_ctx *ctx, u64 virt_addr, u64 *phys_addr)
index 2d778d0f011e6ce5ce8a77745cfce600f69487cc..c0fe3295c3303fd00ee7b26d54a2bfd6ba80b849 100644 (file)
@@ -2288,15 +2288,13 @@ crq_failed:
        return -EPERM;
 }
 
-static int ibmvmc_remove(struct vio_dev *vdev)
+static void ibmvmc_remove(struct vio_dev *vdev)
 {
        struct crq_server_adapter *adapter = dev_get_drvdata(&vdev->dev);
 
        dev_info(adapter->dev, "Entering remove for UA 0x%x\n",
                 vdev->unit_address);
        ibmvmc_release_crq_queue(adapter);
-
-       return 0;
 }
 
 static struct vio_device_id ibmvmc_device_table[] = {
index 9f350e05ef68a1dfc76e333f328ca7f66ed3a4cc..f1655f5ca016dfd7f09b52885c3e6ebfa320e00f 100644 (file)
@@ -140,6 +140,7 @@ static const struct of_device_id pvpanic_mmio_match[] = {
        { .compatible = "qemu,pvpanic-mmio", },
        {}
 };
+MODULE_DEVICE_TABLE(of, pvpanic_mmio_match);
 
 static const struct acpi_device_id pvpanic_device_ids[] = {
        { "QEMU0001", 0 },
index c2e70b757dd12c603ad9a5cbe7086b24841eec99..4383c262b3f5a383a95a56cdf115571ae838118d 100644 (file)
@@ -399,11 +399,6 @@ void mmc_remove_card(struct mmc_card *card)
        mmc_remove_card_debugfs(card);
 #endif
 
-       if (host->cqe_enabled) {
-               host->cqe_ops->cqe_disable(host);
-               host->cqe_enabled = false;
-       }
-
        if (mmc_card_present(card)) {
                if (mmc_host_is_spi(card->host)) {
                        pr_info("%s: SPI card removed\n",
@@ -416,6 +411,10 @@ void mmc_remove_card(struct mmc_card *card)
                of_node_put(card->dev.of_node);
        }
 
+       if (host->cqe_enabled) {
+               host->cqe_ops->cqe_disable(host);
+               host->cqe_enabled = false;
+       }
+
        put_device(&card->dev);
 }
-
index 0d80b72ddde8199da3916f63d26ac4fd8551cb2d..8741271d39712b4950a039c3244c0f26fbb08575 100644 (file)
@@ -423,10 +423,6 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd)
 
                /* EXT_CSD value is in units of 10ms, but we store in ms */
                card->ext_csd.part_time = 10 * ext_csd[EXT_CSD_PART_SWITCH_TIME];
-               /* Some eMMC set the value too low so set a minimum */
-               if (card->ext_csd.part_time &&
-                   card->ext_csd.part_time < MMC_MIN_PART_SWITCH_TIME)
-                       card->ext_csd.part_time = MMC_MIN_PART_SWITCH_TIME;
 
                /* Sleep / awake timeout in 100ns units */
                if (sa_shift > 0 && sa_shift <= 0x17)
@@ -616,6 +612,17 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd)
                card->ext_csd.data_sector_size = 512;
        }
 
+       /*
+        * GENERIC_CMD6_TIME is to be used "unless a specific timeout is defined
+        * when accessing a specific field", so use it here if there is no
+        * PARTITION_SWITCH_TIME.
+        */
+       if (!card->ext_csd.part_time)
+               card->ext_csd.part_time = card->ext_csd.generic_cmd6_time;
+       /* Some eMMC set the value too low so set a minimum */
+       if (card->ext_csd.part_time < MMC_MIN_PART_SWITCH_TIME)
+               card->ext_csd.part_time = MMC_MIN_PART_SWITCH_TIME;
+
        /* eMMC v5 or later */
        if (card->ext_csd.rev >= 7) {
                memcpy(card->ext_csd.fwrev, &ext_csd[EXT_CSD_FIRMWARE_VERSION],
index 17dbc81c221eb5ad20ad269adc9a91530fb641cc..984d350551567d1c7a299f76fd5b3739b7633ddd 100644 (file)
@@ -1242,7 +1242,11 @@ mmci_start_command(struct mmci_host *host, struct mmc_command *cmd, u32 c)
                if (!cmd->busy_timeout)
                        cmd->busy_timeout = 10 * MSEC_PER_SEC;
 
-               clks = (unsigned long long)cmd->busy_timeout * host->cclk;
+               if (cmd->busy_timeout > host->mmc->max_busy_timeout)
+                       clks = (unsigned long long)host->mmc->max_busy_timeout * host->cclk;
+               else
+                       clks = (unsigned long long)cmd->busy_timeout * host->cclk;
+
                do_div(clks, MSEC_PER_SEC);
                writel_relaxed(clks, host->base + MMCIDATATIMER);
        }
@@ -2151,6 +2155,10 @@ static int mmci_probe(struct amba_device *dev,
                mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY;
        }
 
+       /* Variants with mandatory busy timeout in HW needs R1B responses. */
+       if (variant->busy_timeout)
+               mmc->caps |= MMC_CAP_NEED_RSP_BUSY;
+
        /* Prepare a CMD12 - needed to clear the DPSM on some variants. */
        host->stop_abort.opcode = MMC_STOP_TRANSMISSION;
        host->stop_abort.arg = 0;
index ebfe84e69715d5433c597912bc421ef2a03c8327..4b8145b9e7ad510966a597d145138b7efdbbbf1f 100644 (file)
@@ -32,4 +32,14 @@ config MOST_CDEV
 
          To compile this driver as a module, choose M here: the
          module will be called most_cdev.
+
+config MOST_SND
+       tristate "Sound"
+       depends on SND
+       select SND_PCM
+       help
+         Say Y here if you want to commumicate via ALSA/sound devices.
+
+         To compile this driver as a module, choose M here: the
+         module will be called most_sound.
 endif
index 8b53ca46633f14b2408ae198e2cb31a24010037c..60db6cd3787af3127af7b2db7f68e82c41ee7f8a 100644 (file)
@@ -5,3 +5,4 @@ most_core-y :=  core.o \
 
 obj-$(CONFIG_MOST_USB_HDM) += most_usb.o
 obj-$(CONFIG_MOST_CDEV) += most_cdev.o
+obj-$(CONFIG_MOST_SND) += most_snd.o
diff --git a/drivers/most/most_snd.c b/drivers/most/most_snd.c
new file mode 100644 (file)
index 0000000..c87f6a0
--- /dev/null
@@ -0,0 +1,745 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * sound.c - Sound component for Mostcore
+ *
+ * Copyright (C) 2015 Microchip Technology Germany II GmbH & Co. KG
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/module.h>
+#include <linux/printk.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/init.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <linux/sched.h>
+#include <linux/kthread.h>
+#include <linux/most.h>
+
+#define DRIVER_NAME "sound"
+#define STRING_SIZE    80
+
+static struct most_component comp;
+
+/**
+ * struct channel - private structure to keep channel specific data
+ * @substream: stores the substream structure
+ * @iface: interface for which the channel belongs to
+ * @cfg: channel configuration
+ * @card: registered sound card
+ * @list: list for private use
+ * @id: channel index
+ * @period_pos: current period position (ring buffer)
+ * @buffer_pos: current buffer position (ring buffer)
+ * @is_stream_running: identifies whether a stream is running or not
+ * @opened: set when the stream is opened
+ * @playback_task: playback thread
+ * @playback_waitq: waitq used by playback thread
+ */
+struct channel {
+       struct snd_pcm_substream *substream;
+       struct snd_pcm_hardware pcm_hardware;
+       struct most_interface *iface;
+       struct most_channel_config *cfg;
+       struct snd_card *card;
+       struct list_head list;
+       int id;
+       unsigned int period_pos;
+       unsigned int buffer_pos;
+       bool is_stream_running;
+       struct task_struct *playback_task;
+       wait_queue_head_t playback_waitq;
+       void (*copy_fn)(void *alsa, void *most, unsigned int bytes);
+};
+
+struct sound_adapter {
+       struct list_head dev_list;
+       struct most_interface *iface;
+       struct snd_card *card;
+       struct list_head list;
+       bool registered;
+       int pcm_dev_idx;
+};
+
+static struct list_head adpt_list;
+
+#define MOST_PCM_INFO (SNDRV_PCM_INFO_MMAP | \
+                      SNDRV_PCM_INFO_MMAP_VALID | \
+                      SNDRV_PCM_INFO_BATCH | \
+                      SNDRV_PCM_INFO_INTERLEAVED | \
+                      SNDRV_PCM_INFO_BLOCK_TRANSFER)
+
+static void swap_copy16(u16 *dest, const u16 *source, unsigned int bytes)
+{
+       unsigned int i = 0;
+
+       while (i < (bytes / 2)) {
+               dest[i] = swab16(source[i]);
+               i++;
+       }
+}
+
+static void swap_copy24(u8 *dest, const u8 *source, unsigned int bytes)
+{
+       unsigned int i = 0;
+
+       if (bytes < 2)
+               return;
+       while (i < bytes - 2) {
+               dest[i] = source[i + 2];
+               dest[i + 1] = source[i + 1];
+               dest[i + 2] = source[i];
+               i += 3;
+       }
+}
+
+static void swap_copy32(u32 *dest, const u32 *source, unsigned int bytes)
+{
+       unsigned int i = 0;
+
+       while (i < bytes / 4) {
+               dest[i] = swab32(source[i]);
+               i++;
+       }
+}
+
+static void alsa_to_most_memcpy(void *alsa, void *most, unsigned int bytes)
+{
+       memcpy(most, alsa, bytes);
+}
+
+static void alsa_to_most_copy16(void *alsa, void *most, unsigned int bytes)
+{
+       swap_copy16(most, alsa, bytes);
+}
+
+static void alsa_to_most_copy24(void *alsa, void *most, unsigned int bytes)
+{
+       swap_copy24(most, alsa, bytes);
+}
+
+static void alsa_to_most_copy32(void *alsa, void *most, unsigned int bytes)
+{
+       swap_copy32(most, alsa, bytes);
+}
+
+static void most_to_alsa_memcpy(void *alsa, void *most, unsigned int bytes)
+{
+       memcpy(alsa, most, bytes);
+}
+
+static void most_to_alsa_copy16(void *alsa, void *most, unsigned int bytes)
+{
+       swap_copy16(alsa, most, bytes);
+}
+
+static void most_to_alsa_copy24(void *alsa, void *most, unsigned int bytes)
+{
+       swap_copy24(alsa, most, bytes);
+}
+
+static void most_to_alsa_copy32(void *alsa, void *most, unsigned int bytes)
+{
+       swap_copy32(alsa, most, bytes);
+}
+
+/**
+ * get_channel - get pointer to channel
+ * @iface: interface structure
+ * @channel_id: channel ID
+ *
+ * This traverses the channel list and returns the channel matching the
+ * ID and interface.
+ *
+ * Returns pointer to channel on success or NULL otherwise.
+ */
+static struct channel *get_channel(struct most_interface *iface,
+                                  int channel_id)
+{
+       struct sound_adapter *adpt = iface->priv;
+       struct channel *channel;
+
+       list_for_each_entry(channel, &adpt->dev_list, list) {
+               if ((channel->iface == iface) && (channel->id == channel_id))
+                       return channel;
+       }
+       return NULL;
+}
+
+/**
+ * copy_data - implements data copying function
+ * @channel: channel
+ * @mbo: MBO from core
+ *
+ * Copy data from/to ring buffer to/from MBO and update the buffer position
+ */
+static bool copy_data(struct channel *channel, struct mbo *mbo)
+{
+       struct snd_pcm_runtime *const runtime = channel->substream->runtime;
+       unsigned int const frame_bytes = channel->cfg->subbuffer_size;
+       unsigned int const buffer_size = runtime->buffer_size;
+       unsigned int frames;
+       unsigned int fr0;
+
+       if (channel->cfg->direction & MOST_CH_RX)
+               frames = mbo->processed_length / frame_bytes;
+       else
+               frames = mbo->buffer_length / frame_bytes;
+       fr0 = min(buffer_size - channel->buffer_pos, frames);
+
+       channel->copy_fn(runtime->dma_area + channel->buffer_pos * frame_bytes,
+                        mbo->virt_address,
+                        fr0 * frame_bytes);
+
+       if (frames > fr0) {
+               /* wrap around at end of ring buffer */
+               channel->copy_fn(runtime->dma_area,
+                                mbo->virt_address + fr0 * frame_bytes,
+                                (frames - fr0) * frame_bytes);
+       }
+
+       channel->buffer_pos += frames;
+       if (channel->buffer_pos >= buffer_size)
+               channel->buffer_pos -= buffer_size;
+       channel->period_pos += frames;
+       if (channel->period_pos >= runtime->period_size) {
+               channel->period_pos -= runtime->period_size;
+               return true;
+       }
+       return false;
+}
+
+/**
+ * playback_thread - function implements the playback thread
+ * @data: private data
+ *
+ * Thread which does the playback functionality in a loop. It waits for a free
+ * MBO from mostcore for a particular channel and copy the data from ring buffer
+ * to MBO. Submit the MBO back to mostcore, after copying the data.
+ *
+ * Returns 0 on success or error code otherwise.
+ */
+static int playback_thread(void *data)
+{
+       struct channel *const channel = data;
+
+       while (!kthread_should_stop()) {
+               struct mbo *mbo = NULL;
+               bool period_elapsed = false;
+
+               wait_event_interruptible(
+                       channel->playback_waitq,
+                       kthread_should_stop() ||
+                       (channel->is_stream_running &&
+                        (mbo = most_get_mbo(channel->iface, channel->id,
+                                            &comp))));
+               if (!mbo)
+                       continue;
+
+               if (channel->is_stream_running)
+                       period_elapsed = copy_data(channel, mbo);
+               else
+                       memset(mbo->virt_address, 0, mbo->buffer_length);
+
+               most_submit_mbo(mbo);
+               if (period_elapsed)
+                       snd_pcm_period_elapsed(channel->substream);
+       }
+       return 0;
+}
+
+/**
+ * pcm_open - implements open callback function for PCM middle layer
+ * @substream: pointer to ALSA PCM substream
+ *
+ * This is called when a PCM substream is opened. At least, the function should
+ * initialize the runtime->hw record.
+ *
+ * Returns 0 on success or error code otherwise.
+ */
+static int pcm_open(struct snd_pcm_substream *substream)
+{
+       struct channel *channel = substream->private_data;
+       struct snd_pcm_runtime *runtime = substream->runtime;
+       struct most_channel_config *cfg = channel->cfg;
+       int ret;
+
+       channel->substream = substream;
+
+       if (cfg->direction == MOST_CH_TX) {
+               channel->playback_task = kthread_run(playback_thread, channel,
+                                                    "most_audio_playback");
+               if (IS_ERR(channel->playback_task)) {
+                       pr_err("Couldn't start thread\n");
+                       return PTR_ERR(channel->playback_task);
+               }
+       }
+
+       ret = most_start_channel(channel->iface, channel->id, &comp);
+       if (ret) {
+               pr_err("most_start_channel() failed!\n");
+               if (cfg->direction == MOST_CH_TX)
+                       kthread_stop(channel->playback_task);
+               return ret;
+       }
+
+       runtime->hw = channel->pcm_hardware;
+       return 0;
+}
+
+/**
+ * pcm_close - implements close callback function for PCM middle layer
+ * @substream: sub-stream pointer
+ *
+ * Obviously, this is called when a PCM substream is closed. Any private
+ * instance for a PCM substream allocated in the open callback will be
+ * released here.
+ *
+ * Returns 0 on success or error code otherwise.
+ */
+static int pcm_close(struct snd_pcm_substream *substream)
+{
+       struct channel *channel = substream->private_data;
+
+       if (channel->cfg->direction == MOST_CH_TX)
+               kthread_stop(channel->playback_task);
+       most_stop_channel(channel->iface, channel->id, &comp);
+       return 0;
+}
+
+/**
+ * pcm_prepare - implements prepare callback function for PCM middle layer
+ * @substream: substream pointer
+ *
+ * This callback is called when the PCM is "prepared". Format rate, sample rate,
+ * etc., can be set here. This callback can be called many times at each setup.
+ *
+ * Returns 0 on success or error code otherwise.
+ */
+static int pcm_prepare(struct snd_pcm_substream *substream)
+{
+       struct channel *channel = substream->private_data;
+       struct snd_pcm_runtime *runtime = substream->runtime;
+       struct most_channel_config *cfg = channel->cfg;
+       int width = snd_pcm_format_physical_width(runtime->format);
+
+       channel->copy_fn = NULL;
+
+       if (cfg->direction == MOST_CH_TX) {
+               if (snd_pcm_format_big_endian(runtime->format) || width == 8)
+                       channel->copy_fn = alsa_to_most_memcpy;
+               else if (width == 16)
+                       channel->copy_fn = alsa_to_most_copy16;
+               else if (width == 24)
+                       channel->copy_fn = alsa_to_most_copy24;
+               else if (width == 32)
+                       channel->copy_fn = alsa_to_most_copy32;
+       } else {
+               if (snd_pcm_format_big_endian(runtime->format) || width == 8)
+                       channel->copy_fn = most_to_alsa_memcpy;
+               else if (width == 16)
+                       channel->copy_fn = most_to_alsa_copy16;
+               else if (width == 24)
+                       channel->copy_fn = most_to_alsa_copy24;
+               else if (width == 32)
+                       channel->copy_fn = most_to_alsa_copy32;
+       }
+
+       if (!channel->copy_fn)
+               return -EINVAL;
+       channel->period_pos = 0;
+       channel->buffer_pos = 0;
+       return 0;
+}
+
+/**
+ * pcm_trigger - implements trigger callback function for PCM middle layer
+ * @substream: substream pointer
+ * @cmd: action to perform
+ *
+ * This is called when the PCM is started, stopped or paused. The action will be
+ * specified in the second argument, SNDRV_PCM_TRIGGER_XXX
+ *
+ * Returns 0 on success or error code otherwise.
+ */
+static int pcm_trigger(struct snd_pcm_substream *substream, int cmd)
+{
+       struct channel *channel = substream->private_data;
+
+       switch (cmd) {
+       case SNDRV_PCM_TRIGGER_START:
+               channel->is_stream_running = true;
+               wake_up_interruptible(&channel->playback_waitq);
+               return 0;
+
+       case SNDRV_PCM_TRIGGER_STOP:
+               channel->is_stream_running = false;
+               return 0;
+
+       default:
+               return -EINVAL;
+       }
+       return 0;
+}
+
+/**
+ * pcm_pointer - implements pointer callback function for PCM middle layer
+ * @substream: substream pointer
+ *
+ * This callback is called when the PCM middle layer inquires the current
+ * hardware position on the buffer. The position must be returned in frames,
+ * ranging from 0 to buffer_size-1.
+ */
+static snd_pcm_uframes_t pcm_pointer(struct snd_pcm_substream *substream)
+{
+       struct channel *channel = substream->private_data;
+
+       return channel->buffer_pos;
+}
+
+/**
+ * Initialization of struct snd_pcm_ops
+ */
+static const struct snd_pcm_ops pcm_ops = {
+       .open       = pcm_open,
+       .close      = pcm_close,
+       .prepare    = pcm_prepare,
+       .trigger    = pcm_trigger,
+       .pointer    = pcm_pointer,
+};
+
+static int split_arg_list(char *buf, u16 *ch_num, char **sample_res)
+{
+       char *num;
+       int ret;
+
+       num = strsep(&buf, "x");
+       if (!num)
+               goto err;
+       ret = kstrtou16(num, 0, ch_num);
+       if (ret)
+               goto err;
+       *sample_res = strsep(&buf, ".\n");
+       if (!*sample_res)
+               goto err;
+       return 0;
+
+err:
+       pr_err("Bad PCM format\n");
+       return -EINVAL;
+}
+
+static const struct sample_resolution_info {
+       const char *sample_res;
+       int bytes;
+       u64 formats;
+} sinfo[] = {
+       { "8", 1, SNDRV_PCM_FMTBIT_S8 },
+       { "16", 2, SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE },
+       { "24", 3, SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_3BE },
+       { "32", 4, SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE },
+};
+
+static int audio_set_hw_params(struct snd_pcm_hardware *pcm_hw,
+                              u16 ch_num, char *sample_res,
+                              struct most_channel_config *cfg)
+{
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(sinfo); i++) {
+               if (!strcmp(sample_res, sinfo[i].sample_res))
+                       goto found;
+       }
+       pr_err("Unsupported PCM format\n");
+       return -EINVAL;
+
+found:
+       if (!ch_num) {
+               pr_err("Bad number of channels\n");
+               return -EINVAL;
+       }
+
+       if (cfg->subbuffer_size != ch_num * sinfo[i].bytes) {
+               pr_err("Audio resolution doesn't fit subbuffer size\n");
+               return -EINVAL;
+       }
+
+       pcm_hw->info = MOST_PCM_INFO;
+       pcm_hw->rates = SNDRV_PCM_RATE_48000;
+       pcm_hw->rate_min = 48000;
+       pcm_hw->rate_max = 48000;
+       pcm_hw->buffer_bytes_max = cfg->num_buffers * cfg->buffer_size;
+       pcm_hw->period_bytes_min = cfg->buffer_size;
+       pcm_hw->period_bytes_max = cfg->buffer_size;
+       pcm_hw->periods_min = 1;
+       pcm_hw->periods_max = cfg->num_buffers;
+       pcm_hw->channels_min = ch_num;
+       pcm_hw->channels_max = ch_num;
+       pcm_hw->formats = sinfo[i].formats;
+       return 0;
+}
+
+static void release_adapter(struct sound_adapter *adpt)
+{
+       struct channel *channel, *tmp;
+
+       list_for_each_entry_safe(channel, tmp, &adpt->dev_list, list) {
+               list_del(&channel->list);
+               kfree(channel);
+       }
+       if (adpt->card)
+               snd_card_free(adpt->card);
+       list_del(&adpt->list);
+       kfree(adpt);
+}
+
+/**
+ * audio_probe_channel - probe function of the driver module
+ * @iface: pointer to interface instance
+ * @channel_id: channel index/ID
+ * @cfg: pointer to actual channel configuration
+ * @arg_list: string that provides the name of the device to be created in /dev
+ *           plus the desired audio resolution
+ *
+ * Creates sound card, pcm device, sets pcm ops and registers sound card.
+ *
+ * Returns 0 on success or error code otherwise.
+ */
+static int audio_probe_channel(struct most_interface *iface, int channel_id,
+                              struct most_channel_config *cfg,
+                              char *device_name, char *arg_list)
+{
+       struct channel *channel;
+       struct sound_adapter *adpt;
+       struct snd_pcm *pcm;
+       int playback_count = 0;
+       int capture_count = 0;
+       int ret;
+       int direction;
+       u16 ch_num;
+       char *sample_res;
+       char arg_list_cpy[STRING_SIZE];
+
+       if (cfg->data_type != MOST_CH_SYNC) {
+               pr_err("Incompatible channel type\n");
+               return -EINVAL;
+       }
+       strscpy(arg_list_cpy, arg_list, STRING_SIZE);
+       ret = split_arg_list(arg_list_cpy, &ch_num, &sample_res);
+       if (ret < 0)
+               return ret;
+
+       list_for_each_entry(adpt, &adpt_list, list) {
+               if (adpt->iface != iface)
+                       continue;
+               if (adpt->registered)
+                       return -ENOSPC;
+               adpt->pcm_dev_idx++;
+               goto skip_adpt_alloc;
+       }
+       adpt = kzalloc(sizeof(*adpt), GFP_KERNEL);
+       if (!adpt)
+               return -ENOMEM;
+
+       adpt->iface = iface;
+       INIT_LIST_HEAD(&adpt->dev_list);
+       iface->priv = adpt;
+       list_add_tail(&adpt->list, &adpt_list);
+       ret = snd_card_new(iface->driver_dev, -1, "INIC", THIS_MODULE,
+                          sizeof(*channel), &adpt->card);
+       if (ret < 0)
+               goto err_free_adpt;
+       snprintf(adpt->card->driver, sizeof(adpt->card->driver),
+                "%s", DRIVER_NAME);
+       snprintf(adpt->card->shortname, sizeof(adpt->card->shortname),
+                "Microchip INIC");
+       snprintf(adpt->card->longname, sizeof(adpt->card->longname),
+                "%s at %s", adpt->card->shortname, iface->description);
+skip_adpt_alloc:
+       if (get_channel(iface, channel_id)) {
+               pr_err("channel (%s:%d) is already linked\n",
+                      iface->description, channel_id);
+               return -EEXIST;
+       }
+
+       if (cfg->direction == MOST_CH_TX) {
+               playback_count = 1;
+               direction = SNDRV_PCM_STREAM_PLAYBACK;
+       } else {
+               capture_count = 1;
+               direction = SNDRV_PCM_STREAM_CAPTURE;
+       }
+       channel = kzalloc(sizeof(*channel), GFP_KERNEL);
+       if (!channel) {
+               ret = -ENOMEM;
+               goto err_free_adpt;
+       }
+       channel->card = adpt->card;
+       channel->cfg = cfg;
+       channel->iface = iface;
+       channel->id = channel_id;
+       init_waitqueue_head(&channel->playback_waitq);
+       list_add_tail(&channel->list, &adpt->dev_list);
+
+       ret = audio_set_hw_params(&channel->pcm_hardware, ch_num, sample_res,
+                                 cfg);
+       if (ret)
+               goto err_free_adpt;
+
+       ret = snd_pcm_new(adpt->card, device_name, adpt->pcm_dev_idx,
+                         playback_count, capture_count, &pcm);
+
+       if (ret < 0)
+               goto err_free_adpt;
+
+       pcm->private_data = channel;
+       strscpy(pcm->name, device_name, sizeof(pcm->name));
+       snd_pcm_set_ops(pcm, direction, &pcm_ops);
+       snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
+       return 0;
+
+err_free_adpt:
+       release_adapter(adpt);
+       return ret;
+}
+
+static int audio_create_sound_card(void)
+{
+       int ret;
+       struct sound_adapter *adpt;
+
+       list_for_each_entry(adpt, &adpt_list, list) {
+               if (!adpt->registered)
+                       goto adpt_alloc;
+       }
+       return -ENODEV;
+adpt_alloc:
+       ret = snd_card_register(adpt->card);
+       if (ret < 0) {
+               release_adapter(adpt);
+               return ret;
+       }
+       adpt->registered = true;
+       return 0;
+}
+
+/**
+ * audio_disconnect_channel - function to disconnect a channel
+ * @iface: pointer to interface instance
+ * @channel_id: channel index
+ *
+ * This frees allocated memory and removes the sound card from ALSA
+ *
+ * Returns 0 on success or error code otherwise.
+ */
+static int audio_disconnect_channel(struct most_interface *iface,
+                                   int channel_id)
+{
+       struct channel *channel;
+       struct sound_adapter *adpt = iface->priv;
+
+       channel = get_channel(iface, channel_id);
+       if (!channel)
+               return -EINVAL;
+
+       list_del(&channel->list);
+
+       kfree(channel);
+       if (list_empty(&adpt->dev_list))
+               release_adapter(adpt);
+       return 0;
+}
+
+/**
+ * audio_rx_completion - completion handler for rx channels
+ * @mbo: pointer to buffer object that has completed
+ *
+ * This searches for the channel this MBO belongs to and copy the data from MBO
+ * to ring buffer
+ *
+ * Returns 0 on success or error code otherwise.
+ */
+static int audio_rx_completion(struct mbo *mbo)
+{
+       struct channel *channel = get_channel(mbo->ifp, mbo->hdm_channel_id);
+       bool period_elapsed = false;
+
+       if (!channel)
+               return -EINVAL;
+       if (channel->is_stream_running)
+               period_elapsed = copy_data(channel, mbo);
+       most_put_mbo(mbo);
+       if (period_elapsed)
+               snd_pcm_period_elapsed(channel->substream);
+       return 0;
+}
+
+/**
+ * audio_tx_completion - completion handler for tx channels
+ * @iface: pointer to interface instance
+ * @channel_id: channel index/ID
+ *
+ * This searches the channel that belongs to this combination of interface
+ * pointer and channel ID and wakes a process sitting in the wait queue of
+ * this channel.
+ *
+ * Returns 0 on success or error code otherwise.
+ */
+static int audio_tx_completion(struct most_interface *iface, int channel_id)
+{
+       struct channel *channel = get_channel(iface, channel_id);
+
+       if (!channel)
+               return -EINVAL;
+
+       wake_up_interruptible(&channel->playback_waitq);
+       return 0;
+}
+
+/**
+ * Initialization of the struct most_component
+ */
+static struct most_component comp = {
+       .mod = THIS_MODULE,
+       .name = DRIVER_NAME,
+       .probe_channel = audio_probe_channel,
+       .disconnect_channel = audio_disconnect_channel,
+       .rx_completion = audio_rx_completion,
+       .tx_completion = audio_tx_completion,
+       .cfg_complete = audio_create_sound_card,
+};
+
+static int __init audio_init(void)
+{
+       int ret;
+
+       INIT_LIST_HEAD(&adpt_list);
+
+       ret = most_register_component(&comp);
+       if (ret) {
+               pr_err("Failed to register %s\n", comp.name);
+               return ret;
+       }
+       ret = most_register_configfs_subsys(&comp);
+       if (ret) {
+               pr_err("Failed to register %s configfs subsys\n", comp.name);
+               most_deregister_component(&comp);
+       }
+       return ret;
+}
+
+static void __exit audio_exit(void)
+{
+       most_deregister_configfs_subsys(&comp);
+       most_deregister_component(&comp);
+}
+
+module_init(audio_init);
+module_exit(audio_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Christian Gromm <christian.gromm@microchip.com>");
+MODULE_DESCRIPTION("Sound Component Module for Mostcore");
index eb72582932564d3a62edda5091736986b884daf0..f9cfb084c029187fd8a50e25f1bfd5271765f91f 100644 (file)
@@ -32,7 +32,6 @@
 
 MODULE_AUTHOR("Eric Brower <ebrower@usa.net>");
 MODULE_DESCRIPTION("User-programmable flash device on Sun Microsystems boardsets");
-MODULE_SUPPORTED_DEVICE(DRIVER_NAME);
 MODULE_LICENSE("GPL");
 MODULE_VERSION("2.1");
 
index b09bed554f266c42884ce0152be22d9186b0c65d..bcd31f458d1acd76d9c79b1c5b84a76b457d3eb2 100644 (file)
@@ -94,7 +94,7 @@ config WIREGUARD
        select CRYPTO_BLAKE2S_ARM if ARM
        select CRYPTO_CURVE25519_NEON if ARM && KERNEL_MODE_NEON
        select CRYPTO_CHACHA_MIPS if CPU_MIPS32_R2
-       select CRYPTO_POLY1305_MIPS if CPU_MIPS32 || (CPU_MIPS64 && 64BIT)
+       select CRYPTO_POLY1305_MIPS if MIPS
        help
          WireGuard is a secure, fast, and easy to use replacement for IPSec
          that uses modern cryptography and clever networking tricks. It's
index 74cbbb22470b5ec22015bf5c7563a22edda0e1d3..456315bef3a8b7084960ab2e87a79cd09066b48b 100644 (file)
@@ -3978,11 +3978,15 @@ static int bond_neigh_init(struct neighbour *n)
 
        rcu_read_lock();
        slave = bond_first_slave_rcu(bond);
-       if (!slave)
+       if (!slave) {
+               ret = -EINVAL;
                goto out;
+       }
        slave_ops = slave->dev->netdev_ops;
-       if (!slave_ops->ndo_neigh_setup)
+       if (!slave_ops->ndo_neigh_setup) {
+               ret = -EINVAL;
                goto out;
+       }
 
        /* TODO: find another way [1] to implement this.
         * Passing a zeroed structure is fragile,
index 971ada36e37fa7987a101f74a6d4cfdf8957b7d1..134c05757a3bb19d2eeae17abe7d9232bc28743b 100644 (file)
@@ -701,7 +701,7 @@ static int flexcan_chip_freeze(struct flexcan_priv *priv)
        u32 reg;
 
        reg = priv->read(&regs->mcr);
-       reg |= FLEXCAN_MCR_HALT;
+       reg |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_HALT;
        priv->write(reg, &regs->mcr);
 
        while (timeout-- && !(priv->read(&regs->mcr) & FLEXCAN_MCR_FRZ_ACK))
@@ -1480,10 +1480,13 @@ static int flexcan_chip_start(struct net_device *dev)
 
        flexcan_set_bittiming(dev);
 
+       /* set freeze, halt */
+       err = flexcan_chip_freeze(priv);
+       if (err)
+               goto out_chip_disable;
+
        /* MCR
         *
-        * enable freeze
-        * halt now
         * only supervisor access
         * enable warning int
         * enable individual RX masking
@@ -1492,9 +1495,8 @@ static int flexcan_chip_start(struct net_device *dev)
         */
        reg_mcr = priv->read(&regs->mcr);
        reg_mcr &= ~FLEXCAN_MCR_MAXMB(0xff);
-       reg_mcr |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_HALT | FLEXCAN_MCR_SUPV |
-               FLEXCAN_MCR_WRN_EN | FLEXCAN_MCR_IRMQ | FLEXCAN_MCR_IDAM_C |
-               FLEXCAN_MCR_MAXMB(priv->tx_mb_idx);
+       reg_mcr |= FLEXCAN_MCR_SUPV | FLEXCAN_MCR_WRN_EN | FLEXCAN_MCR_IRMQ |
+               FLEXCAN_MCR_IDAM_C | FLEXCAN_MCR_MAXMB(priv->tx_mb_idx);
 
        /* MCR
         *
@@ -1865,10 +1867,14 @@ static int register_flexcandev(struct net_device *dev)
        if (err)
                goto out_chip_disable;
 
-       /* set freeze, halt and activate FIFO, restrict register access */
+       /* set freeze, halt */
+       err = flexcan_chip_freeze(priv);
+       if (err)
+               goto out_chip_disable;
+
+       /* activate FIFO, restrict register access */
        reg = priv->read(&regs->mcr);
-       reg |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_HALT |
-               FLEXCAN_MCR_FEN | FLEXCAN_MCR_SUPV;
+       reg |=  FLEXCAN_MCR_FEN | FLEXCAN_MCR_SUPV;
        priv->write(reg, &regs->mcr);
 
        /* Currently we only support newer versions of this core
index b7caec769ddb9b569c8376457cd3922337c1bf80..4147cecfbbd6dbd8e2207de82b728eed7dd2625d 100644 (file)
@@ -237,14 +237,14 @@ static int tcan4x5x_init(struct m_can_classdev *cdev)
        if (ret)
                return ret;
 
+       /* Zero out the MCAN buffers */
+       m_can_init_ram(cdev);
+
        ret = regmap_update_bits(tcan4x5x->regmap, TCAN4X5X_CONFIG,
                                 TCAN4X5X_MODE_SEL_MASK, TCAN4X5X_MODE_NORMAL);
        if (ret)
                return ret;
 
-       /* Zero out the MCAN buffers */
-       m_can_init_ram(cdev);
-
        return ret;
 }
 
index 0df1cdfa683577059f73e36af2142ac40c6586f1..1df3c4b54f03c37185cedadfab9b59c9297b5dbe 100644 (file)
@@ -21,7 +21,6 @@
 
 MODULE_AUTHOR("Stephane Grosjean <s.grosjean@peak-system.com>");
 MODULE_DESCRIPTION("Socket-CAN driver for PEAK PCAN PCIe/M.2 FD family cards");
-MODULE_SUPPORTED_DEVICE("PEAK PCAN PCIe/M.2 FD CAN cards");
 MODULE_LICENSE("GPL v2");
 
 #define PCIEFD_DRV_NAME                "peak_pciefd"
index 6f88c993292010eb0740d9cd6d8d03f0a3829a78..4ab91759a5c64d8607dc6b6e14c6ec3ef55b6fd1 100644 (file)
@@ -21,7 +21,6 @@
 
 MODULE_AUTHOR("Sebastian Haas <haas@ems-wuenche.com>");
 MODULE_DESCRIPTION("Socket-CAN driver for EMS CPC-PCI/PCIe/104P CAN cards");
-MODULE_SUPPORTED_DEVICE("EMS CPC-PCI/PCIe/104P CAN card");
 MODULE_LICENSE("GPL v2");
 
 #define EMS_PCI_V1_MAX_CHAN 2
index 770304eaef950386f0754c7f35854bf94005001f..e21b169c14c0122d9038fdd967dfc15cedde7da3 100644 (file)
@@ -21,7 +21,6 @@
 
 MODULE_AUTHOR("Markus Plessing <plessing@ems-wuensche.com>");
 MODULE_DESCRIPTION("Socket-CAN driver for EMS CPC-CARD cards");
-MODULE_SUPPORTED_DEVICE("EMS CPC-CARD CAN card");
 MODULE_LICENSE("GPL v2");
 
 #define EMS_PCMCIA_MAX_CHAN 2
index 0ea6b711c07befbd107ad85fb14ecb209b0c5d24..95fe9ee1ce32666428fe5d921a341bbfb58e46c3 100644 (file)
@@ -33,7 +33,6 @@
 
 MODULE_AUTHOR("Per Dalen <per.dalen@cnw.se>");
 MODULE_DESCRIPTION("Socket-CAN driver for KVASER PCAN PCI cards");
-MODULE_SUPPORTED_DEVICE("KVASER PCAN PCI CAN card");
 MODULE_LICENSE("GPL v2");
 
 #define MAX_NO_OF_CHANNELS        4 /* max no of channels on a single card */
index 4713921bd511e6b92ff707842a1d5b9e9acfce3f..84eac8cb86869a599d00d25dfe6021b286fa3d67 100644 (file)
@@ -24,8 +24,6 @@
 
 MODULE_AUTHOR("Stephane Grosjean <s.grosjean@peak-system.com>");
 MODULE_DESCRIPTION("Socket-CAN driver for PEAK PCAN PCI family cards");
-MODULE_SUPPORTED_DEVICE("PEAK PCAN PCI/PCIe/PCIeC miniPCI CAN cards");
-MODULE_SUPPORTED_DEVICE("PEAK PCAN miniPCIe/cPCI PC/104+ PCI/104e CAN Cards");
 MODULE_LICENSE("GPL v2");
 
 #define DRV_NAME  "peak_pci"
index cf951a78307813c689d96fd6e2d604981d6d0025..131a084c35351e921ed0d835e33a67f7373974d3 100644 (file)
@@ -22,7 +22,6 @@
 MODULE_AUTHOR("Stephane Grosjean <s.grosjean@peak-system.com>");
 MODULE_DESCRIPTION("CAN driver for PEAK-System PCAN-PC Cards");
 MODULE_LICENSE("GPL v2");
-MODULE_SUPPORTED_DEVICE("PEAK PCAN-PC Card");
 
 /* PEAK-System PCMCIA driver name */
 #define PCC_NAME               "peak_pcmcia"
index 85679588ef73029199d2c1ad99aa973f8f625e74..5de1ebb0c6f04c09713ca23c5a679f1f66673c2f 100644 (file)
 MODULE_AUTHOR("Pavel Cheblakov <P.B.Cheblakov@inp.nsk.su>");
 MODULE_DESCRIPTION("Socket-CAN driver for PLX90xx PCI-bridge cards with "
                   "the SJA1000 chips");
-MODULE_SUPPORTED_DEVICE("Adlink PCI-7841/cPCI-7841, "
-                       "Adlink PCI-7841/cPCI-7841 SE, "
-                       "Marathon CAN-bus-PCI, "
-                       "Marathon CAN-bus-PCIe, "
-                       "TEWS TECHNOLOGIES TPMC810, "
-                       "esd CAN-PCI/CPCI/PCI104/200, "
-                       "esd CAN-PCI/PMC/266, "
-                       "esd CAN-PCIe/2000, "
-                       "Connect Tech Inc. CANpro/104-Plus Opto (CRG001), "
-                       "IXXAT PC-I 04/PCI, "
-                       "ELCUS CAN-200-PCI, "
-                       "ASEM DUAL CAN-RAW")
 MODULE_LICENSE("GPL v2");
 
 #define PLX_PCI_MAX_CHAN 2
index 3c5b92911d469302d5ed864df47e58143e5c5be7..799e9d5d348133edaa806772498067545b752da3 100644 (file)
@@ -335,8 +335,6 @@ static void mcp251xfd_ring_init(struct mcp251xfd_priv *priv)
        u8 len;
        int i, j;
 
-       netdev_reset_queue(priv->ndev);
-
        /* TEF */
        tef_ring = priv->tef;
        tef_ring->head = 0;
@@ -1249,8 +1247,7 @@ mcp251xfd_handle_tefif_recover(const struct mcp251xfd_priv *priv, const u32 seq)
 
 static int
 mcp251xfd_handle_tefif_one(struct mcp251xfd_priv *priv,
-                          const struct mcp251xfd_hw_tef_obj *hw_tef_obj,
-                          unsigned int *frame_len_ptr)
+                          const struct mcp251xfd_hw_tef_obj *hw_tef_obj)
 {
        struct net_device_stats *stats = &priv->ndev->stats;
        u32 seq, seq_masked, tef_tail_masked;
@@ -1272,8 +1269,7 @@ mcp251xfd_handle_tefif_one(struct mcp251xfd_priv *priv,
        stats->tx_bytes +=
                can_rx_offload_get_echo_skb(&priv->offload,
                                            mcp251xfd_get_tef_tail(priv),
-                                           hw_tef_obj->ts,
-                                           frame_len_ptr);
+                                           hw_tef_obj->ts, NULL);
        stats->tx_packets++;
        priv->tef->tail++;
 
@@ -1331,7 +1327,6 @@ mcp251xfd_tef_obj_read(const struct mcp251xfd_priv *priv,
 static int mcp251xfd_handle_tefif(struct mcp251xfd_priv *priv)
 {
        struct mcp251xfd_hw_tef_obj hw_tef_obj[MCP251XFD_TX_OBJ_NUM_MAX];
-       unsigned int total_frame_len = 0;
        u8 tef_tail, len, l;
        int err, i;
 
@@ -1353,9 +1348,7 @@ static int mcp251xfd_handle_tefif(struct mcp251xfd_priv *priv)
        }
 
        for (i = 0; i < len; i++) {
-               unsigned int frame_len;
-
-               err = mcp251xfd_handle_tefif_one(priv, &hw_tef_obj[i], &frame_len);
+               err = mcp251xfd_handle_tefif_one(priv, &hw_tef_obj[i]);
                /* -EAGAIN means the Sequence Number in the TEF
                 * doesn't match our tef_tail. This can happen if we
                 * read the TEF objects too early. Leave loop let the
@@ -1365,8 +1358,6 @@ static int mcp251xfd_handle_tefif(struct mcp251xfd_priv *priv)
                        goto out_netif_wake_queue;
                if (err)
                        return err;
-
-               total_frame_len += frame_len;
        }
 
  out_netif_wake_queue:
@@ -1397,7 +1388,6 @@ static int mcp251xfd_handle_tefif(struct mcp251xfd_priv *priv)
                        return err;
 
                tx_ring->tail += len;
-               netdev_completed_queue(priv->ndev, len, total_frame_len);
 
                err = mcp251xfd_check_tef_tail(priv);
                if (err)
@@ -2443,7 +2433,6 @@ static netdev_tx_t mcp251xfd_start_xmit(struct sk_buff *skb,
        struct mcp251xfd_priv *priv = netdev_priv(ndev);
        struct mcp251xfd_tx_ring *tx_ring = priv->tx;
        struct mcp251xfd_tx_obj *tx_obj;
-       unsigned int frame_len;
        u8 tx_head;
        int err;
 
@@ -2462,9 +2451,7 @@ static netdev_tx_t mcp251xfd_start_xmit(struct sk_buff *skb,
        if (mcp251xfd_get_tx_free(tx_ring) == 0)
                netif_stop_queue(ndev);
 
-       frame_len = can_skb_get_frame_len(skb);
-       can_put_echo_skb(skb, ndev, tx_head, frame_len);
-       netdev_sent_queue(priv->ndev, frame_len);
+       can_put_echo_skb(skb, ndev, tx_head, 0);
 
        err = mcp251xfd_tx_obj_write(priv, tx_obj);
        if (err)
index e6c1e5d33924e4f41107af145f16fcb717895c1c..e393e8457d773b257cd76f21e55e6efc2eeb8a43 100644 (file)
@@ -18,8 +18,6 @@
 
 #include "pcan_usb_core.h"
 
-MODULE_SUPPORTED_DEVICE("PEAK-System PCAN-USB adapter");
-
 /* PCAN-USB Endpoints */
 #define PCAN_USB_EP_CMDOUT             1
 #define PCAN_USB_EP_CMDIN              (PCAN_USB_EP_CMDOUT | USB_DIR_IN)
index f347ecc79aef2d5395ecc44167fbdb999eb4edef..bae078579c0d6ac8cd594d9a25e7bcf2ba07cedd 100644 (file)
@@ -16,9 +16,6 @@
 #include "pcan_usb_core.h"
 #include "pcan_usb_pro.h"
 
-MODULE_SUPPORTED_DEVICE("PEAK-System PCAN-USB FD adapter");
-MODULE_SUPPORTED_DEVICE("PEAK-System PCAN-USB Pro FD adapter");
-
 #define PCAN_USBPROFD_CHANNEL_COUNT    2
 #define PCAN_USBFD_CHANNEL_COUNT       1
 
index 275087c39602541a7626ac0e7115e350c6aea311..18fa180ecc81f5dd82d912419fc0e76f2643058e 100644 (file)
@@ -17,8 +17,6 @@
 #include "pcan_usb_core.h"
 #include "pcan_usb_pro.h"
 
-MODULE_SUPPORTED_DEVICE("PEAK-System PCAN-USB Pro adapter");
-
 #define PCAN_USBPRO_CHANNEL_COUNT      2
 
 /* PCAN-USB Pro adapter internal clock (MHz) */
index 5ee8103b8e9c7eb16d4cce068182a883429687dd..f277df922fcded6db853d155399e8354287ea299 100644 (file)
@@ -406,7 +406,7 @@ static int bcm_sf2_sw_rst(struct bcm_sf2_priv *priv)
        /* The watchdog reset does not work on 7278, we need to hit the
         * "external" reset line through the reset controller.
         */
-       if (priv->type == BCM7278_DEVICE_ID && !IS_ERR(priv->rcdev)) {
+       if (priv->type == BCM7278_DEVICE_ID) {
                ret = reset_control_assert(priv->rcdev);
                if (ret)
                        return ret;
@@ -1265,7 +1265,7 @@ static int bcm_sf2_sw_probe(struct platform_device *pdev)
 
        priv->rcdev = devm_reset_control_get_optional_exclusive(&pdev->dev,
                                                                "switch");
-       if (PTR_ERR(priv->rcdev) == -EPROBE_DEFER)
+       if (IS_ERR(priv->rcdev))
                return PTR_ERR(priv->rcdev);
 
        /* Auto-detection using standard registers will not work, so
@@ -1426,7 +1426,7 @@ static int bcm_sf2_sw_remove(struct platform_device *pdev)
        bcm_sf2_mdio_unregister(priv);
        clk_disable_unprepare(priv->clk_mdiv);
        clk_disable_unprepare(priv->clk);
-       if (priv->type == BCM7278_DEVICE_ID && !IS_ERR(priv->rcdev))
+       if (priv->type == BCM7278_DEVICE_ID)
                reset_control_assert(priv->rcdev);
 
        return 0;
index c17de2bcf2fef7233efc3f047ffb54c3ac71815d..f06f5fa2f898c115c4999cc793c8c91634f2acd0 100644 (file)
@@ -1624,6 +1624,7 @@ mtk_get_tag_protocol(struct dsa_switch *ds, int port,
        }
 }
 
+#ifdef CONFIG_GPIOLIB
 static inline u32
 mt7530_gpio_to_bit(unsigned int offset)
 {
@@ -1726,6 +1727,7 @@ mt7530_setup_gpio(struct mt7530_priv *priv)
 
        return devm_gpiochip_add_data(dev, gc, priv);
 }
+#endif /* CONFIG_GPIOLIB */
 
 static int
 mt7530_setup(struct dsa_switch *ds)
@@ -1868,11 +1870,13 @@ mt7530_setup(struct dsa_switch *ds)
                }
        }
 
+#ifdef CONFIG_GPIOLIB
        if (of_property_read_bool(priv->dev->of_node, "gpio-controller")) {
                ret = mt7530_setup_gpio(priv);
                if (ret)
                        return ret;
        }
+#endif /* CONFIG_GPIOLIB */
 
        mt7530_setup_port5(ds, interface);
 
index 7692338730df525cf7673192ac9bac4d0f40177e..51ea104c63bbbed55c160200fe29100013c20eaf 100644 (file)
@@ -1922,7 +1922,7 @@ out_unlock_ptp:
                                speed = SPEED_1000;
                        else if (bmcr & BMCR_SPEED100)
                                speed = SPEED_100;
-                       else if (bmcr & BMCR_SPEED10)
+                       else
                                speed = SPEED_10;
 
                        sja1105_sgmii_pcs_force_speed(priv, speed);
@@ -3369,14 +3369,14 @@ static int sja1105_port_ucast_bcast_flood(struct sja1105_private *priv, int to,
                if (flags.val & BR_FLOOD)
                        priv->ucast_egress_floods |= BIT(to);
                else
-                       priv->ucast_egress_floods |= BIT(to);
+                       priv->ucast_egress_floods &= ~BIT(to);
        }
 
        if (flags.mask & BR_BCAST_FLOOD) {
                if (flags.val & BR_BCAST_FLOOD)
                        priv->bcast_egress_floods |= BIT(to);
                else
-                       priv->bcast_egress_floods |= BIT(to);
+                       priv->bcast_egress_floods &= ~BIT(to);
        }
 
        return sja1105_manage_flood_domains(priv);
index f025f968f96da298772cc5716541900646c81c36..fde6e99274b60a43a7b9475d039fc3fdfdfe9e24 100644 (file)
@@ -528,7 +528,10 @@ static int xrs700x_hsr_join(struct dsa_switch *ds, int port,
                return -EOPNOTSUPP;
 
        dsa_hsr_foreach_port(dp, ds, hsr) {
-               partner = dp;
+               if (dp->index != port) {
+                       partner = dp;
+                       break;
+               }
        }
 
        /* We can't enable redundancy on the switch until both
@@ -582,7 +585,10 @@ static int xrs700x_hsr_leave(struct dsa_switch *ds, int port,
        unsigned int val;
 
        dsa_hsr_foreach_port(dp, ds, hsr) {
-               partner = dp;
+               if (dp->index != port) {
+                       partner = dp;
+                       break;
+               }
        }
 
        if (!partner)
index 9b7f1af5f574708caf5475f62212c72d12fe942e..9e02f886459312ce022d10ce7dabd110917588d1 100644 (file)
@@ -1894,13 +1894,16 @@ static int alx_resume(struct device *dev)
 
        if (!netif_running(alx->dev))
                return 0;
-       netif_device_attach(alx->dev);
 
        rtnl_lock();
        err = __alx_open(alx, true);
        rtnl_unlock();
+       if (err)
+               return err;
 
-       return err;
+       netif_device_attach(alx->dev);
+
+       return 0;
 }
 
 static SIMPLE_DEV_PM_OPS(alx_pm_ops, alx_suspend, alx_resume);
index 0b70e9e0ddad559d5d3c127682f1381ab94bf503..98cf82dea3e4a1cf67d6639d7a098f6a2f3ba16e 100644 (file)
@@ -592,6 +592,9 @@ static int bcm4908_enet_poll(struct napi_struct *napi, int weight)
                bcm4908_enet_intrs_on(enet);
        }
 
+       /* Hardware could disable ring if it run out of descriptors */
+       bcm4908_enet_dma_rx_ring_enable(enet, &enet->rx_ring);
+
        return handled;
 }
 
index a680fd9c68ea909c8e4a0618123010a615014907..b53a0d87371a204d43d037ab1a3e92bb89eb14cd 100644 (file)
@@ -8556,10 +8556,18 @@ static void bnxt_setup_inta(struct bnxt *bp)
        bp->irq_tbl[0].handler = bnxt_inta;
 }
 
+static int bnxt_init_int_mode(struct bnxt *bp);
+
 static int bnxt_setup_int_mode(struct bnxt *bp)
 {
        int rc;
 
+       if (!bp->irq_tbl) {
+               rc = bnxt_init_int_mode(bp);
+               if (rc || !bp->irq_tbl)
+                       return rc ?: -ENODEV;
+       }
+
        if (bp->flags & BNXT_FLAG_USING_MSIX)
                bnxt_setup_msix(bp);
        else
@@ -8744,7 +8752,7 @@ static int bnxt_init_inta(struct bnxt *bp)
 
 static int bnxt_init_int_mode(struct bnxt *bp)
 {
-       int rc = 0;
+       int rc = -ENODEV;
 
        if (bp->flags & BNXT_FLAG_MSIX_CAP)
                rc = bnxt_init_msix(bp);
@@ -9514,7 +9522,8 @@ static int bnxt_hwrm_if_change(struct bnxt *bp, bool up)
 {
        struct hwrm_func_drv_if_change_output *resp = bp->hwrm_cmd_resp_addr;
        struct hwrm_func_drv_if_change_input req = {0};
-       bool resc_reinit = false, fw_reset = false;
+       bool fw_reset = !bp->irq_tbl;
+       bool resc_reinit = false;
        int rc, retry = 0;
        u32 flags = 0;
 
@@ -9557,6 +9566,7 @@ static int bnxt_hwrm_if_change(struct bnxt *bp, bool up)
 
        if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state) && !fw_reset) {
                netdev_err(bp->dev, "RESET_DONE not set during FW reset.\n");
+               set_bit(BNXT_STATE_ABORT_ERR, &bp->state);
                return -ENODEV;
        }
        if (resc_reinit || fw_reset) {
@@ -9890,6 +9900,9 @@ static int bnxt_reinit_after_abort(struct bnxt *bp)
        if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state))
                return -EBUSY;
 
+       if (bp->dev->reg_state == NETREG_UNREGISTERED)
+               return -ENODEV;
+
        rc = bnxt_fw_init_one(bp);
        if (!rc) {
                bnxt_clear_int_mode(bp);
index 472bf8f220bc6234e0cbf480b143acf33fd3cc04..15362d016a87e1862b756b7f10e8506795029462 100644 (file)
@@ -3954,6 +3954,13 @@ static int macb_init(struct platform_device *pdev)
        return 0;
 }
 
+static const struct macb_usrio_config macb_default_usrio = {
+       .mii = MACB_BIT(MII),
+       .rmii = MACB_BIT(RMII),
+       .rgmii = GEM_BIT(RGMII),
+       .refclk = MACB_BIT(CLKEN),
+};
+
 #if defined(CONFIG_OF)
 /* 1518 rounded up */
 #define AT91ETHER_MAX_RBUFF_SZ 0x600
@@ -4439,13 +4446,6 @@ static int fu540_c000_init(struct platform_device *pdev)
        return macb_init(pdev);
 }
 
-static const struct macb_usrio_config macb_default_usrio = {
-       .mii = MACB_BIT(MII),
-       .rmii = MACB_BIT(RMII),
-       .rgmii = GEM_BIT(RGMII),
-       .refclk = MACB_BIT(CLKEN),
-};
-
 static const struct macb_usrio_config sama7g5_usrio = {
        .mii = 0,
        .rmii = 1,
@@ -4594,6 +4594,7 @@ static const struct macb_config default_gem_config = {
        .dma_burst_length = 16,
        .clk_init = macb_clk_init,
        .init = macb_init,
+       .usrio = &macb_default_usrio,
        .jumbo_max_len = 10240,
 };
 
index 46a809f2aeca22e09ac1fea3948720a9bfb554a5..169e10c913780659bcd6e3128815a996a3896e3f 100644 (file)
@@ -672,7 +672,7 @@ static int chcr_ktls_cpl_act_open_rpl(struct adapter *adap,
        if (tx_info->pending_close) {
                spin_unlock(&tx_info->lock);
                if (!status) {
-                       /* it's a late success, tcb status is establised,
+                       /* it's a late success, tcb status is established,
                         * mark it close.
                         */
                        chcr_ktls_mark_tcb_close(tx_info);
@@ -930,7 +930,7 @@ chcr_ktls_get_tx_flits(u32 nr_frags, unsigned int key_ctx_len)
 }
 
 /*
- * chcr_ktls_check_tcp_options: To check if there is any TCP option availbale
+ * chcr_ktls_check_tcp_options: To check if there is any TCP option available
  * other than timestamp.
  * @skb - skb contains partial record..
  * return: 1 / 0
@@ -1115,7 +1115,7 @@ static int chcr_ktls_xmit_wr_complete(struct sk_buff *skb,
        }
 
        if (unlikely(credits < ETHTXQ_STOP_THRES)) {
-               /* Credits are below the threshold vaues, stop the queue after
+               /* Credits are below the threshold values, stop the queue after
                 * injecting the Work Request for this packet.
                 */
                chcr_eth_txq_stop(q);
@@ -2006,7 +2006,7 @@ static int chcr_ktls_xmit(struct sk_buff *skb, struct net_device *dev)
 
        /* TCP segments can be in received either complete or partial.
         * chcr_end_part_handler will handle cases if complete record or end
-        * part of the record is received. Incase of partial end part of record,
+        * part of the record is received. In case of partial end part of record,
         * we will send the complete record again.
         */
 
index 3fdc70dab5c141a74b536e88ecff8d9730d276c4..252adfa5d837ba1002498f3c6a83efd5f62187d1 100644 (file)
@@ -133,6 +133,8 @@ struct board_info {
        u32             wake_state;
 
        int             ip_summed;
+
+       struct regulator *power_supply;
 };
 
 /* debug code */
@@ -1449,7 +1451,7 @@ dm9000_probe(struct platform_device *pdev)
                if (ret) {
                        dev_err(dev, "failed to request reset gpio %d: %d\n",
                                reset_gpios, ret);
-                       return -ENODEV;
+                       goto out_regulator_disable;
                }
 
                /* According to manual PWRST# Low Period Min 1ms */
@@ -1461,8 +1463,10 @@ dm9000_probe(struct platform_device *pdev)
 
        if (!pdata) {
                pdata = dm9000_parse_dt(&pdev->dev);
-               if (IS_ERR(pdata))
-                       return PTR_ERR(pdata);
+               if (IS_ERR(pdata)) {
+                       ret = PTR_ERR(pdata);
+                       goto out_regulator_disable;
+               }
        }
 
        /* Init network device */
@@ -1479,6 +1483,8 @@ dm9000_probe(struct platform_device *pdev)
 
        db->dev = &pdev->dev;
        db->ndev = ndev;
+       if (!IS_ERR(power))
+               db->power_supply = power;
 
        spin_lock_init(&db->lock);
        mutex_init(&db->addr_lock);
@@ -1501,7 +1507,7 @@ dm9000_probe(struct platform_device *pdev)
                goto out;
        }
 
-       db->irq_wake = platform_get_irq(pdev, 1);
+       db->irq_wake = platform_get_irq_optional(pdev, 1);
        if (db->irq_wake >= 0) {
                dev_dbg(db->dev, "wakeup irq %d\n", db->irq_wake);
 
@@ -1703,6 +1709,10 @@ out:
        dm9000_release_board(pdev, db);
        free_netdev(ndev);
 
+out_regulator_disable:
+       if (!IS_ERR(power))
+               regulator_disable(power);
+
        return ret;
 }
 
@@ -1760,10 +1770,13 @@ static int
 dm9000_drv_remove(struct platform_device *pdev)
 {
        struct net_device *ndev = platform_get_drvdata(pdev);
+       struct board_info *dm = to_dm9000_board(ndev);
 
        unregister_netdev(ndev);
-       dm9000_release_board(pdev, netdev_priv(ndev));
+       dm9000_release_board(pdev, dm);
        free_netdev(ndev);              /* free device structure */
+       if (dm->power_supply)
+               regulator_disable(dm->power_supply);
 
        dev_dbg(&pdev->dev, "released and freed device\n");
        return 0;
index c78d12229730ba27cb2206f7c1609894059ccec2..09471329f3a36ebaee687b105556f33ba22c1b5c 100644 (file)
@@ -281,6 +281,8 @@ static int enetc_poll(struct napi_struct *napi, int budget)
        int work_done;
        int i;
 
+       enetc_lock_mdio();
+
        for (i = 0; i < v->count_tx_rings; i++)
                if (!enetc_clean_tx_ring(&v->tx_ring[i], budget))
                        complete = false;
@@ -291,8 +293,10 @@ static int enetc_poll(struct napi_struct *napi, int budget)
        if (work_done)
                v->rx_napi_work = true;
 
-       if (!complete)
+       if (!complete) {
+               enetc_unlock_mdio();
                return budget;
+       }
 
        napi_complete_done(napi, work_done);
 
@@ -301,8 +305,6 @@ static int enetc_poll(struct napi_struct *napi, int budget)
 
        v->rx_napi_work = false;
 
-       enetc_lock_mdio();
-
        /* enable interrupts */
        enetc_wr_reg_hot(v->rbier, ENETC_RBIER_RXTIE);
 
@@ -327,8 +329,8 @@ static void enetc_get_tx_tstamp(struct enetc_hw *hw, union enetc_tx_bd *txbd,
 {
        u32 lo, hi, tstamp_lo;
 
-       lo = enetc_rd(hw, ENETC_SICTR0);
-       hi = enetc_rd(hw, ENETC_SICTR1);
+       lo = enetc_rd_hot(hw, ENETC_SICTR0);
+       hi = enetc_rd_hot(hw, ENETC_SICTR1);
        tstamp_lo = le32_to_cpu(txbd->wb.tstamp);
        if (lo <= tstamp_lo)
                hi -= 1;
@@ -342,6 +344,12 @@ static void enetc_tstamp_tx(struct sk_buff *skb, u64 tstamp)
        if (skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS) {
                memset(&shhwtstamps, 0, sizeof(shhwtstamps));
                shhwtstamps.hwtstamp = ns_to_ktime(tstamp);
+               /* Ensure skb_mstamp_ns, which might have been populated with
+                * the txtime, is not mistaken for a software timestamp,
+                * because this will prevent the dispatch of our hardware
+                * timestamp to the socket.
+                */
+               skb->tstamp = ktime_set(0, 0);
                skb_tstamp_tx(skb, &shhwtstamps);
        }
 }
@@ -358,9 +366,7 @@ static bool enetc_clean_tx_ring(struct enetc_bdr *tx_ring, int napi_budget)
        i = tx_ring->next_to_clean;
        tx_swbd = &tx_ring->tx_swbd[i];
 
-       enetc_lock_mdio();
        bds_to_clean = enetc_bd_ready_count(tx_ring, i);
-       enetc_unlock_mdio();
 
        do_tstamp = false;
 
@@ -403,8 +409,6 @@ static bool enetc_clean_tx_ring(struct enetc_bdr *tx_ring, int napi_budget)
                        tx_swbd = tx_ring->tx_swbd;
                }
 
-               enetc_lock_mdio();
-
                /* BD iteration loop end */
                if (is_eof) {
                        tx_frm_cnt++;
@@ -415,8 +419,6 @@ static bool enetc_clean_tx_ring(struct enetc_bdr *tx_ring, int napi_budget)
 
                if (unlikely(!bds_to_clean))
                        bds_to_clean = enetc_bd_ready_count(tx_ring, i);
-
-               enetc_unlock_mdio();
        }
 
        tx_ring->next_to_clean = i;
@@ -527,9 +529,8 @@ static void enetc_get_rx_tstamp(struct net_device *ndev,
 static void enetc_get_offloads(struct enetc_bdr *rx_ring,
                               union enetc_rx_bd *rxbd, struct sk_buff *skb)
 {
-#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
        struct enetc_ndev_priv *priv = netdev_priv(rx_ring->ndev);
-#endif
+
        /* TODO: hashing */
        if (rx_ring->ndev->features & NETIF_F_RXCSUM) {
                u16 inet_csum = le16_to_cpu(rxbd->r.inet_csum);
@@ -538,12 +539,31 @@ static void enetc_get_offloads(struct enetc_bdr *rx_ring,
                skb->ip_summed = CHECKSUM_COMPLETE;
        }
 
-       /* copy VLAN to skb, if one is extracted, for now we assume it's a
-        * standard TPID, but HW also supports custom values
-        */
-       if (le16_to_cpu(rxbd->r.flags) & ENETC_RXBD_FLAG_VLAN)
-               __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q),
-                                      le16_to_cpu(rxbd->r.vlan_opt));
+       if (le16_to_cpu(rxbd->r.flags) & ENETC_RXBD_FLAG_VLAN) {
+               __be16 tpid = 0;
+
+               switch (le16_to_cpu(rxbd->r.flags) & ENETC_RXBD_FLAG_TPID) {
+               case 0:
+                       tpid = htons(ETH_P_8021Q);
+                       break;
+               case 1:
+                       tpid = htons(ETH_P_8021AD);
+                       break;
+               case 2:
+                       tpid = htons(enetc_port_rd(&priv->si->hw,
+                                                  ENETC_PCVLANR1));
+                       break;
+               case 3:
+                       tpid = htons(enetc_port_rd(&priv->si->hw,
+                                                  ENETC_PCVLANR2));
+                       break;
+               default:
+                       break;
+               }
+
+               __vlan_hwaccel_put_tag(skb, tpid, le16_to_cpu(rxbd->r.vlan_opt));
+       }
+
 #ifdef CONFIG_FSL_ENETC_PTP_CLOCK
        if (priv->active_offloads & ENETC_F_RX_TSTAMP)
                enetc_get_rx_tstamp(rx_ring->ndev, rxbd, skb);
@@ -660,8 +680,6 @@ static int enetc_clean_rx_ring(struct enetc_bdr *rx_ring,
                u32 bd_status;
                u16 size;
 
-               enetc_lock_mdio();
-
                if (cleaned_cnt >= ENETC_RXBD_BUNDLE) {
                        int count = enetc_refill_rx_ring(rx_ring, cleaned_cnt);
 
@@ -672,19 +690,15 @@ static int enetc_clean_rx_ring(struct enetc_bdr *rx_ring,
 
                rxbd = enetc_rxbd(rx_ring, i);
                bd_status = le32_to_cpu(rxbd->r.lstatus);
-               if (!bd_status) {
-                       enetc_unlock_mdio();
+               if (!bd_status)
                        break;
-               }
 
                enetc_wr_reg_hot(rx_ring->idr, BIT(rx_ring->index));
                dma_rmb(); /* for reading other rxbd fields */
                size = le16_to_cpu(rxbd->r.buf_len);
                skb = enetc_map_rx_buff_to_skb(rx_ring, i, size);
-               if (!skb) {
-                       enetc_unlock_mdio();
+               if (!skb)
                        break;
-               }
 
                enetc_get_offloads(rx_ring, rxbd, skb);
 
@@ -696,7 +710,6 @@ static int enetc_clean_rx_ring(struct enetc_bdr *rx_ring,
 
                if (unlikely(bd_status &
                             ENETC_RXBD_LSTATUS(ENETC_RXBD_ERR_MASK))) {
-                       enetc_unlock_mdio();
                        dev_kfree_skb(skb);
                        while (!(bd_status & ENETC_RXBD_LSTATUS_F)) {
                                dma_rmb();
@@ -736,8 +749,6 @@ static int enetc_clean_rx_ring(struct enetc_bdr *rx_ring,
 
                enetc_process_skb(rx_ring, skb);
 
-               enetc_unlock_mdio();
-
                napi_gro_receive(napi, skb);
 
                rx_frm_cnt++;
@@ -984,7 +995,7 @@ static void enetc_free_rxtx_rings(struct enetc_ndev_priv *priv)
                enetc_free_tx_ring(priv->tx_ring[i]);
 }
 
-static int enetc_alloc_cbdr(struct device *dev, struct enetc_cbdr *cbdr)
+int enetc_alloc_cbdr(struct device *dev, struct enetc_cbdr *cbdr)
 {
        int size = cbdr->bd_count * sizeof(struct enetc_cbd);
 
@@ -1005,7 +1016,7 @@ static int enetc_alloc_cbdr(struct device *dev, struct enetc_cbdr *cbdr)
        return 0;
 }
 
-static void enetc_free_cbdr(struct device *dev, struct enetc_cbdr *cbdr)
+void enetc_free_cbdr(struct device *dev, struct enetc_cbdr *cbdr)
 {
        int size = cbdr->bd_count * sizeof(struct enetc_cbd);
 
@@ -1013,7 +1024,7 @@ static void enetc_free_cbdr(struct device *dev, struct enetc_cbdr *cbdr)
        cbdr->bd_base = NULL;
 }
 
-static void enetc_setup_cbdr(struct enetc_hw *hw, struct enetc_cbdr *cbdr)
+void enetc_setup_cbdr(struct enetc_hw *hw, struct enetc_cbdr *cbdr)
 {
        /* set CBDR cache attributes */
        enetc_wr(hw, ENETC_SICAR2,
@@ -1033,7 +1044,7 @@ static void enetc_setup_cbdr(struct enetc_hw *hw, struct enetc_cbdr *cbdr)
        cbdr->cir = hw->reg + ENETC_SICBDRCIR;
 }
 
-static void enetc_clear_cbdr(struct enetc_hw *hw)
+void enetc_clear_cbdr(struct enetc_hw *hw)
 {
        enetc_wr(hw, ENETC_SICBDRMR, 0);
 }
@@ -1058,13 +1069,12 @@ static int enetc_setup_default_rss_table(struct enetc_si *si, int num_groups)
        return 0;
 }
 
-static int enetc_configure_si(struct enetc_ndev_priv *priv)
+int enetc_configure_si(struct enetc_ndev_priv *priv)
 {
        struct enetc_si *si = priv->si;
        struct enetc_hw *hw = &si->hw;
        int err;
 
-       enetc_setup_cbdr(hw, &si->cbd_ring);
        /* set SI cache attributes */
        enetc_wr(hw, ENETC_SICAR0,
                 ENETC_SICAR_RD_COHERENT | ENETC_SICAR_WR_COHERENT);
@@ -1112,6 +1122,8 @@ int enetc_alloc_si_resources(struct enetc_ndev_priv *priv)
        if (err)
                return err;
 
+       enetc_setup_cbdr(&si->hw, &si->cbd_ring);
+
        priv->cls_rules = kcalloc(si->num_fs_entries, sizeof(*priv->cls_rules),
                                  GFP_KERNEL);
        if (!priv->cls_rules) {
@@ -1119,14 +1131,8 @@ int enetc_alloc_si_resources(struct enetc_ndev_priv *priv)
                goto err_alloc_cls;
        }
 
-       err = enetc_configure_si(priv);
-       if (err)
-               goto err_config_si;
-
        return 0;
 
-err_config_si:
-       kfree(priv->cls_rules);
 err_alloc_cls:
        enetc_clear_cbdr(&si->hw);
        enetc_free_cbdr(priv->dev, &si->cbd_ring);
@@ -1212,7 +1218,8 @@ static void enetc_setup_rxbdr(struct enetc_hw *hw, struct enetc_bdr *rx_ring)
        rx_ring->idr = hw->reg + ENETC_SIRXIDR;
 
        enetc_refill_rx_ring(rx_ring, enetc_bd_unused(rx_ring));
-       enetc_wr(hw, ENETC_SIRXIDR, rx_ring->next_to_use);
+       /* update ENETC's consumer index */
+       enetc_rxbdr_wr(hw, idx, ENETC_RBCIR, rx_ring->next_to_use);
 
        /* enable ring */
        enetc_rxbdr_wr(hw, idx, ENETC_RBMR, rbmr);
index 8532d23b54f5f14c57dec2eb47855b6fcd35c4cb..8b380fc13314a3fd43c9ba0ddf71bb6284264fb0 100644 (file)
@@ -292,6 +292,7 @@ void enetc_get_si_caps(struct enetc_si *si);
 void enetc_init_si_rings_params(struct enetc_ndev_priv *priv);
 int enetc_alloc_si_resources(struct enetc_ndev_priv *priv);
 void enetc_free_si_resources(struct enetc_ndev_priv *priv);
+int enetc_configure_si(struct enetc_ndev_priv *priv);
 
 int enetc_open(struct net_device *ndev);
 int enetc_close(struct net_device *ndev);
@@ -309,6 +310,10 @@ int enetc_setup_tc(struct net_device *ndev, enum tc_setup_type type,
 void enetc_set_ethtool_ops(struct net_device *ndev);
 
 /* control buffer descriptor ring (CBDR) */
+int enetc_alloc_cbdr(struct device *dev, struct enetc_cbdr *cbdr);
+void enetc_free_cbdr(struct device *dev, struct enetc_cbdr *cbdr);
+void enetc_setup_cbdr(struct enetc_hw *hw, struct enetc_cbdr *cbdr);
+void enetc_clear_cbdr(struct enetc_hw *hw);
 int enetc_set_mac_flt_entry(struct enetc_si *si, int index,
                            char *mac_addr, int si_map);
 int enetc_clear_mac_flt_entry(struct enetc_si *si, int index);
index c71fe8d751d50342a9ad2d764a4afe01ba1aaf18..00938f7960a43aae09bc10c44fc5cea0db313d4b 100644 (file)
@@ -172,6 +172,8 @@ enum enetc_bdr_type {TX, RX};
 #define ENETC_PSIPMAR0(n)      (0x0100 + (n) * 0x8) /* n = SI index */
 #define ENETC_PSIPMAR1(n)      (0x0104 + (n) * 0x8)
 #define ENETC_PVCLCTR          0x0208
+#define ENETC_PCVLANR1         0x0210
+#define ENETC_PCVLANR2         0x0214
 #define ENETC_VLAN_TYPE_C      BIT(0)
 #define ENETC_VLAN_TYPE_S      BIT(1)
 #define ENETC_PVCLCTR_OVTPIDL(bmp)     ((bmp) & 0xff) /* VLAN_TYPE */
@@ -232,14 +234,23 @@ enum enetc_bdr_type {TX, RX};
 #define ENETC_PM0_MAXFRM       0x8014
 #define ENETC_SET_TX_MTU(val)  ((val) << 16)
 #define ENETC_SET_MAXFRM(val)  ((val) & 0xffff)
+#define ENETC_PM0_RX_FIFO      0x801c
+#define ENETC_PM0_RX_FIFO_VAL  1
 
 #define ENETC_PM_IMDIO_BASE    0x8030
 
 #define ENETC_PM0_IF_MODE      0x8300
-#define ENETC_PMO_IFM_RG       BIT(2)
+#define ENETC_PM0_IFM_RG       BIT(2)
 #define ENETC_PM0_IFM_RLP      (BIT(5) | BIT(11))
-#define ENETC_PM0_IFM_RGAUTO   (BIT(15) | ENETC_PMO_IFM_RG | BIT(1))
-#define ENETC_PM0_IFM_XGMII    BIT(12)
+#define ENETC_PM0_IFM_EN_AUTO  BIT(15)
+#define ENETC_PM0_IFM_SSP_MASK GENMASK(14, 13)
+#define ENETC_PM0_IFM_SSP_1000 (2 << 13)
+#define ENETC_PM0_IFM_SSP_100  (0 << 13)
+#define ENETC_PM0_IFM_SSP_10   (1 << 13)
+#define ENETC_PM0_IFM_FULL_DPX BIT(12)
+#define ENETC_PM0_IFM_IFMODE_MASK GENMASK(1, 0)
+#define ENETC_PM0_IFM_IFMODE_XGMII 0
+#define ENETC_PM0_IFM_IFMODE_GMII 2
 #define ENETC_PSIDCAPR         0x1b08
 #define ENETC_PSIDCAPR_MSK     GENMASK(15, 0)
 #define ENETC_PSFCAPR          0x1b18
@@ -453,6 +464,8 @@ static inline u64 _enetc_rd_reg64_wa(void __iomem *reg)
 #define enetc_wr_reg(reg, val)         _enetc_wr_reg_wa((reg), (val))
 #define enetc_rd(hw, off)              enetc_rd_reg((hw)->reg + (off))
 #define enetc_wr(hw, off, val)         enetc_wr_reg((hw)->reg + (off), val)
+#define enetc_rd_hot(hw, off)          enetc_rd_reg_hot((hw)->reg + (off))
+#define enetc_wr_hot(hw, off, val)     enetc_wr_reg_hot((hw)->reg + (off), val)
 #define enetc_rd64(hw, off)            _enetc_rd_reg64_wa((hw)->reg + (off))
 /* port register accessors - PF only */
 #define enetc_port_rd(hw, off)         enetc_rd_reg((hw)->port + (off))
@@ -568,6 +581,7 @@ union enetc_rx_bd {
 #define ENETC_RXBD_LSTATUS(flags)      ((flags) << 16)
 #define ENETC_RXBD_FLAG_VLAN   BIT(9)
 #define ENETC_RXBD_FLAG_TSTMP  BIT(10)
+#define ENETC_RXBD_FLAG_TPID   GENMASK(1, 0)
 
 #define ENETC_MAC_ADDR_FILT_CNT        8 /* # of supported entries per port */
 #define EMETC_MAC_ADDR_FILT_RES        3 /* # of reserved entries at the beginning */
index 515c5b29d7aabe4553c3e547c08beebaae86cb87..224fc37a6757cd5d8a87532d3ac0360433e5957c 100644 (file)
@@ -190,7 +190,6 @@ static void enetc_pf_set_rx_mode(struct net_device *ndev)
 {
        struct enetc_ndev_priv *priv = netdev_priv(ndev);
        struct enetc_pf *pf = enetc_si_priv(priv->si);
-       char vlan_promisc_simap = pf->vlan_promisc_simap;
        struct enetc_hw *hw = &priv->si->hw;
        bool uprom = false, mprom = false;
        struct enetc_mac_filter *filter;
@@ -203,16 +202,12 @@ static void enetc_pf_set_rx_mode(struct net_device *ndev)
                psipmr = ENETC_PSIPMR_SET_UP(0) | ENETC_PSIPMR_SET_MP(0);
                uprom = true;
                mprom = true;
-               /* Enable VLAN promiscuous mode for SI0 (PF) */
-               vlan_promisc_simap |= BIT(0);
        } else if (ndev->flags & IFF_ALLMULTI) {
                /* enable multi cast promisc mode for SI0 (PF) */
                psipmr = ENETC_PSIPMR_SET_MP(0);
                mprom = true;
        }
 
-       enetc_set_vlan_promisc(&pf->si->hw, vlan_promisc_simap);
-
        /* first 2 filter entries belong to PF */
        if (!uprom) {
                /* Update unicast filters */
@@ -320,7 +315,7 @@ static void enetc_set_loopback(struct net_device *ndev, bool en)
        u32 reg;
 
        reg = enetc_port_rd(hw, ENETC_PM0_IF_MODE);
-       if (reg & ENETC_PMO_IFM_RG) {
+       if (reg & ENETC_PM0_IFM_RG) {
                /* RGMII mode */
                reg = (reg & ~ENETC_PM0_IFM_RLP) |
                      (en ? ENETC_PM0_IFM_RLP : 0);
@@ -495,17 +490,30 @@ static void enetc_configure_port_mac(struct enetc_hw *hw)
 
        enetc_port_wr(hw, ENETC_PM1_CMD_CFG, ENETC_PM0_CMD_PHY_TX_EN |
                      ENETC_PM0_CMD_TXP | ENETC_PM0_PROMISC);
+
+       /* On LS1028A, the MAC RX FIFO defaults to 2, which is too high
+        * and may lead to RX lock-up under traffic. Set it to 1 instead,
+        * as recommended by the hardware team.
+        */
+       enetc_port_wr(hw, ENETC_PM0_RX_FIFO, ENETC_PM0_RX_FIFO_VAL);
 }
 
 static void enetc_mac_config(struct enetc_hw *hw, phy_interface_t phy_mode)
 {
-       /* set auto-speed for RGMII */
-       if (enetc_port_rd(hw, ENETC_PM0_IF_MODE) & ENETC_PMO_IFM_RG ||
-           phy_interface_mode_is_rgmii(phy_mode))
-               enetc_port_wr(hw, ENETC_PM0_IF_MODE, ENETC_PM0_IFM_RGAUTO);
+       u32 val;
+
+       if (phy_interface_mode_is_rgmii(phy_mode)) {
+               val = enetc_port_rd(hw, ENETC_PM0_IF_MODE);
+               val &= ~ENETC_PM0_IFM_EN_AUTO;
+               val &= ENETC_PM0_IFM_IFMODE_MASK;
+               val |= ENETC_PM0_IFM_IFMODE_GMII | ENETC_PM0_IFM_RG;
+               enetc_port_wr(hw, ENETC_PM0_IF_MODE, val);
+       }
 
-       if (phy_mode == PHY_INTERFACE_MODE_USXGMII)
-               enetc_port_wr(hw, ENETC_PM0_IF_MODE, ENETC_PM0_IFM_XGMII);
+       if (phy_mode == PHY_INTERFACE_MODE_USXGMII) {
+               val = ENETC_PM0_IFM_FULL_DPX | ENETC_PM0_IFM_IFMODE_XGMII;
+               enetc_port_wr(hw, ENETC_PM0_IF_MODE, val);
+       }
 }
 
 static void enetc_mac_enable(struct enetc_hw *hw, bool en)
@@ -937,6 +945,34 @@ static void enetc_pl_mac_config(struct phylink_config *config,
                phylink_set_pcs(priv->phylink, &pf->pcs->pcs);
 }
 
+static void enetc_force_rgmii_mac(struct enetc_hw *hw, int speed, int duplex)
+{
+       u32 old_val, val;
+
+       old_val = val = enetc_port_rd(hw, ENETC_PM0_IF_MODE);
+
+       if (speed == SPEED_1000) {
+               val &= ~ENETC_PM0_IFM_SSP_MASK;
+               val |= ENETC_PM0_IFM_SSP_1000;
+       } else if (speed == SPEED_100) {
+               val &= ~ENETC_PM0_IFM_SSP_MASK;
+               val |= ENETC_PM0_IFM_SSP_100;
+       } else if (speed == SPEED_10) {
+               val &= ~ENETC_PM0_IFM_SSP_MASK;
+               val |= ENETC_PM0_IFM_SSP_10;
+       }
+
+       if (duplex == DUPLEX_FULL)
+               val |= ENETC_PM0_IFM_FULL_DPX;
+       else
+               val &= ~ENETC_PM0_IFM_FULL_DPX;
+
+       if (val == old_val)
+               return;
+
+       enetc_port_wr(hw, ENETC_PM0_IF_MODE, val);
+}
+
 static void enetc_pl_mac_link_up(struct phylink_config *config,
                                 struct phy_device *phy, unsigned int mode,
                                 phy_interface_t interface, int speed,
@@ -949,6 +985,10 @@ static void enetc_pl_mac_link_up(struct phylink_config *config,
        if (priv->active_offloads & ENETC_F_QBV)
                enetc_sched_speed_set(priv, speed);
 
+       if (!phylink_autoneg_inband(mode) &&
+           phy_interface_mode_is_rgmii(interface))
+               enetc_force_rgmii_mac(&pf->si->hw, speed, duplex);
+
        enetc_mac_enable(&pf->si->hw, true);
 }
 
@@ -1041,6 +1081,26 @@ static int enetc_init_port_rss_memory(struct enetc_si *si)
        return err;
 }
 
+static void enetc_init_unused_port(struct enetc_si *si)
+{
+       struct device *dev = &si->pdev->dev;
+       struct enetc_hw *hw = &si->hw;
+       int err;
+
+       si->cbd_ring.bd_count = ENETC_CBDR_DEFAULT_SIZE;
+       err = enetc_alloc_cbdr(dev, &si->cbd_ring);
+       if (err)
+               return;
+
+       enetc_setup_cbdr(hw, &si->cbd_ring);
+
+       enetc_init_port_rfs_memory(si);
+       enetc_init_port_rss_memory(si);
+
+       enetc_clear_cbdr(hw);
+       enetc_free_cbdr(dev, &si->cbd_ring);
+}
+
 static int enetc_pf_probe(struct pci_dev *pdev,
                          const struct pci_device_id *ent)
 {
@@ -1051,11 +1111,6 @@ static int enetc_pf_probe(struct pci_dev *pdev,
        struct enetc_pf *pf;
        int err;
 
-       if (node && !of_device_is_available(node)) {
-               dev_info(&pdev->dev, "device is disabled, skipping\n");
-               return -ENODEV;
-       }
-
        err = enetc_pci_probe(pdev, KBUILD_MODNAME, sizeof(*pf));
        if (err) {
                dev_err(&pdev->dev, "PCI probing failed\n");
@@ -1069,6 +1124,13 @@ static int enetc_pf_probe(struct pci_dev *pdev,
                goto err_map_pf_space;
        }
 
+       if (node && !of_device_is_available(node)) {
+               enetc_init_unused_port(si);
+               dev_info(&pdev->dev, "device is disabled, skipping\n");
+               err = -ENODEV;
+               goto err_device_disabled;
+       }
+
        pf = enetc_si_priv(si);
        pf->si = si;
        pf->total_vfs = pci_sriov_get_totalvfs(pdev);
@@ -1108,6 +1170,12 @@ static int enetc_pf_probe(struct pci_dev *pdev,
                goto err_init_port_rss;
        }
 
+       err = enetc_configure_si(priv);
+       if (err) {
+               dev_err(&pdev->dev, "Failed to configure SI\n");
+               goto err_config_si;
+       }
+
        err = enetc_alloc_msix(priv);
        if (err) {
                dev_err(&pdev->dev, "MSIX alloc failed\n");
@@ -1136,6 +1204,7 @@ err_phylink_create:
        enetc_mdiobus_destroy(pf);
 err_mdiobus_create:
        enetc_free_msix(priv);
+err_config_si:
 err_init_port_rss:
 err_init_port_rfs:
 err_alloc_msix:
@@ -1144,6 +1213,7 @@ err_alloc_si_res:
        si->ndev = NULL;
        free_netdev(ndev);
 err_alloc_netdev:
+err_device_disabled:
 err_map_pf_space:
        enetc_pci_remove(pdev);
 
index 39c1a09e69a95d8ccb1fa0981a0b992c2ec07eae..9b755a84c2d6276a25893aaaa9530a3b11d62379 100644 (file)
@@ -171,6 +171,12 @@ static int enetc_vf_probe(struct pci_dev *pdev,
                goto err_alloc_si_res;
        }
 
+       err = enetc_configure_si(priv);
+       if (err) {
+               dev_err(&pdev->dev, "Failed to configure SI\n");
+               goto err_config_si;
+       }
+
        err = enetc_alloc_msix(priv);
        if (err) {
                dev_err(&pdev->dev, "MSIX alloc failed\n");
@@ -187,6 +193,7 @@ static int enetc_vf_probe(struct pci_dev *pdev,
 
 err_reg_netdev:
        enetc_free_msix(priv);
+err_config_si:
 err_alloc_msix:
        enetc_free_si_resources(priv);
 err_alloc_si_res:
index 2e344aada4c6027a2a235d1f618be321e5001f0d..1753807cbf97e2bff83a218a8ba33f662fe593b7 100644 (file)
@@ -377,9 +377,16 @@ static int fec_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
        u64 ns;
        unsigned long flags;
 
+       mutex_lock(&adapter->ptp_clk_mutex);
+       /* Check the ptp clock */
+       if (!adapter->ptp_clk_on) {
+               mutex_unlock(&adapter->ptp_clk_mutex);
+               return -EINVAL;
+       }
        spin_lock_irqsave(&adapter->tmreg_lock, flags);
        ns = timecounter_read(&adapter->tc);
        spin_unlock_irqrestore(&adapter->tmreg_lock, flags);
+       mutex_unlock(&adapter->ptp_clk_mutex);
 
        *ts = ns_to_timespec64(ns);
 
index 541de32ea6622e355130ad5d284ae6414e278a5a..1cf8ef717453dd46bbde2c98e1525618f789b8e8 100644 (file)
@@ -2390,6 +2390,10 @@ static bool gfar_add_rx_frag(struct gfar_rx_buff *rxb, u32 lstatus,
                if (lstatus & BD_LFLAG(RXBD_LAST))
                        size -= skb->len;
 
+               WARN(size < 0, "gianfar: rx fragment size underflow");
+               if (size < 0)
+                       return false;
+
                skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page,
                                rxb->page_offset + RXBUF_ALIGNMENT,
                                size, GFAR_RXB_TRUESIZE);
@@ -2552,6 +2556,17 @@ static int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue,
                if (lstatus & BD_LFLAG(RXBD_EMPTY))
                        break;
 
+               /* lost RXBD_LAST descriptor due to overrun */
+               if (skb &&
+                   (lstatus & BD_LFLAG(RXBD_FIRST))) {
+                       /* discard faulty buffer */
+                       dev_kfree_skb(skb);
+                       skb = NULL;
+                       rx_queue->stats.rx_dropped++;
+
+                       /* can continue normally */
+               }
+
                /* order rx buffer descriptor reads */
                rmb();
 
index 5d7824d2b4d475fb2e07f912afd197e980afdf61..c66a7a51198ee4431f4edaacb742f2135027cb9d 100644 (file)
@@ -1663,8 +1663,10 @@ static int hns_nic_clear_all_rx_fetch(struct net_device *ndev)
                        for (j = 0; j < fetch_num; j++) {
                                /* alloc one skb and init */
                                skb = hns_assemble_skb(ndev);
-                               if (!skb)
+                               if (!skb) {
+                                       ret = -ENOMEM;
                                        goto out;
+                               }
                                rd = &tx_ring_data(priv, skb->queue_mapping);
                                hns_nic_net_xmit_hw(ndev, skb, rd);
 
index ff52a65b4cffbc9555687f78d8e01fb361dfc416..057dda735492478fcf38de0229312e90b4bf22a9 100644 (file)
@@ -1053,16 +1053,16 @@ struct hclge_fd_tcam_config_3_cmd {
 #define HCLGE_FD_AD_DROP_B             0
 #define HCLGE_FD_AD_DIRECT_QID_B       1
 #define HCLGE_FD_AD_QID_S              2
-#define HCLGE_FD_AD_QID_M              GENMASK(12, 2)
+#define HCLGE_FD_AD_QID_M              GENMASK(11, 2)
 #define HCLGE_FD_AD_USE_COUNTER_B      12
 #define HCLGE_FD_AD_COUNTER_NUM_S      13
 #define HCLGE_FD_AD_COUNTER_NUM_M      GENMASK(20, 13)
 #define HCLGE_FD_AD_NXT_STEP_B         20
 #define HCLGE_FD_AD_NXT_KEY_S          21
-#define HCLGE_FD_AD_NXT_KEY_M          GENMASK(26, 21)
+#define HCLGE_FD_AD_NXT_KEY_M          GENMASK(25, 21)
 #define HCLGE_FD_AD_WR_RULE_ID_B       0
 #define HCLGE_FD_AD_RULE_ID_S          1
-#define HCLGE_FD_AD_RULE_ID_M          GENMASK(13, 1)
+#define HCLGE_FD_AD_RULE_ID_M          GENMASK(12, 1)
 #define HCLGE_FD_AD_TC_OVRD_B          16
 #define HCLGE_FD_AD_TC_SIZE_S          17
 #define HCLGE_FD_AD_TC_SIZE_M          GENMASK(20, 17)
index 34b744df67096ba826b68b688da81ca8856f8407..e3f81c7e0ce74fa185773d3fc5f1284abf88d0e4 100644 (file)
@@ -5245,9 +5245,9 @@ static bool hclge_fd_convert_tuple(u32 tuple_bit, u8 *key_x, u8 *key_y,
        case BIT(INNER_SRC_MAC):
                for (i = 0; i < ETH_ALEN; i++) {
                        calc_x(key_x[ETH_ALEN - 1 - i], rule->tuples.src_mac[i],
-                              rule->tuples.src_mac[i]);
+                              rule->tuples_mask.src_mac[i]);
                        calc_y(key_y[ETH_ALEN - 1 - i], rule->tuples.src_mac[i],
-                              rule->tuples.src_mac[i]);
+                              rule->tuples_mask.src_mac[i]);
                }
 
                return true;
@@ -6330,8 +6330,7 @@ static void hclge_fd_get_ext_info(struct ethtool_rx_flow_spec *fs,
                fs->h_ext.vlan_tci = cpu_to_be16(rule->tuples.vlan_tag1);
                fs->m_ext.vlan_tci =
                                rule->unused_tuple & BIT(INNER_VLAN_TAG_FST) ?
-                               cpu_to_be16(VLAN_VID_MASK) :
-                               cpu_to_be16(rule->tuples_mask.vlan_tag1);
+                               0 : cpu_to_be16(rule->tuples_mask.vlan_tag1);
        }
 
        if (fs->flow_type & FLOW_MAC_EXT) {
index c3ec9ceed833ed4e6d128c86bbf09aa476de91b5..7fea9ae60f130b8d8e9b974be2d9d92544a18df0 100644 (file)
@@ -1758,7 +1758,7 @@ static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)
        return 0;
 }
 
-static int ibmveth_remove(struct vio_dev *dev)
+static void ibmveth_remove(struct vio_dev *dev)
 {
        struct net_device *netdev = dev_get_drvdata(&dev->dev);
        struct ibmveth_adapter *adapter = netdev_priv(netdev);
@@ -1771,8 +1771,6 @@ static int ibmveth_remove(struct vio_dev *dev)
 
        free_netdev(netdev);
        dev_set_drvdata(&dev->dev, NULL);
-
-       return 0;
 }
 
 static struct attribute veth_active_attr;
index 118a4bd3f8779031f68cf925a7937c51dbea646f..9c6438d3b3a5be52fe3cd02f97481964b6bcedf7 100644 (file)
@@ -78,7 +78,6 @@ MODULE_LICENSE("GPL");
 MODULE_VERSION(IBMVNIC_DRIVER_VERSION);
 
 static int ibmvnic_version = IBMVNIC_INITIAL_VERSION;
-static int ibmvnic_remove(struct vio_dev *);
 static void release_sub_crqs(struct ibmvnic_adapter *, bool);
 static int ibmvnic_reset_crq(struct ibmvnic_adapter *);
 static int ibmvnic_send_crq_init(struct ibmvnic_adapter *);
@@ -1906,10 +1905,9 @@ static int ibmvnic_set_mac(struct net_device *netdev, void *p)
        if (!is_valid_ether_addr(addr->sa_data))
                return -EADDRNOTAVAIL;
 
-       if (adapter->state != VNIC_PROBED) {
-               ether_addr_copy(adapter->mac_addr, addr->sa_data);
+       ether_addr_copy(adapter->mac_addr, addr->sa_data);
+       if (adapter->state != VNIC_PROBED)
                rc = __ibmvnic_set_mac(netdev, addr->sa_data);
-       }
 
        return rc;
 }
@@ -5219,16 +5217,14 @@ static int ibmvnic_reset_init(struct ibmvnic_adapter *adapter, bool reset)
 {
        struct device *dev = &adapter->vdev->dev;
        unsigned long timeout = msecs_to_jiffies(20000);
-       u64 old_num_rx_queues, old_num_tx_queues;
+       u64 old_num_rx_queues = adapter->req_rx_queues;
+       u64 old_num_tx_queues = adapter->req_tx_queues;
        int rc;
 
        adapter->from_passive_init = false;
 
-       if (reset) {
-               old_num_rx_queues = adapter->req_rx_queues;
-               old_num_tx_queues = adapter->req_tx_queues;
+       if (reset)
                reinit_completion(&adapter->init_done);
-       }
 
        adapter->init_done_rc = 0;
        rc = ibmvnic_send_crq_init(adapter);
@@ -5396,7 +5392,7 @@ ibmvnic_init_fail:
        return rc;
 }
 
-static int ibmvnic_remove(struct vio_dev *dev)
+static void ibmvnic_remove(struct vio_dev *dev)
 {
        struct net_device *netdev = dev_get_drvdata(&dev->dev);
        struct ibmvnic_adapter *adapter = netdev_priv(netdev);
@@ -5411,9 +5407,9 @@ static int ibmvnic_remove(struct vio_dev *dev)
         * after setting state, so __ibmvnic_reset() which is called
         * from the flush_work() below, can make progress.
         */
-       spin_lock_irqsave(&adapter->rwi_lock, flags);
+       spin_lock(&adapter->rwi_lock);
        adapter->state = VNIC_REMOVING;
-       spin_unlock_irqrestore(&adapter->rwi_lock, flags);
+       spin_unlock(&adapter->rwi_lock);
 
        spin_unlock_irqrestore(&adapter->state_lock, flags);
 
@@ -5437,8 +5433,6 @@ static int ibmvnic_remove(struct vio_dev *dev)
        device_remove_file(&dev->dev, &dev_attr_failover);
        free_netdev(netdev);
        dev_set_drvdata(&dev->dev, NULL);
-
-       return 0;
 }
 
 static ssize_t failover_store(struct device *dev, struct device_attribute *attr,
index 0a867d64d46753ae4f065ce479b4f4a139f38067..dc5b3c06d1e01451917d75e5bedf83bdf8bec8da 100644 (file)
@@ -1776,7 +1776,8 @@ static int iavf_init_get_resources(struct iavf_adapter *adapter)
                goto err_alloc;
        }
 
-       if (iavf_process_config(adapter))
+       err = iavf_process_config(adapter);
+       if (err)
                goto err_alloc;
        adapter->current_op = VIRTCHNL_OP_UNKNOWN;
 
index eca73526ac86bc609d560023596b9d2391caead0..54d47265a7ac1038e3e5ab8938f6aab3238ce8c9 100644 (file)
@@ -575,6 +575,11 @@ static int ixgbe_ipsec_add_sa(struct xfrm_state *xs)
                return -EINVAL;
        }
 
+       if (xs->props.mode != XFRM_MODE_TRANSPORT) {
+               netdev_err(dev, "Unsupported mode for ipsec offload\n");
+               return -EINVAL;
+       }
+
        if (ixgbe_ipsec_check_mgmt_ip(xs)) {
                netdev_err(dev, "IPsec IP addr clash with mgmt filters\n");
                return -EINVAL;
index fae84202d870c9c2206904349e790f0cc1125362..9f3f12e2ccf231a7e9002d89096ab86e4e74d050 100644 (file)
@@ -9565,8 +9565,10 @@ static int ixgbe_configure_clsu32(struct ixgbe_adapter *adapter,
        ixgbe_atr_compute_perfect_hash_82599(&input->filter, mask);
        err = ixgbe_fdir_write_perfect_filter_82599(hw, &input->filter,
                                                    input->sw_idx, queue);
-       if (!err)
-               ixgbe_update_ethtool_fdir_entry(adapter, input, input->sw_idx);
+       if (err)
+               goto err_out_w_lock;
+
+       ixgbe_update_ethtool_fdir_entry(adapter, input, input->sw_idx);
        spin_unlock(&adapter->fdir_perfect_lock);
 
        if ((uhtid != 0x800) && (adapter->jump_tables[uhtid]))
index 5170dd9d8705b0b6467151b9154e5f7b2ea8d78a..caaea2c920a6e48d08abc13501996960755dbdea 100644 (file)
@@ -272,6 +272,11 @@ static int ixgbevf_ipsec_add_sa(struct xfrm_state *xs)
                return -EINVAL;
        }
 
+       if (xs->props.mode != XFRM_MODE_TRANSPORT) {
+               netdev_err(dev, "Unsupported mode for ipsec offload\n");
+               return -EINVAL;
+       }
+
        if (xs->xso.flags & XFRM_OFFLOAD_INBOUND) {
                struct rx_sa rsa;
 
index 9caa375d01b15dec793e26209b8ea8cc97bda720..68deae529bc94a4ddb32503ce6424d8122495c6b 100644 (file)
@@ -56,7 +56,9 @@ static bool is_dev_rpm(void *cgxd)
 
 bool is_lmac_valid(struct cgx *cgx, int lmac_id)
 {
-       return cgx && test_bit(lmac_id, &cgx->lmac_bmap);
+       if (!cgx || lmac_id < 0 || lmac_id >= MAX_LMAC_PER_CGX)
+               return false;
+       return test_bit(lmac_id, &cgx->lmac_bmap);
 }
 
 struct mac_ops *get_mac_ops(void *cgxd)
index a8641a407c06a817faed34e537420ffc25e1e924..96d2891f1675ab80c4b0a1d04fc78b7e5ce115f9 100644 (file)
@@ -1225,8 +1225,6 @@ static int mtk_star_receive_packet(struct mtk_star_priv *priv)
                goto push_new_skb;
        }
 
-       desc_data.dma_addr = new_dma_addr;
-
        /* We can't fail anymore at this point: it's safe to unmap the skb. */
        mtk_star_dma_unmap_rx(priv, &desc_data);
 
@@ -1236,6 +1234,9 @@ static int mtk_star_receive_packet(struct mtk_star_priv *priv)
        desc_data.skb->dev = ndev;
        netif_receive_skb(desc_data.skb);
 
+       /* update dma_addr for new skb */
+       desc_data.dma_addr = new_dma_addr;
+
 push_new_skb:
        desc_data.len = skb_tailroom(new_skb);
        desc_data.skb = new_skb;
index 23849f2b9c2527f4ab85815b7ada6260722d5742..1434df66fcf2ee0910d086e44694dfd35d7f1039 100644 (file)
@@ -47,7 +47,7 @@
 #define EN_ETHTOOL_SHORT_MASK cpu_to_be16(0xffff)
 #define EN_ETHTOOL_WORD_MASK  cpu_to_be32(0xffffffff)
 
-static int mlx4_en_moderation_update(struct mlx4_en_priv *priv)
+int mlx4_en_moderation_update(struct mlx4_en_priv *priv)
 {
        int i, t;
        int err = 0;
index 51b9700fce83630ac2e7dabfb54c252875f83e18..5d0c9c62382dc5b5832743ebe94a862ccf5a798a 100644 (file)
@@ -3554,6 +3554,8 @@ int mlx4_en_reset_config(struct net_device *dev,
                        en_err(priv, "Failed starting port\n");
        }
 
+       if (!err)
+               err = mlx4_en_moderation_update(priv);
 out:
        mutex_unlock(&mdev->state_lock);
        kfree(tmp);
index e8ed23190de01b1b4c7e961387bb53a22d783c23..f3d1a20201ef34f860ef865143de5abc3349f04e 100644 (file)
@@ -775,6 +775,7 @@ void mlx4_en_ptp_overflow_check(struct mlx4_en_dev *mdev);
 #define DEV_FEATURE_CHANGED(dev, new_features, feature) \
        ((dev->features & feature) ^ (new_features & feature))
 
+int mlx4_en_moderation_update(struct mlx4_en_priv *priv);
 int mlx4_en_reset_config(struct net_device *dev,
                         struct hwtstamp_config ts_config,
                         netdev_features_t new_features);
index 16e2df6ef2f48edead0736aded2a2a32abb336cb..c4adc7f740d3e6b8a6c2f50b399846cbd2ecacbd 100644 (file)
@@ -4430,6 +4430,7 @@ MLXSW_ITEM32(reg, ptys, ext_eth_proto_cap, 0x08, 0, 32);
 #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_CR4          BIT(20)
 #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_SR4          BIT(21)
 #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_KR4          BIT(22)
+#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_LR4_ER4      BIT(23)
 #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_CR            BIT(27)
 #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_KR            BIT(28)
 #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_SR            BIT(29)
index bd7f873f6290b3e74fcf49c747fee4280e99d0cf..0bd64169bf8121c6c39f19be9ba8add48bf3374f 100644 (file)
@@ -1169,6 +1169,11 @@ static const struct mlxsw_sp1_port_link_mode mlxsw_sp1_port_link_mode[] = {
                .mask_ethtool   = ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT,
                .speed          = SPEED_100000,
        },
+       {
+               .mask           = MLXSW_REG_PTYS_ETH_SPEED_100GBASE_LR4_ER4,
+               .mask_ethtool   = ETHTOOL_LINK_MODE_100000baseLR4_ER4_Full_BIT,
+               .speed          = SPEED_100000,
+       },
 };
 
 #define MLXSW_SP1_PORT_LINK_MODE_LEN ARRAY_SIZE(mlxsw_sp1_port_link_mode)
index 9ce90841f92d8117cf4be234cb9e3183bbb99216..eda99d82766a7b40e420df70feefcf4acd311de5 100644 (file)
@@ -5951,6 +5951,10 @@ mlxsw_sp_router_fib4_replace(struct mlxsw_sp *mlxsw_sp,
        if (mlxsw_sp->router->aborted)
                return 0;
 
+       if (fen_info->fi->nh &&
+           !mlxsw_sp_nexthop_obj_group_lookup(mlxsw_sp, fen_info->fi->nh->id))
+               return 0;
+
        fib_node = mlxsw_sp_fib_node_get(mlxsw_sp, fen_info->tb_id,
                                         &fen_info->dst, sizeof(fen_info->dst),
                                         fen_info->dst_len,
@@ -6601,6 +6605,9 @@ static int mlxsw_sp_router_fib6_replace(struct mlxsw_sp *mlxsw_sp,
        if (mlxsw_sp_fib6_rt_should_ignore(rt))
                return 0;
 
+       if (rt->nh && !mlxsw_sp_nexthop_obj_group_lookup(mlxsw_sp, rt->nh->id))
+               return 0;
+
        fib_node = mlxsw_sp_fib_node_get(mlxsw_sp, rt->fib6_table->tb6_id,
                                         &rt->fib6_dst.addr,
                                         sizeof(rt->fib6_dst.addr),
index 40e2e79d451798eb7009a1de733fd4372893f223..131b2a53d261d64b5ff2d19cbe68741eead7d469 100644 (file)
@@ -613,7 +613,8 @@ static const struct mlxsw_sx_port_link_mode mlxsw_sx_port_link_mode[] = {
        {
                .mask           = MLXSW_REG_PTYS_ETH_SPEED_100GBASE_CR4 |
                                  MLXSW_REG_PTYS_ETH_SPEED_100GBASE_SR4 |
-                                 MLXSW_REG_PTYS_ETH_SPEED_100GBASE_KR4,
+                                 MLXSW_REG_PTYS_ETH_SPEED_100GBASE_KR4 |
+                                 MLXSW_REG_PTYS_ETH_SPEED_100GBASE_LR4_ER4,
                .speed          = 100000,
        },
 };
index dbdfabff3b0034e64db879b117e5749c6dd6281e..1c3e204d727cf8b242e6befc3a8f79791b96306f 100644 (file)
@@ -2040,7 +2040,7 @@ lan743x_rx_trim_skb(struct sk_buff *skb, int frame_length)
                dev_kfree_skb_irq(skb);
                return NULL;
        }
-       frame_length = max_t(int, 0, frame_length - RX_HEAD_PADDING - 2);
+       frame_length = max_t(int, 0, frame_length - RX_HEAD_PADDING - 4);
        if (skb->len > frame_length) {
                skb->tail -= skb->len - frame_length;
                skb->len = frame_length;
index c0ede0ca7115e26be088631dfda175f803209308..05cb040c26775657c851867371daada609d90fe9 100644 (file)
@@ -13,6 +13,7 @@ if NET_VENDOR_MICROSEMI
 
 # Users should depend on NET_SWITCHDEV, HAS_IOMEM
 config MSCC_OCELOT_SWITCH_LIB
+       select NET_DEVLINK
        select REGMAP_MMIO
        select PACKING
        select PHYLIB
index c3ac026f6aea2bc270e32d77789ff7481e367a63..a41b458b1b3ef09fdb6933384a19ed917f104746 100644 (file)
@@ -540,13 +540,14 @@ ocelot_flower_parse_key(struct ocelot *ocelot, int port, bool ingress,
                        return -EOPNOTSUPP;
                }
 
+               flow_rule_match_ipv4_addrs(rule, &match);
+
                if (filter->block_id == VCAP_IS1 && *(u32 *)&match.mask->dst) {
                        NL_SET_ERR_MSG_MOD(extack,
                                           "Key type S1_NORMAL cannot match on destination IP");
                        return -EOPNOTSUPP;
                }
 
-               flow_rule_match_ipv4_addrs(rule, &match);
                tmp = &filter->key.ipv4.sip.value.addr[0];
                memcpy(tmp, &match.key->src, 4);
 
index f704da3f214c04d3f43c344a98806f0a1b25a966..7aad0ba53372cb5cd5765d5819d5f61935a2a2da 100644 (file)
@@ -767,7 +767,7 @@ static void r8168fp_adjust_ocp_cmd(struct rtl8169_private *tp, u32 *cmd, int typ
        if (type == ERIAR_OOB &&
            (tp->mac_version == RTL_GIGA_MAC_VER_52 ||
             tp->mac_version == RTL_GIGA_MAC_VER_53))
-               *cmd |= 0x7f0 << 18;
+               *cmd |= 0xf70 << 18;
 }
 
 DECLARE_RTL_COND(rtl_eriar_cond)
index 590b088bc4c7f3e2f0d6d79443fcff6a6f4da077..f029c7c03804f916e9ff134475f14ecd8a0d0058 100644 (file)
@@ -560,6 +560,8 @@ static struct sh_eth_cpu_data r7s72100_data = {
                          EESR_TDE,
        .fdr_value      = 0x0000070f,
 
+       .trscer_err_mask = DESC_I_RINT8 | DESC_I_RINT5,
+
        .no_psr         = 1,
        .apr            = 1,
        .mpr            = 1,
@@ -780,6 +782,8 @@ static struct sh_eth_cpu_data r7s9210_data = {
 
        .fdr_value      = 0x0000070f,
 
+       .trscer_err_mask = DESC_I_RINT8 | DESC_I_RINT5,
+
        .apr            = 1,
        .mpr            = 1,
        .tpauser        = 1,
@@ -1089,6 +1093,9 @@ static struct sh_eth_cpu_data sh771x_data = {
                          EESIPR_CEEFIP | EESIPR_CELFIP |
                          EESIPR_RRFIP | EESIPR_RTLFIP | EESIPR_RTSFIP |
                          EESIPR_PREIP | EESIPR_CERFIP,
+
+       .trscer_err_mask = DESC_I_RINT8,
+
        .tsu            = 1,
        .dual_port      = 1,
 };
index 751dfdeec41c04949430884f98d286238490ac1b..0b64f7710d174836e540fef7473ef6a80e010bda 100644 (file)
@@ -233,6 +233,7 @@ static void common_default_data(struct plat_stmmacenet_data *plat)
 static int intel_mgbe_common_data(struct pci_dev *pdev,
                                  struct plat_stmmacenet_data *plat)
 {
+       char clk_name[20];
        int ret;
        int i;
 
@@ -301,8 +302,10 @@ static int intel_mgbe_common_data(struct pci_dev *pdev,
        plat->eee_usecs_rate = plat->clk_ptp_rate;
 
        /* Set system clock */
+       sprintf(clk_name, "%s-%s", "stmmac", pci_name(pdev));
+
        plat->stmmac_clk = clk_register_fixed_rate(&pdev->dev,
-                                                  "stmmac-clk", NULL, 0,
+                                                  clk_name, NULL, 0,
                                                   plat->clk_ptp_rate);
 
        if (IS_ERR(plat->stmmac_clk)) {
@@ -446,8 +449,8 @@ static int tgl_common_data(struct pci_dev *pdev,
        return intel_mgbe_common_data(pdev, plat);
 }
 
-static int tgl_sgmii_data(struct pci_dev *pdev,
-                         struct plat_stmmacenet_data *plat)
+static int tgl_sgmii_phy0_data(struct pci_dev *pdev,
+                              struct plat_stmmacenet_data *plat)
 {
        plat->bus_id = 1;
        plat->phy_interface = PHY_INTERFACE_MODE_SGMII;
@@ -456,12 +459,26 @@ static int tgl_sgmii_data(struct pci_dev *pdev,
        return tgl_common_data(pdev, plat);
 }
 
-static struct stmmac_pci_info tgl_sgmii1g_info = {
-       .setup = tgl_sgmii_data,
+static struct stmmac_pci_info tgl_sgmii1g_phy0_info = {
+       .setup = tgl_sgmii_phy0_data,
 };
 
-static int adls_sgmii_data(struct pci_dev *pdev,
-                          struct plat_stmmacenet_data *plat)
+static int tgl_sgmii_phy1_data(struct pci_dev *pdev,
+                              struct plat_stmmacenet_data *plat)
+{
+       plat->bus_id = 2;
+       plat->phy_interface = PHY_INTERFACE_MODE_SGMII;
+       plat->serdes_powerup = intel_serdes_powerup;
+       plat->serdes_powerdown = intel_serdes_powerdown;
+       return tgl_common_data(pdev, plat);
+}
+
+static struct stmmac_pci_info tgl_sgmii1g_phy1_info = {
+       .setup = tgl_sgmii_phy1_data,
+};
+
+static int adls_sgmii_phy0_data(struct pci_dev *pdev,
+                               struct plat_stmmacenet_data *plat)
 {
        plat->bus_id = 1;
        plat->phy_interface = PHY_INTERFACE_MODE_SGMII;
@@ -471,10 +488,24 @@ static int adls_sgmii_data(struct pci_dev *pdev,
        return tgl_common_data(pdev, plat);
 }
 
-static struct stmmac_pci_info adls_sgmii1g_info = {
-       .setup = adls_sgmii_data,
+static struct stmmac_pci_info adls_sgmii1g_phy0_info = {
+       .setup = adls_sgmii_phy0_data,
 };
 
+static int adls_sgmii_phy1_data(struct pci_dev *pdev,
+                               struct plat_stmmacenet_data *plat)
+{
+       plat->bus_id = 2;
+       plat->phy_interface = PHY_INTERFACE_MODE_SGMII;
+
+       /* SerDes power up and power down are done in BIOS for ADL */
+
+       return tgl_common_data(pdev, plat);
+}
+
+static struct stmmac_pci_info adls_sgmii1g_phy1_info = {
+       .setup = adls_sgmii_phy1_data,
+};
 static const struct stmmac_pci_func_data galileo_stmmac_func_data[] = {
        {
                .func = 6,
@@ -756,11 +787,11 @@ static const struct pci_device_id intel_eth_pci_id_table[] = {
        { PCI_DEVICE_DATA(INTEL, EHL_PSE1_RGMII1G_ID, &ehl_pse1_rgmii1g_info) },
        { PCI_DEVICE_DATA(INTEL, EHL_PSE1_SGMII1G_ID, &ehl_pse1_sgmii1g_info) },
        { PCI_DEVICE_DATA(INTEL, EHL_PSE1_SGMII2G5_ID, &ehl_pse1_sgmii1g_info) },
-       { PCI_DEVICE_DATA(INTEL, TGL_SGMII1G_ID, &tgl_sgmii1g_info) },
-       { PCI_DEVICE_DATA(INTEL, TGLH_SGMII1G_0_ID, &tgl_sgmii1g_info) },
-       { PCI_DEVICE_DATA(INTEL, TGLH_SGMII1G_1_ID, &tgl_sgmii1g_info) },
-       { PCI_DEVICE_DATA(INTEL, ADLS_SGMII1G_0_ID, &adls_sgmii1g_info) },
-       { PCI_DEVICE_DATA(INTEL, ADLS_SGMII1G_1_ID, &adls_sgmii1g_info) },
+       { PCI_DEVICE_DATA(INTEL, TGL_SGMII1G_ID, &tgl_sgmii1g_phy0_info) },
+       { PCI_DEVICE_DATA(INTEL, TGLH_SGMII1G_0_ID, &tgl_sgmii1g_phy0_info) },
+       { PCI_DEVICE_DATA(INTEL, TGLH_SGMII1G_1_ID, &tgl_sgmii1g_phy1_info) },
+       { PCI_DEVICE_DATA(INTEL, ADLS_SGMII1G_0_ID, &adls_sgmii1g_phy0_info) },
+       { PCI_DEVICE_DATA(INTEL, ADLS_SGMII1G_1_ID, &adls_sgmii1g_phy1_info) },
        {}
 };
 MODULE_DEVICE_TABLE(pci, intel_eth_pci_id_table);
index c6540b003b430b05301756a67dc876741e7965dc..cbf4429fb1d232f15f3371b5e841399538af70dd 100644 (file)
@@ -402,19 +402,53 @@ static void dwmac4_rd_set_tx_ic(struct dma_desc *p)
        p->des2 |= cpu_to_le32(TDES2_INTERRUPT_ON_COMPLETION);
 }
 
-static void dwmac4_display_ring(void *head, unsigned int size, bool rx)
+static void dwmac4_display_ring(void *head, unsigned int size, bool rx,
+                               dma_addr_t dma_rx_phy, unsigned int desc_size)
 {
-       struct dma_desc *p = (struct dma_desc *)head;
+       dma_addr_t dma_addr;
        int i;
 
        pr_info("%s descriptor ring:\n", rx ? "RX" : "TX");
 
-       for (i = 0; i < size; i++) {
-               pr_info("%03d [0x%x]: 0x%x 0x%x 0x%x 0x%x\n",
-                       i, (unsigned int)virt_to_phys(p),
-                       le32_to_cpu(p->des0), le32_to_cpu(p->des1),
-                       le32_to_cpu(p->des2), le32_to_cpu(p->des3));
-               p++;
+       if (desc_size == sizeof(struct dma_desc)) {
+               struct dma_desc *p = (struct dma_desc *)head;
+
+               for (i = 0; i < size; i++) {
+                       dma_addr = dma_rx_phy + i * sizeof(*p);
+                       pr_info("%03d [%pad]: 0x%x 0x%x 0x%x 0x%x\n",
+                               i, &dma_addr,
+                               le32_to_cpu(p->des0), le32_to_cpu(p->des1),
+                               le32_to_cpu(p->des2), le32_to_cpu(p->des3));
+                       p++;
+               }
+       } else if (desc_size == sizeof(struct dma_extended_desc)) {
+               struct dma_extended_desc *extp = (struct dma_extended_desc *)head;
+
+               for (i = 0; i < size; i++) {
+                       dma_addr = dma_rx_phy + i * sizeof(*extp);
+                       pr_info("%03d [%pad]: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
+                               i, &dma_addr,
+                               le32_to_cpu(extp->basic.des0), le32_to_cpu(extp->basic.des1),
+                               le32_to_cpu(extp->basic.des2), le32_to_cpu(extp->basic.des3),
+                               le32_to_cpu(extp->des4), le32_to_cpu(extp->des5),
+                               le32_to_cpu(extp->des6), le32_to_cpu(extp->des7));
+                       extp++;
+               }
+       } else if (desc_size == sizeof(struct dma_edesc)) {
+               struct dma_edesc *ep = (struct dma_edesc *)head;
+
+               for (i = 0; i < size; i++) {
+                       dma_addr = dma_rx_phy + i * sizeof(*ep);
+                       pr_info("%03d [%pad]: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
+                               i, &dma_addr,
+                               le32_to_cpu(ep->des4), le32_to_cpu(ep->des5),
+                               le32_to_cpu(ep->des6), le32_to_cpu(ep->des7),
+                               le32_to_cpu(ep->basic.des0), le32_to_cpu(ep->basic.des1),
+                               le32_to_cpu(ep->basic.des2), le32_to_cpu(ep->basic.des3));
+                       ep++;
+               }
+       } else {
+               pr_err("unsupported descriptor!");
        }
 }
 
@@ -499,10 +533,15 @@ static void dwmac4_get_rx_header_len(struct dma_desc *p, unsigned int *len)
        *len = le32_to_cpu(p->des2) & RDES2_HL;
 }
 
-static void dwmac4_set_sec_addr(struct dma_desc *p, dma_addr_t addr)
+static void dwmac4_set_sec_addr(struct dma_desc *p, dma_addr_t addr, bool buf2_valid)
 {
        p->des2 = cpu_to_le32(lower_32_bits(addr));
-       p->des3 = cpu_to_le32(upper_32_bits(addr) | RDES3_BUFFER2_VALID_ADDR);
+       p->des3 = cpu_to_le32(upper_32_bits(addr));
+
+       if (buf2_valid)
+               p->des3 |= cpu_to_le32(RDES3_BUFFER2_VALID_ADDR);
+       else
+               p->des3 &= cpu_to_le32(~RDES3_BUFFER2_VALID_ADDR);
 }
 
 static void dwmac4_set_tbs(struct dma_edesc *p, u32 sec, u32 nsec)
index bb29bfcd62c347cda7a9a93fa932568c2828de7a..62aa0e95beb709a65faefba7cafae6e9b6105ddc 100644 (file)
@@ -124,6 +124,23 @@ static void dwmac4_dma_init_channel(void __iomem *ioaddr,
               ioaddr + DMA_CHAN_INTR_ENA(chan));
 }
 
+static void dwmac410_dma_init_channel(void __iomem *ioaddr,
+                                     struct stmmac_dma_cfg *dma_cfg, u32 chan)
+{
+       u32 value;
+
+       /* common channel control register config */
+       value = readl(ioaddr + DMA_CHAN_CONTROL(chan));
+       if (dma_cfg->pblx8)
+               value = value | DMA_BUS_MODE_PBL;
+
+       writel(value, ioaddr + DMA_CHAN_CONTROL(chan));
+
+       /* Mask interrupts by writing to CSR7 */
+       writel(DMA_CHAN_INTR_DEFAULT_MASK_4_10,
+              ioaddr + DMA_CHAN_INTR_ENA(chan));
+}
+
 static void dwmac4_dma_init(void __iomem *ioaddr,
                            struct stmmac_dma_cfg *dma_cfg, int atds)
 {
@@ -523,7 +540,7 @@ const struct stmmac_dma_ops dwmac4_dma_ops = {
 const struct stmmac_dma_ops dwmac410_dma_ops = {
        .reset = dwmac4_dma_reset,
        .init = dwmac4_dma_init,
-       .init_chan = dwmac4_dma_init_channel,
+       .init_chan = dwmac410_dma_init_channel,
        .init_rx_chan = dwmac4_dma_init_rx_chan,
        .init_tx_chan = dwmac4_dma_init_tx_chan,
        .axi = dwmac4_dma_axi,
index 0b4ee2dbb691d3c0112e9f56e8ce294317bb45e6..71e50751ef2dc2c6ba3d1a133edb3663dc5a6968 100644 (file)
@@ -53,10 +53,6 @@ void dwmac4_dma_stop_tx(void __iomem *ioaddr, u32 chan)
 
        value &= ~DMA_CONTROL_ST;
        writel(value, ioaddr + DMA_CHAN_TX_CONTROL(chan));
-
-       value = readl(ioaddr + GMAC_CONFIG);
-       value &= ~GMAC_CONFIG_TE;
-       writel(value, ioaddr + GMAC_CONFIG);
 }
 
 void dwmac4_dma_start_rx(void __iomem *ioaddr, u32 chan)
index 0aaf19ab56729555b15de680622d21deb38c2ecf..ccfb0102dde492657e70cc6958edc428158be8d4 100644 (file)
@@ -292,7 +292,7 @@ static void dwxgmac2_get_rx_header_len(struct dma_desc *p, unsigned int *len)
                *len = le32_to_cpu(p->des2) & XGMAC_RDES2_HL;
 }
 
-static void dwxgmac2_set_sec_addr(struct dma_desc *p, dma_addr_t addr)
+static void dwxgmac2_set_sec_addr(struct dma_desc *p, dma_addr_t addr, bool is_valid)
 {
        p->des2 = cpu_to_le32(lower_32_bits(addr));
        p->des3 = cpu_to_le32(upper_32_bits(addr));
index d02cec296f51e078a7da9838fba7d5afd0b0404f..6650edfab5bc488b041be84e261e7c2d8a20a37f 100644 (file)
@@ -417,19 +417,22 @@ static int enh_desc_get_rx_timestamp_status(void *desc, void *next_desc,
        }
 }
 
-static void enh_desc_display_ring(void *head, unsigned int size, bool rx)
+static void enh_desc_display_ring(void *head, unsigned int size, bool rx,
+                                 dma_addr_t dma_rx_phy, unsigned int desc_size)
 {
        struct dma_extended_desc *ep = (struct dma_extended_desc *)head;
+       dma_addr_t dma_addr;
        int i;
 
        pr_info("Extended %s descriptor ring:\n", rx ? "RX" : "TX");
 
        for (i = 0; i < size; i++) {
                u64 x;
+               dma_addr = dma_rx_phy + i * sizeof(*ep);
 
                x = *(u64 *)ep;
-               pr_info("%03d [0x%x]: 0x%x 0x%x 0x%x 0x%x\n",
-                       i, (unsigned int)virt_to_phys(ep),
+               pr_info("%03d [%pad]: 0x%x 0x%x 0x%x 0x%x\n",
+                       i, &dma_addr,
                        (unsigned int)x, (unsigned int)(x >> 32),
                        ep->basic.des2, ep->basic.des3);
                ep++;
index b40b2e0667bbae44a50221762b9d6eb506b7fcb1..979ac9fca23c7bb1434a5c3f0717c035ee18f1c9 100644 (file)
@@ -78,7 +78,8 @@ struct stmmac_desc_ops {
        /* get rx timestamp status */
        int (*get_rx_timestamp_status)(void *desc, void *next_desc, u32 ats);
        /* Display ring */
-       void (*display_ring)(void *head, unsigned int size, bool rx);
+       void (*display_ring)(void *head, unsigned int size, bool rx,
+                            dma_addr_t dma_rx_phy, unsigned int desc_size);
        /* set MSS via context descriptor */
        void (*set_mss)(struct dma_desc *p, unsigned int mss);
        /* get descriptor skbuff address */
@@ -91,7 +92,7 @@ struct stmmac_desc_ops {
        int (*get_rx_hash)(struct dma_desc *p, u32 *hash,
                           enum pkt_hash_types *type);
        void (*get_rx_header_len)(struct dma_desc *p, unsigned int *len);
-       void (*set_sec_addr)(struct dma_desc *p, dma_addr_t addr);
+       void (*set_sec_addr)(struct dma_desc *p, dma_addr_t addr, bool buf2_valid);
        void (*set_sarc)(struct dma_desc *p, u32 sarc_type);
        void (*set_vlan_tag)(struct dma_desc *p, u16 tag, u16 inner_tag,
                             u32 inner_type);
index f083360e4ba67f126b3e719e81a5f21f9b3903cc..98ef43f35802adfa50aa5e55bf5ce0d5e407acae 100644 (file)
@@ -269,19 +269,22 @@ static int ndesc_get_rx_timestamp_status(void *desc, void *next_desc, u32 ats)
                return 1;
 }
 
-static void ndesc_display_ring(void *head, unsigned int size, bool rx)
+static void ndesc_display_ring(void *head, unsigned int size, bool rx,
+                              dma_addr_t dma_rx_phy, unsigned int desc_size)
 {
        struct dma_desc *p = (struct dma_desc *)head;
+       dma_addr_t dma_addr;
        int i;
 
        pr_info("%s descriptor ring:\n", rx ? "RX" : "TX");
 
        for (i = 0; i < size; i++) {
                u64 x;
+               dma_addr = dma_rx_phy + i * sizeof(*p);
 
                x = *(u64 *)p;
-               pr_info("%03d [0x%x]: 0x%x 0x%x 0x%x 0x%x",
-                       i, (unsigned int)virt_to_phys(p),
+               pr_info("%03d [%pad]: 0x%x 0x%x 0x%x 0x%x",
+                       i, &dma_addr,
                        (unsigned int)x, (unsigned int)(x >> 32),
                        p->des2, p->des3);
                p++;
index 26b971cd4da5abfb8407fe9b8bf3aa63c6f87c52..208cae344ffa26432885dea59be676fa1b6dca9e 100644 (file)
@@ -1133,6 +1133,7 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
 static void stmmac_display_rx_rings(struct stmmac_priv *priv)
 {
        u32 rx_cnt = priv->plat->rx_queues_to_use;
+       unsigned int desc_size;
        void *head_rx;
        u32 queue;
 
@@ -1142,19 +1143,24 @@ static void stmmac_display_rx_rings(struct stmmac_priv *priv)
 
                pr_info("\tRX Queue %u rings\n", queue);
 
-               if (priv->extend_desc)
+               if (priv->extend_desc) {
                        head_rx = (void *)rx_q->dma_erx;
-               else
+                       desc_size = sizeof(struct dma_extended_desc);
+               } else {
                        head_rx = (void *)rx_q->dma_rx;
+                       desc_size = sizeof(struct dma_desc);
+               }
 
                /* Display RX ring */
-               stmmac_display_ring(priv, head_rx, priv->dma_rx_size, true);
+               stmmac_display_ring(priv, head_rx, priv->dma_rx_size, true,
+                                   rx_q->dma_rx_phy, desc_size);
        }
 }
 
 static void stmmac_display_tx_rings(struct stmmac_priv *priv)
 {
        u32 tx_cnt = priv->plat->tx_queues_to_use;
+       unsigned int desc_size;
        void *head_tx;
        u32 queue;
 
@@ -1164,14 +1170,19 @@ static void stmmac_display_tx_rings(struct stmmac_priv *priv)
 
                pr_info("\tTX Queue %d rings\n", queue);
 
-               if (priv->extend_desc)
+               if (priv->extend_desc) {
                        head_tx = (void *)tx_q->dma_etx;
-               else if (tx_q->tbs & STMMAC_TBS_AVAIL)
+                       desc_size = sizeof(struct dma_extended_desc);
+               } else if (tx_q->tbs & STMMAC_TBS_AVAIL) {
                        head_tx = (void *)tx_q->dma_entx;
-               else
+                       desc_size = sizeof(struct dma_edesc);
+               } else {
                        head_tx = (void *)tx_q->dma_tx;
+                       desc_size = sizeof(struct dma_desc);
+               }
 
-               stmmac_display_ring(priv, head_tx, priv->dma_tx_size, false);
+               stmmac_display_ring(priv, head_tx, priv->dma_tx_size, false,
+                                   tx_q->dma_tx_phy, desc_size);
        }
 }
 
@@ -1303,9 +1314,10 @@ static int stmmac_init_rx_buffers(struct stmmac_priv *priv, struct dma_desc *p,
                        return -ENOMEM;
 
                buf->sec_addr = page_pool_get_dma_addr(buf->sec_page);
-               stmmac_set_desc_sec_addr(priv, p, buf->sec_addr);
+               stmmac_set_desc_sec_addr(priv, p, buf->sec_addr, true);
        } else {
                buf->sec_page = NULL;
+               stmmac_set_desc_sec_addr(priv, p, buf->sec_addr, false);
        }
 
        buf->addr = page_pool_get_dma_addr(buf->page);
@@ -1367,6 +1379,88 @@ static void stmmac_free_tx_buffer(struct stmmac_priv *priv, u32 queue, int i)
        }
 }
 
+/**
+ * stmmac_reinit_rx_buffers - reinit the RX descriptor buffer.
+ * @priv: driver private structure
+ * Description: this function is called to re-allocate a receive buffer, perform
+ * the DMA mapping and init the descriptor.
+ */
+static void stmmac_reinit_rx_buffers(struct stmmac_priv *priv)
+{
+       u32 rx_count = priv->plat->rx_queues_to_use;
+       u32 queue;
+       int i;
+
+       for (queue = 0; queue < rx_count; queue++) {
+               struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue];
+
+               for (i = 0; i < priv->dma_rx_size; i++) {
+                       struct stmmac_rx_buffer *buf = &rx_q->buf_pool[i];
+
+                       if (buf->page) {
+                               page_pool_recycle_direct(rx_q->page_pool, buf->page);
+                               buf->page = NULL;
+                       }
+
+                       if (priv->sph && buf->sec_page) {
+                               page_pool_recycle_direct(rx_q->page_pool, buf->sec_page);
+                               buf->sec_page = NULL;
+                       }
+               }
+       }
+
+       for (queue = 0; queue < rx_count; queue++) {
+               struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue];
+
+               for (i = 0; i < priv->dma_rx_size; i++) {
+                       struct stmmac_rx_buffer *buf = &rx_q->buf_pool[i];
+                       struct dma_desc *p;
+
+                       if (priv->extend_desc)
+                               p = &((rx_q->dma_erx + i)->basic);
+                       else
+                               p = rx_q->dma_rx + i;
+
+                       if (!buf->page) {
+                               buf->page = page_pool_dev_alloc_pages(rx_q->page_pool);
+                               if (!buf->page)
+                                       goto err_reinit_rx_buffers;
+
+                               buf->addr = page_pool_get_dma_addr(buf->page);
+                       }
+
+                       if (priv->sph && !buf->sec_page) {
+                               buf->sec_page = page_pool_dev_alloc_pages(rx_q->page_pool);
+                               if (!buf->sec_page)
+                                       goto err_reinit_rx_buffers;
+
+                               buf->sec_addr = page_pool_get_dma_addr(buf->sec_page);
+                       }
+
+                       stmmac_set_desc_addr(priv, p, buf->addr);
+                       if (priv->sph)
+                               stmmac_set_desc_sec_addr(priv, p, buf->sec_addr, true);
+                       else
+                               stmmac_set_desc_sec_addr(priv, p, buf->sec_addr, false);
+                       if (priv->dma_buf_sz == BUF_SIZE_16KiB)
+                               stmmac_init_desc3(priv, p);
+               }
+       }
+
+       return;
+
+err_reinit_rx_buffers:
+       do {
+               while (--i >= 0)
+                       stmmac_free_rx_buffer(priv, queue, i);
+
+               if (queue == 0)
+                       break;
+
+               i = priv->dma_rx_size;
+       } while (queue-- > 0);
+}
+
 /**
  * init_dma_rx_desc_rings - init the RX descriptor rings
  * @dev: net device structure
@@ -3648,7 +3742,10 @@ static inline void stmmac_rx_refill(struct stmmac_priv *priv, u32 queue)
                                           DMA_FROM_DEVICE);
 
                stmmac_set_desc_addr(priv, p, buf->addr);
-               stmmac_set_desc_sec_addr(priv, p, buf->sec_addr);
+               if (priv->sph)
+                       stmmac_set_desc_sec_addr(priv, p, buf->sec_addr, true);
+               else
+                       stmmac_set_desc_sec_addr(priv, p, buf->sec_addr, false);
                stmmac_refill_desc3(priv, rx_q, p);
 
                rx_q->rx_count_frames++;
@@ -3736,18 +3833,23 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
        unsigned int count = 0, error = 0, len = 0;
        int status = 0, coe = priv->hw->rx_csum;
        unsigned int next_entry = rx_q->cur_rx;
+       unsigned int desc_size;
        struct sk_buff *skb = NULL;
 
        if (netif_msg_rx_status(priv)) {
                void *rx_head;
 
                netdev_dbg(priv->dev, "%s: descriptor ring:\n", __func__);
-               if (priv->extend_desc)
+               if (priv->extend_desc) {
                        rx_head = (void *)rx_q->dma_erx;
-               else
+                       desc_size = sizeof(struct dma_extended_desc);
+               } else {
                        rx_head = (void *)rx_q->dma_rx;
+                       desc_size = sizeof(struct dma_desc);
+               }
 
-               stmmac_display_ring(priv, rx_head, priv->dma_rx_size, true);
+               stmmac_display_ring(priv, rx_head, priv->dma_rx_size, true,
+                                   rx_q->dma_rx_phy, desc_size);
        }
        while (count < limit) {
                unsigned int buf1_len = 0, buf2_len = 0;
@@ -4315,24 +4417,27 @@ static int stmmac_set_mac_address(struct net_device *ndev, void *addr)
 static struct dentry *stmmac_fs_dir;
 
 static void sysfs_display_ring(void *head, int size, int extend_desc,
-                              struct seq_file *seq)
+                              struct seq_file *seq, dma_addr_t dma_phy_addr)
 {
        int i;
        struct dma_extended_desc *ep = (struct dma_extended_desc *)head;
        struct dma_desc *p = (struct dma_desc *)head;
+       dma_addr_t dma_addr;
 
        for (i = 0; i < size; i++) {
                if (extend_desc) {
-                       seq_printf(seq, "%d [0x%x]: 0x%x 0x%x 0x%x 0x%x\n",
-                                  i, (unsigned int)virt_to_phys(ep),
+                       dma_addr = dma_phy_addr + i * sizeof(*ep);
+                       seq_printf(seq, "%d [%pad]: 0x%x 0x%x 0x%x 0x%x\n",
+                                  i, &dma_addr,
                                   le32_to_cpu(ep->basic.des0),
                                   le32_to_cpu(ep->basic.des1),
                                   le32_to_cpu(ep->basic.des2),
                                   le32_to_cpu(ep->basic.des3));
                        ep++;
                } else {
-                       seq_printf(seq, "%d [0x%x]: 0x%x 0x%x 0x%x 0x%x\n",
-                                  i, (unsigned int)virt_to_phys(p),
+                       dma_addr = dma_phy_addr + i * sizeof(*p);
+                       seq_printf(seq, "%d [%pad]: 0x%x 0x%x 0x%x 0x%x\n",
+                                  i, &dma_addr,
                                   le32_to_cpu(p->des0), le32_to_cpu(p->des1),
                                   le32_to_cpu(p->des2), le32_to_cpu(p->des3));
                        p++;
@@ -4360,11 +4465,11 @@ static int stmmac_rings_status_show(struct seq_file *seq, void *v)
                if (priv->extend_desc) {
                        seq_printf(seq, "Extended descriptor ring:\n");
                        sysfs_display_ring((void *)rx_q->dma_erx,
-                                          priv->dma_rx_size, 1, seq);
+                                          priv->dma_rx_size, 1, seq, rx_q->dma_rx_phy);
                } else {
                        seq_printf(seq, "Descriptor ring:\n");
                        sysfs_display_ring((void *)rx_q->dma_rx,
-                                          priv->dma_rx_size, 0, seq);
+                                          priv->dma_rx_size, 0, seq, rx_q->dma_rx_phy);
                }
        }
 
@@ -4376,11 +4481,11 @@ static int stmmac_rings_status_show(struct seq_file *seq, void *v)
                if (priv->extend_desc) {
                        seq_printf(seq, "Extended descriptor ring:\n");
                        sysfs_display_ring((void *)tx_q->dma_etx,
-                                          priv->dma_tx_size, 1, seq);
+                                          priv->dma_tx_size, 1, seq, tx_q->dma_tx_phy);
                } else if (!(tx_q->tbs & STMMAC_TBS_AVAIL)) {
                        seq_printf(seq, "Descriptor ring:\n");
                        sysfs_display_ring((void *)tx_q->dma_tx,
-                                          priv->dma_tx_size, 0, seq);
+                                          priv->dma_tx_size, 0, seq, tx_q->dma_tx_phy);
                }
        }
 
@@ -5144,13 +5249,16 @@ int stmmac_dvr_remove(struct device *dev)
        netdev_info(priv->dev, "%s: removing driver", __func__);
 
        stmmac_stop_all_dma(priv);
+       stmmac_mac_set(priv, priv->ioaddr, false);
+       netif_carrier_off(ndev);
+       unregister_netdev(ndev);
 
+       /* Serdes power down needs to happen after VLAN filter
+        * is deleted that is triggered by unregister_netdev().
+        */
        if (priv->plat->serdes_powerdown)
                priv->plat->serdes_powerdown(ndev, priv->plat->bsp_priv);
 
-       stmmac_mac_set(priv, priv->ioaddr, false);
-       netif_carrier_off(ndev);
-       unregister_netdev(ndev);
 #ifdef CONFIG_DEBUG_FS
        stmmac_exit_fs(ndev);
 #endif
@@ -5257,6 +5365,8 @@ static void stmmac_reset_queues_param(struct stmmac_priv *priv)
                tx_q->cur_tx = 0;
                tx_q->dirty_tx = 0;
                tx_q->mss = 0;
+
+               netdev_tx_reset_queue(netdev_get_tx_queue(priv->dev, queue));
        }
 }
 
@@ -5318,7 +5428,7 @@ int stmmac_resume(struct device *dev)
        mutex_lock(&priv->lock);
 
        stmmac_reset_queues_param(priv);
-
+       stmmac_reinit_rx_buffers(priv);
        stmmac_free_tx_skbufs(priv);
        stmmac_clear_descriptors(priv);
 
index 68695d4afacd542a7d8d51d18da7a07918f72575..707ccdd03b19eea1de7c818bd6ead715a2da7393 100644 (file)
@@ -3931,8 +3931,6 @@ static void niu_xmac_interrupt(struct niu *np)
                mp->rx_mcasts += RXMAC_MC_FRM_CNT_COUNT;
        if (val & XRXMAC_STATUS_RXBCAST_CNT_EXP)
                mp->rx_bcasts += RXMAC_BC_FRM_CNT_COUNT;
-       if (val & XRXMAC_STATUS_RXBCAST_CNT_EXP)
-               mp->rx_bcasts += RXMAC_BC_FRM_CNT_COUNT;
        if (val & XRXMAC_STATUS_RXHIST1_CNT_EXP)
                mp->rx_hist_cnt1 += RXMAC_HIST_CNT1_COUNT;
        if (val & XRXMAC_STATUS_RXHIST2_CNT_EXP)
index b8f4f419173f974fd6ff1f04a1ab660ba896ebfc..d054c6e83b1c92184fe4b12227aff2ea72d6ad2a 100644 (file)
@@ -2044,6 +2044,7 @@ bdx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                /*bdx_hw_reset(priv); */
                if (bdx_read_mac(priv)) {
                        pr_err("load MAC address failed\n");
+                       err = -EFAULT;
                        goto err_out_iomap;
                }
                SET_NETDEV_DEV(ndev, &pdev->dev);
index 71d6629e65c970e7e133cfa615aa01341a68d43f..9f5b5614a1503734e201d14e8524b74db6e8e884 100644 (file)
@@ -171,11 +171,6 @@ static void sp_encaps(struct sixpack *sp, unsigned char *icp, int len)
                goto out_drop;
        }
 
-       if (len > sp->mtu) {    /* sp->mtu = AX25_MTU = max. PACLEN = 256 */
-               msg = "oversized transmit packet!";
-               goto out_drop;
-       }
-
        if (p[0] > 5) {
                msg = "invalid KISS command";
                goto out_drop;
index 36eeb80406f2b887046bd523f2bbfd8141316260..4690c6a590548ed2352bf4680e2af9437d01847a 100644 (file)
@@ -2167,7 +2167,6 @@ static void __exit scc_cleanup_driver(void)
 
 MODULE_AUTHOR("Joerg Reuter <jreuter@yaina.de>");
 MODULE_DESCRIPTION("AX.25 Device Driver for Z8530 based HDLC cards");
-MODULE_SUPPORTED_DEVICE("Z8530 based SCC cards for Amateur Radio");
 MODULE_LICENSE("GPL");
 module_init(scc_init_driver);
 module_exit(scc_cleanup_driver);
index e1a497d3c9ba427fa8e9fea9262225cc34f5bb5c..59ac04a610adbf6670611a2db7b1d7cdeb2474b4 100644 (file)
@@ -229,7 +229,7 @@ int netvsc_send(struct net_device *net,
                bool xdp_tx);
 void netvsc_linkstatus_callback(struct net_device *net,
                                struct rndis_message *resp,
-                               void *data);
+                               void *data, u32 data_buflen);
 int netvsc_recv_callback(struct net_device *net,
                         struct netvsc_device *nvdev,
                         struct netvsc_channel *nvchan);
index 8176fa0c8b16868efb49573c53c7d6db9e7340fd..15f262b70489e3b6475d3a4af82273130467ddd0 100644 (file)
@@ -744,7 +744,7 @@ static netdev_tx_t netvsc_start_xmit(struct sk_buff *skb,
  */
 void netvsc_linkstatus_callback(struct net_device *net,
                                struct rndis_message *resp,
-                               void *data)
+                               void *data, u32 data_buflen)
 {
        struct rndis_indicate_status *indicate = &resp->msg.indicate_status;
        struct net_device_context *ndev_ctx = netdev_priv(net);
@@ -765,11 +765,16 @@ void netvsc_linkstatus_callback(struct net_device *net,
        if (indicate->status == RNDIS_STATUS_LINK_SPEED_CHANGE) {
                u32 speed;
 
-               /* Validate status_buf_offset */
+               /* Validate status_buf_offset and status_buflen.
+                *
+                * Certain (pre-Fe) implementations of Hyper-V's vSwitch didn't account
+                * for the status buffer field in resp->msg_len; perform the validation
+                * using data_buflen (>= resp->msg_len).
+                */
                if (indicate->status_buflen < sizeof(speed) ||
                    indicate->status_buf_offset < sizeof(*indicate) ||
-                   resp->msg_len - RNDIS_HEADER_SIZE < indicate->status_buf_offset ||
-                   resp->msg_len - RNDIS_HEADER_SIZE - indicate->status_buf_offset
+                   data_buflen - RNDIS_HEADER_SIZE < indicate->status_buf_offset ||
+                   data_buflen - RNDIS_HEADER_SIZE - indicate->status_buf_offset
                                < indicate->status_buflen) {
                        netdev_err(net, "invalid rndis_indicate_status packet\n");
                        return;
index 123cc9d25f5ed52fa66698348aab827a263b4975..c0e89e107d575256573c70bde95f308a25c99c28 100644 (file)
@@ -620,7 +620,7 @@ int rndis_filter_receive(struct net_device *ndev,
 
        case RNDIS_MSG_INDICATE:
                /* notification msgs */
-               netvsc_linkstatus_callback(ndev, rndis_msg, data);
+               netvsc_linkstatus_callback(ndev, rndis_msg, data, buflen);
                break;
        default:
                netdev_err(ndev,
index aec92440eef16dc7b8b29a1649e1ea2a21e0aff0..659d3dceb687f368c2e6dd1c8c1e90016c91823d 100644 (file)
@@ -294,6 +294,7 @@ nsim_create(struct nsim_dev *nsim_dev, struct nsim_dev_port *nsim_dev_port)
        dev_net_set(dev, nsim_dev_net(nsim_dev));
        ns = netdev_priv(dev);
        ns->netdev = dev;
+       u64_stats_init(&ns->syncp);
        ns->nsim_dev = nsim_dev;
        ns->nsim_dev_port = nsim_dev_port;
        ns->nsim_bus_dev = nsim_dev->nsim_bus_dev;
index be1224b4447b40af8f608439c83930d689805ddc..f7a2ec150e542af3ff5ed1cd62a9fdae020868dd 100644 (file)
@@ -290,6 +290,7 @@ static int dp83822_config_intr(struct phy_device *phydev)
 
 static irqreturn_t dp83822_handle_interrupt(struct phy_device *phydev)
 {
+       bool trigger_machine = false;
        int irq_status;
 
        /* The MISR1 and MISR2 registers are holding the interrupt status in
@@ -305,7 +306,7 @@ static irqreturn_t dp83822_handle_interrupt(struct phy_device *phydev)
                return IRQ_NONE;
        }
        if (irq_status & ((irq_status & GENMASK(7, 0)) << 8))
-               goto trigger_machine;
+               trigger_machine = true;
 
        irq_status = phy_read(phydev, MII_DP83822_MISR2);
        if (irq_status < 0) {
@@ -313,11 +314,11 @@ static irqreturn_t dp83822_handle_interrupt(struct phy_device *phydev)
                return IRQ_NONE;
        }
        if (irq_status & ((irq_status & GENMASK(7, 0)) << 8))
-               goto trigger_machine;
+               trigger_machine = true;
 
-       return IRQ_NONE;
+       if (!trigger_machine)
+               return IRQ_NONE;
 
-trigger_machine:
        phy_trigger_machine(phydev);
 
        return IRQ_HANDLED;
index 688fadffb249daf35720cea2836e6f8d4f980252..7ea32fb77190c47544355d17edaffd8f9d9c7c23 100644 (file)
@@ -264,6 +264,7 @@ static int dp83811_config_intr(struct phy_device *phydev)
 
 static irqreturn_t dp83811_handle_interrupt(struct phy_device *phydev)
 {
+       bool trigger_machine = false;
        int irq_status;
 
        /* The INT_STAT registers 1, 2 and 3 are holding the interrupt status
@@ -279,7 +280,7 @@ static irqreturn_t dp83811_handle_interrupt(struct phy_device *phydev)
                return IRQ_NONE;
        }
        if (irq_status & ((irq_status & GENMASK(7, 0)) << 8))
-               goto trigger_machine;
+               trigger_machine = true;
 
        irq_status = phy_read(phydev, MII_DP83811_INT_STAT2);
        if (irq_status < 0) {
@@ -287,7 +288,7 @@ static irqreturn_t dp83811_handle_interrupt(struct phy_device *phydev)
                return IRQ_NONE;
        }
        if (irq_status & ((irq_status & GENMASK(7, 0)) << 8))
-               goto trigger_machine;
+               trigger_machine = true;
 
        irq_status = phy_read(phydev, MII_DP83811_INT_STAT3);
        if (irq_status < 0) {
@@ -295,11 +296,11 @@ static irqreturn_t dp83811_handle_interrupt(struct phy_device *phydev)
                return IRQ_NONE;
        }
        if (irq_status & ((irq_status & GENMASK(7, 0)) << 8))
-               goto trigger_machine;
+               trigger_machine = true;
 
-       return IRQ_NONE;
+       if (!trigger_machine)
+               return IRQ_NONE;
 
-trigger_machine:
        phy_trigger_machine(phydev);
 
        return IRQ_HANDLED;
index 1be07e45d314e5354bb1bfe31f4ea75431d991fd..fc2e7cb5b2e584030ee030311f3e365b02153646 100644 (file)
@@ -276,14 +276,16 @@ int phy_ethtool_ksettings_set(struct phy_device *phydev,
 
        phydev->autoneg = autoneg;
 
-       phydev->speed = speed;
+       if (autoneg == AUTONEG_DISABLE) {
+               phydev->speed = speed;
+               phydev->duplex = duplex;
+       }
 
        linkmode_copy(phydev->advertising, advertising);
 
        linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
                         phydev->advertising, autoneg == AUTONEG_ENABLE);
 
-       phydev->duplex = duplex;
        phydev->master_slave_set = cmd->base.master_slave_cfg;
        phydev->mdix_ctrl = cmd->base.eth_tp_mdix_ctrl;
 
index ce495473cd5dc80a0a85764fa998258b0067fbe4..cc38e326405a6585a7b602628ba61c51daa7912a 100644 (file)
@@ -230,7 +230,6 @@ static struct phy_driver genphy_driver;
 static LIST_HEAD(phy_fixup_list);
 static DEFINE_MUTEX(phy_fixup_lock);
 
-#ifdef CONFIG_PM
 static bool mdio_bus_phy_may_suspend(struct phy_device *phydev)
 {
        struct device_driver *drv = phydev->mdio.dev.driver;
@@ -270,7 +269,7 @@ out:
        return !phydev->suspended;
 }
 
-static int mdio_bus_phy_suspend(struct device *dev)
+static __maybe_unused int mdio_bus_phy_suspend(struct device *dev)
 {
        struct phy_device *phydev = to_phy_device(dev);
 
@@ -290,7 +289,7 @@ static int mdio_bus_phy_suspend(struct device *dev)
        return phy_suspend(phydev);
 }
 
-static int mdio_bus_phy_resume(struct device *dev)
+static __maybe_unused int mdio_bus_phy_resume(struct device *dev)
 {
        struct phy_device *phydev = to_phy_device(dev);
        int ret;
@@ -316,7 +315,6 @@ no_resume:
 
 static SIMPLE_DEV_PM_OPS(mdio_bus_phy_pm_ops, mdio_bus_phy_suspend,
                         mdio_bus_phy_resume);
-#endif /* CONFIG_PM */
 
 /**
  * phy_register_fixup - creates a new phy_fixup and adds it to the list
index 4087c9e337819b3bfe1679495a3215386f84c027..8acf3011542820114edc728d65cbd404ad9434f0 100644 (file)
@@ -851,17 +851,17 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
 
        /* check if we got everything */
        if (!ctx->data) {
-               dev_dbg(&intf->dev, "CDC Union missing and no IAD found\n");
+               dev_err(&intf->dev, "CDC Union missing and no IAD found\n");
                goto error;
        }
        if (cdc_ncm_comm_intf_is_mbim(intf->cur_altsetting)) {
                if (!ctx->mbim_desc) {
-                       dev_dbg(&intf->dev, "MBIM functional descriptor missing\n");
+                       dev_err(&intf->dev, "MBIM functional descriptor missing\n");
                        goto error;
                }
        } else {
                if (!ctx->ether_desc || !ctx->func_desc) {
-                       dev_dbg(&intf->dev, "NCM or ECM functional descriptors missing\n");
+                       dev_err(&intf->dev, "NCM or ECM functional descriptors missing\n");
                        goto error;
                }
        }
@@ -870,7 +870,7 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
        if (ctx->data != ctx->control) {
                temp = usb_driver_claim_interface(driver, ctx->data, dev);
                if (temp) {
-                       dev_dbg(&intf->dev, "failed to claim data intf\n");
+                       dev_err(&intf->dev, "failed to claim data intf\n");
                        goto error;
                }
        }
@@ -926,7 +926,7 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
        if (ctx->ether_desc) {
                temp = usbnet_get_ethernet_addr(dev, ctx->ether_desc->iMACAddress);
                if (temp) {
-                       dev_dbg(&intf->dev, "failed to get mac address\n");
+                       dev_err(&intf->dev, "failed to get mac address\n");
                        goto error2;
                }
                dev_info(&intf->dev, "MAC-Address: %pM\n", dev->net->dev_addr);
index 17a050521b866b44c6877c5ff78be5d79534b846..6700f1970b240bb53c372727efdb92f72854c7a5 100644 (file)
@@ -429,13 +429,6 @@ static ssize_t add_mux_store(struct device *d,  struct device_attribute *attr, c
                goto err;
        }
 
-       /* we don't want to modify a running netdev */
-       if (netif_running(dev->net)) {
-               netdev_err(dev->net, "Cannot change a running device\n");
-               ret = -EBUSY;
-               goto err;
-       }
-
        ret = qmimux_register_device(dev->net, mux_id);
        if (!ret) {
                info->flags |= QMI_WWAN_FLAG_MUX;
@@ -465,13 +458,6 @@ static ssize_t del_mux_store(struct device *d,  struct device_attribute *attr, c
        if (!rtnl_trylock())
                return restart_syscall();
 
-       /* we don't want to modify a running netdev */
-       if (netif_running(dev->net)) {
-               netdev_err(dev->net, "Cannot change a running device\n");
-               ret = -EBUSY;
-               goto err;
-       }
-
        del_dev = qmimux_find_dev(dev, mux_id);
        if (!del_dev) {
                netdev_err(dev->net, "mux_id not present\n");
index b246817f340574e684ee96f83132b15df7f1f742..90f1c020004257871d8a21ab88cc40dc37caf974 100644 (file)
@@ -3021,29 +3021,6 @@ static void __rtl_set_wol(struct r8152 *tp, u32 wolopts)
                device_set_wakeup_enable(&tp->udev->dev, false);
 }
 
-static void r8153_mac_clk_spd(struct r8152 *tp, bool enable)
-{
-       /* MAC clock speed down */
-       if (enable) {
-               ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL,
-                              ALDPS_SPDWN_RATIO);
-               ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL2,
-                              EEE_SPDWN_RATIO);
-               ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL3,
-                              PKT_AVAIL_SPDWN_EN | SUSPEND_SPDWN_EN |
-                              U1U2_SPDWN_EN | L1_SPDWN_EN);
-               ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL4,
-                              PWRSAVE_SPDWN_EN | RXDV_SPDWN_EN | TX10MIDLE_EN |
-                              TP100_SPDWN_EN | TP500_SPDWN_EN | EEE_SPDWN_EN |
-                              TP1000_SPDWN_EN);
-       } else {
-               ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL, 0);
-               ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL2, 0);
-               ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL3, 0);
-               ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL4, 0);
-       }
-}
-
 static void r8153_u1u2en(struct r8152 *tp, bool enable)
 {
        u8 u1u2[8];
@@ -3338,11 +3315,9 @@ static void rtl8153_runtime_enable(struct r8152 *tp, bool enable)
        if (enable) {
                r8153_u1u2en(tp, false);
                r8153_u2p3en(tp, false);
-               r8153_mac_clk_spd(tp, true);
                rtl_runtime_suspend_enable(tp, true);
        } else {
                rtl_runtime_suspend_enable(tp, false);
-               r8153_mac_clk_spd(tp, false);
 
                switch (tp->version) {
                case RTL_VER_03:
@@ -4718,7 +4693,6 @@ static void r8153_first_init(struct r8152 *tp)
 {
        u32 ocp_data;
 
-       r8153_mac_clk_spd(tp, false);
        rxdy_gated_en(tp, true);
        r8153_teredo_off(tp);
 
@@ -4769,8 +4743,6 @@ static void r8153_enter_oob(struct r8152 *tp)
 {
        u32 ocp_data;
 
-       r8153_mac_clk_spd(tp, true);
-
        ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL);
        ocp_data &= ~NOW_IS_OOB;
        ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data);
@@ -5496,10 +5468,15 @@ static void r8153_init(struct r8152 *tp)
 
        ocp_write_word(tp, MCU_TYPE_USB, USB_CONNECT_TIMER, 0x0001);
 
+       /* MAC clock speed down */
+       ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL, 0);
+       ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL2, 0);
+       ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL3, 0);
+       ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL4, 0);
+
        r8153_power_cut_en(tp, false);
        rtl_runtime_suspend_enable(tp, false);
        r8153_u1u2en(tp, true);
-       r8153_mac_clk_spd(tp, false);
        usb_enable_lpm(tp->udev);
 
        ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_CONFIG6);
index b4c8080e6f87ae8e0e17c2fc587bd5de7b32db9b..f4f37ecfed58743d8bbfa41abcef244e7bbe8bb7 100644 (file)
@@ -887,7 +887,7 @@ int usbnet_open (struct net_device *net)
 
        // insist peer be connected
        if (info->check_connect && (retval = info->check_connect (dev)) < 0) {
-               netif_dbg(dev, ifup, dev->net, "can't open; %d\n", retval);
+               netif_err(dev, ifup, dev->net, "can't open; %d\n", retval);
                goto done;
        }
 
index dca97cd7c4e75c4ec4f069d5816d969fbf710c25..7eac6a3e1cdee1e90de74fa17ce75e899a4bda1c 100644 (file)
@@ -204,14 +204,18 @@ static int uhdlc_init(struct ucc_hdlc_private *priv)
        priv->rx_skbuff = kcalloc(priv->rx_ring_size,
                                  sizeof(*priv->rx_skbuff),
                                  GFP_KERNEL);
-       if (!priv->rx_skbuff)
+       if (!priv->rx_skbuff) {
+               ret = -ENOMEM;
                goto free_ucc_pram;
+       }
 
        priv->tx_skbuff = kcalloc(priv->tx_ring_size,
                                  sizeof(*priv->tx_skbuff),
                                  GFP_KERNEL);
-       if (!priv->tx_skbuff)
+       if (!priv->tx_skbuff) {
+               ret = -ENOMEM;
                goto free_rx_skbuff;
+       }
 
        priv->skb_curtx = 0;
        priv->skb_dirtytx = 0;
index 605fe555e157d59e2e76d7b58cf8abd39110b183..c3372498f4f154dc483bb4beda7ce4a83aa52b36 100644 (file)
@@ -292,7 +292,6 @@ static int lapbeth_open(struct net_device *dev)
                return -ENODEV;
        }
 
-       netif_start_queue(dev);
        return 0;
 }
 
@@ -300,8 +299,6 @@ static int lapbeth_close(struct net_device *dev)
 {
        int err;
 
-       netif_stop_queue(dev);
-
        if ((err = lapb_unregister(dev)) != LAPB_OK)
                pr_err("lapb_unregister error: %d\n", err);
 
index c41e72508d3dbfdbea34422026ee11a50031e6e5..2db9c948c0fc332aa4f2f125302a2f93b278fb38 100644 (file)
@@ -28,7 +28,6 @@
 MODULE_AUTHOR("Michael Wu <flamingice@sourmilk.net>");
 MODULE_AUTHOR("Jouni Malinen <j@w1.fi>");
 MODULE_DESCRIPTION("Driver for IEEE 802.11b wireless cards based on ADMtek ADM8211");
-MODULE_SUPPORTED_DEVICE("ADM8211");
 MODULE_LICENSE("GPL");
 
 static unsigned int tx_ring_size __read_mostly = 16;
index b391169576e27c613931dc8f8f90575506657a60..faa2e678e63eff9b1c605ad0c32a30127b2b171e 100644 (file)
@@ -5450,8 +5450,8 @@ ath11k_mac_op_assign_vif_chanctx(struct ieee80211_hw *hw,
        }
 
        if (ab->hw_params.vdev_start_delay &&
-           (arvif->vdev_type == WMI_VDEV_TYPE_AP ||
-           arvif->vdev_type == WMI_VDEV_TYPE_MONITOR)) {
+           arvif->vdev_type != WMI_VDEV_TYPE_AP &&
+           arvif->vdev_type != WMI_VDEV_TYPE_MONITOR) {
                param.vdev_id = arvif->vdev_id;
                param.peer_type = WMI_PEER_TYPE_DEFAULT;
                param.peer_addr = ar->mac_addr;
index 1aca841cd147cfee6dedb59b6e08b38201257dfb..7968fe4eda22a839d80e4ed5b2220d857598d4ca 100644 (file)
@@ -1687,8 +1687,8 @@ static int ath11k_qmi_respond_fw_mem_request(struct ath11k_base *ab)
                        req->mem_seg[i].size = ab->qmi.target_mem[i].size;
                        req->mem_seg[i].type = ab->qmi.target_mem[i].type;
                        ath11k_dbg(ab, ATH11K_DBG_QMI,
-                                  "qmi req mem_seg[%d] 0x%llx %u %u\n", i,
-                                   ab->qmi.target_mem[i].paddr,
+                                  "qmi req mem_seg[%d] %pad %u %u\n", i,
+                                   &ab->qmi.target_mem[i].paddr,
                                    ab->qmi.target_mem[i].size,
                                    ab->qmi.target_mem[i].type);
                }
index 4c6e57f9976defe00390e58119593d1403bf011b..cef17f33c69ea652ed322427b4178e5f931f3b9d 100644 (file)
@@ -90,7 +90,6 @@ MODULE_PARM_DESC(no_hw_rfkill_switch, "Ignore the GPIO RFKill switch state");
 MODULE_AUTHOR("Jiri Slaby");
 MODULE_AUTHOR("Nick Kossifidis");
 MODULE_DESCRIPTION("Support for 5xxx series of Atheros 802.11 wireless LAN cards.");
-MODULE_SUPPORTED_DEVICE("Atheros 5xxx WLAN cards");
 MODULE_LICENSE("Dual BSD/GPL");
 
 static int ath5k_init(struct ieee80211_hw *hw);
index 13b4f5f50f8aac5af114bc1941570d6100960a74..ef6f5ea06c1f53d2bd3b118f43e7444cf0090dec 100644 (file)
@@ -177,7 +177,8 @@ struct ath_frame_info {
        s8 txq;
        u8 keyix;
        u8 rtscts_rate;
-       u8 retries : 7;
+       u8 retries : 6;
+       u8 dyn_smps : 1;
        u8 baw_tracked : 1;
        u8 tx_power;
        enum ath9k_key_type keytype:2;
index b66eeb57727243476166bc7323bd1adeeea58184..5abc2a5526ecff26f18425acba9d4d6698aeb642 100644 (file)
@@ -34,7 +34,6 @@ static bool ath9k_hw_set_reset_reg(struct ath_hw *ah, u32 type);
 
 MODULE_AUTHOR("Atheros Communications");
 MODULE_DESCRIPTION("Support for Atheros 802.11n wireless LAN cards.");
-MODULE_SUPPORTED_DEVICE("Atheros 802.11n WLAN cards");
 MODULE_LICENSE("Dual BSD/GPL");
 
 static void ath9k_hw_set_clockrate(struct ath_hw *ah)
index 42a208787f5afced9bfca6660a09a69991489465..01f9c26f9bf3705c6fa5c01ea7a6671bdf939c63 100644 (file)
@@ -37,7 +37,6 @@ static char *dev_info = "ath9k";
 
 MODULE_AUTHOR("Atheros Communications");
 MODULE_DESCRIPTION("Support for Atheros 802.11n wireless LAN cards.");
-MODULE_SUPPORTED_DEVICE("Atheros 802.11n WLAN cards");
 MODULE_LICENSE("Dual BSD/GPL");
 
 static unsigned int ath9k_debug = ATH_DBG_DEFAULT;
index e60d4737fc6e4e42bc49c9486b6ea90263d43838..5691bd6eb82c2fc5d251f37855cb1ea0b694ba2e 100644 (file)
@@ -1271,6 +1271,11 @@ static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf,
                                 is_40, is_sgi, is_sp);
                        if (rix < 8 && (tx_info->flags & IEEE80211_TX_CTL_STBC))
                                info->rates[i].RateFlags |= ATH9K_RATESERIES_STBC;
+                       if (rix >= 8 && fi->dyn_smps) {
+                               info->rates[i].RateFlags |=
+                                       ATH9K_RATESERIES_RTS_CTS;
+                               info->flags |= ATH9K_TXDESC_CTSENA;
+                       }
 
                        info->txpower[i] = ath_get_rate_txpower(sc, bf, rix,
                                                                is_40, false);
@@ -2114,6 +2119,7 @@ static void setup_frame_info(struct ieee80211_hw *hw,
                fi->keyix = an->ps_key;
        else
                fi->keyix = ATH9K_TXKEYIX_INVALID;
+       fi->dyn_smps = sta && sta->smps_mode == IEEE80211_SMPS_DYNAMIC;
        fi->keytype = keytype;
        fi->framelen = framelen;
        fi->tx_power = txpower;
index 707fe66727f8d9c3d5066bd0b15058a0647154e8..febce4e8b3dd37b09b9df3aa3faddbd522834fe4 100644 (file)
@@ -75,7 +75,6 @@
 MODULE_AUTHOR("Simon Kelley");
 MODULE_DESCRIPTION("Support for Atmel at76c50x 802.11 wireless ethernet cards.");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("Atmel at76c50x wireless cards");
 
 /* The name of the firmware file to be loaded
    over-rides any automatic selection */
index 368eebefa741ed9d1c613ae28c3bc3057727d328..453bb84cb3386b002b3f16118a673539f61bd6aa 100644 (file)
@@ -57,7 +57,6 @@
 MODULE_AUTHOR("Simon Kelley");
 MODULE_DESCRIPTION("Support for Atmel at76c50x 802.11 wireless ethernet cards.");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("Atmel at76c50x PCMCIA cards");
 
 /*====================================================================*/
 
index 47f7ccb32414e9ccad453f22361beba23842b13e..f428dc79d91613f7c0b27a00d6e4a8be4561b6df 100644 (file)
@@ -16,7 +16,6 @@
 MODULE_AUTHOR("Simon Kelley");
 MODULE_DESCRIPTION("Support for Atmel at76c50x 802.11 wireless ethernet cards.");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("Atmel at76c506 PCI wireless cards");
 
 static const struct pci_device_id card_ids[] = {
        { 0x1114, 0x0506, PCI_ANY_ID, PCI_ANY_ID },
index 818e523f6025d97cc9ac391cb6cb972e1fd9195f..39f3af2d0439bc1e05f717d254051355e64e71a1 100644 (file)
@@ -87,7 +87,6 @@ static int n_adapters_found;
 
 MODULE_AUTHOR("Broadcom Corporation");
 MODULE_DESCRIPTION("Broadcom 802.11n wireless LAN driver.");
-MODULE_SUPPORTED_DEVICE("Broadcom 802.11n WLAN cards");
 MODULE_LICENSE("Dual BSD/GPL");
 /* This needs to be adjusted when brcms_firmwares changes */
 MODULE_FIRMWARE("brcm/bcm43xx-0.fw");
index 4c84c3001c3fde9c08714cbd8ee8d048261ad983..e87e68cc46e22969f75c6deb22a30b97839bd39c 100644 (file)
@@ -12,7 +12,6 @@
 
 MODULE_AUTHOR("Broadcom Corporation");
 MODULE_DESCRIPTION("Broadcom 802.11n wireless LAN driver utilities.");
-MODULE_SUPPORTED_DEVICE("Broadcom 802.11n WLAN cards");
 MODULE_LICENSE("Dual BSD/GPL");
 
 struct sk_buff *brcmu_pkt_buf_get_skb(uint len)
index e35e1380ae4330d23882f8327c527f9de1991117..60db38c3896065d735adb220d39a98ffd24dae8e 100644 (file)
@@ -251,7 +251,6 @@ MODULE_AUTHOR("Benjamin Reed");
 MODULE_DESCRIPTION("Support for Cisco/Aironet 802.11 wireless ethernet cards.  "
                   "Direct support for ISA/PCI/MPI cards and support for PCMCIA when used with airo_cs.");
 MODULE_LICENSE("Dual BSD/GPL");
-MODULE_SUPPORTED_DEVICE("Aironet 4500, 4800 and Cisco 340/350");
 module_param_hw_array(io, int, ioport, NULL, 0);
 module_param_hw_array(irq, int, irq, NULL, 0);
 module_param_array(rates, int, NULL, 0);
index 3718f958c0fca44cfd56f556b73c3a19ba8ee99f..fcfe4c6d62f04ff5d2574f390516e53d2c213a65 100644 (file)
@@ -47,7 +47,6 @@ MODULE_DESCRIPTION("Support for Cisco/Aironet 802.11 wireless ethernet "
                   "cards.  This is the module that links the PCMCIA card "
                   "with the airo module.");
 MODULE_LICENSE("Dual BSD/GPL");
-MODULE_SUPPORTED_DEVICE("Aironet 4500, 4800 and Cisco 340 PCMCIA cards");
 
 /*====================================================================*/
 
index fd070ca5e517ffa4139e5d66f89e5fd1fd4cce3e..40f2109a097f3eb8a9c9cab9826385a3895b1c07 100644 (file)
@@ -271,12 +271,12 @@ static int iwl_pnvm_get_from_efi(struct iwl_trans *trans,
        err = efivar_entry_get(pnvm_efivar, NULL, &package_size, package);
        if (err) {
                IWL_DEBUG_FW(trans,
-                            "PNVM UEFI variable not found %d (len %zd)\n",
+                            "PNVM UEFI variable not found %d (len %lu)\n",
                             err, package_size);
                goto out;
        }
 
-       IWL_DEBUG_FW(trans, "Read PNVM fro UEFI with size %zd\n", package_size);
+       IWL_DEBUG_FW(trans, "Read PNVM fro UEFI with size %lu\n", package_size);
 
        *data = kmemdup(package->data, *len, GFP_KERNEL);
        if (!*data)
index 868da7e79a45507ba2a8851267cb56b402569591..e6d2e09943170af6fb48334d34182f74dc8f7ad5 100644 (file)
@@ -205,6 +205,8 @@ static inline void iwl_op_mode_time_point(struct iwl_op_mode *op_mode,
                                          enum iwl_fw_ini_time_point tp_id,
                                          union iwl_dbg_tlv_tp_data *tp_data)
 {
+       if (!op_mode || !op_mode->ops || !op_mode->ops->time_point)
+               return;
        op_mode->ops->time_point(op_mode, tp_id, tp_data);
 }
 
index 15e2773ce7e700e85a58957dd88c0acf40f730ae..5ee64f7f3c85fcffd9ede8d7247062d2aba9ab62 100644 (file)
@@ -1083,6 +1083,7 @@ static const struct dmi_system_id dmi_ppag_approved_list[] = {
                        DMI_MATCH(DMI_SYS_VENDOR, "ASUSTek COMPUTER INC."),
                },
        },
+       {}
 };
 
 static int iwl_mvm_ppag_init(struct iwl_mvm *mvm)
index 314fec4a89ad12b7b2171d1d6ddc7978478cc52a..ffaf973dae948bfc5616d4a025ea150bc0dfddb1 100644 (file)
@@ -1106,6 +1106,8 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                }
        }
 
+#if IS_ENABLED(CONFIG_IWLMVM)
+
        /*
         * Workaround for problematic SnJ device: sometimes when
         * certain RF modules are connected to SnJ, the device ID
@@ -1116,7 +1118,6 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        if (CSR_HW_REV_TYPE(iwl_trans->hw_rev) == IWL_CFG_MAC_TYPE_SNJ)
                iwl_trans->trans_cfg = &iwl_so_trans_cfg;
 
-#if IS_ENABLED(CONFIG_IWLMVM)
        /*
         * special-case 7265D, it has the same PCI IDs.
         *
index 42426e25cac605aabe41ab134a4233e0e1028fbb..2bec971331194245a6cae0bba64d9ff199d33b74 100644 (file)
@@ -1129,6 +1129,8 @@ static int _iwl_pcie_rx_init(struct iwl_trans *trans)
 
                iwl_pcie_rx_init_rxb_lists(rxq);
 
+               spin_unlock_bh(&rxq->lock);
+
                if (!rxq->napi.poll) {
                        int (*poll)(struct napi_struct *, int) = iwl_pcie_napi_poll;
 
@@ -1149,7 +1151,6 @@ static int _iwl_pcie_rx_init(struct iwl_trans *trans)
                        napi_enable(&rxq->napi);
                }
 
-               spin_unlock_bh(&rxq->lock);
        }
 
        /* move the pool to the default queue and allocator ownerships */
index 1a748670835ac0bf6014209a07aa5ce77b4d3a9f..ec7db2badc40eca48da220e460446f2c04dd92cd 100644 (file)
@@ -26,7 +26,6 @@ static char *dev_info = "hostap_cs";
 MODULE_AUTHOR("Jouni Malinen");
 MODULE_DESCRIPTION("Support for Intersil Prism2-based 802.11 wireless LAN "
                   "cards (PC Card).");
-MODULE_SUPPORTED_DEVICE("Intersil Prism2-based WLAN cards (PC Card)");
 MODULE_LICENSE("GPL");
 
 
index 101887e6bd0fbced38b23dac8a1f9684321f6245..52d77506effd255bae0c2036b4548bf44435e7f5 100644 (file)
@@ -27,7 +27,6 @@ static char *dev_info = "hostap_pci";
 MODULE_AUTHOR("Jouni Malinen");
 MODULE_DESCRIPTION("Support for Intersil Prism2.5-based 802.11 wireless LAN "
                   "PCI cards.");
-MODULE_SUPPORTED_DEVICE("Intersil Prism2.5-based WLAN PCI cards");
 MODULE_LICENSE("GPL");
 
 
index 841cfc68ce84044cb75a664ed8cfe180225030cf..58247290fcbc41e124657b6c61364aa33ec336ce 100644 (file)
@@ -30,7 +30,6 @@ static char *dev_info = "hostap_plx";
 MODULE_AUTHOR("Jouni Malinen");
 MODULE_DESCRIPTION("Support for Intersil Prism2-based 802.11 wireless LAN "
                   "cards (PLX).");
-MODULE_SUPPORTED_DEVICE("Intersil Prism2-based WLAN cards (PLX)");
 MODULE_LICENSE("GPL");
 
 
index 19098b852d0a8bb69f9d539a41e64b5c640be1af..2f27c43ad76df3f354f6196fb49e3df911a45ad4 100644 (file)
@@ -345,7 +345,6 @@ mt76_dma_tx_queue_skb(struct mt76_dev *dev, struct mt76_queue *q,
        };
        struct ieee80211_hw *hw;
        int len, n = 0, ret = -ENOMEM;
-       struct mt76_queue_entry e;
        struct mt76_txwi_cache *t;
        struct sk_buff *iter;
        dma_addr_t addr;
@@ -387,6 +386,11 @@ mt76_dma_tx_queue_skb(struct mt76_dev *dev, struct mt76_queue *q,
        }
        tx_info.nbuf = n;
 
+       if (q->queued + (tx_info.nbuf + 1) / 2 >= q->ndesc - 1) {
+               ret = -ENOMEM;
+               goto unmap;
+       }
+
        dma_sync_single_for_cpu(dev->dev, t->dma_addr, dev->drv->txwi_size,
                                DMA_TO_DEVICE);
        ret = dev->drv->tx_prepare_skb(dev, txwi, q->qid, wcid, sta, &tx_info);
@@ -395,11 +399,6 @@ mt76_dma_tx_queue_skb(struct mt76_dev *dev, struct mt76_queue *q,
        if (ret < 0)
                goto unmap;
 
-       if (q->queued + (tx_info.nbuf + 1) / 2 >= q->ndesc - 1) {
-               ret = -ENOMEM;
-               goto unmap;
-       }
-
        return mt76_dma_add_buf(dev, q, tx_info.buf, tx_info.nbuf,
                                tx_info.info, tx_info.skb, t);
 
@@ -419,9 +418,7 @@ free:
        }
 #endif
 
-       e.skb = tx_info.skb;
-       e.txwi = t;
-       dev->drv->tx_complete_skb(dev, &e);
+       dev_kfree_skb(tx_info.skb);
        mt76_put_txwi(dev, t);
        return ret;
 }
@@ -515,13 +512,13 @@ mt76_add_fragment(struct mt76_dev *dev, struct mt76_queue *q, void *data,
 {
        struct sk_buff *skb = q->rx_head;
        struct skb_shared_info *shinfo = skb_shinfo(skb);
+       int nr_frags = shinfo->nr_frags;
 
-       if (shinfo->nr_frags < ARRAY_SIZE(shinfo->frags)) {
+       if (nr_frags < ARRAY_SIZE(shinfo->frags)) {
                struct page *page = virt_to_head_page(data);
                int offset = data - page_address(page) + q->buf_offset;
 
-               skb_add_rx_frag(skb, shinfo->nr_frags, page, offset, len,
-                               q->buf_size);
+               skb_add_rx_frag(skb, nr_frags, page, offset, len, q->buf_size);
        } else {
                skb_free_frag(data);
        }
@@ -530,7 +527,10 @@ mt76_add_fragment(struct mt76_dev *dev, struct mt76_queue *q, void *data,
                return;
 
        q->rx_head = NULL;
-       dev->drv->rx_skb(dev, q - dev->q_rx, skb);
+       if (nr_frags < ARRAY_SIZE(shinfo->frags))
+               dev->drv->rx_skb(dev, q - dev->q_rx, skb);
+       else
+               dev_kfree_skb(skb);
 }
 
 static int
index eb889f8d6feaaa8ad82dc9f839ae859fb3eb2452..e5a258958ac919a8407d43564571a9f0750714c1 100644 (file)
@@ -967,11 +967,6 @@ int mt7915_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
        }
        txp->nbuf = nbuf;
 
-       /* pass partial skb header to fw */
-       tx_info->buf[1].len = MT_CT_PARSE_LEN;
-       tx_info->buf[1].skip_unmap = true;
-       tx_info->nbuf = MT_CT_DMA_BUF_NUM;
-
        txp->flags = cpu_to_le16(MT_CT_INFO_APPLY_TXD | MT_CT_INFO_FROM_HOST);
 
        if (!key)
@@ -1009,6 +1004,11 @@ int mt7915_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
                txp->rept_wds_wcid = cpu_to_le16(0x3ff);
        tx_info->skb = DMA_DUMMY_DATA;
 
+       /* pass partial skb header to fw */
+       tx_info->buf[1].len = MT_CT_PARSE_LEN;
+       tx_info->buf[1].skip_unmap = true;
+       tx_info->nbuf = MT_CT_DMA_BUF_NUM;
+
        return 0;
 }
 
index 7fb2170a9561210cbb3f7f18b5ef5ba93e750f3c..bd798df748ba5ea107ae38b95fd762670c21b85e 100644 (file)
@@ -543,7 +543,7 @@ mt7915_tm_set_tx_cont(struct mt7915_phy *phy, bool en)
                tx_cont->bw = CMD_CBW_20MHZ;
                break;
        default:
-               break;
+               return -EINVAL;
        }
 
        if (!en) {
@@ -591,7 +591,7 @@ mt7915_tm_set_tx_cont(struct mt7915_phy *phy, bool en)
                mode = MT_PHY_TYPE_HE_MU;
                break;
        default:
-               break;
+               return -EINVAL;
        }
 
        rateval =  mode << 6 | rate_idx;
index db125cd22b91a6558c58e1aaef9fea5fbb0d2926..b5cc72e7e81c3681d9bd111f603785090c532aaa 100644 (file)
@@ -405,10 +405,8 @@ mt7921_mcu_tx_rate_report(struct mt7921_dev *dev, struct sk_buff *skb,
        if (wlan_idx >= MT76_N_WCIDS)
                return;
        wcid = rcu_dereference(dev->mt76.wcid[wlan_idx]);
-       if (!wcid) {
-               stats->tx_rate = rate;
+       if (!wcid)
                return;
-       }
 
        msta = container_of(wcid, struct mt7921_sta, wcid);
        stats = &msta->stats;
index 8f860c14da58b8de3ac6e087a6b981439108129f..dec6ffdf07c42a3471bcfe14ca6eccabc6f13172 100644 (file)
@@ -1821,7 +1821,6 @@ static const struct pci_device_id rt2400pci_device_table[] = {
 MODULE_AUTHOR(DRV_PROJECT);
 MODULE_VERSION(DRV_VERSION);
 MODULE_DESCRIPTION("Ralink RT2400 PCI & PCMCIA Wireless LAN driver.");
-MODULE_SUPPORTED_DEVICE("Ralink RT2460 PCI & PCMCIA chipset based cards");
 MODULE_DEVICE_TABLE(pci, rt2400pci_device_table);
 MODULE_LICENSE("GPL");
 
index e940443c52ad830ff706d04a033bc6e50e9cc557..8faa0a80e73a667603b805c73b24b8bb1fdb9567 100644 (file)
@@ -2119,7 +2119,6 @@ static const struct pci_device_id rt2500pci_device_table[] = {
 MODULE_AUTHOR(DRV_PROJECT);
 MODULE_VERSION(DRV_VERSION);
 MODULE_DESCRIPTION("Ralink RT2500 PCI & PCMCIA Wireless LAN driver.");
-MODULE_SUPPORTED_DEVICE("Ralink RT2560 PCI & PCMCIA chipset based cards");
 MODULE_DEVICE_TABLE(pci, rt2500pci_device_table);
 MODULE_LICENSE("GPL");
 
index fce05fc88aaf99ceb312cb97e16a2e920616f1cf..bb5ed6630645823e5232c18545d4fd8a0848af9b 100644 (file)
@@ -1956,7 +1956,6 @@ static const struct usb_device_id rt2500usb_device_table[] = {
 MODULE_AUTHOR(DRV_PROJECT);
 MODULE_VERSION(DRV_VERSION);
 MODULE_DESCRIPTION("Ralink RT2500 USB Wireless LAN driver.");
-MODULE_SUPPORTED_DEVICE("Ralink RT2570 USB chipset based cards");
 MODULE_DEVICE_TABLE(usb, rt2500usb_device_table);
 MODULE_LICENSE("GPL");
 
index 9a33baaa61843927972f2a65874264583f74a470..1fde0e767ce3901ad3fb43b0e7233bb7fe9174bf 100644 (file)
@@ -439,7 +439,6 @@ static const struct pci_device_id rt2800pci_device_table[] = {
 MODULE_AUTHOR(DRV_PROJECT);
 MODULE_VERSION(DRV_VERSION);
 MODULE_DESCRIPTION("Ralink RT2800 PCI & PCMCIA Wireless LAN driver.");
-MODULE_SUPPORTED_DEVICE("Ralink RT2860 PCI & PCMCIA chipset based cards");
 MODULE_FIRMWARE(FIRMWARE_RT2860);
 MODULE_DEVICE_TABLE(pci, rt2800pci_device_table);
 MODULE_LICENSE("GPL");
index 36ac18ca8082ef0b89ba3b3fbc52d0f24b652397..b5c67f656cfd5b0bbb4e58a8457282d63599d72c 100644 (file)
@@ -1248,7 +1248,6 @@ static const struct usb_device_id rt2800usb_device_table[] = {
 MODULE_AUTHOR(DRV_PROJECT);
 MODULE_VERSION(DRV_VERSION);
 MODULE_DESCRIPTION("Ralink RT2800 USB Wireless LAN driver.");
-MODULE_SUPPORTED_DEVICE("Ralink RT2870 USB chipset based cards");
 MODULE_DEVICE_TABLE(usb, rt2800usb_device_table);
 MODULE_FIRMWARE(FIRMWARE_RT2870);
 MODULE_LICENSE("GPL");
index 02da5dd37ddd729ff798c9f85f12c862442d0434..82cfc2aadc2b3182a01338d47b1aba68799300ba 100644 (file)
@@ -2993,8 +2993,6 @@ static const struct pci_device_id rt61pci_device_table[] = {
 MODULE_AUTHOR(DRV_PROJECT);
 MODULE_VERSION(DRV_VERSION);
 MODULE_DESCRIPTION("Ralink RT61 PCI & PCMCIA Wireless LAN driver.");
-MODULE_SUPPORTED_DEVICE("Ralink RT2561, RT2561s & RT2661 "
-                       "PCI & PCMCIA chipset based cards");
 MODULE_DEVICE_TABLE(pci, rt61pci_device_table);
 MODULE_FIRMWARE(FIRMWARE_RT2561);
 MODULE_FIRMWARE(FIRMWARE_RT2561s);
index e69793773d8704e2a1ac6f4aa406dc8b01d285cc..5ff2c740c3ea0a673c269dd398cec28779406a51 100644 (file)
@@ -2513,7 +2513,6 @@ static const struct usb_device_id rt73usb_device_table[] = {
 MODULE_AUTHOR(DRV_PROJECT);
 MODULE_VERSION(DRV_VERSION);
 MODULE_DESCRIPTION("Ralink RT73 USB Wireless LAN driver.");
-MODULE_SUPPORTED_DEVICE("Ralink RT2571W & RT2671 USB chipset based cards");
 MODULE_DEVICE_TABLE(usb, rt73usb_device_table);
 MODULE_FIRMWARE(FIRMWARE_RT2571);
 MODULE_LICENSE("GPL");
index 9a3d2439a8e7aecfd903d825d8d4c96c2f774025..d98483298555c2a5ef2aa513f3878ab20af02679 100644 (file)
@@ -441,6 +441,5 @@ module_init(rsi_91x_hal_module_init);
 module_exit(rsi_91x_hal_module_exit);
 MODULE_AUTHOR("Redpine Signals Inc");
 MODULE_DESCRIPTION("Station driver for RSI 91x devices");
-MODULE_SUPPORTED_DEVICE("RSI-91x");
 MODULE_VERSION("0.1");
 MODULE_LICENSE("Dual BSD/GPL");
index 592e9dadcb556d73351a64cf437b8eee1ae6a8cd..fe0287b22a25454c3d28f8d47a808e3ee90569c0 100644 (file)
@@ -1571,7 +1571,6 @@ module_exit(rsi_module_exit);
 
 MODULE_AUTHOR("Redpine Signals Inc");
 MODULE_DESCRIPTION("Common SDIO layer for RSI drivers");
-MODULE_SUPPORTED_DEVICE("RSI-91x");
 MODULE_DEVICE_TABLE(sdio, rsi_dev_table);
 MODULE_FIRMWARE(FIRMWARE_RSI9113);
 MODULE_VERSION("0.1");
index a4a533c2a7838d7f7cf97a0e18c0892ba225a1c5..3fbe2a3c1455062f7f40e11a505a1bacc04102e4 100644 (file)
@@ -928,7 +928,6 @@ module_usb_driver(rsi_driver);
 
 MODULE_AUTHOR("Redpine Signals Inc");
 MODULE_DESCRIPTION("Common USB layer for RSI drivers");
-MODULE_SUPPORTED_DEVICE("RSI-91x");
 MODULE_DEVICE_TABLE(usb, rsi_dev_table);
 MODULE_FIRMWARE(FIRMWARE_RSI9113);
 MODULE_VERSION("0.1");
index 6afb5ca999c2c993e045bc8e3325206852327069..39a01c2a3058d6a8628d9dc47a7520b5f969cabe 100644 (file)
@@ -557,8 +557,8 @@ check_frags:
        }
 
        if (skb_has_frag_list(skb) && !first_shinfo) {
-               first_shinfo = skb_shinfo(skb);
-               shinfo = skb_shinfo(skb_shinfo(skb)->frag_list);
+               first_shinfo = shinfo;
+               shinfo = skb_shinfo(shinfo->frag_list);
                nr_frags = shinfo->nr_frags;
 
                goto check_frags;
index e68a8c4ac5a6ea6dbd9ddd7768e2cd8dcd18c3e9..0896e21642bebabf4450a5694b9196b77174d91b 100644 (file)
@@ -380,6 +380,7 @@ bool nvme_cancel_request(struct request *req, void *data, bool reserved)
                return true;
 
        nvme_req(req)->status = NVME_SC_HOST_ABORTED_CMD;
+       nvme_req(req)->flags |= NVME_REQ_CANCELLED;
        blk_mq_complete_request(req);
        return true;
 }
@@ -1225,28 +1226,12 @@ static void nvme_keep_alive_end_io(struct request *rq, blk_status_t status)
                queue_delayed_work(nvme_wq, &ctrl->ka_work, ctrl->kato * HZ);
 }
 
-static int nvme_keep_alive(struct nvme_ctrl *ctrl)
-{
-       struct request *rq;
-
-       rq = nvme_alloc_request(ctrl->admin_q, &ctrl->ka_cmd,
-                       BLK_MQ_REQ_RESERVED);
-       if (IS_ERR(rq))
-               return PTR_ERR(rq);
-
-       rq->timeout = ctrl->kato * HZ;
-       rq->end_io_data = ctrl;
-
-       blk_execute_rq_nowait(NULL, rq, 0, nvme_keep_alive_end_io);
-
-       return 0;
-}
-
 static void nvme_keep_alive_work(struct work_struct *work)
 {
        struct nvme_ctrl *ctrl = container_of(to_delayed_work(work),
                        struct nvme_ctrl, ka_work);
        bool comp_seen = ctrl->comp_seen;
+       struct request *rq;
 
        if ((ctrl->ctratt & NVME_CTRL_ATTR_TBKAS) && comp_seen) {
                dev_dbg(ctrl->device,
@@ -1256,12 +1241,18 @@ static void nvme_keep_alive_work(struct work_struct *work)
                return;
        }
 
-       if (nvme_keep_alive(ctrl)) {
+       rq = nvme_alloc_request(ctrl->admin_q, &ctrl->ka_cmd,
+                               BLK_MQ_REQ_RESERVED | BLK_MQ_REQ_NOWAIT);
+       if (IS_ERR(rq)) {
                /* allocation failure, reset the controller */
-               dev_err(ctrl->device, "keep-alive failed\n");
+               dev_err(ctrl->device, "keep-alive failed: %ld\n", PTR_ERR(rq));
                nvme_reset_ctrl(ctrl);
                return;
        }
+
+       rq->timeout = ctrl->kato * HZ;
+       rq->end_io_data = ctrl;
+       blk_execute_rq_nowait(NULL, rq, 0, nvme_keep_alive_end_io);
 }
 
 static void nvme_start_keep_alive(struct nvme_ctrl *ctrl)
@@ -1440,7 +1431,7 @@ static int nvme_identify_ns(struct nvme_ctrl *ctrl, unsigned nsid,
                goto out_free_id;
        }
 
-       error = -ENODEV;
+       error = NVME_SC_INVALID_NS | NVME_SC_DNR;
        if ((*id)->ncap == 0) /* namespace not allocated or attached */
                goto out_free_id;
 
@@ -1963,30 +1954,18 @@ static void nvme_config_discard(struct gendisk *disk, struct nvme_ns *ns)
                blk_queue_max_write_zeroes_sectors(queue, UINT_MAX);
 }
 
-static void nvme_config_write_zeroes(struct gendisk *disk, struct nvme_ns *ns)
+/*
+ * Even though NVMe spec explicitly states that MDTS is not applicable to the
+ * write-zeroes, we are cautious and limit the size to the controllers
+ * max_hw_sectors value, which is based on the MDTS field and possibly other
+ * limiting factors.
+ */
+static void nvme_config_write_zeroes(struct request_queue *q,
+               struct nvme_ctrl *ctrl)
 {
-       u64 max_blocks;
-
-       if (!(ns->ctrl->oncs & NVME_CTRL_ONCS_WRITE_ZEROES) ||
-           (ns->ctrl->quirks & NVME_QUIRK_DISABLE_WRITE_ZEROES))
-               return;
-       /*
-        * Even though NVMe spec explicitly states that MDTS is not
-        * applicable to the write-zeroes:- "The restriction does not apply to
-        * commands that do not transfer data between the host and the
-        * controller (e.g., Write Uncorrectable ro Write Zeroes command).".
-        * In order to be more cautious use controller's max_hw_sectors value
-        * to configure the maximum sectors for the write-zeroes which is
-        * configured based on the controller's MDTS field in the
-        * nvme_init_identify() if available.
-        */
-       if (ns->ctrl->max_hw_sectors == UINT_MAX)
-               max_blocks = (u64)USHRT_MAX + 1;
-       else
-               max_blocks = ns->ctrl->max_hw_sectors + 1;
-
-       blk_queue_max_write_zeroes_sectors(disk->queue,
-                                          nvme_lba_to_sect(ns, max_blocks));
+       if ((ctrl->oncs & NVME_CTRL_ONCS_WRITE_ZEROES) &&
+           !(ctrl->quirks & NVME_QUIRK_DISABLE_WRITE_ZEROES))
+               blk_queue_max_write_zeroes_sectors(q, ctrl->max_hw_sectors);
 }
 
 static bool nvme_ns_ids_valid(struct nvme_ns_ids *ids)
@@ -2158,7 +2137,7 @@ static void nvme_update_disk_info(struct gendisk *disk,
        set_capacity_and_notify(disk, capacity);
 
        nvme_config_discard(disk, ns);
-       nvme_config_write_zeroes(disk, ns);
+       nvme_config_write_zeroes(disk->queue, ns->ctrl);
 
        set_disk_ro(disk, (id->nsattr & NVME_NS_ATTR_RO) ||
                test_bit(NVME_NS_FORCE_RO, &ns->flags));
@@ -4038,7 +4017,7 @@ static void nvme_ns_remove_by_nsid(struct nvme_ctrl *ctrl, u32 nsid)
 static void nvme_validate_ns(struct nvme_ns *ns, struct nvme_ns_ids *ids)
 {
        struct nvme_id_ns *id;
-       int ret = -ENODEV;
+       int ret = NVME_SC_INVALID_NS | NVME_SC_DNR;
 
        if (test_bit(NVME_NS_DEAD, &ns->flags))
                goto out;
@@ -4047,7 +4026,7 @@ static void nvme_validate_ns(struct nvme_ns *ns, struct nvme_ns_ids *ids)
        if (ret)
                goto out;
 
-       ret = -ENODEV;
+       ret = NVME_SC_INVALID_NS | NVME_SC_DNR;
        if (!nvme_ns_ids_equal(&ns->head->ids, ids)) {
                dev_err(ns->ctrl->device,
                        "identifiers changed for nsid %d\n", ns->head->ns_id);
@@ -4065,7 +4044,7 @@ out:
         *
         * TODO: we should probably schedule a delayed retry here.
         */
-       if (ret && ret != -ENOMEM && !(ret > 0 && !(ret & NVME_SC_DNR)))
+       if (ret > 0 && (ret & NVME_SC_DNR))
                nvme_ns_remove(ns);
 }
 
@@ -4095,6 +4074,12 @@ static void nvme_validate_or_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
                                nsid);
                        break;
                }
+               if (!nvme_multi_css(ctrl)) {
+                       dev_warn(ctrl->device,
+                               "command set not reported for nsid: %d\n",
+                               nsid);
+                       break;
+               }
                nvme_alloc_ns(ctrl, nsid, &ids);
                break;
        default:
index 733010d2eafd80c8235f884ee5dcb08fbba88abd..888b108d87a4004ee2682669e915c6d4616099e1 100644 (file)
 /* default is -1: the fail fast mechanism is disabled  */
 #define NVMF_DEF_FAIL_FAST_TMO         -1
 
+/*
+ * Reserved one command for internal usage.  This command is used for sending
+ * the connect command, as well as for the keep alive command on the admin
+ * queue once live.
+ */
+#define NVMF_RESERVED_TAGS     1
+
 /*
  * Define a host as seen by the target.  We allocate one at boot, but also
  * allow the override it when creating controllers.  This is both to provide
index 20dadd86e9812157cc655cc3ee0ab9eee9f6d423..6ffa8de2a0d770184ec9ac101777c3139d7371a4 100644 (file)
@@ -1956,7 +1956,7 @@ nvme_fc_fcpio_done(struct nvmefc_fcp_req *req)
                                sizeof(op->rsp_iu), DMA_FROM_DEVICE);
 
        if (opstate == FCPOP_STATE_ABORTED)
-               status = cpu_to_le16(NVME_SC_HOST_PATH_ERROR << 1);
+               status = cpu_to_le16(NVME_SC_HOST_ABORTED_CMD << 1);
        else if (freq->status) {
                status = cpu_to_le16(NVME_SC_HOST_PATH_ERROR << 1);
                dev_info(ctrl->ctrl.device,
@@ -2055,7 +2055,7 @@ done:
                nvme_fc_complete_rq(rq);
 
 check_error:
-       if (terminate_assoc)
+       if (terminate_assoc && ctrl->ctrl.state != NVME_CTRL_RESETTING)
                queue_work(nvme_reset_wq, &ctrl->ioerr_work);
 }
 
@@ -2443,6 +2443,7 @@ nvme_fc_terminate_exchange(struct request *req, void *data, bool reserved)
        struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl);
        struct nvme_fc_fcp_op *op = blk_mq_rq_to_pdu(req);
 
+       op->nreq.flags |= NVME_REQ_CANCELLED;
        __nvme_fc_abort_op(ctrl, op);
        return true;
 }
@@ -2862,7 +2863,7 @@ nvme_fc_create_io_queues(struct nvme_fc_ctrl *ctrl)
        memset(&ctrl->tag_set, 0, sizeof(ctrl->tag_set));
        ctrl->tag_set.ops = &nvme_fc_mq_ops;
        ctrl->tag_set.queue_depth = ctrl->ctrl.opts->queue_size;
-       ctrl->tag_set.reserved_tags = 1; /* fabric connect */
+       ctrl->tag_set.reserved_tags = NVMF_RESERVED_TAGS;
        ctrl->tag_set.numa_node = ctrl->ctrl.numa_node;
        ctrl->tag_set.flags = BLK_MQ_F_SHOULD_MERGE;
        ctrl->tag_set.cmd_size =
@@ -3484,7 +3485,7 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
        memset(&ctrl->admin_tag_set, 0, sizeof(ctrl->admin_tag_set));
        ctrl->admin_tag_set.ops = &nvme_fc_admin_mq_ops;
        ctrl->admin_tag_set.queue_depth = NVME_AQ_MQ_TAG_DEPTH;
-       ctrl->admin_tag_set.reserved_tags = 2; /* fabric connect + Keep-Alive */
+       ctrl->admin_tag_set.reserved_tags = NVMF_RESERVED_TAGS;
        ctrl->admin_tag_set.numa_node = ctrl->ctrl.numa_node;
        ctrl->admin_tag_set.cmd_size =
                struct_size((struct nvme_fcp_op_w_sgl *)NULL, priv,
index 17ab3320d28b44b7534fd587d1e21447302bd3e8..7249ae74f71ff96f1328a7aeac2ee7890333e98b 100644 (file)
@@ -3246,6 +3246,7 @@ static const struct pci_device_id nvme_id_table[] = {
                .driver_data = NVME_QUIRK_DELAY_BEFORE_CHK_RDY, },
        { PCI_DEVICE(0x144d, 0xa822),   /* Samsung PM1725a */
                .driver_data = NVME_QUIRK_DELAY_BEFORE_CHK_RDY |
+                               NVME_QUIRK_DISABLE_WRITE_ZEROES|
                                NVME_QUIRK_IGNORE_DEV_SUBNQN, },
        { PCI_DEVICE(0x1987, 0x5016),   /* Phison E16 */
                .driver_data = NVME_QUIRK_IGNORE_DEV_SUBNQN, },
index 53ac4d7442ba9c59b5384c2c888e14580a224771..be905d4fdb47f47171968016aec16827b0dc0860 100644 (file)
@@ -736,8 +736,11 @@ static int nvme_rdma_alloc_io_queues(struct nvme_rdma_ctrl *ctrl)
                return ret;
 
        ctrl->ctrl.queue_count = nr_io_queues + 1;
-       if (ctrl->ctrl.queue_count < 2)
-               return 0;
+       if (ctrl->ctrl.queue_count < 2) {
+               dev_err(ctrl->ctrl.device,
+                       "unable to set any I/O queues\n");
+               return -ENOMEM;
+       }
 
        dev_info(ctrl->ctrl.device,
                "creating %d I/O queues.\n", nr_io_queues);
@@ -798,7 +801,7 @@ static struct blk_mq_tag_set *nvme_rdma_alloc_tagset(struct nvme_ctrl *nctrl,
                memset(set, 0, sizeof(*set));
                set->ops = &nvme_rdma_admin_mq_ops;
                set->queue_depth = NVME_AQ_MQ_TAG_DEPTH;
-               set->reserved_tags = 2; /* connect + keep-alive */
+               set->reserved_tags = NVMF_RESERVED_TAGS;
                set->numa_node = nctrl->numa_node;
                set->cmd_size = sizeof(struct nvme_rdma_request) +
                                NVME_RDMA_DATA_SGL_SIZE;
@@ -811,7 +814,7 @@ static struct blk_mq_tag_set *nvme_rdma_alloc_tagset(struct nvme_ctrl *nctrl,
                memset(set, 0, sizeof(*set));
                set->ops = &nvme_rdma_mq_ops;
                set->queue_depth = nctrl->sqsize + 1;
-               set->reserved_tags = 1; /* fabric connect */
+               set->reserved_tags = NVMF_RESERVED_TAGS;
                set->numa_node = nctrl->numa_node;
                set->flags = BLK_MQ_F_SHOULD_MERGE;
                set->cmd_size = sizeof(struct nvme_rdma_request) +
index 69f59d2c5799b8dbaf04f43a4c0e2e8628c16135..a0f00cb8f9f3c203e78b0a4f446a932a1e755dc3 100644 (file)
@@ -287,7 +287,7 @@ static inline void nvme_tcp_queue_request(struct nvme_tcp_request *req,
         * directly, otherwise queue io_work. Also, only do that if we
         * are on the same cpu, so we don't introduce contention.
         */
-       if (queue->io_cpu == __smp_processor_id() &&
+       if (queue->io_cpu == raw_smp_processor_id() &&
            sync && empty && mutex_trylock(&queue->send_mutex)) {
                queue->more_requests = !last;
                nvme_tcp_send_all(queue);
@@ -568,6 +568,13 @@ static int nvme_tcp_setup_h2c_data_pdu(struct nvme_tcp_request *req,
        req->pdu_len = le32_to_cpu(pdu->r2t_length);
        req->pdu_sent = 0;
 
+       if (unlikely(!req->pdu_len)) {
+               dev_err(queue->ctrl->ctrl.device,
+                       "req %d r2t len is %u, probably a bug...\n",
+                       rq->tag, req->pdu_len);
+               return -EPROTO;
+       }
+
        if (unlikely(req->data_sent + req->pdu_len > req->data_len)) {
                dev_err(queue->ctrl->ctrl.device,
                        "req %d r2t len %u exceeded data len %u (%zu sent)\n",
@@ -1575,7 +1582,7 @@ static struct blk_mq_tag_set *nvme_tcp_alloc_tagset(struct nvme_ctrl *nctrl,
                memset(set, 0, sizeof(*set));
                set->ops = &nvme_tcp_admin_mq_ops;
                set->queue_depth = NVME_AQ_MQ_TAG_DEPTH;
-               set->reserved_tags = 2; /* connect + keep-alive */
+               set->reserved_tags = NVMF_RESERVED_TAGS;
                set->numa_node = nctrl->numa_node;
                set->flags = BLK_MQ_F_BLOCKING;
                set->cmd_size = sizeof(struct nvme_tcp_request);
@@ -1587,7 +1594,7 @@ static struct blk_mq_tag_set *nvme_tcp_alloc_tagset(struct nvme_ctrl *nctrl,
                memset(set, 0, sizeof(*set));
                set->ops = &nvme_tcp_mq_ops;
                set->queue_depth = nctrl->sqsize + 1;
-               set->reserved_tags = 1; /* fabric connect */
+               set->reserved_tags = NVMF_RESERVED_TAGS;
                set->numa_node = nctrl->numa_node;
                set->flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_BLOCKING;
                set->cmd_size = sizeof(struct nvme_tcp_request);
@@ -1745,8 +1752,11 @@ static int nvme_tcp_alloc_io_queues(struct nvme_ctrl *ctrl)
                return ret;
 
        ctrl->queue_count = nr_io_queues + 1;
-       if (ctrl->queue_count < 2)
-               return 0;
+       if (ctrl->queue_count < 2) {
+               dev_err(ctrl->device,
+                       "unable to set any I/O queues\n");
+               return -ENOMEM;
+       }
 
        dev_info(ctrl->device,
                "creating %d I/O queues.\n", nr_io_queues);
index c7e3ec561ba0ca882defae384b7c8fd193f4feac..bc2f344f0ae01864caf8e477552f6bccbf6c0512 100644 (file)
@@ -9,7 +9,13 @@
 
 int nvme_revalidate_zones(struct nvme_ns *ns)
 {
-       return blk_revalidate_disk_zones(ns->disk, NULL);
+       struct request_queue *q = ns->queue;
+       int ret;
+
+       ret = blk_revalidate_disk_zones(ns->disk, NULL);
+       if (!ret)
+               blk_queue_max_zone_append_sectors(q, ns->ctrl->max_zone_append);
+       return ret;
 }
 
 static int nvme_set_max_append(struct nvme_ctrl *ctrl)
@@ -107,7 +113,6 @@ int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf)
        blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
        blk_queue_max_open_zones(q, le32_to_cpu(id->mor) + 1);
        blk_queue_max_active_zones(q, le32_to_cpu(id->mar) + 1);
-       blk_queue_max_zone_append_sectors(q, ns->ctrl->max_zone_append);
 free_data:
        kfree(id);
        return status;
index be6fcdaf51a7b60768c2109270e4924ee4afa41e..a027433b8be84e10b232381bc0a63ef17c7ecb31 100644 (file)
@@ -1118,9 +1118,20 @@ static void nvmet_start_ctrl(struct nvmet_ctrl *ctrl)
 {
        lockdep_assert_held(&ctrl->lock);
 
-       if (nvmet_cc_iosqes(ctrl->cc) != NVME_NVM_IOSQES ||
-           nvmet_cc_iocqes(ctrl->cc) != NVME_NVM_IOCQES ||
-           nvmet_cc_mps(ctrl->cc) != 0 ||
+       /*
+        * Only I/O controllers should verify iosqes,iocqes.
+        * Strictly speaking, the spec says a discovery controller
+        * should verify iosqes,iocqes are zeroed, however that
+        * would break backwards compatibility, so don't enforce it.
+        */
+       if (ctrl->subsys->type != NVME_NQN_DISC &&
+           (nvmet_cc_iosqes(ctrl->cc) != NVME_NVM_IOSQES ||
+            nvmet_cc_iocqes(ctrl->cc) != NVME_NVM_IOCQES)) {
+               ctrl->csts = NVME_CSTS_CFS;
+               return;
+       }
+
+       if (nvmet_cc_mps(ctrl->cc) != 0 ||
            nvmet_cc_ams(ctrl->cc) != 0 ||
            nvmet_cc_css(ctrl->cc) != 0) {
                ctrl->csts = NVME_CSTS_CFS;
index cb6f86572b24ad37c12408f7733bf9ffbb5677c3..3e189e753bcf5add622d26dad4dcf8527b08d98b 100644 (file)
@@ -349,7 +349,7 @@ static int nvme_loop_configure_admin_queue(struct nvme_loop_ctrl *ctrl)
        memset(&ctrl->admin_tag_set, 0, sizeof(ctrl->admin_tag_set));
        ctrl->admin_tag_set.ops = &nvme_loop_admin_mq_ops;
        ctrl->admin_tag_set.queue_depth = NVME_AQ_MQ_TAG_DEPTH;
-       ctrl->admin_tag_set.reserved_tags = 2; /* connect + keep-alive */
+       ctrl->admin_tag_set.reserved_tags = NVMF_RESERVED_TAGS;
        ctrl->admin_tag_set.numa_node = ctrl->ctrl.numa_node;
        ctrl->admin_tag_set.cmd_size = sizeof(struct nvme_loop_iod) +
                NVME_INLINE_SG_CNT * sizeof(struct scatterlist);
@@ -520,7 +520,7 @@ static int nvme_loop_create_io_queues(struct nvme_loop_ctrl *ctrl)
        memset(&ctrl->tag_set, 0, sizeof(ctrl->tag_set));
        ctrl->tag_set.ops = &nvme_loop_mq_ops;
        ctrl->tag_set.queue_depth = ctrl->ctrl.opts->queue_size;
-       ctrl->tag_set.reserved_tags = 1; /* fabric connect */
+       ctrl->tag_set.reserved_tags = NVMF_RESERVED_TAGS;
        ctrl->tag_set.numa_node = ctrl->ctrl.numa_node;
        ctrl->tag_set.flags = BLK_MQ_F_SHOULD_MERGE;
        ctrl->tag_set.cmd_size = sizeof(struct nvme_loop_iod) +
index 26c587ccd152c2649f0aff66a50b880e82f6d04f..2798944899b7360e93dd659718cd73e14c7e84c4 100644 (file)
@@ -50,9 +50,9 @@ static u16 nvmet_passthru_override_id_ctrl(struct nvmet_req *req)
 
        /*
         * nvmet_passthru_map_sg is limitted to using a single bio so limit
-        * the mdts based on BIO_MAX_PAGES as well
+        * the mdts based on BIO_MAX_VECS as well
         */
-       max_hw_sectors = min_not_zero(BIO_MAX_PAGES << (PAGE_SHIFT - 9),
+       max_hw_sectors = min_not_zero(BIO_MAX_VECS << (PAGE_SHIFT - 9),
                                      max_hw_sectors);
 
        page_shift = NVME_CAP_MPSMIN(ctrl->cap) + 12;
@@ -191,7 +191,7 @@ static int nvmet_passthru_map_sg(struct nvmet_req *req, struct request *rq)
        struct bio *bio;
        int i;
 
-       if (req->sg_cnt > BIO_MAX_PAGES)
+       if (req->sg_cnt > BIO_MAX_VECS)
                return -EINVAL;
 
        if (req->transfer_len <= NVMET_MAX_INLINE_DATA_LEN) {
index 06b6b742bb213e3ba924ef113d81e4081379b2be..6c1f3ab7649c78b3e6aa9cd8b266e29bcbeba3ad 100644 (file)
@@ -802,9 +802,8 @@ static void nvmet_rdma_write_data_done(struct ib_cq *cq, struct ib_wc *wc)
                nvmet_req_uninit(&rsp->req);
                nvmet_rdma_release_rsp(rsp);
                if (wc->status != IB_WC_WR_FLUSH_ERR) {
-                       pr_info("RDMA WRITE for CQE 0x%p failed with status %s (%d).\n",
-                               wc->wr_cqe, ib_wc_status_msg(wc->status),
-                               wc->status);
+                       pr_info("RDMA WRITE for CQE failed with status %s (%d).\n",
+                               ib_wc_status_msg(wc->status), wc->status);
                        nvmet_rdma_error_comp(queue);
                }
                return;
index 8b0485ada315b9f139e3e42b8131d70ea466b92f..d658c6e8263afd967daa722680c9b1b6ab35e62d 100644 (file)
@@ -1098,11 +1098,11 @@ static int nvmet_tcp_try_recv_data(struct nvmet_tcp_queue *queue)
                cmd->rbytes_done += ret;
        }
 
+       nvmet_tcp_unmap_pdu_iovec(cmd);
        if (queue->data_digest) {
                nvmet_tcp_prep_recv_ddgst(cmd);
                return 0;
        }
-       nvmet_tcp_unmap_pdu_iovec(cmd);
 
        if (!(cmd->flags & NVMET_TCP_F_INIT_FAILED) &&
            cmd->rbytes_done == cmd->req.transfer_len) {
index c2689386a90688a47020b9b2e38d0571aaca92b5..1556998425d5bc752c35970be104b1fbcf09e972 100644 (file)
@@ -1492,7 +1492,11 @@ static struct dev_pm_opp *_opp_get_next(struct opp_table *opp_table,
 
        mutex_lock(&opp_table->lock);
        list_for_each_entry(temp, &opp_table->opp_list, node) {
-               if (dynamic == temp->dynamic) {
+               /*
+                * Refcount must be dropped only once for each OPP by OPP core,
+                * do that with help of "removed" flag.
+                */
+               if (!temp->removed && dynamic == temp->dynamic) {
                        opp = temp;
                        break;
                }
@@ -1502,10 +1506,27 @@ static struct dev_pm_opp *_opp_get_next(struct opp_table *opp_table,
        return opp;
 }
 
-bool _opp_remove_all_static(struct opp_table *opp_table)
+/*
+ * Can't call dev_pm_opp_put() from under the lock as debugfs removal needs to
+ * happen lock less to avoid circular dependency issues. This routine must be
+ * called without the opp_table->lock held.
+ */
+static void _opp_remove_all(struct opp_table *opp_table, bool dynamic)
 {
        struct dev_pm_opp *opp;
 
+       while ((opp = _opp_get_next(opp_table, dynamic))) {
+               opp->removed = true;
+               dev_pm_opp_put(opp);
+
+               /* Drop the references taken by dev_pm_opp_add() */
+               if (dynamic)
+                       dev_pm_opp_put_opp_table(opp_table);
+       }
+}
+
+bool _opp_remove_all_static(struct opp_table *opp_table)
+{
        mutex_lock(&opp_table->lock);
 
        if (!opp_table->parsed_static_opps) {
@@ -1520,13 +1541,7 @@ bool _opp_remove_all_static(struct opp_table *opp_table)
 
        mutex_unlock(&opp_table->lock);
 
-       /*
-        * Can't remove the OPP from under the lock, debugfs removal needs to
-        * happen lock less to avoid circular dependency issues.
-        */
-       while ((opp = _opp_get_next(opp_table, false)))
-               dev_pm_opp_put(opp);
-
+       _opp_remove_all(opp_table, false);
        return true;
 }
 
@@ -1539,25 +1554,12 @@ bool _opp_remove_all_static(struct opp_table *opp_table)
 void dev_pm_opp_remove_all_dynamic(struct device *dev)
 {
        struct opp_table *opp_table;
-       struct dev_pm_opp *opp;
-       int count = 0;
 
        opp_table = _find_opp_table(dev);
        if (IS_ERR(opp_table))
                return;
 
-       /*
-        * Can't remove the OPP from under the lock, debugfs removal needs to
-        * happen lock less to avoid circular dependency issues.
-        */
-       while ((opp = _opp_get_next(opp_table, true))) {
-               dev_pm_opp_put(opp);
-               count++;
-       }
-
-       /* Drop the references taken by dev_pm_opp_add() */
-       while (count--)
-               dev_pm_opp_put_opp_table(opp_table);
+       _opp_remove_all(opp_table, true);
 
        /* Drop the reference taken by _find_opp_table() */
        dev_pm_opp_put_opp_table(opp_table);
index 50fb9dced3c528018e8a467c286c8efb1226c161..407c3bfe51d9685344ffcc643f7835b273e57aea 100644 (file)
@@ -56,6 +56,7 @@ extern struct list_head opp_tables, lazy_opp_tables;
  * @dynamic:   not-created from static DT entries.
  * @turbo:     true if turbo (boost) OPP
  * @suspend:   true if suspend OPP
+ * @removed:   flag indicating that OPP's reference is dropped by OPP core.
  * @pstate: Device's power domain's performance state.
  * @rate:      Frequency in hertz
  * @level:     Performance level
@@ -78,6 +79,7 @@ struct dev_pm_opp {
        bool dynamic;
        bool turbo;
        bool suspend;
+       bool removed;
        unsigned int pstate;
        unsigned long rate;
        unsigned int level;
index 1e88bcfe0d7b18adb4e410b902c3c273ac2a263e..84d5701d606ce9b16f0d870df22a82e23ed770d4 100644 (file)
@@ -241,6 +241,5 @@ module_platform_driver_probe(amiga_parallel_driver, amiga_parallel_probe);
 
 MODULE_AUTHOR("Joerg Dorchain <joerg@dorchain.net>");
 MODULE_DESCRIPTION("Parport Driver for Amiga builtin Port");
-MODULE_SUPPORTED_DEVICE("Amiga builtin Parallel Port");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS("platform:amiga-parallel");
index 2ff0fe053e6ee3530b29d85c72a11d2c0f9ec863..1623f010cdcc6420c7d5a70df66d1047e4d0c86f 100644 (file)
@@ -218,7 +218,6 @@ static void __exit parport_atari_exit(void)
 
 MODULE_AUTHOR("Andreas Schwab");
 MODULE_DESCRIPTION("Parport Driver for Atari builtin Port");
-MODULE_SUPPORTED_DEVICE("Atari builtin Parallel Port");
 MODULE_LICENSE("GPL");
 
 module_init(parport_atari_init)
index 9228e8f903092b1f02605fb2d6737621b17f89ae..1e43b3f399a83d05a0289f4d67cac605dbc77352 100644 (file)
@@ -41,7 +41,6 @@
 
 MODULE_AUTHOR("Helge Deller <deller@gmx.de>");
 MODULE_DESCRIPTION("HP-PARISC PC-style parallel port driver");
-MODULE_SUPPORTED_DEVICE("integrated PC-style parallel port");
 MODULE_LICENSE("GPL");
 
 
index d6bbe84463014baf3e102a43cc4a6eda71fd0ea8..f4d0da741e8566a77fe1a15441d7bc6fec16eac4 100644 (file)
@@ -359,7 +359,6 @@ static void __exit parport_mfc3_exit(void)
 
 MODULE_AUTHOR("Joerg Dorchain <joerg@dorchain.net>");
 MODULE_DESCRIPTION("Parport Driver for Multiface 3 expansion cards Parallel Port");
-MODULE_SUPPORTED_DEVICE("Multiface 3 Parallel Port");
 MODULE_LICENSE("GPL");
 
 module_init(parport_mfc3_init)
index e840c1b5ab9086448a05fee719363e167d2f6d1f..865fc41dbb6c422d931bcd88e3a10a6dd0fcd614 100644 (file)
@@ -377,6 +377,5 @@ module_platform_driver(bpp_sbus_driver);
 
 MODULE_AUTHOR("Derrick J Brashear");
 MODULE_DESCRIPTION("Parport Driver for Sparc bidirectional Port");
-MODULE_SUPPORTED_DEVICE("Sparc Bidirectional Parallel Port");
 MODULE_VERSION("2.0");
 MODULE_LICENSE("GPL");
index cdbfa5df3a51f3d629179bf83f830cf7f4f1095b..dbfa0b55d31a5126f35785653857117dac463d35 100644 (file)
@@ -34,12 +34,11 @@ static ssize_t add_slot_store(struct kobject *kobj, struct kobj_attribute *attr,
        if (nbytes >= MAX_DRC_NAME_LEN)
                return 0;
 
-       memcpy(drc_name, buf, nbytes);
+       strscpy(drc_name, buf, nbytes + 1);
 
        end = strchr(drc_name, '\n');
-       if (!end)
-               end = &drc_name[nbytes];
-       *end = '\0';
+       if (end)
+               *end = '\0';
 
        rc = dlpar_add_slot(drc_name);
        if (rc)
@@ -65,12 +64,11 @@ static ssize_t remove_slot_store(struct kobject *kobj,
        if (nbytes >= MAX_DRC_NAME_LEN)
                return 0;
 
-       memcpy(drc_name, buf, nbytes);
+       strscpy(drc_name, buf, nbytes + 1);
 
        end = strchr(drc_name, '\n');
-       if (!end)
-               end = &drc_name[nbytes];
-       *end = '\0';
+       if (end)
+               *end = '\0';
 
        rc = dlpar_remove_slot(drc_name);
        if (rc)
index c9e790c74051f6215b7c8f1057234f2a169ee965..a047c421debe2e10606f8649f015436953daa7d1 100644 (file)
@@ -93,8 +93,9 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)
                pci_dev_put(pdev);
                return -EBUSY;
        }
+       pci_dev_put(pdev);
 
-       zpci_remove_device(zdev);
+       zpci_remove_device(zdev, false);
 
        rc = zpci_disable_device(zdev);
        if (rc)
index c6fe0cfec0f681f19cabecc0826627e5d6018f2f..2d75026482197de191e13b73f39f3f4ba09ce79f 100644 (file)
@@ -26,7 +26,7 @@
 #include <xen/platform_pci.h>
 
 #include <asm/xen/swiotlb-xen.h>
-#define INVALID_GRANT_REF (0)
+
 #define INVALID_EVTCHN    (-1)
 
 struct pci_bus_entry {
@@ -42,7 +42,7 @@ struct pcifront_device {
        struct list_head root_buses;
 
        int evtchn;
-       int gnt_ref;
+       grant_ref_t gnt_ref;
 
        int irq;
 
index 66ad5b3ece1974b6b2fd296408b69d87fd0f8682..f2a85500258d0bca8bfb57f01bd0d1b4f545d456 100644 (file)
@@ -681,6 +681,7 @@ static int dmc620_pmu_device_probe(struct platform_device *pdev)
        if (!name) {
                dev_err(&pdev->dev,
                          "Create name failed, PMU @%pa\n", &res->start);
+               ret = -ENOMEM;
                goto out_teardown_dev;
        }
 
index d49a1534d8e91c5b34ae93f639fb0257b10636a5..9edc34981ee0a21c7adcec13e801f5b5890c1bc1 100644 (file)
@@ -41,7 +41,7 @@ struct mt6315_chip {
                .type = REGULATOR_VOLTAGE,                      \
                .id = _bid,                                     \
                .owner = THIS_MODULE,                           \
-               .n_voltages = 0xbf,                             \
+               .n_voltages = 0xc0,                             \
                .linear_ranges = mt_volt_range1,                \
                .n_linear_ranges = ARRAY_SIZE(mt_volt_range1),  \
                .vsel_reg = _vsel,                              \
@@ -69,7 +69,7 @@ static unsigned int mt6315_map_mode(u32 mode)
        case MT6315_BUCK_MODE_LP:
                return REGULATOR_MODE_IDLE;
        default:
-               return -EINVAL;
+               return REGULATOR_MODE_INVALID;
        }
 }
 
index 833d398c6aa21f3f5cdd777ca0c3ec6120d1045b..2f7ee212cb8c9d2b3b70e8900bff8c3bf461be04 100644 (file)
@@ -797,6 +797,14 @@ static int pca9450_i2c_probe(struct i2c_client *i2c,
                return ret;
        }
 
+       /* Clear PRESET_EN bit in BUCK123_DVS to use DVS registers */
+       ret = regmap_clear_bits(pca9450->regmap, PCA9450_REG_BUCK123_DVS,
+                               BUCK123_PRESET_EN);
+       if (ret) {
+               dev_err(&i2c->dev, "Failed to clear PRESET_EN bit: %d\n", ret);
+               return ret;
+       }
+
        /* Set reset behavior on assertion of WDOG_B signal */
        ret = regmap_update_bits(pca9450->regmap, PCA9450_REG_RESET_CTRL,
                                WDOG_B_CFG_MASK, WDOG_B_CFG_COLD_LDO12);
@@ -814,7 +822,7 @@ static int pca9450_i2c_probe(struct i2c_client *i2c,
 
        if (IS_ERR(pca9450->sd_vsel_gpio)) {
                dev_err(&i2c->dev, "Failed to get SD_VSEL GPIO\n");
-               return ret;
+               return PTR_ERR(pca9450->sd_vsel_gpio);
        }
 
        dev_info(&i2c->dev, "%s probed.\n",
index 79a554f1029dcd8722ea249155304686f3758e4d..65a108c9121f55590133f05f05314372556e9531 100644 (file)
@@ -726,8 +726,8 @@ static const struct rpmh_vreg_hw_data pmic5_ftsmps510 = {
 static const struct rpmh_vreg_hw_data pmic5_hfsmps515 = {
        .regulator_type = VRM,
        .ops = &rpmh_regulator_vrm_ops,
-       .voltage_range = REGULATOR_LINEAR_RANGE(2800000, 0, 4, 16000),
-       .n_voltages = 5,
+       .voltage_range = REGULATOR_LINEAR_RANGE(320000, 0, 235, 16000),
+       .n_voltages = 236,
        .pmic_mode_map = pmic_mode_map_pmic5_smps,
        .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode,
 };
@@ -901,7 +901,7 @@ static const struct rpmh_vreg_init_data pm8350_vreg_data[] = {
 };
 
 static const struct rpmh_vreg_init_data pm8350c_vreg_data[] = {
-       RPMH_VREG("smps1",  "smp%s1",  &pmic5_hfsmps510, "vdd-s1"),
+       RPMH_VREG("smps1",  "smp%s1",  &pmic5_hfsmps515, "vdd-s1"),
        RPMH_VREG("smps2",  "smp%s2",  &pmic5_ftsmps510, "vdd-s2"),
        RPMH_VREG("smps3",  "smp%s3",  &pmic5_ftsmps510, "vdd-s3"),
        RPMH_VREG("smps4",  "smp%s4",  &pmic5_ftsmps510, "vdd-s4"),
index 3d4695ded6293de5edb60290273b3d28e2251db8..e3aaac90d238faf4697222e2e6de9cc85a4a50c5 100644 (file)
@@ -153,9 +153,9 @@ static int rt4831_regulator_probe(struct platform_device *pdev)
        int i, ret;
 
        regmap = dev_get_regmap(pdev->dev.parent, NULL);
-       if (IS_ERR(regmap)) {
+       if (!regmap) {
                dev_err(&pdev->dev, "Failed to init regmap\n");
-               return PTR_ERR(regmap);
+               return -ENODEV;
        }
 
        /* Configure DSV mode to normal by default */
index 28c04a4efa66f2706568134459336619c877bc2b..3a945abf268c1b0a604128936bd10cecc497dc3c 100644 (file)
@@ -63,7 +63,6 @@ void dasd_int_handler(struct ccw_device *, unsigned long, struct irb *);
 MODULE_AUTHOR("Holger Smolinski <Holger.Smolinski@de.ibm.com>");
 MODULE_DESCRIPTION("Linux on S/390 DASD device driver,"
                   " Copyright IBM Corp. 2000");
-MODULE_SUPPORTED_DEVICE("dasd");
 MODULE_LICENSE("GPL");
 
 /*
@@ -3052,7 +3051,8 @@ static blk_status_t do_dasd_request(struct blk_mq_hw_ctx *hctx,
 
        basedev = block->base;
        spin_lock_irq(&dq->lock);
-       if (basedev->state < DASD_STATE_READY) {
+       if (basedev->state < DASD_STATE_READY ||
+           test_bit(DASD_FLAG_OFFLINE, &basedev->flags)) {
                DBF_DEV_EVENT(DBF_ERR, basedev,
                              "device not ready for request %p", req);
                rc = BLK_STS_IOERR;
@@ -3487,8 +3487,6 @@ void dasd_generic_remove(struct ccw_device *cdev)
        struct dasd_device *device;
        struct dasd_block *block;
 
-       cdev->handler = NULL;
-
        device = dasd_device_from_cdev(cdev);
        if (IS_ERR(device)) {
                dasd_remove_sysfs_files(cdev);
@@ -3507,6 +3505,7 @@ void dasd_generic_remove(struct ccw_device *cdev)
         * no quite down yet.
         */
        dasd_set_target_state(device, DASD_STATE_NEW);
+       cdev->handler = NULL;
        /* dasd_delete_device destroys the device reference. */
        block = device->block;
        dasd_delete_device(device);
index 15692449a1c3fc6032e739efb926ef071a6bdaeb..307a80f85c07de434274d0b8338c591040553c17 100644 (file)
@@ -424,8 +424,10 @@ tty3270_update(struct timer_list *t)
                         * last output position matches the start address
                         * of this line.
                         */
-                       if (s->string[1] == sba[0] && s->string[2] == sba[1])
-                               str += 3, len -= 3;
+                       if (s->string[1] == sba[0] && s->string[2] == sba[1]) {
+                               str += 3;
+                               len -= 3;
+                       }
                        if (raw3270_request_add_data(wrq, str, len) != 0)
                                break;
                        list_del_init(&s->update);
index 1515fdc3c1abd53c6fc73c57ecaebeafbc605eff..bd3c724bf695f12866a53b02faaa28c2628d602d 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/debugfs.h>
+#include <linux/reboot.h>
 
 #include <asm/asm-offsets.h>
 #include <asm/ipl.h>
@@ -238,6 +239,28 @@ static int __init zcore_reipl_init(void)
        return 0;
 }
 
+static int zcore_reboot_and_on_panic_handler(struct notifier_block *self,
+                                            unsigned long         event,
+                                            void                  *data)
+{
+       if (hsa_available)
+               release_hsa();
+
+       return NOTIFY_OK;
+}
+
+static struct notifier_block zcore_reboot_notifier = {
+       .notifier_call  = zcore_reboot_and_on_panic_handler,
+       /* we need to be notified before reipl and kdump */
+       .priority       = INT_MAX,
+};
+
+static struct notifier_block zcore_on_panic_notifier = {
+       .notifier_call  = zcore_reboot_and_on_panic_handler,
+       /* we need to be notified before reipl and kdump */
+       .priority       = INT_MAX,
+};
+
 static int __init zcore_init(void)
 {
        unsigned char arch;
@@ -293,28 +316,15 @@ static int __init zcore_init(void)
                goto fail;
 
        zcore_dir = debugfs_create_dir("zcore" , NULL);
-       if (!zcore_dir) {
-               rc = -ENOMEM;
-               goto fail;
-       }
        zcore_reipl_file = debugfs_create_file("reipl", S_IRUSR, zcore_dir,
                                                NULL, &zcore_reipl_fops);
-       if (!zcore_reipl_file) {
-               rc = -ENOMEM;
-               goto fail_dir;
-       }
        zcore_hsa_file = debugfs_create_file("hsa", S_IRUSR|S_IWUSR, zcore_dir,
                                             NULL, &zcore_hsa_fops);
-       if (!zcore_hsa_file) {
-               rc = -ENOMEM;
-               goto fail_reipl_file;
-       }
-       return 0;
 
-fail_reipl_file:
-       debugfs_remove(zcore_reipl_file);
-fail_dir:
-       debugfs_remove(zcore_dir);
+       register_reboot_notifier(&zcore_reboot_notifier);
+       atomic_notifier_chain_register(&panic_notifier_list, &zcore_on_panic_notifier);
+
+       return 0;
 fail:
        diag308(DIAG308_REL_HSA, NULL);
        return rc;
index 6420b197bb050724f0d6ed8127a4e1674526f171..05e136cfb8be7226381570392d282d83aafad375 100644 (file)
@@ -47,7 +47,7 @@ static void ccw_timeout_log(struct ccw_device *cdev)
        orb = &private->orb;
        cc = stsch(sch->schid, &schib);
 
-       printk(KERN_WARNING "cio: ccw device timeout occurred at %llx, "
+       printk(KERN_WARNING "cio: ccw device timeout occurred at %lx, "
               "device information:\n", get_tod_clock());
        printk(KERN_WARNING "cio: orb:\n");
        print_hex_dump(KERN_WARNING, "cio:  ", DUMP_PREFIX_NONE, 16, 1,
index 68106be4ba7a19b5fb182e820cf92cc132eb328e..767ac41686fe2f123a23e8c099aad17a23fc9836 100644 (file)
@@ -543,7 +543,7 @@ static ssize_t vfio_ccw_mdev_ioctl(struct mdev_device *mdev,
                if (ret)
                        return ret;
 
-               return copy_to_user((void __user *)arg, &info, minsz);
+               return copy_to_user((void __user *)arg, &info, minsz) ? -EFAULT : 0;
        }
        case VFIO_DEVICE_GET_REGION_INFO:
        {
@@ -561,7 +561,7 @@ static ssize_t vfio_ccw_mdev_ioctl(struct mdev_device *mdev,
                if (ret)
                        return ret;
 
-               return copy_to_user((void __user *)arg, &info, minsz);
+               return copy_to_user((void __user *)arg, &info, minsz) ? -EFAULT : 0;
        }
        case VFIO_DEVICE_GET_IRQ_INFO:
        {
@@ -582,7 +582,7 @@ static ssize_t vfio_ccw_mdev_ioctl(struct mdev_device *mdev,
                if (info.count == -1)
                        return -EINVAL;
 
-               return copy_to_user((void __user *)arg, &info, minsz);
+               return copy_to_user((void __user *)arg, &info, minsz) ? -EFAULT : 0;
        }
        case VFIO_DEVICE_SET_IRQS:
        {
index 41fc2e4135fe18714aba0a9e39748fe826886067..1ffdd411201cd62333d0efdd988d33a3ba116c85 100644 (file)
@@ -1286,7 +1286,7 @@ static int vfio_ap_mdev_get_device_info(unsigned long arg)
        info.num_regions = 0;
        info.num_irqs = 0;
 
-       return copy_to_user((void __user *)arg, &info, minsz);
+       return copy_to_user((void __user *)arg, &info, minsz) ? -EFAULT : 0;
 }
 
 static ssize_t vfio_ap_mdev_ioctl(struct mdev_device *mdev,
index a1da83b0b0ef329f2684408a10647412bb16efd2..91acff493612aaa7082f391a4bfd99d086889a1e 100644 (file)
@@ -436,7 +436,7 @@ struct qeth_qdio_out_buffer {
        int is_header[QDIO_MAX_ELEMENTS_PER_BUFFER];
 
        struct qeth_qdio_out_q *q;
-       struct qeth_qdio_out_buffer *next_pending;
+       struct list_head list_entry;
 };
 
 struct qeth_card;
@@ -500,6 +500,7 @@ struct qeth_qdio_out_q {
        struct qdio_buffer *qdio_bufs[QDIO_MAX_BUFFERS_PER_Q];
        struct qeth_qdio_out_buffer *bufs[QDIO_MAX_BUFFERS_PER_Q];
        struct qdio_outbuf_state *bufstates; /* convenience pointer */
+       struct list_head pending_bufs;
        struct qeth_out_q_stats stats;
        spinlock_t lock;
        unsigned int priority;
index b71b8902d1c49a66fae6072f84336d3afbbdaeaf..a814698387bc37d397e64ee3546a2b67b5ac1bee 100644 (file)
@@ -73,8 +73,6 @@ static void qeth_free_qdio_queues(struct qeth_card *card);
 static void qeth_notify_skbs(struct qeth_qdio_out_q *queue,
                struct qeth_qdio_out_buffer *buf,
                enum iucv_tx_notify notification);
-static void qeth_tx_complete_buf(struct qeth_qdio_out_buffer *buf, bool error,
-                                int budget);
 
 static void qeth_close_dev_handler(struct work_struct *work)
 {
@@ -465,41 +463,6 @@ static enum iucv_tx_notify qeth_compute_cq_notification(int sbalf15,
        return n;
 }
 
-static void qeth_cleanup_handled_pending(struct qeth_qdio_out_q *q, int bidx,
-                                        int forced_cleanup)
-{
-       if (q->card->options.cq != QETH_CQ_ENABLED)
-               return;
-
-       if (q->bufs[bidx]->next_pending != NULL) {
-               struct qeth_qdio_out_buffer *head = q->bufs[bidx];
-               struct qeth_qdio_out_buffer *c = q->bufs[bidx]->next_pending;
-
-               while (c) {
-                       if (forced_cleanup ||
-                           atomic_read(&c->state) == QETH_QDIO_BUF_EMPTY) {
-                               struct qeth_qdio_out_buffer *f = c;
-
-                               QETH_CARD_TEXT(f->q->card, 5, "fp");
-                               QETH_CARD_TEXT_(f->q->card, 5, "%lx", (long) f);
-                               /* release here to avoid interleaving between
-                                  outbound tasklet and inbound tasklet
-                                  regarding notifications and lifecycle */
-                               qeth_tx_complete_buf(c, forced_cleanup, 0);
-
-                               c = f->next_pending;
-                               WARN_ON_ONCE(head->next_pending != f);
-                               head->next_pending = c;
-                               kmem_cache_free(qeth_qdio_outbuf_cache, f);
-                       } else {
-                               head = c;
-                               c = c->next_pending;
-                       }
-
-               }
-       }
-}
-
 static void qeth_qdio_handle_aob(struct qeth_card *card,
                                 unsigned long phys_aob_addr)
 {
@@ -507,6 +470,7 @@ static void qeth_qdio_handle_aob(struct qeth_card *card,
        struct qaob *aob;
        struct qeth_qdio_out_buffer *buffer;
        enum iucv_tx_notify notification;
+       struct qeth_qdio_out_q *queue;
        unsigned int i;
 
        aob = (struct qaob *) phys_to_virt(phys_aob_addr);
@@ -537,7 +501,7 @@ static void qeth_qdio_handle_aob(struct qeth_card *card,
                qeth_notify_skbs(buffer->q, buffer, notification);
 
                /* Free dangling allocations. The attached skbs are handled by
-                * qeth_cleanup_handled_pending().
+                * qeth_tx_complete_pending_bufs().
                 */
                for (i = 0;
                     i < aob->sb_count && i < QETH_MAX_BUFFER_ELEMENTS(card);
@@ -549,7 +513,9 @@ static void qeth_qdio_handle_aob(struct qeth_card *card,
                        buffer->is_header[i] = 0;
                }
 
+               queue = buffer->q;
                atomic_set(&buffer->state, QETH_QDIO_BUF_EMPTY);
+               napi_schedule(&queue->napi);
                break;
        default:
                WARN_ON_ONCE(1);
@@ -1424,9 +1390,6 @@ static void qeth_tx_complete_buf(struct qeth_qdio_out_buffer *buf, bool error,
        struct qeth_qdio_out_q *queue = buf->q;
        struct sk_buff *skb;
 
-       if (atomic_read(&buf->state) == QETH_QDIO_BUF_PENDING)
-               qeth_notify_skbs(queue, buf, TX_NOTIFY_GENERALERROR);
-
        /* Empty buffer? */
        if (buf->next_element_to_fill == 0)
                return;
@@ -1488,14 +1451,38 @@ static void qeth_clear_output_buffer(struct qeth_qdio_out_q *queue,
        atomic_set(&buf->state, QETH_QDIO_BUF_EMPTY);
 }
 
+static void qeth_tx_complete_pending_bufs(struct qeth_card *card,
+                                         struct qeth_qdio_out_q *queue,
+                                         bool drain)
+{
+       struct qeth_qdio_out_buffer *buf, *tmp;
+
+       list_for_each_entry_safe(buf, tmp, &queue->pending_bufs, list_entry) {
+               if (drain || atomic_read(&buf->state) == QETH_QDIO_BUF_EMPTY) {
+                       QETH_CARD_TEXT(card, 5, "fp");
+                       QETH_CARD_TEXT_(card, 5, "%lx", (long) buf);
+
+                       if (drain)
+                               qeth_notify_skbs(queue, buf,
+                                                TX_NOTIFY_GENERALERROR);
+                       qeth_tx_complete_buf(buf, drain, 0);
+
+                       list_del(&buf->list_entry);
+                       kmem_cache_free(qeth_qdio_outbuf_cache, buf);
+               }
+       }
+}
+
 static void qeth_drain_output_queue(struct qeth_qdio_out_q *q, bool free)
 {
        int j;
 
+       qeth_tx_complete_pending_bufs(q->card, q, true);
+
        for (j = 0; j < QDIO_MAX_BUFFERS_PER_Q; ++j) {
                if (!q->bufs[j])
                        continue;
-               qeth_cleanup_handled_pending(q, j, 1);
+
                qeth_clear_output_buffer(q, q->bufs[j], true, 0);
                if (free) {
                        kmem_cache_free(qeth_qdio_outbuf_cache, q->bufs[j]);
@@ -2615,7 +2602,6 @@ static int qeth_init_qdio_out_buf(struct qeth_qdio_out_q *q, int bidx)
        skb_queue_head_init(&newbuf->skb_list);
        lockdep_set_class(&newbuf->skb_list.lock, &qdio_out_skb_queue_key);
        newbuf->q = q;
-       newbuf->next_pending = q->bufs[bidx];
        atomic_set(&newbuf->state, QETH_QDIO_BUF_EMPTY);
        q->bufs[bidx] = newbuf;
        return 0;
@@ -2634,15 +2620,28 @@ static void qeth_free_output_queue(struct qeth_qdio_out_q *q)
 static struct qeth_qdio_out_q *qeth_alloc_output_queue(void)
 {
        struct qeth_qdio_out_q *q = kzalloc(sizeof(*q), GFP_KERNEL);
+       unsigned int i;
 
        if (!q)
                return NULL;
 
-       if (qdio_alloc_buffers(q->qdio_bufs, QDIO_MAX_BUFFERS_PER_Q)) {
-               kfree(q);
-               return NULL;
+       if (qdio_alloc_buffers(q->qdio_bufs, QDIO_MAX_BUFFERS_PER_Q))
+               goto err_qdio_bufs;
+
+       for (i = 0; i < QDIO_MAX_BUFFERS_PER_Q; i++) {
+               if (qeth_init_qdio_out_buf(q, i))
+                       goto err_out_bufs;
        }
+
        return q;
+
+err_out_bufs:
+       while (i > 0)
+               kmem_cache_free(qeth_qdio_outbuf_cache, q->bufs[--i]);
+       qdio_free_buffers(q->qdio_bufs, QDIO_MAX_BUFFERS_PER_Q);
+err_qdio_bufs:
+       kfree(q);
+       return NULL;
 }
 
 static void qeth_tx_completion_timer(struct timer_list *timer)
@@ -2655,7 +2654,7 @@ static void qeth_tx_completion_timer(struct timer_list *timer)
 
 static int qeth_alloc_qdio_queues(struct qeth_card *card)
 {
-       int i, j;
+       unsigned int i;
 
        QETH_CARD_TEXT(card, 2, "allcqdbf");
 
@@ -2684,18 +2683,12 @@ static int qeth_alloc_qdio_queues(struct qeth_card *card)
                card->qdio.out_qs[i] = queue;
                queue->card = card;
                queue->queue_no = i;
+               INIT_LIST_HEAD(&queue->pending_bufs);
                spin_lock_init(&queue->lock);
                timer_setup(&queue->timer, qeth_tx_completion_timer, 0);
                queue->coalesce_usecs = QETH_TX_COALESCE_USECS;
                queue->max_coalesced_frames = QETH_TX_MAX_COALESCED_FRAMES;
                queue->priority = QETH_QIB_PQUE_PRIO_DEFAULT;
-
-               /* give outbound qeth_qdio_buffers their qdio_buffers */
-               for (j = 0; j < QDIO_MAX_BUFFERS_PER_Q; ++j) {
-                       WARN_ON(queue->bufs[j]);
-                       if (qeth_init_qdio_out_buf(queue, j))
-                               goto out_freeoutqbufs;
-               }
        }
 
        /* completion */
@@ -2704,13 +2697,6 @@ static int qeth_alloc_qdio_queues(struct qeth_card *card)
 
        return 0;
 
-out_freeoutqbufs:
-       while (j > 0) {
-               --j;
-               kmem_cache_free(qeth_qdio_outbuf_cache,
-                               card->qdio.out_qs[i]->bufs[j]);
-               card->qdio.out_qs[i]->bufs[j] = NULL;
-       }
 out_freeoutq:
        while (i > 0) {
                qeth_free_output_queue(card->qdio.out_qs[--i]);
@@ -6107,6 +6093,8 @@ static void qeth_iqd_tx_complete(struct qeth_qdio_out_q *queue,
                                        qeth_schedule_recovery(card);
                                }
 
+                               list_add(&buffer->list_entry,
+                                        &queue->pending_bufs);
                                /* Skip clearing the buffer: */
                                return;
                        case QETH_QDIO_BUF_QAOB_OK:
@@ -6162,6 +6150,8 @@ static int qeth_tx_poll(struct napi_struct *napi, int budget)
                unsigned int bytes = 0;
                int completed;
 
+               qeth_tx_complete_pending_bufs(card, queue, false);
+
                if (qeth_out_queue_is_empty(queue)) {
                        napi_complete(napi);
                        return 0;
@@ -6194,7 +6184,6 @@ static int qeth_tx_poll(struct napi_struct *napi, int budget)
 
                        qeth_handle_send_error(card, buffer, error);
                        qeth_iqd_tx_complete(queue, bidx, error, budget);
-                       qeth_cleanup_handled_pending(queue, bidx, false);
                }
 
                netdev_tx_completed_queue(txq, packets, bytes);
@@ -7249,9 +7238,7 @@ int qeth_open(struct net_device *dev)
        card->data.state = CH_STATE_UP;
        netif_tx_start_all_queues(dev);
 
-       napi_enable(&card->napi);
        local_bh_disable();
-       napi_schedule(&card->napi);
        if (IS_IQD(card)) {
                struct qeth_qdio_out_q *queue;
                unsigned int i;
@@ -7263,8 +7250,12 @@ int qeth_open(struct net_device *dev)
                        napi_schedule(&queue->napi);
                }
        }
+
+       napi_enable(&card->napi);
+       napi_schedule(&card->napi);
        /* kick-start the NAPI softirq: */
        local_bh_enable();
+
        return 0;
 }
 EXPORT_SYMBOL_GPL(qeth_open);
@@ -7274,6 +7265,11 @@ int qeth_stop(struct net_device *dev)
        struct qeth_card *card = dev->ml_priv;
 
        QETH_CARD_TEXT(card, 4, "qethstop");
+
+       napi_disable(&card->napi);
+       cancel_delayed_work_sync(&card->buffer_reclaim_work);
+       qdio_stop_irq(CARD_DDEV(card));
+
        if (IS_IQD(card)) {
                struct qeth_qdio_out_q *queue;
                unsigned int i;
@@ -7294,10 +7290,6 @@ int qeth_stop(struct net_device *dev)
                netif_tx_disable(dev);
        }
 
-       napi_disable(&card->napi);
-       cancel_delayed_work_sync(&card->buffer_reclaim_work);
-       qdio_stop_irq(CARD_DDEV(card));
-
        return 0;
 }
 EXPORT_SYMBOL_GPL(qeth_stop);
index 00e72b97d0b6e27b9a763685cfaf444a28dfd080..d93595b39afa97a3cc705ebf6f27a4a39bcab354 100644 (file)
@@ -50,7 +50,6 @@ MODULE_PARM_DESC(sol_compat,
 MODULE_AUTHOR("Eric Brower <ebrower@usa.net>");
 MODULE_DESCRIPTION("7-Segment Display driver for Sun Microsystems CP1400/1500");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("d7s");
 
 struct d7s {
        void __iomem    *regs;
index 38369766511c4cff1b21654ab207a3d4f57d5209..f135a10f582bc0f92fa3afa406aac6f37bc14b48 100644 (file)
@@ -80,7 +80,6 @@
 MODULE_AUTHOR("Hewlett-Packard Company");
 MODULE_DESCRIPTION("Driver for HP Smart Array Controller version " \
        HPSA_DRIVER_VERSION);
-MODULE_SUPPORTED_DEVICE("HP Smart Array Controllers");
 MODULE_VERSION(HPSA_DRIVER_VERSION);
 MODULE_LICENSE("GPL");
 MODULE_ALIAS("cciss");
index 755313b766b914aed345a124b0052c1e969b1740..f140eafc0d6a2df1fa3f6e5c0f1cc42be1ce7f1a 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/bsg-lib.h>
 #include <asm/firmware.h>
 #include <asm/irq.h>
+#include <asm/rtas.h>
 #include <asm/vio.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
@@ -158,6 +159,9 @@ static void ibmvfc_npiv_logout(struct ibmvfc_host *);
 static void ibmvfc_tgt_implicit_logout_and_del(struct ibmvfc_target *);
 static void ibmvfc_tgt_move_login(struct ibmvfc_target *);
 
+static void ibmvfc_release_sub_crqs(struct ibmvfc_host *);
+static void ibmvfc_init_sub_crqs(struct ibmvfc_host *);
+
 static const char *unknown_error = "unknown error";
 
 static long h_reg_sub_crq(unsigned long unit_address, unsigned long ioba,
@@ -899,6 +903,9 @@ static int ibmvfc_reenable_crq_queue(struct ibmvfc_host *vhost)
 {
        int rc = 0;
        struct vio_dev *vdev = to_vio_dev(vhost->dev);
+       unsigned long flags;
+
+       ibmvfc_release_sub_crqs(vhost);
 
        /* Re-enable the CRQ */
        do {
@@ -910,6 +917,15 @@ static int ibmvfc_reenable_crq_queue(struct ibmvfc_host *vhost)
        if (rc)
                dev_err(vhost->dev, "Error enabling adapter (rc=%d)\n", rc);
 
+       spin_lock_irqsave(vhost->host->host_lock, flags);
+       spin_lock(vhost->crq.q_lock);
+       vhost->do_enquiry = 1;
+       vhost->using_channels = 0;
+       spin_unlock(vhost->crq.q_lock);
+       spin_unlock_irqrestore(vhost->host->host_lock, flags);
+
+       ibmvfc_init_sub_crqs(vhost);
+
        return rc;
 }
 
@@ -926,8 +942,8 @@ static int ibmvfc_reset_crq(struct ibmvfc_host *vhost)
        unsigned long flags;
        struct vio_dev *vdev = to_vio_dev(vhost->dev);
        struct ibmvfc_queue *crq = &vhost->crq;
-       struct ibmvfc_queue *scrq;
-       int i;
+
+       ibmvfc_release_sub_crqs(vhost);
 
        /* Close the CRQ */
        do {
@@ -947,16 +963,6 @@ static int ibmvfc_reset_crq(struct ibmvfc_host *vhost)
        memset(crq->msgs.crq, 0, PAGE_SIZE);
        crq->cur = 0;
 
-       if (vhost->scsi_scrqs.scrqs) {
-               for (i = 0; i < nr_scsi_hw_queues; i++) {
-                       scrq = &vhost->scsi_scrqs.scrqs[i];
-                       spin_lock(scrq->q_lock);
-                       memset(scrq->msgs.scrq, 0, PAGE_SIZE);
-                       scrq->cur = 0;
-                       spin_unlock(scrq->q_lock);
-               }
-       }
-
        /* And re-open it again */
        rc = plpar_hcall_norets(H_REG_CRQ, vdev->unit_address,
                                crq->msg_token, PAGE_SIZE);
@@ -966,9 +972,12 @@ static int ibmvfc_reset_crq(struct ibmvfc_host *vhost)
                dev_warn(vhost->dev, "Partner adapter not ready\n");
        else if (rc != 0)
                dev_warn(vhost->dev, "Couldn't register crq (rc=%d)\n", rc);
+
        spin_unlock(vhost->crq.q_lock);
        spin_unlock_irqrestore(vhost->host->host_lock, flags);
 
+       ibmvfc_init_sub_crqs(vhost);
+
        return rc;
 }
 
@@ -5642,7 +5651,8 @@ static int ibmvfc_register_scsi_channel(struct ibmvfc_host *vhost,
        rc = h_reg_sub_crq(vdev->unit_address, scrq->msg_token, PAGE_SIZE,
                           &scrq->cookie, &scrq->hw_irq);
 
-       if (rc) {
+       /* H_CLOSED indicates successful register, but no CRQ partner */
+       if (rc && rc != H_CLOSED) {
                dev_warn(dev, "Error registering sub-crq: %d\n", rc);
                if (rc == H_PARAMETER)
                        dev_warn_once(dev, "Firmware may not support MQ\n");
@@ -5675,8 +5685,8 @@ static int ibmvfc_register_scsi_channel(struct ibmvfc_host *vhost,
 
 irq_failed:
        do {
-               plpar_hcall_norets(H_FREE_SUB_CRQ, vdev->unit_address, scrq->cookie);
-       } while (rc == H_BUSY || H_IS_LONG_BUSY(rc));
+               rc = plpar_hcall_norets(H_FREE_SUB_CRQ, vdev->unit_address, scrq->cookie);
+       } while (rtas_busy_delay(rc));
 reg_failed:
        ibmvfc_free_queue(vhost, scrq);
        LEAVE;
@@ -5694,6 +5704,7 @@ static void ibmvfc_deregister_scsi_channel(struct ibmvfc_host *vhost, int index)
 
        free_irq(scrq->irq, scrq);
        irq_dispose_mapping(scrq->irq);
+       scrq->irq = 0;
 
        do {
                rc = plpar_hcall_norets(H_FREE_SUB_CRQ, vdev->unit_address,
@@ -5707,17 +5718,21 @@ static void ibmvfc_deregister_scsi_channel(struct ibmvfc_host *vhost, int index)
        LEAVE;
 }
 
-static int ibmvfc_init_sub_crqs(struct ibmvfc_host *vhost)
+static void ibmvfc_init_sub_crqs(struct ibmvfc_host *vhost)
 {
        int i, j;
 
        ENTER;
+       if (!vhost->mq_enabled)
+               return;
 
        vhost->scsi_scrqs.scrqs = kcalloc(nr_scsi_hw_queues,
                                          sizeof(*vhost->scsi_scrqs.scrqs),
                                          GFP_KERNEL);
-       if (!vhost->scsi_scrqs.scrqs)
-               return -1;
+       if (!vhost->scsi_scrqs.scrqs) {
+               vhost->do_enquiry = 0;
+               return;
+       }
 
        for (i = 0; i < nr_scsi_hw_queues; i++) {
                if (ibmvfc_register_scsi_channel(vhost, i)) {
@@ -5726,13 +5741,12 @@ static int ibmvfc_init_sub_crqs(struct ibmvfc_host *vhost)
                        kfree(vhost->scsi_scrqs.scrqs);
                        vhost->scsi_scrqs.scrqs = NULL;
                        vhost->scsi_scrqs.active_queues = 0;
-                       LEAVE;
-                       return -1;
+                       vhost->do_enquiry = 0;
+                       break;
                }
        }
 
        LEAVE;
-       return 0;
 }
 
 static void ibmvfc_release_sub_crqs(struct ibmvfc_host *vhost)
@@ -5770,6 +5784,8 @@ static void ibmvfc_free_mem(struct ibmvfc_host *vhost)
                          vhost->disc_buf_dma);
        dma_free_coherent(vhost->dev, sizeof(*vhost->login_buf),
                          vhost->login_buf, vhost->login_buf_dma);
+       dma_free_coherent(vhost->dev, sizeof(*vhost->channel_setup_buf),
+                         vhost->channel_setup_buf, vhost->channel_setup_dma);
        dma_pool_destroy(vhost->sg_pool);
        ibmvfc_free_queue(vhost, async_q);
        LEAVE;
@@ -5999,11 +6015,7 @@ static int ibmvfc_probe(struct vio_dev *vdev, const struct vio_device_id *id)
                goto remove_shost;
        }
 
-       if (vhost->mq_enabled) {
-               rc = ibmvfc_init_sub_crqs(vhost);
-               if (rc)
-                       dev_warn(dev, "Failed to allocate Sub-CRQs. rc=%d\n", rc);
-       }
+       ibmvfc_init_sub_crqs(vhost);
 
        if (shost_to_fc_host(shost)->rqst_q)
                blk_queue_max_segments(shost_to_fc_host(shost)->rqst_q, 1);
@@ -6038,7 +6050,7 @@ out:
  * Return value:
  *     0
  **/
-static int ibmvfc_remove(struct vio_dev *vdev)
+static void ibmvfc_remove(struct vio_dev *vdev)
 {
        struct ibmvfc_host *vhost = dev_get_drvdata(&vdev->dev);
        LIST_HEAD(purge);
@@ -6070,7 +6082,6 @@ static int ibmvfc_remove(struct vio_dev *vdev)
        spin_unlock(&ibmvfc_driver_lock);
        scsi_host_put(vhost->host);
        LEAVE;
-       return 0;
 }
 
 /**
index 29fcc44be2d57f800363a8f8a5cfe98585c89a20..77fafb1bc173a1dc2fd1bdf6e037f501cf5d20d0 100644 (file)
@@ -2335,7 +2335,7 @@ static int ibmvscsi_probe(struct vio_dev *vdev, const struct vio_device_id *id)
        return -1;
 }
 
-static int ibmvscsi_remove(struct vio_dev *vdev)
+static void ibmvscsi_remove(struct vio_dev *vdev)
 {
        struct ibmvscsi_host_data *hostdata = dev_get_drvdata(&vdev->dev);
 
@@ -2356,8 +2356,6 @@ static int ibmvscsi_remove(struct vio_dev *vdev)
        spin_unlock(&ibmvscsi_driver_lock);
 
        scsi_host_put(hostdata->host);
-
-       return 0;
 }
 
 /**
index cc3908c2d2f943173e0bc6cffe7770032d1eb2a8..9abd9e253af60e88b79b6821757d8499517a3733 100644 (file)
@@ -3595,7 +3595,7 @@ free_adapter:
        return rc;
 }
 
-static int ibmvscsis_remove(struct vio_dev *vdev)
+static void ibmvscsis_remove(struct vio_dev *vdev)
 {
        struct scsi_info *vscsi = dev_get_drvdata(&vdev->dev);
 
@@ -3622,8 +3622,6 @@ static int ibmvscsis_remove(struct vio_dev *vdev)
        list_del(&vscsi->list);
        spin_unlock_bh(&ibmvscsis_dev_lock);
        kfree(vscsi);
-
-       return 0;
 }
 
 static ssize_t system_id_show(struct device *dev,
index bc79a017e1a21b8449aa2e6d2828d51c8c1c6e11..46a8f2d1d2b83b8aa775238f8acb98c38db4d423 100644 (file)
@@ -2421,7 +2421,7 @@ lpfc_debugfs_dif_err_write(struct file *file, const char __user *buf,
        memset(dstbuf, 0, 33);
        size = (nbytes < 32) ? nbytes : 32;
        if (copy_from_user(dstbuf, buf, size))
-               return 0;
+               return -EFAULT;
 
        if (dent == phba->debug_InjErrLBA) {
                if ((dstbuf[0] == 'o') && (dstbuf[1] == 'f') &&
@@ -2430,7 +2430,7 @@ lpfc_debugfs_dif_err_write(struct file *file, const char __user *buf,
        }
 
        if ((tmp == 0) && (kstrtoull(dstbuf, 0, &tmp)))
-               return 0;
+               return -EINVAL;
 
        if (dent == phba->debug_writeGuard)
                phba->lpfc_injerr_wgrd_cnt = (uint32_t)tmp;
index ffca0306479779abe1f8f7ee20d017b00f5753dc..6aa6de72918761c84801035d74e87a5e68f89cfd 100644 (file)
@@ -413,7 +413,7 @@ mpt3sas_get_port_by_id(struct MPT3SAS_ADAPTER *ioc,
         * And add this object to port_table_list.
         */
        if (!ioc->multipath_on_hba) {
-               port = kzalloc(sizeof(struct hba_port), GFP_KERNEL);
+               port = kzalloc(sizeof(struct hba_port), GFP_ATOMIC);
                if (!port)
                        return NULL;
 
index 4adf9ded296aa60667d27835ac3c82d7f946d7fb..329fd025c718986f61e8d529e3a8ca7dd7d53794 100644 (file)
@@ -2273,12 +2273,12 @@ static void myrs_cleanup(struct myrs_hba *cs)
        if (cs->mmio_base) {
                cs->disable_intr(cs);
                iounmap(cs->mmio_base);
+               cs->mmio_base = NULL;
        }
        if (cs->irq)
                free_irq(cs->irq, cs);
        if (cs->io_addr)
                release_region(cs->io_addr, 0x80);
-       iounmap(cs->mmio_base);
        pci_set_drvdata(pdev, NULL);
        pci_disable_device(pdev);
        scsi_host_put(cs->host);
index 5d5f50d6a02d7cbbda482b56accfc3b7b1353ecd..ac89002646a3e309df8ba20c807cce334309b41e 100644 (file)
@@ -55,7 +55,6 @@
 
 MODULE_AUTHOR("YOKOTA Hiroshi <yokota@netlab.is.tsukuba.ac.jp>");
 MODULE_DESCRIPTION("WorkBit NinjaSCSI-3 / NinjaSCSI-32Bi(16bit) PCMCIA SCSI host adapter module");
-MODULE_SUPPORTED_DEVICE("sd,sr,sg,st");
 MODULE_LICENSE("GPL");
 
 #include "nsp_io.h"
index 10e5e6c8087dc8993f6a64d3239b9b6e77074c48..01620f3eab39f8783b70b894a306228d43336a58 100644 (file)
        (min(1270, ((ql) > 0) ? (QLA_TGT_DATASEGS_PER_CMD_24XX + \
                QLA_TGT_DATASEGS_PER_CONT_24XX*((ql) - 1)) : 0))
 #endif
-#endif
 
 #define GET_TARGET_ID(ha, iocb) ((HAS_EXTENDED_IDS(ha))                        \
                         ? le16_to_cpu((iocb)->u.isp2x.target.extended) \
@@ -244,6 +243,7 @@ struct ctio_to_2xxx {
 #ifndef CTIO_RET_TYPE
 #define CTIO_RET_TYPE  0x17            /* CTIO return entry */
 #define ATIO_TYPE7 0x06 /* Accept target I/O entry for 24xx */
+#endif
 
 struct fcp_hdr {
        uint8_t  r_ctl;
index ee558675eab4aa862850dd86a620570e1e4fe98a..994f1b8e3504df17006ce3dff4cc7a0eaec9eda9 100644 (file)
@@ -280,27 +280,28 @@ static int sd_zbc_update_wp_offset_cb(struct blk_zone *zone, unsigned int idx,
 static void sd_zbc_update_wp_offset_workfn(struct work_struct *work)
 {
        struct scsi_disk *sdkp;
+       unsigned long flags;
        unsigned int zno;
        int ret;
 
        sdkp = container_of(work, struct scsi_disk, zone_wp_offset_work);
 
-       spin_lock_bh(&sdkp->zones_wp_offset_lock);
+       spin_lock_irqsave(&sdkp->zones_wp_offset_lock, flags);
        for (zno = 0; zno < sdkp->nr_zones; zno++) {
                if (sdkp->zones_wp_offset[zno] != SD_ZBC_UPDATING_WP_OFST)
                        continue;
 
-               spin_unlock_bh(&sdkp->zones_wp_offset_lock);
+               spin_unlock_irqrestore(&sdkp->zones_wp_offset_lock, flags);
                ret = sd_zbc_do_report_zones(sdkp, sdkp->zone_wp_update_buf,
                                             SD_BUF_SIZE,
                                             zno * sdkp->zone_blocks, true);
-               spin_lock_bh(&sdkp->zones_wp_offset_lock);
+               spin_lock_irqsave(&sdkp->zones_wp_offset_lock, flags);
                if (!ret)
                        sd_zbc_parse_report(sdkp, sdkp->zone_wp_update_buf + 64,
                                            zno, sd_zbc_update_wp_offset_cb,
                                            sdkp);
        }
-       spin_unlock_bh(&sdkp->zones_wp_offset_lock);
+       spin_unlock_irqrestore(&sdkp->zones_wp_offset_lock, flags);
 
        scsi_device_put(sdkp->device);
 }
@@ -324,6 +325,7 @@ blk_status_t sd_zbc_prepare_zone_append(struct scsi_cmnd *cmd, sector_t *lba,
        struct request *rq = cmd->request;
        struct scsi_disk *sdkp = scsi_disk(rq->rq_disk);
        unsigned int wp_offset, zno = blk_rq_zone_no(rq);
+       unsigned long flags;
        blk_status_t ret;
 
        ret = sd_zbc_cmnd_checks(cmd);
@@ -337,7 +339,7 @@ blk_status_t sd_zbc_prepare_zone_append(struct scsi_cmnd *cmd, sector_t *lba,
        if (!blk_req_zone_write_trylock(rq))
                return BLK_STS_ZONE_RESOURCE;
 
-       spin_lock_bh(&sdkp->zones_wp_offset_lock);
+       spin_lock_irqsave(&sdkp->zones_wp_offset_lock, flags);
        wp_offset = sdkp->zones_wp_offset[zno];
        switch (wp_offset) {
        case SD_ZBC_INVALID_WP_OFST:
@@ -366,7 +368,7 @@ blk_status_t sd_zbc_prepare_zone_append(struct scsi_cmnd *cmd, sector_t *lba,
 
                *lba += wp_offset;
        }
-       spin_unlock_bh(&sdkp->zones_wp_offset_lock);
+       spin_unlock_irqrestore(&sdkp->zones_wp_offset_lock, flags);
        if (ret)
                blk_req_zone_write_unlock(rq);
        return ret;
@@ -445,6 +447,7 @@ static unsigned int sd_zbc_zone_wp_update(struct scsi_cmnd *cmd,
        struct scsi_disk *sdkp = scsi_disk(rq->rq_disk);
        unsigned int zno = blk_rq_zone_no(rq);
        enum req_opf op = req_op(rq);
+       unsigned long flags;
 
        /*
         * If we got an error for a command that needs updating the write
@@ -452,7 +455,7 @@ static unsigned int sd_zbc_zone_wp_update(struct scsi_cmnd *cmd,
         * invalid to force an update from disk the next time a zone append
         * command is issued.
         */
-       spin_lock_bh(&sdkp->zones_wp_offset_lock);
+       spin_lock_irqsave(&sdkp->zones_wp_offset_lock, flags);
 
        if (result && op != REQ_OP_ZONE_RESET_ALL) {
                if (op == REQ_OP_ZONE_APPEND) {
@@ -496,7 +499,7 @@ static unsigned int sd_zbc_zone_wp_update(struct scsi_cmnd *cmd,
        }
 
 unlock_wp_offset:
-       spin_unlock_bh(&sdkp->zones_wp_offset_lock);
+       spin_unlock_irqrestore(&sdkp->zones_wp_offset_lock, flags);
 
        return good_bytes;
 }
index c53f456fbd094ac222dc11c286783f41d339f82b..a1dacb6e993e7a8319b15f9d642724b757a46917 100644 (file)
@@ -48,7 +48,6 @@
 MODULE_AUTHOR("Microsemi");
 MODULE_DESCRIPTION("Driver for Microsemi Smart Family Controller version "
        DRIVER_VERSION);
-MODULE_SUPPORTED_DEVICE("Microsemi Smart Family Controllers");
 MODULE_VERSION(DRIVER_VERSION);
 MODULE_LICENSE("GPL");
 
index 841ad2fc369a070b81958f9dcd8688616c24bcea..9ca536aae784918700ec944ab7d3a849f972441c 100644 (file)
@@ -1269,8 +1269,8 @@ static int st_open(struct inode *inode, struct file *filp)
        spin_lock(&st_use_lock);
        if (STp->in_use) {
                spin_unlock(&st_use_lock);
-               scsi_tape_put(STp);
                DEBC_printk(STp, "Device already in use.\n");
+               scsi_tape_put(STp);
                return (-EBUSY);
        }
 
index c55202b92a43a1b307862192e46ce11eb3258b9d..a981f261b3043cae5861ce82e8d56c4003c50fab 100644 (file)
@@ -911,7 +911,7 @@ static void ufs_mtk_vreg_set_lpm(struct ufs_hba *hba, bool lpm)
        if (!hba->vreg_info.vccq2 || !hba->vreg_info.vcc)
                return;
 
-       if (lpm & !hba->vreg_info.vcc->enabled)
+       if (lpm && !hba->vreg_info.vcc->enabled)
                regulator_set_mode(hba->vreg_info.vccq2->reg,
                                   REGULATOR_MODE_IDLE);
        else if (!lpm)
index f97d7b0ae3b6a175b905f8cf63a060b7c7cea613..a9dc8d7c9f784b63ecdbec3c4164d0bac79e8019 100644 (file)
@@ -253,12 +253,17 @@ static int ufs_qcom_host_reset(struct ufs_hba *hba)
 {
        int ret = 0;
        struct ufs_qcom_host *host = ufshcd_get_variant(hba);
+       bool reenable_intr = false;
 
        if (!host->core_reset) {
                dev_warn(hba->dev, "%s: reset control not set\n", __func__);
                goto out;
        }
 
+       reenable_intr = hba->is_irq_enabled;
+       disable_irq(hba->irq);
+       hba->is_irq_enabled = false;
+
        ret = reset_control_assert(host->core_reset);
        if (ret) {
                dev_err(hba->dev, "%s: core_reset assert failed, err = %d\n",
@@ -280,6 +285,11 @@ static int ufs_qcom_host_reset(struct ufs_hba *hba)
 
        usleep_range(1000, 1100);
 
+       if (reenable_intr) {
+               enable_irq(hba->irq);
+               hba->is_irq_enabled = true;
+       }
+
 out:
        return ret;
 }
index 77161750c9fb34df04e48caf6548600f7b16bac6..c86760788c72c9a6703dd3b997e5e4570d8100a2 100644 (file)
@@ -95,8 +95,6 @@
                       16, 4, buf, __len, false);                        \
 } while (0)
 
-static bool early_suspend;
-
 int ufshcd_dump_regs(struct ufs_hba *hba, size_t offset, size_t len,
                     const char *prefix)
 {
@@ -1535,7 +1533,7 @@ static ssize_t ufshcd_clkscale_enable_show(struct device *dev,
 {
        struct ufs_hba *hba = dev_get_drvdata(dev);
 
-       return snprintf(buf, PAGE_SIZE, "%d\n", hba->clk_scaling.is_enabled);
+       return sysfs_emit(buf, "%d\n", hba->clk_scaling.is_enabled);
 }
 
 static ssize_t ufshcd_clkscale_enable_store(struct device *dev,
@@ -4987,6 +4985,7 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
                         * UFS device needs urgent BKOPs.
                         */
                        if (!hba->pm_op_in_progress &&
+                           !ufshcd_eh_in_progress(hba) &&
                            ufshcd_is_exception_event(lrbp->ucd_rsp_ptr) &&
                            schedule_work(&hba->eeh_work)) {
                                /*
@@ -5784,13 +5783,20 @@ static void ufshcd_err_handling_prepare(struct ufs_hba *hba)
                        ufshcd_suspend_clkscaling(hba);
                ufshcd_clk_scaling_allow(hba, false);
        }
+       ufshcd_scsi_block_requests(hba);
+       /* Drain ufshcd_queuecommand() */
+       down_write(&hba->clk_scaling_lock);
+       up_write(&hba->clk_scaling_lock);
+       cancel_work_sync(&hba->eeh_work);
 }
 
 static void ufshcd_err_handling_unprepare(struct ufs_hba *hba)
 {
+       ufshcd_scsi_unblock_requests(hba);
        ufshcd_release(hba);
        if (ufshcd_is_clkscaling_supported(hba))
                ufshcd_clk_scaling_suspend(hba, false);
+       ufshcd_clear_ua_wluns(hba);
        pm_runtime_put(hba->dev);
 }
 
@@ -5882,8 +5888,8 @@ static void ufshcd_err_handler(struct work_struct *work)
        spin_unlock_irqrestore(hba->host->host_lock, flags);
        ufshcd_err_handling_prepare(hba);
        spin_lock_irqsave(hba->host->host_lock, flags);
-       ufshcd_scsi_block_requests(hba);
-       hba->ufshcd_state = UFSHCD_STATE_RESET;
+       if (hba->ufshcd_state != UFSHCD_STATE_ERROR)
+               hba->ufshcd_state = UFSHCD_STATE_RESET;
 
        /* Complete requests that have door-bell cleared by h/w */
        ufshcd_complete_requests(hba);
@@ -6042,12 +6048,8 @@ skip_err_handling:
        }
        ufshcd_clear_eh_in_progress(hba);
        spin_unlock_irqrestore(hba->host->host_lock, flags);
-       ufshcd_scsi_unblock_requests(hba);
        ufshcd_err_handling_unprepare(hba);
        up(&hba->host_sem);
-
-       if (!err && needs_reset)
-               ufshcd_clear_ua_wluns(hba);
 }
 
 /**
@@ -7858,6 +7860,8 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, bool async)
        unsigned long flags;
        ktime_t start = ktime_get();
 
+       hba->ufshcd_state = UFSHCD_STATE_RESET;
+
        ret = ufshcd_link_startup(hba);
        if (ret)
                goto out;
@@ -8972,11 +8976,6 @@ int ufshcd_system_suspend(struct ufs_hba *hba)
        int ret = 0;
        ktime_t start = ktime_get();
 
-       if (!hba) {
-               early_suspend = true;
-               return 0;
-       }
-
        down(&hba->host_sem);
 
        if (!hba->is_powered)
@@ -9028,14 +9027,6 @@ int ufshcd_system_resume(struct ufs_hba *hba)
        int ret = 0;
        ktime_t start = ktime_get();
 
-       if (!hba)
-               return -EINVAL;
-
-       if (unlikely(early_suspend)) {
-               early_suspend = false;
-               down(&hba->host_sem);
-       }
-
        if (!hba->is_powered || pm_runtime_suspended(hba->dev))
                /*
                 * Let the runtime resume take care of resuming
@@ -9068,9 +9059,6 @@ int ufshcd_runtime_suspend(struct ufs_hba *hba)
        int ret = 0;
        ktime_t start = ktime_get();
 
-       if (!hba)
-               return -EINVAL;
-
        if (!hba->is_powered)
                goto out;
        else
@@ -9109,9 +9097,6 @@ int ufshcd_runtime_resume(struct ufs_hba *hba)
        int ret = 0;
        ktime_t start = ktime_get();
 
-       if (!hba)
-               return -EINVAL;
-
        if (!hba->is_powered)
                goto out;
        else
index 081f54ab7d86cb2a076cc71284a76e8c134145e5..8a79605d9652150b9433c81b8cfd811eb06f13b1 100644 (file)
@@ -17,8 +17,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * Maintained by: Jim Gill <jgill@vmware.com>
- *
  */
 
 #include <linux/kernel.h>
index 75966d3f326e0b20ee49b78cdea0b0d6bd635470..51a82f7803d3c7ede3643dc2ea04fee0cc387989 100644 (file)
@@ -17,8 +17,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * Maintained by: Jim Gill <jgill@vmware.com>
- *
  */
 
 #ifndef _VMW_PVSCSI_H_
index e5d7fb81ad66568d64107c4b592e2b87be33a215..bd0fbcdbdefe9408b018c42ef9a55301d982c049 100644 (file)
@@ -30,7 +30,6 @@
 MODULE_AUTHOR("Adrian McMenamin <adrian@mcmen.demon.co.uk>");
 MODULE_DESCRIPTION("Maple bus driver for Dreamcast");
 MODULE_LICENSE("GPL v2");
-MODULE_SUPPORTED_DEVICE("{{SEGA, Dreamcast/Maple}}");
 
 static void maple_dma_handler(struct work_struct *work);
 static void maple_vblank_handler(struct work_struct *work);
index 442cc7c53a47b97dea6f6a6cd7e9502c5be5b2d4..52ddb3255d88c14dbcbc5a3da493171d5d81dad3 100644 (file)
@@ -1433,6 +1433,7 @@ static int cqspi_probe(struct platform_device *pdev)
        cqspi = spi_master_get_devdata(master);
 
        cqspi->pdev = pdev;
+       platform_set_drvdata(pdev, cqspi);
 
        /* Obtain configuration from OF. */
        ret = cqspi_of_get_pdata(cqspi);
index b22f73d7bfc42eedfdeb5fbd72a4aa0bc02cab9f..7b57b755bfa30083efa47b84759505ae35732b16 100644 (file)
@@ -98,8 +98,6 @@ source "drivers/staging/ralink-gdma/Kconfig"
 
 source "drivers/staging/mt7621-dts/Kconfig"
 
-source "drivers/staging/gasket/Kconfig"
-
 source "drivers/staging/axis-fifo/Kconfig"
 
 source "drivers/staging/fieldbus/Kconfig"
@@ -108,8 +106,6 @@ source "drivers/staging/kpc2000/Kconfig"
 
 source "drivers/staging/qlge/Kconfig"
 
-source "drivers/staging/wimax/Kconfig"
-
 source "drivers/staging/wfx/Kconfig"
 
 source "drivers/staging/hikey9xx/Kconfig"
index 2245059e69c701cbe2b378ee52b40ec6626dfffa..4350423f65aa595cce3dd2b387be693600f8c10c 100644 (file)
@@ -39,11 +39,9 @@ obj-$(CONFIG_PCI_MT7621)     += mt7621-pci/
 obj-$(CONFIG_SOC_MT7621)       += mt7621-dma/
 obj-$(CONFIG_DMA_RALINK)       += ralink-gdma/
 obj-$(CONFIG_SOC_MT7621)       += mt7621-dts/
-obj-$(CONFIG_STAGING_GASKET_FRAMEWORK) += gasket/
 obj-$(CONFIG_XIL_AXIS_FIFO)    += axis-fifo/
 obj-$(CONFIG_FIELDBUS_DEV)     += fieldbus/
 obj-$(CONFIG_KPC2000)          += kpc2000/
 obj-$(CONFIG_QLGE)             += qlge/
-obj-$(CONFIG_WIMAX)            += wimax/
 obj-$(CONFIG_WFX)              += wfx/
 obj-y                          += hikey9xx/
index 35b75f0c9200b9d946d8964fe2af6f8950f31cef..81a246fbcc01f956a43c944d826eff6e522565ee 100644 (file)
@@ -260,6 +260,7 @@ static irqreturn_t apci1032_interrupt(int irq, void *d)
        struct apci1032_private *devpriv = dev->private;
        struct comedi_subdevice *s = dev->read_subdev;
        unsigned int ctrl;
+       unsigned short val;
 
        /* check interrupt is from this device */
        if ((inl(devpriv->amcc_iobase + AMCC_OP_REG_INTCSR) &
@@ -275,7 +276,8 @@ static irqreturn_t apci1032_interrupt(int irq, void *d)
        outl(ctrl & ~APCI1032_CTRL_INT_ENA, dev->iobase + APCI1032_CTRL_REG);
 
        s->state = inl(dev->iobase + APCI1032_STATUS_REG) & 0xffff;
-       comedi_buf_write_samples(s, &s->state, 1);
+       val = s->state;
+       comedi_buf_write_samples(s, &val, 1);
        comedi_handle_events(dev, s);
 
        /* enable the interrupt */
index 11efb21555e395b2e2b86a38132a69f75fc1d9f6..b04c15dcfb57541980d040df6c5ab2e2c44ec6a5 100644 (file)
@@ -208,7 +208,7 @@ static irqreturn_t apci1500_interrupt(int irq, void *d)
        struct comedi_device *dev = d;
        struct apci1500_private *devpriv = dev->private;
        struct comedi_subdevice *s = dev->read_subdev;
-       unsigned int status = 0;
+       unsigned short status = 0;
        unsigned int val;
 
        val = inl(devpriv->amcc + AMCC_OP_REG_INTCSR);
@@ -238,14 +238,14 @@ static irqreturn_t apci1500_interrupt(int irq, void *d)
         *
         *    Mask     Meaning
         * ----------  ------------------------------------------
-        * 0x00000001  Event 1 has occurred
-        * 0x00000010  Event 2 has occurred
-        * 0x00000100  Counter/timer 1 has run down (not implemented)
-        * 0x00001000  Counter/timer 2 has run down (not implemented)
-        * 0x00010000  Counter 3 has run down (not implemented)
-        * 0x00100000  Watchdog has run down (not implemented)
-        * 0x01000000  Voltage error
-        * 0x10000000  Short-circuit error
+        * 0b00000001  Event 1 has occurred
+        * 0b00000010  Event 2 has occurred
+        * 0b00000100  Counter/timer 1 has run down (not implemented)
+        * 0b00001000  Counter/timer 2 has run down (not implemented)
+        * 0b00010000  Counter 3 has run down (not implemented)
+        * 0b00100000  Watchdog has run down (not implemented)
+        * 0b01000000  Voltage error
+        * 0b10000000  Short-circuit error
         */
        comedi_buf_write_samples(s, &status, 1);
        comedi_handle_events(dev, s);
index 692893c7e5c3d06ab2f7161f5d0a0d7df871be42..090607760be6b24e1b9230c65aa8c55aa1999df0 100644 (file)
@@ -300,11 +300,11 @@ static int pci1710_ai_eoc(struct comedi_device *dev,
 static int pci1710_ai_read_sample(struct comedi_device *dev,
                                  struct comedi_subdevice *s,
                                  unsigned int cur_chan,
-                                 unsigned int *val)
+                                 unsigned short *val)
 {
        const struct boardtype *board = dev->board_ptr;
        struct pci1710_private *devpriv = dev->private;
-       unsigned int sample;
+       unsigned short sample;
        unsigned int chan;
 
        sample = inw(dev->iobase + PCI171X_AD_DATA_REG);
@@ -345,7 +345,7 @@ static int pci1710_ai_insn_read(struct comedi_device *dev,
        pci1710_ai_setup_chanlist(dev, s, &insn->chanspec, 1, 1);
 
        for (i = 0; i < insn->n; i++) {
-               unsigned int val;
+               unsigned short val;
 
                /* start conversion */
                outw(0, dev->iobase + PCI171X_SOFTTRG_REG);
@@ -395,7 +395,7 @@ static void pci1710_handle_every_sample(struct comedi_device *dev,
 {
        struct comedi_cmd *cmd = &s->async->cmd;
        unsigned int status;
-       unsigned int val;
+       unsigned short val;
        int ret;
 
        status = inw(dev->iobase + PCI171X_STATUS_REG);
@@ -455,7 +455,7 @@ static void pci1710_handle_fifo(struct comedi_device *dev,
        }
 
        for (i = 0; i < devpriv->max_samples; i++) {
-               unsigned int val;
+               unsigned short val;
                int ret;
 
                ret = pci1710_ai_read_sample(dev, s, s->async->cur_chan, &val);
index 043752663188fd37f3ae697677e549c6ce2a57f4..981d281e87a136f30721db67792e9cfcfabf37e0 100644 (file)
@@ -126,7 +126,9 @@ static irqreturn_t pc236_interrupt(int irq, void *d)
 
        handled = pc236_intr_check(dev);
        if (dev->attached && handled) {
-               comedi_buf_write_samples(s, &s->state, 1);
+               unsigned short val = 0;
+
+               comedi_buf_write_samples(s, &val, 1);
                comedi_handle_events(dev, s);
        }
        return IRQ_RETVAL(handled);
index d740c478277513c73233afce007e239a624d2edc..2f20bd56ec6ca4b1ad6695501473771c092fab78 100644 (file)
@@ -1281,7 +1281,7 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev,
             devpriv->amcc + AMCC_OP_REG_INTCSR);
 
        ret = request_irq(pcidev->irq, cb_pcidas_interrupt, IRQF_SHARED,
-                         dev->board_name, dev);
+                         "cb_pcidas", dev);
        if (ret) {
                dev_dbg(dev->class_dev, "unable to allocate irq %d\n",
                        pcidev->irq);
index fa987bb0e7cd4b628dcbcffc1c647ab3ffde3c47..6d3ba399a7f0bb4e5dc84a4299cee080b6d93d6f 100644 (file)
@@ -4035,7 +4035,7 @@ static int auto_attach(struct comedi_device *dev,
        init_stc_registers(dev);
 
        retval = request_irq(pcidev->irq, handle_interrupt, IRQF_SHARED,
-                            dev->board_name, dev);
+                            "cb_pcidas64", dev);
        if (retval) {
                dev_dbg(dev->class_dev, "unable to allocate irq %u\n",
                        pcidev->irq);
index 9361b2dcf949d4f0ca19b07a7a59b1020f7ca0fb..5338b5eea44023c3f3dfaaa40431df6056f198c2 100644 (file)
@@ -210,12 +210,13 @@ static irqreturn_t parport_interrupt(int irq, void *d)
        struct comedi_device *dev = d;
        struct comedi_subdevice *s = dev->read_subdev;
        unsigned int ctrl;
+       unsigned short val = 0;
 
        ctrl = inb(dev->iobase + PARPORT_CTRL_REG);
        if (!(ctrl & PARPORT_CTRL_IRQ_ENA))
                return IRQ_NONE;
 
-       comedi_buf_write_samples(s, &s->state, 1);
+       comedi_buf_write_samples(s, &val, 1);
        comedi_handle_events(dev, s);
 
        return IRQ_HANDLED;
index 04e224f8b77930db7c052b1b3b4682ba3bcb730a..96f4107b8054df21b3e59cfcb79a207825e30e6f 100644 (file)
@@ -186,7 +186,7 @@ static irqreturn_t das6402_interrupt(int irq, void *d)
        if (status & DAS6402_STATUS_FFULL) {
                async->events |= COMEDI_CB_OVERFLOW;
        } else if (status & DAS6402_STATUS_FFNE) {
-               unsigned int val;
+               unsigned short val;
 
                val = das6402_ai_read_sample(dev, s);
                comedi_buf_write_samples(s, &val, 1);
index 4ea100ff6930f3c91fd5d5aac0192a343863cefb..bc08324f422faf3f1df19c44dbf043e9ed871c12 100644 (file)
@@ -427,7 +427,7 @@ static irqreturn_t das800_interrupt(int irq, void *d)
        struct comedi_cmd *cmd;
        unsigned long irq_flags;
        unsigned int status;
-       unsigned int val;
+       unsigned short val;
        bool fifo_empty;
        bool fifo_overflow;
        int i;
@@ -668,7 +668,7 @@ static int das800_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        dev->board_name = board->name;
 
        if (irq > 1 && irq <= 7) {
-               ret = request_irq(irq, das800_interrupt, 0, dev->board_name,
+               ret = request_irq(irq, das800_interrupt, 0, "das800",
                                  dev);
                if (ret == 0)
                        dev->irq = irq;
index 17e6018918bbf9bc51359f5214756c1adf36cd0d..56682f01242fd024c9900db9a23003e698ee1d85 100644 (file)
@@ -404,7 +404,7 @@ static irqreturn_t dmm32at_isr(int irq, void *d)
 {
        struct comedi_device *dev = d;
        unsigned char intstat;
-       unsigned int val;
+       unsigned short val;
        int i;
 
        if (!dev->attached) {
index 726e40dc17b6212a74b94caf654e4d2a9e6514ff..0d3d4cafce2e81af787fef75a4f6760467d76338 100644 (file)
@@ -924,7 +924,7 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
        struct comedi_subdevice *s = dev->read_subdev;
        int i;
        int c = 0;
-       unsigned int lval;
+       unsigned short lval;
 
        if (!dev->attached)
                return IRQ_NONE;
index 99e744172f4d4f41eee619b0fdf83d7e0041442b..f1a45cf7342ae70da68fe9e91a6c8ac9725377f5 100644 (file)
@@ -195,7 +195,9 @@ static irqreturn_t ni6527_interrupt(int irq, void *d)
                return IRQ_NONE;
 
        if (status & NI6527_STATUS_EDGE) {
-               comedi_buf_write_samples(s, &s->state, 1);
+               unsigned short val = 0;
+
+               comedi_buf_write_samples(s, &val, 1);
                comedi_handle_events(dev, s);
        }
 
index eb3f9f7109da9378ead1833cac4511dd15e655ac..7cd8497420f224844adf74eee69d87cba53231c0 100644 (file)
@@ -472,6 +472,7 @@ static irqreturn_t ni_65xx_interrupt(int irq, void *d)
        struct comedi_device *dev = d;
        struct comedi_subdevice *s = dev->read_subdev;
        unsigned int status;
+       unsigned short val = 0;
 
        status = readb(dev->mmio + NI_65XX_STATUS_REG);
        if ((status & NI_65XX_STATUS_INT) == 0)
@@ -482,7 +483,7 @@ static irqreturn_t ni_65xx_interrupt(int irq, void *d)
        writeb(NI_65XX_CLR_EDGE_INT | NI_65XX_CLR_OVERFLOW_INT,
               dev->mmio + NI_65XX_CLR_REG);
 
-       comedi_buf_write_samples(s, &s->state, 1);
+       comedi_buf_write_samples(s, &val, 1);
        comedi_handle_events(dev, s);
 
        return IRQ_HANDLED;
index 2dbf69e3096507d8f18433152cabf3199b95fdf4..bd6f42fe9e3caf453a3685713c20edb0864cd359 100644 (file)
@@ -184,7 +184,7 @@ static irqreturn_t pcl711_interrupt(int irq, void *d)
        struct comedi_device *dev = d;
        struct comedi_subdevice *s = dev->read_subdev;
        struct comedi_cmd *cmd = &s->async->cmd;
-       unsigned int data;
+       unsigned short data;
 
        if (!dev->attached) {
                dev_err(dev->class_dev, "spurious interrupt\n");
index 64eb649c9813568717fd7ea526426cb7c95509ca..88f25d7e76f7e4448eba9073299dccc7b1c31e13 100644 (file)
@@ -220,9 +220,11 @@ static irqreturn_t pcl726_interrupt(int irq, void *d)
        struct pcl726_private *devpriv = dev->private;
 
        if (devpriv->cmd_running) {
+               unsigned short val = 0;
+
                pcl726_intr_cancel(dev, s);
 
-               comedi_buf_write_samples(s, &s->state, 1);
+               comedi_buf_write_samples(s, &val, 1);
                comedi_handle_events(dev, s);
        }
 
index 63e3011158f2308cbe92bb254ae7aec2162d130d..f4b4a686c710f5302d7eefd0a5518f740cb963ea 100644 (file)
@@ -423,7 +423,7 @@ static int pcl818_ai_eoc(struct comedi_device *dev,
 
 static bool pcl818_ai_write_sample(struct comedi_device *dev,
                                   struct comedi_subdevice *s,
-                                  unsigned int chan, unsigned int val)
+                                  unsigned int chan, unsigned short val)
 {
        struct pcl818_private *devpriv = dev->private;
        struct comedi_cmd *cmd = &s->async->cmd;
index 7956abcbae22bfdd2294b1220d892763bd431b3a..9f920819cd7426542382414c5ee972f86c4cd3d2 100644 (file)
@@ -877,5 +877,4 @@ module_comedi_usb_driver(vmk80xx_driver, vmk80xx_usb_driver);
 
 MODULE_AUTHOR("Manuel Gebele <forensixs@gmx.de>");
 MODULE_DESCRIPTION("Velleman USB Board Low-Level Driver");
-MODULE_SUPPORTED_DEVICE("K8055/K8061 aka VM110/VM140");
 MODULE_LICENSE("GPL");
diff --git a/drivers/staging/gasket/Kconfig b/drivers/staging/gasket/Kconfig
deleted file mode 100644 (file)
index d9bef8c..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-menu "Gasket devices"
-
-config STAGING_GASKET_FRAMEWORK
-       tristate "Gasket framework"
-       depends on PCI && (X86_64 || ARM64)
-       help
-         This framework supports Gasket-compatible devices, such as Apex.
-         It is required for any of the following module(s).
-
-         To compile this driver as a module, choose M here.  The module
-         will be called "gasket".
-
-config STAGING_APEX_DRIVER
-       tristate "Apex Driver"
-       depends on STAGING_GASKET_FRAMEWORK
-       help
-         This driver supports the Apex Edge TPU device.  See
-         https://cloud.google.com/edge-tpu/ for more information.
-         Say Y if you want to include this driver in the kernel.
-
-         To compile this driver as a module, choose M here.  The module
-         will be called "apex".
-
-endmenu
diff --git a/drivers/staging/gasket/Makefile b/drivers/staging/gasket/Makefile
deleted file mode 100644 (file)
index ce03e25..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-#
-#  Makefile for Gasket framework and dependent drivers.
-#
-
-obj-$(CONFIG_STAGING_GASKET_FRAMEWORK) += gasket.o
-obj-$(CONFIG_STAGING_APEX_DRIVER)      += apex.o
-
-gasket-objs    := gasket_core.o gasket_ioctl.o gasket_interrupt.o gasket_page_table.o gasket_sysfs.o
-apex-objs      := apex_driver.o
diff --git a/drivers/staging/gasket/TODO b/drivers/staging/gasket/TODO
deleted file mode 100644 (file)
index 5b1865f..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-This is a list of things that need to be done to get this driver out of the
-staging directory.
-
-- Implement the gasket framework's functionality through UIO instead of
-  introducing a new user-space drivers framework that is quite similar.
-
-  UIO provides the necessary bits to implement user-space drivers. Meanwhile
-  the gasket APIs adds some extra conveniences like PCI BAR mapping, and
-  MSI interrupts. Add these features to the UIO subsystem, then re-implement
-  the Apex driver as a basic UIO driver instead (include/linux/uio_driver.h)
-
-- Document sysfs files with Documentation/ABI/ entries.
-
-- Use misc interface instead of major number for driver version description.
-
-- Add descriptions of module_param's
-
-- apex_get_status() should actually check status.
-
-- "drivers" should never be dealing with "raw" sysfs calls or mess around with
-  kobjects at all. The driver core should handle all of this for you
-  automaically. There should not be a need for raw attribute macros.
diff --git a/drivers/staging/gasket/apex.h b/drivers/staging/gasket/apex.h
deleted file mode 100644 (file)
index 3bbceff..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Apex kernel-userspace interface definitions.
- *
- * Copyright (C) 2018 Google, Inc.
- */
-#ifndef __APEX_H__
-#define __APEX_H__
-
-#include <linux/ioctl.h>
-
-/* Clock Gating ioctl. */
-struct apex_gate_clock_ioctl {
-       /* Enter or leave clock gated state. */
-       u64 enable;
-
-       /* If set, enter clock gating state, regardless of custom block's
-        * internal idle state
-        */
-       u64 force_idle;
-};
-
-/* Base number for all Apex-common IOCTLs */
-#define APEX_IOCTL_BASE 0x7F
-
-/* Enable/Disable clock gating. */
-#define APEX_IOCTL_GATE_CLOCK                                                  \
-       _IOW(APEX_IOCTL_BASE, 0, struct apex_gate_clock_ioctl)
-
-#endif /* __APEX_H__ */
diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c
deleted file mode 100644 (file)
index f12f81c..0000000
+++ /dev/null
@@ -1,726 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Driver for the Apex chip.
- *
- * Copyright (C) 2018 Google, Inc.
- */
-
-#include <linux/compiler.h>
-#include <linux/delay.h>
-#include <linux/device.h>
-#include <linux/fs.h>
-#include <linux/init.h>
-#include <linux/mm.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/pci.h>
-#include <linux/printk.h>
-#include <linux/sched.h>
-#include <linux/uaccess.h>
-
-#include "apex.h"
-
-#include "gasket_core.h"
-#include "gasket_interrupt.h"
-#include "gasket_page_table.h"
-#include "gasket_sysfs.h"
-
-/* Constants */
-#define APEX_DEVICE_NAME "Apex"
-#define APEX_DRIVER_VERSION "1.0"
-
-/* CSRs are in BAR 2. */
-#define APEX_BAR_INDEX 2
-
-#define APEX_PCI_VENDOR_ID 0x1ac1
-#define APEX_PCI_DEVICE_ID 0x089a
-
-/* Bar Offsets. */
-#define APEX_BAR_OFFSET 0
-#define APEX_CM_OFFSET 0x1000000
-
-/* The sizes of each Apex BAR 2. */
-#define APEX_BAR_BYTES 0x100000
-#define APEX_CH_MEM_BYTES (PAGE_SIZE * MAX_NUM_COHERENT_PAGES)
-
-/* The number of user-mappable memory ranges in BAR2 of a Apex chip. */
-#define NUM_REGIONS 3
-
-/* The number of nodes in a Apex chip. */
-#define NUM_NODES 1
-
-/*
- * The total number of entries in the page table. Should match the value read
- * from the register APEX_BAR2_REG_KERNEL_HIB_PAGE_TABLE_SIZE.
- */
-#define APEX_PAGE_TABLE_TOTAL_ENTRIES 8192
-
-#define APEX_EXTENDED_SHIFT 63 /* Extended address bit position. */
-
-/* Check reset 120 times */
-#define APEX_RESET_RETRY 120
-/* Wait 100 ms between checks. Total 12 sec wait maximum. */
-#define APEX_RESET_DELAY 100
-
-/* Enumeration of the supported sysfs entries. */
-enum sysfs_attribute_type {
-       ATTR_KERNEL_HIB_PAGE_TABLE_SIZE,
-       ATTR_KERNEL_HIB_SIMPLE_PAGE_TABLE_SIZE,
-       ATTR_KERNEL_HIB_NUM_ACTIVE_PAGES,
-};
-
-/*
- * Register offsets into BAR2 memory.
- * Only values necessary for driver implementation are defined.
- */
-enum apex_bar2_regs {
-       APEX_BAR2_REG_SCU_BASE = 0x1A300,
-       APEX_BAR2_REG_KERNEL_HIB_PAGE_TABLE_SIZE = 0x46000,
-       APEX_BAR2_REG_KERNEL_HIB_EXTENDED_TABLE = 0x46008,
-       APEX_BAR2_REG_KERNEL_HIB_TRANSLATION_ENABLE = 0x46010,
-       APEX_BAR2_REG_KERNEL_HIB_INSTR_QUEUE_INTVECCTL = 0x46018,
-       APEX_BAR2_REG_KERNEL_HIB_INPUT_ACTV_QUEUE_INTVECCTL = 0x46020,
-       APEX_BAR2_REG_KERNEL_HIB_PARAM_QUEUE_INTVECCTL = 0x46028,
-       APEX_BAR2_REG_KERNEL_HIB_OUTPUT_ACTV_QUEUE_INTVECCTL = 0x46030,
-       APEX_BAR2_REG_KERNEL_HIB_SC_HOST_INTVECCTL = 0x46038,
-       APEX_BAR2_REG_KERNEL_HIB_TOP_LEVEL_INTVECCTL = 0x46040,
-       APEX_BAR2_REG_KERNEL_HIB_FATAL_ERR_INTVECCTL = 0x46048,
-       APEX_BAR2_REG_KERNEL_HIB_DMA_PAUSE = 0x46050,
-       APEX_BAR2_REG_KERNEL_HIB_DMA_PAUSE_MASK = 0x46058,
-       APEX_BAR2_REG_KERNEL_HIB_STATUS_BLOCK_DELAY = 0x46060,
-       APEX_BAR2_REG_KERNEL_HIB_MSIX_PENDING_BIT_ARRAY0 = 0x46068,
-       APEX_BAR2_REG_KERNEL_HIB_MSIX_PENDING_BIT_ARRAY1 = 0x46070,
-       APEX_BAR2_REG_KERNEL_HIB_PAGE_TABLE_INIT = 0x46078,
-       APEX_BAR2_REG_KERNEL_HIB_MSIX_TABLE_INIT = 0x46080,
-       APEX_BAR2_REG_KERNEL_WIRE_INT_PENDING_BIT_ARRAY = 0x48778,
-       APEX_BAR2_REG_KERNEL_WIRE_INT_MASK_ARRAY = 0x48780,
-       APEX_BAR2_REG_USER_HIB_DMA_PAUSE = 0x486D8,
-       APEX_BAR2_REG_USER_HIB_DMA_PAUSED = 0x486E0,
-       APEX_BAR2_REG_IDLEGENERATOR_IDLEGEN_IDLEREGISTER = 0x4A000,
-       APEX_BAR2_REG_KERNEL_HIB_PAGE_TABLE = 0x50000,
-
-       /* Error registers - Used mostly for debug */
-       APEX_BAR2_REG_USER_HIB_ERROR_STATUS = 0x86f0,
-       APEX_BAR2_REG_SCALAR_CORE_ERROR_STATUS = 0x41a0,
-};
-
-/* Addresses for packed registers. */
-#define APEX_BAR2_REG_AXI_QUIESCE (APEX_BAR2_REG_SCU_BASE + 0x2C)
-#define APEX_BAR2_REG_GCB_CLOCK_GATE (APEX_BAR2_REG_SCU_BASE + 0x14)
-#define APEX_BAR2_REG_SCU_0 (APEX_BAR2_REG_SCU_BASE + 0xc)
-#define APEX_BAR2_REG_SCU_1 (APEX_BAR2_REG_SCU_BASE + 0x10)
-#define APEX_BAR2_REG_SCU_2 (APEX_BAR2_REG_SCU_BASE + 0x14)
-#define APEX_BAR2_REG_SCU_3 (APEX_BAR2_REG_SCU_BASE + 0x18)
-#define APEX_BAR2_REG_SCU_4 (APEX_BAR2_REG_SCU_BASE + 0x1c)
-#define APEX_BAR2_REG_SCU_5 (APEX_BAR2_REG_SCU_BASE + 0x20)
-
-#define SCU3_RG_PWR_STATE_OVR_BIT_OFFSET 26
-#define SCU3_RG_PWR_STATE_OVR_MASK_WIDTH 2
-#define SCU3_CUR_RST_GCB_BIT_MASK 0x10
-#define SCU2_RG_RST_GCB_BIT_MASK 0xc
-
-/* Configuration for page table. */
-static struct gasket_page_table_config apex_page_table_configs[NUM_NODES] = {
-       {
-               .id = 0,
-               .mode = GASKET_PAGE_TABLE_MODE_NORMAL,
-               .total_entries = APEX_PAGE_TABLE_TOTAL_ENTRIES,
-               .base_reg = APEX_BAR2_REG_KERNEL_HIB_PAGE_TABLE,
-               .extended_reg = APEX_BAR2_REG_KERNEL_HIB_EXTENDED_TABLE,
-               .extended_bit = APEX_EXTENDED_SHIFT,
-       },
-};
-
-/* The regions in the BAR2 space that can be mapped into user space. */
-static const struct gasket_mappable_region mappable_regions[NUM_REGIONS] = {
-       { 0x40000, 0x1000 },
-       { 0x44000, 0x1000 },
-       { 0x48000, 0x1000 },
-};
-
-/* Gasket device interrupts enums must be dense (i.e., no empty slots). */
-enum apex_interrupt {
-       APEX_INTERRUPT_INSTR_QUEUE = 0,
-       APEX_INTERRUPT_INPUT_ACTV_QUEUE = 1,
-       APEX_INTERRUPT_PARAM_QUEUE = 2,
-       APEX_INTERRUPT_OUTPUT_ACTV_QUEUE = 3,
-       APEX_INTERRUPT_SC_HOST_0 = 4,
-       APEX_INTERRUPT_SC_HOST_1 = 5,
-       APEX_INTERRUPT_SC_HOST_2 = 6,
-       APEX_INTERRUPT_SC_HOST_3 = 7,
-       APEX_INTERRUPT_TOP_LEVEL_0 = 8,
-       APEX_INTERRUPT_TOP_LEVEL_1 = 9,
-       APEX_INTERRUPT_TOP_LEVEL_2 = 10,
-       APEX_INTERRUPT_TOP_LEVEL_3 = 11,
-       APEX_INTERRUPT_FATAL_ERR = 12,
-       APEX_INTERRUPT_COUNT = 13,
-};
-
-/* Interrupt descriptors for Apex */
-static struct gasket_interrupt_desc apex_interrupts[] = {
-       {
-               APEX_INTERRUPT_INSTR_QUEUE,
-               APEX_BAR2_REG_KERNEL_HIB_INSTR_QUEUE_INTVECCTL,
-               UNPACKED,
-       },
-       {
-               APEX_INTERRUPT_INPUT_ACTV_QUEUE,
-               APEX_BAR2_REG_KERNEL_HIB_INPUT_ACTV_QUEUE_INTVECCTL,
-               UNPACKED
-       },
-       {
-               APEX_INTERRUPT_PARAM_QUEUE,
-               APEX_BAR2_REG_KERNEL_HIB_PARAM_QUEUE_INTVECCTL,
-               UNPACKED
-       },
-       {
-               APEX_INTERRUPT_OUTPUT_ACTV_QUEUE,
-               APEX_BAR2_REG_KERNEL_HIB_OUTPUT_ACTV_QUEUE_INTVECCTL,
-               UNPACKED
-       },
-       {
-               APEX_INTERRUPT_SC_HOST_0,
-               APEX_BAR2_REG_KERNEL_HIB_SC_HOST_INTVECCTL,
-               PACK_0
-       },
-       {
-               APEX_INTERRUPT_SC_HOST_1,
-               APEX_BAR2_REG_KERNEL_HIB_SC_HOST_INTVECCTL,
-               PACK_1
-       },
-       {
-               APEX_INTERRUPT_SC_HOST_2,
-               APEX_BAR2_REG_KERNEL_HIB_SC_HOST_INTVECCTL,
-               PACK_2
-       },
-       {
-               APEX_INTERRUPT_SC_HOST_3,
-               APEX_BAR2_REG_KERNEL_HIB_SC_HOST_INTVECCTL,
-               PACK_3
-       },
-       {
-               APEX_INTERRUPT_TOP_LEVEL_0,
-               APEX_BAR2_REG_KERNEL_HIB_TOP_LEVEL_INTVECCTL,
-               PACK_0
-       },
-       {
-               APEX_INTERRUPT_TOP_LEVEL_1,
-               APEX_BAR2_REG_KERNEL_HIB_TOP_LEVEL_INTVECCTL,
-               PACK_1
-       },
-       {
-               APEX_INTERRUPT_TOP_LEVEL_2,
-               APEX_BAR2_REG_KERNEL_HIB_TOP_LEVEL_INTVECCTL,
-               PACK_2
-       },
-       {
-               APEX_INTERRUPT_TOP_LEVEL_3,
-               APEX_BAR2_REG_KERNEL_HIB_TOP_LEVEL_INTVECCTL,
-               PACK_3
-       },
-       {
-               APEX_INTERRUPT_FATAL_ERR,
-               APEX_BAR2_REG_KERNEL_HIB_FATAL_ERR_INTVECCTL,
-               UNPACKED
-       },
-};
-
-/* Allows device to enter power save upon driver close(). */
-static int allow_power_save = 1;
-
-/* Allows SW based clock gating. */
-static int allow_sw_clock_gating;
-
-/* Allows HW based clock gating. */
-/* Note: this is not mutual exclusive with SW clock gating. */
-static int allow_hw_clock_gating = 1;
-
-/* Act as if only GCB is instantiated. */
-static int bypass_top_level;
-
-module_param(allow_power_save, int, 0644);
-module_param(allow_sw_clock_gating, int, 0644);
-module_param(allow_hw_clock_gating, int, 0644);
-module_param(bypass_top_level, int, 0644);
-
-/* Check the device status registers and return device status ALIVE or DEAD. */
-static int apex_get_status(struct gasket_dev *gasket_dev)
-{
-       /* TODO: Check device status. */
-       return GASKET_STATUS_ALIVE;
-}
-
-/* Enter GCB reset state. */
-static int apex_enter_reset(struct gasket_dev *gasket_dev)
-{
-       if (bypass_top_level)
-               return 0;
-
-       /*
-        * Software reset:
-        * Enable sleep mode
-        *  - Software force GCB idle
-        *    - Enable GCB idle
-        */
-       gasket_read_modify_write_64(gasket_dev, APEX_BAR_INDEX,
-                                   APEX_BAR2_REG_IDLEGENERATOR_IDLEGEN_IDLEREGISTER,
-                                   0x0, 1, 32);
-
-       /*    - Initiate DMA pause */
-       gasket_dev_write_64(gasket_dev, 1, APEX_BAR_INDEX,
-                           APEX_BAR2_REG_USER_HIB_DMA_PAUSE);
-
-       /*    - Wait for DMA pause complete. */
-       if (gasket_wait_with_reschedule(gasket_dev, APEX_BAR_INDEX,
-                                       APEX_BAR2_REG_USER_HIB_DMA_PAUSED, 1, 1,
-                                       APEX_RESET_DELAY, APEX_RESET_RETRY)) {
-               dev_err(gasket_dev->dev,
-                       "DMAs did not quiesce within timeout (%d ms)\n",
-                       APEX_RESET_RETRY * APEX_RESET_DELAY);
-               return -ETIMEDOUT;
-       }
-
-       /*  - Enable GCB reset (0x1 to rg_rst_gcb) */
-       gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX,
-                                   APEX_BAR2_REG_SCU_2, 0x1, 2, 2);
-
-       /*  - Enable GCB clock Gate (0x1 to rg_gated_gcb) */
-       gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX,
-                                   APEX_BAR2_REG_SCU_2, 0x1, 2, 18);
-
-       /*  - Enable GCB memory shut down (0x3 to rg_force_ram_sd) */
-       gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX,
-                                   APEX_BAR2_REG_SCU_3, 0x3, 2, 14);
-
-       /*    - Wait for RAM shutdown. */
-       if (gasket_wait_with_reschedule(gasket_dev, APEX_BAR_INDEX,
-                                       APEX_BAR2_REG_SCU_3, BIT(6), BIT(6),
-                                       APEX_RESET_DELAY, APEX_RESET_RETRY)) {
-               dev_err(gasket_dev->dev,
-                       "RAM did not shut down within timeout (%d ms)\n",
-                       APEX_RESET_RETRY * APEX_RESET_DELAY);
-               return -ETIMEDOUT;
-       }
-
-       return 0;
-}
-
-/* Quit GCB reset state. */
-static int apex_quit_reset(struct gasket_dev *gasket_dev)
-{
-       u32 val0, val1;
-
-       if (bypass_top_level)
-               return 0;
-
-       /*
-        * Disable sleep mode:
-        *  - Disable GCB memory shut down:
-        *    - b00: Not forced (HW controlled)
-        *    - b1x: Force disable
-        */
-       gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX,
-                                   APEX_BAR2_REG_SCU_3, 0x0, 2, 14);
-
-       /*
-        *  - Disable software clock gate:
-        *    - b00: Not forced (HW controlled)
-        *    - b1x: Force disable
-        */
-       gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX,
-                                   APEX_BAR2_REG_SCU_2, 0x0, 2, 18);
-
-       /*
-        *  - Disable GCB reset (rg_rst_gcb):
-        *    - b00: Not forced (HW controlled)
-        *    - b1x: Force disable = Force not Reset
-        */
-       gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX,
-                                   APEX_BAR2_REG_SCU_2, 0x2, 2, 2);
-
-       /*    - Wait for RAM enable. */
-       if (gasket_wait_with_reschedule(gasket_dev, APEX_BAR_INDEX,
-                                       APEX_BAR2_REG_SCU_3, BIT(6), 0,
-                                       APEX_RESET_DELAY, APEX_RESET_RETRY)) {
-               dev_err(gasket_dev->dev,
-                       "RAM did not enable within timeout (%d ms)\n",
-                       APEX_RESET_RETRY * APEX_RESET_DELAY);
-               return -ETIMEDOUT;
-       }
-
-       /*    - Wait for Reset complete. */
-       if (gasket_wait_with_reschedule(gasket_dev, APEX_BAR_INDEX,
-                                       APEX_BAR2_REG_SCU_3,
-                                       SCU3_CUR_RST_GCB_BIT_MASK, 0,
-                                       APEX_RESET_DELAY, APEX_RESET_RETRY)) {
-               dev_err(gasket_dev->dev,
-                       "GCB did not leave reset within timeout (%d ms)\n",
-                       APEX_RESET_RETRY * APEX_RESET_DELAY);
-               return -ETIMEDOUT;
-       }
-
-       if (!allow_hw_clock_gating) {
-               val0 = gasket_dev_read_32(gasket_dev, APEX_BAR_INDEX,
-                                         APEX_BAR2_REG_SCU_3);
-               /* Inactive and Sleep mode are disabled. */
-               gasket_read_modify_write_32(gasket_dev,
-                                           APEX_BAR_INDEX,
-                                           APEX_BAR2_REG_SCU_3, 0x3,
-                                           SCU3_RG_PWR_STATE_OVR_MASK_WIDTH,
-                                           SCU3_RG_PWR_STATE_OVR_BIT_OFFSET);
-               val1 = gasket_dev_read_32(gasket_dev, APEX_BAR_INDEX,
-                                         APEX_BAR2_REG_SCU_3);
-               dev_dbg(gasket_dev->dev,
-                       "Disallow HW clock gating 0x%x -> 0x%x\n", val0, val1);
-       } else {
-               val0 = gasket_dev_read_32(gasket_dev, APEX_BAR_INDEX,
-                                         APEX_BAR2_REG_SCU_3);
-               /* Inactive mode enabled - Sleep mode disabled. */
-               gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX,
-                                           APEX_BAR2_REG_SCU_3, 2,
-                                           SCU3_RG_PWR_STATE_OVR_MASK_WIDTH,
-                                           SCU3_RG_PWR_STATE_OVR_BIT_OFFSET);
-               val1 = gasket_dev_read_32(gasket_dev, APEX_BAR_INDEX,
-                                         APEX_BAR2_REG_SCU_3);
-               dev_dbg(gasket_dev->dev, "Allow HW clock gating 0x%x -> 0x%x\n",
-                       val0, val1);
-       }
-
-       return 0;
-}
-
-/* Reset the Apex hardware. Called on final close via device_close_cb. */
-static int apex_device_cleanup(struct gasket_dev *gasket_dev)
-{
-       u64 scalar_error;
-       u64 hib_error;
-       int ret = 0;
-
-       hib_error = gasket_dev_read_64(gasket_dev, APEX_BAR_INDEX,
-                                      APEX_BAR2_REG_USER_HIB_ERROR_STATUS);
-       scalar_error = gasket_dev_read_64(gasket_dev, APEX_BAR_INDEX,
-                                         APEX_BAR2_REG_SCALAR_CORE_ERROR_STATUS);
-
-       dev_dbg(gasket_dev->dev,
-               "%s 0x%p hib_error 0x%llx scalar_error 0x%llx\n",
-               __func__, gasket_dev, hib_error, scalar_error);
-
-       if (allow_power_save)
-               ret = apex_enter_reset(gasket_dev);
-
-       return ret;
-}
-
-/* Determine if GCB is in reset state. */
-static bool is_gcb_in_reset(struct gasket_dev *gasket_dev)
-{
-       u32 val = gasket_dev_read_32(gasket_dev, APEX_BAR_INDEX,
-                                    APEX_BAR2_REG_SCU_3);
-
-       /* Masks rg_rst_gcb bit of SCU_CTRL_2 */
-       return (val & SCU3_CUR_RST_GCB_BIT_MASK);
-}
-
-/* Reset the hardware, then quit reset.  Called on device open. */
-static int apex_reset(struct gasket_dev *gasket_dev)
-{
-       int ret;
-
-       if (bypass_top_level)
-               return 0;
-
-       if (!is_gcb_in_reset(gasket_dev)) {
-               /* We are not in reset - toggle the reset bit so as to force
-                * re-init of custom block
-                */
-               dev_dbg(gasket_dev->dev, "%s: toggle reset\n", __func__);
-
-               ret = apex_enter_reset(gasket_dev);
-               if (ret)
-                       return ret;
-       }
-       return apex_quit_reset(gasket_dev);
-}
-
-/*
- * Check permissions for Apex ioctls.
- * Returns true if the current user may execute this ioctl, and false otherwise.
- */
-static bool apex_ioctl_check_permissions(struct file *filp, uint cmd)
-{
-       return !!(filp->f_mode & FMODE_WRITE);
-}
-
-/* Gates or un-gates Apex clock. */
-static long apex_clock_gating(struct gasket_dev *gasket_dev,
-                             struct apex_gate_clock_ioctl __user *argp)
-{
-       struct apex_gate_clock_ioctl ibuf;
-
-       if (bypass_top_level || !allow_sw_clock_gating)
-               return 0;
-
-       if (copy_from_user(&ibuf, argp, sizeof(ibuf)))
-               return -EFAULT;
-
-       dev_dbg(gasket_dev->dev, "%s %llu\n", __func__, ibuf.enable);
-
-       if (ibuf.enable) {
-               /* Quiesce AXI, gate GCB clock. */
-               gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX,
-                                           APEX_BAR2_REG_AXI_QUIESCE, 0x1, 1,
-                                           16);
-               gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX,
-                                           APEX_BAR2_REG_GCB_CLOCK_GATE, 0x1,
-                                           2, 18);
-       } else {
-               /* Un-gate GCB clock, un-quiesce AXI. */
-               gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX,
-                                           APEX_BAR2_REG_GCB_CLOCK_GATE, 0x0,
-                                           2, 18);
-               gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX,
-                                           APEX_BAR2_REG_AXI_QUIESCE, 0x0, 1,
-                                           16);
-       }
-       return 0;
-}
-
-/* Apex-specific ioctl handler. */
-static long apex_ioctl(struct file *filp, uint cmd, void __user *argp)
-{
-       struct gasket_dev *gasket_dev = filp->private_data;
-
-       if (!apex_ioctl_check_permissions(filp, cmd))
-               return -EPERM;
-
-       switch (cmd) {
-       case APEX_IOCTL_GATE_CLOCK:
-               return apex_clock_gating(gasket_dev, argp);
-       default:
-               return -ENOTTY; /* unknown command */
-       }
-}
-
-/* Display driver sysfs entries. */
-static ssize_t sysfs_show(struct device *device, struct device_attribute *attr,
-                         char *buf)
-{
-       int ret;
-       struct gasket_dev *gasket_dev;
-       struct gasket_sysfs_attribute *gasket_attr;
-       enum sysfs_attribute_type type;
-       struct gasket_page_table *gpt;
-       uint val;
-
-       gasket_dev = gasket_sysfs_get_device_data(device);
-       if (!gasket_dev) {
-               dev_err(device, "No Apex device sysfs mapping found\n");
-               return -ENODEV;
-       }
-
-       gasket_attr = gasket_sysfs_get_attr(device, attr);
-       if (!gasket_attr) {
-               dev_err(device, "No Apex device sysfs attr data found\n");
-               gasket_sysfs_put_device_data(device, gasket_dev);
-               return -ENODEV;
-       }
-
-       type = (enum sysfs_attribute_type)gasket_attr->data.attr_type;
-       gpt = gasket_dev->page_table[0];
-       switch (type) {
-       case ATTR_KERNEL_HIB_PAGE_TABLE_SIZE:
-               val = gasket_page_table_num_entries(gpt);
-               break;
-       case ATTR_KERNEL_HIB_SIMPLE_PAGE_TABLE_SIZE:
-               val = gasket_page_table_num_simple_entries(gpt);
-               break;
-       case ATTR_KERNEL_HIB_NUM_ACTIVE_PAGES:
-               val = gasket_page_table_num_active_pages(gpt);
-               break;
-       default:
-               dev_dbg(gasket_dev->dev, "Unknown attribute: %s\n",
-                       attr->attr.name);
-               ret = 0;
-               goto exit;
-       }
-       ret = scnprintf(buf, PAGE_SIZE, "%u\n", val);
-exit:
-       gasket_sysfs_put_attr(device, gasket_attr);
-       gasket_sysfs_put_device_data(device, gasket_dev);
-       return ret;
-}
-
-static struct gasket_sysfs_attribute apex_sysfs_attrs[] = {
-       GASKET_SYSFS_RO(node_0_page_table_entries, sysfs_show,
-                       ATTR_KERNEL_HIB_PAGE_TABLE_SIZE),
-       GASKET_SYSFS_RO(node_0_simple_page_table_entries, sysfs_show,
-                       ATTR_KERNEL_HIB_SIMPLE_PAGE_TABLE_SIZE),
-       GASKET_SYSFS_RO(node_0_num_mapped_pages, sysfs_show,
-                       ATTR_KERNEL_HIB_NUM_ACTIVE_PAGES),
-       GASKET_END_OF_ATTR_ARRAY
-};
-
-/* On device open, perform a core reinit reset. */
-static int apex_device_open_cb(struct gasket_dev *gasket_dev)
-{
-       return gasket_reset_nolock(gasket_dev);
-}
-
-static const struct pci_device_id apex_pci_ids[] = {
-       { PCI_DEVICE(APEX_PCI_VENDOR_ID, APEX_PCI_DEVICE_ID) }, { 0 }
-};
-
-static int apex_pci_probe(struct pci_dev *pci_dev,
-                         const struct pci_device_id *id)
-{
-       int ret;
-       ulong page_table_ready, msix_table_ready;
-       int retries = 0;
-       struct gasket_dev *gasket_dev;
-
-       ret = pci_enable_device(pci_dev);
-       if (ret) {
-               dev_err(&pci_dev->dev, "error enabling PCI device\n");
-               return ret;
-       }
-
-       pci_set_master(pci_dev);
-
-       ret = gasket_pci_add_device(pci_dev, &gasket_dev);
-       if (ret) {
-               dev_err(&pci_dev->dev, "error adding gasket device\n");
-               pci_disable_device(pci_dev);
-               return ret;
-       }
-
-       pci_set_drvdata(pci_dev, gasket_dev);
-       apex_reset(gasket_dev);
-
-       while (retries < APEX_RESET_RETRY) {
-               page_table_ready =
-                       gasket_dev_read_64(gasket_dev, APEX_BAR_INDEX,
-                                          APEX_BAR2_REG_KERNEL_HIB_PAGE_TABLE_INIT);
-               msix_table_ready =
-                       gasket_dev_read_64(gasket_dev, APEX_BAR_INDEX,
-                                          APEX_BAR2_REG_KERNEL_HIB_MSIX_TABLE_INIT);
-               if (page_table_ready && msix_table_ready)
-                       break;
-               schedule_timeout(msecs_to_jiffies(APEX_RESET_DELAY));
-               retries++;
-       }
-
-       if (retries == APEX_RESET_RETRY) {
-               if (!page_table_ready)
-                       dev_err(gasket_dev->dev, "Page table init timed out\n");
-               if (!msix_table_ready)
-                       dev_err(gasket_dev->dev, "MSI-X table init timed out\n");
-               ret = -ETIMEDOUT;
-               goto remove_device;
-       }
-
-       ret = gasket_sysfs_create_entries(gasket_dev->dev_info.device,
-                                         apex_sysfs_attrs);
-       if (ret)
-               dev_err(&pci_dev->dev, "error creating device sysfs entries\n");
-
-       ret = gasket_enable_device(gasket_dev);
-       if (ret) {
-               dev_err(&pci_dev->dev, "error enabling gasket device\n");
-               goto remove_device;
-       }
-
-       /* Place device in low power mode until opened */
-       if (allow_power_save)
-               apex_enter_reset(gasket_dev);
-
-       return 0;
-
-remove_device:
-       gasket_pci_remove_device(pci_dev);
-       pci_disable_device(pci_dev);
-       return ret;
-}
-
-static void apex_pci_remove(struct pci_dev *pci_dev)
-{
-       struct gasket_dev *gasket_dev = pci_get_drvdata(pci_dev);
-
-       gasket_disable_device(gasket_dev);
-       gasket_pci_remove_device(pci_dev);
-       pci_disable_device(pci_dev);
-}
-
-static const struct gasket_driver_desc apex_desc = {
-       .name = "apex",
-       .driver_version = APEX_DRIVER_VERSION,
-       .major = 120,
-       .minor = 0,
-       .module = THIS_MODULE,
-       .pci_id_table = apex_pci_ids,
-
-       .num_page_tables = NUM_NODES,
-       .page_table_bar_index = APEX_BAR_INDEX,
-       .page_table_configs = apex_page_table_configs,
-       .page_table_extended_bit = APEX_EXTENDED_SHIFT,
-
-       .bar_descriptions = {
-               GASKET_UNUSED_BAR,
-               GASKET_UNUSED_BAR,
-               { APEX_BAR_BYTES, (VM_WRITE | VM_READ), APEX_BAR_OFFSET,
-                       NUM_REGIONS, mappable_regions, PCI_BAR },
-               GASKET_UNUSED_BAR,
-               GASKET_UNUSED_BAR,
-               GASKET_UNUSED_BAR,
-       },
-       .coherent_buffer_description = {
-               APEX_CH_MEM_BYTES,
-               (VM_WRITE | VM_READ),
-               APEX_CM_OFFSET,
-       },
-       .interrupt_type = PCI_MSIX,
-       .interrupt_bar_index = APEX_BAR_INDEX,
-       .num_interrupts = APEX_INTERRUPT_COUNT,
-       .interrupts = apex_interrupts,
-       .interrupt_pack_width = 7,
-
-       .device_open_cb = apex_device_open_cb,
-       .device_close_cb = apex_device_cleanup,
-
-       .ioctl_handler_cb = apex_ioctl,
-       .device_status_cb = apex_get_status,
-       .hardware_revision_cb = NULL,
-       .device_reset_cb = apex_reset,
-};
-
-static struct pci_driver apex_pci_driver = {
-       .name = "apex",
-       .probe = apex_pci_probe,
-       .remove = apex_pci_remove,
-       .id_table = apex_pci_ids,
-};
-
-static int __init apex_init(void)
-{
-       int ret;
-
-       ret = gasket_register_device(&apex_desc);
-       if (ret)
-               return ret;
-       ret = pci_register_driver(&apex_pci_driver);
-       if (ret)
-               gasket_unregister_device(&apex_desc);
-       return ret;
-}
-
-static void apex_exit(void)
-{
-       pci_unregister_driver(&apex_pci_driver);
-       gasket_unregister_device(&apex_desc);
-}
-MODULE_DESCRIPTION("Google Apex driver");
-MODULE_VERSION(APEX_DRIVER_VERSION);
-MODULE_LICENSE("GPL v2");
-MODULE_AUTHOR("John Joseph <jnjoseph@google.com>");
-MODULE_DEVICE_TABLE(pci, apex_pci_ids);
-module_init(apex_init);
-module_exit(apex_exit);
diff --git a/drivers/staging/gasket/gasket.h b/drivers/staging/gasket/gasket.h
deleted file mode 100644 (file)
index a0f065c..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Common Gasket device kernel and user space declarations.
- *
- * Copyright (C) 2018 Google, Inc.
- */
-#ifndef __GASKET_H__
-#define __GASKET_H__
-
-#include <linux/ioctl.h>
-#include <linux/types.h>
-
-/* ioctl structure declarations */
-
-/* Ioctl structures are padded to a multiple of 64 bits */
-/* and padded to put 64 bit values on 64 bit boundaries. */
-/* Unsigned 64 bit integers are used to hold pointers. */
-/* This helps compatibility between 32 and 64 bits. */
-
-/*
- * Common structure for ioctls associating an eventfd with a device interrupt,
- * when using the Gasket interrupt module.
- */
-struct gasket_interrupt_eventfd {
-       u64 interrupt;
-       u64 event_fd;
-};
-
-/*
- * Common structure for ioctls mapping and unmapping buffers when using the
- * Gasket page_table module.
- */
-struct gasket_page_table_ioctl {
-       u64 page_table_index;
-       u64 size;
-       u64 host_address;
-       u64 device_address;
-};
-
-/*
- * Common structure for ioctls mapping and unmapping buffers when using the
- * Gasket page_table module.
- * dma_address: phys addr start of coherent memory, allocated by kernel
- */
-struct gasket_coherent_alloc_config_ioctl {
-       u64 page_table_index;
-       u64 enable;
-       u64 size;
-       u64 dma_address;
-};
-
-/* Base number for all Gasket-common IOCTLs */
-#define GASKET_IOCTL_BASE 0xDC
-
-/* Reset the device. */
-#define GASKET_IOCTL_RESET _IO(GASKET_IOCTL_BASE, 0)
-
-/* Associate the specified [event]fd with the specified interrupt. */
-#define GASKET_IOCTL_SET_EVENTFD                                               \
-       _IOW(GASKET_IOCTL_BASE, 1, struct gasket_interrupt_eventfd)
-
-/*
- * Clears any eventfd associated with the specified interrupt. The (ulong)
- * argument is the interrupt number to clear.
- */
-#define GASKET_IOCTL_CLEAR_EVENTFD _IOW(GASKET_IOCTL_BASE, 2, unsigned long)
-
-/*
- * [Loopbacks only] Requests that the loopback device send the specified
- * interrupt to the host. The (ulong) argument is the number of the interrupt to
- * send.
- */
-#define GASKET_IOCTL_LOOPBACK_INTERRUPT                                        \
-       _IOW(GASKET_IOCTL_BASE, 3, unsigned long)
-
-/* Queries the kernel for the number of page tables supported by the device. */
-#define GASKET_IOCTL_NUMBER_PAGE_TABLES _IOR(GASKET_IOCTL_BASE, 4, u64)
-
-/*
- * Queries the kernel for the maximum size of the page table.  Only the size and
- * page_table_index fields are used from the struct gasket_page_table_ioctl.
- */
-#define GASKET_IOCTL_PAGE_TABLE_SIZE                                           \
-       _IOWR(GASKET_IOCTL_BASE, 5, struct gasket_page_table_ioctl)
-
-/*
- * Queries the kernel for the current simple page table size.  Only the size and
- * page_table_index fields are used from the struct gasket_page_table_ioctl.
- */
-#define GASKET_IOCTL_SIMPLE_PAGE_TABLE_SIZE                                    \
-       _IOWR(GASKET_IOCTL_BASE, 6, struct gasket_page_table_ioctl)
-
-/*
- * Tells the kernel to change the split between the number of simple and
- * extended entries in the given page table. Only the size and page_table_index
- * fields are used from the struct gasket_page_table_ioctl.
- */
-#define GASKET_IOCTL_PARTITION_PAGE_TABLE                                      \
-       _IOW(GASKET_IOCTL_BASE, 7, struct gasket_page_table_ioctl)
-
-/*
- * Tells the kernel to map size bytes at host_address to device_address in
- * page_table_index page table.
- */
-#define GASKET_IOCTL_MAP_BUFFER                                                \
-       _IOW(GASKET_IOCTL_BASE, 8, struct gasket_page_table_ioctl)
-
-/*
- * Tells the kernel to unmap size bytes at host_address from device_address in
- * page_table_index page table.
- */
-#define GASKET_IOCTL_UNMAP_BUFFER                                              \
-       _IOW(GASKET_IOCTL_BASE, 9, struct gasket_page_table_ioctl)
-
-/* Clear the interrupt counts stored for this device. */
-#define GASKET_IOCTL_CLEAR_INTERRUPT_COUNTS _IO(GASKET_IOCTL_BASE, 10)
-
-/* Enable/Disable and configure the coherent allocator. */
-#define GASKET_IOCTL_CONFIG_COHERENT_ALLOCATOR                                 \
-       _IOWR(GASKET_IOCTL_BASE, 11, struct gasket_coherent_alloc_config_ioctl)
-
-#endif /* __GASKET_H__ */
diff --git a/drivers/staging/gasket/gasket_constants.h b/drivers/staging/gasket/gasket_constants.h
deleted file mode 100644 (file)
index 9ea9c88..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/* Copyright (C) 2018 Google, Inc. */
-#ifndef __GASKET_CONSTANTS_H__
-#define __GASKET_CONSTANTS_H__
-
-#define GASKET_FRAMEWORK_VERSION "1.1.2"
-
-/*
- * The maximum number of simultaneous device types supported by the framework.
- */
-#define GASKET_FRAMEWORK_DESC_MAX 2
-
-/* The maximum devices per each type. */
-#define GASKET_DEV_MAX 256
-
-/* The number of supported Gasket page tables per device. */
-#define GASKET_MAX_NUM_PAGE_TABLES 1
-
-/* Maximum length of device names (driver name + minor number suffix + NULL). */
-#define GASKET_NAME_MAX 32
-
-/* Device status enumeration. */
-enum gasket_status {
-       /*
-        * A device is DEAD if it has not been initialized or has had an error.
-        */
-       GASKET_STATUS_DEAD = 0,
-       /*
-        * A device is LAMED if the hardware is healthy but the kernel was
-        * unable to enable some functionality (e.g. interrupts).
-        */
-       GASKET_STATUS_LAMED,
-
-       /* A device is ALIVE if it is ready for operation. */
-       GASKET_STATUS_ALIVE,
-
-       /*
-        * This status is set when the driver is exiting and waiting for all
-        * handles to be closed.
-        */
-       GASKET_STATUS_DRIVER_EXIT,
-};
-
-#endif
diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c
deleted file mode 100644 (file)
index 28dab30..0000000
+++ /dev/null
@@ -1,1815 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Gasket generic driver framework. This file contains the implementation
- * for the Gasket generic driver framework - the functionality that is common
- * across Gasket devices.
- *
- * Copyright (C) 2018 Google, Inc.
- */
-
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include "gasket_core.h"
-
-#include "gasket_interrupt.h"
-#include "gasket_ioctl.h"
-#include "gasket_page_table.h"
-#include "gasket_sysfs.h"
-
-#include <linux/capability.h>
-#include <linux/compiler.h>
-#include <linux/delay.h>
-#include <linux/device.h>
-#include <linux/fs.h>
-#include <linux/init.h>
-#include <linux/of.h>
-#include <linux/pid_namespace.h>
-#include <linux/printk.h>
-#include <linux/sched.h>
-
-#ifdef GASKET_KERNEL_TRACE_SUPPORT
-#define CREATE_TRACE_POINTS
-#include <trace/events/gasket_mmap.h>
-#else
-#define trace_gasket_mmap_exit(x)
-#define trace_gasket_mmap_entry(x, ...)
-#endif
-
-/*
- * "Private" members of gasket_driver_desc.
- *
- * Contains internal per-device type tracking data, i.e., data not appropriate
- * as part of the public interface for the generic framework.
- */
-struct gasket_internal_desc {
-       /* Device-specific-driver-provided configuration information. */
-       const struct gasket_driver_desc *driver_desc;
-
-       /* Protects access to per-driver data (i.e. this structure). */
-       struct mutex mutex;
-
-       /* Kernel-internal device class. */
-       struct class *class;
-
-       /* Instantiated / present devices of this type. */
-       struct gasket_dev *devs[GASKET_DEV_MAX];
-};
-
-/* do_map_region() needs be able to return more than just true/false. */
-enum do_map_region_status {
-       /* The region was successfully mapped. */
-       DO_MAP_REGION_SUCCESS,
-
-       /* Attempted to map region and failed. */
-       DO_MAP_REGION_FAILURE,
-
-       /* The requested region to map was not part of a mappable region. */
-       DO_MAP_REGION_INVALID,
-};
-
-/* Global data definitions. */
-/* Mutex - only for framework-wide data. Other data should be protected by
- * finer-grained locks.
- */
-static DEFINE_MUTEX(g_mutex);
-
-/* List of all registered device descriptions & their supporting data. */
-static struct gasket_internal_desc g_descs[GASKET_FRAMEWORK_DESC_MAX];
-
-/* Mapping of statuses to human-readable strings. Must end with {0,NULL}. */
-static const struct gasket_num_name gasket_status_name_table[] = {
-       { GASKET_STATUS_DEAD, "DEAD" },
-       { GASKET_STATUS_ALIVE, "ALIVE" },
-       { GASKET_STATUS_LAMED, "LAMED" },
-       { GASKET_STATUS_DRIVER_EXIT, "DRIVER_EXITING" },
-       { 0, NULL },
-};
-
-/* Enumeration of the automatic Gasket framework sysfs nodes. */
-enum gasket_sysfs_attribute_type {
-       ATTR_BAR_OFFSETS,
-       ATTR_BAR_SIZES,
-       ATTR_DRIVER_VERSION,
-       ATTR_FRAMEWORK_VERSION,
-       ATTR_DEVICE_TYPE,
-       ATTR_HARDWARE_REVISION,
-       ATTR_PCI_ADDRESS,
-       ATTR_STATUS,
-       ATTR_IS_DEVICE_OWNED,
-       ATTR_DEVICE_OWNER,
-       ATTR_WRITE_OPEN_COUNT,
-       ATTR_RESET_COUNT,
-       ATTR_USER_MEM_RANGES
-};
-
-/* Perform a standard Gasket callback. */
-static inline int
-check_and_invoke_callback(struct gasket_dev *gasket_dev,
-                         int (*cb_function)(struct gasket_dev *))
-{
-       int ret = 0;
-
-       if (cb_function) {
-               mutex_lock(&gasket_dev->mutex);
-               ret = cb_function(gasket_dev);
-               mutex_unlock(&gasket_dev->mutex);
-       }
-       return ret;
-}
-
-/* Perform a standard Gasket callback without grabbing gasket_dev->mutex. */
-static inline int
-gasket_check_and_invoke_callback_nolock(struct gasket_dev *gasket_dev,
-                                       int (*cb_function)(struct gasket_dev *))
-{
-       int ret = 0;
-
-       if (cb_function)
-               ret = cb_function(gasket_dev);
-       return ret;
-}
-
-/*
- * Return nonzero if the gasket_cdev_info is owned by the current thread group
- * ID.
- */
-static int gasket_owned_by_current_tgid(struct gasket_cdev_info *info)
-{
-       return (info->ownership.is_owned &&
-               (info->ownership.owner == current->tgid));
-}
-
-/*
- * Find the next free gasket_internal_dev slot.
- *
- * Returns the located slot number on success or a negative number on failure.
- */
-static int gasket_find_dev_slot(struct gasket_internal_desc *internal_desc,
-                               const char *kobj_name)
-{
-       int i;
-
-       mutex_lock(&internal_desc->mutex);
-
-       /* Search for a previous instance of this device. */
-       for (i = 0; i < GASKET_DEV_MAX; i++) {
-               if (internal_desc->devs[i] &&
-                   strcmp(internal_desc->devs[i]->kobj_name, kobj_name) == 0) {
-                       pr_err("Duplicate device %s\n", kobj_name);
-                       mutex_unlock(&internal_desc->mutex);
-                       return -EBUSY;
-               }
-       }
-
-       /* Find a free device slot. */
-       for (i = 0; i < GASKET_DEV_MAX; i++) {
-               if (!internal_desc->devs[i])
-                       break;
-       }
-
-       if (i == GASKET_DEV_MAX) {
-               pr_err("Too many registered devices; max %d\n", GASKET_DEV_MAX);
-               mutex_unlock(&internal_desc->mutex);
-               return -EBUSY;
-       }
-
-       mutex_unlock(&internal_desc->mutex);
-       return i;
-}
-
-/*
- * Allocate and initialize a Gasket device structure, add the device to the
- * device list.
- *
- * Returns 0 if successful, a negative error code otherwise.
- */
-static int gasket_alloc_dev(struct gasket_internal_desc *internal_desc,
-                           struct device *parent, struct gasket_dev **pdev)
-{
-       int dev_idx;
-       const struct gasket_driver_desc *driver_desc =
-               internal_desc->driver_desc;
-       struct gasket_dev *gasket_dev;
-       struct gasket_cdev_info *dev_info;
-       const char *parent_name = dev_name(parent);
-
-       pr_debug("Allocating a Gasket device, parent %s.\n", parent_name);
-
-       *pdev = NULL;
-
-       dev_idx = gasket_find_dev_slot(internal_desc, parent_name);
-       if (dev_idx < 0)
-               return dev_idx;
-
-       gasket_dev = *pdev = kzalloc(sizeof(*gasket_dev), GFP_KERNEL);
-       if (!gasket_dev) {
-               pr_err("no memory for device, parent %s\n", parent_name);
-               return -ENOMEM;
-       }
-       internal_desc->devs[dev_idx] = gasket_dev;
-
-       mutex_init(&gasket_dev->mutex);
-
-       gasket_dev->internal_desc = internal_desc;
-       gasket_dev->dev_idx = dev_idx;
-       snprintf(gasket_dev->kobj_name, GASKET_NAME_MAX, "%s", parent_name);
-       gasket_dev->dev = get_device(parent);
-       /* gasket_bar_data is uninitialized. */
-       gasket_dev->num_page_tables = driver_desc->num_page_tables;
-       /* max_page_table_size and *page table are uninit'ed */
-       /* interrupt_data is not initialized. */
-       /* status is 0, or GASKET_STATUS_DEAD */
-
-       dev_info = &gasket_dev->dev_info;
-       snprintf(dev_info->name, GASKET_NAME_MAX, "%s_%u", driver_desc->name,
-                gasket_dev->dev_idx);
-       dev_info->devt =
-               MKDEV(driver_desc->major, driver_desc->minor +
-                     gasket_dev->dev_idx);
-       dev_info->device =
-               device_create(internal_desc->class, parent, dev_info->devt,
-                             gasket_dev, dev_info->name);
-
-       /* cdev has not yet been added; cdev_added is 0 */
-       dev_info->gasket_dev_ptr = gasket_dev;
-       /* ownership is all 0, indicating no owner or opens. */
-
-       return 0;
-}
-
-/* Free a Gasket device. */
-static void gasket_free_dev(struct gasket_dev *gasket_dev)
-{
-       struct gasket_internal_desc *internal_desc = gasket_dev->internal_desc;
-
-       mutex_lock(&internal_desc->mutex);
-       internal_desc->devs[gasket_dev->dev_idx] = NULL;
-       mutex_unlock(&internal_desc->mutex);
-       put_device(gasket_dev->dev);
-       kfree(gasket_dev);
-}
-
-/*
- * Maps the specified bar into kernel space.
- *
- * Returns 0 on success, a negative error code otherwise.
- * A zero-sized BAR will not be mapped, but is not an error.
- */
-static int gasket_map_pci_bar(struct gasket_dev *gasket_dev, int bar_num)
-{
-       struct gasket_internal_desc *internal_desc = gasket_dev->internal_desc;
-       const struct gasket_driver_desc *driver_desc =
-               internal_desc->driver_desc;
-       ulong desc_bytes = driver_desc->bar_descriptions[bar_num].size;
-       struct gasket_bar_data *data;
-       int ret;
-
-       if (desc_bytes == 0)
-               return 0;
-
-       if (driver_desc->bar_descriptions[bar_num].type != PCI_BAR) {
-               /* not PCI: skip this entry */
-               return 0;
-       }
-
-       data = &gasket_dev->bar_data[bar_num];
-
-       /*
-        * pci_resource_start and pci_resource_len return a "resource_size_t",
-        * which is safely castable to ulong (which itself is the arg to
-        * request_mem_region).
-        */
-       data->phys_base =
-               (ulong)pci_resource_start(gasket_dev->pci_dev, bar_num);
-       if (!data->phys_base) {
-               dev_err(gasket_dev->dev, "Cannot get BAR%u base address\n",
-                       bar_num);
-               return -EINVAL;
-       }
-
-       data->length_bytes =
-               (ulong)pci_resource_len(gasket_dev->pci_dev, bar_num);
-       if (data->length_bytes < desc_bytes) {
-               dev_err(gasket_dev->dev,
-                       "PCI BAR %u space is too small: %lu; expected >= %lu\n",
-                       bar_num, data->length_bytes, desc_bytes);
-               return -ENOMEM;
-       }
-
-       if (!request_mem_region(data->phys_base, data->length_bytes,
-                               gasket_dev->dev_info.name)) {
-               dev_err(gasket_dev->dev,
-                       "Cannot get BAR %d memory region %p\n",
-                       bar_num, &gasket_dev->pci_dev->resource[bar_num]);
-               return -EINVAL;
-       }
-
-       data->virt_base = ioremap(data->phys_base, data->length_bytes);
-       if (!data->virt_base) {
-               dev_err(gasket_dev->dev,
-                       "Cannot remap BAR %d memory region %p\n",
-                       bar_num, &gasket_dev->pci_dev->resource[bar_num]);
-               ret = -ENOMEM;
-               goto fail;
-       }
-
-       dma_set_mask(&gasket_dev->pci_dev->dev, DMA_BIT_MASK(64));
-       dma_set_coherent_mask(&gasket_dev->pci_dev->dev, DMA_BIT_MASK(64));
-
-       return 0;
-
-fail:
-       iounmap(data->virt_base);
-       release_mem_region(data->phys_base, data->length_bytes);
-       return ret;
-}
-
-/*
- * Releases PCI BAR mapping.
- *
- * A zero-sized or not-mapped BAR will not be unmapped, but is not an error.
- */
-static void gasket_unmap_pci_bar(struct gasket_dev *dev, int bar_num)
-{
-       ulong base, bytes;
-       struct gasket_internal_desc *internal_desc = dev->internal_desc;
-       const struct gasket_driver_desc *driver_desc =
-               internal_desc->driver_desc;
-
-       if (driver_desc->bar_descriptions[bar_num].size == 0 ||
-           !dev->bar_data[bar_num].virt_base)
-               return;
-
-       if (driver_desc->bar_descriptions[bar_num].type != PCI_BAR)
-               return;
-
-       iounmap(dev->bar_data[bar_num].virt_base);
-       dev->bar_data[bar_num].virt_base = NULL;
-
-       base = pci_resource_start(dev->pci_dev, bar_num);
-       if (!base) {
-               dev_err(dev->dev, "cannot get PCI BAR%u base address\n",
-                       bar_num);
-               return;
-       }
-
-       bytes = pci_resource_len(dev->pci_dev, bar_num);
-       release_mem_region(base, bytes);
-}
-
-/*
- * Setup PCI memory mapping for the specified device.
- *
- * Reads the BAR registers and sets up pointers to the device's memory mapped
- * IO space.
- *
- * Returns 0 on success and a negative value otherwise.
- */
-static int gasket_setup_pci(struct pci_dev *pci_dev,
-                           struct gasket_dev *gasket_dev)
-{
-       int i, mapped_bars, ret;
-
-       for (i = 0; i < PCI_STD_NUM_BARS; i++) {
-               ret = gasket_map_pci_bar(gasket_dev, i);
-               if (ret) {
-                       mapped_bars = i;
-                       goto fail;
-               }
-       }
-
-       return 0;
-
-fail:
-       for (i = 0; i < mapped_bars; i++)
-               gasket_unmap_pci_bar(gasket_dev, i);
-
-       return -ENOMEM;
-}
-
-/* Unmaps memory for the specified device. */
-static void gasket_cleanup_pci(struct gasket_dev *gasket_dev)
-{
-       int i;
-
-       for (i = 0; i < PCI_STD_NUM_BARS; i++)
-               gasket_unmap_pci_bar(gasket_dev, i);
-}
-
-/* Determine the health of the Gasket device. */
-static int gasket_get_hw_status(struct gasket_dev *gasket_dev)
-{
-       int status;
-       int i;
-       const struct gasket_driver_desc *driver_desc =
-               gasket_dev->internal_desc->driver_desc;
-
-       status = gasket_check_and_invoke_callback_nolock(gasket_dev,
-                                                        driver_desc->device_status_cb);
-       if (status != GASKET_STATUS_ALIVE) {
-               dev_dbg(gasket_dev->dev, "Hardware reported status %d.\n",
-                       status);
-               return status;
-       }
-
-       status = gasket_interrupt_system_status(gasket_dev);
-       if (status != GASKET_STATUS_ALIVE) {
-               dev_dbg(gasket_dev->dev,
-                       "Interrupt system reported status %d.\n", status);
-               return status;
-       }
-
-       for (i = 0; i < driver_desc->num_page_tables; ++i) {
-               status = gasket_page_table_system_status(gasket_dev->page_table[i]);
-               if (status != GASKET_STATUS_ALIVE) {
-                       dev_dbg(gasket_dev->dev,
-                               "Page table %d reported status %d.\n",
-                               i, status);
-                       return status;
-               }
-       }
-
-       return GASKET_STATUS_ALIVE;
-}
-
-static ssize_t
-gasket_write_mappable_regions(char *buf,
-                             const struct gasket_driver_desc *driver_desc,
-                             int bar_index)
-{
-       int i;
-       ssize_t written;
-       ssize_t total_written = 0;
-       ulong min_addr, max_addr;
-       struct gasket_bar_desc bar_desc =
-               driver_desc->bar_descriptions[bar_index];
-
-       if (bar_desc.permissions == GASKET_NOMAP)
-               return 0;
-       for (i = 0;
-            i < bar_desc.num_mappable_regions && total_written < PAGE_SIZE;
-            i++) {
-               min_addr = bar_desc.mappable_regions[i].start -
-                          driver_desc->legacy_mmap_address_offset;
-               max_addr = bar_desc.mappable_regions[i].start -
-                          driver_desc->legacy_mmap_address_offset +
-                          bar_desc.mappable_regions[i].length_bytes;
-               written = scnprintf(buf, PAGE_SIZE - total_written,
-                                   "0x%08lx-0x%08lx\n", min_addr, max_addr);
-               total_written += written;
-               buf += written;
-       }
-       return total_written;
-}
-
-static ssize_t gasket_sysfs_data_show(struct device *device,
-                                     struct device_attribute *attr, char *buf)
-{
-       int i, ret = 0;
-       ssize_t current_written = 0;
-       const struct gasket_driver_desc *driver_desc;
-       struct gasket_dev *gasket_dev;
-       struct gasket_sysfs_attribute *gasket_attr;
-       const struct gasket_bar_desc *bar_desc;
-       enum gasket_sysfs_attribute_type sysfs_type;
-
-       gasket_dev = gasket_sysfs_get_device_data(device);
-       if (!gasket_dev) {
-               dev_err(device, "No sysfs mapping found for device\n");
-               return 0;
-       }
-
-       gasket_attr = gasket_sysfs_get_attr(device, attr);
-       if (!gasket_attr) {
-               dev_err(device, "No sysfs attr found for device\n");
-               gasket_sysfs_put_device_data(device, gasket_dev);
-               return 0;
-       }
-
-       driver_desc = gasket_dev->internal_desc->driver_desc;
-
-       sysfs_type =
-               (enum gasket_sysfs_attribute_type)gasket_attr->data.attr_type;
-       switch (sysfs_type) {
-       case ATTR_BAR_OFFSETS:
-               for (i = 0; i < PCI_STD_NUM_BARS; i++) {
-                       bar_desc = &driver_desc->bar_descriptions[i];
-                       if (bar_desc->size == 0)
-                               continue;
-                       current_written =
-                               snprintf(buf, PAGE_SIZE - ret, "%d: 0x%lx\n", i,
-                                        (ulong)bar_desc->base);
-                       buf += current_written;
-                       ret += current_written;
-               }
-               break;
-       case ATTR_BAR_SIZES:
-               for (i = 0; i < PCI_STD_NUM_BARS; i++) {
-                       bar_desc = &driver_desc->bar_descriptions[i];
-                       if (bar_desc->size == 0)
-                               continue;
-                       current_written =
-                               snprintf(buf, PAGE_SIZE - ret, "%d: 0x%lx\n", i,
-                                        (ulong)bar_desc->size);
-                       buf += current_written;
-                       ret += current_written;
-               }
-               break;
-       case ATTR_DRIVER_VERSION:
-               ret = snprintf(buf, PAGE_SIZE, "%s\n",
-                              gasket_dev->internal_desc->driver_desc->driver_version);
-               break;
-       case ATTR_FRAMEWORK_VERSION:
-               ret = snprintf(buf, PAGE_SIZE, "%s\n",
-                              GASKET_FRAMEWORK_VERSION);
-               break;
-       case ATTR_DEVICE_TYPE:
-               ret = snprintf(buf, PAGE_SIZE, "%s\n",
-                              gasket_dev->internal_desc->driver_desc->name);
-               break;
-       case ATTR_HARDWARE_REVISION:
-               ret = snprintf(buf, PAGE_SIZE, "%d\n",
-                              gasket_dev->hardware_revision);
-               break;
-       case ATTR_PCI_ADDRESS:
-               ret = snprintf(buf, PAGE_SIZE, "%s\n", gasket_dev->kobj_name);
-               break;
-       case ATTR_STATUS:
-               ret = snprintf(buf, PAGE_SIZE, "%s\n",
-                              gasket_num_name_lookup(gasket_dev->status,
-                                                     gasket_status_name_table));
-               break;
-       case ATTR_IS_DEVICE_OWNED:
-               ret = snprintf(buf, PAGE_SIZE, "%d\n",
-                              gasket_dev->dev_info.ownership.is_owned);
-               break;
-       case ATTR_DEVICE_OWNER:
-               ret = snprintf(buf, PAGE_SIZE, "%d\n",
-                              gasket_dev->dev_info.ownership.owner);
-               break;
-       case ATTR_WRITE_OPEN_COUNT:
-               ret = snprintf(buf, PAGE_SIZE, "%d\n",
-                              gasket_dev->dev_info.ownership.write_open_count);
-               break;
-       case ATTR_RESET_COUNT:
-               ret = snprintf(buf, PAGE_SIZE, "%d\n", gasket_dev->reset_count);
-               break;
-       case ATTR_USER_MEM_RANGES:
-               for (i = 0; i < PCI_STD_NUM_BARS; ++i) {
-                       current_written =
-                               gasket_write_mappable_regions(buf, driver_desc,
-                                                             i);
-                       buf += current_written;
-                       ret += current_written;
-               }
-               break;
-       default:
-               dev_dbg(gasket_dev->dev, "Unknown attribute: %s\n",
-                       attr->attr.name);
-               ret = 0;
-               break;
-       }
-
-       gasket_sysfs_put_attr(device, gasket_attr);
-       gasket_sysfs_put_device_data(device, gasket_dev);
-       return ret;
-}
-
-/* These attributes apply to all Gasket driver instances. */
-static const struct gasket_sysfs_attribute gasket_sysfs_generic_attrs[] = {
-       GASKET_SYSFS_RO(bar_offsets, gasket_sysfs_data_show, ATTR_BAR_OFFSETS),
-       GASKET_SYSFS_RO(bar_sizes, gasket_sysfs_data_show, ATTR_BAR_SIZES),
-       GASKET_SYSFS_RO(driver_version, gasket_sysfs_data_show,
-                       ATTR_DRIVER_VERSION),
-       GASKET_SYSFS_RO(framework_version, gasket_sysfs_data_show,
-                       ATTR_FRAMEWORK_VERSION),
-       GASKET_SYSFS_RO(device_type, gasket_sysfs_data_show, ATTR_DEVICE_TYPE),
-       GASKET_SYSFS_RO(revision, gasket_sysfs_data_show,
-                       ATTR_HARDWARE_REVISION),
-       GASKET_SYSFS_RO(pci_address, gasket_sysfs_data_show, ATTR_PCI_ADDRESS),
-       GASKET_SYSFS_RO(status, gasket_sysfs_data_show, ATTR_STATUS),
-       GASKET_SYSFS_RO(is_device_owned, gasket_sysfs_data_show,
-                       ATTR_IS_DEVICE_OWNED),
-       GASKET_SYSFS_RO(device_owner, gasket_sysfs_data_show,
-                       ATTR_DEVICE_OWNER),
-       GASKET_SYSFS_RO(write_open_count, gasket_sysfs_data_show,
-                       ATTR_WRITE_OPEN_COUNT),
-       GASKET_SYSFS_RO(reset_count, gasket_sysfs_data_show, ATTR_RESET_COUNT),
-       GASKET_SYSFS_RO(user_mem_ranges, gasket_sysfs_data_show,
-                       ATTR_USER_MEM_RANGES),
-       GASKET_END_OF_ATTR_ARRAY
-};
-
-/* Add a char device and related info. */
-static int gasket_add_cdev(struct gasket_cdev_info *dev_info,
-                          const struct file_operations *file_ops,
-                          struct module *owner)
-{
-       int ret;
-
-       cdev_init(&dev_info->cdev, file_ops);
-       dev_info->cdev.owner = owner;
-       ret = cdev_add(&dev_info->cdev, dev_info->devt, 1);
-       if (ret) {
-               dev_err(dev_info->gasket_dev_ptr->dev,
-                       "cannot add char device [ret=%d]\n", ret);
-               return ret;
-       }
-       dev_info->cdev_added = 1;
-
-       return 0;
-}
-
-/* Disable device operations. */
-void gasket_disable_device(struct gasket_dev *gasket_dev)
-{
-       const struct gasket_driver_desc *driver_desc =
-               gasket_dev->internal_desc->driver_desc;
-       int i;
-
-       /* Only delete the device if it has been successfully added. */
-       if (gasket_dev->dev_info.cdev_added)
-               cdev_del(&gasket_dev->dev_info.cdev);
-
-       gasket_dev->status = GASKET_STATUS_DEAD;
-
-       gasket_interrupt_cleanup(gasket_dev);
-
-       for (i = 0; i < driver_desc->num_page_tables; ++i) {
-               if (gasket_dev->page_table[i]) {
-                       gasket_page_table_reset(gasket_dev->page_table[i]);
-                       gasket_page_table_cleanup(gasket_dev->page_table[i]);
-               }
-       }
-}
-EXPORT_SYMBOL(gasket_disable_device);
-
-/*
- * Registered driver descriptor lookup for PCI devices.
- *
- * Precondition: Called with g_mutex held (to avoid a race on return).
- * Returns NULL if no matching device was found.
- */
-static struct gasket_internal_desc *
-lookup_pci_internal_desc(struct pci_dev *pci_dev)
-{
-       int i;
-
-       __must_hold(&g_mutex);
-       for (i = 0; i < GASKET_FRAMEWORK_DESC_MAX; i++) {
-               if (g_descs[i].driver_desc &&
-                   g_descs[i].driver_desc->pci_id_table &&
-                   pci_match_id(g_descs[i].driver_desc->pci_id_table, pci_dev))
-                       return &g_descs[i];
-       }
-
-       return NULL;
-}
-
-/*
- * Verifies that the user has permissions to perform the requested mapping and
- * that the provided descriptor/range is of adequate size to hold the range to
- * be mapped.
- */
-static bool gasket_mmap_has_permissions(struct gasket_dev *gasket_dev,
-                                       struct vm_area_struct *vma,
-                                       int bar_permissions)
-{
-       int requested_permissions;
-       /* Always allow sysadmin to access. */
-       if (capable(CAP_SYS_ADMIN))
-               return true;
-
-       /* Never allow non-sysadmins to access to a dead device. */
-       if (gasket_dev->status != GASKET_STATUS_ALIVE) {
-               dev_dbg(gasket_dev->dev, "Device is dead.\n");
-               return false;
-       }
-
-       /* Make sure that no wrong flags are set. */
-       requested_permissions =
-               (vma->vm_flags & VM_ACCESS_FLAGS);
-       if (requested_permissions & ~(bar_permissions)) {
-               dev_dbg(gasket_dev->dev,
-                       "Attempting to map a region with requested permissions 0x%x, but region has permissions 0x%x.\n",
-                       requested_permissions, bar_permissions);
-               return false;
-       }
-
-       /* Do not allow a non-owner to write. */
-       if ((vma->vm_flags & VM_WRITE) &&
-           !gasket_owned_by_current_tgid(&gasket_dev->dev_info)) {
-               dev_dbg(gasket_dev->dev,
-                       "Attempting to mmap a region for write without owning device.\n");
-               return false;
-       }
-
-       return true;
-}
-
-/*
- * Verifies that the input address is within the region allocated to coherent
- * buffer.
- */
-static bool
-gasket_is_coherent_region(const struct gasket_driver_desc *driver_desc,
-                         ulong address)
-{
-       struct gasket_coherent_buffer_desc coh_buff_desc =
-               driver_desc->coherent_buffer_description;
-
-       if (coh_buff_desc.permissions != GASKET_NOMAP) {
-               if ((address >= coh_buff_desc.base) &&
-                   (address < coh_buff_desc.base + coh_buff_desc.size)) {
-                       return true;
-               }
-       }
-       return false;
-}
-
-static int gasket_get_bar_index(const struct gasket_dev *gasket_dev,
-                               ulong phys_addr)
-{
-       int i;
-       const struct gasket_driver_desc *driver_desc;
-
-       driver_desc = gasket_dev->internal_desc->driver_desc;
-       for (i = 0; i < PCI_STD_NUM_BARS; ++i) {
-               struct gasket_bar_desc bar_desc =
-                       driver_desc->bar_descriptions[i];
-
-               if (bar_desc.permissions != GASKET_NOMAP) {
-                       if (phys_addr >= bar_desc.base &&
-                           phys_addr < (bar_desc.base + bar_desc.size)) {
-                               return i;
-                       }
-               }
-       }
-       /* If we haven't found the address by now, it is invalid. */
-       return -EINVAL;
-}
-
-/*
- * Sets the actual bounds to map, given the device's mappable region.
- *
- * Given the device's mappable region, along with the user-requested mapping
- * start offset and length of the user region, determine how much of this
- * mappable region can be mapped into the user's region (start/end offsets),
- * and the physical offset (phys_offset) into the BAR where the mapping should
- * begin (either the VMA's or region lower bound).
- *
- * In other words, this calculates the overlap between the VMA
- * (bar_offset, requested_length) and the given gasket_mappable_region.
- *
- * Returns true if there's anything to map, and false otherwise.
- */
-static bool
-gasket_mm_get_mapping_addrs(const struct gasket_mappable_region *region,
-                           ulong bar_offset, ulong requested_length,
-                           struct gasket_mappable_region *mappable_region,
-                           ulong *virt_offset)
-{
-       ulong range_start = region->start;
-       ulong range_length = region->length_bytes;
-       ulong range_end = range_start + range_length;
-
-       *virt_offset = 0;
-       if (bar_offset + requested_length < range_start) {
-               /*
-                * If the requested region is completely below the range,
-                * there is nothing to map.
-                */
-               return false;
-       } else if (bar_offset <= range_start) {
-               /* If the bar offset is below this range's start
-                * but the requested length continues into it:
-                * 1) Only map starting from the beginning of this
-                *      range's phys. offset, so we don't map unmappable
-                *      memory.
-                * 2) The length of the virtual memory to not map is the
-                *      delta between the bar offset and the
-                *      mappable start (and since the mappable start is
-                *      bigger, start - req.)
-                * 3) The map length is the minimum of the mappable
-                *      requested length (requested_length - virt_offset)
-                *      and the actual mappable length of the range.
-                */
-               mappable_region->start = range_start;
-               *virt_offset = range_start - bar_offset;
-               mappable_region->length_bytes =
-                       min(requested_length - *virt_offset, range_length);
-               return true;
-       } else if (bar_offset > range_start &&
-                  bar_offset < range_end) {
-               /*
-                * If the bar offset is within this range:
-                * 1) Map starting from the bar offset.
-                * 2) Because there is no forbidden memory between the
-                *      bar offset and the range start,
-                *      virt_offset is 0.
-                * 3) The map length is the minimum of the requested
-                *      length and the remaining length in the buffer
-                *      (range_end - bar_offset)
-                */
-               mappable_region->start = bar_offset;
-               *virt_offset = 0;
-               mappable_region->length_bytes =
-                       min(requested_length, range_end - bar_offset);
-               return true;
-       }
-
-       /*
-        * If the requested [start] offset is above range_end,
-        * there's nothing to map.
-        */
-       return false;
-}
-
-/*
- * Calculates the offset where the VMA range begins in its containing BAR.
- * The offset is written into bar_offset on success.
- * Returns zero on success, anything else on error.
- */
-static int gasket_mm_vma_bar_offset(const struct gasket_dev *gasket_dev,
-                                   const struct vm_area_struct *vma,
-                                   ulong *bar_offset)
-{
-       ulong raw_offset;
-       int bar_index;
-       const struct gasket_driver_desc *driver_desc =
-               gasket_dev->internal_desc->driver_desc;
-
-       raw_offset = (vma->vm_pgoff << PAGE_SHIFT) +
-               driver_desc->legacy_mmap_address_offset;
-       bar_index = gasket_get_bar_index(gasket_dev, raw_offset);
-       if (bar_index < 0) {
-               dev_err(gasket_dev->dev,
-                       "Unable to find matching bar for address 0x%lx\n",
-                       raw_offset);
-               trace_gasket_mmap_exit(bar_index);
-               return bar_index;
-       }
-       *bar_offset =
-               raw_offset - driver_desc->bar_descriptions[bar_index].base;
-
-       return 0;
-}
-
-int gasket_mm_unmap_region(const struct gasket_dev *gasket_dev,
-                          struct vm_area_struct *vma,
-                          const struct gasket_mappable_region *map_region)
-{
-       ulong bar_offset;
-       ulong virt_offset;
-       struct gasket_mappable_region mappable_region;
-       int ret;
-
-       if (map_region->length_bytes == 0)
-               return 0;
-
-       ret = gasket_mm_vma_bar_offset(gasket_dev, vma, &bar_offset);
-       if (ret)
-               return ret;
-
-       if (!gasket_mm_get_mapping_addrs(map_region, bar_offset,
-                                        vma->vm_end - vma->vm_start,
-                                        &mappable_region, &virt_offset))
-               return 1;
-
-       /*
-        * The length passed to zap_vma_ptes MUST BE A MULTIPLE OF
-        * PAGE_SIZE! Trust me. I have the scars.
-        *
-        * Next multiple of y: ceil_div(x, y) * y
-        */
-       zap_vma_ptes(vma, vma->vm_start + virt_offset,
-                    DIV_ROUND_UP(mappable_region.length_bytes, PAGE_SIZE) *
-                    PAGE_SIZE);
-       return 0;
-}
-EXPORT_SYMBOL(gasket_mm_unmap_region);
-
-/* Maps a virtual address + range to a physical offset of a BAR. */
-static enum do_map_region_status
-do_map_region(const struct gasket_dev *gasket_dev, struct vm_area_struct *vma,
-             struct gasket_mappable_region *mappable_region)
-{
-       /* Maximum size of a single call to io_remap_pfn_range. */
-       /* I pulled this number out of thin air. */
-       const ulong max_chunk_size = 64 * 1024 * 1024;
-       ulong chunk_size, mapped_bytes = 0;
-
-       const struct gasket_driver_desc *driver_desc =
-               gasket_dev->internal_desc->driver_desc;
-
-       ulong bar_offset, virt_offset;
-       struct gasket_mappable_region region_to_map;
-       ulong phys_offset, map_length;
-       ulong virt_base, phys_base;
-       int bar_index, ret;
-
-       ret = gasket_mm_vma_bar_offset(gasket_dev, vma, &bar_offset);
-       if (ret)
-               return DO_MAP_REGION_INVALID;
-
-       if (!gasket_mm_get_mapping_addrs(mappable_region, bar_offset,
-                                        vma->vm_end - vma->vm_start,
-                                        &region_to_map, &virt_offset))
-               return DO_MAP_REGION_INVALID;
-       phys_offset = region_to_map.start;
-       map_length = region_to_map.length_bytes;
-
-       virt_base = vma->vm_start + virt_offset;
-       bar_index =
-               gasket_get_bar_index(gasket_dev,
-                                    (vma->vm_pgoff << PAGE_SHIFT) +
-                                    driver_desc->legacy_mmap_address_offset);
-
-       if (bar_index < 0)
-               return DO_MAP_REGION_INVALID;
-
-       phys_base = gasket_dev->bar_data[bar_index].phys_base + phys_offset;
-       while (mapped_bytes < map_length) {
-               /*
-                * io_remap_pfn_range can take a while, so we chunk its
-                * calls and call cond_resched between each.
-                */
-               chunk_size = min(max_chunk_size, map_length - mapped_bytes);
-
-               cond_resched();
-               ret = io_remap_pfn_range(vma, virt_base + mapped_bytes,
-                                        (phys_base + mapped_bytes) >>
-                                        PAGE_SHIFT, chunk_size,
-                                        vma->vm_page_prot);
-               if (ret) {
-                       dev_err(gasket_dev->dev,
-                               "Error remapping PFN range.\n");
-                       goto fail;
-               }
-               mapped_bytes += chunk_size;
-       }
-
-       return DO_MAP_REGION_SUCCESS;
-
-fail:
-       /* Unmap the partial chunk we mapped. */
-       mappable_region->length_bytes = mapped_bytes;
-       if (gasket_mm_unmap_region(gasket_dev, vma, mappable_region))
-               dev_err(gasket_dev->dev,
-                       "Error unmapping partial region 0x%lx (0x%lx bytes)\n",
-                       (ulong)virt_offset,
-                       (ulong)mapped_bytes);
-
-       return DO_MAP_REGION_FAILURE;
-}
-
-/* Map a region of coherent memory. */
-static int gasket_mmap_coherent(struct gasket_dev *gasket_dev,
-                               struct vm_area_struct *vma)
-{
-       const struct gasket_driver_desc *driver_desc =
-               gasket_dev->internal_desc->driver_desc;
-       const ulong requested_length = vma->vm_end - vma->vm_start;
-       int ret;
-       ulong permissions;
-
-       if (requested_length == 0 || requested_length >
-           gasket_dev->coherent_buffer.length_bytes) {
-               trace_gasket_mmap_exit(-EINVAL);
-               return -EINVAL;
-       }
-
-       permissions = driver_desc->coherent_buffer_description.permissions;
-       if (!gasket_mmap_has_permissions(gasket_dev, vma, permissions)) {
-               dev_err(gasket_dev->dev, "Permission checking failed.\n");
-               trace_gasket_mmap_exit(-EPERM);
-               return -EPERM;
-       }
-
-       vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
-
-       ret = remap_pfn_range(vma, vma->vm_start,
-                             (gasket_dev->coherent_buffer.phys_base) >>
-                             PAGE_SHIFT, requested_length, vma->vm_page_prot);
-       if (ret) {
-               dev_err(gasket_dev->dev, "Error remapping PFN range err=%d.\n",
-                       ret);
-               trace_gasket_mmap_exit(ret);
-               return ret;
-       }
-
-       /* Record the user virtual to dma_address mapping that was
-        * created by the kernel.
-        */
-       gasket_set_user_virt(gasket_dev, requested_length,
-                            gasket_dev->coherent_buffer.phys_base,
-                            vma->vm_start);
-       return 0;
-}
-
-/* Map a device's BARs into user space. */
-static int gasket_mmap(struct file *filp, struct vm_area_struct *vma)
-{
-       int i, ret;
-       int bar_index;
-       int has_mapped_anything = 0;
-       ulong permissions;
-       ulong raw_offset, vma_size;
-       bool is_coherent_region;
-       const struct gasket_driver_desc *driver_desc;
-       struct gasket_dev *gasket_dev = (struct gasket_dev *)filp->private_data;
-       const struct gasket_bar_desc *bar_desc;
-       struct gasket_mappable_region *map_regions = NULL;
-       int num_map_regions = 0;
-       enum do_map_region_status map_status;
-
-       driver_desc = gasket_dev->internal_desc->driver_desc;
-
-       if (vma->vm_start & ~PAGE_MASK) {
-               dev_err(gasket_dev->dev,
-                       "Base address not page-aligned: 0x%lx\n",
-                       vma->vm_start);
-               trace_gasket_mmap_exit(-EINVAL);
-               return -EINVAL;
-       }
-
-       /* Calculate the offset of this range into physical mem. */
-       raw_offset = (vma->vm_pgoff << PAGE_SHIFT) +
-               driver_desc->legacy_mmap_address_offset;
-       vma_size = vma->vm_end - vma->vm_start;
-       trace_gasket_mmap_entry(gasket_dev->dev_info.name, raw_offset,
-                               vma_size);
-
-       /*
-        * Check if the raw offset is within a bar region. If not, check if it
-        * is a coherent region.
-        */
-       bar_index = gasket_get_bar_index(gasket_dev, raw_offset);
-       is_coherent_region = gasket_is_coherent_region(driver_desc, raw_offset);
-       if (bar_index < 0 && !is_coherent_region) {
-               dev_err(gasket_dev->dev,
-                       "Unable to find matching bar for address 0x%lx\n",
-                       raw_offset);
-               trace_gasket_mmap_exit(bar_index);
-               return bar_index;
-       }
-       if (bar_index > 0 && is_coherent_region) {
-               dev_err(gasket_dev->dev,
-                       "double matching bar and coherent buffers for address 0x%lx\n",
-                       raw_offset);
-               trace_gasket_mmap_exit(bar_index);
-               return -EINVAL;
-       }
-
-       vma->vm_private_data = gasket_dev;
-
-       if (is_coherent_region)
-               return gasket_mmap_coherent(gasket_dev, vma);
-
-       /* Everything in the rest of this function is for normal BAR mapping. */
-
-       /*
-        * Subtract the base of the bar from the raw offset to get the
-        * memory location within the bar to map.
-        */
-       bar_desc = &driver_desc->bar_descriptions[bar_index];
-       permissions = bar_desc->permissions;
-       if (!gasket_mmap_has_permissions(gasket_dev, vma, permissions)) {
-               dev_err(gasket_dev->dev, "Permission checking failed.\n");
-               trace_gasket_mmap_exit(-EPERM);
-               return -EPERM;
-       }
-
-       if (driver_desc->get_mappable_regions_cb) {
-               ret = driver_desc->get_mappable_regions_cb(gasket_dev,
-                                                          bar_index,
-                                                          &map_regions,
-                                                          &num_map_regions);
-               if (ret)
-                       return ret;
-       } else {
-               if (!gasket_mmap_has_permissions(gasket_dev, vma,
-                                                bar_desc->permissions)) {
-                       dev_err(gasket_dev->dev,
-                               "Permission checking failed.\n");
-                       trace_gasket_mmap_exit(-EPERM);
-                       return -EPERM;
-               }
-               num_map_regions = bar_desc->num_mappable_regions;
-               map_regions = kcalloc(num_map_regions,
-                                     sizeof(*bar_desc->mappable_regions),
-                                     GFP_KERNEL);
-               if (map_regions) {
-                       memcpy(map_regions, bar_desc->mappable_regions,
-                              num_map_regions *
-                                       sizeof(*bar_desc->mappable_regions));
-               }
-       }
-
-       if (!map_regions || num_map_regions == 0) {
-               dev_err(gasket_dev->dev, "No mappable regions returned!\n");
-               return -EINVAL;
-       }
-
-       /* Marks the VMA's pages as uncacheable. */
-       vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
-       for (i = 0; i < num_map_regions; i++) {
-               map_status = do_map_region(gasket_dev, vma, &map_regions[i]);
-               /* Try the next region if this one was not mappable. */
-               if (map_status == DO_MAP_REGION_INVALID)
-                       continue;
-               if (map_status == DO_MAP_REGION_FAILURE) {
-                       ret = -ENOMEM;
-                       goto fail;
-               }
-
-               has_mapped_anything = 1;
-       }
-
-       kfree(map_regions);
-
-       /* If we could not map any memory, the request was invalid. */
-       if (!has_mapped_anything) {
-               dev_err(gasket_dev->dev,
-                       "Map request did not contain a valid region.\n");
-               trace_gasket_mmap_exit(-EINVAL);
-               return -EINVAL;
-       }
-
-       trace_gasket_mmap_exit(0);
-       return 0;
-
-fail:
-       /* Need to unmap any mapped ranges. */
-       num_map_regions = i;
-       for (i = 0; i < num_map_regions; i++)
-               if (gasket_mm_unmap_region(gasket_dev, vma,
-                                          &bar_desc->mappable_regions[i]))
-                       dev_err(gasket_dev->dev, "Error unmapping range %d.\n",
-                               i);
-       kfree(map_regions);
-
-       return ret;
-}
-
-/*
- * Open the char device file.
- *
- * If the open is for writing, and the device is not owned, this process becomes
- * the owner.  If the open is for writing and the device is already owned by
- * some other process, it is an error.  If this process is the owner, increment
- * the open count.
- *
- * Returns 0 if successful, a negative error number otherwise.
- */
-static int gasket_open(struct inode *inode, struct file *filp)
-{
-       int ret;
-       struct gasket_dev *gasket_dev;
-       const struct gasket_driver_desc *driver_desc;
-       struct gasket_ownership *ownership;
-       char task_name[TASK_COMM_LEN];
-       struct gasket_cdev_info *dev_info =
-           container_of(inode->i_cdev, struct gasket_cdev_info, cdev);
-       struct pid_namespace *pid_ns = task_active_pid_ns(current);
-       bool is_root = ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN);
-
-       gasket_dev = dev_info->gasket_dev_ptr;
-       driver_desc = gasket_dev->internal_desc->driver_desc;
-       ownership = &dev_info->ownership;
-       get_task_comm(task_name, current);
-       filp->private_data = gasket_dev;
-       inode->i_size = 0;
-
-       dev_dbg(gasket_dev->dev,
-               "Attempting to open with tgid %u (%s) (f_mode: 0%03o, fmode_write: %d is_root: %u)\n",
-               current->tgid, task_name, filp->f_mode,
-               (filp->f_mode & FMODE_WRITE), is_root);
-
-       /* Always allow non-writing accesses. */
-       if (!(filp->f_mode & FMODE_WRITE)) {
-               dev_dbg(gasket_dev->dev, "Allowing read-only opening.\n");
-               return 0;
-       }
-
-       mutex_lock(&gasket_dev->mutex);
-
-       dev_dbg(gasket_dev->dev,
-               "Current owner open count (owning tgid %u): %d.\n",
-               ownership->owner, ownership->write_open_count);
-
-       /* Opening a node owned by another TGID is an error (unless root) */
-       if (ownership->is_owned && ownership->owner != current->tgid &&
-           !is_root) {
-               dev_err(gasket_dev->dev,
-                       "Process %u is opening a node held by %u.\n",
-                       current->tgid, ownership->owner);
-               mutex_unlock(&gasket_dev->mutex);
-               return -EPERM;
-       }
-
-       /* If the node is not owned, assign it to the current TGID. */
-       if (!ownership->is_owned) {
-               ret = gasket_check_and_invoke_callback_nolock(gasket_dev,
-                                                             driver_desc->device_open_cb);
-               if (ret) {
-                       dev_err(gasket_dev->dev,
-                               "Error in device open cb: %d\n", ret);
-                       mutex_unlock(&gasket_dev->mutex);
-                       return ret;
-               }
-               ownership->is_owned = 1;
-               ownership->owner = current->tgid;
-               dev_dbg(gasket_dev->dev, "Device owner is now tgid %u\n",
-                       ownership->owner);
-       }
-
-       ownership->write_open_count++;
-
-       dev_dbg(gasket_dev->dev, "New open count (owning tgid %u): %d\n",
-               ownership->owner, ownership->write_open_count);
-
-       mutex_unlock(&gasket_dev->mutex);
-       return 0;
-}
-
-/*
- * Called on a close of the device file.  If this process is the owner,
- * decrement the open count.  On last close by the owner, free up buffers and
- * eventfd contexts, and release ownership.
- *
- * Returns 0 if successful, a negative error number otherwise.
- */
-static int gasket_release(struct inode *inode, struct file *file)
-{
-       int i;
-       struct gasket_dev *gasket_dev;
-       struct gasket_ownership *ownership;
-       const struct gasket_driver_desc *driver_desc;
-       char task_name[TASK_COMM_LEN];
-       struct gasket_cdev_info *dev_info =
-               container_of(inode->i_cdev, struct gasket_cdev_info, cdev);
-       struct pid_namespace *pid_ns = task_active_pid_ns(current);
-       bool is_root = ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN);
-
-       gasket_dev = dev_info->gasket_dev_ptr;
-       driver_desc = gasket_dev->internal_desc->driver_desc;
-       ownership = &dev_info->ownership;
-       get_task_comm(task_name, current);
-       mutex_lock(&gasket_dev->mutex);
-
-       dev_dbg(gasket_dev->dev,
-               "Releasing device node. Call origin: tgid %u (%s) (f_mode: 0%03o, fmode_write: %d, is_root: %u)\n",
-               current->tgid, task_name, file->f_mode,
-               (file->f_mode & FMODE_WRITE), is_root);
-       dev_dbg(gasket_dev->dev, "Current open count (owning tgid %u): %d\n",
-               ownership->owner, ownership->write_open_count);
-
-       if (file->f_mode & FMODE_WRITE) {
-               ownership->write_open_count--;
-               if (ownership->write_open_count == 0) {
-                       dev_dbg(gasket_dev->dev, "Device is now free\n");
-                       ownership->is_owned = 0;
-                       ownership->owner = 0;
-
-                       /* Forces chip reset before we unmap the page tables. */
-                       driver_desc->device_reset_cb(gasket_dev);
-
-                       for (i = 0; i < driver_desc->num_page_tables; ++i) {
-                               gasket_page_table_unmap_all(gasket_dev->page_table[i]);
-                               gasket_page_table_garbage_collect(gasket_dev->page_table[i]);
-                               gasket_free_coherent_memory_all(gasket_dev, i);
-                       }
-
-                       /* Closes device, enters power save. */
-                       gasket_check_and_invoke_callback_nolock(gasket_dev,
-                                                               driver_desc->device_close_cb);
-               }
-       }
-
-       dev_dbg(gasket_dev->dev, "New open count (owning tgid %u): %d\n",
-               ownership->owner, ownership->write_open_count);
-       mutex_unlock(&gasket_dev->mutex);
-       return 0;
-}
-
-/*
- * Gasket ioctl dispatch function.
- *
- * Check if the ioctl is a generic ioctl. If not, pass the ioctl to the
- * ioctl_handler_cb registered in the driver description.
- * If the ioctl is a generic ioctl, pass it to gasket_ioctl_handler.
- */
-static long gasket_ioctl(struct file *filp, uint cmd, ulong arg)
-{
-       struct gasket_dev *gasket_dev;
-       const struct gasket_driver_desc *driver_desc;
-       void __user *argp = (void __user *)arg;
-       char path[256];
-
-       gasket_dev = (struct gasket_dev *)filp->private_data;
-       driver_desc = gasket_dev->internal_desc->driver_desc;
-       if (!driver_desc) {
-               dev_dbg(gasket_dev->dev,
-                       "Unable to find device descriptor for file %s\n",
-                       d_path(&filp->f_path, path, 256));
-               return -ENODEV;
-       }
-
-       if (!gasket_is_supported_ioctl(cmd)) {
-               /*
-                * The ioctl handler is not a standard Gasket callback, since
-                * it requires different arguments. This means we can't use
-                * check_and_invoke_callback.
-                */
-               if (driver_desc->ioctl_handler_cb)
-                       return driver_desc->ioctl_handler_cb(filp, cmd, argp);
-
-               dev_dbg(gasket_dev->dev, "Received unknown ioctl 0x%x\n", cmd);
-               return -EINVAL;
-       }
-
-       return gasket_handle_ioctl(filp, cmd, argp);
-}
-
-/* File operations for all Gasket devices. */
-static const struct file_operations gasket_file_ops = {
-       .owner = THIS_MODULE,
-       .llseek = no_llseek,
-       .mmap = gasket_mmap,
-       .open = gasket_open,
-       .release = gasket_release,
-       .unlocked_ioctl = gasket_ioctl,
-};
-
-/* Perform final init and marks the device as active. */
-int gasket_enable_device(struct gasket_dev *gasket_dev)
-{
-       int tbl_idx;
-       int ret;
-       const struct gasket_driver_desc *driver_desc =
-               gasket_dev->internal_desc->driver_desc;
-
-       ret = gasket_interrupt_init(gasket_dev);
-       if (ret) {
-               dev_err(gasket_dev->dev,
-                       "Critical failure to allocate interrupts: %d\n", ret);
-               gasket_interrupt_cleanup(gasket_dev);
-               return ret;
-       }
-
-       for (tbl_idx = 0; tbl_idx < driver_desc->num_page_tables; tbl_idx++) {
-               dev_dbg(gasket_dev->dev, "Initializing page table %d.\n",
-                       tbl_idx);
-               ret = gasket_page_table_init(&gasket_dev->page_table[tbl_idx],
-                                            &gasket_dev->bar_data[driver_desc->page_table_bar_index],
-                                            &driver_desc->page_table_configs[tbl_idx],
-                                            gasket_dev->dev,
-                                            gasket_dev->pci_dev);
-               if (ret) {
-                       dev_err(gasket_dev->dev,
-                               "Couldn't init page table %d: %d\n",
-                               tbl_idx, ret);
-                       return ret;
-               }
-               /*
-                * Make sure that the page table is clear and set to simple
-                * addresses.
-                */
-               gasket_page_table_reset(gasket_dev->page_table[tbl_idx]);
-       }
-
-       /*
-        * hardware_revision_cb returns a positive integer (the rev) if
-        * successful.)
-        */
-       ret = check_and_invoke_callback(gasket_dev,
-                                       driver_desc->hardware_revision_cb);
-       if (ret < 0) {
-               dev_err(gasket_dev->dev,
-                       "Error getting hardware revision: %d\n", ret);
-               return ret;
-       }
-       gasket_dev->hardware_revision = ret;
-
-       /* device_status_cb returns a device status, not an error code. */
-       gasket_dev->status = gasket_get_hw_status(gasket_dev);
-       if (gasket_dev->status == GASKET_STATUS_DEAD)
-               dev_err(gasket_dev->dev, "Device reported as unhealthy.\n");
-
-       ret = gasket_add_cdev(&gasket_dev->dev_info, &gasket_file_ops,
-                             driver_desc->module);
-       if (ret)
-               return ret;
-
-       return 0;
-}
-EXPORT_SYMBOL(gasket_enable_device);
-
-static int __gasket_add_device(struct device *parent_dev,
-                              struct gasket_internal_desc *internal_desc,
-                              struct gasket_dev **gasket_devp)
-{
-       int ret;
-       struct gasket_dev *gasket_dev;
-       const struct gasket_driver_desc *driver_desc =
-           internal_desc->driver_desc;
-
-       ret = gasket_alloc_dev(internal_desc, parent_dev, &gasket_dev);
-       if (ret)
-               return ret;
-       if (IS_ERR(gasket_dev->dev_info.device)) {
-               dev_err(parent_dev, "Cannot create %s device %s [ret = %ld]\n",
-                       driver_desc->name, gasket_dev->dev_info.name,
-                       PTR_ERR(gasket_dev->dev_info.device));
-               ret = -ENODEV;
-               goto free_gasket_dev;
-       }
-
-       ret = gasket_sysfs_create_mapping(gasket_dev->dev_info.device,
-                                         gasket_dev);
-       if (ret)
-               goto remove_device;
-
-       ret = gasket_sysfs_create_entries(gasket_dev->dev_info.device,
-                                         gasket_sysfs_generic_attrs);
-       if (ret)
-               goto remove_sysfs_mapping;
-
-       *gasket_devp = gasket_dev;
-       return 0;
-
-remove_sysfs_mapping:
-       gasket_sysfs_remove_mapping(gasket_dev->dev_info.device);
-remove_device:
-       device_destroy(internal_desc->class, gasket_dev->dev_info.devt);
-free_gasket_dev:
-       gasket_free_dev(gasket_dev);
-       return ret;
-}
-
-static void __gasket_remove_device(struct gasket_internal_desc *internal_desc,
-                                  struct gasket_dev *gasket_dev)
-{
-       gasket_sysfs_remove_mapping(gasket_dev->dev_info.device);
-       device_destroy(internal_desc->class, gasket_dev->dev_info.devt);
-       gasket_free_dev(gasket_dev);
-}
-
-/*
- * Add PCI gasket device.
- *
- * Called by Gasket device probe function.
- * Allocates device metadata and maps device memory.  The device driver must
- * call gasket_enable_device after driver init is complete to place the device
- * in active use.
- */
-int gasket_pci_add_device(struct pci_dev *pci_dev,
-                         struct gasket_dev **gasket_devp)
-{
-       int ret;
-       struct gasket_internal_desc *internal_desc;
-       struct gasket_dev *gasket_dev;
-       struct device *parent;
-
-       dev_dbg(&pci_dev->dev, "add PCI gasket device\n");
-
-       mutex_lock(&g_mutex);
-       internal_desc = lookup_pci_internal_desc(pci_dev);
-       mutex_unlock(&g_mutex);
-       if (!internal_desc) {
-               dev_err(&pci_dev->dev,
-                       "PCI add device called for unknown driver type\n");
-               return -ENODEV;
-       }
-
-       parent = &pci_dev->dev;
-       ret = __gasket_add_device(parent, internal_desc, &gasket_dev);
-       if (ret)
-               return ret;
-
-       gasket_dev->pci_dev = pci_dev;
-       ret = gasket_setup_pci(pci_dev, gasket_dev);
-       if (ret)
-               goto cleanup_pci;
-
-       /*
-        * Once we've created the mapping structures successfully, attempt to
-        * create a symlink to the pci directory of this object.
-        */
-       ret = sysfs_create_link(&gasket_dev->dev_info.device->kobj,
-                               &pci_dev->dev.kobj, dev_name(&pci_dev->dev));
-       if (ret) {
-               dev_err(gasket_dev->dev,
-                       "Cannot create sysfs pci link: %d\n", ret);
-               goto cleanup_pci;
-       }
-
-       *gasket_devp = gasket_dev;
-       return 0;
-
-cleanup_pci:
-       gasket_cleanup_pci(gasket_dev);
-       __gasket_remove_device(internal_desc, gasket_dev);
-       return ret;
-}
-EXPORT_SYMBOL(gasket_pci_add_device);
-
-/* Remove a PCI gasket device. */
-void gasket_pci_remove_device(struct pci_dev *pci_dev)
-{
-       int i;
-       struct gasket_internal_desc *internal_desc;
-       struct gasket_dev *gasket_dev = NULL;
-       /* Find the device desc. */
-       mutex_lock(&g_mutex);
-       internal_desc = lookup_pci_internal_desc(pci_dev);
-       if (!internal_desc) {
-               mutex_unlock(&g_mutex);
-               return;
-       }
-       mutex_unlock(&g_mutex);
-
-       /* Now find the specific device */
-       mutex_lock(&internal_desc->mutex);
-       for (i = 0; i < GASKET_DEV_MAX; i++) {
-               if (internal_desc->devs[i] &&
-                   internal_desc->devs[i]->pci_dev == pci_dev) {
-                       gasket_dev = internal_desc->devs[i];
-                       break;
-               }
-       }
-       mutex_unlock(&internal_desc->mutex);
-
-       if (!gasket_dev)
-               return;
-
-       dev_dbg(gasket_dev->dev, "remove %s PCI gasket device\n",
-               internal_desc->driver_desc->name);
-
-       gasket_cleanup_pci(gasket_dev);
-       __gasket_remove_device(internal_desc, gasket_dev);
-}
-EXPORT_SYMBOL(gasket_pci_remove_device);
-
-/**
- * Lookup a name by number in a num_name table.
- * @num: Number to lookup.
- * @table: Array of num_name structures, the table for the lookup.
- *
- * Description: Searches for num in the table.  If found, the
- *             corresponding name is returned; otherwise NULL
- *             is returned.
- *
- *             The table must have a NULL name pointer at the end.
- */
-const char *gasket_num_name_lookup(uint num,
-                                  const struct gasket_num_name *table)
-{
-       uint i = 0;
-
-       while (table[i].snn_name) {
-               if (num == table[i].snn_num)
-                       break;
-               ++i;
-       }
-
-       return table[i].snn_name;
-}
-EXPORT_SYMBOL(gasket_num_name_lookup);
-
-int gasket_reset(struct gasket_dev *gasket_dev)
-{
-       int ret;
-
-       mutex_lock(&gasket_dev->mutex);
-       ret = gasket_reset_nolock(gasket_dev);
-       mutex_unlock(&gasket_dev->mutex);
-       return ret;
-}
-EXPORT_SYMBOL(gasket_reset);
-
-int gasket_reset_nolock(struct gasket_dev *gasket_dev)
-{
-       int ret;
-       int i;
-       const struct gasket_driver_desc *driver_desc;
-
-       driver_desc = gasket_dev->internal_desc->driver_desc;
-       if (!driver_desc->device_reset_cb)
-               return 0;
-
-       ret = driver_desc->device_reset_cb(gasket_dev);
-       if (ret) {
-               dev_dbg(gasket_dev->dev, "Device reset cb returned %d.\n",
-                       ret);
-               return ret;
-       }
-
-       /* Reinitialize the page tables and interrupt framework. */
-       for (i = 0; i < driver_desc->num_page_tables; ++i)
-               gasket_page_table_reset(gasket_dev->page_table[i]);
-
-       ret = gasket_interrupt_reinit(gasket_dev);
-       if (ret) {
-               dev_dbg(gasket_dev->dev, "Unable to reinit interrupts: %d.\n",
-                       ret);
-               return ret;
-       }
-
-       /* Get current device health. */
-       gasket_dev->status = gasket_get_hw_status(gasket_dev);
-       if (gasket_dev->status == GASKET_STATUS_DEAD) {
-               dev_dbg(gasket_dev->dev, "Device reported as dead.\n");
-               return -EINVAL;
-       }
-
-       return 0;
-}
-EXPORT_SYMBOL(gasket_reset_nolock);
-
-gasket_ioctl_permissions_cb_t
-gasket_get_ioctl_permissions_cb(struct gasket_dev *gasket_dev)
-{
-       return gasket_dev->internal_desc->driver_desc->ioctl_permissions_cb;
-}
-EXPORT_SYMBOL(gasket_get_ioctl_permissions_cb);
-
-/* Get the driver structure for a given gasket_dev.
- * @dev: pointer to gasket_dev, implementing the requested driver.
- */
-const struct gasket_driver_desc *gasket_get_driver_desc(struct gasket_dev *dev)
-{
-       return dev->internal_desc->driver_desc;
-}
-
-/* Get the device structure for a given gasket_dev.
- * @dev: pointer to gasket_dev, implementing the requested driver.
- */
-struct device *gasket_get_device(struct gasket_dev *dev)
-{
-       return dev->dev;
-}
-
-/**
- * Asynchronously waits on device.
- * @gasket_dev: Device struct.
- * @bar: Bar
- * @offset: Register offset
- * @mask: Register mask
- * @val: Expected value
- * @max_retries: number of sleep periods
- * @delay_ms: Timeout in milliseconds
- *
- * Description: Busy waits for a specific combination of bits to be set on a
- * Gasket register.
- **/
-int gasket_wait_with_reschedule(struct gasket_dev *gasket_dev, int bar,
-                               u64 offset, u64 mask, u64 val,
-                               uint max_retries, u64 delay_ms)
-{
-       uint retries = 0;
-       u64 tmp;
-
-       while (retries < max_retries) {
-               tmp = gasket_dev_read_64(gasket_dev, bar, offset);
-               if ((tmp & mask) == val)
-                       return 0;
-               msleep(delay_ms);
-               retries++;
-       }
-       dev_dbg(gasket_dev->dev, "%s timeout: reg %llx timeout (%llu ms)\n",
-               __func__, offset, max_retries * delay_ms);
-       return -ETIMEDOUT;
-}
-EXPORT_SYMBOL(gasket_wait_with_reschedule);
-
-/* See gasket_core.h for description. */
-int gasket_register_device(const struct gasket_driver_desc *driver_desc)
-{
-       int i, ret;
-       int desc_idx = -1;
-       struct gasket_internal_desc *internal;
-
-       pr_debug("Loading %s driver version %s\n", driver_desc->name,
-                driver_desc->driver_version);
-       /* Check for duplicates and find a free slot. */
-       mutex_lock(&g_mutex);
-
-       for (i = 0; i < GASKET_FRAMEWORK_DESC_MAX; i++) {
-               if (g_descs[i].driver_desc == driver_desc) {
-                       pr_err("%s driver already loaded/registered\n",
-                              driver_desc->name);
-                       mutex_unlock(&g_mutex);
-                       return -EBUSY;
-               }
-       }
-
-       /* This and the above loop could be combined, but this reads easier. */
-       for (i = 0; i < GASKET_FRAMEWORK_DESC_MAX; i++) {
-               if (!g_descs[i].driver_desc) {
-                       g_descs[i].driver_desc = driver_desc;
-                       desc_idx = i;
-                       break;
-               }
-       }
-       mutex_unlock(&g_mutex);
-
-       if (desc_idx == -1) {
-               pr_err("too many drivers loaded, max %d\n",
-                      GASKET_FRAMEWORK_DESC_MAX);
-               return -EBUSY;
-       }
-
-       internal = &g_descs[desc_idx];
-       mutex_init(&internal->mutex);
-       memset(internal->devs, 0, sizeof(struct gasket_dev *) * GASKET_DEV_MAX);
-       internal->class =
-               class_create(driver_desc->module, driver_desc->name);
-
-       if (IS_ERR(internal->class)) {
-               pr_err("Cannot register %s class [ret=%ld]\n",
-                      driver_desc->name, PTR_ERR(internal->class));
-               ret = PTR_ERR(internal->class);
-               goto unregister_gasket_driver;
-       }
-
-       ret = register_chrdev_region(MKDEV(driver_desc->major,
-                                          driver_desc->minor), GASKET_DEV_MAX,
-                                    driver_desc->name);
-       if (ret) {
-               pr_err("cannot register %s char driver [ret=%d]\n",
-                      driver_desc->name, ret);
-               goto destroy_class;
-       }
-
-       return 0;
-
-destroy_class:
-       class_destroy(internal->class);
-
-unregister_gasket_driver:
-       mutex_lock(&g_mutex);
-       g_descs[desc_idx].driver_desc = NULL;
-       mutex_unlock(&g_mutex);
-       return ret;
-}
-EXPORT_SYMBOL(gasket_register_device);
-
-/* See gasket_core.h for description. */
-void gasket_unregister_device(const struct gasket_driver_desc *driver_desc)
-{
-       int i, desc_idx;
-       struct gasket_internal_desc *internal_desc = NULL;
-
-       mutex_lock(&g_mutex);
-       for (i = 0; i < GASKET_FRAMEWORK_DESC_MAX; i++) {
-               if (g_descs[i].driver_desc == driver_desc) {
-                       internal_desc = &g_descs[i];
-                       desc_idx = i;
-                       break;
-               }
-       }
-
-       if (!internal_desc) {
-               mutex_unlock(&g_mutex);
-               pr_err("request to unregister unknown desc: %s, %d:%d\n",
-                      driver_desc->name, driver_desc->major,
-                      driver_desc->minor);
-               return;
-       }
-
-       unregister_chrdev_region(MKDEV(driver_desc->major, driver_desc->minor),
-                                GASKET_DEV_MAX);
-
-       class_destroy(internal_desc->class);
-
-       /* Finally, effectively "remove" the driver. */
-       g_descs[desc_idx].driver_desc = NULL;
-       mutex_unlock(&g_mutex);
-
-       pr_debug("removed %s driver\n", driver_desc->name);
-}
-EXPORT_SYMBOL(gasket_unregister_device);
-
-static int __init gasket_init(void)
-{
-       int i;
-
-       mutex_lock(&g_mutex);
-       for (i = 0; i < GASKET_FRAMEWORK_DESC_MAX; i++) {
-               g_descs[i].driver_desc = NULL;
-               mutex_init(&g_descs[i].mutex);
-       }
-
-       gasket_sysfs_init();
-
-       mutex_unlock(&g_mutex);
-       return 0;
-}
-
-MODULE_DESCRIPTION("Google Gasket driver framework");
-MODULE_VERSION(GASKET_FRAMEWORK_VERSION);
-MODULE_LICENSE("GPL v2");
-MODULE_AUTHOR("Rob Springer <rspringer@google.com>");
-module_init(gasket_init);
diff --git a/drivers/staging/gasket/gasket_core.h b/drivers/staging/gasket/gasket_core.h
deleted file mode 100644 (file)
index c417aca..0000000
+++ /dev/null
@@ -1,638 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Gasket generic driver. Defines the set of data types and functions necessary
- * to define a driver using the Gasket generic driver framework.
- *
- * Copyright (C) 2018 Google, Inc.
- */
-#ifndef __GASKET_CORE_H__
-#define __GASKET_CORE_H__
-
-#include <linux/cdev.h>
-#include <linux/compiler.h>
-#include <linux/device.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/pci.h>
-#include <linux/sched.h>
-#include <linux/slab.h>
-
-#include "gasket_constants.h"
-
-/**
- * struct gasket_num_name - Map numbers to names.
- * @ein_num: Number.
- * @ein_name: Name associated with the number, a char pointer.
- *
- * This structure maps numbers to names. It is used to provide printable enum
- * names, e.g {0, "DEAD"} or {1, "ALIVE"}.
- */
-struct gasket_num_name {
-       uint snn_num;
-       const char *snn_name;
-};
-
-/*
- * Register location for packed interrupts.
- * Each value indicates the location of an interrupt field (in units of
- * gasket_driver_desc->interrupt_pack_width) within the containing register.
- * In other words, this indicates the shift to use when creating a mask to
- * extract/set bits within a register for a given interrupt.
- */
-enum gasket_interrupt_packing {
-       PACK_0 = 0,
-       PACK_1 = 1,
-       PACK_2 = 2,
-       PACK_3 = 3,
-       UNPACKED = 4,
-};
-
-/* Type of the interrupt supported by the device. */
-enum gasket_interrupt_type {
-       PCI_MSIX = 0,
-};
-
-/*
- * Used to describe a Gasket interrupt. Contains an interrupt index, a register,
- * and packing data for that interrupt. The register and packing data
- * fields are relevant only for PCI_MSIX interrupt type and can be
- * set to 0 for everything else.
- */
-struct gasket_interrupt_desc {
-       /* Device-wide interrupt index/number. */
-       int index;
-       /* The register offset controlling this interrupt. */
-       u64 reg;
-       /* The location of this interrupt inside register reg, if packed. */
-       int packing;
-};
-
-/*
- * This enum is used to identify memory regions being part of the physical
- * memory that belongs to a device.
- */
-enum mappable_area_type {
-       PCI_BAR = 0, /* Default */
-       BUS_REGION,  /* For SYSBUS devices, i.e. AXI etc... */
-       COHERENT_MEMORY
-};
-
-/*
- * Metadata for each BAR mapping.
- * This struct is used so as to track PCI memory, I/O space, AXI and coherent
- * memory area... i.e. memory objects which can be referenced in the device's
- * mmap function.
- */
-struct gasket_bar_data {
-       /* Virtual base address. */
-       u8 __iomem *virt_base;
-
-       /* Physical base address. */
-       ulong phys_base;
-
-       /* Length of the mapping. */
-       ulong length_bytes;
-
-       /* Type of mappable area */
-       enum mappable_area_type type;
-};
-
-/* Maintains device open ownership data. */
-struct gasket_ownership {
-       /* 1 if the device is owned, 0 otherwise. */
-       int is_owned;
-
-       /* TGID of the owner. */
-       pid_t owner;
-
-       /* Count of current device opens in write mode. */
-       int write_open_count;
-};
-
-/* Page table modes of operation. */
-enum gasket_page_table_mode {
-       /* The page table is partitionable as normal, all simple by default. */
-       GASKET_PAGE_TABLE_MODE_NORMAL,
-
-       /* All entries are always simple. */
-       GASKET_PAGE_TABLE_MODE_SIMPLE,
-
-       /* All entries are always extended. No extended bit is used. */
-       GASKET_PAGE_TABLE_MODE_EXTENDED,
-};
-
-/* Page table configuration. One per table. */
-struct gasket_page_table_config {
-       /* The identifier/index of this page table. */
-       int id;
-
-       /* The operation mode of this page table. */
-       enum gasket_page_table_mode mode;
-
-       /* Total (first-level) entries in this page table. */
-       ulong total_entries;
-
-       /* Base register for the page table. */
-       int base_reg;
-
-       /*
-        * Register containing the extended page table. This value is unused in
-        * GASKET_PAGE_TABLE_MODE_SIMPLE and GASKET_PAGE_TABLE_MODE_EXTENDED
-        * modes.
-        */
-       int extended_reg;
-
-       /* The bit index indicating whether a PT entry is extended. */
-       int extended_bit;
-};
-
-/* Maintains information about a device node. */
-struct gasket_cdev_info {
-       /* The internal name of this device. */
-       char name[GASKET_NAME_MAX];
-
-       /* Device number. */
-       dev_t devt;
-
-       /* Kernel-internal device structure. */
-       struct device *device;
-
-       /* Character device for real. */
-       struct cdev cdev;
-
-       /* Flag indicating if cdev_add has been called for the devices. */
-       int cdev_added;
-
-       /* Pointer to the overall gasket_dev struct for this device. */
-       struct gasket_dev *gasket_dev_ptr;
-
-       /* Ownership data for the device in question. */
-       struct gasket_ownership ownership;
-};
-
-/* Describes the offset and length of mmapable device BAR regions. */
-struct gasket_mappable_region {
-       u64 start;
-       u64 length_bytes;
-};
-
-/* Describe the offset, size, and permissions for a device bar. */
-struct gasket_bar_desc {
-       /*
-        * The size of each PCI BAR range, in bytes. If a value is 0, that BAR
-        * will not be mapped into kernel space at all.
-        * For devices with 64 bit BARs, only elements 0, 2, and 4 should be
-        * populated, and 1, 3, and 5 should be set to 0.
-        * For example, for a device mapping 1M in each of the first two 64-bit
-        * BARs, this field would be set as { 0x100000, 0, 0x100000, 0, 0, 0 }
-        * (one number per bar_desc struct.)
-        */
-       u64 size;
-       /* The permissions for this bar. (Should be VM_WRITE/VM_READ/VM_EXEC,
-        * and can be or'd.) If set to GASKET_NOMAP, the bar will
-        * not be used for mmapping.
-        */
-       ulong permissions;
-       /* The memory address corresponding to the base of this bar, if used. */
-       u64 base;
-       /* The number of mappable regions in this bar. */
-       int num_mappable_regions;
-
-       /* The mappable subregions of this bar. */
-       const struct gasket_mappable_region *mappable_regions;
-
-       /* Type of mappable area */
-       enum mappable_area_type type;
-};
-
-/* Describes the offset, size, and permissions for a coherent buffer. */
-struct gasket_coherent_buffer_desc {
-       /* The size of the coherent buffer. */
-       u64 size;
-
-       /* The permissions for this bar. (Should be VM_WRITE/VM_READ/VM_EXEC,
-        * and can be or'd.) If set to GASKET_NOMAP, the bar will
-        * not be used for mmaping.
-        */
-       ulong permissions;
-
-       /* device side address. */
-       u64 base;
-};
-
-/* Coherent buffer structure. */
-struct gasket_coherent_buffer {
-       /* Virtual base address. */
-       u8 *virt_base;
-
-       /* Physical base address. */
-       ulong phys_base;
-
-       /* Length of the mapping. */
-       ulong length_bytes;
-};
-
-/* Description of Gasket-specific permissions in the mmap field. */
-enum gasket_mapping_options { GASKET_NOMAP = 0 };
-
-/* This struct represents an undefined bar that should never be mapped. */
-#define GASKET_UNUSED_BAR                                                      \
-       {                                                                      \
-               0, GASKET_NOMAP, 0, 0, NULL, 0                                 \
-       }
-
-/* Internal data for a Gasket device. See gasket_core.c for more information. */
-struct gasket_internal_desc;
-
-#define MAX_NUM_COHERENT_PAGES 16
-
-/*
- * Device data for Gasket device instances.
- *
- * This structure contains the data required to manage a Gasket device.
- */
-struct gasket_dev {
-       /* Pointer to the internal driver description for this device. */
-       struct gasket_internal_desc *internal_desc;
-
-       /* Device info */
-       struct device *dev;
-
-       /* PCI subsystem metadata. */
-       struct pci_dev *pci_dev;
-
-       /* This device's index into internal_desc->devs. */
-       int dev_idx;
-
-       /* The name of this device, as reported by the kernel. */
-       char kobj_name[GASKET_NAME_MAX];
-
-       /* Virtual address of mapped BAR memory range. */
-       struct gasket_bar_data bar_data[PCI_STD_NUM_BARS];
-
-       /* Coherent buffer. */
-       struct gasket_coherent_buffer coherent_buffer;
-
-       /* Number of page tables for this device. */
-       int num_page_tables;
-
-       /* Address translations. Page tables have a private implementation. */
-       struct gasket_page_table *page_table[GASKET_MAX_NUM_PAGE_TABLES];
-
-       /* Interrupt data for this device. */
-       struct gasket_interrupt_data *interrupt_data;
-
-       /* Status for this device - GASKET_STATUS_ALIVE or _DEAD. */
-       uint status;
-
-       /* Number of times this device has been reset. */
-       uint reset_count;
-
-       /* Dev information for the cdev node. */
-       struct gasket_cdev_info dev_info;
-
-       /* Hardware revision value for this device. */
-       int hardware_revision;
-
-       /* Protects access to per-device data (i.e. this structure). */
-       struct mutex mutex;
-
-       /* cdev hash tracking/membership structure, Accel and legacy. */
-       /* Unused until Accel is upstreamed. */
-       struct hlist_node hlist_node;
-       struct hlist_node legacy_hlist_node;
-};
-
-/* Type of the ioctl handler callback. */
-typedef long (*gasket_ioctl_handler_cb_t)(struct file *file, uint cmd,
-                                         void __user *argp);
-/* Type of the ioctl permissions check callback. See below. */
-typedef int (*gasket_ioctl_permissions_cb_t)(struct file *filp, uint cmd,
-                                            void __user *argp);
-
-/*
- * Device type descriptor.
- *
- * This structure contains device-specific data needed to identify and address a
- * type of device to be administered via the Gasket generic driver.
- *
- * Device IDs are per-driver. In other words, two drivers using the Gasket
- * framework will each have a distinct device 0 (for example).
- */
-struct gasket_driver_desc {
-       /* The name of this device type. */
-       const char *name;
-
-       /* The name of this specific device model. */
-       const char *chip_model;
-
-       /* The version of the chip specified in chip_model. */
-       const char *chip_version;
-
-       /* The version of this driver: "1.0.0", "2.1.3", etc. */
-       const char *driver_version;
-
-       /*
-        * Non-zero if we should create "legacy" (device and device-class-
-        * specific) character devices and sysfs nodes.
-        */
-       /* Unused until Accel is upstreamed. */
-       int legacy_support;
-
-       /* Major and minor numbers identifying the device. */
-       int major, minor;
-
-       /* Module structure for this driver. */
-       struct module *module;
-
-       /* PCI ID table. */
-       const struct pci_device_id *pci_id_table;
-
-       /* The number of page tables handled by this driver. */
-       int num_page_tables;
-
-       /* The index of the bar containing the page tables. */
-       int page_table_bar_index;
-
-       /* Registers used to control each page table. */
-       const struct gasket_page_table_config *page_table_configs;
-
-       /* The bit index indicating whether a PT entry is extended. */
-       int page_table_extended_bit;
-
-       /*
-        * Legacy mmap address adjusment for legacy devices only. Should be 0
-        * for any new device.
-        */
-       ulong legacy_mmap_address_offset;
-
-       /* Set of 6 bar descriptions that describe all PCIe bars.
-        * Note that BUS/AXI devices (i.e. non PCI devices) use those.
-        */
-       struct gasket_bar_desc bar_descriptions[PCI_STD_NUM_BARS];
-
-       /*
-        * Coherent buffer description.
-        */
-       struct gasket_coherent_buffer_desc coherent_buffer_description;
-
-       /* Interrupt type. (One of gasket_interrupt_type). */
-       int interrupt_type;
-
-       /* Index of the bar containing the interrupt registers to program. */
-       int interrupt_bar_index;
-
-       /* Number of interrupts in the gasket_interrupt_desc array */
-       int num_interrupts;
-
-       /* Description of the interrupts for this device. */
-       const struct gasket_interrupt_desc *interrupts;
-
-       /*
-        * If this device packs multiple interrupt->MSI-X mappings into a
-        * single register (i.e., "uses packed interrupts"), only a single bit
-        * width is supported for each interrupt mapping (unpacked/"full-width"
-        * interrupts are always supported). This value specifies that width. If
-        * packed interrupts are not used, this value is ignored.
-        */
-       int interrupt_pack_width;
-
-       /* Driver callback functions - all may be NULL */
-       /*
-        * device_open_cb: Callback for when a device node is opened in write
-        * mode.
-        * @dev: The gasket_dev struct for this driver instance.
-        *
-        * This callback should perform device-specific setup that needs to
-        * occur only once when a device is first opened.
-        */
-       int (*device_open_cb)(struct gasket_dev *dev);
-
-       /*
-        * device_release_cb: Callback when a device is closed.
-        * @gasket_dev: The gasket_dev struct for this driver instance.
-        *
-        * This callback is called whenever a device node fd is closed, as
-        * opposed to device_close_cb, which is called when the _last_
-        * descriptor for an open file is closed. This call is intended to
-        * handle any per-user or per-fd cleanup.
-        */
-       int (*device_release_cb)(struct gasket_dev *gasket_dev,
-                                struct file *file);
-
-       /*
-        * device_close_cb: Callback for when a device node is closed for the
-        * last time.
-        * @dev: The gasket_dev struct for this driver instance.
-        *
-        * This callback should perform device-specific cleanup that only
-        * needs to occur when the last reference to a device node is closed.
-        *
-        * This call is intended to handle and device-wide cleanup, as opposed
-        * to per-fd cleanup (which should be handled by device_release_cb).
-        */
-       int (*device_close_cb)(struct gasket_dev *dev);
-
-       /*
-        * get_mappable_regions_cb: Get descriptors of mappable device memory.
-        * @gasket_dev: Pointer to the struct gasket_dev for this device.
-        * @bar_index: BAR for which to retrieve memory ranges.
-        * @mappable_regions: Out-pointer to the list of mappable regions on the
-        * device/BAR for this process.
-        * @num_mappable_regions: Out-pointer for the size of mappable_regions.
-        *
-        * Called when handling mmap(), this callback is used to determine which
-        * regions of device memory may be mapped by the current process. This
-        * information is then compared to mmap request to determine which
-        * regions to actually map.
-        */
-       int (*get_mappable_regions_cb)(struct gasket_dev *gasket_dev,
-                                      int bar_index,
-                                      struct gasket_mappable_region **mappable_regions,
-                                      int *num_mappable_regions);
-
-       /*
-        * ioctl_permissions_cb: Check permissions for generic ioctls.
-        * @filp: File structure pointer describing this node usage session.
-        * @cmd: ioctl number to handle.
-        * @arg: ioctl-specific data pointer.
-        *
-        * Returns 1 if the ioctl may be executed, 0 otherwise. If this callback
-        * isn't specified a default routine will be used, that only allows the
-        * original device opener (i.e, the "owner") to execute state-affecting
-        * ioctls.
-        */
-       gasket_ioctl_permissions_cb_t ioctl_permissions_cb;
-
-       /*
-        * ioctl_handler_cb: Callback to handle device-specific ioctls.
-        * @filp: File structure pointer describing this node usage session.
-        * @cmd: ioctl number to handle.
-        * @arg: ioctl-specific data pointer.
-        *
-        * Invoked whenever an ioctl is called that the generic Gasket
-        * framework doesn't support. If no cb is registered, unknown ioctls
-        * return -EINVAL. Should return an error status (either -EINVAL or
-        * the error result of the ioctl being handled).
-        */
-       gasket_ioctl_handler_cb_t ioctl_handler_cb;
-
-       /*
-        * device_status_cb: Callback to determine device health.
-        * @dev: Pointer to the gasket_dev struct for this device.
-        *
-        * Called to determine if the device is healthy or not. Should return
-        * a member of the gasket_status_type enum.
-        *
-        */
-       int (*device_status_cb)(struct gasket_dev *dev);
-
-       /*
-        * hardware_revision_cb: Get the device's hardware revision.
-        * @dev: Pointer to the gasket_dev struct for this device.
-        *
-        * Called to determine the reported rev of the physical hardware.
-        * Revision should be >0. A negative return value is an error.
-        */
-       int (*hardware_revision_cb)(struct gasket_dev *dev);
-
-       /*
-        * device_reset_cb: Reset the hardware in question.
-        * @dev: Pointer to the gasket_dev structure for this device.
-        *
-        * Called by reset ioctls. This function should not
-        * lock the gasket_dev mutex. It should return 0 on success
-        * and an error on failure.
-        */
-       int (*device_reset_cb)(struct gasket_dev *dev);
-};
-
-/*
- * Register the specified device type with the framework.
- * @desc: Populated/initialized device type descriptor.
- *
- * This function does _not_ take ownership of desc; the underlying struct must
- * exist until the matching call to gasket_unregister_device.
- * This function should be called from your driver's module_init function.
- */
-int gasket_register_device(const struct gasket_driver_desc *desc);
-
-/*
- * Remove the specified device type from the framework.
- * @desc: Descriptor for the device type to unregister; it should have been
- *        passed to gasket_register_device in a previous call.
- *
- * This function should be called from your driver's module_exit function.
- */
-void gasket_unregister_device(const struct gasket_driver_desc *desc);
-
-/* Add a PCI gasket device. */
-int gasket_pci_add_device(struct pci_dev *pci_dev,
-                         struct gasket_dev **gasket_devp);
-/* Remove a PCI gasket device. */
-void gasket_pci_remove_device(struct pci_dev *pci_dev);
-
-/* Enable a Gasket device. */
-int gasket_enable_device(struct gasket_dev *gasket_dev);
-
-/* Disable a Gasket device. */
-void gasket_disable_device(struct gasket_dev *gasket_dev);
-
-/*
- * Reset the Gasket device.
- * @gasket_dev: Gasket device struct.
- *
- * Calls device_reset_cb. Returns 0 on success and an error code othewrise.
- * gasket_reset_nolock will not lock the mutex, gasket_reset will.
- *
- */
-int gasket_reset(struct gasket_dev *gasket_dev);
-int gasket_reset_nolock(struct gasket_dev *gasket_dev);
-
-/*
- * Memory management functions. These will likely be spun off into their own
- * file in the future.
- */
-
-/* Unmaps the specified mappable region from a VMA. */
-int gasket_mm_unmap_region(const struct gasket_dev *gasket_dev,
-                          struct vm_area_struct *vma,
-                          const struct gasket_mappable_region *map_region);
-
-/*
- * Get the ioctl permissions callback.
- * @gasket_dev: Gasket device structure.
- */
-gasket_ioctl_permissions_cb_t
-gasket_get_ioctl_permissions_cb(struct gasket_dev *gasket_dev);
-
-/**
- * Lookup a name by number in a num_name table.
- * @num: Number to lookup.
- * @table: Array of num_name structures, the table for the lookup.
- *
- */
-const char *gasket_num_name_lookup(uint num,
-                                  const struct gasket_num_name *table);
-
-/* Handy inlines */
-static inline ulong gasket_dev_read_64(struct gasket_dev *gasket_dev, int bar,
-                                      ulong location)
-{
-       return readq_relaxed(&gasket_dev->bar_data[bar].virt_base[location]);
-}
-
-static inline void gasket_dev_write_64(struct gasket_dev *dev, u64 value,
-                                      int bar, ulong location)
-{
-       writeq_relaxed(value, &dev->bar_data[bar].virt_base[location]);
-}
-
-static inline void gasket_dev_write_32(struct gasket_dev *dev, u32 value,
-                                      int bar, ulong location)
-{
-       writel_relaxed(value, &dev->bar_data[bar].virt_base[location]);
-}
-
-static inline u32 gasket_dev_read_32(struct gasket_dev *dev, int bar,
-                                    ulong location)
-{
-       return readl_relaxed(&dev->bar_data[bar].virt_base[location]);
-}
-
-static inline void gasket_read_modify_write_64(struct gasket_dev *dev, int bar,
-                                              ulong location, u64 value,
-                                              u64 mask_width, u64 mask_shift)
-{
-       u64 mask, tmp;
-
-       tmp = gasket_dev_read_64(dev, bar, location);
-       mask = ((1ULL << mask_width) - 1) << mask_shift;
-       tmp = (tmp & ~mask) | (value << mask_shift);
-       gasket_dev_write_64(dev, tmp, bar, location);
-}
-
-static inline void gasket_read_modify_write_32(struct gasket_dev *dev, int bar,
-                                              ulong location, u32 value,
-                                              u32 mask_width, u32 mask_shift)
-{
-       u32 mask, tmp;
-
-       tmp = gasket_dev_read_32(dev, bar, location);
-       mask = ((1 << mask_width) - 1) << mask_shift;
-       tmp = (tmp & ~mask) | (value << mask_shift);
-       gasket_dev_write_32(dev, tmp, bar, location);
-}
-
-/* Get the Gasket driver structure for a given device. */
-const struct gasket_driver_desc *gasket_get_driver_desc(struct gasket_dev *dev);
-
-/* Get the device structure for a given device. */
-struct device *gasket_get_device(struct gasket_dev *dev);
-
-/* Helper function, Asynchronous waits on a given set of bits. */
-int gasket_wait_with_reschedule(struct gasket_dev *gasket_dev, int bar,
-                               u64 offset, u64 mask, u64 val,
-                               uint max_retries, u64 delay_ms);
-
-#endif /* __GASKET_CORE_H__ */
diff --git a/drivers/staging/gasket/gasket_interrupt.c b/drivers/staging/gasket/gasket_interrupt.c
deleted file mode 100644 (file)
index 864342a..0000000
+++ /dev/null
@@ -1,515 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright (C) 2018 Google, Inc. */
-
-#include "gasket_interrupt.h"
-
-#include "gasket_constants.h"
-#include "gasket_core.h"
-#include "gasket_sysfs.h"
-#include <linux/device.h>
-#include <linux/interrupt.h>
-#include <linux/printk.h>
-#ifdef GASKET_KERNEL_TRACE_SUPPORT
-#define CREATE_TRACE_POINTS
-#include <trace/events/gasket_interrupt.h>
-#else
-#define trace_gasket_interrupt_event(x, ...)
-#endif
-/* Retry attempts if the requested number of interrupts aren't available. */
-#define MSIX_RETRY_COUNT 3
-
-/* Instance interrupt management data. */
-struct gasket_interrupt_data {
-       /* The name associated with this interrupt data. */
-       const char *name;
-
-       /* Interrupt type. See gasket_interrupt_type in gasket_core.h */
-       int type;
-
-       /* The PCI device [if any] associated with the owning device. */
-       struct pci_dev *pci_dev;
-
-       /* Set to 1 if MSI-X has successfully been configred, 0 otherwise. */
-       int msix_configured;
-
-       /* The number of interrupts requested by the owning device. */
-       int num_interrupts;
-
-       /* A pointer to the interrupt descriptor struct for this device. */
-       const struct gasket_interrupt_desc *interrupts;
-
-       /* The index of the bar into which interrupts should be mapped. */
-       int interrupt_bar_index;
-
-       /* The width of a single interrupt in a packed interrupt register. */
-       int pack_width;
-
-       /*
-        * Design-wise, these elements should be bundled together, but
-        * pci_enable_msix's interface requires that they be managed
-        * individually (requires array of struct msix_entry).
-        */
-
-       /* The number of successfully configured interrupts. */
-       int num_configured;
-
-       /* The MSI-X data for each requested/configured interrupt. */
-       struct msix_entry *msix_entries;
-
-       /* The eventfd "callback" data for each interrupt. */
-       struct eventfd_ctx **eventfd_ctxs;
-
-       /* The number of times each interrupt has been called. */
-       ulong *interrupt_counts;
-
-       /* Linux IRQ number. */
-       int irq;
-};
-
-/* Structures to display interrupt counts in sysfs. */
-enum interrupt_sysfs_attribute_type {
-       ATTR_INTERRUPT_COUNTS,
-};
-
-/* Set up device registers for interrupt handling. */
-static void gasket_interrupt_setup(struct gasket_dev *gasket_dev)
-{
-       int i;
-       int pack_shift;
-       ulong mask;
-       ulong value;
-       struct gasket_interrupt_data *interrupt_data =
-               gasket_dev->interrupt_data;
-
-       if (!interrupt_data) {
-               dev_dbg(gasket_dev->dev, "Interrupt data is not initialized\n");
-               return;
-       }
-
-       dev_dbg(gasket_dev->dev, "Running interrupt setup\n");
-
-       /* Setup the MSIX table. */
-
-       for (i = 0; i < interrupt_data->num_interrupts; i++) {
-               /*
-                * If the interrupt is not packed, we can write the index into
-                * the register directly. If not, we need to deal with a read-
-                * modify-write and shift based on the packing index.
-                */
-               dev_dbg(gasket_dev->dev,
-                       "Setting up interrupt index %d with index 0x%llx and packing %d\n",
-                       interrupt_data->interrupts[i].index,
-                       interrupt_data->interrupts[i].reg,
-                       interrupt_data->interrupts[i].packing);
-               if (interrupt_data->interrupts[i].packing == UNPACKED) {
-                       value = interrupt_data->interrupts[i].index;
-               } else {
-                       switch (interrupt_data->interrupts[i].packing) {
-                       case PACK_0:
-                               pack_shift = 0;
-                               break;
-                       case PACK_1:
-                               pack_shift = interrupt_data->pack_width;
-                               break;
-                       case PACK_2:
-                               pack_shift = 2 * interrupt_data->pack_width;
-                               break;
-                       case PACK_3:
-                               pack_shift = 3 * interrupt_data->pack_width;
-                               break;
-                       default:
-                               dev_dbg(gasket_dev->dev,
-                                       "Found interrupt description with unknown enum %d\n",
-                                       interrupt_data->interrupts[i].packing);
-                               return;
-                       }
-
-                       mask = ~(0xFFFF << pack_shift);
-                       value = gasket_dev_read_64(gasket_dev,
-                                                  interrupt_data->interrupt_bar_index,
-                                                  interrupt_data->interrupts[i].reg);
-                       value &= mask;
-                       value |= interrupt_data->interrupts[i].index
-                                << pack_shift;
-               }
-               gasket_dev_write_64(gasket_dev, value,
-                                   interrupt_data->interrupt_bar_index,
-                                   interrupt_data->interrupts[i].reg);
-       }
-}
-
-static void
-gasket_handle_interrupt(struct gasket_interrupt_data *interrupt_data,
-                       int interrupt_index)
-{
-       struct eventfd_ctx *ctx;
-
-       trace_gasket_interrupt_event(interrupt_data->name, interrupt_index);
-       ctx = interrupt_data->eventfd_ctxs[interrupt_index];
-       if (ctx)
-               eventfd_signal(ctx, 1);
-
-       ++(interrupt_data->interrupt_counts[interrupt_index]);
-}
-
-static irqreturn_t gasket_msix_interrupt_handler(int irq, void *dev_id)
-{
-       struct gasket_interrupt_data *interrupt_data = dev_id;
-       int interrupt = -1;
-       int i;
-
-       /* If this linear lookup is a problem, we can maintain a map/hash. */
-       for (i = 0; i < interrupt_data->num_interrupts; i++) {
-               if (interrupt_data->msix_entries[i].vector == irq) {
-                       interrupt = interrupt_data->msix_entries[i].entry;
-                       break;
-               }
-       }
-       if (interrupt == -1) {
-               pr_err("Received unknown irq %d\n", irq);
-               return IRQ_HANDLED;
-       }
-       gasket_handle_interrupt(interrupt_data, interrupt);
-       return IRQ_HANDLED;
-}
-
-static int
-gasket_interrupt_msix_init(struct gasket_interrupt_data *interrupt_data)
-{
-       int ret = 1;
-       int i;
-
-       interrupt_data->msix_entries =
-               kcalloc(interrupt_data->num_interrupts,
-                       sizeof(*interrupt_data->msix_entries), GFP_KERNEL);
-       if (!interrupt_data->msix_entries)
-               return -ENOMEM;
-
-       for (i = 0; i < interrupt_data->num_interrupts; i++) {
-               interrupt_data->msix_entries[i].entry = i;
-               interrupt_data->msix_entries[i].vector = 0;
-               interrupt_data->eventfd_ctxs[i] = NULL;
-       }
-
-       /* Retry MSIX_RETRY_COUNT times if not enough IRQs are available. */
-       for (i = 0; i < MSIX_RETRY_COUNT && ret > 0; i++)
-               ret = pci_enable_msix_exact(interrupt_data->pci_dev,
-                                           interrupt_data->msix_entries,
-                                           interrupt_data->num_interrupts);
-
-       if (ret)
-               return ret > 0 ? -EBUSY : ret;
-       interrupt_data->msix_configured = 1;
-
-       for (i = 0; i < interrupt_data->num_interrupts; i++) {
-               ret = request_irq(interrupt_data->msix_entries[i].vector,
-                                 gasket_msix_interrupt_handler, 0,
-                                 interrupt_data->name, interrupt_data);
-
-               if (ret) {
-                       dev_err(&interrupt_data->pci_dev->dev,
-                               "Cannot get IRQ for interrupt %d, vector %d; "
-                               "%d\n",
-                               i, interrupt_data->msix_entries[i].vector, ret);
-                       return ret;
-               }
-
-               interrupt_data->num_configured++;
-       }
-
-       return 0;
-}
-
-/*
- * On QCM DragonBoard, we exit gasket_interrupt_msix_init() and kernel interrupt
- * setup code with MSIX vectors masked. This is wrong because nothing else in
- * the driver will normally touch the MSIX vectors.
- *
- * As a temporary hack, force unmasking there.
- *
- * TODO: Figure out why QCM kernel doesn't unmask the MSIX vectors, after
- * gasket_interrupt_msix_init(), and remove this code.
- */
-static void force_msix_interrupt_unmasking(struct gasket_dev *gasket_dev)
-{
-       int i;
-#define MSIX_VECTOR_SIZE 16
-#define MSIX_MASK_BIT_OFFSET 12
-#define APEX_BAR2_REG_KERNEL_HIB_MSIX_TABLE 0x46800
-       for (i = 0; i < gasket_dev->interrupt_data->num_configured; i++) {
-               /* Check if the MSIX vector is unmasked */
-               ulong location = APEX_BAR2_REG_KERNEL_HIB_MSIX_TABLE +
-                                MSIX_MASK_BIT_OFFSET + i * MSIX_VECTOR_SIZE;
-               u32 mask =
-                       gasket_dev_read_32(gasket_dev,
-                                          gasket_dev->interrupt_data->interrupt_bar_index,
-                                          location);
-               if (!(mask & 1))
-                       continue;
-               /* Unmask the msix vector (clear 32 bits) */
-               gasket_dev_write_32(gasket_dev, 0,
-                                   gasket_dev->interrupt_data->interrupt_bar_index,
-                                   location);
-       }
-#undef MSIX_VECTOR_SIZE
-#undef MSIX_MASK_BIT_OFFSET
-#undef APEX_BAR2_REG_KERNEL_HIB_MSIX_TABLE
-}
-
-static ssize_t interrupt_sysfs_show(struct device *device,
-                                   struct device_attribute *attr, char *buf)
-{
-       int i, ret;
-       ssize_t written = 0, total_written = 0;
-       struct gasket_interrupt_data *interrupt_data;
-       struct gasket_dev *gasket_dev;
-       struct gasket_sysfs_attribute *gasket_attr;
-       enum interrupt_sysfs_attribute_type sysfs_type;
-
-       gasket_dev = gasket_sysfs_get_device_data(device);
-       if (!gasket_dev) {
-               dev_dbg(device, "No sysfs mapping found for device\n");
-               return 0;
-       }
-
-       gasket_attr = gasket_sysfs_get_attr(device, attr);
-       if (!gasket_attr) {
-               dev_dbg(device, "No sysfs attr data found for device\n");
-               gasket_sysfs_put_device_data(device, gasket_dev);
-               return 0;
-       }
-
-       sysfs_type = (enum interrupt_sysfs_attribute_type)
-               gasket_attr->data.attr_type;
-       interrupt_data = gasket_dev->interrupt_data;
-       switch (sysfs_type) {
-       case ATTR_INTERRUPT_COUNTS:
-               for (i = 0; i < interrupt_data->num_interrupts; ++i) {
-                       written =
-                               scnprintf(buf, PAGE_SIZE - total_written,
-                                         "0x%02x: %ld\n", i,
-                                         interrupt_data->interrupt_counts[i]);
-                       total_written += written;
-                       buf += written;
-               }
-               ret = total_written;
-               break;
-       default:
-               dev_dbg(gasket_dev->dev, "Unknown attribute: %s\n",
-                       attr->attr.name);
-               ret = 0;
-               break;
-       }
-
-       gasket_sysfs_put_attr(device, gasket_attr);
-       gasket_sysfs_put_device_data(device, gasket_dev);
-       return ret;
-}
-
-static struct gasket_sysfs_attribute interrupt_sysfs_attrs[] = {
-       GASKET_SYSFS_RO(interrupt_counts, interrupt_sysfs_show,
-                       ATTR_INTERRUPT_COUNTS),
-       GASKET_END_OF_ATTR_ARRAY,
-};
-
-int gasket_interrupt_init(struct gasket_dev *gasket_dev)
-{
-       int ret;
-       struct gasket_interrupt_data *interrupt_data;
-       const struct gasket_driver_desc *driver_desc =
-               gasket_get_driver_desc(gasket_dev);
-
-       interrupt_data = kzalloc(sizeof(*interrupt_data), GFP_KERNEL);
-       if (!interrupt_data)
-               return -ENOMEM;
-       gasket_dev->interrupt_data = interrupt_data;
-       interrupt_data->name = driver_desc->name;
-       interrupt_data->type = driver_desc->interrupt_type;
-       interrupt_data->pci_dev = gasket_dev->pci_dev;
-       interrupt_data->num_interrupts = driver_desc->num_interrupts;
-       interrupt_data->interrupts = driver_desc->interrupts;
-       interrupt_data->interrupt_bar_index = driver_desc->interrupt_bar_index;
-       interrupt_data->pack_width = driver_desc->interrupt_pack_width;
-       interrupt_data->num_configured = 0;
-
-       interrupt_data->eventfd_ctxs =
-               kcalloc(driver_desc->num_interrupts,
-                       sizeof(*interrupt_data->eventfd_ctxs), GFP_KERNEL);
-       if (!interrupt_data->eventfd_ctxs) {
-               kfree(interrupt_data);
-               return -ENOMEM;
-       }
-
-       interrupt_data->interrupt_counts =
-               kcalloc(driver_desc->num_interrupts,
-                       sizeof(*interrupt_data->interrupt_counts), GFP_KERNEL);
-       if (!interrupt_data->interrupt_counts) {
-               kfree(interrupt_data->eventfd_ctxs);
-               kfree(interrupt_data);
-               return -ENOMEM;
-       }
-
-       switch (interrupt_data->type) {
-       case PCI_MSIX:
-               ret = gasket_interrupt_msix_init(interrupt_data);
-               if (ret)
-                       break;
-               force_msix_interrupt_unmasking(gasket_dev);
-               break;
-
-       default:
-               ret = -EINVAL;
-       }
-
-       if (ret) {
-               /* Failing to setup interrupts will cause the device to report
-                * GASKET_STATUS_LAMED. But it is not fatal.
-                */
-               dev_warn(gasket_dev->dev,
-                        "Couldn't initialize interrupts: %d\n", ret);
-               return 0;
-       }
-
-       gasket_interrupt_setup(gasket_dev);
-       gasket_sysfs_create_entries(gasket_dev->dev_info.device,
-                                   interrupt_sysfs_attrs);
-
-       return 0;
-}
-
-static void
-gasket_interrupt_msix_cleanup(struct gasket_interrupt_data *interrupt_data)
-{
-       int i;
-
-       for (i = 0; i < interrupt_data->num_configured; i++)
-               free_irq(interrupt_data->msix_entries[i].vector,
-                        interrupt_data);
-       interrupt_data->num_configured = 0;
-
-       if (interrupt_data->msix_configured)
-               pci_disable_msix(interrupt_data->pci_dev);
-       interrupt_data->msix_configured = 0;
-       kfree(interrupt_data->msix_entries);
-}
-
-int gasket_interrupt_reinit(struct gasket_dev *gasket_dev)
-{
-       int ret;
-
-       if (!gasket_dev->interrupt_data) {
-               dev_dbg(gasket_dev->dev,
-                       "Attempted to reinit uninitialized interrupt data\n");
-               return -EINVAL;
-       }
-
-       switch (gasket_dev->interrupt_data->type) {
-       case PCI_MSIX:
-               gasket_interrupt_msix_cleanup(gasket_dev->interrupt_data);
-               ret = gasket_interrupt_msix_init(gasket_dev->interrupt_data);
-               if (ret)
-                       break;
-               force_msix_interrupt_unmasking(gasket_dev);
-               break;
-
-       default:
-               ret = -EINVAL;
-       }
-
-       if (ret) {
-               /* Failing to setup interrupts will cause the device
-                * to report GASKET_STATUS_LAMED, but is not fatal.
-                */
-               dev_warn(gasket_dev->dev, "Couldn't reinit interrupts: %d\n",
-                        ret);
-               return 0;
-       }
-
-       gasket_interrupt_setup(gasket_dev);
-
-       return 0;
-}
-
-/* See gasket_interrupt.h for description. */
-int gasket_interrupt_reset_counts(struct gasket_dev *gasket_dev)
-{
-       dev_dbg(gasket_dev->dev, "Clearing interrupt counts\n");
-       memset(gasket_dev->interrupt_data->interrupt_counts, 0,
-              gasket_dev->interrupt_data->num_interrupts *
-                       sizeof(*gasket_dev->interrupt_data->interrupt_counts));
-       return 0;
-}
-
-/* See gasket_interrupt.h for description. */
-void gasket_interrupt_cleanup(struct gasket_dev *gasket_dev)
-{
-       struct gasket_interrupt_data *interrupt_data =
-               gasket_dev->interrupt_data;
-       /*
-        * It is possible to get an error code from gasket_interrupt_init
-        * before interrupt_data has been allocated, so check it.
-        */
-       if (!interrupt_data)
-               return;
-
-       switch (interrupt_data->type) {
-       case PCI_MSIX:
-               gasket_interrupt_msix_cleanup(interrupt_data);
-               break;
-
-       default:
-               break;
-       }
-
-       kfree(interrupt_data->interrupt_counts);
-       kfree(interrupt_data->eventfd_ctxs);
-       kfree(interrupt_data);
-       gasket_dev->interrupt_data = NULL;
-}
-
-int gasket_interrupt_system_status(struct gasket_dev *gasket_dev)
-{
-       if (!gasket_dev->interrupt_data) {
-               dev_dbg(gasket_dev->dev, "Interrupt data is null\n");
-               return GASKET_STATUS_DEAD;
-       }
-
-       if (gasket_dev->interrupt_data->num_configured !=
-               gasket_dev->interrupt_data->num_interrupts) {
-               dev_dbg(gasket_dev->dev,
-                       "Not all interrupts were configured\n");
-               return GASKET_STATUS_LAMED;
-       }
-
-       return GASKET_STATUS_ALIVE;
-}
-
-int gasket_interrupt_set_eventfd(struct gasket_interrupt_data *interrupt_data,
-                                int interrupt, int event_fd)
-{
-       struct eventfd_ctx *ctx;
-
-       if (interrupt < 0 || interrupt >= interrupt_data->num_interrupts)
-               return -EINVAL;
-
-       ctx = eventfd_ctx_fdget(event_fd);
-
-       if (IS_ERR(ctx))
-               return PTR_ERR(ctx);
-
-       interrupt_data->eventfd_ctxs[interrupt] = ctx;
-       return 0;
-}
-
-int gasket_interrupt_clear_eventfd(struct gasket_interrupt_data *interrupt_data,
-                                  int interrupt)
-{
-       if (interrupt < 0 || interrupt >= interrupt_data->num_interrupts)
-               return -EINVAL;
-
-       if (interrupt_data->eventfd_ctxs[interrupt]) {
-               eventfd_ctx_put(interrupt_data->eventfd_ctxs[interrupt]);
-               interrupt_data->eventfd_ctxs[interrupt] = NULL;
-       }
-       return 0;
-}
diff --git a/drivers/staging/gasket/gasket_interrupt.h b/drivers/staging/gasket/gasket_interrupt.h
deleted file mode 100644 (file)
index 85526a1..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Gasket common interrupt module. Defines functions for enabling
- * eventfd-triggered interrupts between a Gasket device and a host process.
- *
- * Copyright (C) 2018 Google, Inc.
- */
-#ifndef __GASKET_INTERRUPT_H__
-#define __GASKET_INTERRUPT_H__
-
-#include <linux/eventfd.h>
-#include <linux/pci.h>
-
-#include "gasket_core.h"
-
-/* Note that this currently assumes that device interrupts are a dense set,
- * numbered from 0 - (num_interrupts - 1). Should this have to change, these
- * APIs will have to be updated.
- */
-
-/* Opaque type used to hold interrupt subsystem data. */
-struct gasket_interrupt_data;
-
-/*
- * Initialize the interrupt module.
- * @gasket_dev: The Gasket device structure for the device to be initted.
- */
-int gasket_interrupt_init(struct gasket_dev *gasket_dev);
-
-/*
- * Clean up a device's interrupt structure.
- * @gasket_dev: The Gasket information structure for this device.
- *
- * Cleans up the device's interrupts and deallocates data.
- */
-void gasket_interrupt_cleanup(struct gasket_dev *gasket_dev);
-
-/*
- * Clean up and re-initialize the MSI-x subsystem.
- * @gasket_dev: The Gasket information structure for this device.
- *
- * Performs a teardown of the MSI-x subsystem and re-initializes it. Does not
- * free the underlying data structures. Returns 0 on success and an error code
- * on error.
- */
-int gasket_interrupt_reinit(struct gasket_dev *gasket_dev);
-
-/*
- * Reset the counts stored in the interrupt subsystem.
- * @gasket_dev: The Gasket information structure for this device.
- *
- * Sets the counts of all interrupts in the subsystem to 0.
- */
-int gasket_interrupt_reset_counts(struct gasket_dev *gasket_dev);
-
-/*
- * Associates an eventfd with a device interrupt.
- * @data: Pointer to device interrupt data.
- * @interrupt: The device interrupt to configure.
- * @event_fd: The eventfd to associate with the interrupt.
- *
- * Prepares the host to receive notification of device interrupts by associating
- * event_fd with interrupt. Upon receipt of a device interrupt, event_fd will be
- * signaled, after successful configuration.
- *
- * Returns 0 on success, a negative error code otherwise.
- */
-int gasket_interrupt_set_eventfd(struct gasket_interrupt_data *interrupt_data,
-                                int interrupt, int event_fd);
-
-/*
- * Removes an interrupt-eventfd association.
- * @data: Pointer to device interrupt data.
- * @interrupt: The device interrupt to de-associate.
- *
- * Removes any eventfd associated with the specified interrupt, if any.
- */
-int gasket_interrupt_clear_eventfd(struct gasket_interrupt_data *interrupt_data,
-                                  int interrupt);
-
-/*
- * The below functions exist for backwards compatibility.
- * No new uses should be written.
- */
-/*
- * Get the health of the interrupt subsystem.
- * @gasket_dev: The Gasket device struct.
- *
- * Returns DEAD if not set up, LAMED if initialization failed, and ALIVE
- * otherwise.
- */
-
-int gasket_interrupt_system_status(struct gasket_dev *gasket_dev);
-
-#endif
diff --git a/drivers/staging/gasket/gasket_ioctl.c b/drivers/staging/gasket/gasket_ioctl.c
deleted file mode 100644 (file)
index aa65f4f..0000000
+++ /dev/null
@@ -1,388 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright (C) 2018 Google, Inc. */
-#include "gasket.h"
-#include "gasket_ioctl.h"
-#include "gasket_constants.h"
-#include "gasket_core.h"
-#include "gasket_interrupt.h"
-#include "gasket_page_table.h"
-#include <linux/compiler.h>
-#include <linux/device.h>
-#include <linux/fs.h>
-#include <linux/uaccess.h>
-
-#ifdef GASKET_KERNEL_TRACE_SUPPORT
-#define CREATE_TRACE_POINTS
-#include <trace/events/gasket_ioctl.h>
-#else
-#define trace_gasket_ioctl_entry(x, ...)
-#define trace_gasket_ioctl_exit(x)
-#define trace_gasket_ioctl_integer_data(x)
-#define trace_gasket_ioctl_eventfd_data(x, ...)
-#define trace_gasket_ioctl_page_table_data(x, ...)
-#define trace_gasket_ioctl_config_coherent_allocator(x, ...)
-#endif
-
-/* Associate an eventfd with an interrupt. */
-static int gasket_set_event_fd(struct gasket_dev *gasket_dev,
-                              struct gasket_interrupt_eventfd __user *argp)
-{
-       struct gasket_interrupt_eventfd die;
-
-       if (copy_from_user(&die, argp, sizeof(struct gasket_interrupt_eventfd)))
-               return -EFAULT;
-
-       trace_gasket_ioctl_eventfd_data(die.interrupt, die.event_fd);
-
-       return gasket_interrupt_set_eventfd(gasket_dev->interrupt_data,
-                                           die.interrupt, die.event_fd);
-}
-
-/* Read the size of the page table. */
-static int gasket_read_page_table_size(struct gasket_dev *gasket_dev,
-                                      struct gasket_page_table_ioctl __user *argp)
-{
-       int ret = 0;
-       struct gasket_page_table_ioctl ibuf;
-       struct gasket_page_table *table;
-
-       if (copy_from_user(&ibuf, argp, sizeof(struct gasket_page_table_ioctl)))
-               return -EFAULT;
-
-       if (ibuf.page_table_index >= gasket_dev->num_page_tables)
-               return -EFAULT;
-
-       table = gasket_dev->page_table[ibuf.page_table_index];
-       ibuf.size = gasket_page_table_num_entries(table);
-
-       trace_gasket_ioctl_page_table_data(ibuf.page_table_index, ibuf.size,
-                                          ibuf.host_address,
-                                          ibuf.device_address);
-
-       if (copy_to_user(argp, &ibuf, sizeof(ibuf)))
-               return -EFAULT;
-
-       return ret;
-}
-
-/* Read the size of the simple page table. */
-static int gasket_read_simple_page_table_size(struct gasket_dev *gasket_dev,
-                                             struct gasket_page_table_ioctl __user *argp)
-{
-       int ret = 0;
-       struct gasket_page_table_ioctl ibuf;
-       struct gasket_page_table *table;
-
-       if (copy_from_user(&ibuf, argp, sizeof(struct gasket_page_table_ioctl)))
-               return -EFAULT;
-
-       if (ibuf.page_table_index >= gasket_dev->num_page_tables)
-               return -EFAULT;
-
-       table = gasket_dev->page_table[ibuf.page_table_index];
-       ibuf.size = gasket_page_table_num_simple_entries(table);
-
-       trace_gasket_ioctl_page_table_data(ibuf.page_table_index, ibuf.size,
-                                          ibuf.host_address,
-                                          ibuf.device_address);
-
-       if (copy_to_user(argp, &ibuf, sizeof(ibuf)))
-               return -EFAULT;
-
-       return ret;
-}
-
-/* Set the boundary between the simple and extended page tables. */
-static int gasket_partition_page_table(struct gasket_dev *gasket_dev,
-                                      struct gasket_page_table_ioctl __user *argp)
-{
-       int ret;
-       struct gasket_page_table_ioctl ibuf;
-       uint max_page_table_size;
-       struct gasket_page_table *table;
-
-       if (copy_from_user(&ibuf, argp, sizeof(struct gasket_page_table_ioctl)))
-               return -EFAULT;
-
-       trace_gasket_ioctl_page_table_data(ibuf.page_table_index, ibuf.size,
-                                          ibuf.host_address,
-                                          ibuf.device_address);
-
-       if (ibuf.page_table_index >= gasket_dev->num_page_tables)
-               return -EFAULT;
-       table = gasket_dev->page_table[ibuf.page_table_index];
-       max_page_table_size = gasket_page_table_max_size(table);
-
-       if (ibuf.size > max_page_table_size) {
-               dev_dbg(gasket_dev->dev,
-                       "Partition request 0x%llx too large, max is 0x%x\n",
-                       ibuf.size, max_page_table_size);
-               return -EINVAL;
-       }
-
-       mutex_lock(&gasket_dev->mutex);
-
-       ret = gasket_page_table_partition(table, ibuf.size);
-       mutex_unlock(&gasket_dev->mutex);
-
-       return ret;
-}
-
-/* Map a userspace buffer to a device virtual address. */
-static int gasket_map_buffers(struct gasket_dev *gasket_dev,
-                             struct gasket_page_table_ioctl __user *argp)
-{
-       struct gasket_page_table_ioctl ibuf;
-       struct gasket_page_table *table;
-
-       if (copy_from_user(&ibuf, argp, sizeof(struct gasket_page_table_ioctl)))
-               return -EFAULT;
-
-       trace_gasket_ioctl_page_table_data(ibuf.page_table_index, ibuf.size,
-                                          ibuf.host_address,
-                                          ibuf.device_address);
-
-       if (ibuf.page_table_index >= gasket_dev->num_page_tables)
-               return -EFAULT;
-
-       table = gasket_dev->page_table[ibuf.page_table_index];
-       if (gasket_page_table_are_addrs_bad(table, ibuf.host_address,
-                                           ibuf.device_address, ibuf.size))
-               return -EINVAL;
-
-       return gasket_page_table_map(table, ibuf.host_address, ibuf.device_address,
-                                    ibuf.size / PAGE_SIZE);
-}
-
-/* Unmap a userspace buffer from a device virtual address. */
-static int gasket_unmap_buffers(struct gasket_dev *gasket_dev,
-                               struct gasket_page_table_ioctl __user *argp)
-{
-       struct gasket_page_table_ioctl ibuf;
-       struct gasket_page_table *table;
-
-       if (copy_from_user(&ibuf, argp, sizeof(struct gasket_page_table_ioctl)))
-               return -EFAULT;
-
-       trace_gasket_ioctl_page_table_data(ibuf.page_table_index, ibuf.size,
-                                          ibuf.host_address,
-                                          ibuf.device_address);
-
-       if (ibuf.page_table_index >= gasket_dev->num_page_tables)
-               return -EFAULT;
-
-       table = gasket_dev->page_table[ibuf.page_table_index];
-       if (gasket_page_table_is_dev_addr_bad(table, ibuf.device_address, ibuf.size))
-               return -EINVAL;
-
-       gasket_page_table_unmap(table, ibuf.device_address, ibuf.size / PAGE_SIZE);
-
-       return 0;
-}
-
-/*
- * Reserve structures for coherent allocation, and allocate or free the
- * corresponding memory.
- */
-static int gasket_config_coherent_allocator(struct gasket_dev *gasket_dev,
-                                           struct gasket_coherent_alloc_config_ioctl __user *argp)
-{
-       int ret;
-       struct gasket_coherent_alloc_config_ioctl ibuf;
-
-       if (copy_from_user(&ibuf, argp,
-                          sizeof(struct gasket_coherent_alloc_config_ioctl)))
-               return -EFAULT;
-
-       trace_gasket_ioctl_config_coherent_allocator(ibuf.enable, ibuf.size,
-                                                    ibuf.dma_address);
-
-       if (ibuf.page_table_index >= gasket_dev->num_page_tables)
-               return -EFAULT;
-
-       if (ibuf.size > PAGE_SIZE * MAX_NUM_COHERENT_PAGES)
-               return -ENOMEM;
-
-       if (ibuf.enable == 0) {
-               ret = gasket_free_coherent_memory(gasket_dev, ibuf.size,
-                                                 ibuf.dma_address,
-                                                 ibuf.page_table_index);
-       } else {
-               ret = gasket_alloc_coherent_memory(gasket_dev, ibuf.size,
-                                                  &ibuf.dma_address,
-                                                  ibuf.page_table_index);
-       }
-       if (ret)
-               return ret;
-       if (copy_to_user(argp, &ibuf, sizeof(ibuf)))
-               return -EFAULT;
-
-       return 0;
-}
-
-/* Check permissions for Gasket ioctls. */
-static bool gasket_ioctl_check_permissions(struct file *filp, uint cmd)
-{
-       bool alive;
-       bool read, write;
-       struct gasket_dev *gasket_dev = (struct gasket_dev *)filp->private_data;
-
-       alive = (gasket_dev->status == GASKET_STATUS_ALIVE);
-       if (!alive)
-               dev_dbg(gasket_dev->dev, "%s alive %d status %d\n",
-                       __func__, alive, gasket_dev->status);
-
-       read = !!(filp->f_mode & FMODE_READ);
-       write = !!(filp->f_mode & FMODE_WRITE);
-
-       switch (cmd) {
-       case GASKET_IOCTL_RESET:
-       case GASKET_IOCTL_CLEAR_INTERRUPT_COUNTS:
-               return write;
-
-       case GASKET_IOCTL_PAGE_TABLE_SIZE:
-       case GASKET_IOCTL_SIMPLE_PAGE_TABLE_SIZE:
-       case GASKET_IOCTL_NUMBER_PAGE_TABLES:
-               return read;
-
-       case GASKET_IOCTL_PARTITION_PAGE_TABLE:
-       case GASKET_IOCTL_CONFIG_COHERENT_ALLOCATOR:
-               return alive && write;
-
-       case GASKET_IOCTL_MAP_BUFFER:
-       case GASKET_IOCTL_UNMAP_BUFFER:
-               return alive && write;
-
-       case GASKET_IOCTL_CLEAR_EVENTFD:
-       case GASKET_IOCTL_SET_EVENTFD:
-               return alive && write;
-       }
-
-       return false; /* unknown permissions */
-}
-
-/*
- * standard ioctl dispatch function.
- * @filp: File structure pointer describing this node usage session.
- * @cmd: ioctl number to handle.
- * @argp: ioctl-specific data pointer.
- *
- * Standard ioctl dispatcher; forwards operations to individual handlers.
- */
-long gasket_handle_ioctl(struct file *filp, uint cmd, void __user *argp)
-{
-       struct gasket_dev *gasket_dev;
-       unsigned long arg = (unsigned long)argp;
-       gasket_ioctl_permissions_cb_t ioctl_permissions_cb;
-       int retval;
-
-       gasket_dev = (struct gasket_dev *)filp->private_data;
-       trace_gasket_ioctl_entry(gasket_dev->dev_info.name, cmd);
-
-       ioctl_permissions_cb = gasket_get_ioctl_permissions_cb(gasket_dev);
-       if (ioctl_permissions_cb) {
-               retval = ioctl_permissions_cb(filp, cmd, argp);
-               if (retval < 0) {
-                       trace_gasket_ioctl_exit(retval);
-                       return retval;
-               } else if (retval == 0) {
-                       trace_gasket_ioctl_exit(-EPERM);
-                       return -EPERM;
-               }
-       } else if (!gasket_ioctl_check_permissions(filp, cmd)) {
-               trace_gasket_ioctl_exit(-EPERM);
-               dev_dbg(gasket_dev->dev, "ioctl cmd=%x noperm\n", cmd);
-               return -EPERM;
-       }
-
-       /* Tracing happens in this switch statement for all ioctls with
-        * an integer argrument, but ioctls with a struct argument
-        * that needs copying and decoding, that tracing is done within
-        * the handler call.
-        */
-       switch (cmd) {
-       case GASKET_IOCTL_RESET:
-               retval = gasket_reset(gasket_dev);
-               break;
-       case GASKET_IOCTL_SET_EVENTFD:
-               retval = gasket_set_event_fd(gasket_dev, argp);
-               break;
-       case GASKET_IOCTL_CLEAR_EVENTFD:
-               trace_gasket_ioctl_integer_data(arg);
-               retval =
-                       gasket_interrupt_clear_eventfd(gasket_dev->interrupt_data,
-                                                      (int)arg);
-               break;
-       case GASKET_IOCTL_PARTITION_PAGE_TABLE:
-               trace_gasket_ioctl_integer_data(arg);
-               retval = gasket_partition_page_table(gasket_dev, argp);
-               break;
-       case GASKET_IOCTL_NUMBER_PAGE_TABLES:
-               trace_gasket_ioctl_integer_data(gasket_dev->num_page_tables);
-               if (copy_to_user(argp, &gasket_dev->num_page_tables,
-                                sizeof(uint64_t)))
-                       retval = -EFAULT;
-               else
-                       retval = 0;
-               break;
-       case GASKET_IOCTL_PAGE_TABLE_SIZE:
-               retval = gasket_read_page_table_size(gasket_dev, argp);
-               break;
-       case GASKET_IOCTL_SIMPLE_PAGE_TABLE_SIZE:
-               retval = gasket_read_simple_page_table_size(gasket_dev, argp);
-               break;
-       case GASKET_IOCTL_MAP_BUFFER:
-               retval = gasket_map_buffers(gasket_dev, argp);
-               break;
-       case GASKET_IOCTL_CONFIG_COHERENT_ALLOCATOR:
-               retval = gasket_config_coherent_allocator(gasket_dev, argp);
-               break;
-       case GASKET_IOCTL_UNMAP_BUFFER:
-               retval = gasket_unmap_buffers(gasket_dev, argp);
-               break;
-       case GASKET_IOCTL_CLEAR_INTERRUPT_COUNTS:
-               /* Clear interrupt counts doesn't take an arg, so use 0. */
-               trace_gasket_ioctl_integer_data(0);
-               retval = gasket_interrupt_reset_counts(gasket_dev);
-               break;
-       default:
-               /* If we don't understand the ioctl, the best we can do is trace
-                * the arg.
-                */
-               trace_gasket_ioctl_integer_data(arg);
-               dev_dbg(gasket_dev->dev,
-                       "Unknown ioctl cmd=0x%x not caught by gasket_is_supported_ioctl\n",
-                       cmd);
-               retval = -EINVAL;
-               break;
-       }
-
-       trace_gasket_ioctl_exit(retval);
-       return retval;
-}
-
-/*
- * Determines if an ioctl is part of the standard Gasket framework.
- * @cmd: The ioctl number to handle.
- *
- * Returns 1 if the ioctl is supported and 0 otherwise.
- */
-long gasket_is_supported_ioctl(uint cmd)
-{
-       switch (cmd) {
-       case GASKET_IOCTL_RESET:
-       case GASKET_IOCTL_SET_EVENTFD:
-       case GASKET_IOCTL_CLEAR_EVENTFD:
-       case GASKET_IOCTL_PARTITION_PAGE_TABLE:
-       case GASKET_IOCTL_NUMBER_PAGE_TABLES:
-       case GASKET_IOCTL_PAGE_TABLE_SIZE:
-       case GASKET_IOCTL_SIMPLE_PAGE_TABLE_SIZE:
-       case GASKET_IOCTL_MAP_BUFFER:
-       case GASKET_IOCTL_UNMAP_BUFFER:
-       case GASKET_IOCTL_CLEAR_INTERRUPT_COUNTS:
-       case GASKET_IOCTL_CONFIG_COHERENT_ALLOCATOR:
-               return 1;
-       default:
-               return 0;
-       }
-}
diff --git a/drivers/staging/gasket/gasket_ioctl.h b/drivers/staging/gasket/gasket_ioctl.h
deleted file mode 100644 (file)
index 51f468c..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/* Copyright (C) 2018 Google, Inc. */
-#ifndef __GASKET_IOCTL_H__
-#define __GASKET_IOCTL_H__
-
-#include "gasket_core.h"
-
-#include <linux/compiler.h>
-
-/*
- * Handle Gasket common ioctls.
- * @filp: Pointer to the ioctl's file.
- * @cmd: Ioctl command.
- * @arg: Ioctl argument pointer.
- *
- * Returns 0 on success and nonzero on failure.
- */
-long gasket_handle_ioctl(struct file *filp, uint cmd, void __user *argp);
-
-/*
- * Determines if an ioctl is part of the standard Gasket framework.
- * @cmd: The ioctl number to handle.
- *
- * Returns 1 if the ioctl is supported and 0 otherwise.
- */
-long gasket_is_supported_ioctl(uint cmd);
-
-#endif
diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c
deleted file mode 100644 (file)
index 2dbf3d9..0000000
+++ /dev/null
@@ -1,1357 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Implementation of Gasket page table support.
- *
- * Copyright (C) 2018 Google, Inc.
- */
-
-/*
- * Implementation of Gasket page table support.
- *
- * This file assumes 4kB pages throughout; can be factored out when necessary.
- *
- * There is a configurable number of page table entries, as well as a
- * configurable bit index for the extended address flag. Both of these are
- * specified in gasket_page_table_init through the page_table_config parameter.
- *
- * The following example assumes:
- *   page_table_config->total_entries = 8192
- *   page_table_config->extended_bit = 63
- *
- * Address format:
- * Simple addresses - those whose containing pages are directly placed in the
- * device's address translation registers - are laid out as:
- * [ 63 - 25: 0 | 24 - 12: page index | 11 - 0: page offset ]
- * page index:  The index of the containing page in the device's address
- *              translation registers.
- * page offset: The index of the address into the containing page.
- *
- * Extended address - those whose containing pages are contained in a second-
- * level page table whose address is present in the device's address translation
- * registers - are laid out as:
- * [ 63: flag | 62 - 34: 0 | 33 - 21: dev/level 0 index |
- *   20 - 12: host/level 1 index | 11 - 0: page offset ]
- * flag:        Marker indicating that this is an extended address. Always 1.
- * dev index:   The index of the first-level page in the device's extended
- *              address translation registers.
- * host index:  The index of the containing page in the [host-resident] second-
- *              level page table.
- * page offset: The index of the address into the containing [second-level]
- *              page.
- */
-#include "gasket_page_table.h"
-
-#include <linux/device.h>
-#include <linux/file.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/pagemap.h>
-#include <linux/vmalloc.h>
-
-#include "gasket_constants.h"
-#include "gasket_core.h"
-
-/* Constants & utility macros */
-/* The number of pages that can be mapped into each second-level page table. */
-#define GASKET_PAGES_PER_SUBTABLE 512
-
-/* The starting position of the page index in a simple virtual address. */
-#define GASKET_SIMPLE_PAGE_SHIFT 12
-
-/* Flag indicating that a [device] slot is valid for use. */
-#define GASKET_VALID_SLOT_FLAG 1
-
-/*
- * The starting position of the level 0 page index (i.e., the entry in the
- * device's extended address registers) in an extended address.
- * Also can be thought of as (log2(PAGE_SIZE) + log2(PAGES_PER_SUBTABLE)),
- * or (12 + 9).
- */
-#define GASKET_EXTENDED_LVL0_SHIFT 21
-
-/*
- * Number of first level pages that Gasket chips support. Equivalent to
- * log2(NUM_LVL0_PAGE_TABLES)
- *
- * At a maximum, allowing for a 34 bits address space (or 16GB)
- *   = GASKET_EXTENDED_LVL0_WIDTH + (log2(PAGE_SIZE) + log2(PAGES_PER_SUBTABLE)
- * or, = 13 + 9 + 12
- */
-#define GASKET_EXTENDED_LVL0_WIDTH 13
-
-/*
- * The starting position of the level 1 page index (i.e., the entry in the
- * host second-level/sub- table) in an extended address.
- */
-#define GASKET_EXTENDED_LVL1_SHIFT 12
-
-/* Type declarations */
-/* Valid states for a struct gasket_page_table_entry. */
-enum pte_status {
-       PTE_FREE,
-       PTE_INUSE,
-};
-
-/*
- * Mapping metadata for a single page.
- *
- * In this file, host-side page table entries are referred to as that (or PTEs).
- * Where device vs. host entries are differentiated, device-side or -visible
- * entries are called "slots". A slot may be either an entry in the device's
- * address translation table registers or an entry in a second-level page
- * table ("subtable").
- *
- * The full data in this structure is visible on the host [of course]. Only
- * the address contained in dma_addr is communicated to the device; that points
- * to the actual page mapped and described by this structure.
- */
-struct gasket_page_table_entry {
-       /* The status of this entry/slot: free or in use. */
-       enum pte_status status;
-
-       /*
-        * Index for alignment into host vaddrs.
-        * When a user specifies a host address for a mapping, that address may
-        * not be page-aligned. Offset is the index into the containing page of
-        * the host address (i.e., host_vaddr & (PAGE_SIZE - 1)).
-        * This is necessary for translating between user-specified addresses
-        * and page-aligned addresses.
-        */
-       int offset;
-
-       /* Address of the page in DMA space. */
-       dma_addr_t dma_addr;
-
-       /* Linux page descriptor for the page described by this structure. */
-       struct page *page;
-
-       /*
-        * If this is an extended and first-level entry, sublevel points
-        * to the second-level entries underneath this entry.
-        */
-       struct gasket_page_table_entry *sublevel;
-};
-
-/*
- * Maintains virtual to physical address mapping for a coherent page that is
- * allocated by this module for a given device.
- * Note that coherent pages mappings virt mapping cannot be tracked by the
- * Linux kernel, and coherent pages don't have a struct page associated,
- * hence Linux kernel cannot perform a get_user_page_xx() on a phys address
- * that was allocated coherent.
- * This structure trivially implements this mechanism.
- */
-struct gasket_coherent_page_entry {
-       /* Phys address, dma'able by the owner device */
-       dma_addr_t paddr;
-
-       /* Kernel virtual address */
-       u64 user_virt;
-
-       /* User virtual address that was mapped by the mmap kernel subsystem */
-       u64 kernel_virt;
-
-       /*
-        * Whether this page has been mapped into a user land process virtual
-        * space
-        */
-       u32 in_use;
-};
-
-/*
- * [Host-side] page table descriptor.
- *
- * This structure tracks the metadata necessary to manage both simple and
- * extended page tables.
- */
-struct gasket_page_table {
-       /* The config used to create this page table. */
-       struct gasket_page_table_config config;
-
-       /* The number of simple (single-level) entries in the page table. */
-       uint num_simple_entries;
-
-       /* The number of extended (two-level) entries in the page table. */
-       uint num_extended_entries;
-
-       /* Array of [host-side] page table entries. */
-       struct gasket_page_table_entry *entries;
-
-       /* Number of actively mapped kernel pages in this table. */
-       uint num_active_pages;
-
-       /* Device register: base of/first slot in the page table. */
-       u64 __iomem *base_slot;
-
-       /* Device register: holds the offset indicating the start of the
-        * extended address region of the device's address translation table.
-        */
-       u64 __iomem *extended_offset_reg;
-
-       /* Device structure for the underlying device. Only used for logging. */
-       struct device *device;
-
-       /* PCI system descriptor for the underlying device. */
-       struct pci_dev *pci_dev;
-
-       /* Location of the extended address bit for this Gasket device. */
-       u64 extended_flag;
-
-       /* Mutex to protect page table internals. */
-       struct mutex mutex;
-
-       /* Number of coherent pages accessible thru by this page table */
-       int num_coherent_pages;
-
-       /*
-        * List of coherent memory (physical) allocated for a device.
-        *
-        * This structure also remembers the user virtual mapping, this is
-        * hacky, but we need to do this because the kernel doesn't keep track
-        * of the user coherent pages (pfn pages), and virt to coherent page
-        * mapping.
-        * TODO: use find_vma() APIs to convert host address to vm_area, to
-        * dma_addr_t instead of storing user virtu address in
-        * gasket_coherent_page_entry
-        *
-        * Note that the user virtual mapping is created by the driver, in
-        * gasket_mmap function, so user_virt belongs in the driver anyhow.
-        */
-       struct gasket_coherent_page_entry *coherent_pages;
-};
-
-/* See gasket_page_table.h for description. */
-int gasket_page_table_init(struct gasket_page_table **ppg_tbl,
-                          const struct gasket_bar_data *bar_data,
-                          const struct gasket_page_table_config *page_table_config,
-                          struct device *device, struct pci_dev *pci_dev)
-{
-       ulong bytes;
-       struct gasket_page_table *pg_tbl;
-       ulong total_entries = page_table_config->total_entries;
-
-       /*
-        * TODO: Verify config->total_entries against value read from the
-        * hardware register that contains the page table size.
-        */
-       if (total_entries == ULONG_MAX) {
-               dev_dbg(device,
-                       "Error reading page table size. Initializing page table with size 0\n");
-               total_entries = 0;
-       }
-
-       dev_dbg(device,
-               "Attempting to initialize page table of size 0x%lx\n",
-               total_entries);
-
-       dev_dbg(device,
-               "Table has base reg 0x%x, extended offset reg 0x%x\n",
-               page_table_config->base_reg,
-               page_table_config->extended_reg);
-
-       *ppg_tbl = kzalloc(sizeof(**ppg_tbl), GFP_KERNEL);
-       if (!*ppg_tbl) {
-               dev_dbg(device, "No memory for page table\n");
-               return -ENOMEM;
-       }
-
-       pg_tbl = *ppg_tbl;
-       bytes = total_entries * sizeof(struct gasket_page_table_entry);
-       if (bytes != 0) {
-               pg_tbl->entries = vzalloc(bytes);
-               if (!pg_tbl->entries) {
-                       kfree(pg_tbl);
-                       *ppg_tbl = NULL;
-                       return -ENOMEM;
-               }
-       }
-
-       mutex_init(&pg_tbl->mutex);
-       memcpy(&pg_tbl->config, page_table_config, sizeof(*page_table_config));
-       if (pg_tbl->config.mode == GASKET_PAGE_TABLE_MODE_NORMAL ||
-           pg_tbl->config.mode == GASKET_PAGE_TABLE_MODE_SIMPLE) {
-               pg_tbl->num_simple_entries = total_entries;
-               pg_tbl->num_extended_entries = 0;
-               pg_tbl->extended_flag = 1ull << page_table_config->extended_bit;
-       } else {
-               pg_tbl->num_simple_entries = 0;
-               pg_tbl->num_extended_entries = total_entries;
-               pg_tbl->extended_flag = 0;
-       }
-       pg_tbl->num_active_pages = 0;
-       pg_tbl->base_slot =
-               (u64 __iomem *)&bar_data->virt_base[page_table_config->base_reg];
-       pg_tbl->extended_offset_reg =
-               (u64 __iomem *)&bar_data->virt_base[page_table_config->extended_reg];
-       pg_tbl->device = get_device(device);
-       pg_tbl->pci_dev = pci_dev;
-
-       dev_dbg(device, "Page table initialized successfully\n");
-
-       return 0;
-}
-
-/*
- * Check if a range of PTEs is free.
- * The page table mutex must be held by the caller.
- */
-static bool gasket_is_pte_range_free(struct gasket_page_table_entry *ptes,
-                                    uint num_entries)
-{
-       int i;
-
-       for (i = 0; i < num_entries; i++) {
-               if (ptes[i].status != PTE_FREE)
-                       return false;
-       }
-
-       return true;
-}
-
-/*
- * Free a second level page [sub]table.
- * The page table mutex must be held before this call.
- */
-static void gasket_free_extended_subtable(struct gasket_page_table *pg_tbl,
-                                         struct gasket_page_table_entry *pte,
-                                         u64 __iomem *slot)
-{
-       /* Release the page table from the driver */
-       pte->status = PTE_FREE;
-
-       /* Release the page table from the device */
-       writeq(0, slot);
-
-       if (pte->dma_addr)
-               dma_unmap_page(pg_tbl->device, pte->dma_addr, PAGE_SIZE,
-                              DMA_TO_DEVICE);
-
-       vfree(pte->sublevel);
-
-       if (pte->page)
-               free_page((ulong)page_address(pte->page));
-
-       memset(pte, 0, sizeof(struct gasket_page_table_entry));
-}
-
-/*
- * Actually perform collection.
- * The page table mutex must be held by the caller.
- */
-static void
-gasket_page_table_garbage_collect_nolock(struct gasket_page_table *pg_tbl)
-{
-       struct gasket_page_table_entry *pte;
-       u64 __iomem *slot;
-
-       /* XXX FIX ME XXX -- more efficient to keep a usage count */
-       /* rather than scanning the second level page tables */
-
-       for (pte = pg_tbl->entries + pg_tbl->num_simple_entries,
-            slot = pg_tbl->base_slot + pg_tbl->num_simple_entries;
-            pte < pg_tbl->entries + pg_tbl->config.total_entries;
-            pte++, slot++) {
-               if (pte->status == PTE_INUSE) {
-                       if (gasket_is_pte_range_free(pte->sublevel,
-                                                    GASKET_PAGES_PER_SUBTABLE))
-                               gasket_free_extended_subtable(pg_tbl, pte,
-                                                             slot);
-               }
-       }
-}
-
-/* See gasket_page_table.h for description. */
-void gasket_page_table_garbage_collect(struct gasket_page_table *pg_tbl)
-{
-       mutex_lock(&pg_tbl->mutex);
-       gasket_page_table_garbage_collect_nolock(pg_tbl);
-       mutex_unlock(&pg_tbl->mutex);
-}
-
-/* See gasket_page_table.h for description. */
-void gasket_page_table_cleanup(struct gasket_page_table *pg_tbl)
-{
-       /* Deallocate free second-level tables. */
-       gasket_page_table_garbage_collect(pg_tbl);
-
-       /* TODO: Check that all PTEs have been freed? */
-
-       vfree(pg_tbl->entries);
-       pg_tbl->entries = NULL;
-
-       put_device(pg_tbl->device);
-       kfree(pg_tbl);
-}
-
-/* See gasket_page_table.h for description. */
-int gasket_page_table_partition(struct gasket_page_table *pg_tbl,
-                               uint num_simple_entries)
-{
-       int i, start;
-
-       mutex_lock(&pg_tbl->mutex);
-       if (num_simple_entries > pg_tbl->config.total_entries) {
-               mutex_unlock(&pg_tbl->mutex);
-               return -EINVAL;
-       }
-
-       gasket_page_table_garbage_collect_nolock(pg_tbl);
-
-       start = min(pg_tbl->num_simple_entries, num_simple_entries);
-
-       for (i = start; i < pg_tbl->config.total_entries; i++) {
-               if (pg_tbl->entries[i].status != PTE_FREE) {
-                       dev_err(pg_tbl->device, "entry %d is not free\n", i);
-                       mutex_unlock(&pg_tbl->mutex);
-                       return -EBUSY;
-               }
-       }
-
-       pg_tbl->num_simple_entries = num_simple_entries;
-       pg_tbl->num_extended_entries =
-               pg_tbl->config.total_entries - num_simple_entries;
-       writeq(num_simple_entries, pg_tbl->extended_offset_reg);
-
-       mutex_unlock(&pg_tbl->mutex);
-       return 0;
-}
-EXPORT_SYMBOL(gasket_page_table_partition);
-
-/*
- * Return whether a host buffer was mapped as coherent memory.
- *
- * A Gasket page_table currently support one contiguous dma range, mapped to one
- * contiguous virtual memory range. Check if the host_addr is within that range.
- */
-static int is_coherent(struct gasket_page_table *pg_tbl, ulong host_addr)
-{
-       u64 min, max;
-
-       /* whether the host address is within user virt range */
-       if (!pg_tbl->coherent_pages)
-               return 0;
-
-       min = (u64)pg_tbl->coherent_pages[0].user_virt;
-       max = min + PAGE_SIZE * pg_tbl->num_coherent_pages;
-
-       return min <= host_addr && host_addr < max;
-}
-
-/* Safely return a page to the OS. */
-static bool gasket_release_page(struct page *page)
-{
-       if (!page)
-               return false;
-
-       if (!PageReserved(page))
-               SetPageDirty(page);
-       unpin_user_page(page);
-
-       return true;
-}
-
-/*
- * Get and map last level page table buffers.
- *
- * slots is the location(s) to write device-mapped page address. If this is a
- * simple mapping, these will be address translation registers. If this is
- * an extended mapping, these will be within a second-level page table
- * allocated by the host and so must have their __iomem attribute casted away.
- */
-static int gasket_perform_mapping(struct gasket_page_table *pg_tbl,
-                                 struct gasket_page_table_entry *ptes,
-                                 u64 __iomem *slots, ulong host_addr,
-                                 uint num_pages, int is_simple_mapping)
-{
-       int ret;
-       ulong offset;
-       struct page *page;
-       dma_addr_t dma_addr;
-       ulong page_addr;
-       int i;
-
-       for (i = 0; i < num_pages; i++) {
-               page_addr = host_addr + i * PAGE_SIZE;
-               offset = page_addr & (PAGE_SIZE - 1);
-               if (is_coherent(pg_tbl, host_addr)) {
-                       u64 off =
-                               (u64)host_addr -
-                               (u64)pg_tbl->coherent_pages[0].user_virt;
-                       ptes[i].page = NULL;
-                       ptes[i].offset = offset;
-                       ptes[i].dma_addr = pg_tbl->coherent_pages[0].paddr +
-                                          off + i * PAGE_SIZE;
-               } else {
-                       ret = pin_user_pages_fast(page_addr - offset, 1,
-                                                 FOLL_WRITE, &page);
-
-                       if (ret <= 0) {
-                               dev_err(pg_tbl->device,
-                                       "pin user pages failed for addr=0x%lx, offset=0x%lx [ret=%d]\n",
-                                       page_addr, offset, ret);
-                               return ret ? ret : -ENOMEM;
-                       }
-                       ++pg_tbl->num_active_pages;
-
-                       ptes[i].page = page;
-                       ptes[i].offset = offset;
-
-                       /* Map the page into DMA space. */
-                       ptes[i].dma_addr =
-                               dma_map_page(pg_tbl->device, page, 0, PAGE_SIZE,
-                                            DMA_BIDIRECTIONAL);
-
-                       if (dma_mapping_error(pg_tbl->device,
-                                             ptes[i].dma_addr)) {
-                               if (gasket_release_page(ptes[i].page))
-                                       --pg_tbl->num_active_pages;
-
-                               memset(&ptes[i], 0,
-                                      sizeof(struct gasket_page_table_entry));
-                               return -EINVAL;
-                       }
-               }
-
-               /* Make the DMA-space address available to the device. */
-               dma_addr = (ptes[i].dma_addr + offset) | GASKET_VALID_SLOT_FLAG;
-
-               if (is_simple_mapping) {
-                       writeq(dma_addr, &slots[i]);
-               } else {
-                       ((u64 __force *)slots)[i] = dma_addr;
-                       /* Extended page table vectors are in DRAM,
-                        * and so need to be synced each time they are updated.
-                        */
-                       dma_map_single(pg_tbl->device,
-                                      (void *)&((u64 __force *)slots)[i],
-                                      sizeof(u64), DMA_TO_DEVICE);
-               }
-               ptes[i].status = PTE_INUSE;
-       }
-       return 0;
-}
-
-/*
- * Return the index of the page for the address in the simple table.
- * Does not perform validity checking.
- */
-static int gasket_simple_page_idx(struct gasket_page_table *pg_tbl,
-                                 ulong dev_addr)
-{
-       return (dev_addr >> GASKET_SIMPLE_PAGE_SHIFT) &
-               (pg_tbl->config.total_entries - 1);
-}
-
-/*
- * Return the level 0 page index for the given address.
- * Does not perform validity checking.
- */
-static ulong gasket_extended_lvl0_page_idx(struct gasket_page_table *pg_tbl,
-                                          ulong dev_addr)
-{
-       return (dev_addr >> GASKET_EXTENDED_LVL0_SHIFT) &
-               (pg_tbl->config.total_entries - 1);
-}
-
-/*
- * Return the level 1 page index for the given address.
- * Does not perform validity checking.
- */
-static ulong gasket_extended_lvl1_page_idx(struct gasket_page_table *pg_tbl,
-                                          ulong dev_addr)
-{
-       return (dev_addr >> GASKET_EXTENDED_LVL1_SHIFT) &
-              (GASKET_PAGES_PER_SUBTABLE - 1);
-}
-
-/*
- * Allocate page table entries in a simple table.
- * The page table mutex must be held by the caller.
- */
-static int gasket_alloc_simple_entries(struct gasket_page_table *pg_tbl,
-                                      ulong dev_addr, uint num_pages)
-{
-       if (!gasket_is_pte_range_free(pg_tbl->entries +
-                                     gasket_simple_page_idx(pg_tbl, dev_addr),
-                                     num_pages))
-               return -EBUSY;
-
-       return 0;
-}
-
-/*
- * Unmap and release mapped pages.
- * The page table mutex must be held by the caller.
- */
-static void gasket_perform_unmapping(struct gasket_page_table *pg_tbl,
-                                    struct gasket_page_table_entry *ptes,
-                                    u64 __iomem *slots, uint num_pages,
-                                    int is_simple_mapping)
-{
-       int i;
-       /*
-        * For each page table entry and corresponding entry in the device's
-        * address translation table:
-        */
-       for (i = 0; i < num_pages; i++) {
-               /* release the address from the device, */
-               if (is_simple_mapping || ptes[i].status == PTE_INUSE) {
-                       writeq(0, &slots[i]);
-               } else {
-                       ((u64 __force *)slots)[i] = 0;
-                       /* sync above PTE update before updating mappings */
-                       wmb();
-               }
-
-               /* release the address from the driver, */
-               if (ptes[i].status == PTE_INUSE) {
-                       if (ptes[i].page && ptes[i].dma_addr) {
-                               dma_unmap_page(pg_tbl->device, ptes[i].dma_addr,
-                                              PAGE_SIZE, DMA_BIDIRECTIONAL);
-                       }
-                       if (gasket_release_page(ptes[i].page))
-                               --pg_tbl->num_active_pages;
-               }
-
-               /* and clear the PTE. */
-               memset(&ptes[i], 0, sizeof(struct gasket_page_table_entry));
-       }
-}
-
-/*
- * Unmap and release pages mapped to simple addresses.
- * The page table mutex must be held by the caller.
- */
-static void gasket_unmap_simple_pages(struct gasket_page_table *pg_tbl,
-                                     ulong dev_addr, uint num_pages)
-{
-       uint slot = gasket_simple_page_idx(pg_tbl, dev_addr);
-
-       gasket_perform_unmapping(pg_tbl, pg_tbl->entries + slot,
-                                pg_tbl->base_slot + slot, num_pages, 1);
-}
-
-/*
- * Unmap and release buffers to extended addresses.
- * The page table mutex must be held by the caller.
- */
-static void gasket_unmap_extended_pages(struct gasket_page_table *pg_tbl,
-                                       ulong dev_addr, uint num_pages)
-{
-       uint slot_idx, remain, len;
-       struct gasket_page_table_entry *pte;
-       u64 __iomem *slot_base;
-
-       remain = num_pages;
-       slot_idx = gasket_extended_lvl1_page_idx(pg_tbl, dev_addr);
-       pte = pg_tbl->entries + pg_tbl->num_simple_entries +
-             gasket_extended_lvl0_page_idx(pg_tbl, dev_addr);
-
-       while (remain > 0) {
-               /* TODO: Add check to ensure pte remains valid? */
-               len = min(remain, GASKET_PAGES_PER_SUBTABLE - slot_idx);
-
-               if (pte->status == PTE_INUSE) {
-                       slot_base = (u64 __iomem *)(page_address(pte->page) +
-                                                   pte->offset);
-                       gasket_perform_unmapping(pg_tbl,
-                                                pte->sublevel + slot_idx,
-                                                slot_base + slot_idx, len, 0);
-               }
-
-               remain -= len;
-               slot_idx = 0;
-               pte++;
-       }
-}
-
-/* Evaluates to nonzero if the specified virtual address is simple. */
-static inline bool gasket_addr_is_simple(struct gasket_page_table *pg_tbl,
-                                        ulong addr)
-{
-       return !((addr) & (pg_tbl)->extended_flag);
-}
-
-/*
- * Convert (simple, page, offset) into a device address.
- * Examples:
- * Simple page 0, offset 32:
- *  Input (1, 0, 32), Output 0x20
- * Simple page 1000, offset 511:
- *  Input (1, 1000, 511), Output 0x3E81FF
- * Extended page 0, offset 32:
- *  Input (0, 0, 32), Output 0x8000000020
- * Extended page 1000, offset 511:
- *  Input (0, 1000, 511), Output 0x8003E81FF
- */
-static ulong gasket_components_to_dev_address(struct gasket_page_table *pg_tbl,
-                                             int is_simple, uint page_index,
-                                             uint offset)
-{
-       ulong dev_addr = (page_index << GASKET_SIMPLE_PAGE_SHIFT) | offset;
-
-       return is_simple ? dev_addr : (pg_tbl->extended_flag | dev_addr);
-}
-
-/*
- * Validity checking for simple addresses.
- *
- * Verify that address translation commutes (from address to/from page + offset)
- * and that the requested page range starts and ends within the set of
- * currently-partitioned simple pages.
- */
-static bool gasket_is_simple_dev_addr_bad(struct gasket_page_table *pg_tbl,
-                                         ulong dev_addr, uint num_pages)
-{
-       ulong page_offset = dev_addr & (PAGE_SIZE - 1);
-       ulong page_index =
-               (dev_addr / PAGE_SIZE) & (pg_tbl->config.total_entries - 1);
-
-       if (gasket_components_to_dev_address(pg_tbl, 1, page_index,
-                                            page_offset) != dev_addr) {
-               dev_err(pg_tbl->device, "address is invalid, 0x%lX\n",
-                       dev_addr);
-               return true;
-       }
-
-       if (page_index >= pg_tbl->num_simple_entries) {
-               dev_err(pg_tbl->device,
-                       "starting slot at %lu is too large, max is < %u\n",
-                       page_index, pg_tbl->num_simple_entries);
-               return true;
-       }
-
-       if (page_index + num_pages > pg_tbl->num_simple_entries) {
-               dev_err(pg_tbl->device,
-                       "ending slot at %lu is too large, max is <= %u\n",
-                       page_index + num_pages, pg_tbl->num_simple_entries);
-               return true;
-       }
-
-       return false;
-}
-
-/*
- * Validity checking for extended addresses.
- *
- * Verify that address translation commutes (from address to/from page +
- * offset) and that the requested page range starts and ends within the set of
- * currently-partitioned extended pages.
- */
-static bool gasket_is_extended_dev_addr_bad(struct gasket_page_table *pg_tbl,
-                                           ulong dev_addr, uint num_pages)
-{
-       /* Starting byte index of dev_addr into the first mapped page */
-       ulong page_offset = dev_addr & (PAGE_SIZE - 1);
-       ulong page_global_idx, page_lvl0_idx;
-       ulong num_lvl0_pages;
-       ulong addr;
-
-       /* check if the device address is out of bound */
-       addr = dev_addr & ~((pg_tbl)->extended_flag);
-       if (addr >> (GASKET_EXTENDED_LVL0_WIDTH + GASKET_EXTENDED_LVL0_SHIFT)) {
-               dev_err(pg_tbl->device, "device address out of bounds: 0x%lx\n",
-                       dev_addr);
-               return true;
-       }
-
-       /* Find the starting sub-page index in the space of all sub-pages. */
-       page_global_idx = (dev_addr / PAGE_SIZE) &
-               (pg_tbl->config.total_entries * GASKET_PAGES_PER_SUBTABLE - 1);
-
-       /* Find the starting level 0 index. */
-       page_lvl0_idx = gasket_extended_lvl0_page_idx(pg_tbl, dev_addr);
-
-       /* Get the count of affected level 0 pages. */
-       num_lvl0_pages = DIV_ROUND_UP(num_pages, GASKET_PAGES_PER_SUBTABLE);
-
-       if (gasket_components_to_dev_address(pg_tbl, 0, page_global_idx,
-                                            page_offset) != dev_addr) {
-               dev_err(pg_tbl->device, "address is invalid: 0x%lx\n",
-                       dev_addr);
-               return true;
-       }
-
-       if (page_lvl0_idx >= pg_tbl->num_extended_entries) {
-               dev_err(pg_tbl->device,
-                       "starting level 0 slot at %lu is too large, max is < %u\n",
-                       page_lvl0_idx, pg_tbl->num_extended_entries);
-               return true;
-       }
-
-       if (page_lvl0_idx + num_lvl0_pages > pg_tbl->num_extended_entries) {
-               dev_err(pg_tbl->device,
-                       "ending level 0 slot at %lu is too large, max is <= %u\n",
-                       page_lvl0_idx + num_lvl0_pages,
-                       pg_tbl->num_extended_entries);
-               return true;
-       }
-
-       return false;
-}
-
-/*
- * Non-locking entry to unmapping routines.
- * The page table mutex must be held by the caller.
- */
-static void gasket_page_table_unmap_nolock(struct gasket_page_table *pg_tbl,
-                                          ulong dev_addr, uint num_pages)
-{
-       if (!num_pages)
-               return;
-
-       if (gasket_addr_is_simple(pg_tbl, dev_addr))
-               gasket_unmap_simple_pages(pg_tbl, dev_addr, num_pages);
-       else
-               gasket_unmap_extended_pages(pg_tbl, dev_addr, num_pages);
-}
-
-/*
- * Allocate and map pages to simple addresses.
- * If there is an error, no pages are mapped.
- */
-static int gasket_map_simple_pages(struct gasket_page_table *pg_tbl,
-                                  ulong host_addr, ulong dev_addr,
-                                  uint num_pages)
-{
-       int ret;
-       uint slot_idx = gasket_simple_page_idx(pg_tbl, dev_addr);
-
-       ret = gasket_alloc_simple_entries(pg_tbl, dev_addr, num_pages);
-       if (ret) {
-               dev_err(pg_tbl->device,
-                       "page table slots %u (@ 0x%lx) to %u are not available\n",
-                       slot_idx, dev_addr, slot_idx + num_pages - 1);
-               return ret;
-       }
-
-       ret = gasket_perform_mapping(pg_tbl, pg_tbl->entries + slot_idx,
-                                    pg_tbl->base_slot + slot_idx, host_addr,
-                                    num_pages, 1);
-
-       if (ret) {
-               gasket_page_table_unmap_nolock(pg_tbl, dev_addr, num_pages);
-               dev_err(pg_tbl->device, "gasket_perform_mapping %d\n", ret);
-       }
-       return ret;
-}
-
-/*
- * Allocate a second level page table.
- * The page table mutex must be held by the caller.
- */
-static int gasket_alloc_extended_subtable(struct gasket_page_table *pg_tbl,
-                                         struct gasket_page_table_entry *pte,
-                                         u64 __iomem *slot)
-{
-       ulong page_addr, subtable_bytes;
-       dma_addr_t dma_addr;
-
-       /* XXX FIX ME XXX this is inefficient for non-4K page sizes */
-
-       /* GFP_DMA flag must be passed to architectures for which
-        * part of the memory range is not considered DMA'able.
-        * This seems to be the case for Juno board with 4.5.0 Linaro kernel
-        */
-       page_addr = get_zeroed_page(GFP_KERNEL | GFP_DMA);
-       if (!page_addr)
-               return -ENOMEM;
-       pte->page = virt_to_page((void *)page_addr);
-       pte->offset = 0;
-
-       subtable_bytes = sizeof(struct gasket_page_table_entry) *
-               GASKET_PAGES_PER_SUBTABLE;
-       pte->sublevel = vzalloc(subtable_bytes);
-       if (!pte->sublevel) {
-               free_page(page_addr);
-               memset(pte, 0, sizeof(struct gasket_page_table_entry));
-               return -ENOMEM;
-       }
-
-       /* Map the page into DMA space. */
-       pte->dma_addr = dma_map_page(pg_tbl->device, pte->page, 0, PAGE_SIZE,
-                                    DMA_TO_DEVICE);
-       if (dma_mapping_error(pg_tbl->device, pte->dma_addr)) {
-               free_page(page_addr);
-               vfree(pte->sublevel);
-               memset(pte, 0, sizeof(struct gasket_page_table_entry));
-               return -ENOMEM;
-       }
-
-       /* make the addresses available to the device */
-       dma_addr = (pte->dma_addr + pte->offset) | GASKET_VALID_SLOT_FLAG;
-       writeq(dma_addr, slot);
-
-       pte->status = PTE_INUSE;
-
-       return 0;
-}
-
-/*
- * Allocate slots in an extended page table.  Check to see if a range of page
- * table slots are available. If necessary, memory is allocated for second level
- * page tables.
- *
- * Note that memory for second level page tables is allocated as needed, but
- * that memory is only freed on the final close        of the device file, when the
- * page tables are repartitioned, or the device is removed.  If there is an
- * error or if the full range of slots is not available, any memory
- * allocated for second level page tables remains allocated until final close,
- * repartition, or device removal.
- *
- * The page table mutex must be held by the caller.
- */
-static int gasket_alloc_extended_entries(struct gasket_page_table *pg_tbl,
-                                        ulong dev_addr, uint num_entries)
-{
-       int ret = 0;
-       uint remain, subtable_slot_idx, len;
-       struct gasket_page_table_entry *pte;
-       u64 __iomem *slot;
-
-       remain = num_entries;
-       subtable_slot_idx = gasket_extended_lvl1_page_idx(pg_tbl, dev_addr);
-       pte = pg_tbl->entries + pg_tbl->num_simple_entries +
-             gasket_extended_lvl0_page_idx(pg_tbl, dev_addr);
-       slot = pg_tbl->base_slot + pg_tbl->num_simple_entries +
-              gasket_extended_lvl0_page_idx(pg_tbl, dev_addr);
-
-       while (remain > 0) {
-               len = min(remain,
-                         GASKET_PAGES_PER_SUBTABLE - subtable_slot_idx);
-
-               if (pte->status == PTE_FREE) {
-                       ret = gasket_alloc_extended_subtable(pg_tbl, pte, slot);
-                       if (ret) {
-                               dev_err(pg_tbl->device,
-                                       "no memory for extended addr subtable\n");
-                               return ret;
-                       }
-               } else {
-                       if (!gasket_is_pte_range_free(pte->sublevel +
-                                                     subtable_slot_idx, len))
-                               return -EBUSY;
-               }
-
-               remain -= len;
-               subtable_slot_idx = 0;
-               pte++;
-               slot++;
-       }
-
-       return 0;
-}
-
-/*
- * gasket_map_extended_pages - Get and map buffers to extended addresses.
- * If there is an error, no pages are mapped.
- */
-static int gasket_map_extended_pages(struct gasket_page_table *pg_tbl,
-                                    ulong host_addr, ulong dev_addr,
-                                    uint num_pages)
-{
-       int ret;
-       ulong dev_addr_end;
-       uint slot_idx, remain, len;
-       struct gasket_page_table_entry *pte;
-       u64 __iomem *slot_base;
-
-       ret = gasket_alloc_extended_entries(pg_tbl, dev_addr, num_pages);
-       if (ret) {
-               dev_addr_end = dev_addr + (num_pages / PAGE_SIZE) - 1;
-               dev_err(pg_tbl->device,
-                       "page table slots (%lu,%lu) (@ 0x%lx) to (%lu,%lu) are not available\n",
-                       gasket_extended_lvl0_page_idx(pg_tbl, dev_addr),
-                       dev_addr,
-                       gasket_extended_lvl1_page_idx(pg_tbl, dev_addr),
-                       gasket_extended_lvl0_page_idx(pg_tbl, dev_addr_end),
-                       gasket_extended_lvl1_page_idx(pg_tbl, dev_addr_end));
-               return ret;
-       }
-
-       remain = num_pages;
-       slot_idx = gasket_extended_lvl1_page_idx(pg_tbl, dev_addr);
-       pte = pg_tbl->entries + pg_tbl->num_simple_entries +
-             gasket_extended_lvl0_page_idx(pg_tbl, dev_addr);
-
-       while (remain > 0) {
-               len = min(remain, GASKET_PAGES_PER_SUBTABLE - slot_idx);
-
-               slot_base =
-                       (u64 __iomem *)(page_address(pte->page) + pte->offset);
-               ret = gasket_perform_mapping(pg_tbl, pte->sublevel + slot_idx,
-                                            slot_base + slot_idx, host_addr,
-                                            len, 0);
-               if (ret) {
-                       gasket_page_table_unmap_nolock(pg_tbl, dev_addr,
-                                                      num_pages);
-                       return ret;
-               }
-
-               remain -= len;
-               slot_idx = 0;
-               pte++;
-               host_addr += len * PAGE_SIZE;
-       }
-
-       return 0;
-}
-
-/*
- * See gasket_page_table.h for general description.
- *
- * gasket_page_table_map calls either gasket_map_simple_pages() or
- * gasket_map_extended_pages() to actually perform the mapping.
- *
- * The page table mutex is held for the entire operation.
- */
-int gasket_page_table_map(struct gasket_page_table *pg_tbl, ulong host_addr,
-                         ulong dev_addr, uint num_pages)
-{
-       int ret;
-
-       if (!num_pages)
-               return 0;
-
-       mutex_lock(&pg_tbl->mutex);
-
-       if (gasket_addr_is_simple(pg_tbl, dev_addr)) {
-               ret = gasket_map_simple_pages(pg_tbl, host_addr, dev_addr,
-                                             num_pages);
-       } else {
-               ret = gasket_map_extended_pages(pg_tbl, host_addr, dev_addr,
-                                               num_pages);
-       }
-
-       mutex_unlock(&pg_tbl->mutex);
-       return ret;
-}
-EXPORT_SYMBOL(gasket_page_table_map);
-
-/*
- * See gasket_page_table.h for general description.
- *
- * gasket_page_table_unmap takes the page table lock and calls either
- * gasket_unmap_simple_pages() or gasket_unmap_extended_pages() to
- * actually unmap the pages from device space.
- *
- * The page table mutex is held for the entire operation.
- */
-void gasket_page_table_unmap(struct gasket_page_table *pg_tbl, ulong dev_addr,
-                            uint num_pages)
-{
-       if (!num_pages)
-               return;
-
-       mutex_lock(&pg_tbl->mutex);
-       gasket_page_table_unmap_nolock(pg_tbl, dev_addr, num_pages);
-       mutex_unlock(&pg_tbl->mutex);
-}
-EXPORT_SYMBOL(gasket_page_table_unmap);
-
-static void gasket_page_table_unmap_all_nolock(struct gasket_page_table *pg_tbl)
-{
-       gasket_unmap_simple_pages(pg_tbl,
-                                 gasket_components_to_dev_address(pg_tbl, 1, 0,
-                                                                  0),
-                                 pg_tbl->num_simple_entries);
-       gasket_unmap_extended_pages(pg_tbl,
-                                   gasket_components_to_dev_address(pg_tbl, 0,
-                                                                    0, 0),
-                                   pg_tbl->num_extended_entries *
-                                   GASKET_PAGES_PER_SUBTABLE);
-}
-
-/* See gasket_page_table.h for description. */
-void gasket_page_table_unmap_all(struct gasket_page_table *pg_tbl)
-{
-       mutex_lock(&pg_tbl->mutex);
-       gasket_page_table_unmap_all_nolock(pg_tbl);
-       mutex_unlock(&pg_tbl->mutex);
-}
-EXPORT_SYMBOL(gasket_page_table_unmap_all);
-
-/* See gasket_page_table.h for description. */
-void gasket_page_table_reset(struct gasket_page_table *pg_tbl)
-{
-       mutex_lock(&pg_tbl->mutex);
-       gasket_page_table_unmap_all_nolock(pg_tbl);
-       writeq(pg_tbl->config.total_entries, pg_tbl->extended_offset_reg);
-       mutex_unlock(&pg_tbl->mutex);
-}
-
-/* See gasket_page_table.h for description. */
-int gasket_page_table_lookup_page(struct gasket_page_table *pg_tbl,
-                                 ulong dev_addr, struct page **ppage,
-                                 ulong *poffset)
-{
-       uint page_num;
-       struct gasket_page_table_entry *pte;
-
-       mutex_lock(&pg_tbl->mutex);
-       if (gasket_addr_is_simple(pg_tbl, dev_addr)) {
-               page_num = gasket_simple_page_idx(pg_tbl, dev_addr);
-               if (page_num >= pg_tbl->num_simple_entries)
-                       goto fail;
-
-               pte = pg_tbl->entries + page_num;
-               if (pte->status != PTE_INUSE)
-                       goto fail;
-       } else {
-               /* Find the level 0 entry, */
-               page_num = gasket_extended_lvl0_page_idx(pg_tbl, dev_addr);
-               if (page_num >= pg_tbl->num_extended_entries)
-                       goto fail;
-
-               pte = pg_tbl->entries + pg_tbl->num_simple_entries + page_num;
-               if (pte->status != PTE_INUSE)
-                       goto fail;
-
-               /* and its contained level 1 entry. */
-               page_num = gasket_extended_lvl1_page_idx(pg_tbl, dev_addr);
-               pte = pte->sublevel + page_num;
-               if (pte->status != PTE_INUSE)
-                       goto fail;
-       }
-
-       *ppage = pte->page;
-       *poffset = pte->offset;
-       mutex_unlock(&pg_tbl->mutex);
-       return 0;
-
-fail:
-       *ppage = NULL;
-       *poffset = 0;
-       mutex_unlock(&pg_tbl->mutex);
-       return -EINVAL;
-}
-
-/* See gasket_page_table.h for description. */
-bool gasket_page_table_are_addrs_bad(struct gasket_page_table *pg_tbl,
-                                    ulong host_addr, ulong dev_addr,
-                                    ulong bytes)
-{
-       if (host_addr & (PAGE_SIZE - 1)) {
-               dev_err(pg_tbl->device,
-                       "host mapping address 0x%lx must be page aligned\n",
-                       host_addr);
-               return true;
-       }
-
-       return gasket_page_table_is_dev_addr_bad(pg_tbl, dev_addr, bytes);
-}
-EXPORT_SYMBOL(gasket_page_table_are_addrs_bad);
-
-/* See gasket_page_table.h for description. */
-bool gasket_page_table_is_dev_addr_bad(struct gasket_page_table *pg_tbl,
-                                      ulong dev_addr, ulong bytes)
-{
-       uint num_pages = bytes / PAGE_SIZE;
-
-       if (bytes & (PAGE_SIZE - 1)) {
-               dev_err(pg_tbl->device,
-                       "mapping size 0x%lX must be page aligned\n", bytes);
-               return true;
-       }
-
-       if (num_pages == 0) {
-               dev_err(pg_tbl->device,
-                       "requested mapping is less than one page: %lu / %lu\n",
-                       bytes, PAGE_SIZE);
-               return true;
-       }
-
-       if (gasket_addr_is_simple(pg_tbl, dev_addr))
-               return gasket_is_simple_dev_addr_bad(pg_tbl, dev_addr,
-                                                    num_pages);
-       return gasket_is_extended_dev_addr_bad(pg_tbl, dev_addr, num_pages);
-}
-EXPORT_SYMBOL(gasket_page_table_is_dev_addr_bad);
-
-/* See gasket_page_table.h for description. */
-uint gasket_page_table_max_size(struct gasket_page_table *page_table)
-{
-       if (!page_table)
-               return 0;
-       return page_table->config.total_entries;
-}
-EXPORT_SYMBOL(gasket_page_table_max_size);
-
-/* See gasket_page_table.h for description. */
-uint gasket_page_table_num_entries(struct gasket_page_table *pg_tbl)
-{
-       if (!pg_tbl)
-               return 0;
-       return pg_tbl->num_simple_entries + pg_tbl->num_extended_entries;
-}
-EXPORT_SYMBOL(gasket_page_table_num_entries);
-
-/* See gasket_page_table.h for description. */
-uint gasket_page_table_num_simple_entries(struct gasket_page_table *pg_tbl)
-{
-       if (!pg_tbl)
-               return 0;
-       return pg_tbl->num_simple_entries;
-}
-EXPORT_SYMBOL(gasket_page_table_num_simple_entries);
-
-/* See gasket_page_table.h for description. */
-uint gasket_page_table_num_active_pages(struct gasket_page_table *pg_tbl)
-{
-       if (!pg_tbl)
-               return 0;
-       return pg_tbl->num_active_pages;
-}
-EXPORT_SYMBOL(gasket_page_table_num_active_pages);
-
-/* See gasket_page_table.h */
-int gasket_page_table_system_status(struct gasket_page_table *page_table)
-{
-       if (!page_table)
-               return GASKET_STATUS_LAMED;
-
-       if (gasket_page_table_num_entries(page_table) == 0) {
-               dev_dbg(page_table->device, "Page table size is 0\n");
-               return GASKET_STATUS_LAMED;
-       }
-
-       return GASKET_STATUS_ALIVE;
-}
-
-/* Record the host_addr to coherent dma memory mapping. */
-int gasket_set_user_virt(struct gasket_dev *gasket_dev, u64 size,
-                        dma_addr_t dma_address, ulong vma)
-{
-       int j;
-       struct gasket_page_table *pg_tbl;
-
-       unsigned int num_pages = size / PAGE_SIZE;
-
-       /*
-        * TODO: for future chipset, better handling of the case where multiple
-        * page tables are supported on a given device
-        */
-       pg_tbl = gasket_dev->page_table[0];
-       if (!pg_tbl) {
-               dev_dbg(gasket_dev->dev, "%s: invalid page table index\n",
-                       __func__);
-               return 0;
-       }
-       for (j = 0; j < num_pages; j++) {
-               pg_tbl->coherent_pages[j].user_virt =
-                       (u64)vma + j * PAGE_SIZE;
-       }
-       return 0;
-}
-
-/* Allocate a block of coherent memory. */
-int gasket_alloc_coherent_memory(struct gasket_dev *gasket_dev, u64 size,
-                                dma_addr_t *dma_address, u64 index)
-{
-       dma_addr_t handle;
-       void *mem;
-       int j;
-       unsigned int num_pages = DIV_ROUND_UP(size, PAGE_SIZE);
-       const struct gasket_driver_desc *driver_desc =
-               gasket_get_driver_desc(gasket_dev);
-
-       if (!gasket_dev->page_table[index])
-               return -EFAULT;
-
-       if (num_pages == 0)
-               return -EINVAL;
-
-       mem = dma_alloc_coherent(gasket_get_device(gasket_dev),
-                                num_pages * PAGE_SIZE, &handle, GFP_KERNEL);
-       if (!mem)
-               goto nomem;
-
-       gasket_dev->page_table[index]->num_coherent_pages = num_pages;
-
-       /* allocate the physical memory block */
-       gasket_dev->page_table[index]->coherent_pages =
-               kcalloc(num_pages,
-                       sizeof(*gasket_dev->page_table[index]->coherent_pages),
-                       GFP_KERNEL);
-       if (!gasket_dev->page_table[index]->coherent_pages)
-               goto nomem;
-
-       gasket_dev->coherent_buffer.length_bytes =
-               PAGE_SIZE * (num_pages);
-       gasket_dev->coherent_buffer.phys_base = handle;
-       gasket_dev->coherent_buffer.virt_base = mem;
-
-       *dma_address = driver_desc->coherent_buffer_description.base;
-       for (j = 0; j < num_pages; j++) {
-               gasket_dev->page_table[index]->coherent_pages[j].paddr =
-                       handle + j * PAGE_SIZE;
-               gasket_dev->page_table[index]->coherent_pages[j].kernel_virt =
-                       (u64)mem + j * PAGE_SIZE;
-       }
-
-       return 0;
-
-nomem:
-       if (mem) {
-               dma_free_coherent(gasket_get_device(gasket_dev),
-                                 num_pages * PAGE_SIZE, mem, handle);
-               gasket_dev->coherent_buffer.length_bytes = 0;
-               gasket_dev->coherent_buffer.virt_base = NULL;
-               gasket_dev->coherent_buffer.phys_base = 0;
-       }
-
-       kfree(gasket_dev->page_table[index]->coherent_pages);
-       gasket_dev->page_table[index]->coherent_pages = NULL;
-       gasket_dev->page_table[index]->num_coherent_pages = 0;
-       return -ENOMEM;
-}
-
-/* Free a block of coherent memory. */
-int gasket_free_coherent_memory(struct gasket_dev *gasket_dev, u64 size,
-                               dma_addr_t dma_address, u64 index)
-{
-       const struct gasket_driver_desc *driver_desc;
-
-       if (!gasket_dev->page_table[index])
-               return -EFAULT;
-
-       driver_desc = gasket_get_driver_desc(gasket_dev);
-
-       if (driver_desc->coherent_buffer_description.base != dma_address)
-               return -EADDRNOTAVAIL;
-
-       if (gasket_dev->coherent_buffer.length_bytes) {
-               dma_free_coherent(gasket_get_device(gasket_dev),
-                                 gasket_dev->coherent_buffer.length_bytes,
-                                 gasket_dev->coherent_buffer.virt_base,
-                                 gasket_dev->coherent_buffer.phys_base);
-               gasket_dev->coherent_buffer.length_bytes = 0;
-               gasket_dev->coherent_buffer.virt_base = NULL;
-               gasket_dev->coherent_buffer.phys_base = 0;
-       }
-
-       kfree(gasket_dev->page_table[index]->coherent_pages);
-       gasket_dev->page_table[index]->coherent_pages = NULL;
-       gasket_dev->page_table[index]->num_coherent_pages = 0;
-
-       return 0;
-}
-
-/* Release all coherent memory. */
-void gasket_free_coherent_memory_all(struct gasket_dev *gasket_dev, u64 index)
-{
-       if (!gasket_dev->page_table[index])
-               return;
-
-       if (gasket_dev->coherent_buffer.length_bytes) {
-               dma_free_coherent(gasket_get_device(gasket_dev),
-                                 gasket_dev->coherent_buffer.length_bytes,
-                                 gasket_dev->coherent_buffer.virt_base,
-                                 gasket_dev->coherent_buffer.phys_base);
-               gasket_dev->coherent_buffer.length_bytes = 0;
-               gasket_dev->coherent_buffer.virt_base = NULL;
-               gasket_dev->coherent_buffer.phys_base = 0;
-       }
-}
diff --git a/drivers/staging/gasket/gasket_page_table.h b/drivers/staging/gasket/gasket_page_table.h
deleted file mode 100644 (file)
index 7b01b73..0000000
+++ /dev/null
@@ -1,249 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Gasket Page Table functionality. This file describes the address
- * translation/paging functionality supported by the Gasket driver framework.
- * As much as possible, internal details are hidden to simplify use -
- * all calls are thread-safe (protected by an internal mutex) except where
- * indicated otherwise.
- *
- * Copyright (C) 2018 Google, Inc.
- */
-
-#ifndef __GASKET_PAGE_TABLE_H__
-#define __GASKET_PAGE_TABLE_H__
-
-#include <linux/pci.h>
-#include <linux/types.h>
-
-#include "gasket_constants.h"
-#include "gasket_core.h"
-
-/*
- * Structure used for managing address translation on a device. All details are
- * internal to the implementation.
- */
-struct gasket_page_table;
-
-/*
- * Allocate and init address translation data.
- * @ppage_table: Pointer to Gasket page table pointer. Set by this call.
- * @att_base_reg: [Mapped] pointer to the first entry in the device's address
- *                translation table.
- * @extended_offset_reg: [Mapped] pointer to the device's register containing
- *                       the starting index of the extended translation table.
- * @extended_bit_location: The index of the bit indicating whether an address
- *                         is extended.
- * @total_entries: The total number of entries in the device's address
- *                 translation table.
- * @device: Device structure for the underlying device. Only used for logging.
- * @pci_dev: PCI system descriptor for the underlying device.
- * whether the driver will supply its own.
- *
- * Description: Allocates and initializes data to track address translation -
- * simple and extended page table metadata. Initially, the page table is
- * partitioned such that all addresses are "simple" (single-level lookup).
- * gasket_partition_page_table can be called to change this paritioning.
- *
- * Returns 0 on success, a negative error code otherwise.
- */
-int gasket_page_table_init(struct gasket_page_table **ppg_tbl,
-                          const struct gasket_bar_data *bar_data,
-                          const struct gasket_page_table_config *page_table_config,
-                          struct device *device, struct pci_dev *pci_dev);
-
-/*
- * Deallocate and cleanup page table data.
- * @page_table: Gasket page table pointer.
- *
- * Description: The inverse of gasket_init; frees page_table and its contained
- *              elements.
- *
- *             Because this call destroys the page table, it cannot be
- *             thread-safe (mutex-protected)!
- */
-void gasket_page_table_cleanup(struct gasket_page_table *page_table);
-
-/*
- * Sets the size of the simple page table.
- * @page_table: Gasket page table pointer.
- * @num_simple_entries: Desired size of the simple page table (in entries).
- *
- * Description: gasket_partition_page_table checks to see if the simple page
- *              size can be changed (i.e., if there are no active extended
- *              mappings in the new simple size range), and, if so,
- *              sets the new simple and extended page table sizes.
- *
- *              Returns 0 if successful, or non-zero if the page table entries
- *              are not free.
- */
-int gasket_page_table_partition(struct gasket_page_table *page_table,
-                               uint num_simple_entries);
-
-/*
- * Get and map [host] user space pages into device memory.
- * @page_table: Gasket page table pointer.
- * @host_addr: Starting host virtual memory address of the pages.
- * @dev_addr: Starting device address of the pages.
- * @num_pages: Number of [4kB] pages to map.
- *
- * Description: Maps the "num_pages" pages of host memory pointed to by
- *              host_addr to the address "dev_addr" in device memory.
- *
- *              The caller is responsible for checking the addresses ranges.
- *
- *              Returns 0 if successful or a non-zero error number otherwise.
- *              If there is an error, no pages are mapped.
- */
-int gasket_page_table_map(struct gasket_page_table *page_table, ulong host_addr,
-                         ulong dev_addr, uint num_pages);
-
-/*
- * Un-map host pages from device memory.
- * @page_table: Gasket page table pointer.
- * @dev_addr: Starting device address of the pages to unmap.
- * @num_pages: The number of [4kB] pages to unmap.
- *
- * Description: The inverse of gasket_map_pages. Unmaps pages from the device.
- */
-void gasket_page_table_unmap(struct gasket_page_table *page_table,
-                            ulong dev_addr, uint num_pages);
-
-/*
- * Unmap ALL host pages from device memory.
- * @page_table: Gasket page table pointer.
- */
-void gasket_page_table_unmap_all(struct gasket_page_table *page_table);
-
-/*
- * Unmap all host pages from device memory and reset the table to fully simple
- * addressing.
- * @page_table: Gasket page table pointer.
- */
-void gasket_page_table_reset(struct gasket_page_table *page_table);
-
-/*
- * Reclaims unused page table memory.
- * @page_table: Gasket page table pointer.
- *
- * Description: Examines the page table and frees any currently-unused
- *              allocations. Called internally on gasket_cleanup().
- */
-void gasket_page_table_garbage_collect(struct gasket_page_table *page_table);
-
-/*
- * Retrieve the backing page for a device address.
- * @page_table: Gasket page table pointer.
- * @dev_addr: Gasket device address.
- * @ppage: Pointer to a page pointer for the returned page.
- * @poffset: Pointer to an unsigned long for the returned offset.
- *
- * Description: Interprets the address and looks up the corresponding page
- *              in the page table and the offset in that page.  (We need an
- *              offset because the host page may be larger than the Gasket chip
- *              page it contains.)
- *
- *              Returns 0 if successful, -1 for an error.  The page pointer
- *              and offset are returned through the pointers, if successful.
- */
-int gasket_page_table_lookup_page(struct gasket_page_table *page_table,
-                                 ulong dev_addr, struct page **page,
-                                 ulong *poffset);
-
-/*
- * Checks validity for input addrs and size.
- * @page_table: Gasket page table pointer.
- * @host_addr: Host address to check.
- * @dev_addr: Gasket device address.
- * @bytes: Size of the range to check (in bytes).
- *
- * Description: This call performs a number of checks to verify that the ranges
- * specified by both addresses and the size are valid for mapping pages into
- * device memory.
- *
- * Returns true if the mapping is bad, false otherwise.
- */
-bool gasket_page_table_are_addrs_bad(struct gasket_page_table *page_table,
-                                    ulong host_addr, ulong dev_addr,
-                                    ulong bytes);
-
-/*
- * Checks validity for input dev addr and size.
- * @page_table: Gasket page table pointer.
- * @dev_addr: Gasket device address.
- * @bytes: Size of the range to check (in bytes).
- *
- * Description: This call performs a number of checks to verify that the range
- * specified by the device address and the size is valid for mapping pages into
- * device memory.
- *
- * Returns true if the address is bad, false otherwise.
- */
-bool gasket_page_table_is_dev_addr_bad(struct gasket_page_table *page_table,
-                                      ulong dev_addr, ulong bytes);
-
-/*
- * Gets maximum size for the given page table.
- * @page_table: Gasket page table pointer.
- */
-uint gasket_page_table_max_size(struct gasket_page_table *page_table);
-
-/*
- * Gets the total number of entries in the arg.
- * @page_table: Gasket page table pointer.
- */
-uint gasket_page_table_num_entries(struct gasket_page_table *page_table);
-
-/*
- * Gets the number of simple entries.
- * @page_table: Gasket page table pointer.
- */
-uint gasket_page_table_num_simple_entries(struct gasket_page_table *page_table);
-
-/*
- * Gets the number of actively pinned pages.
- * @page_table: Gasket page table pointer.
- */
-uint gasket_page_table_num_active_pages(struct gasket_page_table *page_table);
-
-/*
- * Get status of page table managed by @page_table.
- * @page_table: Gasket page table pointer.
- */
-int gasket_page_table_system_status(struct gasket_page_table *page_table);
-
-/*
- * Allocate a block of coherent memory.
- * @gasket_dev: Gasket Device.
- * @size: Size of the memory block.
- * @dma_address: Dma address allocated by the kernel.
- * @index: Index of the gasket_page_table within this Gasket device
- *
- * Description: Allocate a contiguous coherent memory block, DMA'ble
- * by this device.
- */
-int gasket_alloc_coherent_memory(struct gasket_dev *gasket_dev, uint64_t size,
-                                dma_addr_t *dma_address, uint64_t index);
-/* Release a block of contiguous coherent memory, in use by a device. */
-int gasket_free_coherent_memory(struct gasket_dev *gasket_dev, uint64_t size,
-                               dma_addr_t dma_address, uint64_t index);
-
-/* Release all coherent memory. */
-void gasket_free_coherent_memory_all(struct gasket_dev *gasket_dev,
-                                    uint64_t index);
-
-/*
- * Records the host_addr to coherent dma memory mapping.
- * @gasket_dev: Gasket Device.
- * @size: Size of the virtual address range to map.
- * @dma_address: Dma address within the coherent memory range.
- * @vma: Virtual address we wish to map to coherent memory.
- *
- * Description: For each page in the virtual address range, record the
- * coherent page mapping.
- *
- * Does not perform validity checking.
- */
-int gasket_set_user_virt(struct gasket_dev *gasket_dev, uint64_t size,
-                        dma_addr_t dma_address, ulong vma);
-
-#endif  /* __GASKET_PAGE_TABLE_H__ */
diff --git a/drivers/staging/gasket/gasket_sysfs.c b/drivers/staging/gasket/gasket_sysfs.c
deleted file mode 100644 (file)
index c5658fd..0000000
+++ /dev/null
@@ -1,398 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright (C) 2018 Google, Inc. */
-#include "gasket_sysfs.h"
-
-#include "gasket_core.h"
-
-#include <linux/device.h>
-#include <linux/printk.h>
-
-/*
- * Pair of kernel device and user-specified pointer. Used in lookups in sysfs
- * "show" functions to return user data.
- */
-
-struct gasket_sysfs_mapping {
-       /*
-        * The device bound to this mapping. If this is NULL, then this mapping
-        * is free.
-        */
-       struct device *device;
-
-       /* The Gasket descriptor for this device. */
-       struct gasket_dev *gasket_dev;
-
-       /* This device's set of sysfs attributes/nodes. */
-       struct gasket_sysfs_attribute *attributes;
-
-       /* The number of live elements in "attributes". */
-       int attribute_count;
-
-       /* Protects structure from simultaneous access. */
-       struct mutex mutex;
-
-       /* Tracks active users of this mapping. */
-       struct kref refcount;
-};
-
-/*
- * Data needed to manage users of this sysfs utility.
- * Currently has a fixed size; if space is a concern, this can be dynamically
- * allocated.
- */
-/*
- * 'Global' (file-scoped) list of mappings between devices and gasket_data
- * pointers. This removes the requirement to have a gasket_sysfs_data
- * handle in all files.
- */
-static struct gasket_sysfs_mapping dev_mappings[GASKET_SYSFS_NUM_MAPPINGS];
-
-/* Callback when a mapping's refcount goes to zero. */
-static void release_entry(struct kref *ref)
-{
-       /* All work is done after the return from kref_put. */
-}
-
-/* Look up mapping information for the given device. */
-static struct gasket_sysfs_mapping *get_mapping(struct device *device)
-{
-       int i;
-
-       for (i = 0; i < GASKET_SYSFS_NUM_MAPPINGS; i++) {
-               mutex_lock(&dev_mappings[i].mutex);
-               if (dev_mappings[i].device == device) {
-                       kref_get(&dev_mappings[i].refcount);
-                       mutex_unlock(&dev_mappings[i].mutex);
-                       return &dev_mappings[i];
-               }
-               mutex_unlock(&dev_mappings[i].mutex);
-       }
-
-       dev_dbg(device, "%s: Mapping to device %s not found\n",
-               __func__, device->kobj.name);
-       return NULL;
-}
-
-/* Put a reference to a mapping. */
-static void put_mapping(struct gasket_sysfs_mapping *mapping)
-{
-       int i;
-       int num_files_to_remove = 0;
-       struct device_attribute *files_to_remove;
-       struct device *device;
-
-       if (!mapping) {
-               pr_debug("%s: Mapping should not be NULL\n", __func__);
-               return;
-       }
-
-       mutex_lock(&mapping->mutex);
-       if (kref_put(&mapping->refcount, release_entry)) {
-               dev_dbg(mapping->device, "Removing Gasket sysfs mapping\n");
-               /*
-                * We can't remove the sysfs nodes in the kref callback, since
-                * device_remove_file() blocks until the node is free.
-                * Readers/writers of sysfs nodes, though, will be blocked on
-                * the mapping mutex, resulting in deadlock. To fix this, the
-                * sysfs nodes are removed outside the lock.
-                */
-               device = mapping->device;
-               num_files_to_remove = mapping->attribute_count;
-               files_to_remove = kcalloc(num_files_to_remove,
-                                         sizeof(*files_to_remove),
-                                         GFP_KERNEL);
-               if (files_to_remove)
-                       for (i = 0; i < num_files_to_remove; i++)
-                               files_to_remove[i] =
-                                   mapping->attributes[i].attr;
-               else
-                       num_files_to_remove = 0;
-
-               kfree(mapping->attributes);
-               mapping->attributes = NULL;
-               mapping->attribute_count = 0;
-               put_device(mapping->device);
-               mapping->device = NULL;
-               mapping->gasket_dev = NULL;
-       }
-       mutex_unlock(&mapping->mutex);
-
-       if (num_files_to_remove != 0) {
-               for (i = 0; i < num_files_to_remove; ++i)
-                       device_remove_file(device, &files_to_remove[i]);
-               kfree(files_to_remove);
-       }
-}
-
-/*
- * Put a reference to a mapping N times.
- *
- * In higher-level resource acquire/release function pairs, the release function
- * will need to release a mapping 2x - once for the refcount taken in the
- * release function itself, and once for the count taken in the acquire call.
- */
-static void put_mapping_n(struct gasket_sysfs_mapping *mapping, int times)
-{
-       int i;
-
-       for (i = 0; i < times; i++)
-               put_mapping(mapping);
-}
-
-void gasket_sysfs_init(void)
-{
-       int i;
-
-       for (i = 0; i < GASKET_SYSFS_NUM_MAPPINGS; i++) {
-               dev_mappings[i].device = NULL;
-               mutex_init(&dev_mappings[i].mutex);
-       }
-}
-
-int gasket_sysfs_create_mapping(struct device *device,
-                               struct gasket_dev *gasket_dev)
-{
-       struct gasket_sysfs_mapping *mapping;
-       int map_idx = -1;
-
-       /*
-        * We need a function-level mutex to protect against the same device
-        * being added [multiple times] simultaneously.
-        */
-       static DEFINE_MUTEX(function_mutex);
-
-       mutex_lock(&function_mutex);
-       dev_dbg(device, "Creating sysfs entries for device\n");
-
-       /* Check that the device we're adding hasn't already been added. */
-       mapping = get_mapping(device);
-       if (mapping) {
-               dev_err(device,
-                       "Attempting to re-initialize sysfs mapping for device\n");
-               put_mapping(mapping);
-               mutex_unlock(&function_mutex);
-               return -EBUSY;
-       }
-
-       /* Find the first empty entry in the array. */
-       for (map_idx = 0; map_idx < GASKET_SYSFS_NUM_MAPPINGS; ++map_idx) {
-               mutex_lock(&dev_mappings[map_idx].mutex);
-               if (!dev_mappings[map_idx].device)
-                       /* Break with the mutex held! */
-                       break;
-               mutex_unlock(&dev_mappings[map_idx].mutex);
-       }
-
-       if (map_idx == GASKET_SYSFS_NUM_MAPPINGS) {
-               dev_err(device, "All mappings have been exhausted\n");
-               mutex_unlock(&function_mutex);
-               return -ENOMEM;
-       }
-
-       dev_dbg(device, "Creating sysfs mapping for device %s\n",
-               device->kobj.name);
-
-       mapping = &dev_mappings[map_idx];
-       mapping->attributes = kcalloc(GASKET_SYSFS_MAX_NODES,
-                                     sizeof(*mapping->attributes),
-                                     GFP_KERNEL);
-       if (!mapping->attributes) {
-               dev_dbg(device, "Unable to allocate sysfs attribute array\n");
-               mutex_unlock(&mapping->mutex);
-               mutex_unlock(&function_mutex);
-               return -ENOMEM;
-       }
-
-       kref_init(&mapping->refcount);
-       mapping->device = get_device(device);
-       mapping->gasket_dev = gasket_dev;
-       mapping->attribute_count = 0;
-       mutex_unlock(&mapping->mutex);
-       mutex_unlock(&function_mutex);
-
-       /* Don't decrement the refcount here! One open count keeps it alive! */
-       return 0;
-}
-
-int gasket_sysfs_create_entries(struct device *device,
-                               const struct gasket_sysfs_attribute *attrs)
-{
-       int i;
-       int ret;
-       struct gasket_sysfs_mapping *mapping = get_mapping(device);
-
-       if (!mapping) {
-               dev_dbg(device,
-                       "Creating entries for device without first initializing mapping\n");
-               return -EINVAL;
-       }
-
-       mutex_lock(&mapping->mutex);
-       for (i = 0; attrs[i].attr.attr.name; i++) {
-               if (mapping->attribute_count == GASKET_SYSFS_MAX_NODES) {
-                       dev_err(device,
-                               "Maximum number of sysfs nodes reached for device\n");
-                       mutex_unlock(&mapping->mutex);
-                       put_mapping(mapping);
-                       return -ENOMEM;
-               }
-
-               ret = device_create_file(device, &attrs[i].attr);
-               if (ret) {
-                       dev_dbg(device, "Unable to create device entries\n");
-                       mutex_unlock(&mapping->mutex);
-                       put_mapping(mapping);
-                       return ret;
-               }
-
-               mapping->attributes[mapping->attribute_count] = attrs[i];
-               ++mapping->attribute_count;
-       }
-
-       mutex_unlock(&mapping->mutex);
-       put_mapping(mapping);
-       return 0;
-}
-EXPORT_SYMBOL(gasket_sysfs_create_entries);
-
-void gasket_sysfs_remove_mapping(struct device *device)
-{
-       struct gasket_sysfs_mapping *mapping = get_mapping(device);
-
-       if (!mapping) {
-               dev_err(device,
-                       "Attempted to remove non-existent sysfs mapping to device\n");
-               return;
-       }
-
-       put_mapping_n(mapping, 2);
-}
-
-struct gasket_dev *gasket_sysfs_get_device_data(struct device *device)
-{
-       struct gasket_sysfs_mapping *mapping = get_mapping(device);
-
-       if (!mapping) {
-               dev_err(device, "device not registered\n");
-               return NULL;
-       }
-
-       return mapping->gasket_dev;
-}
-EXPORT_SYMBOL(gasket_sysfs_get_device_data);
-
-void gasket_sysfs_put_device_data(struct device *device, struct gasket_dev *dev)
-{
-       struct gasket_sysfs_mapping *mapping = get_mapping(device);
-
-       if (!mapping)
-               return;
-
-       /* See comment of put_mapping_n() for why the '2' is necessary. */
-       put_mapping_n(mapping, 2);
-}
-EXPORT_SYMBOL(gasket_sysfs_put_device_data);
-
-struct gasket_sysfs_attribute *
-gasket_sysfs_get_attr(struct device *device, struct device_attribute *attr)
-{
-       int i;
-       int num_attrs;
-       struct gasket_sysfs_mapping *mapping = get_mapping(device);
-       struct gasket_sysfs_attribute *attrs = NULL;
-
-       if (!mapping)
-               return NULL;
-
-       attrs = mapping->attributes;
-       num_attrs = mapping->attribute_count;
-       for (i = 0; i < num_attrs; ++i) {
-               if (!strcmp(attrs[i].attr.attr.name, attr->attr.name))
-                       return &attrs[i];
-       }
-
-       dev_err(device, "Unable to find match for device_attribute %s\n",
-               attr->attr.name);
-       return NULL;
-}
-EXPORT_SYMBOL(gasket_sysfs_get_attr);
-
-void gasket_sysfs_put_attr(struct device *device,
-                          struct gasket_sysfs_attribute *attr)
-{
-       int i;
-       int num_attrs;
-       struct gasket_sysfs_mapping *mapping = get_mapping(device);
-       struct gasket_sysfs_attribute *attrs = NULL;
-
-       if (!mapping)
-               return;
-
-       attrs = mapping->attributes;
-       num_attrs = mapping->attribute_count;
-       for (i = 0; i < num_attrs; ++i) {
-               if (&attrs[i] == attr) {
-                       put_mapping_n(mapping, 2);
-                       return;
-               }
-       }
-
-       dev_err(device, "Unable to put unknown attribute: %s\n",
-               attr->attr.attr.name);
-       put_mapping(mapping);
-}
-EXPORT_SYMBOL(gasket_sysfs_put_attr);
-
-ssize_t gasket_sysfs_register_store(struct device *device,
-                                   struct device_attribute *attr,
-                                   const char *buf, size_t count)
-{
-       ulong parsed_value = 0;
-       struct gasket_sysfs_mapping *mapping;
-       struct gasket_dev *gasket_dev;
-       struct gasket_sysfs_attribute *gasket_attr;
-
-       if (count < 3 || buf[0] != '0' || buf[1] != 'x') {
-               dev_err(device,
-                       "sysfs register write format: \"0x<hex value>\"\n");
-               return -EINVAL;
-       }
-
-       if (kstrtoul(buf, 16, &parsed_value) != 0) {
-               dev_err(device,
-                       "Unable to parse input as 64-bit hex value: %s\n", buf);
-               return -EINVAL;
-       }
-
-       mapping = get_mapping(device);
-       if (!mapping) {
-               dev_err(device, "Device driver may have been removed\n");
-               return 0;
-       }
-
-       gasket_dev = mapping->gasket_dev;
-       if (!gasket_dev) {
-               dev_err(device, "Device driver may have been removed\n");
-               put_mapping(mapping);
-               return 0;
-       }
-
-       gasket_attr = gasket_sysfs_get_attr(device, attr);
-       if (!gasket_attr) {
-               put_mapping(mapping);
-               return count;
-       }
-
-       gasket_dev_write_64(gasket_dev, parsed_value,
-                           gasket_attr->data.bar_address.bar,
-                           gasket_attr->data.bar_address.offset);
-
-       if (gasket_attr->write_callback)
-               gasket_attr->write_callback(gasket_dev, gasket_attr,
-                                           parsed_value);
-
-       gasket_sysfs_put_attr(device, gasket_attr);
-       put_mapping(mapping);
-       return count;
-}
-EXPORT_SYMBOL(gasket_sysfs_register_store);
diff --git a/drivers/staging/gasket/gasket_sysfs.h b/drivers/staging/gasket/gasket_sysfs.h
deleted file mode 100644 (file)
index d5e167d..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Set of common sysfs utilities.
- *
- * Copyright (C) 2018 Google, Inc.
- */
-
-/* The functions described here are a set of utilities to allow each file in the
- * Gasket driver framework to manage their own set of sysfs entries, instead of
- * centralizing all that work in one file.
- *
- * The goal of these utilities is to allow for sysfs entries to be easily
- * created without causing a proliferation of sysfs "show" functions. This
- * requires O(N) string lookups during show function execution, but as reading
- * sysfs entries is rarely performance-critical, this is likely acceptible.
- */
-#ifndef __GASKET_SYSFS_H__
-#define __GASKET_SYSFS_H__
-
-#include "gasket_constants.h"
-#include "gasket_core.h"
-#include <linux/device.h>
-#include <linux/stringify.h>
-#include <linux/sysfs.h>
-
-/* The maximum number of mappings/devices a driver needs to support. */
-#define GASKET_SYSFS_NUM_MAPPINGS (GASKET_FRAMEWORK_DESC_MAX * GASKET_DEV_MAX)
-
-/* The maximum number of sysfs nodes in a directory.
- */
-#define GASKET_SYSFS_MAX_NODES 196
-
-/*
- * Terminator struct for a gasket_sysfs_attr array. Must be at the end of
- * all gasket_sysfs_attribute arrays.
- */
-#define GASKET_END_OF_ATTR_ARRAY                                               \
-       {                                                                      \
-               .attr = __ATTR_NULL,                            \
-               .data.attr_type = 0,                            \
-       }
-
-/*
- * Pairing of sysfs attribute and user data.
- * Used in lookups in sysfs "show" functions to return attribute metadata.
- */
-struct gasket_sysfs_attribute {
-       /* The underlying sysfs device attribute associated with this data. */
-       struct device_attribute attr;
-
-       /* User-specified data to associate with the attribute. */
-       union {
-               struct bar_address_ {
-                       ulong bar;
-                       ulong offset;
-               } bar_address;
-               uint attr_type;
-       } data;
-
-       /*
-        * Function pointer to a callback to be invoked when this attribute is
-        * written (if so configured). The arguments are to the Gasket device
-        * pointer, the enclosing gasket_attr structure, and the value written.
-        * The callback should perform any logging necessary, as errors cannot
-        * be returned from the callback.
-        */
-       void (*write_callback)(struct gasket_dev *dev,
-                              struct gasket_sysfs_attribute *attr,
-                              ulong value);
-};
-
-#define GASKET_SYSFS_RO(_name, _show_function, _attr_type)                     \
-       {                                                                      \
-               .attr = __ATTR(_name, 0444, _show_function, NULL),          \
-               .data.attr_type = _attr_type                                   \
-       }
-
-/* Initializes the Gasket sysfs subsystem.
- *
- * Description: Performs one-time initialization. Must be called before usage
- * at [Gasket] module load time.
- */
-void gasket_sysfs_init(void);
-
-/*
- * Create an entry in mapping_data between a device and a Gasket device.
- * @device: Device struct to map to.
- * @gasket_dev: The dev struct associated with the driver controlling @device.
- *
- * Description: This function maps a gasket_dev* to a device*. This mapping can
- * be used in sysfs_show functions to get a handle to the gasket_dev struct
- * controlling the device node.
- *
- * If this function is not called before gasket_sysfs_create_entries, a warning
- * will be logged.
- */
-int gasket_sysfs_create_mapping(struct device *device,
-                               struct gasket_dev *gasket_dev);
-
-/*
- * Creates bulk entries in sysfs.
- * @device: Kernel device structure.
- * @attrs: List of attributes/sysfs entries to create.
- *
- * Description: Creates each sysfs entry described in "attrs". Can be called
- * multiple times for a given @device. If the gasket_dev specified in
- * gasket_sysfs_create_mapping had a legacy device, the entries will be created
- * for it, as well.
- */
-int gasket_sysfs_create_entries(struct device *device,
-                               const struct gasket_sysfs_attribute *attrs);
-
-/*
- * Removes a device mapping from the global table.
- * @device: Device to unmap.
- *
- * Description: Removes the device->Gasket device mapping from the internal
- * table.
- */
-void gasket_sysfs_remove_mapping(struct device *device);
-
-/*
- * User data lookup based on kernel device structure.
- * @device: Kernel device structure.
- *
- * Description: Returns the user data associated with "device" in a prior call
- * to gasket_sysfs_create_entries. Returns NULL if no mapping can be found.
- * Upon success, this call take a reference to internal sysfs data that must be
- * released with gasket_sysfs_put_device_data. While this reference is held, the
- * underlying device sysfs information/structure will remain valid/will not be
- * deleted.
- */
-struct gasket_dev *gasket_sysfs_get_device_data(struct device *device);
-
-/*
- * Releases a references to internal data.
- * @device: Kernel device structure.
- * @dev: Gasket device descriptor (returned by gasket_sysfs_get_device_data).
- */
-void gasket_sysfs_put_device_data(struct device *device,
-                                 struct gasket_dev *gasket_dev);
-
-/*
- * Gasket-specific attribute lookup.
- * @device: Kernel device structure.
- * @attr: Device attribute to look up.
- *
- * Returns the Gasket sysfs attribute associated with the kernel device
- * attribute and device structure itself. Upon success, this call will take a
- * reference to internal sysfs data that must be released with a call to
- * gasket_sysfs_put_attr. While this reference is held, the underlying device
- * sysfs information/structure will remain valid/will not be deleted.
- */
-struct gasket_sysfs_attribute *
-gasket_sysfs_get_attr(struct device *device, struct device_attribute *attr);
-
-/*
- * Releases a references to internal data.
- * @device: Kernel device structure.
- * @attr: Gasket sysfs attribute descriptor (returned by
- *        gasket_sysfs_get_attr).
- */
-void gasket_sysfs_put_attr(struct device *device,
-                          struct gasket_sysfs_attribute *attr);
-
-/*
- * Write to a register sysfs node.
- * @buf: NULL-terminated data being written.
- * @count: number of bytes in the "buf" argument.
- */
-ssize_t gasket_sysfs_register_store(struct device *device,
-                                   struct device_attribute *attr,
-                                   const char *buf, size_t count);
-
-#endif /* __GASKET_SYSFS_H__ */
index dc09cc6e1c4784ac6b3c95ca06ee576f2348ac53..09e7b4cd0138c9ac8e675a83c00e3a6f2a10b355 100644 (file)
@@ -1120,6 +1120,7 @@ static int ks_wlan_set_scan(struct net_device *dev,
 {
        struct ks_wlan_private *priv = netdev_priv(dev);
        struct iw_scan_req *req = NULL;
+       int len;
 
        if (priv->sleep_mode == SLP_SLEEP)
                return -EPERM;
@@ -1129,8 +1130,9 @@ static int ks_wlan_set_scan(struct net_device *dev,
        if (wrqu->data.length == sizeof(struct iw_scan_req) &&
            wrqu->data.flags & IW_SCAN_THIS_ESSID) {
                req = (struct iw_scan_req *)extra;
-               priv->scan_ssid_len = req->essid_len;
-               memcpy(priv->scan_ssid, req->essid, priv->scan_ssid_len);
+               len = min_t(int, req->essid_len, IW_ESSID_MAX_SIZE);
+               priv->scan_ssid_len = len;
+               memcpy(priv->scan_ssid, req->essid, len);
        } else {
                priv->scan_ssid_len = 0;
        }
index 535e6dec3504d45402b404fe552570ee724feb3d..6f420cbcdcfff67f02db4a47e3d587dee8a22151 100644 (file)
@@ -20,8 +20,6 @@ if MOST_COMPONENTS
 
 source "drivers/staging/most/net/Kconfig"
 
-source "drivers/staging/most/sound/Kconfig"
-
 source "drivers/staging/most/video/Kconfig"
 
 source "drivers/staging/most/dim2/Kconfig"
index be94673209f5f3ee74d569d92b7c263374c5f2c7..8b3fc5a7af5148d520ae5cfb3a0e4bdbf14fe3c3 100644 (file)
@@ -1,7 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 
 obj-$(CONFIG_MOST_NET) += net/
-obj-$(CONFIG_MOST_SOUND)       += sound/
 obj-$(CONFIG_MOST_VIDEO)       += video/
 obj-$(CONFIG_MOST_DIM2)        += dim2/
 obj-$(CONFIG_MOST_I2C) += i2c/
diff --git a/drivers/staging/most/sound/Kconfig b/drivers/staging/most/sound/Kconfig
deleted file mode 100644 (file)
index ad9f782..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-#
-# MOST ALSA configuration
-#
-
-config MOST_SOUND
-       tristate "Sound"
-       depends on SND
-       select SND_PCM
-       help
-         Say Y here if you want to commumicate via ALSA/sound devices.
-
-         To compile this driver as a module, choose M here: the
-         module will be called most_sound.
diff --git a/drivers/staging/most/sound/Makefile b/drivers/staging/most/sound/Makefile
deleted file mode 100644 (file)
index f0cd9d8..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-obj-$(CONFIG_MOST_SOUND) += most_sound.o
-
-most_sound-objs := sound.o
diff --git a/drivers/staging/most/sound/sound.c b/drivers/staging/most/sound/sound.c
deleted file mode 100644 (file)
index c87f6a0..0000000
+++ /dev/null
@@ -1,745 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * sound.c - Sound component for Mostcore
- *
- * Copyright (C) 2015 Microchip Technology Germany II GmbH & Co. KG
- */
-
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include <linux/module.h>
-#include <linux/printk.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/init.h>
-#include <sound/core.h>
-#include <sound/pcm.h>
-#include <sound/pcm_params.h>
-#include <linux/sched.h>
-#include <linux/kthread.h>
-#include <linux/most.h>
-
-#define DRIVER_NAME "sound"
-#define STRING_SIZE    80
-
-static struct most_component comp;
-
-/**
- * struct channel - private structure to keep channel specific data
- * @substream: stores the substream structure
- * @iface: interface for which the channel belongs to
- * @cfg: channel configuration
- * @card: registered sound card
- * @list: list for private use
- * @id: channel index
- * @period_pos: current period position (ring buffer)
- * @buffer_pos: current buffer position (ring buffer)
- * @is_stream_running: identifies whether a stream is running or not
- * @opened: set when the stream is opened
- * @playback_task: playback thread
- * @playback_waitq: waitq used by playback thread
- */
-struct channel {
-       struct snd_pcm_substream *substream;
-       struct snd_pcm_hardware pcm_hardware;
-       struct most_interface *iface;
-       struct most_channel_config *cfg;
-       struct snd_card *card;
-       struct list_head list;
-       int id;
-       unsigned int period_pos;
-       unsigned int buffer_pos;
-       bool is_stream_running;
-       struct task_struct *playback_task;
-       wait_queue_head_t playback_waitq;
-       void (*copy_fn)(void *alsa, void *most, unsigned int bytes);
-};
-
-struct sound_adapter {
-       struct list_head dev_list;
-       struct most_interface *iface;
-       struct snd_card *card;
-       struct list_head list;
-       bool registered;
-       int pcm_dev_idx;
-};
-
-static struct list_head adpt_list;
-
-#define MOST_PCM_INFO (SNDRV_PCM_INFO_MMAP | \
-                      SNDRV_PCM_INFO_MMAP_VALID | \
-                      SNDRV_PCM_INFO_BATCH | \
-                      SNDRV_PCM_INFO_INTERLEAVED | \
-                      SNDRV_PCM_INFO_BLOCK_TRANSFER)
-
-static void swap_copy16(u16 *dest, const u16 *source, unsigned int bytes)
-{
-       unsigned int i = 0;
-
-       while (i < (bytes / 2)) {
-               dest[i] = swab16(source[i]);
-               i++;
-       }
-}
-
-static void swap_copy24(u8 *dest, const u8 *source, unsigned int bytes)
-{
-       unsigned int i = 0;
-
-       if (bytes < 2)
-               return;
-       while (i < bytes - 2) {
-               dest[i] = source[i + 2];
-               dest[i + 1] = source[i + 1];
-               dest[i + 2] = source[i];
-               i += 3;
-       }
-}
-
-static void swap_copy32(u32 *dest, const u32 *source, unsigned int bytes)
-{
-       unsigned int i = 0;
-
-       while (i < bytes / 4) {
-               dest[i] = swab32(source[i]);
-               i++;
-       }
-}
-
-static void alsa_to_most_memcpy(void *alsa, void *most, unsigned int bytes)
-{
-       memcpy(most, alsa, bytes);
-}
-
-static void alsa_to_most_copy16(void *alsa, void *most, unsigned int bytes)
-{
-       swap_copy16(most, alsa, bytes);
-}
-
-static void alsa_to_most_copy24(void *alsa, void *most, unsigned int bytes)
-{
-       swap_copy24(most, alsa, bytes);
-}
-
-static void alsa_to_most_copy32(void *alsa, void *most, unsigned int bytes)
-{
-       swap_copy32(most, alsa, bytes);
-}
-
-static void most_to_alsa_memcpy(void *alsa, void *most, unsigned int bytes)
-{
-       memcpy(alsa, most, bytes);
-}
-
-static void most_to_alsa_copy16(void *alsa, void *most, unsigned int bytes)
-{
-       swap_copy16(alsa, most, bytes);
-}
-
-static void most_to_alsa_copy24(void *alsa, void *most, unsigned int bytes)
-{
-       swap_copy24(alsa, most, bytes);
-}
-
-static void most_to_alsa_copy32(void *alsa, void *most, unsigned int bytes)
-{
-       swap_copy32(alsa, most, bytes);
-}
-
-/**
- * get_channel - get pointer to channel
- * @iface: interface structure
- * @channel_id: channel ID
- *
- * This traverses the channel list and returns the channel matching the
- * ID and interface.
- *
- * Returns pointer to channel on success or NULL otherwise.
- */
-static struct channel *get_channel(struct most_interface *iface,
-                                  int channel_id)
-{
-       struct sound_adapter *adpt = iface->priv;
-       struct channel *channel;
-
-       list_for_each_entry(channel, &adpt->dev_list, list) {
-               if ((channel->iface == iface) && (channel->id == channel_id))
-                       return channel;
-       }
-       return NULL;
-}
-
-/**
- * copy_data - implements data copying function
- * @channel: channel
- * @mbo: MBO from core
- *
- * Copy data from/to ring buffer to/from MBO and update the buffer position
- */
-static bool copy_data(struct channel *channel, struct mbo *mbo)
-{
-       struct snd_pcm_runtime *const runtime = channel->substream->runtime;
-       unsigned int const frame_bytes = channel->cfg->subbuffer_size;
-       unsigned int const buffer_size = runtime->buffer_size;
-       unsigned int frames;
-       unsigned int fr0;
-
-       if (channel->cfg->direction & MOST_CH_RX)
-               frames = mbo->processed_length / frame_bytes;
-       else
-               frames = mbo->buffer_length / frame_bytes;
-       fr0 = min(buffer_size - channel->buffer_pos, frames);
-
-       channel->copy_fn(runtime->dma_area + channel->buffer_pos * frame_bytes,
-                        mbo->virt_address,
-                        fr0 * frame_bytes);
-
-       if (frames > fr0) {
-               /* wrap around at end of ring buffer */
-               channel->copy_fn(runtime->dma_area,
-                                mbo->virt_address + fr0 * frame_bytes,
-                                (frames - fr0) * frame_bytes);
-       }
-
-       channel->buffer_pos += frames;
-       if (channel->buffer_pos >= buffer_size)
-               channel->buffer_pos -= buffer_size;
-       channel->period_pos += frames;
-       if (channel->period_pos >= runtime->period_size) {
-               channel->period_pos -= runtime->period_size;
-               return true;
-       }
-       return false;
-}
-
-/**
- * playback_thread - function implements the playback thread
- * @data: private data
- *
- * Thread which does the playback functionality in a loop. It waits for a free
- * MBO from mostcore for a particular channel and copy the data from ring buffer
- * to MBO. Submit the MBO back to mostcore, after copying the data.
- *
- * Returns 0 on success or error code otherwise.
- */
-static int playback_thread(void *data)
-{
-       struct channel *const channel = data;
-
-       while (!kthread_should_stop()) {
-               struct mbo *mbo = NULL;
-               bool period_elapsed = false;
-
-               wait_event_interruptible(
-                       channel->playback_waitq,
-                       kthread_should_stop() ||
-                       (channel->is_stream_running &&
-                        (mbo = most_get_mbo(channel->iface, channel->id,
-                                            &comp))));
-               if (!mbo)
-                       continue;
-
-               if (channel->is_stream_running)
-                       period_elapsed = copy_data(channel, mbo);
-               else
-                       memset(mbo->virt_address, 0, mbo->buffer_length);
-
-               most_submit_mbo(mbo);
-               if (period_elapsed)
-                       snd_pcm_period_elapsed(channel->substream);
-       }
-       return 0;
-}
-
-/**
- * pcm_open - implements open callback function for PCM middle layer
- * @substream: pointer to ALSA PCM substream
- *
- * This is called when a PCM substream is opened. At least, the function should
- * initialize the runtime->hw record.
- *
- * Returns 0 on success or error code otherwise.
- */
-static int pcm_open(struct snd_pcm_substream *substream)
-{
-       struct channel *channel = substream->private_data;
-       struct snd_pcm_runtime *runtime = substream->runtime;
-       struct most_channel_config *cfg = channel->cfg;
-       int ret;
-
-       channel->substream = substream;
-
-       if (cfg->direction == MOST_CH_TX) {
-               channel->playback_task = kthread_run(playback_thread, channel,
-                                                    "most_audio_playback");
-               if (IS_ERR(channel->playback_task)) {
-                       pr_err("Couldn't start thread\n");
-                       return PTR_ERR(channel->playback_task);
-               }
-       }
-
-       ret = most_start_channel(channel->iface, channel->id, &comp);
-       if (ret) {
-               pr_err("most_start_channel() failed!\n");
-               if (cfg->direction == MOST_CH_TX)
-                       kthread_stop(channel->playback_task);
-               return ret;
-       }
-
-       runtime->hw = channel->pcm_hardware;
-       return 0;
-}
-
-/**
- * pcm_close - implements close callback function for PCM middle layer
- * @substream: sub-stream pointer
- *
- * Obviously, this is called when a PCM substream is closed. Any private
- * instance for a PCM substream allocated in the open callback will be
- * released here.
- *
- * Returns 0 on success or error code otherwise.
- */
-static int pcm_close(struct snd_pcm_substream *substream)
-{
-       struct channel *channel = substream->private_data;
-
-       if (channel->cfg->direction == MOST_CH_TX)
-               kthread_stop(channel->playback_task);
-       most_stop_channel(channel->iface, channel->id, &comp);
-       return 0;
-}
-
-/**
- * pcm_prepare - implements prepare callback function for PCM middle layer
- * @substream: substream pointer
- *
- * This callback is called when the PCM is "prepared". Format rate, sample rate,
- * etc., can be set here. This callback can be called many times at each setup.
- *
- * Returns 0 on success or error code otherwise.
- */
-static int pcm_prepare(struct snd_pcm_substream *substream)
-{
-       struct channel *channel = substream->private_data;
-       struct snd_pcm_runtime *runtime = substream->runtime;
-       struct most_channel_config *cfg = channel->cfg;
-       int width = snd_pcm_format_physical_width(runtime->format);
-
-       channel->copy_fn = NULL;
-
-       if (cfg->direction == MOST_CH_TX) {
-               if (snd_pcm_format_big_endian(runtime->format) || width == 8)
-                       channel->copy_fn = alsa_to_most_memcpy;
-               else if (width == 16)
-                       channel->copy_fn = alsa_to_most_copy16;
-               else if (width == 24)
-                       channel->copy_fn = alsa_to_most_copy24;
-               else if (width == 32)
-                       channel->copy_fn = alsa_to_most_copy32;
-       } else {
-               if (snd_pcm_format_big_endian(runtime->format) || width == 8)
-                       channel->copy_fn = most_to_alsa_memcpy;
-               else if (width == 16)
-                       channel->copy_fn = most_to_alsa_copy16;
-               else if (width == 24)
-                       channel->copy_fn = most_to_alsa_copy24;
-               else if (width == 32)
-                       channel->copy_fn = most_to_alsa_copy32;
-       }
-
-       if (!channel->copy_fn)
-               return -EINVAL;
-       channel->period_pos = 0;
-       channel->buffer_pos = 0;
-       return 0;
-}
-
-/**
- * pcm_trigger - implements trigger callback function for PCM middle layer
- * @substream: substream pointer
- * @cmd: action to perform
- *
- * This is called when the PCM is started, stopped or paused. The action will be
- * specified in the second argument, SNDRV_PCM_TRIGGER_XXX
- *
- * Returns 0 on success or error code otherwise.
- */
-static int pcm_trigger(struct snd_pcm_substream *substream, int cmd)
-{
-       struct channel *channel = substream->private_data;
-
-       switch (cmd) {
-       case SNDRV_PCM_TRIGGER_START:
-               channel->is_stream_running = true;
-               wake_up_interruptible(&channel->playback_waitq);
-               return 0;
-
-       case SNDRV_PCM_TRIGGER_STOP:
-               channel->is_stream_running = false;
-               return 0;
-
-       default:
-               return -EINVAL;
-       }
-       return 0;
-}
-
-/**
- * pcm_pointer - implements pointer callback function for PCM middle layer
- * @substream: substream pointer
- *
- * This callback is called when the PCM middle layer inquires the current
- * hardware position on the buffer. The position must be returned in frames,
- * ranging from 0 to buffer_size-1.
- */
-static snd_pcm_uframes_t pcm_pointer(struct snd_pcm_substream *substream)
-{
-       struct channel *channel = substream->private_data;
-
-       return channel->buffer_pos;
-}
-
-/**
- * Initialization of struct snd_pcm_ops
- */
-static const struct snd_pcm_ops pcm_ops = {
-       .open       = pcm_open,
-       .close      = pcm_close,
-       .prepare    = pcm_prepare,
-       .trigger    = pcm_trigger,
-       .pointer    = pcm_pointer,
-};
-
-static int split_arg_list(char *buf, u16 *ch_num, char **sample_res)
-{
-       char *num;
-       int ret;
-
-       num = strsep(&buf, "x");
-       if (!num)
-               goto err;
-       ret = kstrtou16(num, 0, ch_num);
-       if (ret)
-               goto err;
-       *sample_res = strsep(&buf, ".\n");
-       if (!*sample_res)
-               goto err;
-       return 0;
-
-err:
-       pr_err("Bad PCM format\n");
-       return -EINVAL;
-}
-
-static const struct sample_resolution_info {
-       const char *sample_res;
-       int bytes;
-       u64 formats;
-} sinfo[] = {
-       { "8", 1, SNDRV_PCM_FMTBIT_S8 },
-       { "16", 2, SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE },
-       { "24", 3, SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_3BE },
-       { "32", 4, SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE },
-};
-
-static int audio_set_hw_params(struct snd_pcm_hardware *pcm_hw,
-                              u16 ch_num, char *sample_res,
-                              struct most_channel_config *cfg)
-{
-       int i;
-
-       for (i = 0; i < ARRAY_SIZE(sinfo); i++) {
-               if (!strcmp(sample_res, sinfo[i].sample_res))
-                       goto found;
-       }
-       pr_err("Unsupported PCM format\n");
-       return -EINVAL;
-
-found:
-       if (!ch_num) {
-               pr_err("Bad number of channels\n");
-               return -EINVAL;
-       }
-
-       if (cfg->subbuffer_size != ch_num * sinfo[i].bytes) {
-               pr_err("Audio resolution doesn't fit subbuffer size\n");
-               return -EINVAL;
-       }
-
-       pcm_hw->info = MOST_PCM_INFO;
-       pcm_hw->rates = SNDRV_PCM_RATE_48000;
-       pcm_hw->rate_min = 48000;
-       pcm_hw->rate_max = 48000;
-       pcm_hw->buffer_bytes_max = cfg->num_buffers * cfg->buffer_size;
-       pcm_hw->period_bytes_min = cfg->buffer_size;
-       pcm_hw->period_bytes_max = cfg->buffer_size;
-       pcm_hw->periods_min = 1;
-       pcm_hw->periods_max = cfg->num_buffers;
-       pcm_hw->channels_min = ch_num;
-       pcm_hw->channels_max = ch_num;
-       pcm_hw->formats = sinfo[i].formats;
-       return 0;
-}
-
-static void release_adapter(struct sound_adapter *adpt)
-{
-       struct channel *channel, *tmp;
-
-       list_for_each_entry_safe(channel, tmp, &adpt->dev_list, list) {
-               list_del(&channel->list);
-               kfree(channel);
-       }
-       if (adpt->card)
-               snd_card_free(adpt->card);
-       list_del(&adpt->list);
-       kfree(adpt);
-}
-
-/**
- * audio_probe_channel - probe function of the driver module
- * @iface: pointer to interface instance
- * @channel_id: channel index/ID
- * @cfg: pointer to actual channel configuration
- * @arg_list: string that provides the name of the device to be created in /dev
- *           plus the desired audio resolution
- *
- * Creates sound card, pcm device, sets pcm ops and registers sound card.
- *
- * Returns 0 on success or error code otherwise.
- */
-static int audio_probe_channel(struct most_interface *iface, int channel_id,
-                              struct most_channel_config *cfg,
-                              char *device_name, char *arg_list)
-{
-       struct channel *channel;
-       struct sound_adapter *adpt;
-       struct snd_pcm *pcm;
-       int playback_count = 0;
-       int capture_count = 0;
-       int ret;
-       int direction;
-       u16 ch_num;
-       char *sample_res;
-       char arg_list_cpy[STRING_SIZE];
-
-       if (cfg->data_type != MOST_CH_SYNC) {
-               pr_err("Incompatible channel type\n");
-               return -EINVAL;
-       }
-       strscpy(arg_list_cpy, arg_list, STRING_SIZE);
-       ret = split_arg_list(arg_list_cpy, &ch_num, &sample_res);
-       if (ret < 0)
-               return ret;
-
-       list_for_each_entry(adpt, &adpt_list, list) {
-               if (adpt->iface != iface)
-                       continue;
-               if (adpt->registered)
-                       return -ENOSPC;
-               adpt->pcm_dev_idx++;
-               goto skip_adpt_alloc;
-       }
-       adpt = kzalloc(sizeof(*adpt), GFP_KERNEL);
-       if (!adpt)
-               return -ENOMEM;
-
-       adpt->iface = iface;
-       INIT_LIST_HEAD(&adpt->dev_list);
-       iface->priv = adpt;
-       list_add_tail(&adpt->list, &adpt_list);
-       ret = snd_card_new(iface->driver_dev, -1, "INIC", THIS_MODULE,
-                          sizeof(*channel), &adpt->card);
-       if (ret < 0)
-               goto err_free_adpt;
-       snprintf(adpt->card->driver, sizeof(adpt->card->driver),
-                "%s", DRIVER_NAME);
-       snprintf(adpt->card->shortname, sizeof(adpt->card->shortname),
-                "Microchip INIC");
-       snprintf(adpt->card->longname, sizeof(adpt->card->longname),
-                "%s at %s", adpt->card->shortname, iface->description);
-skip_adpt_alloc:
-       if (get_channel(iface, channel_id)) {
-               pr_err("channel (%s:%d) is already linked\n",
-                      iface->description, channel_id);
-               return -EEXIST;
-       }
-
-       if (cfg->direction == MOST_CH_TX) {
-               playback_count = 1;
-               direction = SNDRV_PCM_STREAM_PLAYBACK;
-       } else {
-               capture_count = 1;
-               direction = SNDRV_PCM_STREAM_CAPTURE;
-       }
-       channel = kzalloc(sizeof(*channel), GFP_KERNEL);
-       if (!channel) {
-               ret = -ENOMEM;
-               goto err_free_adpt;
-       }
-       channel->card = adpt->card;
-       channel->cfg = cfg;
-       channel->iface = iface;
-       channel->id = channel_id;
-       init_waitqueue_head(&channel->playback_waitq);
-       list_add_tail(&channel->list, &adpt->dev_list);
-
-       ret = audio_set_hw_params(&channel->pcm_hardware, ch_num, sample_res,
-                                 cfg);
-       if (ret)
-               goto err_free_adpt;
-
-       ret = snd_pcm_new(adpt->card, device_name, adpt->pcm_dev_idx,
-                         playback_count, capture_count, &pcm);
-
-       if (ret < 0)
-               goto err_free_adpt;
-
-       pcm->private_data = channel;
-       strscpy(pcm->name, device_name, sizeof(pcm->name));
-       snd_pcm_set_ops(pcm, direction, &pcm_ops);
-       snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
-       return 0;
-
-err_free_adpt:
-       release_adapter(adpt);
-       return ret;
-}
-
-static int audio_create_sound_card(void)
-{
-       int ret;
-       struct sound_adapter *adpt;
-
-       list_for_each_entry(adpt, &adpt_list, list) {
-               if (!adpt->registered)
-                       goto adpt_alloc;
-       }
-       return -ENODEV;
-adpt_alloc:
-       ret = snd_card_register(adpt->card);
-       if (ret < 0) {
-               release_adapter(adpt);
-               return ret;
-       }
-       adpt->registered = true;
-       return 0;
-}
-
-/**
- * audio_disconnect_channel - function to disconnect a channel
- * @iface: pointer to interface instance
- * @channel_id: channel index
- *
- * This frees allocated memory and removes the sound card from ALSA
- *
- * Returns 0 on success or error code otherwise.
- */
-static int audio_disconnect_channel(struct most_interface *iface,
-                                   int channel_id)
-{
-       struct channel *channel;
-       struct sound_adapter *adpt = iface->priv;
-
-       channel = get_channel(iface, channel_id);
-       if (!channel)
-               return -EINVAL;
-
-       list_del(&channel->list);
-
-       kfree(channel);
-       if (list_empty(&adpt->dev_list))
-               release_adapter(adpt);
-       return 0;
-}
-
-/**
- * audio_rx_completion - completion handler for rx channels
- * @mbo: pointer to buffer object that has completed
- *
- * This searches for the channel this MBO belongs to and copy the data from MBO
- * to ring buffer
- *
- * Returns 0 on success or error code otherwise.
- */
-static int audio_rx_completion(struct mbo *mbo)
-{
-       struct channel *channel = get_channel(mbo->ifp, mbo->hdm_channel_id);
-       bool period_elapsed = false;
-
-       if (!channel)
-               return -EINVAL;
-       if (channel->is_stream_running)
-               period_elapsed = copy_data(channel, mbo);
-       most_put_mbo(mbo);
-       if (period_elapsed)
-               snd_pcm_period_elapsed(channel->substream);
-       return 0;
-}
-
-/**
- * audio_tx_completion - completion handler for tx channels
- * @iface: pointer to interface instance
- * @channel_id: channel index/ID
- *
- * This searches the channel that belongs to this combination of interface
- * pointer and channel ID and wakes a process sitting in the wait queue of
- * this channel.
- *
- * Returns 0 on success or error code otherwise.
- */
-static int audio_tx_completion(struct most_interface *iface, int channel_id)
-{
-       struct channel *channel = get_channel(iface, channel_id);
-
-       if (!channel)
-               return -EINVAL;
-
-       wake_up_interruptible(&channel->playback_waitq);
-       return 0;
-}
-
-/**
- * Initialization of the struct most_component
- */
-static struct most_component comp = {
-       .mod = THIS_MODULE,
-       .name = DRIVER_NAME,
-       .probe_channel = audio_probe_channel,
-       .disconnect_channel = audio_disconnect_channel,
-       .rx_completion = audio_rx_completion,
-       .tx_completion = audio_tx_completion,
-       .cfg_complete = audio_create_sound_card,
-};
-
-static int __init audio_init(void)
-{
-       int ret;
-
-       INIT_LIST_HEAD(&adpt_list);
-
-       ret = most_register_component(&comp);
-       if (ret) {
-               pr_err("Failed to register %s\n", comp.name);
-               return ret;
-       }
-       ret = most_register_configfs_subsys(&comp);
-       if (ret) {
-               pr_err("Failed to register %s configfs subsys\n", comp.name);
-               most_deregister_component(&comp);
-       }
-       return ret;
-}
-
-static void __exit audio_exit(void)
-{
-       most_deregister_configfs_subsys(&comp);
-       most_deregister_component(&comp);
-}
-
-module_init(audio_init);
-module_exit(audio_exit);
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Christian Gromm <christian.gromm@microchip.com>");
-MODULE_DESCRIPTION("Sound Component Module for Mostcore");
index 157009015c3b459e8f0a9ce6360f26b4c0b7880c..06041c7f7d4ff0d12d93e0fcd25443aa585f9bb6 100644 (file)
@@ -28,7 +28,7 @@
        print_hex_dump(KERN_DEBUG, str, DUMP_PREFIX_NONE, \
                        16, 1, buf, len, false)
 #else
-#define NVEC_PHD(str, buf, len)
+#define NVEC_PHD(str, buf, len) do { } while (0)
 #endif
 
 enum ps2_subcmds {
index e2f8b6b67f75e29b49ab6efc3607b90fd0f188cc..f27f20a4aa2d2dd192d8534ee1a86ffeddeac17f 100644 (file)
@@ -1258,7 +1258,7 @@ static void cvmx_usb_poll_tx_fifo(struct octeon_hcd *usb)
                union cvmx_usbcx_hptxsts tx_status;
 
                tx_status.u32 = cvmx_usb_read_csr32(usb,
-                                       CVMX_USBCX_HPTXSTS(usb->index));
+                                                   CVMX_USBCX_HPTXSTS(usb->index));
                if (cvmx_usb_fill_tx_hw(usb, &usb->periodic,
                                        tx_status.s.ptxfspcavail))
                        USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index),
@@ -1272,7 +1272,7 @@ static void cvmx_usb_poll_tx_fifo(struct octeon_hcd *usb)
                union cvmx_usbcx_gnptxsts tx_status;
 
                tx_status.u32 = cvmx_usb_read_csr32(usb,
-                                       CVMX_USBCX_GNPTXSTS(usb->index));
+                                                   CVMX_USBCX_GNPTXSTS(usb->index));
                if (cvmx_usb_fill_tx_hw(usb, &usb->nonperiodic,
                                        tx_status.s.nptxfspcavail))
                        USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index),
@@ -1298,13 +1298,13 @@ static void cvmx_usb_fill_tx_fifo(struct octeon_hcd *usb, int channel)
 
        /* We only need to fill data on outbound channels */
        hcchar.u32 = cvmx_usb_read_csr32(usb,
-                       CVMX_USBCX_HCCHARX(channel, usb->index));
+                                        CVMX_USBCX_HCCHARX(channel, usb->index));
        if (hcchar.s.epdir != CVMX_USB_DIRECTION_OUT)
                return;
 
        /* OUT Splits only have data on the start and not the complete */
        usbc_hcsplt.u32 = cvmx_usb_read_csr32(usb,
-                               CVMX_USBCX_HCSPLTX(channel, usb->index));
+                                             CVMX_USBCX_HCSPLTX(channel, usb->index));
        if (usbc_hcsplt.s.spltena && usbc_hcsplt.s.compsplt)
                return;
 
@@ -1313,7 +1313,7 @@ static void cvmx_usb_fill_tx_fifo(struct octeon_hcd *usb, int channel)
         * words.
         */
        usbc_hctsiz.u32 = cvmx_usb_read_csr32(usb,
-                               CVMX_USBCX_HCTSIZX(channel, usb->index));
+                                             CVMX_USBCX_HCTSIZX(channel, usb->index));
        if (!usbc_hctsiz.s.xfersize)
                return;
 
@@ -1360,7 +1360,7 @@ static void cvmx_usb_start_channel_control(struct octeon_hcd *usb,
        union cvmx_usbcx_hctsizx usbc_hctsiz;
 
        usbc_hctsiz.u32 = cvmx_usb_read_csr32(usb,
-                               CVMX_USBCX_HCTSIZX(channel, usb->index));
+                                             CVMX_USBCX_HCTSIZX(channel, usb->index));
 
        switch (transaction->stage) {
        case CVMX_USB_STAGE_NON_CONTROL:
@@ -1517,7 +1517,7 @@ static void cvmx_usb_start_channel(struct octeon_hcd *usb, int channel,
 
                /* Clear all channel status bits */
                usbc_hcint.u32 = cvmx_usb_read_csr32(usb,
-                                       CVMX_USBCX_HCINTX(channel, usb->index));
+                                                    CVMX_USBCX_HCINTX(channel, usb->index));
 
                cvmx_usb_write_csr32(usb,
                                     CVMX_USBCX_HCINTX(channel, usb->index),
@@ -1552,7 +1552,7 @@ static void cvmx_usb_start_channel(struct octeon_hcd *usb, int channel,
 
                /* Enable the channel interrupt to propagate */
                usbc_haintmsk.u32 = cvmx_usb_read_csr32(usb,
-                                       CVMX_USBCX_HAINTMSK(usb->index));
+                                                       CVMX_USBCX_HAINTMSK(usb->index));
                usbc_haintmsk.s.haintmsk |= 1 << channel;
                cvmx_usb_write_csr32(usb, CVMX_USBCX_HAINTMSK(usb->index),
                                     usbc_haintmsk.u32);
@@ -1836,7 +1836,7 @@ static void cvmx_usb_start_channel(struct octeon_hcd *usb, int channel,
  * Returns: Pipe or NULL if none are ready
  */
 static struct cvmx_usb_pipe *cvmx_usb_find_ready_pipe(struct octeon_hcd *usb,
-               enum cvmx_usb_transfer xfer_type)
+                                                     enum cvmx_usb_transfer xfer_type)
 {
        struct list_head *list = usb->active_pipes + xfer_type;
        u64 current_frame = usb->frame_number;
@@ -2309,7 +2309,8 @@ static int cvmx_usb_cancel(struct octeon_hcd *usb,
                CVMX_SYNCW;
 
                usbc_hcchar.u32 = cvmx_usb_read_csr32(usb,
-                               CVMX_USBCX_HCCHARX(pipe->channel, usb->index));
+                                                     CVMX_USBCX_HCCHARX(pipe->channel,
+                                                                        usb->index));
                /*
                 * If the channel isn't enabled then the transaction already
                 * completed.
@@ -2605,11 +2606,12 @@ static int cvmx_usb_poll_channel(struct octeon_hcd *usb, int channel)
 
        /* Read the interrupt status bits for the channel */
        usbc_hcint.u32 = cvmx_usb_read_csr32(usb,
-                               CVMX_USBCX_HCINTX(channel, usb->index));
+                                            CVMX_USBCX_HCINTX(channel, usb->index));
 
        if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA) {
                usbc_hcchar.u32 = cvmx_usb_read_csr32(usb,
-                               CVMX_USBCX_HCCHARX(channel, usb->index));
+                                                     CVMX_USBCX_HCCHARX(channel,
+                                                                        usb->index));
 
                if (usbc_hcchar.s.chena && usbc_hcchar.s.chdis) {
                        /*
@@ -2688,9 +2690,9 @@ static int cvmx_usb_poll_channel(struct octeon_hcd *usb, int channel)
         * transferred
         */
        usbc_hcchar.u32 = cvmx_usb_read_csr32(usb,
-                       CVMX_USBCX_HCCHARX(channel, usb->index));
+                                             CVMX_USBCX_HCCHARX(channel, usb->index));
        usbc_hctsiz.u32 = cvmx_usb_read_csr32(usb,
-                       CVMX_USBCX_HCTSIZX(channel, usb->index));
+                                             CVMX_USBCX_HCTSIZX(channel, usb->index));
 
        /*
         * Calculating the number of bytes successfully transferred is dependent
@@ -3010,7 +3012,7 @@ static int cvmx_usb_poll(struct octeon_hcd *usb)
                union cvmx_usbcx_haint usbc_haint;
 
                usbc_haint.u32 = cvmx_usb_read_csr32(usb,
-                                       CVMX_USBCX_HAINT(usb->index));
+                                                    CVMX_USBCX_HAINT(usb->index));
                while (usbc_haint.u32) {
                        int channel;
 
index 2682a0e474bd39ceb058ad7a9535fde0abd01499..e11470910ef35f975cb82c300c1db859101878fd 100644 (file)
@@ -4549,7 +4549,7 @@ static int qlge_probe(struct pci_dev *pdev,
        struct net_device *ndev = NULL;
        struct devlink *devlink;
        static int cards_found;
-       int err = 0;
+       int err;
 
        devlink = devlink_alloc(&qlge_devlink_ops, sizeof(struct qlge_adapter));
        if (!devlink)
@@ -4560,8 +4560,10 @@ static int qlge_probe(struct pci_dev *pdev,
        ndev = alloc_etherdev_mq(sizeof(struct qlge_netdev_priv),
                                 min(MAX_CPUS,
                                     netif_get_num_default_rss_queues()));
-       if (!ndev)
+       if (!ndev) {
+               err = -ENOMEM;
                goto devlink_free;
+       }
 
        ndev_priv = netdev_priv(ndev);
        ndev_priv->qdev = qdev;
index fa1e34a0d456182d83cd7bd48f601a35a257b60b..008b60e7275861da8a04c1cbd4d173b48a291388 100644 (file)
@@ -507,7 +507,6 @@ void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta)
        struct ht_priv  *phtpriv_sta = &psta->htpriv;
 
        psta->mac_id = psta->aid + 1;
-       DBG_88E("%s\n", __func__);
 
        /* ap mode */
        rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, true);
@@ -571,8 +570,6 @@ static void update_hw_ht_param(struct adapter *padapter)
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
 
-       DBG_88E("%s\n", __func__);
-
        /* handle A-MPDU parameter field
         * ampdu_params_info [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k
         * ampdu_params_info [4:2]:Min MPDU Start Spacing
@@ -791,6 +788,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf,  int len)
        p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_SSID, &ie_len,
                       pbss_network->ie_length - _BEACON_IE_OFFSET_);
        if (p && ie_len > 0) {
+               ie_len = min_t(int, ie_len, sizeof(pbss_network->ssid.ssid));
                memset(&pbss_network->ssid, 0, sizeof(struct ndis_802_11_ssid));
                memcpy(pbss_network->ssid.ssid, p + 2, ie_len);
                pbss_network->ssid.ssid_length = ie_len;
@@ -811,6 +809,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf,  int len)
        p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_SUPP_RATES, &ie_len,
                       pbss_network->ie_length - _BEACON_IE_OFFSET_);
        if (p) {
+               ie_len = min_t(int, ie_len, NDIS_802_11_LENGTH_RATES_EX);
                memcpy(supportRate, p + 2, ie_len);
                supportRateNum = ie_len;
        }
@@ -819,6 +818,8 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf,  int len)
        p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_EXT_SUPP_RATES,
                       &ie_len, pbss_network->ie_length - _BEACON_IE_OFFSET_);
        if (p) {
+               ie_len = min_t(int, ie_len,
+                              NDIS_802_11_LENGTH_RATES_EX - supportRateNum);
                memcpy(supportRate + supportRateNum, p + 2, ie_len);
                supportRateNum += ie_len;
        }
@@ -934,6 +935,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf,  int len)
 
                pht_cap->mcs.rx_mask[0] = 0xff;
                pht_cap->mcs.rx_mask[1] = 0x0;
+               ie_len = min_t(int, ie_len, sizeof(pmlmepriv->htpriv.ht_cap));
                memcpy(&pmlmepriv->htpriv.ht_cap, p + 2, ie_len);
        }
 
@@ -1161,8 +1163,6 @@ static void update_bcn_wps_ie(struct adapter *padapter)
        unsigned char *ie = pnetwork->ies;
        u32 ielen = pnetwork->ie_length;
 
-       DBG_88E("%s\n", __func__);
-
        pwps_ie_src = pmlmepriv->wps_beacon_ie;
        if (!pwps_ie_src)
                return;
@@ -1202,7 +1202,6 @@ static void update_bcn_wps_ie(struct adapter *padapter)
 
 static void update_bcn_vendor_spec_ie(struct adapter *padapter, u8 *oui)
 {
-       DBG_88E("%s\n", __func__);
 
        if (!memcmp(WPS_OUI, oui, 4))
                update_bcn_wps_ie(padapter);
index 11198d43a371cb2b0dbe51b483e929a3946207c9..1060837fe463937c079e3c25d04540e9d4b4d8a3 100644 (file)
@@ -33,7 +33,7 @@ int proc_set_write_reg(struct file *file, const char __user *buffer,
                       unsigned long count, void *data)
 {
        struct net_device *dev = data;
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        char tmp[32];
        u32 addr, val, len;
 
@@ -75,7 +75,7 @@ int proc_get_read_reg(char *page, char **start,
                      int *eof, void *data)
 {
        struct net_device *dev = data;
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
 
        int len = 0;
 
@@ -139,7 +139,7 @@ int proc_get_adapter_state(char *page, char **start,
                           int *eof, void *data)
 {
        struct net_device *dev = data;
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        int len = 0;
 
        len += scnprintf(page + len, count - len, "bSurpriseRemoved=%d, bDriverStopped=%d\n",
@@ -155,7 +155,7 @@ int proc_get_best_channel(char *page, char **start,
                          int *eof, void *data)
 {
        struct net_device *dev = data;
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        int len = 0;
        u32 i, best_channel_24G = 1, index_24G = 0;
index ec5b8be14c2bfaaa48170972303d0a377db8ff5e..7a706fe11750cd0fd593980f3e313bb6c654e3e5 100644 (file)
@@ -223,13 +223,13 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv)
        /* capability info */
        *(u16 *)ie = 0;
 
-       *(__le16 *)ie |= cpu_to_le16(cap_IBSS);
+       *(__le16 *)ie |= cpu_to_le16(WLAN_CAPABILITY_IBSS);
 
        if (pregistrypriv->preamble == PREAMBLE_SHORT)
-               *(__le16 *)ie |= cpu_to_le16(cap_ShortPremble);
+               *(__le16 *)ie |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE);
 
        if (pdev_network->Privacy)
-               *(__le16 *)ie |= cpu_to_le16(cap_Privacy);
+               *(__le16 *)ie |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
 
        sz += 2;
        ie += 2;
index f87dd71934c39eb889e40dd245d1a2d3ef6771df..b6ac5b8915b1c3e644e0e2d972d26b5d58c60175 100644 (file)
@@ -37,7 +37,7 @@ int rtw_init_mlme_priv(struct adapter *padapter)
        pmlmepriv->pscanned = NULL;
        pmlmepriv->fw_state = 0;
        pmlmepriv->cur_network.network.InfrastructureMode = Ndis802_11AutoUnknown;
-       pmlmepriv->scan_mode = SCAN_ACTIVE;/*  1: active, 0: pasive. Maybe someday we should rename this varable to "active_mode" (Jeff) */
+       pmlmepriv->scan_mode = SCAN_ACTIVE;/*  1: active, 0: passive. Maybe someday we should rename this variable to "active_mode" (Jeff) */
 
        spin_lock_init(&pmlmepriv->lock);
        _rtw_init_queue(&pmlmepriv->free_bss_pool);
index ebd9b96a8211a25395a12b85d71be534bd823f1a..50d3c3631be0ad740ef2bc0662d99d8a410b6cc9 100644 (file)
@@ -2188,7 +2188,7 @@ static void start_create_ibss(struct adapter *padapter)
        /* update capability */
        caps = rtw_get_capability(pnetwork);
        update_capinfo(padapter, caps);
-       if (caps & cap_IBSS) {/* adhoc master */
+       if (caps & WLAN_CAPABILITY_IBSS) {/* adhoc master */
                val8 = 0xcf;
                rtw_hal_set_hwreg(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8));
 
@@ -2240,7 +2240,7 @@ static void start_clnt_join(struct adapter *padapter)
        /* update capability */
        caps = rtw_get_capability(pnetwork);
        update_capinfo(padapter, caps);
-       if (caps & cap_ESS) {
+       if (caps & WLAN_CAPABILITY_ESS) {
                Set_MSR(padapter, WIFI_FW_STATION_STATE);
 
                val8 = (pmlmeinfo->auth_algo == dot11AuthAlgrthm_8021X) ? 0xcc : 0xcf;
@@ -2258,7 +2258,7 @@ static void start_clnt_join(struct adapter *padapter)
                          msecs_to_jiffies((REAUTH_TO * REAUTH_LIMIT) + (REASSOC_TO * REASSOC_LIMIT) + beacon_timeout));
 
                pmlmeinfo->state = WIFI_FW_AUTH_NULL | WIFI_FW_STATION_STATE;
-       } else if (caps & cap_IBSS) { /* adhoc client */
+       } else if (caps & WLAN_CAPABILITY_IBSS) { /* adhoc client */
                Set_MSR(padapter, WIFI_FW_ADHOC_STATE);
 
                val8 = 0xcf;
@@ -2526,7 +2526,7 @@ static unsigned int OnProbeReq(struct adapter *padapter,
 
                if (check_fwstate(pmlmepriv, _FW_LINKED) &&
                    pmlmepriv->cur_network.join_res)
-                       issue_probersp(padapter, get_sa(pframe));
+                       issue_probersp(padapter, ieee80211_get_SA((struct ieee80211_hdr *)pframe));
        }
        return _SUCCESS;
 }
@@ -2819,7 +2819,7 @@ static unsigned int OnAuthClient(struct adapter *padapter,
        DBG_88E("%s\n", __func__);
 
        /* check A1 matches or not */
-       if (memcmp(myid(&padapter->eeprompriv), get_da(pframe), ETH_ALEN))
+       if (memcmp(myid(&padapter->eeprompriv), ieee80211_get_DA((struct ieee80211_hdr *)pframe), ETH_ALEN))
                return _SUCCESS;
 
        if (!(pmlmeinfo->state & WIFI_FW_AUTH_STATE))
@@ -3332,7 +3332,7 @@ static unsigned int OnAssocRsp(struct adapter *padapter,
        DBG_88E("%s\n", __func__);
 
        /* check A1 matches or not */
-       if (memcmp(myid(&padapter->eeprompriv), get_da(pframe), ETH_ALEN))
+       if (memcmp(myid(&padapter->eeprompriv), ieee80211_get_DA((struct ieee80211_hdr *)pframe), ETH_ALEN))
                return _SUCCESS;
 
        if (!(pmlmeinfo->state & (WIFI_FW_AUTH_SUCCESS | WIFI_FW_ASSOC_STATE)))
index 3848e695ac846f07c6d4aa0279ebf86fcf7e6877..c3c1cf67cf7edf0d648b405acbdda7f63c560697 100644 (file)
@@ -84,7 +84,7 @@ static int rtw_hw_resume(struct adapter *padapter)
        pwrpriv->bips_processing = true;
        rtw_reset_drv_sw(padapter);
 
-       if (ips_netdrv_open(rtw_netdev_priv(pnetdev)) != _SUCCESS) {
+       if (ips_netdrv_open(netdev_priv(pnetdev)) != _SUCCESS) {
                mutex_unlock(&pwrpriv->mutex_lock);
                goto error_exit;
        }
index 36bcbe635cf480916e6b68beb526974351af0fe3..b9b4bc4350370c10967a18621a68fd45a51b022e 100644 (file)
@@ -1029,8 +1029,8 @@ static int validate_recv_data_frame(struct adapter *adapter,
        int ret = _SUCCESS;
 
        bretry = GetRetry(ptr);
-       pda = get_da(ptr);
-       psa = get_sa(ptr);
+       pda = ieee80211_get_DA((struct ieee80211_hdr *)ptr);
+       psa = ieee80211_get_SA((struct ieee80211_hdr *)ptr);
        pbssid = get_hdr_bssid(ptr);
 
        if (!pbssid) {
index 317355f830cbd0007c86f83752248cc24f54e9e3..ed81cbc5e19105f32b97d33dc9ea7f01522c86bd 100644 (file)
@@ -44,7 +44,10 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
        u32 max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ;
        u32 num_xmit_extbuf = NR_XMIT_EXTBUFF;
 
-       /*  We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */
+       /*
+        * We don't need to memset padapter->XXX to zero because adapter is
+        * allocated by alloc_etherdev_mq, which eventually calls kvzalloc.
+        */
 
        spin_lock_init(&pxmitpriv->lock);
 
index 0d06cb54b1ad09bccf8f54519f78d342a92e75cb..8669bf09747957d607beb11e8dd480d35b483109 100644 (file)
@@ -133,6 +133,8 @@ void update_recvframe_phyinfo_88e(struct recv_frame *precvframe,
        struct rx_pkt_attrib *pattrib = &precvframe->attrib;
        struct odm_phy_status_info *pPHYInfo  = (struct odm_phy_status_info *)(&pattrib->phy_info);
        u8 *wlanhdr;
+       struct ieee80211_hdr *hdr =
+               (struct ieee80211_hdr *)precvframe->pkt->data;
        struct odm_per_pkt_info pkt_info;
        u8 *sa = NULL;
        struct sta_priv *pstapriv;
@@ -144,13 +146,13 @@ void update_recvframe_phyinfo_88e(struct recv_frame *precvframe,
 
        wlanhdr = precvframe->pkt->data;
 
-       pkt_info.bPacketMatchBSSID = ((!IsFrameTypeCtrl(wlanhdr)) &&
+       pkt_info.bPacketMatchBSSID = (!ieee80211_is_ctl(hdr->frame_control) &&
                !pattrib->icv_err && !pattrib->crc_err &&
                !memcmp(get_hdr_bssid(wlanhdr),
                 get_bssid(&padapter->mlmepriv), ETH_ALEN));
 
        pkt_info.bPacketToSelf = pkt_info.bPacketMatchBSSID &&
-                                (!memcmp(get_da(wlanhdr),
+                                (!memcmp(ieee80211_get_DA(hdr),
                                  myid(&padapter->eeprompriv), ETH_ALEN));
 
        pkt_info.bPacketBeacon = pkt_info.bPacketMatchBSSID &&
@@ -161,7 +163,7 @@ void update_recvframe_phyinfo_88e(struct recv_frame *precvframe,
                        sa = padapter->mlmepriv.cur_network.network.MacAddress;
                /* to do Ad-hoc */
        } else {
-               sa = get_sa(wlanhdr);
+               sa = ieee80211_get_SA(hdr);
        }
 
        pstapriv = &padapter->stapriv;
index 5ee4ed99502549437e6d88cd16ca915339f3b109..5012b9176526bbe116a2bb36ad4d4b687fb5f6d1 100644 (file)
@@ -23,7 +23,7 @@ void rtw_cancel_all_timer(struct adapter *padapter);
 
 int rtw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
 
-struct net_device *rtw_init_netdev(struct adapter *padapter);
+struct net_device *rtw_init_netdev(void);
 u16 rtw_recv_select_queue(struct sk_buff *skb);
 
 int netdev_open(struct net_device *pnetdev);
index 56e937b264070d1aeeb5bd5a5fc5e3bc67ef8d42..efd0833e28c8525b18876cc2d8bcd65773642623 100644 (file)
@@ -66,19 +66,6 @@ u8 *_rtw_malloc(u32 sz);
 
 void _rtw_init_queue(struct __queue *pqueue);
 
-struct rtw_netdev_priv_indicator {
-       void *priv;
-};
-
-struct net_device *rtw_alloc_etherdev_with_old_priv(void *old_priv);
-
-static inline struct adapter *rtw_netdev_priv(struct net_device *netdev)
-{
-       return ((struct rtw_netdev_priv_indicator *)netdev_priv(netdev))->priv;
-}
-
-void rtw_free_netdev(struct net_device *netdev);
-
 #define FUNC_NDEV_FMT "%s(%s)"
 #define FUNC_NDEV_ARG(ndev) __func__, ndev->name
 #define FUNC_ADPT_FMT "%s(%s)"
index 1b9006879a11aba821b1a2a491c858b7aeeb15d5..84e17330628e2f9c747124d1d3c45187ec0e6112 100644 (file)
@@ -7,21 +7,8 @@
 #ifndef _WIFI_H_
 #define _WIFI_H_
 
-#define WLAN_IEEE_OUI_LEN      3
-#define WLAN_CRC_LEN           4
-#define WLAN_BSSID_LEN         6
-#define WLAN_BSS_TS_LEN                8
 #define WLAN_HDR_A3_LEN                24
-#define WLAN_HDR_A4_LEN                30
 #define WLAN_HDR_A3_QOS_LEN    26
-#define WLAN_HDR_A4_QOS_LEN    32
-#define WLAN_DATA_MAXLEN       2312
-
-#define WLAN_A3_PN_OFFSET      24
-#define WLAN_A4_PN_OFFSET      30
-
-#define WLAN_MIN_ETHFRM_LEN    60
-#define WLAN_MAX_ETHFRM_LEN    1514
 
 #define P80211CAPTURE_VERSION  0x80211001
 
@@ -74,20 +61,6 @@ enum WIFI_FRAME_SUBTYPE {
        WIFI_QOS_DATA_NULL      = (BIT(6) | WIFI_QOS_DATA_TYPE),
 };
 
-enum WIFI_REG_DOMAIN {
-       DOMAIN_FCC      = 1,
-       DOMAIN_IC       = 2,
-       DOMAIN_ETSI     = 3,
-       DOMAIN_SPA      = 4,
-       DOMAIN_FRANCE   = 5,
-       DOMAIN_MKK      = 6,
-       DOMAIN_ISRAEL   = 7,
-       DOMAIN_MKK1     = 8,
-       DOMAIN_MKK2     = 9,
-       DOMAIN_MKK3     = 10,
-       DOMAIN_MAX
-};
-
 #define SetToDs(pbuf)  \
        *(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_TODS)
 
@@ -199,52 +172,6 @@ enum WIFI_REG_DOMAIN {
 
 #define GetAddr3Ptr(pbuf)      ((unsigned char *)((size_t)(pbuf) + 16))
 
-#define GetAddr4Ptr(pbuf)      ((unsigned char *)((size_t)(pbuf) + 24))
-
-static inline unsigned char *get_da(unsigned char *pframe)
-{
-       unsigned char   *da;
-       unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
-
-       switch (to_fr_ds) {
-       case 0x00:      /*  ToDs=0, FromDs=0 */
-               da = GetAddr1Ptr(pframe);
-               break;
-       case 0x01:      /*  ToDs=0, FromDs=1 */
-               da = GetAddr1Ptr(pframe);
-               break;
-       case 0x02:      /*  ToDs=1, FromDs=0 */
-               da = GetAddr3Ptr(pframe);
-               break;
-       default:        /*  ToDs=1, FromDs=1 */
-               da = GetAddr3Ptr(pframe);
-               break;
-       }
-       return da;
-}
-
-static inline unsigned char *get_sa(unsigned char *pframe)
-{
-       unsigned char   *sa;
-       unsigned int    to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
-
-       switch (to_fr_ds) {
-       case 0x00:      /*  ToDs=0, FromDs=0 */
-               sa = GetAddr2Ptr(pframe);
-               break;
-       case 0x01:      /*  ToDs=0, FromDs=1 */
-               sa = GetAddr3Ptr(pframe);
-               break;
-       case 0x02:      /*  ToDs=1, FromDs=0 */
-               sa = GetAddr2Ptr(pframe);
-               break;
-       default:        /*  ToDs=1, FromDs=1 */
-               sa = GetAddr4Ptr(pframe);
-               break;
-       }
-       return sa;
-}
-
 static inline unsigned char *get_hdr_bssid(unsigned char *pframe)
 {
        unsigned char   *sa;
@@ -270,30 +197,9 @@ static inline unsigned char *get_hdr_bssid(unsigned char *pframe)
        return sa;
 }
 
-static inline int IsFrameTypeCtrl(unsigned char *pframe)
-{
-       if (GetFrameType(pframe) == WIFI_CTRL_TYPE)
-               return true;
-       else
-               return false;
-}
-
 /*-----------------------------------------------------------------------------
                        Below is for the security related definition
 ------------------------------------------------------------------------------*/
-#define _RESERVED_FRAME_TYPE_          0
-#define _SKB_FRAME_TYPE_               2
-#define _PRE_ALLOCMEM_                 1
-#define _PRE_ALLOCHDR_                 3
-#define _PRE_ALLOCLLCHDR_              4
-#define _PRE_ALLOCICVHDR_              5
-#define _PRE_ALLOCMICHDR_              6
-
-#define _SIFSTIME_                             \
-       ((priv->pmib->dot11BssType.net_work_type & WIRELESS_11A) ? 16 : 10)
-#define _ACKCTSLNG_            14      /* 14 bytes long, including crclng */
-#define _CRCLNG_               4
-
 #define _ASOCREQ_IE_OFFSET_    4       /*  excluding wlan_hdr */
 #define        _ASOCRSP_IE_OFFSET_     6
 #define _REASOCREQ_IE_OFFSET_  10
@@ -324,22 +230,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe)
 #define AUTH_ODD_TO            0
 #define AUTH_EVEN_TO           1
 
-#define WLAN_ETHCONV_ENCAP     1
-#define WLAN_ETHCONV_RFC1042   2
-#define WLAN_ETHCONV_8021h     3
-
-#define cap_ESS                BIT(0)
-#define cap_IBSS       BIT(1)
-#define cap_CFPollable BIT(2)
-#define cap_CFRequest  BIT(3)
-#define cap_Privacy    BIT(4)
-#define cap_ShortPremble BIT(5)
-#define cap_PBCC       BIT(6)
-#define cap_ChAgility  BIT(7)
-#define cap_SpecMgmt   BIT(8)
-#define cap_QoSi       BIT(9)
-#define cap_ShortSlot  BIT(10)
-
 /*-----------------------------------------------------------------------------
                                Below is the definition for 802.11i / 802.1x
 ------------------------------------------------------------------------------*/
@@ -360,7 +250,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe)
                                Below is the definition for WMM
 ------------------------------------------------------------------------------*/
 #define _WMM_IE_Length_                                7  /*  for WMM STA */
-#define _WMM_Para_Element_Length_              24
 
 /*-----------------------------------------------------------------------------
                                Below is the definition for 802.11n
@@ -432,13 +321,6 @@ enum ht_cap_ampdu_factor {
 #define HT_INFO_OPERATION_MODE_TRANSMIT_BURST_LIMIT    ((u8)BIT(3))
 #define HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT      ((u8)BIT(4))
 
-#define HT_INFO_STBC_PARAM_DUAL_BEACON         ((u16)BIT(6))
-#define HT_INFO_STBC_PARAM_DUAL_STBC_PROTECT   ((u16)BIT(7))
-#define HT_INFO_STBC_PARAM_SECONDARY_BC                ((u16)BIT(8))
-#define HT_INFO_STBC_PARAM_LSIG_TXOP_PROTECT_ALLOWED   ((u16)BIT(9))
-#define HT_INFO_STBC_PARAM_PCO_ACTIVE          ((u16)BIT(10))
-#define HT_INFO_STBC_PARAM_PCO_PHASE           ((u16)BIT(11))
-
 /*     ===============WPS Section=============== */
 /*     For WPSv1.0 */
 #define WPSOUI                                 0x0050f204
@@ -497,48 +379,10 @@ enum ht_cap_ampdu_factor {
 #define WPS_CONFIG_METHOD_VDISPLAY     0x2008
 #define WPS_CONFIG_METHOD_PDISPLAY     0x4008
 
-/*     Value of Category ID of WPS Primary Device Type Attribute */
-#define WPS_PDT_CID_DISPLAYS           0x0007
-#define WPS_PDT_CID_MULIT_MEDIA                0x0008
-#define WPS_PDT_CID_RTK_WIDI           WPS_PDT_CID_MULIT_MEDIA
-
-/*     Value of Sub Category ID of WPS Primary Device Type Attribute */
-#define WPS_PDT_SCID_MEDIA_SERVER      0x0005
-#define WPS_PDT_SCID_RTK_DMP           WPS_PDT_SCID_MEDIA_SERVER
-
-/*     Value of Device Password ID */
-#define WPS_DPID_P                     0x0000
-#define WPS_DPID_USER_SPEC             0x0001
-#define WPS_DPID_MACHINE_SPEC          0x0002
-#define WPS_DPID_REKEY                 0x0003
-#define WPS_DPID_PBC                   0x0004
-#define WPS_DPID_REGISTRAR_SPEC                0x0005
-
 /*     Value of WPS RF Bands Attribute */
 #define WPS_RF_BANDS_2_4_GHZ           0x01
 #define WPS_RF_BANDS_5_GHZ             0x02
 
-/*     Value of WPS Association State Attribute */
-#define WPS_ASSOC_STATE_NOT_ASSOCIATED         0x00
-#define WPS_ASSOC_STATE_CONNECTION_SUCCESS     0x01
-#define WPS_ASSOC_STATE_CONFIGURATION_FAILURE  0x02
-#define WPS_ASSOC_STATE_ASSOCIATION_FAILURE    0x03
-#define WPS_ASSOC_STATE_IP_FAILURE             0x04
-
-/*     WPS Configuration Method */
-#define        WPS_CM_NONE                     0x0000
-#define        WPS_CM_LABEL                    0x0004
-#define        WPS_CM_DISPLYA                  0x0008
-#define        WPS_CM_EXTERNAL_NFC_TOKEN       0x0010
-#define        WPS_CM_INTEGRATED_NFC_TOKEN     0x0020
-#define        WPS_CM_NFC_INTERFACE            0x0040
-#define        WPS_CM_PUSH_BUTTON              0x0080
-#define        WPS_CM_KEYPAD                   0x0100
-#define        WPS_CM_SW_PUHS_BUTTON           0x0280
-#define        WPS_CM_HW_PUHS_BUTTON           0x0480
-#define        WPS_CM_SW_DISPLAY_P             0x2008
-#define        WPS_CM_LCD_DISPLAY_P            0x4008
-
 #define IP_MCAST_MAC(mac)                              \
        ((mac[0] == 0x01) && (mac[1] == 0x00) && (mac[2] == 0x5e))
 #define ICMPV6_MCAST_MAC(mac)                          \
index bf22f130d3e1671ca6b7b9b8f895d9dd8c36f21e..c95ae4d6a3b6bb507721cb45e1dc20c56ba0cd2d 100644 (file)
@@ -311,7 +311,7 @@ static char *translate_scan(struct adapter *padapter,
 
 static int wpa_set_auth_algs(struct net_device *dev, u32 value)
 {
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        int ret = 0;
 
        if ((value & AUTH_ALG_SHARED_KEY) && (value & AUTH_ALG_OPEN_SYSTEM)) {
@@ -345,7 +345,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
        int ret = 0;
        u32 wep_key_idx, wep_key_len, wep_total_len;
        struct ndis_802_11_wep *pwep = NULL;
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct security_priv *psecuritypriv = &padapter->securitypriv;
 
@@ -617,7 +617,7 @@ static int rtw_wx_get_name(struct net_device *dev,
                           struct iw_request_info *info,
                           union iwreq_data *wrqu, char *extra)
 {
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        u32 ht_ielen = 0;
        char *p;
        u8 ht_cap = false;
@@ -669,7 +669,7 @@ static int rtw_wx_get_freq(struct net_device *dev,
                           struct iw_request_info *info,
                           union iwreq_data *wrqu, char *extra)
 {
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        struct  mlme_priv       *pmlmepriv = &padapter->mlmepriv;
        struct wlan_bssid_ex  *pcur_bss = &pmlmepriv->cur_network.network;
 
@@ -690,7 +690,7 @@ static int rtw_wx_get_freq(struct net_device *dev,
 static int rtw_wx_set_mode(struct net_device *dev, struct iw_request_info *a,
                           union iwreq_data *wrqu, char *b)
 {
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        enum ndis_802_11_network_infra networkType;
        int ret = 0;
 
@@ -738,7 +738,7 @@ exit:
 static int rtw_wx_get_mode(struct net_device *dev, struct iw_request_info *a,
                           union iwreq_data *wrqu, char *b)
 {
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        struct  mlme_priv       *pmlmepriv = &padapter->mlmepriv;
 
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s\n", __func__));
@@ -760,7 +760,7 @@ static int rtw_wx_set_pmkid(struct net_device *dev,
                            struct iw_request_info *a,
                            union iwreq_data *wrqu, char *extra)
 {
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        u8   j, blInserted = false;
        int  ret = false;
        struct security_priv *psecuritypriv = &padapter->securitypriv;
@@ -837,7 +837,7 @@ static int rtw_wx_get_range(struct net_device *dev,
                            union iwreq_data *wrqu, char *extra)
 {
        struct iw_range *range = (struct iw_range *)extra;
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
 
        u16 val;
@@ -925,7 +925,7 @@ static int rtw_wx_set_wap(struct net_device *dev,
                          union iwreq_data *awrq, char *extra)
 {
        uint ret = 0;
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        struct sockaddr *temp = (struct sockaddr *)awrq;
        struct  mlme_priv       *pmlmepriv = &padapter->mlmepriv;
        struct list_head *phead;
@@ -990,7 +990,7 @@ static int rtw_wx_get_wap(struct net_device *dev,
                          struct iw_request_info *info,
                          union iwreq_data *wrqu, char *extra)
 {
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        struct  mlme_priv       *pmlmepriv = &padapter->mlmepriv;
        struct wlan_bssid_ex  *pcur_bss = &pmlmepriv->cur_network.network;
 
@@ -1015,7 +1015,7 @@ static int rtw_wx_set_mlme(struct net_device *dev,
 {
        int ret = 0;
        u16 reason;
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        struct iw_mlme *mlme = (struct iw_mlme *)extra;
 
        if (!mlme)
@@ -1047,7 +1047,7 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
 {
        u8 _status = false;
        int ret = 0;
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT];
 
@@ -1133,9 +1133,11 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
                                                break;
                                        }
                                        sec_len = *(pos++); len -= 1;
-                                       if (sec_len > 0 && sec_len <= len) {
+                                       if (sec_len > 0 &&
+                                           sec_len <= len &&
+                                           sec_len <= 32) {
                                                ssid[ssid_index].ssid_length = sec_len;
-                                               memcpy(ssid[ssid_index].ssid, pos, ssid[ssid_index].ssid_length);
+                                               memcpy(ssid[ssid_index].ssid, pos, sec_len);
                                                ssid_index++;
                                        }
                                        pos += sec_len;
@@ -1176,7 +1178,7 @@ static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a,
                           union iwreq_data *wrqu, char *extra)
 {
        struct list_head *plist, *phead;
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        struct  mlme_priv       *pmlmepriv = &padapter->mlmepriv;
        struct __queue *queue   = &pmlmepriv->scanned_queue;
        struct  wlan_network    *pnetwork = NULL;
@@ -1244,7 +1246,7 @@ static int rtw_wx_set_essid(struct net_device *dev,
                            struct iw_request_info *a,
                            union iwreq_data *wrqu, char *extra)
 {
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct __queue *queue = &pmlmepriv->scanned_queue;
        struct list_head *phead;
@@ -1346,7 +1348,7 @@ static int rtw_wx_get_essid(struct net_device *dev,
                            union iwreq_data *wrqu, char *extra)
 {
        u32 len;
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        struct  mlme_priv       *pmlmepriv = &padapter->mlmepriv;
        struct wlan_bssid_ex  *pcur_bss = &pmlmepriv->cur_network.network;
 
@@ -1451,7 +1453,7 @@ static int rtw_wx_get_rate(struct net_device *dev,
 {
        u16 max_rate = 0;
 
-       max_rate = rtw_get_cur_max_rate(rtw_netdev_priv(dev));
+       max_rate = rtw_get_cur_max_rate(netdev_priv(dev));
 
        if (max_rate == 0)
                return -EPERM;
@@ -1466,7 +1468,7 @@ static int rtw_wx_set_rts(struct net_device *dev,
                          struct iw_request_info *info,
                          union iwreq_data *wrqu, char *extra)
 {
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
 
        if (wrqu->rts.disabled) {
                padapter->registrypriv.rts_thresh = 2347;
@@ -1487,7 +1489,7 @@ static int rtw_wx_get_rts(struct net_device *dev,
                          struct iw_request_info *info,
                          union iwreq_data *wrqu, char *extra)
 {
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
 
        DBG_88E("%s, rts_thresh =%d\n", __func__, padapter->registrypriv.rts_thresh);
 
@@ -1502,7 +1504,7 @@ static int rtw_wx_set_frag(struct net_device *dev,
                           struct iw_request_info *info,
                           union iwreq_data *wrqu, char *extra)
 {
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
 
        if (wrqu->frag.disabled) {
                padapter->xmitpriv.frag_len = MAX_FRAG_THRESHOLD;
@@ -1523,7 +1525,7 @@ static int rtw_wx_get_frag(struct net_device *dev,
                           struct iw_request_info *info,
                           union iwreq_data *wrqu, char *extra)
 {
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
 
        DBG_88E("%s, frag_len =%d\n", __func__, padapter->xmitpriv.frag_len);
 
@@ -1554,7 +1556,7 @@ static int rtw_wx_set_enc(struct net_device *dev,
        enum ndis_802_11_auth_mode authmode;
 
        struct iw_point *erq = &wrqu->encoding;
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
 
        DBG_88E("+%s, flags = 0x%x\n", __func__, erq->flags);
@@ -1663,7 +1665,7 @@ static int rtw_wx_get_enc(struct net_device *dev,
                          union iwreq_data *wrqu, char *keybuf)
 {
        uint key;
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        struct iw_point *erq = &wrqu->encoding;
        struct  mlme_priv       *pmlmepriv = &padapter->mlmepriv;
 
@@ -1738,7 +1740,7 @@ static int rtw_wx_set_gen_ie(struct net_device *dev,
                             struct iw_request_info *info,
                             union iwreq_data *wrqu, char *extra)
 {
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
 
        return rtw_set_wpa_ie(padapter, extra, wrqu->data.length);
 }
@@ -1747,7 +1749,7 @@ static int rtw_wx_set_auth(struct net_device *dev,
                           struct iw_request_info *info,
                           union iwreq_data *wrqu, char *extra)
 {
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        struct iw_param *param = (struct iw_param *)&wrqu->param;
        int ret = 0;
 
@@ -1917,7 +1919,7 @@ static int dummy(struct net_device *dev, struct iw_request_info *a,
 static int wpa_set_param(struct net_device *dev, u8 name, u32 value)
 {
        uint ret = 0;
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
 
        switch (name) {
        case IEEE_PARAM_WPA_ENABLED:
@@ -1972,7 +1974,7 @@ static int wpa_set_param(struct net_device *dev, u8 name, u32 value)
 static int wpa_mlme(struct net_device *dev, u32 command, u32 reason)
 {
        int ret = 0;
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
 
        switch (command) {
        case IEEE_MLME_STA_DEAUTH:
@@ -2009,7 +2011,7 @@ static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p)
                break;
 
        case IEEE_CMD_SET_WPA_IE:
-               ret =  rtw_set_wpa_ie(rtw_netdev_priv(dev),
+               ret =  rtw_set_wpa_ie(netdev_priv(dev),
                                      (char *)param->u.wpa_ie.data, (u16)param->u.wpa_ie.len);
                break;
 
@@ -2153,7 +2155,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
        u32 wep_key_idx, wep_key_len, wep_total_len;
        struct ndis_802_11_wep   *pwep = NULL;
        struct sta_info *psta = NULL, *pbcmc_sta = NULL;
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        struct mlme_priv        *pmlmepriv = &padapter->mlmepriv;
        struct security_priv *psecuritypriv = &padapter->securitypriv;
        struct sta_priv *pstapriv = &padapter->stapriv;
@@ -2379,7 +2381,7 @@ exit:
 static int rtw_set_beacon(struct net_device *dev, struct ieee_param *param, int len)
 {
        int ret = 0;
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct sta_priv *pstapriv = &padapter->stapriv;
        unsigned char *pbuf = param->u.bcn_ie.buf;
@@ -2404,7 +2406,7 @@ static int rtw_set_beacon(struct net_device *dev, struct ieee_param *param, int
 
 static int rtw_hostapd_sta_flush(struct net_device *dev)
 {
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
 
        DBG_88E("%s\n", __func__);
 
@@ -2417,7 +2419,7 @@ static int rtw_add_sta(struct net_device *dev, struct ieee_param *param)
 {
        int ret = 0;
        struct sta_info *psta = NULL;
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct sta_priv *pstapriv = &padapter->stapriv;
 
@@ -2470,7 +2472,7 @@ static int rtw_add_sta(struct net_device *dev, struct ieee_param *param)
 static int rtw_del_sta(struct net_device *dev, struct ieee_param *param)
 {
        struct sta_info *psta = NULL;
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct sta_priv *pstapriv = &padapter->stapriv;
        int updated = 0;
@@ -2505,7 +2507,7 @@ static int rtw_ioctl_get_sta_data(struct net_device *dev, struct ieee_param *par
 {
        int ret = 0;
        struct sta_info *psta = NULL;
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct sta_priv *pstapriv = &padapter->stapriv;
        struct ieee_param_ex *param_ex = (struct ieee_param_ex *)param;
@@ -2561,7 +2563,7 @@ static int rtw_get_sta_wpaie(struct net_device *dev, struct ieee_param *param)
 {
        int ret = 0;
        struct sta_info *psta = NULL;
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct sta_priv *pstapriv = &padapter->stapriv;
 
@@ -2597,7 +2599,7 @@ static int rtw_get_sta_wpaie(struct net_device *dev, struct ieee_param *param)
 static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param, int len)
 {
        unsigned char wps_oui[4] = {0x0, 0x50, 0xf2, 0x04};
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
        int ie_len;
@@ -2632,7 +2634,7 @@ static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param,
 
 static int rtw_set_wps_probe_resp(struct net_device *dev, struct ieee_param *param, int len)
 {
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        int ie_len;
 
@@ -2661,7 +2663,7 @@ static int rtw_set_wps_probe_resp(struct net_device *dev, struct ieee_param *par
 
 static int rtw_set_wps_assoc_resp(struct net_device *dev, struct ieee_param *param, int len)
 {
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        int ie_len;
 
@@ -2691,7 +2693,7 @@ static int rtw_set_wps_assoc_resp(struct net_device *dev, struct ieee_param *par
 
 static int rtw_set_hidden_ssid(struct net_device *dev, struct ieee_param *param, int len)
 {
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
@@ -2715,7 +2717,7 @@ static int rtw_set_hidden_ssid(struct net_device *dev, struct ieee_param *param,
 
 static int rtw_ioctl_acl_remove_sta(struct net_device *dev, struct ieee_param *param, int len)
 {
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
 
        if (!check_fwstate(pmlmepriv, WIFI_AP_STATE))
@@ -2729,7 +2731,7 @@ static int rtw_ioctl_acl_remove_sta(struct net_device *dev, struct ieee_param *p
 
 static int rtw_ioctl_acl_add_sta(struct net_device *dev, struct ieee_param *param, int len)
 {
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
 
        if (!check_fwstate(pmlmepriv, WIFI_AP_STATE))
@@ -2743,7 +2745,7 @@ static int rtw_ioctl_acl_add_sta(struct net_device *dev, struct ieee_param *para
 
 static int rtw_ioctl_set_macaddr_acl(struct net_device *dev, struct ieee_param *param, int len)
 {
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
 
        if (!check_fwstate(pmlmepriv, WIFI_AP_STATE))
@@ -2758,7 +2760,7 @@ static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p)
 {
        struct ieee_param *param;
        int ret = 0;
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
 
        /*
         * this function is expect to call in master mode, which allows no power saving
@@ -2839,7 +2841,7 @@ static int rtw_wx_set_priv(struct net_device *dev,
        int ret = 0;
        int len = 0;
        char *ext;
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        struct iw_point *dwrq = (struct iw_point *)awrq;
 
        if (dwrq->length == 0)
@@ -2957,7 +2959,7 @@ static iw_handler rtw_handlers[] = {
 
 static struct iw_statistics *rtw_get_wireless_stats(struct net_device *dev)
 {
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        struct iw_statistics *piwstats = &padapter->iwstats;
        int tmp_level = 0;
        int tmp_qual = 0;
index c80d30f31869cd17172bd067f0390935eee6a60f..a826228cbbe989984896cc615cecc970db5ef9a1 100644 (file)
@@ -187,7 +187,7 @@ static void loadparam(struct adapter *padapter, struct net_device *pnetdev)
 
 static int rtw_net_set_mac_address(struct net_device *pnetdev, void *p)
 {
-       struct adapter *padapter = rtw_netdev_priv(pnetdev);
+       struct adapter *padapter = netdev_priv(pnetdev);
        struct sockaddr *addr = p;
 
        if (!padapter->bup)
@@ -198,7 +198,7 @@ static int rtw_net_set_mac_address(struct net_device *pnetdev, void *p)
 
 static struct net_device_stats *rtw_net_get_stats(struct net_device *pnetdev)
 {
-       struct adapter *padapter = rtw_netdev_priv(pnetdev);
+       struct adapter *padapter = netdev_priv(pnetdev);
        struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
        struct recv_priv *precvpriv = &padapter->recvpriv;
 
@@ -248,7 +248,7 @@ static unsigned int rtw_classify8021d(struct sk_buff *skb)
 static u16 rtw_select_queue(struct net_device *dev, struct sk_buff *skb,
                            struct net_device *sb_dev)
 {
-       struct adapter *padapter = rtw_netdev_priv(dev);
+       struct adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
 
        skb->priority = rtw_classify8021d(skb);
@@ -296,21 +296,19 @@ static const struct device_type wlan_type = {
        .name = "wlan",
 };
 
-struct net_device *rtw_init_netdev(struct adapter *old_padapter)
+struct net_device *rtw_init_netdev(void)
 {
        struct adapter *padapter;
-       struct net_device *pnetdev = NULL;
+       struct net_device *pnetdev;
 
        RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+init_net_dev\n"));
 
-       if (old_padapter)
-               pnetdev = rtw_alloc_etherdev_with_old_priv((void *)old_padapter);
-
+       pnetdev = alloc_etherdev_mq(sizeof(struct adapter), 4);
        if (!pnetdev)
                return NULL;
 
        pnetdev->dev.type = &wlan_type;
-       padapter = rtw_netdev_priv(pnetdev);
+       padapter = netdev_priv(pnetdev);
        padapter->pnetdev = pnetdev;
        DBG_88E("register rtw_netdev_ops to netdev_ops\n");
        pnetdev->netdev_ops = &rtw_netdev_ops;
@@ -534,7 +532,7 @@ static int _netdev_open(struct net_device *pnetdev)
 {
        uint status;
        int err;
-       struct adapter *padapter = rtw_netdev_priv(pnetdev);
+       struct adapter *padapter = netdev_priv(pnetdev);
        struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv;
 
        RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+88eu_drv - dev_open\n"));
@@ -603,7 +601,7 @@ netdev_open_error:
 int netdev_open(struct net_device *pnetdev)
 {
        int ret;
-       struct adapter *padapter = rtw_netdev_priv(pnetdev);
+       struct adapter *padapter = netdev_priv(pnetdev);
 
        if (mutex_lock_interruptible(&padapter->hw_init_mutex))
                return -ERESTARTSYS;
@@ -689,7 +687,7 @@ void rtw_ips_dev_unload(struct adapter *padapter)
 
 static int netdev_close(struct net_device *pnetdev)
 {
-       struct adapter *padapter = rtw_netdev_priv(pnetdev);
+       struct adapter *padapter = netdev_priv(pnetdev);
 
        RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+88eu_drv - drv_close\n"));
 
index 4d6d0347ab8e235149231cd01be7fe7619e6d6ee..57453df0ced868427f2c7f154b141f24b1727ab3 100644 (file)
@@ -24,37 +24,6 @@ void _rtw_init_queue(struct __queue *pqueue)
        spin_lock_init(&pqueue->lock);
 }
 
-struct net_device *rtw_alloc_etherdev_with_old_priv(void *old_priv)
-{
-       struct net_device *netdev;
-       struct rtw_netdev_priv_indicator *pnpi;
-
-       netdev = alloc_etherdev_mq(sizeof(struct rtw_netdev_priv_indicator), 4);
-       if (!netdev)
-               return NULL;
-
-       pnpi = netdev_priv(netdev);
-       pnpi->priv = old_priv;
-
-       return netdev;
-}
-
-void rtw_free_netdev(struct net_device *netdev)
-{
-       struct rtw_netdev_priv_indicator *pnpi;
-
-       if (!netdev)
-               return;
-
-       pnpi = netdev_priv(netdev);
-
-       if (!pnpi->priv)
-               return;
-
-       vfree(pnpi->priv);
-       free_netdev(netdev);
-}
-
 void rtw_buf_free(u8 **buf, u32 *buf_len)
 {
        *buf_len = 0;
index b5209627fd1af06e5269ba6c0627742c0ec1bbaf..f5763a9d70c585e1aa7468f998792de0e776e9ab 100644 (file)
@@ -76,7 +76,7 @@ int rtw_android_cmdstr_to_num(char *cmdstr)
 static int rtw_android_get_rssi(struct net_device *net, char *command,
                                int total_len)
 {
-       struct adapter *padapter = rtw_netdev_priv(net);
+       struct adapter *padapter = netdev_priv(net);
        struct  mlme_priv       *pmlmepriv = &padapter->mlmepriv;
        struct  wlan_network    *pcur_network = &pmlmepriv->cur_network;
        int bytes_written = 0;
@@ -93,7 +93,7 @@ static int rtw_android_get_rssi(struct net_device *net, char *command,
 static int rtw_android_get_link_speed(struct net_device *net, char *command,
                                      int total_len)
 {
-       struct adapter *padapter = rtw_netdev_priv(net);
+       struct adapter *padapter = netdev_priv(net);
        u16 link_speed;
 
        link_speed = rtw_get_cur_max_rate(padapter) / 10;
@@ -111,7 +111,7 @@ static int rtw_android_get_macaddr(struct net_device *net, char *command,
 static int android_set_cntry(struct net_device *net, char *command,
                             int total_len)
 {
-       struct adapter *adapter = rtw_netdev_priv(net);
+       struct adapter *adapter = netdev_priv(net);
        char *country_code = command + strlen(android_wifi_cmd_str[ANDROID_WIFI_CMD_COUNTRY]) + 1;
        int ret;
 
index efad43d8e465d9b2a41a5454a322ba09800ab5f6..518e9feb3f46faa038be9569ffd23bcfd029f4eb 100644 (file)
@@ -326,26 +326,23 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
                                        struct usb_interface *pusb_intf,
                                        const struct usb_device_id *pdid)
 {
-       struct adapter *padapter = NULL;
-       struct net_device *pnetdev = NULL;
+       struct adapter *padapter;
+       struct net_device *pnetdev;
        struct net_device *pmondev;
        int status = _FAIL;
 
-       padapter = vzalloc(sizeof(*padapter));
-       if (!padapter)
-               goto exit;
+       pnetdev = rtw_init_netdev();
+       if (!pnetdev)
+               return NULL;
+       SET_NETDEV_DEV(pnetdev, dvobj_to_dev(dvobj));
+
+       padapter = netdev_priv(pnetdev);
        padapter->dvobj = dvobj;
        dvobj->if1 = padapter;
 
        padapter->bDriverStopped = true;
        mutex_init(&padapter->hw_init_mutex);
 
-       pnetdev = rtw_init_netdev(padapter);
-       if (!pnetdev)
-               goto free_adapter;
-       SET_NETDEV_DEV(pnetdev, dvobj_to_dev(dvobj));
-       padapter = rtw_netdev_priv(pnetdev);
-
        if (padapter->registrypriv.monitor_enable) {
                pmondev = rtl88eu_mon_init();
                if (!pmondev)
@@ -421,13 +418,9 @@ free_hal_data:
                kfree(padapter->HalData);
 free_adapter:
        if (status != _SUCCESS) {
-               if (pnetdev)
-                       rtw_free_netdev(pnetdev);
-               else
-                       vfree(padapter);
+               free_netdev(pnetdev);
                padapter = NULL;
        }
-exit:
        return padapter;
 }
 
@@ -453,7 +446,7 @@ static void rtw_usb_if1_deinit(struct adapter *if1)
        pr_debug("+r871xu_dev_remove, hw_init_completed=%d\n",
                 if1->hw_init_completed);
        rtw_free_drv_sw(if1);
-       rtw_free_netdev(pnetdev);
+       free_netdev(pnetdev);
 }
 
 static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device_id *pdid)
index b0efa2eb705ec4f4b11c385d0f7e14004423a254..a9c42fb80583371bd1c6174b2674ac43cf4e6670 100644 (file)
@@ -164,7 +164,7 @@ static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb)
 
 int rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev)
 {
-       struct adapter *padapter = rtw_netdev_priv(pnetdev);
+       struct adapter *padapter = netdev_priv(pnetdev);
        struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        s32 res = 0;
index 963a2ffbc1fb0292dfbc4c5d2587ec0f091700e9..39f5a6a7346a558cf6db85fb425dfefb02966c08 100644 (file)
@@ -27,6 +27,7 @@ config RTLLIB_CRYPTO_CCMP
 config RTLLIB_CRYPTO_TKIP
        tristate "Support for rtllib TKIP crypto"
        depends on RTLLIB
+       select CRYPTO
        select CRYPTO_LIB_ARC4
        select CRYPTO_MICHAEL_MIC
        default y
index 16bcee13f64b580d40b72828a478ddcabf708245..407effde5e71aff2d31107c6988241a53e4fec3d 100644 (file)
@@ -406,9 +406,10 @@ static int _rtl92e_wx_set_scan(struct net_device *dev,
                struct iw_scan_req *req = (struct iw_scan_req *)b;
 
                if (req->essid_len) {
-                       ieee->current_network.ssid_len = req->essid_len;
-                       memcpy(ieee->current_network.ssid, req->essid,
-                              req->essid_len);
+                       int len = min_t(int, req->essid_len, IW_ESSID_MAX_SIZE);
+
+                       ieee->current_network.ssid_len = len;
+                       memcpy(ieee->current_network.ssid, req->essid, len);
                }
        }
 
index b6fee7230ce0588d570fcc9ac8658e8aaa964236..b0e01ee65f7f8b10d28694866b4153f92349c560 100644 (file)
@@ -612,9 +612,9 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee,
                pHTInfo->RxReorderDropCounter++;
                {
                        int i;
-                       for (i = 0; i < prxb->nr_subframes; i++) {
+                       for (i = 0; i < prxb->nr_subframes; i++)
                                dev_kfree_skb(prxb->subframes[i]);
-                       }
+
                        kfree(prxb);
                        prxb = NULL;
                }
@@ -632,11 +632,11 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee,
                pTS->rx_indicate_seq = (pTS->rx_indicate_seq + 1) % 4096;
                bMatchWinStart = true;
        } else if (SN_LESS(WinEnd, SeqNum)) {
-               if (SeqNum >= (WinSize - 1)) {
+               if (SeqNum >= (WinSize - 1))
                        pTS->rx_indicate_seq = SeqNum + 1 - WinSize;
-               } else {
+               else
                        pTS->rx_indicate_seq = 4095 - (WinSize - (SeqNum + 1)) + 1;
-               }
+
                IEEE80211_DEBUG(IEEE80211_DL_REORDER, "Window Shift! IndicateSeq: %d, NewSeq: %d\n", pTS->rx_indicate_seq, SeqNum);
        }
 
@@ -674,9 +674,9 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee,
                                list_add_tail(&pReorderEntry->List, &ieee->RxReorder_Unused_List);
                                {
                                        int i;
-                                       for (i = 0; i < prxb->nr_subframes; i++) {
+                                       for (i = 0; i < prxb->nr_subframes; i++)
                                                dev_kfree_skb(prxb->subframes[i]);
-                                       }
+
                                        kfree(prxb);
                                        prxb = NULL;
                                }
@@ -693,9 +693,9 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee,
                        IEEE80211_DEBUG(IEEE80211_DL_ERR, "RxReorderIndicatePacket(): There is no reorder entry!! Packet is dropped!!\n");
                        {
                                int i;
-                               for (i = 0; i < prxb->nr_subframes; i++) {
+                               for (i = 0; i < prxb->nr_subframes; i++)
                                        dev_kfree_skb(prxb->subframes[i]);
-                               }
+
                                kfree(prxb);
                                prxb = NULL;
                        }
@@ -785,13 +785,12 @@ static u8 parse_subframe(struct ieee80211_device *ieee,
                bIsAggregateFrame = true;
        }
 
-       if (IEEE80211_QOS_HAS_SEQ(fc)) {
+       if (IEEE80211_QOS_HAS_SEQ(fc))
                LLCOffset += 2;
-       }
 
-       if (rx_stats->bContainHTC) {
+       if (rx_stats->bContainHTC)
                LLCOffset += HTCLNG;
-       }
+
        // Null packet, don't indicate it to upper layer
        ChkLength = LLCOffset;/* + (Frame_WEP(frame)!=0 ?Adapter->MgntInfo.SecurityInfo.EncryptionHeadOverhead:0);*/
 
@@ -855,13 +854,11 @@ static u8 parse_subframe(struct ieee80211_device *ieee,
 
                        if (skb->len != 0) {
                                nPadding_Length = 4 - ((nSubframe_Length + ETHERNET_HEADER_SIZE) % 4);
-                               if (nPadding_Length == 4) {
+                               if (nPadding_Length == 4)
                                        nPadding_Length = 0;
-                               }
 
-                               if (skb->len < nPadding_Length) {
+                               if (skb->len < nPadding_Length)
                                        return 0;
-                               }
 
                                skb_pull(skb, nPadding_Length);
                        }
@@ -1248,9 +1245,8 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
                TID = Frame_QoSTID(skb->data);
                SeqNum = WLAN_GET_SEQ_SEQ(sc);
                GetTs(ieee, (struct ts_common_info **)&pTS, hdr->addr2, TID, RX_DIR, true);
-               if (TID != 0 && TID != 3) {
+               if (TID != 0 && TID != 3)
                        ieee->bis_any_nonbepkts = true;
-               }
        }
 //added by amy for reorder
        /* skb: hdr + (possible reassembled) full plaintext payload */
@@ -1262,9 +1258,9 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
        /* qos data packets & reserved bit is 1 */
        if (parse_subframe(ieee, skb, rx_stats, rxb, src, dst) == 0) {
                /* only to free rxb, and not submit the packets to upper layer */
-               for (i = 0; i < rxb->nr_subframes; i++) {
+               for (i = 0; i < rxb->nr_subframes; i++)
                        dev_kfree_skb(rxb->subframes[i]);
-               }
+
                kfree(rxb);
                rxb = NULL;
                goto rx_dropped;
@@ -1523,11 +1519,9 @@ static inline void ieee80211_extract_country_ie(
                // some AP (e.g. Cisco 1242) don't include country IE in their
                // probe response frame.
                //
-               if (IS_EQUAL_CIE_SRC(ieee, addr2)) {
+               if (IS_EQUAL_CIE_SRC(ieee, addr2))
                        UPDATE_CIE_WATCHDOG(ieee);
-               }
        }
-
 }
 
 int ieee80211_parse_info_param(struct ieee80211_device *ieee,
index bd8914645e95416b0f05a7341544f0c09764dbcc..96e6aaf859ecc4a5793c8cc0b1074a08043bbe82 100644 (file)
@@ -301,9 +301,9 @@ static void ieee80211_tx_query_agg_cap(struct ieee80211_device *ieee,
        if (is_multicast_ether_addr(hdr->addr1))
                return;
        //check packet and mode later
-       if (!ieee->GetNmodeSupportBySecCfg(ieee->dev)) {
+       if (!ieee->GetNmodeSupportBySecCfg(ieee->dev))
                return;
-       }
+
        if (pHTInfo->bCurrentAMPDUEnable) {
                if (!GetTs(ieee, (struct ts_common_info **)(&pTxTs), hdr->addr1, skb->priority, TX_DIR, true)) {
                        printk("===>can't get TS\n");
index 22373c0afebc19dee212da33f39beb36f2a28993..78cc8f357bbce44b4ef9c4cfb4c46fba0fea1a0f 100644 (file)
@@ -184,9 +184,8 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee,
        //      printk("WPA IE\n");
                u8 *p = buf;
                p += sprintf(p, "wpa_ie=");
-               for (i = 0; i < network->wpa_ie_len; i++) {
+               for (i = 0; i < network->wpa_ie_len; i++)
                        p += sprintf(p, "%02x", network->wpa_ie[i]);
-               }
 
                memset(&iwe, 0, sizeof(iwe));
                iwe.cmd = IWEVCUSTOM;
@@ -199,9 +198,8 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee,
 
                u8 *p = buf;
                p += sprintf(p, "rsn_ie=");
-               for (i = 0; i < network->rsn_ie_len; i++) {
+               for (i = 0; i < network->rsn_ie_len; i++)
                        p += sprintf(p, "%02x", network->rsn_ie[i]);
-               }
 
                memset(&iwe, 0, sizeof(iwe));
                iwe.cmd = IWEVCUSTOM;
index ec33fb9122e96092ba1919f3aa20fc730ac9ae9e..4013107cd93a256f1a54bd3accbe4a78c72f2c43 100644 (file)
@@ -46,9 +46,9 @@
 #define KEY_BUF_SIZE    5
 
 #define        RX_SMOOTH_FACTOR                20
-#define DMESG(x, a...)
-#define DMESGW(x, a...)
-#define DMESGE(x, a...)
+#define DMESG(x, a...)  no_printk(x, ##a)
+#define DMESGW(x, a...) no_printk(x, ##a)
+#define DMESGE(x, a...) no_printk(x, ##a)
 extern u32 rt_global_debug_component;
 #define RT_TRACE(component, x, args...) \
        do {                                                    \
index 175bb8b153893c66acb38d524555d868872a0f44..e6ff310f3e90391027019dde8494552386e244bd 100644 (file)
@@ -276,7 +276,7 @@ static int rtl8180_wx_get_range(struct net_device *dev,
        range->min_pmp = 0;
        range->max_pmp = 5000000;
        range->min_pmt = 0;
-       range->max_pmt = 65535*1000;
+       range->max_pmt = 65535 * 1000;
        range->pmp_flags = IW_POWER_PERIOD;
        range->pmt_flags = IW_POWER_TIMEOUT;
        range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R;
@@ -331,8 +331,10 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
                struct iw_scan_req *req = (struct iw_scan_req *)b;
 
                if (req->essid_len) {
-                       ieee->current_network.ssid_len = req->essid_len;
-                       memcpy(ieee->current_network.ssid, req->essid, req->essid_len);
+                       int len = min_t(int, req->essid_len, IW_ESSID_MAX_SIZE);
+
+                       ieee->current_network.ssid_len = len;
+                       memcpy(ieee->current_network.ssid, req->essid, len);
                }
        }
 
@@ -517,14 +519,14 @@ static int r8192_wx_set_enc(struct net_device *dev,
        /* sometimes, the length is zero while we do not type key value */
        if (wrqu->encoding.length != 0) {
                for (i = 0; i < 4; i++) {
-                       hwkey[i] |=  key[4*i+0]&mask;
-                       if (i == 1 && (4*i+1) == wrqu->encoding.length)
+                       hwkey[i] |=  key[4 * i + 0] & mask;
+                       if (i == 1 && (4 * i + 1) == wrqu->encoding.length)
                                mask = 0x00;
-                       if (i == 3 && (4*i+1) == wrqu->encoding.length)
+                       if (i == 3 && (4 * i + 1) == wrqu->encoding.length)
                                mask = 0x00;
-                       hwkey[i] |= (key[4*i+1]&mask)<<8;
-                       hwkey[i] |= (key[4*i+2]&mask)<<16;
-                       hwkey[i] |= (key[4*i+3]&mask)<<24;
+                       hwkey[i] |= (key[4 * i + 1] & mask) << 8;
+                       hwkey[i] |= (key[4 * i + 2] & mask) << 16;
+                       hwkey[i] |= (key[4 * i + 3] & mask) << 24;
                }
 
                #define CONF_WEP40  0x4
@@ -877,12 +879,10 @@ static iw_handler r8192_wx_handlers[] = {
 
 
 static const struct iw_priv_args r8192_private_args[] = {
-
        {
                SIOCIWFIRSTPRIV + 0x0,
                IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc"
        },
-
        {
                SIOCIWFIRSTPRIV + 0x1,
                IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan"
@@ -895,9 +895,7 @@ static const struct iw_priv_args r8192_private_args[] = {
        {
                SIOCIWFIRSTPRIV + 0x3,
                IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "forcereset"
-
        }
-
 };
 
 static iw_handler r8192_private_handler[] = {
index 0b56bd3ac4d01d9e046bd1713cc872ae9aed5deb..5cd651a0de75a900d1abadb9b1b987afd70e9d11 100644 (file)
 #define MAX_AMSDU_XMITBUF_SZ 8704
 #define MAX_TXAGG_XMITBUF_SZ 16384 /*16k*/
 
-
 #define tx_cmd tx_desc
 
-
 /*
  *defined for TX DESC Operation
  */
@@ -89,10 +87,9 @@ struct tx_desc {
        __le32 txdw7;
 };
 
-
 union txdesc {
        struct tx_desc txdesc;
-       unsigned int value[TXDESC_SIZE>>2];
+       unsigned int value[TXDESC_SIZE >> 2];
 };
 
 int r8712_xmitframe_complete(struct _adapter *padapter,
index 18116469bd31636532e28ab8858726202969db65..75716f59044d9c76458ceb4816fb232157f21da1 100644 (file)
@@ -192,8 +192,10 @@ u8 r8712_sitesurvey_cmd(struct _adapter *padapter,
        psurveyPara->ss_ssidlen = 0;
        memset(psurveyPara->ss_ssid, 0, IW_ESSID_MAX_SIZE + 1);
        if (pssid && pssid->SsidLength) {
-               memcpy(psurveyPara->ss_ssid, pssid->Ssid, pssid->SsidLength);
-               psurveyPara->ss_ssidlen = cpu_to_le32(pssid->SsidLength);
+               int len = min_t(int, pssid->SsidLength, IW_ESSID_MAX_SIZE);
+
+               memcpy(psurveyPara->ss_ssid, pssid->Ssid, len);
+               psurveyPara->ss_ssidlen = cpu_to_le32(len);
        }
        set_fwstate(pmlmepriv, _FW_UNDER_SURVEY);
        r8712_enqueue_cmd(pcmdpriv, ph2c);
index 81de5a9e6b679a1799019194f7395cf49dd45ce4..60dd798a6e5157c18f2f019ba3d7f30afa2bd574 100644 (file)
@@ -924,7 +924,7 @@ static int r871x_wx_set_priv(struct net_device *dev,
        struct iw_point *dwrq = (struct iw_point *)awrq;
 
        len = dwrq->length;
-       ext = memdup_user(dwrq->pointer, len);
+       ext = strndup_user(dwrq->pointer, len);
        if (IS_ERR(ext))
                return PTR_ERR(ext);
 
index 6074383ec0b508279340803f86467699f763119e..f5886b39b3b5007d56b969402e1cc976f64adf51 100644 (file)
@@ -728,7 +728,8 @@ void r8712_joinbss_event_callback(struct _adapter *adapter, u8 *pbuf)
                                             r8712_find_network(&pmlmepriv->
                                             scanned_queue,
                                             cur_network->network.MacAddress);
-                                       pcur_wlan->fixed = false;
+                                       if (pcur_wlan)
+                                               pcur_wlan->fixed = false;
 
                                        pcur_sta = r8712_get_stainfo(pstapriv,
                                             cur_network->network.MacAddress);
index 45065fd3fd5d5a08e4b18835346e814c9db64531..afa620ceb2d86e328deea00e669054125a999140 100644 (file)
@@ -1,5 +1,4 @@
 TODO:
-- find and remove code blocks guarded by never set CONFIG_FOO defines
 - find and remove remaining code valid only for 5 GHz. Most of the obvious
   ones have been removed, but things like channel > 14 still exist.
 - find and remove any code for other chips that is left over
index b6f944b37b08f11c1cdf27d1006737ea495c12ee..3cd9c61eec991ef0be2a6fc8c9a34f8c30ce9049 100644 (file)
 #include <rtw_debug.h>
 #include <asm/unaligned.h>
 
-extern unsigned char RTW_WPA_OUI[];
-extern unsigned char WMM_OUI[];
-extern unsigned char WPS_OUI[];
-extern unsigned char P2P_OUI[];
-
 void init_mlme_ap_info(struct adapter *padapter)
 {
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
@@ -63,8 +58,6 @@ static void update_BCNTIM(struct adapter *padapter)
        struct wlan_bssid_ex *pnetwork_mlmeext = &pmlmeinfo->network;
        unsigned char *pie = pnetwork_mlmeext->IEs;
 
-       /* DBG_871X("%s\n", __func__); */
-
        /* update TIM IE */
        /* if (pstapriv->tim_bitmap) */
        if (true) {
@@ -85,7 +78,7 @@ static void update_BCNTIM(struct adapter *padapter)
 
                        premainder_ie = p + tim_ielen;
 
-                       tim_ie_offset = (sint)(p - pie);
+                       tim_ie_offset = (signed int)(p - pie);
 
                        remainder_ielen = pnetwork_mlmeext->IELength - tim_ie_offset - tim_ielen;
 
@@ -270,10 +263,6 @@ void expire_timeout_chk(struct adapter *padapter)
        while (phead != plist) {
                psta = container_of(plist, struct sta_info, asoc_list);
                plist = get_next(plist);
-#ifdef CONFIG_AUTO_AP_MODE
-               if (psta->isrc)
-                       continue;
-#endif
                if (chk_sta_is_alive(psta) || !psta->expire_to) {
                        psta->expire_to = pstapriv->expire_to;
                        psta->keep_alive_trycnt = 0;
@@ -560,8 +549,6 @@ void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta)
        /* set intf_tag to if1 */
        /* psta->intf_tag = 0; */
 
-       DBG_871X("%s\n", __func__);
-
        /* psta->mac_id = psta->aid+4; */
        /* psta->mac_id = psta->aid+1;//alloc macid when call rtw_alloc_stainfo(), */
        /* release macid when call rtw_free_stainfo() */
@@ -717,13 +704,11 @@ static void update_hw_ht_param(struct adapter *padapter)
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
 
-       DBG_871X("%s\n", __func__);
-
-       /* handle A-MPDU parameter field */
-       /*
-               AMPDU_para [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k
-               AMPDU_para [4:2]:Min MPDU Start Spacing
-       */
+       /* handle A-MPDU parameter field
+        *
+        *      AMPDU_para [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k
+        *      AMPDU_para [4:2]:Min MPDU Start Spacing
+        */
        max_AMPDU_len = pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x03;
 
        min_MPDU_spacing = (
@@ -771,8 +756,6 @@ void start_bss_network(struct adapter *padapter, u8 *pbuf)
        struct HT_info_element *pht_info = NULL;
        u8 cbw40_enable = 0;
 
-       /* DBG_871X("%s\n", __func__); */
-
        bcn_interval = (u16)pnetwork->Configuration.BeaconPeriod;
        cur_channel = pnetwork->Configuration.DSConfig;
        cur_bwmode = CHANNEL_WIDTH_20;
@@ -924,12 +907,10 @@ void start_bss_network(struct adapter *padapter, u8 *pbuf)
        if (pmlmeext->bstart_bss) {
                update_beacon(padapter, WLAN_EID_TIM, NULL, true);
 
-#ifndef CONFIG_INTERRUPT_BASED_TXBCN /* other case will  tx beacon when bcn interrupt coming in. */
-               /* issue beacon frame */
-               if (send_beacon(padapter) == _FAIL)
-                       DBG_871X("issue_beacon, fail!\n");
+       /* issue beacon frame */
+       if (send_beacon(padapter) == _FAIL)
+               DBG_871X("issue_beacon, fail!\n");
 
-#endif /* CONFIG_INTERRUPT_BASED_TXBCN */
        }
 
        /* update bc/mc sta_info */
@@ -1477,8 +1458,6 @@ static int rtw_ap_set_key(
        struct cmd_priv *pcmdpriv = &(padapter->cmdpriv);
        int res = _SUCCESS;
 
-       /* DBG_871X("%s\n", __func__); */
-
        pcmd = rtw_zmalloc(sizeof(struct cmd_obj));
        if (pcmd == NULL) {
                res = _FAIL;
@@ -1532,8 +1511,6 @@ exit:
 
 int rtw_ap_set_group_key(struct adapter *padapter, u8 *key, u8 alg, int keyid)
 {
-       DBG_871X("%s\n", __func__);
-
        return rtw_ap_set_key(padapter, key, alg, keyid, 1);
 }
 
@@ -1558,14 +1535,11 @@ int rtw_ap_set_wep_key(
                alg = _NO_PRIVACY_;
        }
 
-       DBG_871X("%s\n", __func__);
-
        return rtw_ap_set_key(padapter, key, alg, keyid, set_tx);
 }
 
 static void update_bcn_fixed_ie(struct adapter *padapter)
 {
-       DBG_871X("%s\n", __func__);
 }
 
 static void update_bcn_erpinfo_ie(struct adapter *padapter)
@@ -1610,27 +1584,22 @@ static void update_bcn_erpinfo_ie(struct adapter *padapter)
 
 static void update_bcn_htcap_ie(struct adapter *padapter)
 {
-       DBG_871X("%s\n", __func__);
 }
 
 static void update_bcn_htinfo_ie(struct adapter *padapter)
 {
-       DBG_871X("%s\n", __func__);
 }
 
 static void update_bcn_rsn_ie(struct adapter *padapter)
 {
-       DBG_871X("%s\n", __func__);
 }
 
 static void update_bcn_wpa_ie(struct adapter *padapter)
 {
-       DBG_871X("%s\n", __func__);
 }
 
 static void update_bcn_wmm_ie(struct adapter *padapter)
 {
-       DBG_871X("%s\n", __func__);
 }
 
 static void update_bcn_wps_ie(struct adapter *padapter)
@@ -1648,8 +1617,6 @@ static void update_bcn_wps_ie(struct adapter *padapter)
        unsigned char *ie = pnetwork->IEs;
        u32 ielen = pnetwork->IELength;
 
-       DBG_871X("%s\n", __func__);
-
        pwps_ie = rtw_get_wps_ie(
                ie + _FIXED_IE_LENGTH_,
                ielen - _FIXED_IE_LENGTH_,
@@ -1689,26 +1656,6 @@ static void update_bcn_wps_ie(struct adapter *padapter)
        }
 
        kfree(pbackup_remainder_ie);
-
-       /*  deal with the case without set_tx_beacon_cmd() in update_beacon() */
-#if defined(CONFIG_INTERRUPT_BASED_TXBCN)
-       if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) {
-               u8 sr = 0;
-
-               rtw_get_wps_attr_content(
-                       pwps_ie_src,
-                       wps_ielen,
-                       WPS_ATTR_SELECTED_REGISTRAR,
-                       (u8 *)(&sr),
-                       NULL
-               );
-
-               if (sr) {
-                       set_fwstate(pmlmepriv, WIFI_UNDER_WPS);
-                       DBG_871X("%s, set WIFI_UNDER_WPS\n", __func__);
-               }
-       }
-#endif
 }
 
 static void update_bcn_p2p_ie(struct adapter *padapter)
@@ -1717,8 +1664,6 @@ static void update_bcn_p2p_ie(struct adapter *padapter)
 
 static void update_bcn_vendor_spec_ie(struct adapter *padapter, u8 *oui)
 {
-       DBG_871X("%s\n", __func__);
-
        if (!memcmp(RTW_WPA_OUI, oui, 4))
                update_bcn_wpa_ie(padapter);
 
@@ -1741,8 +1686,6 @@ void update_beacon(struct adapter *padapter, u8 ie_id, u8 *oui, u8 tx)
        struct mlme_ext_priv *pmlmeext;
        /* struct mlme_ext_info *pmlmeinfo; */
 
-       /* DBG_871X("%s\n", __func__); */
-
        if (!padapter)
                return;
 
@@ -1806,26 +1749,24 @@ void update_beacon(struct adapter *padapter, u8 ie_id, u8 *oui, u8 tx)
 
        spin_unlock_bh(&pmlmepriv->bcn_update_lock);
 
-#ifndef CONFIG_INTERRUPT_BASED_TXBCN
        if (tx) {
                /* send_beacon(padapter);//send_beacon must execute on TSR level */
                set_tx_beacon_cmd(padapter);
        }
-#endif /* CONFIG_INTERRUPT_BASED_TXBCN */
 }
 
 /*
-op_mode
-Set to 0 (HT pure) under the following conditions
-       - all STAs in the BSS are 20/40 MHz HT in 20/40 MHz BSS or
-       - all STAs in the BSS are 20 MHz HT in 20 MHz BSS
-Set to 1 (HT non-member protection) if there may be non-HT STAs
-       in both the primary and the secondary channel
-Set to 2 if only HT STAs are associated in BSS,
-       however and at least one 20 MHz HT STA is associated
-Set to 3 (HT mixed mode) when one or more non-HT STAs are associated
-       (currently non-GF HT station is considered as non-HT STA also)
-*/
+ * op_mode
+ * Set to 0 (HT pure) under the following conditions
      - all STAs in the BSS are 20/40 MHz HT in 20/40 MHz BSS or
      - all STAs in the BSS are 20 MHz HT in 20 MHz BSS
+ * Set to 1 (HT non-member protection) if there may be non-HT STAs
      in both the primary and the secondary channel
+ * Set to 2 if only HT STAs are associated in BSS,
      however and at least one 20 MHz HT STA is associated
+ * Set to 3 (HT mixed mode) when one or more non-HT STAs are associated
      (currently non-GF HT station is considered as non-HT STA also)
+ */
 static int rtw_ht_operation_update(struct adapter *padapter)
 {
        u16 cur_op_mode, new_op_mode;
@@ -2009,8 +1950,8 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta)
        if (psta->flags & WLAN_STA_HT) {
                u16 ht_capab = le16_to_cpu(psta->htpriv.ht_cap.cap_info);
 
-               DBG_871X("HT: STA %pM HT Capabilities "
-                          "Info: 0x%04x\n", MAC_ARG(psta->hwaddr), ht_capab);
+               DBG_871X("HT: STA %pM HT Capabilities Info: 0x%04x\n",
+                        MAC_ARG(psta->hwaddr), ht_capab);
 
                if (psta->no_ht_set) {
                        psta->no_ht_set = 0;
@@ -2022,10 +1963,9 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta)
                                psta->no_ht_gf_set = 1;
                                pmlmepriv->num_sta_ht_no_gf++;
                        }
-                       DBG_871X("%s STA %pM - no "
-                                  "greenfield, num of non-gf stations %d\n",
-                                  __func__, MAC_ARG(psta->hwaddr),
-                                  pmlmepriv->num_sta_ht_no_gf);
+                       DBG_871X("%s STA %pM - no greenfield, num of non-gf stations %d\n",
+                                __func__, MAC_ARG(psta->hwaddr),
+                                pmlmepriv->num_sta_ht_no_gf);
                }
 
                if ((ht_capab & IEEE80211_HT_CAP_SUP_WIDTH) == 0) {
@@ -2033,10 +1973,9 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta)
                                psta->ht_20mhz_set = 1;
                                pmlmepriv->num_sta_ht_20mhz++;
                        }
-                       DBG_871X("%s STA %pM - 20 MHz HT, "
-                                  "num of 20MHz HT STAs %d\n",
-                                  __func__, MAC_ARG(psta->hwaddr),
-                                  pmlmepriv->num_sta_ht_20mhz);
+                       DBG_871X("%s STA %pM - 20 MHz HT, num of 20MHz HT STAs %d\n",
+                                __func__, MAC_ARG(psta->hwaddr),
+                                pmlmepriv->num_sta_ht_20mhz);
                }
 
        } else {
index 3fe79169a811cacfdad93112572a7d9dd38eff32..2aaf25b48f9684e3492e9f502c8dea5b85bab206 100644 (file)
@@ -203,7 +203,7 @@ exit:
        return res;
 }
 
-static void c2h_wk_callback(_workitem * work);
+static void c2h_wk_callback(struct work_struct *work);
 int rtw_init_evt_priv(struct evt_priv *pevtpriv)
 {
        /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */
@@ -260,7 +260,7 @@ ISR/Call-Back functions can't call this sub-function.
 
 int _rtw_enqueue_cmd(struct __queue *queue, struct cmd_obj *obj)
 {
-       _irqL irqL;
+       unsigned long irqL;
 
        if (obj == NULL)
                goto exit;
@@ -279,7 +279,7 @@ exit:
 
 struct cmd_obj *_rtw_dequeue_cmd(struct __queue *queue)
 {
-       _irqL irqL;
+       unsigned long irqL;
        struct cmd_obj *obj;
 
        /* spin_lock_bh(&(queue->lock)); */
@@ -676,11 +676,10 @@ u8 rtw_createbss_cmd(struct adapter  *padapter)
        struct wlan_bssid_ex            *pdev_network = &padapter->registrypriv.dev_network;
        u8 res = _SUCCESS;
 
-       if (pmlmepriv->assoc_ssid.SsidLength == 0) {
+       if (pmlmepriv->assoc_ssid.SsidLength == 0)
                RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, (" createbss for Any SSid:%s\n", pmlmepriv->assoc_ssid.Ssid));
-       } else {
+       else
                RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, (" createbss for SSid:%s\n", pmlmepriv->assoc_ssid.Ssid));
-       }
 
        pcmd = rtw_zmalloc(sizeof(struct cmd_obj));
        if (pcmd == NULL) {
@@ -761,17 +760,16 @@ u8 rtw_joinbss_cmd(struct adapter  *padapter, struct wlan_network *pnetwork)
        struct security_priv *psecuritypriv = &padapter->securitypriv;
        struct registry_priv *pregistrypriv = &padapter->registrypriv;
        struct ht_priv          *phtpriv = &pmlmepriv->htpriv;
-       enum NDIS_802_11_NETWORK_INFRASTRUCTURE ndis_network_mode = pnetwork->network.InfrastructureMode;
+       enum ndis_802_11_network_infrastructure ndis_network_mode = pnetwork->network.InfrastructureMode;
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
        u32 tmp_len;
        u8 *ptmp = NULL;
 
-       if (pmlmepriv->assoc_ssid.SsidLength == 0) {
+       if (pmlmepriv->assoc_ssid.SsidLength == 0)
                RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("+Join cmd: Any SSid\n"));
-       } else {
+       else
                RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+Join cmd: SSid =[%s]\n", pmlmepriv->assoc_ssid.Ssid));
-       }
 
        pcmd = rtw_zmalloc(sizeof(struct cmd_obj));
        if (pcmd == NULL) {
@@ -810,11 +808,10 @@ u8 rtw_joinbss_cmd(struct adapter  *padapter, struct wlan_network *pnetwork)
 
        psecuritypriv->authenticator_ie[0] = (unsigned char)psecnetwork->IELength;
 
-       if ((psecnetwork->IELength-12) < (256-1)) {
+       if ((psecnetwork->IELength-12) < (256-1))
                memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], psecnetwork->IELength-12);
-       } else {
+       else
                memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], (256-1));
-       }
 
        psecnetwork->IELength = 0;
        /*  Added by Albert 2009/02/18 */
@@ -917,7 +914,7 @@ exit:
        return res;
 }
 
-u8 rtw_setopmode_cmd(struct adapter  *padapter, enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype, bool enqueue)
+u8 rtw_setopmode_cmd(struct adapter  *padapter, enum ndis_802_11_network_infrastructure networktype, bool enqueue)
 {
        struct  cmd_obj *ph2c;
        struct  setopmode_parm *psetop;
@@ -970,17 +967,15 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_
 
        memcpy(psetstakey_para->addr, sta->hwaddr, ETH_ALEN);
 
-       if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
+       if (check_fwstate(pmlmepriv, WIFI_STATION_STATE))
                psetstakey_para->algorithm = (unsigned char) psecuritypriv->dot11PrivacyAlgrthm;
-       } else {
+       else
                GET_ENCRY_ALGO(psecuritypriv, sta, psetstakey_para->algorithm, false);
-       }
 
-       if (unicast_key == true) {
+       if (unicast_key == true)
                memcpy(&psetstakey_para->key, &sta->dot118021x_UncstKey, 16);
-       } else {
+       else
                memcpy(&psetstakey_para->key, &psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey, 16);
-       }
 
        /* jeff: set this because at least sw key is ready */
        padapter->securitypriv.busetkipkey = true;
@@ -1875,7 +1870,7 @@ exit:
        return res;
 }
 
-static void c2h_wk_callback(_workitem *work)
+static void c2h_wk_callback(struct work_struct *work)
 {
        struct evt_priv *evtpriv = container_of(work, struct evt_priv, c2h_wk);
        struct adapter *adapter = container_of(evtpriv, struct adapter, evtpriv);
index 32ca10f01413d8fa73a6d492bc248175e6fe7478..3701336e7ff697690866137e68dd95da0aac20ca 100644 (file)
@@ -32,12 +32,7 @@ u8 fakeBTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN] = {0};
 #define REG_EFUSE_CTRL         0x0030
 #define EFUSE_CTRL                     REG_EFUSE_CTRL          /*  E-Fuse Control. */
 
-bool
-Efuse_Read1ByteFromFakeContent(
-       struct adapter *padapter,
-       u16     Offset,
-       u8 *Value);
-bool
+static bool
 Efuse_Read1ByteFromFakeContent(
        struct adapter *padapter,
        u16     Offset,
@@ -53,12 +48,7 @@ Efuse_Read1ByteFromFakeContent(
        return true;
 }
 
-bool
-Efuse_Write1ByteToFakeContent(
-       struct adapter *padapter,
-       u16     Offset,
-       u8 Value);
-bool
+static bool
 Efuse_Write1ByteToFakeContent(
        struct adapter *padapter,
        u16     Offset,
index be4cffce4f5d693e923e06df59f36c404b314517..cccbea555a32031476517cc5befde9236f34762b 100644 (file)
@@ -120,7 +120,7 @@ u8 *rtw_set_fixed_ie(unsigned char *pbuf, unsigned int len, unsigned char *sourc
 
 /*  rtw_set_ie will update frame length */
 u8 *rtw_set_ie(u8 *pbuf,
-              sint index,
+              signed int index,
               uint len,
               u8 *source,
               uint *frlen) /* frame length */
@@ -140,9 +140,9 @@ u8 *rtw_set_ie(u8 *pbuf,
 /*----------------------------------------------------------------------------
 index: the information element id index, limit is the limit for search
 -----------------------------------------------------------------------------*/
-u8 *rtw_get_ie(u8 *pbuf, sint index, sint *len, sint limit)
+u8 *rtw_get_ie(u8 *pbuf, signed int index, signed int *len, signed int limit)
 {
-       sint tmp, i;
+       signed int tmp, i;
        u8 *p;
 
        if (limit < 1)
@@ -958,7 +958,7 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen,
  * @show_errors: Whether to show parsing errors in debug log
  * Returns: Parsing result
  */
-ParseRes rtw_ieee802_11_parse_elems(u8 *start, uint len,
+enum ParseRes rtw_ieee802_11_parse_elems(u8 *start, uint len,
                                struct rtw_ieee802_11_elems *elems,
                                int show_errors)
 {
index 1cfdf7c9366201b04ecea501a031c74449cbed73..7d858cae23953eaea4e13d5ba185c5690d3c8176 100644 (file)
@@ -33,22 +33,10 @@ u8 rtw_validate_ssid(struct ndis_802_11_ssid *ssid)
                goto exit;
        }
 
-#ifdef CONFIG_VALIDATE_SSID
-       for (i = 0; i < ssid->SsidLength; i++) {
-               /* wifi, printable ascii code must be supported */
-               if (!((ssid->Ssid[i] >= 0x20) && (ssid->Ssid[i] <= 0x7e))) {
-                       RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("ssid has non-printable ascii\n"));
-                       ret = false;
-                       break;
-               }
-       }
-#endif /* CONFIG_VALIDATE_SSID */
-
 exit:
        return ret;
 }
 
-u8 rtw_do_join(struct adapter *padapter);
 u8 rtw_do_join(struct adapter *padapter)
 {
        struct list_head        *plist, *phead;
@@ -401,11 +389,11 @@ exit:
 }
 
 u8 rtw_set_802_11_infrastructure_mode(struct adapter *padapter,
-       enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype)
+       enum ndis_802_11_network_infrastructure networktype)
 {
        struct  mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct  wlan_network    *cur_network = &pmlmepriv->cur_network;
-       enum NDIS_802_11_NETWORK_INFRASTRUCTURE *pold_state = &(cur_network->network.InfrastructureMode);
+       enum ndis_802_11_network_infrastructure *pold_state = &(cur_network->network.InfrastructureMode);
 
        RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_notice_,
                 ("+rtw_set_802_11_infrastructure_mode: old =%d new =%d fw_state = 0x%08x\n",
@@ -539,7 +527,7 @@ exit:
        return res;
 }
 
-u8 rtw_set_802_11_authentication_mode(struct adapter *padapter, enum NDIS_802_11_AUTHENTICATION_MODE authmode)
+u8 rtw_set_802_11_authentication_mode(struct adapter *padapter, enum ndis_802_11_authentication_mode authmode)
 {
        struct security_priv *psecuritypriv = &padapter->securitypriv;
        int res;
@@ -567,7 +555,7 @@ u8 rtw_set_802_11_authentication_mode(struct adapter *padapter, enum NDIS_802_11
 u8 rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep *wep)
 {
 
-       sint            keyid, res;
+       signed int              keyid, res;
        struct security_priv *psecuritypriv = &(padapter->securitypriv);
        u8 ret = _SUCCESS;
 
index 2c9425e2a1e99df4e0f610724ab0b8086f3685fb..29d4b749378411635c27a37b4793e2c9bd42b629 100644 (file)
@@ -12,8 +12,6 @@
 #include <hal_btcoex.h>
 #include <linux/jiffies.h>
 
-extern u8 rtw_do_join(struct adapter *padapter);
-
 int    rtw_init_mlme_priv(struct adapter *padapter)
 {
        int     i;
@@ -67,9 +65,6 @@ int   rtw_init_mlme_priv(struct adapter *padapter)
        pmlmepriv->roam_flags = 0
                | RTW_ROAM_ON_EXPIRED
                | RTW_ROAM_ON_RESUME
-               #ifdef CONFIG_LAYER2_ROAMING_ACTIVE /* FIXME */
-               | RTW_ROAM_ACTIVE
-               #endif
                ;
 
        pmlmepriv->roam_scanr_exp_ms = RTW_ROAM_SCAN_RESULT_EXP_MS;
@@ -298,9 +293,9 @@ void rtw_free_network_queue(struct adapter *padapter, u8 isfreeall)
        spin_unlock_bh(&scanned_queue->lock);
 }
 
-sint rtw_if_up(struct adapter *padapter)
+signed int rtw_if_up(struct adapter *padapter)
 {
-       sint res;
+       signed int res;
 
        if (padapter->bDriverStopped || padapter->bSurpriseRemoved ||
                (check_fwstate(&padapter->mlmepriv, _FW_LINKED) == false)) {
@@ -599,7 +594,7 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t
                }
 
                if (rtw_roam_flags(adapter)) {
-                       /* TODO: don't  select netowrk in the same ess as oldest if it's new enough*/
+                       /* TODO: don't select network in the same ess as oldest if it's new enough*/
                }
 
                if (oldest == NULL || time_after(oldest->last_scanned, pnetwork->last_scanned))
@@ -1131,8 +1126,6 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct adapter *padapter, str
 
        if (psta) { /* update ptarget_sta */
 
-               DBG_871X("%s\n", __func__);
-
                psta->aid  = pnetwork->join_res;
 
                update_sta_info(padapter, psta);
@@ -1220,8 +1213,6 @@ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_net
        struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
        struct wlan_network  *cur_network = &(pmlmepriv->cur_network);
 
-       DBG_871X("%s\n", __func__);
-
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\nfw_state:%x, BSSID:%pM\n"
                , get_fwstate(pmlmepriv), MAC_ARG(pnetwork->network.MacAddress)));
 
@@ -1478,8 +1469,6 @@ void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf)
 
                        rtw_sta_media_status_rpt(adapter, psta, 1);
 
-#ifndef CONFIG_AUTO_AP_MODE
-
                        ap_sta_info_defer_update(adapter, psta);
 
                        /* report to upper layer */
@@ -1503,7 +1492,6 @@ void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf)
 
                                kfree(passoc_req);
                        }
-#endif /* CONFIG_AUTO_AP_MODE */
                }
                return;
        }
@@ -1528,7 +1516,7 @@ void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf)
        psta->qos_option = 0;
        psta->mac_id = (uint)pstassoc->cam_id;
        /* psta->aid = (uint)pstassoc->cam_id; */
-       DBG_871X("%s\n", __func__);
+
        /* for ad-hoc mode */
        rtw_hal_set_odm_var(adapter, HAL_ODM_STA_INFO, psta, true);
 
@@ -2098,9 +2086,6 @@ int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv)
 
        if (!candidate) {
                DBG_871X("%s: return _FAIL(candidate == NULL)\n", __func__);
-#ifdef CONFIG_WOWLAN
-               _clr_fwstate_(pmlmepriv, _FW_LINKED|_FW_UNDER_LINKING);
-#endif
                ret = _FAIL;
                goto exit;
        } else {
@@ -2129,12 +2114,12 @@ exit:
        return ret;
 }
 
-sint rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv)
+signed int rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv)
 {
        struct  cmd_obj *pcmd;
        struct  setauth_parm *psetauthparm;
        struct  cmd_priv *pcmdpriv = &(adapter->cmdpriv);
-       sint            res = _SUCCESS;
+       signed int              res = _SUCCESS;
 
        pcmd = rtw_zmalloc(sizeof(struct cmd_obj));
        if (!pcmd) {
@@ -2167,13 +2152,13 @@ exit:
        return res;
 }
 
-sint rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, sint keyid, u8 set_tx, bool enqueue)
+signed int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, signed int keyid, u8 set_tx, bool enqueue)
 {
        u8 keylen;
        struct cmd_obj          *pcmd;
        struct setkey_parm      *psetkeyparm;
        struct cmd_priv         *pcmdpriv = &(adapter->cmdpriv);
-       sint    res = _SUCCESS;
+       signed int      res = _SUCCESS;
 
        psetkeyparm = rtw_zmalloc(sizeof(struct setkey_parm));
        if (!psetkeyparm) {
@@ -2342,7 +2327,7 @@ static int rtw_append_pmkid(struct adapter *Adapter, int iEntry, u8 *ie, uint ie
        return ie_len;
 }
 
-sint rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len)
+signed int rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len)
 {
        u8 authmode = 0x0;
        uint    ielength;
@@ -2685,14 +2670,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_
                if (stbc_rx_enable)
                        ht_capie.cap_info |= cpu_to_le16(IEEE80211_HT_CAP_RX_STBC_2R);/* RX STBC two spatial stream */
 
-               #ifdef CONFIG_DISABLE_MCS13TO15
-               if (((cbw40_enable == 1) && (operation_bw == CHANNEL_WIDTH_40)) && (pregistrypriv->wifi_spec != 1))
-                               set_mcs_rate_by_mask(ht_capie.mcs.rx_mask, MCS_RATE_2R_13TO15_OFF);
-               else
-                               set_mcs_rate_by_mask(ht_capie.mcs.rx_mask, MCS_RATE_2R);
-               #else /* CONFIG_DISABLE_MCS13TO15 */
-                       set_mcs_rate_by_mask(ht_capie.mcs.rx_mask, MCS_RATE_2R);
-               #endif /* CONFIG_DISABLE_MCS13TO15 */
+               set_mcs_rate_by_mask(ht_capie.mcs.rx_mask, MCS_RATE_2R);
                break;
        }
 
@@ -2815,14 +2793,7 @@ void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len, u8 channe
                        break;
                case RF_2T2R:
                default:
-#ifdef CONFIG_DISABLE_MCS13TO15
-                       if (pmlmeext->cur_bwmode == CHANNEL_WIDTH_40 && pregistrypriv->wifi_spec != 1)
-                               set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_2R_13TO15_OFF);
-                       else
-                               set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_2R);
-#else /* CONFIG_DISABLE_MCS13TO15 */
                        set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_2R);
-#endif /* CONFIG_DISABLE_MCS13TO15 */
                }
 
                /* switch to the 40M Hz mode according to the AP */
@@ -2976,7 +2947,7 @@ void _rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network)
 
 }
 
-sint rtw_linked_check(struct adapter *padapter)
+signed int rtw_linked_check(struct adapter *padapter)
 {
        if ((check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) == true) ||
                        (check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE) == true)) {
index 3443a5764c50bfdc2eaf799b8425348e8a2320eb..8aadcf72a7ba5001e8ad053a78e63af70d486035 100644 (file)
@@ -71,7 +71,7 @@ static unsigned char REALTEK_96B_IE[] = {0x00, 0xe0, 0x4c, 0x02, 0x01, 0x20};
 /********************************************************
 ChannelPlan definitions
 *********************************************************/
-static RT_CHANNEL_PLAN_2G      RTW_ChannelPlan2G[RT_CHANNEL_DOMAIN_2G_MAX] = {
+static struct rt_channel_plan_2g       RTW_ChannelPlan2G[RT_CHANNEL_DOMAIN_2G_MAX] = {
        {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13},              /*  0x00, RT_CHANNEL_DOMAIN_2G_WORLD , Passive scan CH 12, 13 */
        {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13},              /*  0x01, RT_CHANNEL_DOMAIN_2G_ETSI1 */
        {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, 11},                      /*  0x02, RT_CHANNEL_DOMAIN_2G_FCC1 */
@@ -81,7 +81,7 @@ static RT_CHANNEL_PLAN_2G     RTW_ChannelPlan2G[RT_CHANNEL_DOMAIN_2G_MAX] = {
        {{}, 0},                                                                /*  0x06, RT_CHANNEL_DOMAIN_2G_NULL */
 };
 
-static RT_CHANNEL_PLAN_5G      RTW_ChannelPlan5G[RT_CHANNEL_DOMAIN_5G_MAX] = {
+static struct rt_channel_plan_5g       RTW_ChannelPlan5G[RT_CHANNEL_DOMAIN_5G_MAX] = {
        {{}, 0},                                                                                                                                                                        /*  0x00, RT_CHANNEL_DOMAIN_5G_NULL */
        {{36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140}, 19},                                          /*  0x01, RT_CHANNEL_DOMAIN_5G_ETSI1 */
        {{36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165}, 24}, /*  0x02, RT_CHANNEL_DOMAIN_5G_ETSI2 */
@@ -121,7 +121,7 @@ static RT_CHANNEL_PLAN_5G   RTW_ChannelPlan5G[RT_CHANNEL_DOMAIN_5G_MAX] = {
        {{36, 40, 44, 48, 149, 153, 157, 161}, 8},                                                                                                                      /*  0x22, RT_CHANNEL_DOMAIN_5G_FCC4_NO_DFS */
 };
 
-static RT_CHANNEL_PLAN_MAP     RTW_ChannelPlanMap[RT_CHANNEL_DOMAIN_MAX] = {
+static struct rt_channel_plan_map      RTW_ChannelPlanMap[RT_CHANNEL_DOMAIN_MAX] = {
        /*  0x00 ~ 0x1F , Old Define ===== */
        {0x02, 0x20},   /* 0x00, RT_CHANNEL_DOMAIN_FCC */
        {0x02, 0x0A},   /* 0x01, RT_CHANNEL_DOMAIN_IC */
@@ -209,7 +209,7 @@ static RT_CHANNEL_PLAN_MAP  RTW_ChannelPlanMap[RT_CHANNEL_DOMAIN_MAX] = {
 };
 
  /* use the combination for max channel numbers */
-static RT_CHANNEL_PLAN_MAP RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE = {0x03, 0x02};
+static struct rt_channel_plan_map RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE = {0x03, 0x02};
 
 /* Search the @param ch in given @param ch_set
  * @ch_set: the given channel set
@@ -217,7 +217,7 @@ static RT_CHANNEL_PLAN_MAP RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE = {0x03, 0x02};
  *
  * return the index of channel_num in channel_set, -1 if not found
  */
-int rtw_ch_set_search_ch(RT_CHANNEL_INFO *ch_set, const u32 ch)
+int rtw_ch_set_search_ch(struct rt_channel_info *ch_set, const u32 ch)
 {
        int i;
 
@@ -325,7 +325,7 @@ static void init_mlme_ext_priv_value(struct adapter *padapter)
        pmlmeext->action_public_dialog_token = 0xff;
 }
 
-static int has_channel(RT_CHANNEL_INFO *channel_set,
+static int has_channel(struct rt_channel_info *channel_set,
                                           u8 chanset_size,
                                           u8 chan)
 {
@@ -340,7 +340,7 @@ static int has_channel(RT_CHANNEL_INFO *channel_set,
        return 0;
 }
 
-static void init_channel_list(struct adapter *padapter, RT_CHANNEL_INFO *channel_set,
+static void init_channel_list(struct adapter *padapter, struct rt_channel_info *channel_set,
                                                          u8 chanset_size,
                                                          struct p2p_channels *channel_list)
 {
@@ -392,13 +392,13 @@ static void init_channel_list(struct adapter *padapter, RT_CHANNEL_INFO *channel
 
 }
 
-static u8 init_channel_set(struct adapter *padapter, u8 ChannelPlan, RT_CHANNEL_INFO *channel_set)
+static u8 init_channel_set(struct adapter *padapter, u8 ChannelPlan, struct rt_channel_info *channel_set)
 {
        u8 index, chanset_size = 0;
        u8 b5GBand = false, b2_4GBand = false;
        u8 Index2G = 0, Index5G = 0;
 
-       memset(channel_set, 0, sizeof(RT_CHANNEL_INFO)*MAX_CHANNEL_NUM);
+       memset(channel_set, 0, sizeof(struct rt_channel_info)*MAX_CHANNEL_NUM);
 
        if (ChannelPlan >= RT_CHANNEL_DOMAIN_MAX && ChannelPlan != RT_CHANNEL_DOMAIN_REALTEK_DEFINE) {
                DBG_871X("ChannelPlan ID %x error !!!!!\n", ChannelPlan);
@@ -619,115 +619,6 @@ unsigned int OnProbeReq(struct adapter *padapter, union recv_frame *precv_frame)
 
        /* DBG_871X("+OnProbeReq\n"); */
 
-#ifdef CONFIG_AUTO_AP_MODE
-       if (check_fwstate(pmlmepriv, _FW_LINKED) &&
-                       pmlmepriv->cur_network.join_res) {
-               struct sta_info *psta;
-               u8 *mac_addr, *peer_addr;
-               struct sta_priv *pstapriv = &padapter->stapriv;
-               u8 RC_OUI[4] = {0x00, 0xE0, 0x4C, 0x0A};
-               /* EID[1] + EID_LEN[1] + RC_OUI[4] + MAC[6] + PairingID[2] + ChannelNum[2] */
-
-               p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, WLAN_EID_VENDOR_SPECIFIC, (int *)&ielen,
-                       len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_);
-
-               if (!p || ielen != 14)
-                       goto _non_rc_device;
-
-               if (memcmp(p+2, RC_OUI, sizeof(RC_OUI)))
-                       goto _non_rc_device;
-
-               if (memcmp(p+6, get_sa(pframe), ETH_ALEN)) {
-                       DBG_871X("%s, do rc pairing (%pM), but mac addr mismatch!(%pM)\n", __func__,
-                               MAC_ARG(get_sa(pframe)), MAC_ARG(p+6));
-
-                       goto _non_rc_device;
-               }
-
-               DBG_871X("%s, got the pairing device(%pM)\n", __func__,  MAC_ARG(get_sa(pframe)));
-
-               /* new a station */
-               psta = rtw_get_stainfo(pstapriv, get_sa(pframe));
-               if (psta == NULL) {
-                       /*  allocate a new one */
-                       DBG_871X("going to alloc stainfo for rc =%pM\n",  MAC_ARG(get_sa(pframe)));
-                       psta = rtw_alloc_stainfo(pstapriv, get_sa(pframe));
-                       if (!psta) {
-                               /* TODO: */
-                               DBG_871X(" Exceed the upper limit of supported clients...\n");
-                               return _SUCCESS;
-                       }
-
-                       spin_lock_bh(&pstapriv->asoc_list_lock);
-                       if (list_empty(&psta->asoc_list)) {
-                               psta->expire_to = pstapriv->expire_to;
-                               list_add_tail(&psta->asoc_list, &pstapriv->asoc_list);
-                               pstapriv->asoc_list_cnt++;
-                       }
-                       spin_unlock_bh(&pstapriv->asoc_list_lock);
-
-                       /* generate pairing ID */
-                       mac_addr = myid(&(padapter->eeprompriv));
-                       peer_addr = psta->hwaddr;
-                       psta->pid = (u16)(((mac_addr[4]<<8) + mac_addr[5]) + ((peer_addr[4]<<8) + peer_addr[5]));
-
-                       /* update peer stainfo */
-                       psta->isrc = true;
-                       /* psta->aid = 0; */
-                       /* psta->mac_id = 2; */
-
-                       /* get a unique AID */
-                       if (psta->aid > 0) {
-                               DBG_871X("old AID %d\n", psta->aid);
-                       } else {
-                               for (psta->aid = 1; psta->aid <= NUM_STA; psta->aid++)
-                                       if (pstapriv->sta_aid[psta->aid - 1] == NULL)
-                                               break;
-
-                               if (psta->aid > pstapriv->max_num_sta) {
-                                       psta->aid = 0;
-                                       DBG_871X("no room for more AIDs\n");
-                                       return _SUCCESS;
-                               }
-                               pstapriv->sta_aid[psta->aid - 1] = psta;
-                               DBG_871X("allocate new AID = (%d)\n", psta->aid);
-                       }
-
-                       psta->qos_option = 1;
-                       psta->bw_mode = CHANNEL_WIDTH_20;
-                       psta->ieee8021x_blocked = false;
-                       psta->htpriv.ht_option = true;
-                       psta->htpriv.ampdu_enable = false;
-                       psta->htpriv.sgi_20m = false;
-                       psta->htpriv.sgi_40m = false;
-                       psta->htpriv.ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
-                       psta->htpriv.agg_enable_bitmap = 0x0;/* reset */
-                       psta->htpriv.candidate_tid_bitmap = 0x0;/* reset */
-
-                       rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, true);
-
-                       memset((void *)&psta->sta_stats, 0, sizeof(struct stainfo_stats));
-
-                       spin_lock_bh(&psta->lock);
-                       psta->state |= _FW_LINKED;
-                       spin_unlock_bh(&psta->lock);
-
-                       report_add_sta_event(padapter, psta->hwaddr, psta->aid);
-
-               }
-
-               issue_probersp(padapter, get_sa(pframe), false);
-
-               return _SUCCESS;
-
-       }
-
-_non_rc_device:
-
-       return _SUCCESS;
-
-#endif /* CONFIG_AUTO_AP_MODE */
-
        p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, WLAN_EID_SSID, (int *)&ielen,
                        len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_);
 
@@ -1093,8 +984,6 @@ unsigned int OnAuthClient(struct adapter *padapter, union recv_frame *precv_fram
        u8 *pframe = precv_frame->u.hdr.rx_data;
        uint pkt_len = precv_frame->u.hdr.len;
 
-       DBG_871X("%s\n", __func__);
-
        /* check A1 matches or not */
        if (memcmp(myid(&(padapter->eeprompriv)), get_da(pframe), ETH_ALEN))
                return _SUCCESS;
@@ -1220,9 +1109,6 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
        left = pkt_len - (sizeof(struct ieee80211_hdr_3addr) + ie_offset);
        pos = pframe + (sizeof(struct ieee80211_hdr_3addr) + ie_offset);
 
-
-       DBG_871X("%s\n", __func__);
-
        /*  check if this stat has been successfully authenticated/assocated */
        if (!((pstat->state) & WIFI_FW_AUTH_SUCCESS)) {
                if (!((pstat->state) & WIFI_FW_ASSOC_SUCCESS)) {
@@ -1653,8 +1539,6 @@ unsigned int OnAssocRsp(struct adapter *padapter, union recv_frame *precv_frame)
        u8 *pframe = precv_frame->u.hdr.rx_data;
        uint pkt_len = precv_frame->u.hdr.len;
 
-       DBG_871X("%s\n", __func__);
-
        /* check A1 matches or not */
        if (memcmp(myid(&(padapter->eeprompriv)), get_da(pframe), ETH_ALEN))
                return _SUCCESS;
@@ -1866,7 +1750,6 @@ unsigned int OnDisassoc(struct adapter *padapter, union recv_frame *precv_frame)
 
 unsigned int OnAtim(struct adapter *padapter, union recv_frame *precv_frame)
 {
-       DBG_871X("%s\n", __func__);
        return _SUCCESS;
 }
 
@@ -1919,8 +1802,6 @@ unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_fra
        u8 *pframe = precv_frame->u.hdr.rx_data;
        struct sta_priv *pstapriv = &padapter->stapriv;
 
-       DBG_871X("%s\n", __func__);
-
        /* check RA matches or not */
        if (memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), ETH_ALEN))/* for if1, sta/ap mode */
                return _SUCCESS;
@@ -2340,7 +2221,7 @@ void dump_mgntframe(struct adapter *padapter, struct xmit_frame *pmgntframe)
 s32 dump_mgntframe_and_wait(struct adapter *padapter, struct xmit_frame *pmgntframe, int timeout_ms)
 {
        s32 ret = _FAIL;
-       _irqL irqL;
+       unsigned long irqL;
        struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
        struct xmit_buf *pxmitbuf = pmgntframe->pxmitbuf;
        struct submit_ctx sctx;
@@ -2398,7 +2279,7 @@ s32 dump_mgntframe_and_wait_ack(struct adapter *padapter, struct xmit_frame *pmg
 static int update_hidden_ssid(u8 *ies, u32 ies_len, u8 hidden_ssid_mode)
 {
        u8 *ssid_ie;
-       sint ssid_len_ori;
+       signed int ssid_len_ori;
        int len_diff = 0;
 
        ssid_ie = rtw_get_ie(ies,  WLAN_EID_SSID, &ssid_len_ori, ies_len);
@@ -2446,8 +2327,6 @@ void issue_beacon(struct adapter *padapter, int timeout_ms)
        struct wlan_bssid_ex            *cur_network = &(pmlmeinfo->network);
        u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
 
-       /* DBG_871X("%s\n", __func__); */
-
        pmgntframe = alloc_mgtxmitframe(pxmitpriv);
        if (!pmgntframe) {
                DBG_871X("%s, alloc mgnt frame fail\n", __func__);
@@ -2605,8 +2484,6 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p
        struct wlan_bssid_ex            *cur_network = &(pmlmeinfo->network);
        unsigned int    rate_len;
 
-       /* DBG_871X("%s\n", __func__); */
-
        if (da == NULL)
                return;
 
@@ -2686,8 +2563,8 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p
                /* retrieve SSID IE from cur_network->Ssid */
                {
                        u8 *ssid_ie;
-                       sint ssid_ielen;
-                       sint ssid_ielen_diff;
+                       signed int ssid_ielen;
+                       signed int ssid_ielen_diff;
                        u8 buf[MAX_IE_SZ];
                        u8 *ies = pmgntframe->buf_addr+TXDESC_OFFSET+sizeof(struct ieee80211_hdr_3addr);
 
@@ -2771,36 +2648,6 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p
 
        }
 
-#ifdef CONFIG_AUTO_AP_MODE
-{
-       struct sta_info *psta;
-       struct sta_priv *pstapriv = &padapter->stapriv;
-
-       DBG_871X("(%s)\n", __func__);
-
-       /* check rc station */
-       psta = rtw_get_stainfo(pstapriv, da);
-       if (psta && psta->isrc && psta->pid > 0) {
-               u8 RC_OUI[4] = {0x00, 0xE0, 0x4C, 0x0A};
-               u8 RC_INFO[14] = {0};
-               /* EID[1] + EID_LEN[1] + RC_OUI[4] + MAC[6] + PairingID[2] + ChannelNum[2] */
-               u16 cu_ch = (u16)cur_network->Configuration.DSConfig;
-
-               DBG_871X("%s, reply rc(pid = 0x%x) device %pM in ch =%d\n", __func__,
-                       psta->pid, MAC_ARG(psta->hwaddr), cu_ch);
-
-               /* append vendor specific ie */
-               memcpy(RC_INFO, RC_OUI, sizeof(RC_OUI));
-               memcpy(&RC_INFO[4], mac, ETH_ALEN);
-               memcpy(&RC_INFO[10], (u8 *)&psta->pid, 2);
-               memcpy(&RC_INFO[12], (u8 *)&cu_ch, 2);
-
-               pframe = rtw_set_ie(pframe, WLAN_EID_VENDOR_SPECIFIC, sizeof(RC_INFO), RC_INFO, &pattrib->pktlen);
-       }
-}
-#endif /* CONFIG_AUTO_AP_MODE */
-
-
        pattrib->last_txcmdsz = pattrib->pktlen;
 
 
@@ -3084,7 +2931,6 @@ void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short
        pattrib->last_txcmdsz = pattrib->pktlen;
 
        rtw_wep_encrypt(padapter, (u8 *)pmgntframe);
-       DBG_871X("%s\n", __func__);
        dump_mgntframe(padapter, pmgntframe);
 }
 
@@ -3105,8 +2951,6 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i
        u8 *ie = pnetwork->IEs;
        __le16 lestatus, le_tmp;
 
-       DBG_871X("%s\n", __func__);
-
        pmgntframe = alloc_mgtxmitframe(pxmitpriv);
        if (pmgntframe == NULL)
                return;
@@ -3581,8 +3425,6 @@ static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da,
        struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
        struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
 
-       DBG_871X("%s\n", __func__);
-
        pmgntframe = alloc_mgtxmitframe(pxmitpriv);
        if (pmgntframe == NULL)
                goto exit;
@@ -3813,8 +3655,6 @@ void issue_action_SA_Query(struct adapter *padapter, unsigned char *raddr, unsig
        struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
        __le16 le_tmp;
 
-       DBG_871X("%s\n", __func__);
-
        pmgntframe = alloc_mgtxmitframe(pxmitpriv);
        if (pmgntframe == NULL) {
                DBG_871X("%s: alloc_mgtxmitframe fail\n", __func__);
@@ -4050,10 +3890,6 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter)
        if (true == pmlmeinfo->bwmode_updated)
                return;
 
-
-       DBG_871X("%s\n", __func__);
-
-
        category = RTW_WLAN_CATEGORY_PUBLIC;
        action = ACT_PUBLIC_BSSCOEXIST;
 
@@ -4272,7 +4108,7 @@ Following are some utility functions for WiFi MLME
 void site_survey(struct adapter *padapter)
 {
        unsigned char   survey_channel = 0, val8;
-       RT_SCAN_TYPE    ScanType = SCAN_PASSIVE;
+       enum rt_scan_type       ScanType = SCAN_PASSIVE;
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
        u32 initialgain = 0;
@@ -4350,18 +4186,6 @@ void site_survey(struct adapter *padapter)
                channel_scan_time_ms = pmlmeext->chan_scan_time;
 
                set_survey_timer(pmlmeext, channel_scan_time_ms);
-#if defined(CONFIG_SIGNAL_DISPLAY_DBM) && defined(CONFIG_BACKGROUND_NOISE_MONITOR)
-               {
-                       struct noise_info info;
-
-                       info.bPauseDIG = false;
-                       info.IGIValue = 0;
-                       info.max_time = channel_scan_time_ms/2;/* ms */
-                       info.chan = survey_channel;
-                       rtw_hal_set_odm_var(padapter, HAL_ODM_NOISE_MONITOR, &info, false);
-               }
-#endif
-
        } else {
 
                /*      channel number is 0 or this channel is not valid. */
@@ -4747,8 +4571,6 @@ unsigned int receive_disconnect(struct adapter *padapter, unsigned char *MacAddr
        if (!(!memcmp(MacAddr, get_my_bssid(&pmlmeinfo->network), ETH_ALEN)))
                return _SUCCESS;
 
-       DBG_871X("%s\n", __func__);
-
        if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) {
                if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) {
                        pmlmeinfo->state = WIFI_FW_NULL_STATE;
@@ -4767,7 +4589,7 @@ static void process_80211d(struct adapter *padapter, struct wlan_bssid_ex *bssid
 {
        struct registry_priv *pregistrypriv;
        struct mlme_ext_priv *pmlmeext;
-       RT_CHANNEL_INFO *chplan_new;
+       struct rt_channel_info *chplan_new;
        u8 channel;
        u8 i;
 
@@ -4780,8 +4602,8 @@ static void process_80211d(struct adapter *padapter, struct wlan_bssid_ex *bssid
                (!pmlmeext->update_channel_plan_by_ap_done)) {
                u8 *ie, *p;
                u32 len;
-               RT_CHANNEL_PLAN chplan_ap;
-               RT_CHANNEL_INFO chplan_sta[MAX_CHANNEL_NUM];
+               struct rt_channel_plan chplan_ap;
+               struct rt_channel_info chplan_sta[MAX_CHANNEL_NUM];
                u8 country[4];
                u8 fcn; /*  first channel number */
                u8 noc; /*  number of channel */
@@ -5438,7 +5260,7 @@ void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res)
                rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type));
                rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, null_addr);
 
-               goto exit_mlmeext_joinbss_event_callback;
+               return;
        }
 
        if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE)
@@ -5500,11 +5322,6 @@ void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res)
 
        if (get_iface_type(padapter) == IFACE_PORT0)
                rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_CONNECT, 0);
-
-exit_mlmeext_joinbss_event_callback:
-
-       DBG_871X("=>%s\n", __func__);
-
 }
 
 /* currently only adhoc mode will go here */
@@ -5514,8 +5331,6 @@ void mlmeext_sta_add_event_callback(struct adapter *padapter, struct sta_info *p
        struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
        u8 join_type;
 
-       DBG_871X("%s\n", __func__);
-
        if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) {
                if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) { /* adhoc master or sta_count>1 */
 
@@ -5912,99 +5727,6 @@ u8 NULL_hdl(struct adapter *padapter, u8 *pbuf)
        return H2C_SUCCESS;
 }
 
-#ifdef CONFIG_AUTO_AP_MODE
-static int rtw_auto_ap_start_beacon(struct adapter *adapter)
-{
-       int ret = 0;
-       u8 *pbuf = NULL;
-       uint len;
-       u8 supportRate[16];
-       int     sz = 0, rateLen;
-       u8 *ie;
-       u8 wireless_mode, oper_channel;
-       u8 ssid[3] = {0}; /* hidden ssid */
-       u32 ssid_len = sizeof(ssid);
-       struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);
-
-
-       if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true)
-               return -EINVAL;
-
-
-       len = 128;
-       pbuf = rtw_zmalloc(len);
-       if (!pbuf)
-               return -ENOMEM;
-
-
-       /* generate beacon */
-       ie = pbuf;
-
-       /* timestamp will be inserted by hardware */
-       sz += 8;
-       ie += sz;
-
-       /* beacon interval : 2bytes */
-       *(u16 *)ie = cpu_to_le16((u16)100);/* BCN_INTERVAL = 100; */
-       sz += 2;
-       ie += 2;
-
-       /* capability info */
-       *(u16 *)ie = 0;
-       *(u16 *)ie |= cpu_to_le16(WLAN_CAPABILITY_ESS);
-       *(u16 *)ie |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE);
-       /* u16*)ie |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); */
-       sz += 2;
-       ie += 2;
-
-       /* SSID */
-       ie = rtw_set_ie(ie, WLAN_EID_SSID, ssid_len, ssid, &sz);
-
-       /* supported rates */
-       wireless_mode = WIRELESS_11BG_24N;
-       rtw_set_supported_rate(supportRate, wireless_mode);
-       rateLen = rtw_get_rateset_len(supportRate);
-       if (rateLen > 8) {
-               ie = rtw_set_ie(ie, WLAN_EID_SUPP_RATES, 8, supportRate, &sz);
-       } else {
-               ie = rtw_set_ie(ie, WLAN_EID_SUPP_RATES, rateLen, supportRate, &sz);
-       }
-
-
-       /* DS parameter set */
-       if (check_buddy_fwstate(adapter, _FW_LINKED) &&
-               check_buddy_fwstate(adapter, WIFI_STATION_STATE)) {
-               struct adapter *pbuddystruct adapter = adapter->pbuddystruct adapter;
-               struct mlme_ext_priv *pbuddy_mlmeext  = &pbuddystruct adapter->mlmeextpriv;
-
-               oper_channel = pbuddy_mlmeext->cur_channel;
-       } else {
-               oper_channel = adapter_to_dvobj(adapter)->oper_channel;
-       }
-       ie = rtw_set_ie(ie, WLAN_EID_DS_PARAMS, 1, &oper_channel, &sz);
-
-       /* ext supported rates */
-       if (rateLen > 8) {
-               ie = rtw_set_ie(ie, WLAN_EID_EXT_SUPP_RATES, (rateLen - 8), (supportRate + 8), &sz);
-       }
-
-       DBG_871X("%s, start auto ap beacon sz =%d\n", __func__, sz);
-
-       /* lunch ap mode & start to issue beacon */
-       if (rtw_check_beacon_data(adapter, pbuf,  sz) == _SUCCESS) {
-
-       } else {
-               ret = -EINVAL;
-       }
-
-
-       kfree(pbuf);
-
-       return ret;
-
-}
-#endif/* CONFIG_AUTO_AP_MODE */
-
 u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf)
 {
        u8 type;
@@ -6029,12 +5751,6 @@ u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf)
        rtw_hal_set_hwreg(padapter, HW_VAR_SET_OPMODE, (u8 *)(&type));
        /* Set_MSR(padapter, type); */
 
-
-#ifdef CONFIG_AUTO_AP_MODE
-       if (psetop->mode == Ndis802_11APMode)
-               rtw_auto_ap_start_beacon(padapter);
-#endif
-
        if (psetop->mode == Ndis802_11APMode) {
                /*  Do this after port switch to */
                /*  prevent from downloading rsvd page to wrong port */
index 93e8f17d2574f9f7ad8719ce23675115ac3b9dae..53f7cc0444ba1fc7b5122fc67cde3f1a9cd7bdc8 100644 (file)
@@ -152,7 +152,7 @@ inline void rtw_odm_ability_set(struct adapter *adapter, u32 ability)
 void rtw_odm_adaptivity_parm_msg(void *sel, struct adapter *adapter)
 {
        struct hal_com_data *pHalData = GET_HAL_DATA(adapter);
-       DM_ODM_T *odm = &pHalData->odmpriv;
+       struct dm_odm_t *odm = &pHalData->odmpriv;
 
        DBG_871X_SEL_NL(sel, "%10s %16s %8s %10s %11s %14s\n",
                        "TH_L2H_ini", "TH_EDCCA_HL_diff", "IGI_Base",
@@ -173,7 +173,7 @@ void rtw_odm_adaptivity_parm_set(struct adapter *adapter, s8 TH_L2H_ini,
                                 u8 IGI_LowerBound)
 {
        struct hal_com_data *pHalData = GET_HAL_DATA(adapter);
-       DM_ODM_T *odm = &pHalData->odmpriv;
+       struct dm_odm_t *odm = &pHalData->odmpriv;
 
        odm->TH_L2H_ini = TH_L2H_ini;
        odm->TH_EDCCA_HL_diff = TH_EDCCA_HL_diff;
@@ -186,7 +186,7 @@ void rtw_odm_adaptivity_parm_set(struct adapter *adapter, s8 TH_L2H_ini,
 void rtw_odm_get_perpkt_rssi(void *sel, struct adapter *adapter)
 {
        struct hal_com_data *hal_data = GET_HAL_DATA(adapter);
-       DM_ODM_T *odm = &hal_data->odmpriv;
+       struct dm_odm_t *odm = &hal_data->odmpriv;
 
        DBG_871X_SEL_NL(sel, "RxRate = %s, RSSI_A = %d(%%), RSSI_B = %d(%%)\n",
                        HDATA_RATE(odm->RxRate), odm->RSSI_A, odm->RSSI_B);
index c9f4a18b24b946ff06d8b5306ee79b59e6b554dc..8bf80e6f4a11fd1ab99ce0c972d5342669332ef0 100644 (file)
@@ -182,7 +182,6 @@ void rtw_ps_processor(struct adapter *padapter)
                goto exit;
 
        if ((pwrpriv->rf_pwrstate == rf_on) && ((pwrpriv->pwr_state_check_cnts%4) == 0)) {
-               DBG_871X("==>%s\n", __func__);
                pwrpriv->change_rfpwrstate = rf_off;
                {
                        ips_enter(padapter);
@@ -350,17 +349,8 @@ static u8 PS_RDY_CHECK(struct adapter *padapter)
        struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter);
        struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
 
-#if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN)
-       if (pwrpriv->bInSuspend && pwrpriv->wowlan_mode)
-               return true;
-       else if (pwrpriv->bInSuspend && pwrpriv->wowlan_ap_mode)
-               return true;
-       else if (pwrpriv->bInSuspend)
-               return false;
-#else
        if (pwrpriv->bInSuspend)
                return false;
-#endif
 
        curr_time = jiffies;
 
@@ -391,9 +381,6 @@ static u8 PS_RDY_CHECK(struct adapter *padapter)
 void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_ant_mode, const char *msg)
 {
        struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter);
-#if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN)
-       struct debug_priv *pdbgpriv = &padapter->dvobj->drv_dbg;
-#endif
 
        RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_,
                         ("%s: PowerMode =%d Smart_PS =%d\n",
@@ -422,29 +409,6 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_a
                        pwrpriv->pwr_mode = ps_mode;
                        rtw_set_rpwm(padapter, PS_STATE_S4);
 
-#if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN)
-                       if (pwrpriv->wowlan_mode || pwrpriv->wowlan_ap_mode) {
-                               unsigned long start_time;
-                               u32 delay_ms;
-                               u8 val8;
-                               delay_ms = 20;
-                               start_time = jiffies;
-                               do {
-                                       rtw_hal_get_hwreg(padapter, HW_VAR_SYS_CLKR, &val8);
-                                       if (!(val8 & BIT(4))) { /* 0x08 bit4 = 1 --> in 32k, bit4 = 0 --> leave 32k */
-                                               pwrpriv->cpwm = PS_STATE_S4;
-                                               break;
-                                       }
-                                       if (jiffies_to_msecs(jiffies - start_time) > delay_ms) {
-                                               DBG_871X("%s: Wait for FW 32K leave more than %u ms!!!\n",
-                                                               __func__, delay_ms);
-                                               pdbgpriv->dbg_wow_leave_ps_fail_cnt++;
-                                               break;
-                                       }
-                                       msleep(1);
-                               } while (1);
-                       }
-#endif
                        rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&ps_mode));
                        pwrpriv->bFwCurrentInPSMode = false;
 
@@ -603,8 +567,6 @@ void LeaveAllPowerSaveModeDirect(struct adapter *Adapter)
        struct mlme_priv *pmlmepriv = &(Adapter->mlmepriv);
        struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(Adapter);
 
-       DBG_871X("%s.....\n", __func__);
-
        if (Adapter->bSurpriseRemoved) {
                DBG_871X(FUNC_ADPT_FMT ": bSurpriseRemoved =%d Skip!\n",
                        FUNC_ADPT_ARG(Adapter), Adapter->bSurpriseRemoved);
@@ -750,8 +712,6 @@ static void cpwm_event_callback(struct work_struct *work)
        struct adapter *adapter = dvobj->if1;
        struct reportpwrstate_parm report;
 
-       /* DBG_871X("%s\n", __func__); */
-
        report.state = PS_STATE_S2;
        cpwm_int_hdl(adapter, &report);
 }
@@ -1149,29 +1109,11 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter)
 
        pwrctrlpriv->wowlan_mode = false;
        pwrctrlpriv->wowlan_ap_mode = false;
-
-#ifdef CONFIG_PNO_SUPPORT
-       pwrctrlpriv->pno_inited = false;
-       pwrctrlpriv->pnlo_info = NULL;
-       pwrctrlpriv->pscan_info = NULL;
-       pwrctrlpriv->pno_ssid_list = NULL;
-       pwrctrlpriv->pno_in_resume = true;
-#endif
 }
 
 
 void rtw_free_pwrctrl_priv(struct adapter *adapter)
 {
-#ifdef CONFIG_PNO_SUPPORT
-       if (pwrctrlpriv->pnlo_info)
-               printk("****** pnlo_info memory leak********\n");
-
-       if (pwrctrlpriv->pscan_info)
-               printk("****** pscan_info memory leak********\n");
-
-       if (pwrctrlpriv->pno_ssid_list)
-               printk("****** pno_ssid_list memory leak********\n");
-#endif
 }
 
 inline void rtw_set_ips_deny(struct adapter *padapter, u32 ms)
@@ -1322,7 +1264,7 @@ int rtw_pm_set_ips(struct adapter *padapter, u8 mode)
  * ATTENTION:
  *This function will request pwrctrl LOCK!
  */
-void rtw_ps_deny(struct adapter *padapter, enum PS_DENY_REASON reason)
+void rtw_ps_deny(struct adapter *padapter, enum ps_deny_reason reason)
 {
        struct pwrctrl_priv *pwrpriv;
 
@@ -1347,7 +1289,7 @@ void rtw_ps_deny(struct adapter *padapter, enum PS_DENY_REASON reason)
  * ATTENTION:
  *This function will request pwrctrl LOCK!
  */
-void rtw_ps_deny_cancel(struct adapter *padapter, enum PS_DENY_REASON reason)
+void rtw_ps_deny_cancel(struct adapter *padapter, enum ps_deny_reason reason)
 {
        struct pwrctrl_priv *pwrpriv;
 
index f35a134bb75f231bb696651c246e1168fed0e3dd..608a592865059a0074b45179265cadc01dcfbec2 100644 (file)
@@ -30,11 +30,11 @@ void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv)
        _rtw_init_queue(&psta_recvpriv->defrag_q);
 }
 
-sint _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter)
+signed int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter)
 {
-       sint i;
+       signed int i;
        union recv_frame *precvframe;
-       sint    res = _SUCCESS;
+       signed int      res = _SUCCESS;
 
        spin_lock_init(&precvpriv->lock);
 
@@ -168,7 +168,7 @@ int rtw_free_recvframe(union recv_frame *precvframe, struct __queue *pfree_recv_
 
 
 
-sint _rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue)
+signed int _rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue)
 {
 
        struct adapter *padapter = precvframe->u.hdr.adapter;
@@ -187,9 +187,9 @@ sint _rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue)
        return _SUCCESS;
 }
 
-sint rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue)
+signed int rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue)
 {
-       sint ret;
+       signed int ret;
 
        /* _spinlock(&pfree_recv_queue->lock); */
        spin_lock_bh(&queue->lock);
@@ -201,7 +201,7 @@ sint rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue)
 }
 
 /*
-sint   rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue)
+signed int     rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue)
 {
        return rtw_free_recvframe(precvframe, queue);
 }
@@ -255,7 +255,7 @@ u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter)
 }
 
 
-sint rtw_enqueue_recvbuf_to_head(struct recv_buf *precvbuf, struct __queue *queue)
+signed int rtw_enqueue_recvbuf_to_head(struct recv_buf *precvbuf, struct __queue *queue)
 {
        spin_lock_bh(&queue->lock);
 
@@ -267,7 +267,7 @@ sint rtw_enqueue_recvbuf_to_head(struct recv_buf *precvbuf, struct __queue *queu
        return _SUCCESS;
 }
 
-sint rtw_enqueue_recvbuf(struct recv_buf *precvbuf, struct __queue *queue)
+signed int rtw_enqueue_recvbuf(struct recv_buf *precvbuf, struct __queue *queue)
 {
        spin_lock_bh(&queue->lock);
 
@@ -305,11 +305,10 @@ struct recv_buf *rtw_dequeue_recvbuf(struct __queue *queue)
 
 }
 
-sint recvframe_chkmic(struct adapter *adapter,  union recv_frame *precvframe);
-sint recvframe_chkmic(struct adapter *adapter,  union recv_frame *precvframe)
+static signed int recvframe_chkmic(struct adapter *adapter,  union recv_frame *precvframe)
 {
 
-       sint    i, res = _SUCCESS;
+       signed int      i, res = _SUCCESS;
        u32 datalen;
        u8 miccode[8];
        u8 bmic_err = false, brpt_micerror = true;
@@ -436,8 +435,7 @@ exit:
 }
 
 /* decrypt and set the ivlen, icvlen of the recv_frame */
-union recv_frame *decryptor(struct adapter *padapter, union recv_frame *precv_frame);
-union recv_frame *decryptor(struct adapter *padapter, union recv_frame *precv_frame)
+static union recv_frame *decryptor(struct adapter *padapter, union recv_frame *precv_frame)
 {
 
        struct rx_pkt_attrib *prxattrib = &precv_frame->u.hdr.attrib;
@@ -528,8 +526,7 @@ union recv_frame *decryptor(struct adapter *padapter, union recv_frame *precv_fr
 }
 
 /* set the security information in the recv_frame */
-union recv_frame *portctrl(struct adapter *adapter, union recv_frame *precv_frame);
-union recv_frame *portctrl(struct adapter *adapter, union recv_frame *precv_frame)
+static union recv_frame *portctrl(struct adapter *adapter, union recv_frame *precv_frame)
 {
        u8 *psta_addr = NULL;
        u8 *ptr;
@@ -606,10 +603,9 @@ union recv_frame *portctrl(struct adapter *adapter, union recv_frame *precv_fram
        return prtnframe;
 }
 
-sint recv_decache(union recv_frame *precv_frame, u8 bretry, struct stainfo_rxcache *prxcache);
-sint recv_decache(union recv_frame *precv_frame, u8 bretry, struct stainfo_rxcache *prxcache)
+static signed int recv_decache(union recv_frame *precv_frame, u8 bretry, struct stainfo_rxcache *prxcache)
 {
-       sint tid = precv_frame->u.hdr.attrib.priority;
+       signed int tid = precv_frame->u.hdr.attrib.priority;
 
        u16 seq_ctrl = ((precv_frame->u.hdr.attrib.seq_num&0xffff) << 4) |
                (precv_frame->u.hdr.attrib.frag_num & 0xf);
@@ -634,8 +630,7 @@ sint recv_decache(union recv_frame *precv_frame, u8 bretry, struct stainfo_rxcac
 
 }
 
-void process_pwrbit_data(struct adapter *padapter, union recv_frame *precv_frame);
-void process_pwrbit_data(struct adapter *padapter, union recv_frame *precv_frame)
+static void process_pwrbit_data(struct adapter *padapter, union recv_frame *precv_frame)
 {
        unsigned char pwrbit;
        u8 *ptr = precv_frame->u.hdr.rx_data;
@@ -671,8 +666,7 @@ void process_pwrbit_data(struct adapter *padapter, union recv_frame *precv_frame
        }
 }
 
-void process_wmmps_data(struct adapter *padapter, union recv_frame *precv_frame);
-void process_wmmps_data(struct adapter *padapter, union recv_frame *precv_frame)
+static void process_wmmps_data(struct adapter *padapter, union recv_frame *precv_frame)
 {
        struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
        struct sta_priv *pstapriv = &padapter->stapriv;
@@ -723,8 +717,7 @@ void process_wmmps_data(struct adapter *padapter, union recv_frame *precv_frame)
        }
 }
 
-void count_rx_stats(struct adapter *padapter, union recv_frame *prframe, struct sta_info *sta);
-void count_rx_stats(struct adapter *padapter, union recv_frame *prframe, struct sta_info *sta)
+static void count_rx_stats(struct adapter *padapter, union recv_frame *prframe, struct sta_info *sta)
 {
        int sz;
        struct sta_info *psta = NULL;
@@ -755,20 +748,18 @@ void count_rx_stats(struct adapter *padapter, union recv_frame *prframe, struct
        traffic_check_for_leave_lps(padapter, false, 0);
 }
 
-sint sta2sta_data_frame(struct adapter *adapter, union recv_frame *precv_frame,
-                       struct sta_info **psta);
-sint sta2sta_data_frame(struct adapter *adapter, union recv_frame *precv_frame,
+static signed int sta2sta_data_frame(struct adapter *adapter, union recv_frame *precv_frame,
                        struct sta_info **psta)
 {
        u8 *ptr = precv_frame->u.hdr.rx_data;
-       sint ret = _SUCCESS;
+       signed int ret = _SUCCESS;
        struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
        struct sta_priv *pstapriv = &adapter->stapriv;
        struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
        u8 *mybssid  = get_bssid(pmlmepriv);
        u8 *myhwaddr = myid(&adapter->eeprompriv);
        u8 *sta_addr = NULL;
-       sint bmcast = IS_MCAST(pattrib->dst);
+       signed int bmcast = IS_MCAST(pattrib->dst);
 
        /* DBG_871X("[%s] %d, seqnum:%d\n", __func__, __LINE__, pattrib->seq_num); */
 
@@ -850,19 +841,17 @@ exit:
        return ret;
 }
 
-sint ap2sta_data_frame(struct adapter *adapter, union recv_frame *precv_frame,
-                      struct sta_info **psta);
-sint ap2sta_data_frame(struct adapter *adapter, union recv_frame *precv_frame,
+static signed int ap2sta_data_frame(struct adapter *adapter, union recv_frame *precv_frame,
                       struct sta_info **psta)
 {
        u8 *ptr = precv_frame->u.hdr.rx_data;
        struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
-       sint ret = _SUCCESS;
+       signed int ret = _SUCCESS;
        struct sta_priv *pstapriv = &adapter->stapriv;
        struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
        u8 *mybssid  = get_bssid(pmlmepriv);
        u8 *myhwaddr = myid(&adapter->eeprompriv);
-       sint bmcast = IS_MCAST(pattrib->dst);
+       signed int bmcast = IS_MCAST(pattrib->dst);
 
        if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) &&
            (check_fwstate(pmlmepriv, _FW_LINKED) == true ||
@@ -992,9 +981,7 @@ exit:
        return ret;
 }
 
-sint sta2ap_data_frame(struct adapter *adapter, union recv_frame *precv_frame,
-                      struct sta_info **psta);
-sint sta2ap_data_frame(struct adapter *adapter, union recv_frame *precv_frame,
+static signed int sta2ap_data_frame(struct adapter *adapter, union recv_frame *precv_frame,
                       struct sta_info **psta)
 {
        u8 *ptr = precv_frame->u.hdr.rx_data;
@@ -1002,7 +989,7 @@ sint sta2ap_data_frame(struct adapter *adapter, union recv_frame *precv_frame,
        struct sta_priv *pstapriv = &adapter->stapriv;
        struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
        unsigned char *mybssid  = get_bssid(pmlmepriv);
-       sint ret = _SUCCESS;
+       signed int ret = _SUCCESS;
 
        if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) {
                /* For AP mode, RA =BSSID, TX =STA(SRC_ADDR), A3 =DST_ADDR */
@@ -1049,8 +1036,7 @@ exit:
        return ret;
 }
 
-sint validate_recv_ctrl_frame(struct adapter *padapter, union recv_frame *precv_frame);
-sint validate_recv_ctrl_frame(struct adapter *padapter, union recv_frame *precv_frame)
+static signed int validate_recv_ctrl_frame(struct adapter *padapter, union recv_frame *precv_frame)
 {
        struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
        struct sta_priv *pstapriv = &padapter->stapriv;
@@ -1186,9 +1172,191 @@ sint validate_recv_ctrl_frame(struct adapter *padapter, union recv_frame *precv_
 
 }
 
-union recv_frame *recvframe_chk_defrag(struct adapter *padapter, union recv_frame *precv_frame);
-sint validate_recv_mgnt_frame(struct adapter *padapter, union recv_frame *precv_frame);
-sint validate_recv_mgnt_frame(struct adapter *padapter, union recv_frame *precv_frame)
+/* perform defrag */
+static union recv_frame *recvframe_defrag(struct adapter *adapter,
+                                         struct __queue *defrag_q)
+{
+       struct list_head         *plist, *phead;
+       u8  wlanhdr_offset;
+       u8 curfragnum;
+       struct recv_frame_hdr *pfhdr, *pnfhdr;
+       union recv_frame *prframe, *pnextrframe;
+       struct __queue  *pfree_recv_queue;
+
+       curfragnum = 0;
+       pfree_recv_queue = &adapter->recvpriv.free_recv_queue;
+
+       phead = get_list_head(defrag_q);
+       plist = get_next(phead);
+       prframe = (union recv_frame *)plist;
+       pfhdr = &prframe->u.hdr;
+       list_del_init(&(prframe->u.list));
+
+       if (curfragnum != pfhdr->attrib.frag_num) {
+               /* the first fragment number must be 0 */
+               /* free the whole queue */
+               rtw_free_recvframe(prframe, pfree_recv_queue);
+               rtw_free_recvframe_queue(defrag_q, pfree_recv_queue);
+
+               return NULL;
+       }
+
+       curfragnum++;
+
+       plist = get_list_head(defrag_q);
+
+       plist = get_next(plist);
+
+       while (phead != plist) {
+               pnextrframe = (union recv_frame *)plist;
+               pnfhdr = &pnextrframe->u.hdr;
+
+
+               /* check the fragment sequence  (2nd ~n fragment frame) */
+
+               if (curfragnum != pnfhdr->attrib.frag_num) {
+                       /* the fragment number must be increasing  (after decache) */
+                       /* release the defrag_q & prframe */
+                       rtw_free_recvframe(prframe, pfree_recv_queue);
+                       rtw_free_recvframe_queue(defrag_q, pfree_recv_queue);
+                       return NULL;
+               }
+
+               curfragnum++;
+
+               /* copy the 2nd~n fragment frame's payload to the first fragment */
+               /* get the 2nd~last fragment frame's payload */
+
+               wlanhdr_offset = pnfhdr->attrib.hdrlen + pnfhdr->attrib.iv_len;
+
+               recvframe_pull(pnextrframe, wlanhdr_offset);
+
+               /* append  to first fragment frame's tail (if privacy frame, pull the ICV) */
+               recvframe_pull_tail(prframe, pfhdr->attrib.icv_len);
+
+               /* memcpy */
+               memcpy(pfhdr->rx_tail, pnfhdr->rx_data, pnfhdr->len);
+
+               recvframe_put(prframe, pnfhdr->len);
+
+               pfhdr->attrib.icv_len = pnfhdr->attrib.icv_len;
+               plist = get_next(plist);
+
+       }
+
+       /* free the defrag_q queue and return the prframe */
+       rtw_free_recvframe_queue(defrag_q, pfree_recv_queue);
+
+       RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("Performance defrag!!!!!\n"));
+
+       return prframe;
+}
+
+/* check if need to defrag, if needed queue the frame to defrag_q */
+static union recv_frame *recvframe_chk_defrag(struct adapter *padapter, union recv_frame *precv_frame)
+{
+       u8 ismfrag;
+       u8 fragnum;
+       u8 *psta_addr;
+       struct recv_frame_hdr *pfhdr;
+       struct sta_info *psta;
+       struct sta_priv *pstapriv;
+       struct list_head *phead;
+       union recv_frame *prtnframe = NULL;
+       struct __queue *pfree_recv_queue, *pdefrag_q;
+
+       pstapriv = &padapter->stapriv;
+
+       pfhdr = &precv_frame->u.hdr;
+
+       pfree_recv_queue = &padapter->recvpriv.free_recv_queue;
+
+       /* need to define struct of wlan header frame ctrl */
+       ismfrag = pfhdr->attrib.mfrag;
+       fragnum = pfhdr->attrib.frag_num;
+
+       psta_addr = pfhdr->attrib.ta;
+       psta = rtw_get_stainfo(pstapriv, psta_addr);
+       if (!psta) {
+               u8 type = GetFrameType(pfhdr->rx_data);
+               if (type != WIFI_DATA_TYPE) {
+                       psta = rtw_get_bcmc_stainfo(padapter);
+                       pdefrag_q = &psta->sta_recvpriv.defrag_q;
+               } else
+                       pdefrag_q = NULL;
+       } else
+               pdefrag_q = &psta->sta_recvpriv.defrag_q;
+
+       if ((ismfrag == 0) && (fragnum == 0))
+               prtnframe = precv_frame;/* isn't a fragment frame */
+
+       if (ismfrag == 1) {
+               /* 0~(n-1) fragment frame */
+               /* enqueue to defraf_g */
+               if (pdefrag_q) {
+                       if (fragnum == 0)
+                               /* the first fragment */
+                               if (!list_empty(&pdefrag_q->queue))
+                                       /* free current defrag_q */
+                                       rtw_free_recvframe_queue(pdefrag_q, pfree_recv_queue);
+
+
+                       /* Then enqueue the 0~(n-1) fragment into the defrag_q */
+
+                       /* spin_lock(&pdefrag_q->lock); */
+                       phead = get_list_head(pdefrag_q);
+                       list_add_tail(&pfhdr->list, phead);
+                       /* spin_unlock(&pdefrag_q->lock); */
+
+                       RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("Enqueuq: ismfrag = %d, fragnum = %d\n", ismfrag, fragnum));
+
+                       prtnframe = NULL;
+
+               } else {
+                       /* can't find this ta's defrag_queue, so free this recv_frame */
+                       rtw_free_recvframe(precv_frame, pfree_recv_queue);
+                       prtnframe = NULL;
+                       RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("Free because pdefrag_q == NULL: ismfrag = %d, fragnum = %d\n", ismfrag, fragnum));
+               }
+
+       }
+
+       if ((ismfrag == 0) && (fragnum != 0)) {
+               /* the last fragment frame */
+               /* enqueue the last fragment */
+               if (pdefrag_q) {
+                       /* spin_lock(&pdefrag_q->lock); */
+                       phead = get_list_head(pdefrag_q);
+                       list_add_tail(&pfhdr->list, phead);
+                       /* spin_unlock(&pdefrag_q->lock); */
+
+                       /* call recvframe_defrag to defrag */
+                       RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("defrag: ismfrag = %d, fragnum = %d\n", ismfrag, fragnum));
+                       precv_frame = recvframe_defrag(padapter, pdefrag_q);
+                       prtnframe = precv_frame;
+
+               } else {
+                       /* can't find this ta's defrag_queue, so free this recv_frame */
+                       rtw_free_recvframe(precv_frame, pfree_recv_queue);
+                       prtnframe = NULL;
+                       RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("Free because pdefrag_q == NULL: ismfrag = %d, fragnum = %d\n", ismfrag, fragnum));
+               }
+
+       }
+
+
+       if ((prtnframe) && (prtnframe->u.hdr.attrib.privacy)) {
+               /* after defrag we must check tkip mic code */
+               if (recvframe_chkmic(padapter,  prtnframe) == _FAIL) {
+                       RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvframe_chkmic(padapter,  prtnframe) == _FAIL\n"));
+                       rtw_free_recvframe(prtnframe, pfree_recv_queue);
+                       prtnframe = NULL;
+               }
+       }
+       return prtnframe;
+}
+
+static signed int validate_recv_mgnt_frame(struct adapter *padapter, union recv_frame *precv_frame)
 {
        /* struct mlme_priv *pmlmepriv = &adapter->mlmepriv; */
 
@@ -1227,8 +1395,7 @@ sint validate_recv_mgnt_frame(struct adapter *padapter, union recv_frame *precv_
 
 }
 
-sint validate_recv_data_frame(struct adapter *adapter, union recv_frame *precv_frame);
-sint validate_recv_data_frame(struct adapter *adapter, union recv_frame *precv_frame)
+static signed int validate_recv_data_frame(struct adapter *adapter, union recv_frame *precv_frame)
 {
        u8 bretry;
        u8 *psa, *pda, *pbssid;
@@ -1236,7 +1403,7 @@ sint validate_recv_data_frame(struct adapter *adapter, union recv_frame *precv_f
        u8 *ptr = precv_frame->u.hdr.rx_data;
        struct rx_pkt_attrib    *pattrib = &precv_frame->u.hdr.attrib;
        struct security_priv *psecuritypriv = &adapter->securitypriv;
-       sint ret = _SUCCESS;
+       signed int ret = _SUCCESS;
 
        bretry = GetRetry(ptr);
        pda = get_da(ptr);
@@ -1364,7 +1531,7 @@ exit:
        return ret;
 }
 
-static sint validate_80211w_mgmt(struct adapter *adapter, union recv_frame *precv_frame)
+static signed int validate_80211w_mgmt(struct adapter *adapter, union recv_frame *precv_frame)
 {
        struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
        struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
@@ -1410,7 +1577,7 @@ static sint validate_80211w_mgmt(struct adapter *adapter, union recv_frame *prec
                        }
                } else if (IS_MCAST(GetAddr1Ptr(ptr)) &&
                        (subtype == WIFI_DEAUTH || subtype == WIFI_DISASSOC)) {
-                       sint BIP_ret = _SUCCESS;
+                       signed int BIP_ret = _SUCCESS;
                        /* verify BIP MME IE of broadcast/multicast de-auth/disassoc packet */
                        BIP_ret = rtw_BIP_verify(adapter, (u8 *)precv_frame);
                        if (BIP_ret == _FAIL) {
@@ -1459,8 +1626,7 @@ static inline void dump_rx_packet(u8 *ptr)
        DBG_871X("#############################\n");
 }
 
-sint validate_recv_frame(struct adapter *adapter, union recv_frame *precv_frame);
-sint validate_recv_frame(struct adapter *adapter, union recv_frame *precv_frame)
+static signed int validate_recv_frame(struct adapter *adapter, union recv_frame *precv_frame)
 {
        /* shall check frame subtype, to / from ds, da, bssid */
 
@@ -1468,7 +1634,7 @@ sint validate_recv_frame(struct adapter *adapter, union recv_frame *precv_frame)
 
        u8 type;
        u8 subtype;
-       sint retval = _SUCCESS;
+       signed int retval = _SUCCESS;
        u8 bDumpRxPkt;
 
        struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
@@ -1557,12 +1723,10 @@ exit:
        return retval;
 }
 
-
 /* remove the wlanhdr and add the eth_hdr */
-sint wlanhdr_to_ethhdr(union recv_frame *precvframe);
-sint wlanhdr_to_ethhdr(union recv_frame *precvframe)
+static signed int wlanhdr_to_ethhdr(union recv_frame *precvframe)
 {
-       sint    rmv_len;
+       signed int      rmv_len;
        u16 eth_type, len;
        u8 bsnaphdr;
        u8 *psnap_type;
@@ -1600,38 +1764,6 @@ sint wlanhdr_to_ethhdr(union recv_frame *precvframe)
        eth_type = ntohs(be_tmp); /* pattrib->ether_type */
        pattrib->eth_type = eth_type;
 
-#ifdef CONFIG_AUTO_AP_MODE
-       if (0x8899 == pattrib->eth_type) {
-               struct sta_info *psta = precvframe->u.hdr.psta;
-
-               DBG_871X("wlan rx: got eth_type = 0x%x\n", pattrib->eth_type);
-
-               if (psta && psta->isrc && psta->pid > 0) {
-                       u16 rx_pid;
-
-                       rx_pid = *(u16 *)(ptr+rmv_len+2);
-
-                       DBG_871X("wlan rx(pid = 0x%x): sta(%pM) pid = 0x%x\n",
-                               rx_pid, MAC_ARG(psta->hwaddr), psta->pid);
-
-                       if (rx_pid == psta->pid) {
-                               int i;
-                               u16 len = *(u16 *)(ptr+rmv_len+4);
-                               /* u16 ctrl_type = *(u16*)(ptr+rmv_len+6); */
-
-                               /* DBG_871X("RC: len = 0x%x, ctrl_type = 0x%x\n", len, ctrl_type); */
-                               DBG_871X("RC: len = 0x%x\n", len);
-
-                               for (i = 0; i < len ; i++)
-                                       DBG_871X("0x%x\n", *(ptr+rmv_len+6+i));
-                                       /* DBG_871X("0x%x\n", *(ptr+rmv_len+8+i)); */
-
-                               DBG_871X("RC-end\n");
-                       }
-               }
-       }
-#endif /* CONFIG_AUTO_AP_MODE */
-
        if ((check_fwstate(pmlmepriv, WIFI_MP_STATE) == true)) {
                ptr += rmv_len;
                *ptr = 0x87;
@@ -1656,197 +1788,13 @@ sint wlanhdr_to_ethhdr(union recv_frame *precvframe)
        return _SUCCESS;
 }
 
-/* perform defrag */
-static union recv_frame *recvframe_defrag(struct adapter *adapter,
-                                         struct __queue *defrag_q)
-{
-       struct list_head         *plist, *phead;
-       u8  wlanhdr_offset;
-       u8 curfragnum;
-       struct recv_frame_hdr *pfhdr, *pnfhdr;
-       union recv_frame *prframe, *pnextrframe;
-       struct __queue  *pfree_recv_queue;
-
-       curfragnum = 0;
-       pfree_recv_queue = &adapter->recvpriv.free_recv_queue;
-
-       phead = get_list_head(defrag_q);
-       plist = get_next(phead);
-       prframe = (union recv_frame *)plist;
-       pfhdr = &prframe->u.hdr;
-       list_del_init(&(prframe->u.list));
-
-       if (curfragnum != pfhdr->attrib.frag_num) {
-               /* the first fragment number must be 0 */
-               /* free the whole queue */
-               rtw_free_recvframe(prframe, pfree_recv_queue);
-               rtw_free_recvframe_queue(defrag_q, pfree_recv_queue);
-
-               return NULL;
-       }
-
-       curfragnum++;
-
-       plist = get_list_head(defrag_q);
-
-       plist = get_next(plist);
-
-       while (phead != plist) {
-               pnextrframe = (union recv_frame *)plist;
-               pnfhdr = &pnextrframe->u.hdr;
-
-
-               /* check the fragment sequence  (2nd ~n fragment frame) */
-
-               if (curfragnum != pnfhdr->attrib.frag_num) {
-                       /* the fragment number must be increasing  (after decache) */
-                       /* release the defrag_q & prframe */
-                       rtw_free_recvframe(prframe, pfree_recv_queue);
-                       rtw_free_recvframe_queue(defrag_q, pfree_recv_queue);
-                       return NULL;
-               }
-
-               curfragnum++;
-
-               /* copy the 2nd~n fragment frame's payload to the first fragment */
-               /* get the 2nd~last fragment frame's payload */
-
-               wlanhdr_offset = pnfhdr->attrib.hdrlen + pnfhdr->attrib.iv_len;
-
-               recvframe_pull(pnextrframe, wlanhdr_offset);
-
-               /* append  to first fragment frame's tail (if privacy frame, pull the ICV) */
-               recvframe_pull_tail(prframe, pfhdr->attrib.icv_len);
-
-               /* memcpy */
-               memcpy(pfhdr->rx_tail, pnfhdr->rx_data, pnfhdr->len);
-
-               recvframe_put(prframe, pnfhdr->len);
-
-               pfhdr->attrib.icv_len = pnfhdr->attrib.icv_len;
-               plist = get_next(plist);
-
-       }
-
-       /* free the defrag_q queue and return the prframe */
-       rtw_free_recvframe_queue(defrag_q, pfree_recv_queue);
-
-       RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("Performance defrag!!!!!\n"));
-
-       return prframe;
-}
-
-/* check if need to defrag, if needed queue the frame to defrag_q */
-union recv_frame *recvframe_chk_defrag(struct adapter *padapter, union recv_frame *precv_frame)
-{
-       u8 ismfrag;
-       u8 fragnum;
-       u8 *psta_addr;
-       struct recv_frame_hdr *pfhdr;
-       struct sta_info *psta;
-       struct sta_priv *pstapriv;
-       struct list_head *phead;
-       union recv_frame *prtnframe = NULL;
-       struct __queue *pfree_recv_queue, *pdefrag_q;
-
-       pstapriv = &padapter->stapriv;
-
-       pfhdr = &precv_frame->u.hdr;
-
-       pfree_recv_queue = &padapter->recvpriv.free_recv_queue;
-
-       /* need to define struct of wlan header frame ctrl */
-       ismfrag = pfhdr->attrib.mfrag;
-       fragnum = pfhdr->attrib.frag_num;
-
-       psta_addr = pfhdr->attrib.ta;
-       psta = rtw_get_stainfo(pstapriv, psta_addr);
-       if (!psta) {
-               u8 type = GetFrameType(pfhdr->rx_data);
-               if (type != WIFI_DATA_TYPE) {
-                       psta = rtw_get_bcmc_stainfo(padapter);
-                       pdefrag_q = &psta->sta_recvpriv.defrag_q;
-               } else
-                       pdefrag_q = NULL;
-       } else
-               pdefrag_q = &psta->sta_recvpriv.defrag_q;
-
-       if ((ismfrag == 0) && (fragnum == 0))
-               prtnframe = precv_frame;/* isn't a fragment frame */
-
-       if (ismfrag == 1) {
-               /* 0~(n-1) fragment frame */
-               /* enqueue to defraf_g */
-               if (pdefrag_q) {
-                       if (fragnum == 0)
-                               /* the first fragment */
-                               if (!list_empty(&pdefrag_q->queue))
-                                       /* free current defrag_q */
-                                       rtw_free_recvframe_queue(pdefrag_q, pfree_recv_queue);
-
-
-                       /* Then enqueue the 0~(n-1) fragment into the defrag_q */
-
-                       /* spin_lock(&pdefrag_q->lock); */
-                       phead = get_list_head(pdefrag_q);
-                       list_add_tail(&pfhdr->list, phead);
-                       /* spin_unlock(&pdefrag_q->lock); */
-
-                       RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("Enqueuq: ismfrag = %d, fragnum = %d\n", ismfrag, fragnum));
-
-                       prtnframe = NULL;
-
-               } else {
-                       /* can't find this ta's defrag_queue, so free this recv_frame */
-                       rtw_free_recvframe(precv_frame, pfree_recv_queue);
-                       prtnframe = NULL;
-                       RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("Free because pdefrag_q == NULL: ismfrag = %d, fragnum = %d\n", ismfrag, fragnum));
-               }
-
-       }
-
-       if ((ismfrag == 0) && (fragnum != 0)) {
-               /* the last fragment frame */
-               /* enqueue the last fragment */
-               if (pdefrag_q) {
-                       /* spin_lock(&pdefrag_q->lock); */
-                       phead = get_list_head(pdefrag_q);
-                       list_add_tail(&pfhdr->list, phead);
-                       /* spin_unlock(&pdefrag_q->lock); */
-
-                       /* call recvframe_defrag to defrag */
-                       RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("defrag: ismfrag = %d, fragnum = %d\n", ismfrag, fragnum));
-                       precv_frame = recvframe_defrag(padapter, pdefrag_q);
-                       prtnframe = precv_frame;
-
-               } else {
-                       /* can't find this ta's defrag_queue, so free this recv_frame */
-                       rtw_free_recvframe(precv_frame, pfree_recv_queue);
-                       prtnframe = NULL;
-                       RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("Free because pdefrag_q == NULL: ismfrag = %d, fragnum = %d\n", ismfrag, fragnum));
-               }
-
-       }
-
-
-       if ((prtnframe) && (prtnframe->u.hdr.attrib.privacy)) {
-               /* after defrag we must check tkip mic code */
-               if (recvframe_chkmic(padapter,  prtnframe) == _FAIL) {
-                       RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvframe_chkmic(padapter,  prtnframe) == _FAIL\n"));
-                       rtw_free_recvframe(prtnframe, pfree_recv_queue);
-                       prtnframe = NULL;
-               }
-       }
-       return prtnframe;
-}
-
 static int amsdu_to_msdu(struct adapter *padapter, union recv_frame *prframe)
 {
        int     a_len, padding_len;
        u16 nSubframe_Length;
        u8 nr_subframes, i;
        u8 *pdata;
-       _pkt *sub_pkt, *subframes[MAX_SUBFRAME_COUNT];
+       struct sk_buff *sub_pkt, *subframes[MAX_SUBFRAME_COUNT];
        struct recv_priv *precvpriv = &padapter->recvpriv;
        struct __queue *pfree_recv_queue = &(precvpriv->free_recv_queue);
 
@@ -1918,8 +1866,7 @@ static int amsdu_to_msdu(struct adapter *padapter, union recv_frame *prframe)
        return  _SUCCESS;
 }
 
-int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl, u16 seq_num);
-int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl, u16 seq_num)
+static int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl, u16 seq_num)
 {
        struct adapter *padapter = preorder_ctrl->padapter;
        struct dvobj_priv *psdpriv = padapter->dvobj;
@@ -1987,8 +1934,7 @@ int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl, u16 seq_num)
        return true;
 }
 
-int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, union recv_frame *prframe);
-int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, union recv_frame *prframe)
+static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, union recv_frame *prframe)
 {
        struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib;
        struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue;
@@ -2040,8 +1986,7 @@ int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, union rec
 
 }
 
-void recv_indicatepkts_pkt_loss_cnt(struct debug_priv *pdbgpriv, u64 prev_seq, u64 current_seq);
-void recv_indicatepkts_pkt_loss_cnt(struct debug_priv *pdbgpriv, u64 prev_seq, u64 current_seq)
+static void recv_indicatepkts_pkt_loss_cnt(struct debug_priv *pdbgpriv, u64 prev_seq, u64 current_seq)
 {
        if (current_seq < prev_seq)
                pdbgpriv->dbg_rx_ampdu_loss_count += (4096 + current_seq - prev_seq);
@@ -2049,8 +1994,8 @@ void recv_indicatepkts_pkt_loss_cnt(struct debug_priv *pdbgpriv, u64 prev_seq, u
                pdbgpriv->dbg_rx_ampdu_loss_count += (current_seq - prev_seq);
 
 }
-int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reorder_ctrl *preorder_ctrl, int bforced);
-int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reorder_ctrl *preorder_ctrl, int bforced)
+
+static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reorder_ctrl *preorder_ctrl, int bforced)
 {
        struct list_head        *phead, *plist;
        union recv_frame *prframe;
@@ -2157,8 +2102,7 @@ int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reorder_ctr
        return bPktInBuf;
 }
 
-int recv_indicatepkt_reorder(struct adapter *padapter, union recv_frame *prframe);
-int recv_indicatepkt_reorder(struct adapter *padapter, union recv_frame *prframe)
+static int recv_indicatepkt_reorder(struct adapter *padapter, union recv_frame *prframe)
 {
        int retval = _SUCCESS;
        struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib;
@@ -2311,8 +2255,7 @@ void rtw_reordering_ctrl_timeout_handler(struct timer_list *t)
 
 }
 
-int process_recv_indicatepkts(struct adapter *padapter, union recv_frame *prframe);
-int process_recv_indicatepkts(struct adapter *padapter, union recv_frame *prframe)
+static int process_recv_indicatepkts(struct adapter *padapter, union recv_frame *prframe)
 {
        int retval = _SUCCESS;
        /* struct recv_priv *precvpriv = &padapter->recvpriv; */
@@ -2434,9 +2377,7 @@ _recv_data_drop:
        return ret;
 }
 
-
-int recv_func(struct adapter *padapter, union recv_frame *rframe);
-int recv_func(struct adapter *padapter, union recv_frame *rframe)
+static int recv_func(struct adapter *padapter, union recv_frame *rframe)
 {
        int ret;
        struct rx_pkt_attrib *prxattrib = &rframe->u.hdr.attrib;
index a311595deafb90248ea664257f0147c0e9b91158..44e2b362c8678f86fa07ff12d1c0ea052d8d2c3d 100644 (file)
@@ -148,7 +148,7 @@ static void arcfour_encrypt(struct arc4context *parc4ctx, u8 *dest, u8 *src, u32
                dest[i] = src[i] ^ (unsigned char)arcfour_byte(parc4ctx);
 }
 
-static sint bcrc32initialized;
+static signed int bcrc32initialized;
 static u32 crc32_table[256];
 
 
@@ -162,7 +162,7 @@ static void crc32_init(void)
        if (bcrc32initialized == 1)
                return;
        else {
-               sint i, j;
+               signed int i, j;
                u32 c;
                u8 *p = (u8 *)&c, *p1;
                u8 k;
@@ -184,7 +184,7 @@ static void crc32_init(void)
        }
 }
 
-static __le32 getcrc32(u8 *buf, sint len)
+static __le32 getcrc32(u8 *buf, signed int len)
 {
        u8 *p;
        u32  crc;
@@ -209,7 +209,7 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe)
        unsigned char crc[4];
        struct arc4context       mycontext;
 
-       sint    curfragnum, length;
+       signed int      curfragnum, length;
        u32 keylength;
 
        u8 *pframe, *payload, *iv;    /* wepkey */
@@ -266,7 +266,7 @@ void rtw_wep_decrypt(struct adapter  *padapter, u8 *precvframe)
        /*  exclude ICV */
        u8 crc[4];
        struct arc4context       mycontext;
-       sint    length;
+       signed int      length;
        u32 keylength;
        u8 *pframe, *payload, *iv, wepkey[16];
        u8  keyindex;
@@ -319,7 +319,7 @@ static u32 secmicgetuint32(u8 *p)
        u32 res = 0;
 
        for (i = 0; i < 4; i++)
-               res |= ((u32)(*p++)) << (8*i);
+               res |= ((u32)(*p++)) << (8 * i);
 
        return res;
 }
@@ -397,7 +397,7 @@ void rtw_secgetmic(struct mic_data *pmicdata, u8 *dst)
                rtw_secmicappendbyte(pmicdata, 0);
        /*  The appendByte function has already computed the result. */
        secmicputuint32(dst, pmicdata->L);
-       secmicputuint32(dst+4, pmicdata->R);
+       secmicputuint32(dst + 4, pmicdata->R);
        /*  Reset to the empty message. */
        secmicclear(pmicdata);
 }
@@ -413,15 +413,15 @@ void rtw_seccalctkipmic(u8 *key, u8 *header, u8 *data, u32 data_len, u8 *mic_cod
        priority[0] = pri;
 
        /* Michael MIC pseudo header: DA, SA, 3 x 0, Priority */
-       if (header[1]&1) {   /* ToDS == 1 */
+       if (header[1] & 1) {   /* ToDS == 1 */
                rtw_secmicappend(&micdata, &header[16], 6);  /* DA */
-               if (header[1]&2)  /* From Ds == 1 */
+               if (header[1] & 2)  /* From Ds == 1 */
                        rtw_secmicappend(&micdata, &header[24], 6);
                else
                        rtw_secmicappend(&micdata, &header[10], 6);
        } else {        /* ToDS == 0 */
                rtw_secmicappend(&micdata, &header[4], 6);   /* DA */
-               if (header[1]&2)  /* From Ds == 1 */
+               if (header[1] & 2)  /* From Ds == 1 */
                        rtw_secmicappend(&micdata, &header[16], 6);
                else
                        rtw_secmicappend(&micdata, &header[10], 6);
@@ -549,7 +549,7 @@ static const unsigned short Sbox1[2][256] = {      /* Sbox for hash (can be in R
 */
 static void phase1(u16 *p1k, const u8 *tk, const u8 *ta, u32 iv32)
 {
-       sint  i;
+       signed int  i;
 
        /* Initialize the 80 bits of P1K[] from IV32 and TA[0..5]     */
        p1k[0]      = Lo16(iv32);
@@ -597,7 +597,7 @@ static void phase1(u16 *p1k, const u8 *tk, const u8 *ta, u32 iv32)
 */
 static void phase2(u8 *rc4key, const u8 *tk, const u16 *p1k, u16 iv16)
 {
-       sint  i;
+       signed int  i;
        u16 PPK[6];                          /* temporary key for mixing    */
 
        /* Note: all adds in the PPK[] equations below are mod 2**16         */
@@ -651,7 +651,7 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe)
        u8 crc[4];
        u8   hw_hdr_offset = 0;
        struct arc4context mycontext;
-       sint                    curfragnum, length;
+       signed int                      curfragnum, length;
 
        u8 *pframe, *payload, *iv, *prwskey;
        union pn48 dot11txpn;
@@ -727,7 +727,7 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe)
        u8   ttkey[16];
        u8 crc[4];
        struct arc4context mycontext;
-       sint                    length;
+       signed int                      length;
 
        u8 *pframe, *payload, *iv, *prwskey;
        union pn48 dot11txpn;
@@ -874,31 +874,31 @@ exit:
 
 static void bitwise_xor(u8 *ina, u8 *inb, u8 *out);
 static void construct_mic_iv(u8 *mic_header1,
-                            sint qc_exists,
-                            sint a4_exists,
+                            signed int qc_exists,
+                            signed int a4_exists,
                             u8 *mpdu,
                             uint payload_length,
                             u8 *pn_vector,
                             uint frtype); /*  add for CONFIG_IEEE80211W, none 11w also can use */
 static void construct_mic_header1(u8 *mic_header1,
-                                 sint header_length,
+                                 signed int header_length,
                                  u8 *mpdu,
                                  uint frtype); /* for CONFIG_IEEE80211W, none 11w also can use */
 static void construct_mic_header2(u8 *mic_header2,
                                  u8 *mpdu,
-                                 sint a4_exists,
-                                 sint qc_exists);
+                                 signed int a4_exists,
+                                 signed int qc_exists);
 static void construct_ctr_preload(u8 *ctr_preload,
-                                 sint a4_exists,
-                                 sint qc_exists,
+                                 signed int a4_exists,
+                                 signed int qc_exists,
                                  u8 *mpdu,
                                  u8 *pn_vector,
-                                 sint c,
+                                 signed int c,
                                  uint frtype); /* for CONFIG_IEEE80211W, none 11w also can use */
 static void xor_128(u8 *a, u8 *b, u8 *out);
 static void xor_32(u8 *a, u8 *b, u8 *out);
 static u8 sbox(u8 a);
-static void next_key(u8 *key, sint round);
+static void next_key(u8 *key, signed int round);
 static void byte_sub(u8 *in, u8 *out);
 static void shift_row(u8 *in, u8 *out);
 static void mix_column(u8 *in, u8 *out);
@@ -912,7 +912,7 @@ static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext);
 /****************************************/
 static void xor_128(u8 *a, u8 *b, u8 *out)
 {
-               sint i;
+               signed int i;
 
                for (i = 0; i < 16; i++)
                        out[i] = a[i] ^ b[i];
@@ -921,7 +921,7 @@ static void xor_128(u8 *a, u8 *b, u8 *out)
 
 static void xor_32(u8 *a, u8 *b, u8 *out)
 {
-               sint i;
+               signed int i;
 
                for (i = 0; i < 4; i++)
                        out[i] = a[i] ^ b[i];
@@ -930,11 +930,11 @@ static void xor_32(u8 *a, u8 *b, u8 *out)
 
 static u8 sbox(u8 a)
 {
-               return sbox_table[(sint)a];
+               return sbox_table[(signed int)a];
 }
 
 
-static void next_key(u8 *key, sint round)
+static void next_key(u8 *key, signed int round)
 {
                u8 rcon;
                u8 sbox_key[4];
@@ -961,7 +961,7 @@ static void next_key(u8 *key, sint round)
 
 static void byte_sub(u8 *in, u8 *out)
 {
-               sint i;
+               signed int i;
 
                for (i = 0; i < 16; i++)
                        out[i] = sbox(in[i]);
@@ -990,7 +990,7 @@ static void shift_row(u8 *in, u8 *out)
 
 static void mix_column(u8 *in, u8 *out)
 {
-               sint i;
+               signed int i;
                u8 add1b[4];
                u8 add1bf7[4];
                u8 rotl[4];
@@ -1047,8 +1047,8 @@ static void mix_column(u8 *in, u8 *out)
 
 static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext)
 {
-               sint round;
-               sint i;
+               signed int round;
+               signed int i;
                u8 intermediatea[16];
                u8 intermediateb[16];
                u8 round_key[16];
@@ -1084,14 +1084,14 @@ static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext)
 /* nonce                                        */
 /************************************************/
 static void construct_mic_iv(u8 *mic_iv,
-                            sint qc_exists,
-                            sint a4_exists,
+                            signed int qc_exists,
+                            signed int a4_exists,
                             u8 *mpdu,
                             uint payload_length,
                             u8 *pn_vector,
                             uint frtype) /* add for CONFIG_IEEE80211W, none 11w also can use */
 {
-               sint i;
+               signed int i;
 
                mic_iv[0] = 0x59;
 
@@ -1128,7 +1128,7 @@ static void construct_mic_iv(u8 *mic_iv,
 /* Build AAD SC, A1, A2                           */
 /************************************************/
 static void construct_mic_header1(u8 *mic_header1,
-                                 sint header_length,
+                                 signed int header_length,
                                  u8 *mpdu,
                                  uint frtype) /* for CONFIG_IEEE80211W, none 11w also can use */
 {
@@ -1163,10 +1163,10 @@ static void construct_mic_header1(u8 *mic_header1,
 /************************************************/
 static void construct_mic_header2(u8 *mic_header2,
                                  u8 *mpdu,
-                                 sint a4_exists,
-                                 sint qc_exists)
+                                 signed int a4_exists,
+                                 signed int qc_exists)
 {
-               sint i;
+               signed int i;
 
                for (i = 0; i < 16; i++)
                        mic_header2[i] = 0x00;
@@ -1208,14 +1208,14 @@ static void construct_mic_header2(u8 *mic_header2,
 /* nonce                                        */
 /************************************************/
 static void construct_ctr_preload(u8 *ctr_preload,
-                                 sint a4_exists,
-                                 sint qc_exists,
+                                 signed int a4_exists,
+                                 signed int qc_exists,
                                  u8 *mpdu,
                                  u8 *pn_vector,
-                                 sint c,
+                                 signed int c,
                                  uint frtype) /* for CONFIG_IEEE80211W, none 11w also can use */
 {
-       sint i = 0;
+       signed int i = 0;
 
        for (i = 0; i < 16; i++)
                ctr_preload[i] = 0x00;
@@ -1250,13 +1250,13 @@ static void construct_ctr_preload(u8 *ctr_preload,
 /************************************/
 static void bitwise_xor(u8 *ina, u8 *inb, u8 *out)
 {
-               sint i;
+               signed int i;
 
                for (i = 0; i < 16; i++)
                        out[i] = ina[i] ^ inb[i];
 }
 
-static sint aes_cipher(u8 *key, uint   hdrlen,
+static signed int aes_cipher(u8 *key, uint     hdrlen,
                        u8 *pframe, uint plen)
 {
        uint    qc_exists, a4_exists, i, j, payload_remainder,
@@ -1428,7 +1428,7 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe)
        /* unsigned char message[MAX_MSG_SIZE]; */
 
        /* Intermediate Buffers */
-       sint curfragnum, length;
+       signed int curfragnum, length;
        u8 *pframe, *prwskey;   /*  *payload,*iv */
        u8 hw_hdr_offset = 0;
        struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib;
@@ -1471,13 +1471,13 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe)
        return res;
 }
 
-static sint aes_decipher(u8 *key, uint hdrlen,
+static signed int aes_decipher(u8 *key, uint   hdrlen,
                         u8 *pframe, uint plen)
 {
        static u8 message[MAX_MSG_SIZE];
        uint qc_exists, a4_exists, i, j, payload_remainder,
                        num_blocks, payload_index;
-       sint res = _SUCCESS;
+       signed int res = _SUCCESS;
        u8 pn_vector[6];
        u8 mic_iv[16];
        u8 mic_header1[16];
@@ -1704,7 +1704,7 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe)
 
        /* Intermediate Buffers */
 
-       sint length;
+       signed int length;
        u8 *pframe, *prwskey;   /*  *payload,*iv */
        struct sta_info *stainfo;
        struct rx_pkt_attrib *prxattrib = &((union recv_frame *)precvframe)->u.hdr.attrib;
@@ -2241,7 +2241,7 @@ int omac1_aes_128(u8 *key, u8 *data, size_t data_len, u8 *mac)
 void rtw_sec_restore_wep_key(struct adapter *adapter)
 {
        struct security_priv *securitypriv = &(adapter->securitypriv);
-       sint keyid;
+       signed int keyid;
 
        if ((_WEP40_ == securitypriv->dot11PrivacyAlgrthm) || (_WEP104_ == securitypriv->dot11PrivacyAlgrthm)) {
                for (keyid = 0; keyid < 4; keyid++) {
index 96feced698acf16d868a28ef573f70bf109fb33a..760b0ea4e9bd63b48a98247ee837f9196370b7cd 100644 (file)
 #include <rtw_debug.h>
 #include <hal_com_h2c.h>
 
-#if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN)
-#include <linux/inetdevice.h>
-#endif
-
 static unsigned char ARTHEROS_OUI1[] = {0x00, 0x03, 0x7f};
 static unsigned char ARTHEROS_OUI2[] = {0x00, 0x13, 0x74};
 
@@ -29,9 +25,6 @@ static unsigned char AIRGOCAP_OUI[] = {0x00, 0x0a, 0xf5};
 static unsigned char RSN_TKIP_CIPHER[4] = {0x00, 0x0f, 0xac, 0x02};
 static unsigned char WPA_TKIP_CIPHER[4] = {0x00, 0x50, 0xf2, 0x02};
 
-extern unsigned char RTW_WPA_OUI[];
-extern unsigned char WPA_TKIP_CIPHER[4];
-
 #define R2T_PHY_DELAY  (0)
 
 /* define WAIT_FOR_BCN_TO_MIN  (3000) */
@@ -1075,14 +1068,7 @@ void HT_caps_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE)
                break;
        case RF_2T2R:
        default:
-#ifdef CONFIG_DISABLE_MCS13TO15
-               if (pmlmeext->cur_bwmode == CHANNEL_WIDTH_40 && pregistrypriv->wifi_spec != 1)
-                       set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_2R_13TO15_OFF);
-               else
-                       set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_2R);
-#else /* CONFIG_DISABLE_MCS13TO15 */
                set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_2R);
-#endif /* CONFIG_DISABLE_MCS13TO15 */
        }
 
        if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
@@ -1137,8 +1123,6 @@ void HTOnAssocRsp(struct adapter *padapter)
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
 
-       DBG_871X("%s\n", __func__);
-
        if ((pmlmeinfo->HT_info_enable) && (pmlmeinfo->HT_caps_enable)) {
                pmlmeinfo->HT_enable = 1;
        } else {
@@ -1760,7 +1744,7 @@ void update_wireless_mode(struct adapter *padapter)
 
        if (pmlmeext->cur_wireless_mode & WIRELESS_11B)
                update_mgnt_tx_rate(padapter, IEEE80211_CCK_RATE_1MB);
-        else
+       else
                update_mgnt_tx_rate(padapter, IEEE80211_OFDM_RATE_6MB);
 }
 
@@ -1820,15 +1804,7 @@ void process_addba_req(struct adapter *padapter, u8 *paddba_req, u8 *addr)
 
                preorder_ctrl = &psta->recvreorder_ctrl[tid];
 
-               #ifdef CONFIG_UPDATE_INDICATE_SEQ_WHILE_PROCESS_ADDBA_REQ
-               preorder_ctrl->indicate_seq = start_seq;
-               #ifdef DBG_RX_SEQ
-               DBG_871X("DBG_RX_SEQ %s:%d IndicateSeq: %d, start_seq: %d\n", __func__, __LINE__,
-                       preorder_ctrl->indicate_seq, start_seq);
-               #endif
-               #else
                preorder_ctrl->indicate_seq = 0xffff;
-               #endif
 
                preorder_ctrl->enable = pmlmeinfo->accept_addba_req;
        }
@@ -2018,182 +1994,3 @@ struct adapter *dvobj_get_port0_adapter(struct dvobj_priv *dvobj)
 
        return dvobj->padapters;
 }
-
-#ifdef CONFIG_GPIO_API
-int rtw_get_gpio(struct net_device *netdev, int gpio_num)
-{
-       u8 value;
-       u8 direction;
-       struct adapter *adapter = rtw_netdev_priv(netdev);
-       struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(adapter);
-
-       rtw_ps_deny(adapter, PS_DENY_IOCTL);
-
-       DBG_871X("rf_pwrstate = 0x%02x\n", pwrpriv->rf_pwrstate);
-       LeaveAllPowerSaveModeDirect(adapter);
-
-       /* Read GPIO Direction */
-       direction = (rtw_read8(adapter, REG_GPIO_PIN_CTRL + 2) & BIT(gpio_num)) >> gpio_num;
-
-       /* According the direction to read register value */
-       if (direction)
-               value = (rtw_read8(adapter, REG_GPIO_PIN_CTRL + 1) & BIT(gpio_num)) >> gpio_num;
-       else
-               value = (rtw_read8(adapter, REG_GPIO_PIN_CTRL) & BIT(gpio_num)) >> gpio_num;
-
-       rtw_ps_deny_cancel(adapter, PS_DENY_IOCTL);
-       DBG_871X("%s direction =%d value =%d\n", __func__, direction, value);
-
-       return value;
-}
-EXPORT_SYMBOL(rtw_get_gpio);
-
-int  rtw_set_gpio_output_value(struct net_device *netdev, int gpio_num, bool isHigh)
-{
-       u8 direction = 0;
-       u8 res = -1;
-       struct adapter *adapter = rtw_netdev_priv(netdev);
-
-       /* Check GPIO is 4~7 */
-       if (gpio_num > 7 || gpio_num < 4) {
-               DBG_871X("%s The gpio number does not included 4~7.\n", __func__);
-               return -1;
-       }
-
-       rtw_ps_deny(adapter, PS_DENY_IOCTL);
-
-       LeaveAllPowerSaveModeDirect(adapter);
-
-       /* Read GPIO direction */
-       direction = (rtw_read8(adapter, REG_GPIO_PIN_CTRL + 2) & BIT(gpio_num)) >> gpio_num;
-
-       /* If GPIO is output direction, setting value. */
-       if (direction) {
-               if (isHigh)
-                       rtw_write8(adapter, REG_GPIO_PIN_CTRL + 1, rtw_read8(adapter, REG_GPIO_PIN_CTRL + 1) | BIT(gpio_num));
-               else
-                       rtw_write8(adapter, REG_GPIO_PIN_CTRL + 1, rtw_read8(adapter, REG_GPIO_PIN_CTRL + 1) & ~BIT(gpio_num));
-
-               DBG_871X("%s Set gpio %x[%d]=%d\n", __func__, REG_GPIO_PIN_CTRL+1, gpio_num, isHigh);
-               res = 0;
-       } else {
-               DBG_871X("%s The gpio is input, not be set!\n", __func__);
-               res = -1;
-       }
-
-       rtw_ps_deny_cancel(adapter, PS_DENY_IOCTL);
-       return res;
-}
-EXPORT_SYMBOL(rtw_set_gpio_output_value);
-
-int rtw_config_gpio(struct net_device *netdev, int gpio_num, bool isOutput)
-{
-       struct adapter *adapter = rtw_netdev_priv(netdev);
-
-       if (gpio_num > 7 || gpio_num < 4) {
-               DBG_871X("%s The gpio number does not included 4~7.\n", __func__);
-               return -1;
-       }
-
-       DBG_871X("%s gpio_num =%d direction =%d\n", __func__, gpio_num, isOutput);
-
-       rtw_ps_deny(adapter, PS_DENY_IOCTL);
-
-       LeaveAllPowerSaveModeDirect(adapter);
-
-       if (isOutput)
-               rtw_write8(adapter, REG_GPIO_PIN_CTRL + 2, rtw_read8(adapter, REG_GPIO_PIN_CTRL + 2) | BIT(gpio_num));
-       else
-               rtw_write8(adapter, REG_GPIO_PIN_CTRL + 2, rtw_read8(adapter, REG_GPIO_PIN_CTRL + 2) & ~BIT(gpio_num));
-
-       rtw_ps_deny_cancel(adapter, PS_DENY_IOCTL);
-
-       return 0;
-}
-EXPORT_SYMBOL(rtw_config_gpio);
-#endif
-
-#if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN)
-void rtw_get_current_ip_address(struct adapter *padapter, u8 *pcurrentip)
-{
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
-       struct in_device *my_ip_ptr = padapter->pnetdev->ip_ptr;
-       u8 ipaddress[4];
-
-       if ((pmlmeinfo->state & WIFI_FW_LINKING_STATE) ||
-                       pmlmeinfo->state & WIFI_FW_AP_STATE) {
-               if (my_ip_ptr) {
-                       struct in_ifaddr *my_ifa_list = my_ip_ptr->ifa_list;
-
-                       if (my_ifa_list) {
-                               ipaddress[0] = my_ifa_list->ifa_address & 0xFF;
-                               ipaddress[1] = (my_ifa_list->ifa_address >> 8) & 0xFF;
-                               ipaddress[2] = (my_ifa_list->ifa_address >> 16) & 0xFF;
-                               ipaddress[3] = my_ifa_list->ifa_address >> 24;
-                               DBG_871X("%s: %d.%d.%d.%d ==========\n", __func__,
-                                               ipaddress[0], ipaddress[1], ipaddress[2], ipaddress[3]);
-                               memcpy(pcurrentip, ipaddress, 4);
-                       }
-               }
-       }
-}
-#endif
-#ifdef CONFIG_WOWLAN
-void rtw_get_sec_iv(struct adapter *padapter, u8 *pcur_dot11txpn, u8 *StaAddr)
-{
-       struct sta_info *psta;
-       struct security_priv *psecpriv = &padapter->securitypriv;
-
-       memset(pcur_dot11txpn, 0, 8);
-       if (!StaAddr)
-               return;
-       psta = rtw_get_stainfo(&padapter->stapriv, StaAddr);
-       DBG_871X("%s(): StaAddr: %02x %02x %02x %02x %02x %02x\n",
-               __func__, StaAddr[0], StaAddr[1], StaAddr[2],
-               StaAddr[3], StaAddr[4], StaAddr[5]);
-
-       if (psta) {
-               if (psecpriv->dot11PrivacyAlgrthm != _NO_PRIVACY_ && psta->dot11txpn.val > 0)
-                       psta->dot11txpn.val--;
-               AES_IV(pcur_dot11txpn, psta->dot11txpn, 0);
-
-               DBG_871X("%s(): CurrentIV: %02x %02x %02x %02x %02x %02x %02x %02x\n"
-               , __func__, pcur_dot11txpn[0], pcur_dot11txpn[1],
-               pcur_dot11txpn[2], pcur_dot11txpn[3], pcur_dot11txpn[4],
-               pcur_dot11txpn[5], pcur_dot11txpn[6], pcur_dot11txpn[7]);
-       }
-}
-
-void rtw_set_sec_pn(struct adapter *padapter)
-{
-               struct sta_info         *psta;
-               struct mlme_ext_priv    *pmlmeext = &(padapter->mlmeextpriv);
-               struct mlme_ext_info    *pmlmeinfo = &(pmlmeext->mlmext_info);
-               struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter);
-               struct security_priv *psecpriv = &padapter->securitypriv;
-
-               psta = rtw_get_stainfo(&padapter->stapriv,
-               get_my_bssid(&pmlmeinfo->network));
-
-               if (psta) {
-                       if (pwrpriv->wowlan_fw_iv > psta->dot11txpn.val) {
-                               if (psecpriv->dot11PrivacyAlgrthm != _NO_PRIVACY_)
-                                       psta->dot11txpn.val = pwrpriv->wowlan_fw_iv + 2;
-                       } else {
-                               DBG_871X("%s(): FW IV is smaller than driver\n", __func__);
-                               psta->dot11txpn.val += 2;
-                       }
-                       DBG_871X("%s: dot11txpn: 0x%016llx\n", __func__, psta->dot11txpn.val);
-               }
-}
-#endif /* CONFIG_WOWLAN */
-
-#ifdef CONFIG_PNO_SUPPORT
-#define        CSCAN_TLV_TYPE_SSID_IE  'S'
-#define CIPHER_IE "key_mgmt ="
-#define CIPHER_NONE "NONE"
-#define CIPHER_WPA_PSK "WPA-PSK"
-#define CIPHER_WPA_EAP "WPA-EAP IEEE8021X"
-
-#endif /* CONFIG_PNO_SUPPORT */
index 19aecbabbc4d16fabfba68f2689d35eaea332469..2daf5c461a4dd598e4b396ca840b1f1f78eec0b4 100644 (file)
@@ -38,7 +38,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
        int i;
        struct xmit_buf *pxmitbuf;
        struct xmit_frame *pxframe;
-       sint    res = _SUCCESS;
+       signed int      res = _SUCCESS;
 
        spin_lock_init(&pxmitpriv->lock);
        spin_lock_init(&pxmitpriv->lock_sctx);
@@ -467,19 +467,14 @@ static void update_attrib_phy_info(struct adapter *padapter, struct pkt_attrib *
                pattrib->ampdu_spacing = psta->htpriv.rx_ampdu_min_spacing;
 
        pattrib->retry_ctrl = false;
-
-#ifdef CONFIG_AUTO_AP_MODE
-       if (psta->isrc && psta->pid > 0)
-               pattrib->pctrl = true;
-#endif
 }
 
 static s32 update_attrib_sec_info(struct adapter *padapter, struct pkt_attrib *pattrib, struct sta_info *psta)
 {
-       sint res = _SUCCESS;
+       signed int res = _SUCCESS;
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct security_priv *psecuritypriv = &padapter->securitypriv;
-       sint bmcast = IS_MCAST(pattrib->ra);
+       signed int bmcast = IS_MCAST(pattrib->ra);
 
        memset(pattrib->dot118021x_UncstKey.skey,  0, 16);
        memset(pattrib->dot11tkiptxmickey.skey,  0, 16);
@@ -641,17 +636,17 @@ static void set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib)
        pattrib->subtype = WIFI_QOS_DATA_TYPE;
 }
 
-static s32 update_attrib(struct adapter *padapter, _pkt *pkt, struct pkt_attrib *pattrib)
+static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct pkt_attrib *pattrib)
 {
        struct pkt_file pktfile;
        struct sta_info *psta = NULL;
        struct ethhdr etherhdr;
 
-       sint bmcast;
+       signed int bmcast;
        struct sta_priv *pstapriv = &padapter->stapriv;
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct qos_priv *pqospriv = &pmlmepriv->qospriv;
-       sint res = _SUCCESS;
+       signed int res = _SUCCESS;
 
        _rtw_open_pktfile(pkt, &pktfile);
        _rtw_pktfile_read(&pktfile, (u8 *)&etherhdr, ETH_HLEN);
@@ -793,7 +788,7 @@ exit:
 
 static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitframe)
 {
-       sint                    curfragnum, length;
+       signed int                      curfragnum, length;
        u8 *pframe, *payload, mic[8];
        struct mic_data micdata;
        struct pkt_attrib *pattrib = &pxmitframe->attrib;
@@ -801,7 +796,7 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr
        struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
        u8 priority[4] = {0x0, 0x0, 0x0, 0x0};
        u8 hw_hdr_offset = 0;
-       sint bmcst = IS_MCAST(pattrib->ra);
+       signed int bmcst = IS_MCAST(pattrib->ra);
 
        hw_hdr_offset = TXDESC_OFFSET;
 
@@ -922,7 +917,7 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct qos_priv *pqospriv = &pmlmepriv->qospriv;
        u8 qos_option = false;
-       sint res = _SUCCESS;
+       signed int res = _SUCCESS;
        __le16 *fctrl = &pwlanhdr->frame_control;
 
        memset(hdr, 0, WLANHDR_OFFSET);
@@ -1085,7 +1080,7 @@ This sub-routine will perform all the following:
 6. apply sw-encrypt, if necessary.
 
 */
-s32 rtw_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit_frame *pxmitframe)
+s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct xmit_frame *pxmitframe)
 {
        struct pkt_file pktfile;
 
@@ -1216,7 +1211,7 @@ exit:
 }
 
 /* broadcast or multicast management pkt use BIP, unicast management pkt use CCMP encryption */
-s32 rtw_mgmt_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit_frame *pxmitframe)
+s32 rtw_mgmt_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct xmit_frame *pxmitframe)
 {
        u8 *pframe, *mem_start = NULL, *tmp_buf = NULL;
        u8 subtype;
@@ -1416,7 +1411,7 @@ void rtw_update_protection(struct adapter *padapter, u8 *ie, uint ie_len)
 {
        uint    protection;
        u8 *perp;
-       sint     erp_len;
+       signed int       erp_len;
        struct  xmit_priv *pxmitpriv = &padapter->xmitpriv;
        struct  registry_priv *pregistrypriv = &padapter->registrypriv;
 
@@ -1534,7 +1529,7 @@ struct xmit_frame *__rtw_alloc_cmdxmitframe(struct xmit_priv *pxmitpriv,
 
 struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv)
 {
-       _irqL irqL;
+       unsigned long irqL;
        struct xmit_buf *pxmitbuf =  NULL;
        struct list_head *plist, *phead;
        struct __queue *pfree_queue = &pxmitpriv->free_xmit_extbuf_queue;
@@ -1578,7 +1573,7 @@ struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv)
 
 s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf)
 {
-       _irqL irqL;
+       unsigned long irqL;
        struct __queue *pfree_queue = &pxmitpriv->free_xmit_extbuf_queue;
 
        if (!pxmitbuf)
@@ -1601,7 +1596,7 @@ s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf)
 
 struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv)
 {
-       _irqL irqL;
+       unsigned long irqL;
        struct xmit_buf *pxmitbuf =  NULL;
        struct list_head *plist, *phead;
        struct __queue *pfree_xmitbuf_queue = &pxmitpriv->free_xmitbuf_queue;
@@ -1650,7 +1645,7 @@ struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv)
 
 s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf)
 {
-       _irqL irqL;
+       unsigned long irqL;
        struct __queue *pfree_xmitbuf_queue = &pxmitpriv->free_xmitbuf_queue;
 
        if (!pxmitbuf)
@@ -1804,7 +1799,7 @@ s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitfram
 {
        struct __queue *queue = NULL;
        struct adapter *padapter = pxmitpriv->adapter;
-       _pkt *pndis_pkt = NULL;
+       struct sk_buff *pndis_pkt = NULL;
 
        if (!pxmitframe) {
                RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("======rtw_free_xmitframe():pxmitframe == NULL!!!!!!!!!!\n"));
@@ -1884,7 +1879,7 @@ s32 rtw_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitfram
        return _SUCCESS;
 }
 
-struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, struct sta_info *psta, sint up, u8 *ac)
+struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, struct sta_info *psta, signed int up, u8 *ac)
 {
        struct tx_servq *ptxservq = NULL;
 
@@ -1933,7 +1928,7 @@ s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe)
        struct tx_servq *ptxservq;
        struct pkt_attrib       *pattrib = &pxmitframe->attrib;
        struct hw_xmit  *phwxmits =  padapter->xmitpriv.hwxmits;
-       sint res = _SUCCESS;
+       signed int res = _SUCCESS;
 
        psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra);
        if (pattrib->psta != psta) {
@@ -2014,9 +2009,9 @@ void rtw_free_hwxmits(struct adapter *padapter)
        kfree(pxmitpriv->hwxmits);
 }
 
-void rtw_init_hwxmits(struct hw_xmit *phwxmit, sint entry)
+void rtw_init_hwxmits(struct hw_xmit *phwxmit, signed int entry)
 {
-       sint i;
+       signed int i;
 
        for (i = 0; i < entry; i++, phwxmit++)
                phwxmit->accnt = 0;
@@ -2077,7 +2072,7 @@ static void do_queue_select(struct adapter        *padapter, struct pkt_attrib *pattrib
  *0    success, hardware will handle this xmit frame(packet)
  *<0   fail
  */
-s32 rtw_xmit(struct adapter *padapter, _pkt **ppkt)
+s32 rtw_xmit(struct adapter *padapter, struct sk_buff **ppkt)
 {
        static unsigned long start;
        static u32 drop_cnt;
@@ -2163,14 +2158,14 @@ inline bool xmitframe_hiq_filter(struct xmit_frame *xmitframe)
        return allow;
 }
 
-sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_frame *pxmitframe)
+signed int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_frame *pxmitframe)
 {
-       sint ret = false;
+       signed int ret = false;
        struct sta_info *psta = NULL;
        struct sta_priv *pstapriv = &padapter->stapriv;
        struct pkt_attrib *pattrib = &pxmitframe->attrib;
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       sint bmcst = IS_MCAST(pattrib->ra);
+       signed int bmcst = IS_MCAST(pattrib->ra);
        bool update_tim = false;
 
        if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == false)
@@ -2286,7 +2281,7 @@ sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fr
 
 static void dequeue_xmitframes_to_sleeping_queue(struct adapter *padapter, struct sta_info *psta, struct __queue *pframequeue)
 {
-       sint ret;
+       signed int ret;
        struct list_head        *plist, *phead;
        u8 ac_index;
        struct tx_servq *ptxservq;
@@ -2639,10 +2634,10 @@ struct xmit_buf *dequeue_pending_xmitbuf_under_survey(struct xmit_priv *pxmitpri
        return pxmitbuf;
 }
 
-sint check_pending_xmitbuf(struct xmit_priv *pxmitpriv)
+signed int check_pending_xmitbuf(struct xmit_priv *pxmitpriv)
 {
        struct __queue *pqueue;
-       sint    ret = false;
+       signed int      ret = false;
 
        pqueue = &pxmitpriv->pending_xmitbuf_queue;
 
index ef8c6a0f31ae2f34358b7b8ca650dea09d86b5a9..621f8181f46d11c3d08f20a4b12e4edb94539507 100644 (file)
@@ -8,10 +8,10 @@
 #include "Mp_Precomp.h"
 
 /*  Global variables, these are static variables */
-static struct COEX_DM_8723B_1ANT GLCoexDm8723b1Ant;
-static struct COEX_DM_8723B_1ANT * pCoexDm = &GLCoexDm8723b1Ant;
-static struct COEX_STA_8723B_1ANT GLCoexSta8723b1Ant;
-static struct COEX_STA_8723B_1ANT * pCoexSta = &GLCoexSta8723b1Ant;
+static struct coex_dm_8723b_1ant GLCoexDm8723b1Ant;
+static struct coex_dm_8723b_1ant *pCoexDm = &GLCoexDm8723b1Ant;
+static struct coex_sta_8723b_1ant GLCoexSta8723b1Ant;
+static struct coex_sta_8723b_1ant *pCoexSta = &GLCoexSta8723b1Ant;
 
 static const char *const GLBtInfoSrc8723b1Ant[] = {
        "BT Info[wifi fw]",
@@ -151,7 +151,7 @@ static u8 halbtc8723b1ant_BtRssiState(
 }
 
 static void halbtc8723b1ant_UpdateRaMask(
-       PBTC_COEXIST pBtCoexist, bool bForceExec, u32 disRateMask
+       struct btc_coexist *pBtCoexist, bool bForceExec, u32 disRateMask
 )
 {
        pCoexDm->curRaMask = disRateMask;
@@ -166,7 +166,7 @@ static void halbtc8723b1ant_UpdateRaMask(
 }
 
 static void halbtc8723b1ant_AutoRateFallbackRetry(
-       PBTC_COEXIST pBtCoexist, bool bForceExec, u8 type
+       struct btc_coexist *pBtCoexist, bool bForceExec, u8 type
 )
 {
        bool bWifiUnderBMode = false;
@@ -204,7 +204,7 @@ static void halbtc8723b1ant_AutoRateFallbackRetry(
 }
 
 static void halbtc8723b1ant_RetryLimit(
-       PBTC_COEXIST pBtCoexist, bool bForceExec, u8 type
+       struct btc_coexist *pBtCoexist, bool bForceExec, u8 type
 )
 {
        pCoexDm->curRetryLimitType = type;
@@ -231,7 +231,7 @@ static void halbtc8723b1ant_RetryLimit(
 }
 
 static void halbtc8723b1ant_AmpduMaxTime(
-       PBTC_COEXIST pBtCoexist, bool bForceExec, u8 type
+       struct btc_coexist *pBtCoexist, bool bForceExec, u8 type
 )
 {
        pCoexDm->curAmpduTimeType = type;
@@ -257,7 +257,7 @@ static void halbtc8723b1ant_AmpduMaxTime(
 }
 
 static void halbtc8723b1ant_LimitedTx(
-       PBTC_COEXIST pBtCoexist,
+       struct btc_coexist *pBtCoexist,
        bool bForceExec,
        u8 raMaskType,
        u8 arfrType,
@@ -285,7 +285,7 @@ static void halbtc8723b1ant_LimitedTx(
 }
 
 static void halbtc8723b1ant_LimitedRx(
-       PBTC_COEXIST pBtCoexist,
+       struct btc_coexist *pBtCoexist,
        bool bForceExec,
        bool bRejApAggPkt,
        bool bBtCtrlAggBufSize,
@@ -314,7 +314,7 @@ static void halbtc8723b1ant_LimitedRx(
 
 }
 
-static void halbtc8723b1ant_QueryBtInfo(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b1ant_QueryBtInfo(struct btc_coexist *pBtCoexist)
 {
        u8      H2C_Parameter[1] = {0};
 
@@ -331,7 +331,7 @@ static void halbtc8723b1ant_QueryBtInfo(PBTC_COEXIST pBtCoexist)
        pBtCoexist->fBtcFillH2c(pBtCoexist, 0x61, 1, H2C_Parameter);
 }
 
-static void halbtc8723b1ant_MonitorBtCtr(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b1ant_MonitorBtCtr(struct btc_coexist *pBtCoexist)
 {
        u32 regHPTxRx, regLPTxRx, u4Tmp;
        u32 regHPTx = 0, regHPRx = 0, regLPTx = 0, regLPRx = 0;
@@ -392,7 +392,7 @@ static void halbtc8723b1ant_MonitorBtCtr(PBTC_COEXIST pBtCoexist)
 }
 
 
-static void halbtc8723b1ant_MonitorWiFiCtr(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b1ant_MonitorWiFiCtr(struct btc_coexist *pBtCoexist)
 {
        s32     wifiRssi = 0;
        bool bWifiBusy = false, bWifiUnderBMode = false;
@@ -478,7 +478,7 @@ static void halbtc8723b1ant_MonitorWiFiCtr(PBTC_COEXIST pBtCoexist)
 
 }
 
-static bool halbtc8723b1ant_IsWifiStatusChanged(PBTC_COEXIST pBtCoexist)
+static bool halbtc8723b1ant_IsWifiStatusChanged(struct btc_coexist *pBtCoexist)
 {
        static bool     bPreWifiBusy, bPreUnder4way, bPreBtHsOn;
        bool bWifiBusy = false, bUnder4way = false, bBtHsOn = false;
@@ -513,9 +513,9 @@ static bool halbtc8723b1ant_IsWifiStatusChanged(PBTC_COEXIST pBtCoexist)
        return false;
 }
 
-static void halbtc8723b1ant_UpdateBtLinkInfo(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b1ant_UpdateBtLinkInfo(struct btc_coexist *pBtCoexist)
 {
-       PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
+       struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
        bool bBtHsOn = false;
 
        pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
@@ -577,9 +577,9 @@ static void halbtc8723b1ant_UpdateBtLinkInfo(PBTC_COEXIST pBtCoexist)
                pBtLinkInfo->bHidOnly = false;
 }
 
-static u8 halbtc8723b1ant_ActionAlgorithm(PBTC_COEXIST pBtCoexist)
+static u8 halbtc8723b1ant_ActionAlgorithm(struct btc_coexist *pBtCoexist)
 {
-       PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
+       struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
        bool bBtHsOn = false;
        u8 algorithm = BT_8723B_1ANT_COEX_ALGO_UNDEFINED;
        u8 numOfDiffProfile = 0;
@@ -805,7 +805,7 @@ static u8 halbtc8723b1ant_ActionAlgorithm(PBTC_COEXIST pBtCoexist)
 }
 
 static void halbtc8723b1ant_SetSwPenaltyTxRateAdaptive(
-       PBTC_COEXIST pBtCoexist, bool bLowPenaltyRa
+       struct btc_coexist *pBtCoexist, bool bLowPenaltyRa
 )
 {
        u8      H2C_Parameter[6] = {0};
@@ -833,7 +833,7 @@ static void halbtc8723b1ant_SetSwPenaltyTxRateAdaptive(
 }
 
 static void halbtc8723b1ant_LowPenaltyRa(
-       PBTC_COEXIST pBtCoexist, bool bForceExec, bool bLowPenaltyRa
+       struct btc_coexist *pBtCoexist, bool bForceExec, bool bLowPenaltyRa
 )
 {
        pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa;
@@ -850,7 +850,7 @@ static void halbtc8723b1ant_LowPenaltyRa(
 }
 
 static void halbtc8723b1ant_SetCoexTable(
-       PBTC_COEXIST pBtCoexist,
+       struct btc_coexist *pBtCoexist,
        u32 val0x6c0,
        u32 val0x6c4,
        u32 val0x6c8,
@@ -887,7 +887,7 @@ static void halbtc8723b1ant_SetCoexTable(
 }
 
 static void halbtc8723b1ant_CoexTable(
-       PBTC_COEXIST pBtCoexist,
+       struct btc_coexist *pBtCoexist,
        bool bForceExec,
        u32 val0x6c0,
        u32 val0x6c4,
@@ -930,7 +930,7 @@ static void halbtc8723b1ant_CoexTable(
 }
 
 static void halbtc8723b1ant_CoexTableWithType(
-       PBTC_COEXIST pBtCoexist, bool bForceExec, u8 type
+       struct btc_coexist *pBtCoexist, bool bForceExec, u8 type
 )
 {
        BTC_PRINT(
@@ -988,7 +988,7 @@ static void halbtc8723b1ant_CoexTableWithType(
 }
 
 static void halbtc8723b1ant_SetFwIgnoreWlanAct(
-       PBTC_COEXIST pBtCoexist, bool bEnable
+       struct btc_coexist *pBtCoexist, bool bEnable
 )
 {
        u8 H2C_Parameter[1] = {0};
@@ -1009,7 +1009,7 @@ static void halbtc8723b1ant_SetFwIgnoreWlanAct(
 }
 
 static void halbtc8723b1ant_IgnoreWlanAct(
-       PBTC_COEXIST pBtCoexist, bool bForceExec, bool bEnable
+       struct btc_coexist *pBtCoexist, bool bForceExec, bool bEnable
 )
 {
        BTC_PRINT(
@@ -1043,7 +1043,7 @@ static void halbtc8723b1ant_IgnoreWlanAct(
 }
 
 static void halbtc8723b1ant_SetLpsRpwm(
-       PBTC_COEXIST pBtCoexist, u8 lpsVal, u8 rpwmVal
+       struct btc_coexist *pBtCoexist, u8 lpsVal, u8 rpwmVal
 )
 {
        u8 lps = lpsVal;
@@ -1054,7 +1054,7 @@ static void halbtc8723b1ant_SetLpsRpwm(
 }
 
 static void halbtc8723b1ant_LpsRpwm(
-       PBTC_COEXIST pBtCoexist, bool bForceExec, u8 lpsVal, u8 rpwmVal
+       struct btc_coexist *pBtCoexist, bool bForceExec, u8 lpsVal, u8 rpwmVal
 )
 {
        BTC_PRINT(
@@ -1105,7 +1105,7 @@ static void halbtc8723b1ant_LpsRpwm(
 }
 
 static void halbtc8723b1ant_SwMechanism(
-       PBTC_COEXIST pBtCoexist, bool bLowPenaltyRA
+       struct btc_coexist *pBtCoexist, bool bLowPenaltyRA
 )
 {
        BTC_PRINT(
@@ -1118,10 +1118,10 @@ static void halbtc8723b1ant_SwMechanism(
 }
 
 static void halbtc8723b1ant_SetAntPath(
-       PBTC_COEXIST pBtCoexist, u8 antPosType, bool bInitHwCfg, bool bWifiOff
+       struct btc_coexist *pBtCoexist, u8 antPosType, bool bInitHwCfg, bool bWifiOff
 )
 {
-       PBTC_BOARD_INFO pBoardInfo = &pBtCoexist->boardInfo;
+       struct btc_board_info *pBoardInfo = &pBtCoexist->boardInfo;
        u32 fwVer = 0, u4Tmp = 0, cntBtCalChk = 0;
        bool bPgExtSwitch = false;
        bool bUseExtSwitch = false;
@@ -1307,7 +1307,7 @@ static void halbtc8723b1ant_SetAntPath(
 }
 
 static void halbtc8723b1ant_SetFwPstdma(
-       PBTC_COEXIST pBtCoexist, u8 byte1, u8 byte2, u8 byte3, u8 byte4, u8 byte5
+       struct btc_coexist *pBtCoexist, u8 byte1, u8 byte2, u8 byte3, u8 byte4, u8 byte5
 )
 {
        u8 H2C_Parameter[5] = {0};
@@ -1361,10 +1361,10 @@ static void halbtc8723b1ant_SetFwPstdma(
 
 
 static void halbtc8723b1ant_PsTdma(
-       PBTC_COEXIST pBtCoexist, bool bForceExec, bool bTurnOn, u8 type
+       struct btc_coexist *pBtCoexist, bool bForceExec, bool bTurnOn, u8 type
 )
 {
-       PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
+       struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
        bool bWifiBusy = false;
        u8 rssiAdjustVal = 0;
        u8 psTdmaByte4Val = 0x50, psTdmaByte0Val = 0x51, psTdmaByte3Val =  0x10;
@@ -1661,7 +1661,7 @@ static void halbtc8723b1ant_PsTdma(
        pCoexDm->prePsTdma = pCoexDm->curPsTdma;
 }
 
-static bool halbtc8723b1ant_IsCommonAction(PBTC_COEXIST pBtCoexist)
+static bool halbtc8723b1ant_IsCommonAction(struct btc_coexist *pBtCoexist)
 {
        bool bCommon = false, bWifiConnected = false, bWifiBusy = false;
 
@@ -1752,7 +1752,7 @@ static bool halbtc8723b1ant_IsCommonAction(PBTC_COEXIST pBtCoexist)
 
 
 static void halbtc8723b1ant_TdmaDurationAdjustForAcl(
-       PBTC_COEXIST pBtCoexist, u8 wifiStatus
+       struct btc_coexist *pBtCoexist, u8 wifiStatus
 )
 {
        static s32 up, dn, m, n, WaitCount;
@@ -1941,7 +1941,7 @@ static void halbtc8723b1ant_TdmaDurationAdjustForAcl(
 }
 
 static void halbtc8723b1ant_PsTdmaCheckForPowerSaveState(
-       PBTC_COEXIST pBtCoexist, bool bNewPsState
+       struct btc_coexist *pBtCoexist, bool bNewPsState
 )
 {
        u8 lpsMode = 0x0;
@@ -1963,7 +1963,7 @@ static void halbtc8723b1ant_PsTdmaCheckForPowerSaveState(
 }
 
 static void halbtc8723b1ant_PowerSaveState(
-       PBTC_COEXIST pBtCoexist, u8 psType, u8 lpsVal, u8 rpwmVal
+       struct btc_coexist *pBtCoexist, u8 psType, u8 lpsVal, u8 rpwmVal
 )
 {
        bool bLowPwrDisable = false;
@@ -2011,7 +2011,7 @@ static void halbtc8723b1ant_PowerSaveState(
 /*     Non-Software Coex Mechanism start */
 /*  */
 /*  */
-static void halbtc8723b1ant_ActionWifiMultiPort(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b1ant_ActionWifiMultiPort(struct btc_coexist *pBtCoexist)
 {
        halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
 
@@ -2019,15 +2019,15 @@ static void halbtc8723b1ant_ActionWifiMultiPort(PBTC_COEXIST pBtCoexist)
        halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
 }
 
-static void halbtc8723b1ant_ActionHs(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b1ant_ActionHs(struct btc_coexist *pBtCoexist)
 {
        halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5);
        halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
 }
 
-static void halbtc8723b1ant_ActionBtInquiry(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b1ant_ActionBtInquiry(struct btc_coexist *pBtCoexist)
 {
-       PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
+       struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
        bool bWifiConnected = false;
        bool bApEnable = false;
        bool bWifiBusy = false;
@@ -2067,10 +2067,10 @@ static void halbtc8723b1ant_ActionBtInquiry(PBTC_COEXIST pBtCoexist)
 }
 
 static void halbtc8723b1ant_ActionBtScoHidOnlyBusy(
-       PBTC_COEXIST pBtCoexist, u8 wifiStatus
+       struct btc_coexist *pBtCoexist, u8 wifiStatus
 )
 {
-       PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
+       struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
        bool bWifiConnected = false;
 
        pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
@@ -2087,12 +2087,12 @@ static void halbtc8723b1ant_ActionBtScoHidOnlyBusy(
 }
 
 static void halbtc8723b1ant_ActionWifiConnectedBtAclBusy(
-       PBTC_COEXIST pBtCoexist, u8 wifiStatus
+       struct btc_coexist *pBtCoexist, u8 wifiStatus
 )
 {
        u8 btRssiState;
 
-       PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
+       struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
        btRssiState = halbtc8723b1ant_BtRssiState(2, 28, 0);
 
        if ((pCoexSta->lowPriorityRx >= 1000) && (pCoexSta->lowPriorityRx != 65535))
@@ -2141,7 +2141,7 @@ static void halbtc8723b1ant_ActionWifiConnectedBtAclBusy(
        }
 }
 
-static void halbtc8723b1ant_ActionWifiNotConnected(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b1ant_ActionWifiNotConnected(struct btc_coexist *pBtCoexist)
 {
        /*  power save state */
        halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
@@ -2152,10 +2152,10 @@ static void halbtc8723b1ant_ActionWifiNotConnected(PBTC_COEXIST pBtCoexist)
 }
 
 static void halbtc8723b1ant_ActionWifiNotConnectedScan(
-       PBTC_COEXIST pBtCoexist
+       struct btc_coexist *pBtCoexist
 )
 {
-       PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
+       struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
 
        halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
 
@@ -2186,10 +2186,10 @@ static void halbtc8723b1ant_ActionWifiNotConnectedScan(
 }
 
 static void halbtc8723b1ant_ActionWifiNotConnectedAssoAuth(
-       PBTC_COEXIST pBtCoexist
+       struct btc_coexist *pBtCoexist
 )
 {
-       PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
+       struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
 
        halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
 
@@ -2210,9 +2210,9 @@ static void halbtc8723b1ant_ActionWifiNotConnectedAssoAuth(
        }
 }
 
-static void halbtc8723b1ant_ActionWifiConnectedScan(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b1ant_ActionWifiConnectedScan(struct btc_coexist *pBtCoexist)
 {
-       PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
+       struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
 
        halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
 
@@ -2243,10 +2243,10 @@ static void halbtc8723b1ant_ActionWifiConnectedScan(PBTC_COEXIST pBtCoexist)
 }
 
 static void halbtc8723b1ant_ActionWifiConnectedSpecialPacket(
-       PBTC_COEXIST pBtCoexist
+       struct btc_coexist *pBtCoexist
 )
 {
-       PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
+       struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
 
        halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
 
@@ -2267,7 +2267,7 @@ static void halbtc8723b1ant_ActionWifiConnectedSpecialPacket(
        }
 }
 
-static void halbtc8723b1ant_ActionWifiConnected(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b1ant_ActionWifiConnected(struct btc_coexist *pBtCoexist)
 {
        bool bWifiBusy = false;
        bool bScan = false, bLink = false, bRoam = false;
@@ -2387,7 +2387,7 @@ static void halbtc8723b1ant_ActionWifiConnected(PBTC_COEXIST pBtCoexist)
        }
 }
 
-static void halbtc8723b1ant_RunSwCoexistMechanism(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b1ant_RunSwCoexistMechanism(struct btc_coexist *pBtCoexist)
 {
        u8 algorithm = 0;
 
@@ -2446,9 +2446,9 @@ static void halbtc8723b1ant_RunSwCoexistMechanism(PBTC_COEXIST pBtCoexist)
        }
 }
 
-static void halbtc8723b1ant_RunCoexistMechanism(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b1ant_RunCoexistMechanism(struct btc_coexist *pBtCoexist)
 {
-       PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
+       struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
        bool bWifiConnected = false, bBtHsOn = false;
        bool bIncreaseScanDevNum = false;
        bool bBtCtrlAggBufSize = false;
@@ -2579,7 +2579,7 @@ static void halbtc8723b1ant_RunCoexistMechanism(PBTC_COEXIST pBtCoexist)
                halbtc8723b1ant_ActionWifiConnected(pBtCoexist);
 }
 
-static void halbtc8723b1ant_InitCoexDm(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b1ant_InitCoexDm(struct btc_coexist *pBtCoexist)
 {
        /*  force to reset coex mechanism */
 
@@ -2593,7 +2593,7 @@ static void halbtc8723b1ant_InitCoexDm(PBTC_COEXIST pBtCoexist)
 }
 
 static void halbtc8723b1ant_InitHwConfig(
-       PBTC_COEXIST pBtCoexist,
+       struct btc_coexist *pBtCoexist,
        bool bBackUp,
        bool bWifiOnly
 )
@@ -2648,9 +2648,9 @@ static void halbtc8723b1ant_InitHwConfig(
 /*  */
 /*  extern function start with EXhalbtc8723b1ant_ */
 /*  */
-void EXhalbtc8723b1ant_PowerOnSetting(PBTC_COEXIST pBtCoexist)
+void EXhalbtc8723b1ant_PowerOnSetting(struct btc_coexist *pBtCoexist)
 {
-       PBTC_BOARD_INFO pBoardInfo = &pBtCoexist->boardInfo;
+       struct btc_board_info *pBoardInfo = &pBtCoexist->boardInfo;
        u8 u1Tmp = 0x0;
        u16 u2Tmp = 0x0;
 
@@ -2700,12 +2700,12 @@ void EXhalbtc8723b1ant_PowerOnSetting(PBTC_COEXIST pBtCoexist)
        }
 }
 
-void EXhalbtc8723b1ant_InitHwConfig(PBTC_COEXIST pBtCoexist, bool bWifiOnly)
+void EXhalbtc8723b1ant_InitHwConfig(struct btc_coexist *pBtCoexist, bool bWifiOnly)
 {
        halbtc8723b1ant_InitHwConfig(pBtCoexist, true, bWifiOnly);
 }
 
-void EXhalbtc8723b1ant_InitCoexDm(PBTC_COEXIST pBtCoexist)
+void EXhalbtc8723b1ant_InitCoexDm(struct btc_coexist *pBtCoexist)
 {
        BTC_PRINT(
                BTC_MSG_INTERFACE,
@@ -2720,11 +2720,11 @@ void EXhalbtc8723b1ant_InitCoexDm(PBTC_COEXIST pBtCoexist)
        halbtc8723b1ant_QueryBtInfo(pBtCoexist);
 }
 
-void EXhalbtc8723b1ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist)
+void EXhalbtc8723b1ant_DisplayCoexInfo(struct btc_coexist *pBtCoexist)
 {
-       PBTC_BOARD_INFO pBoardInfo = &pBtCoexist->boardInfo;
-       PBTC_STACK_INFO pStackInfo = &pBtCoexist->stackInfo;
-       PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
+       struct btc_board_info *pBoardInfo = &pBtCoexist->boardInfo;
+       struct btc_stack_info *pStackInfo = &pBtCoexist->stackInfo;
+       struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
        u8 *cliBuf = pBtCoexist->cliBuf;
        u8 u1Tmp[4], i, btInfoExt, psTdmaCase = 0;
        u16 u2Tmp[4];
@@ -3183,7 +3183,7 @@ void EXhalbtc8723b1ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist)
 }
 
 
-void EXhalbtc8723b1ant_IpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
+void EXhalbtc8723b1ant_IpsNotify(struct btc_coexist *pBtCoexist, u8 type)
 {
        if (pBtCoexist->bManualControl ||       pBtCoexist->bStopCoexDm)
                return;
@@ -3209,7 +3209,7 @@ void EXhalbtc8723b1ant_IpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
        }
 }
 
-void EXhalbtc8723b1ant_LpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
+void EXhalbtc8723b1ant_LpsNotify(struct btc_coexist *pBtCoexist, u8 type)
 {
        if (pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm)
                return;
@@ -3227,7 +3227,7 @@ void EXhalbtc8723b1ant_LpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
        }
 }
 
-void EXhalbtc8723b1ant_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type)
+void EXhalbtc8723b1ant_ScanNotify(struct btc_coexist *pBtCoexist, u8 type)
 {
        bool bWifiConnected = false, bBtHsOn = false;
        u32 wifiLinkStatus = 0;
@@ -3317,7 +3317,7 @@ void EXhalbtc8723b1ant_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type)
        }
 }
 
-void EXhalbtc8723b1ant_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 type)
+void EXhalbtc8723b1ant_ConnectNotify(struct btc_coexist *pBtCoexist, u8 type)
 {
        bool bWifiConnected = false, bBtHsOn = false;
        u32 wifiLinkStatus = 0;
@@ -3374,7 +3374,7 @@ void EXhalbtc8723b1ant_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 type)
        }
 }
 
-void EXhalbtc8723b1ant_MediaStatusNotify(PBTC_COEXIST pBtCoexist, u8 type)
+void EXhalbtc8723b1ant_MediaStatusNotify(struct btc_coexist *pBtCoexist, u8 type)
 {
        u8 H2C_Parameter[3] = {0};
        u32 wifiBw;
@@ -3444,7 +3444,7 @@ void EXhalbtc8723b1ant_MediaStatusNotify(PBTC_COEXIST pBtCoexist, u8 type)
        pBtCoexist->fBtcFillH2c(pBtCoexist, 0x66, 3, H2C_Parameter);
 }
 
-void EXhalbtc8723b1ant_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 type)
+void EXhalbtc8723b1ant_SpecialPacketNotify(struct btc_coexist *pBtCoexist, u8 type)
 {
        bool bBtHsOn = false;
        u32 wifiLinkStatus = 0;
@@ -3533,7 +3533,7 @@ void EXhalbtc8723b1ant_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 type)
 }
 
 void EXhalbtc8723b1ant_BtInfoNotify(
-       PBTC_COEXIST pBtCoexist, u8 *tmpBuf, u8 length
+       struct btc_coexist *pBtCoexist, u8 *tmpBuf, u8 length
 )
 {
        u8 btInfo = 0;
@@ -3698,7 +3698,7 @@ void EXhalbtc8723b1ant_BtInfoNotify(
        halbtc8723b1ant_RunCoexistMechanism(pBtCoexist);
 }
 
-void EXhalbtc8723b1ant_HaltNotify(PBTC_COEXIST pBtCoexist)
+void EXhalbtc8723b1ant_HaltNotify(struct btc_coexist *pBtCoexist)
 {
        BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Halt notify\n"));
 
@@ -3713,7 +3713,7 @@ void EXhalbtc8723b1ant_HaltNotify(PBTC_COEXIST pBtCoexist)
        pBtCoexist->bStopCoexDm = true;
 }
 
-void EXhalbtc8723b1ant_PnpNotify(PBTC_COEXIST pBtCoexist, u8 pnpState)
+void EXhalbtc8723b1ant_PnpNotify(struct btc_coexist *pBtCoexist, u8 pnpState)
 {
        BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify\n"));
 
@@ -3735,7 +3735,7 @@ void EXhalbtc8723b1ant_PnpNotify(PBTC_COEXIST pBtCoexist, u8 pnpState)
        }
 }
 
-void EXhalbtc8723b1ant_Periodical(PBTC_COEXIST pBtCoexist)
+void EXhalbtc8723b1ant_Periodical(struct btc_coexist *pBtCoexist)
 {
        static u8 disVerInfoCnt;
        u32 fwVer = 0, btPatchVer = 0;
index 661f0cd6aa069ce77fc417191fc23b6ff131a96c..ed569e77e518d8bc4817e331a2d7621cb50c1142 100644 (file)
 
 #define  BT_8723B_1ANT_WIFI_NOISY_THRESH 30   /* max: 255 */
 
-enum BT_INFO_SRC_8723B_1ANT {
+enum bt_info_src_8723b_1ant {
        BT_INFO_SRC_8723B_1ANT_WIFI_FW                  = 0x0,
        BT_INFO_SRC_8723B_1ANT_BT_RSP                           = 0x1,
        BT_INFO_SRC_8723B_1ANT_BT_ACTIVE_SEND           = 0x2,
        BT_INFO_SRC_8723B_1ANT_MAX
 };
 
-enum BT_8723B_1ANT_BT_STATUS {
+enum bt_8723b_1ant_bt_status {
        BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE      = 0x0,
        BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE          = 0x1,
        BT_8723B_1ANT_BT_STATUS_INQ_PAGE                                = 0x2,
@@ -38,7 +38,7 @@ enum BT_8723B_1ANT_BT_STATUS {
        BT_8723B_1ANT_BT_STATUS_MAX
 };
 
-enum BT_8723B_1ANT_WIFI_STATUS {
+enum bt_8723b_1ant_wifi_status {
        BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_IDLE           = 0x0,
        BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN = 0x1,
        BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN               = 0x2,
@@ -48,7 +48,7 @@ enum BT_8723B_1ANT_WIFI_STATUS {
        BT_8723B_1ANT_WIFI_STATUS_MAX
 };
 
-enum BT_8723B_1ANT_COEX_ALGO {
+enum bt_8723b_1ant_coex_algo {
        BT_8723B_1ANT_COEX_ALGO_UNDEFINED               = 0x0,
        BT_8723B_1ANT_COEX_ALGO_SCO                             = 0x1,
        BT_8723B_1ANT_COEX_ALGO_HID                             = 0x2,
@@ -63,7 +63,7 @@ enum BT_8723B_1ANT_COEX_ALGO {
        BT_8723B_1ANT_COEX_ALGO_MAX                             = 0xb,
 };
 
-struct COEX_DM_8723B_1ANT {
+struct coex_dm_8723b_1ant {
        /*  fw mechanism */
        bool bCurIgnoreWlanAct;
        bool bPreIgnoreWlanAct;
@@ -118,7 +118,7 @@ struct COEX_DM_8723B_1ANT {
        u8 errorCondition;
 };
 
-struct COEX_STA_8723B_1ANT {
+struct coex_sta_8723b_1ant {
        bool bBtLinkExist;
        bool bScoExist;
        bool bA2dpExist;
@@ -167,19 +167,19 @@ struct COEX_STA_8723B_1ANT {
 /*  */
 /*  The following is interface which will notify coex module. */
 /*  */
-void EXhalbtc8723b1ant_PowerOnSetting(PBTC_COEXIST pBtCoexist);
-void EXhalbtc8723b1ant_InitHwConfig(PBTC_COEXIST pBtCoexist, bool bWifiOnly);
-void EXhalbtc8723b1ant_InitCoexDm(PBTC_COEXIST pBtCoexist);
-void EXhalbtc8723b1ant_IpsNotify(PBTC_COEXIST pBtCoexist, u8 type);
-void EXhalbtc8723b1ant_LpsNotify(PBTC_COEXIST pBtCoexist, u8 type);
-void EXhalbtc8723b1ant_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type);
-void EXhalbtc8723b1ant_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 type);
-void EXhalbtc8723b1ant_MediaStatusNotify(PBTC_COEXIST pBtCoexist, u8 type);
-void EXhalbtc8723b1ant_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 type);
+void EXhalbtc8723b1ant_PowerOnSetting(struct btc_coexist *pBtCoexist);
+void EXhalbtc8723b1ant_InitHwConfig(struct btc_coexist *pBtCoexist, bool bWifiOnly);
+void EXhalbtc8723b1ant_InitCoexDm(struct btc_coexist *pBtCoexist);
+void EXhalbtc8723b1ant_IpsNotify(struct btc_coexist *pBtCoexist, u8 type);
+void EXhalbtc8723b1ant_LpsNotify(struct btc_coexist *pBtCoexist, u8 type);
+void EXhalbtc8723b1ant_ScanNotify(struct btc_coexist *pBtCoexist, u8 type);
+void EXhalbtc8723b1ant_ConnectNotify(struct btc_coexist *pBtCoexist, u8 type);
+void EXhalbtc8723b1ant_MediaStatusNotify(struct btc_coexist *pBtCoexist, u8 type);
+void EXhalbtc8723b1ant_SpecialPacketNotify(struct btc_coexist *pBtCoexist, u8 type);
 void EXhalbtc8723b1ant_BtInfoNotify(
-       PBTC_COEXIST pBtCoexist, u8 *tmpBuf, u8 length
+       struct btc_coexist *pBtCoexist, u8 *tmpBuf, u8 length
 );
-void EXhalbtc8723b1ant_HaltNotify(PBTC_COEXIST pBtCoexist);
-void EXhalbtc8723b1ant_PnpNotify(PBTC_COEXIST pBtCoexist, u8 pnpState);
-void EXhalbtc8723b1ant_Periodical(PBTC_COEXIST pBtCoexist);
-void EXhalbtc8723b1ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist);
+void EXhalbtc8723b1ant_HaltNotify(struct btc_coexist *pBtCoexist);
+void EXhalbtc8723b1ant_PnpNotify(struct btc_coexist *pBtCoexist, u8 pnpState);
+void EXhalbtc8723b1ant_Periodical(struct btc_coexist *pBtCoexist);
+void EXhalbtc8723b1ant_DisplayCoexInfo(struct btc_coexist *pBtCoexist);
index 0ca14f445882040a5a0e44b45c273a95efc0ead2..6edaefa47af1dbdca1439f1b4c4032f79a4868db 100644 (file)
@@ -15,10 +15,10 @@ do {                                                                              \
 } while (0)
 
 /*  Global variables, these are static variables */
-static struct COEX_DM_8723B_2ANT GLCoexDm8723b2Ant;
-static struct COEX_DM_8723B_2ANT * pCoexDm = &GLCoexDm8723b2Ant;
-static struct COEX_STA_8723B_2ANT GLCoexSta8723b2Ant;
-static struct COEX_STA_8723B_2ANT * pCoexSta = &GLCoexSta8723b2Ant;
+static struct coex_dm_8723b_2ant GLCoexDm8723b2Ant;
+static struct coex_dm_8723b_2ant *pCoexDm = &GLCoexDm8723b2Ant;
+static struct coex_sta_8723b_2ant GLCoexSta8723b2Ant;
+static struct coex_sta_8723b_2ant *pCoexSta = &GLCoexSta8723b2Ant;
 
 static const char *const GLBtInfoSrc8723b2Ant[] = {
        "BT Info[wifi fw]",
@@ -108,7 +108,7 @@ static u8 halbtc8723b2ant_BtRssiState(
 }
 
 static u8 halbtc8723b2ant_WifiRssiState(
-       PBTC_COEXIST pBtCoexist,
+       struct btc_coexist *pBtCoexist,
        u8 index,
        u8 levelNum,
        u8 rssiThresh,
@@ -189,7 +189,7 @@ static u8 halbtc8723b2ant_WifiRssiState(
 }
 
 static void halbtc8723b2ant_LimitedRx(
-       PBTC_COEXIST pBtCoexist,
+       struct btc_coexist *pBtCoexist,
        bool bForceExec,
        bool bRejApAggPkt,
        bool bBtCtrlAggBufSize,
@@ -212,7 +212,7 @@ static void halbtc8723b2ant_LimitedRx(
        pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL);
 }
 
-static void halbtc8723b2ant_MonitorBtCtr(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_MonitorBtCtr(struct btc_coexist *pBtCoexist)
 {
        u32 regHPTxRx, regLPTxRx, u4Tmp;
        u32 regHPTx = 0, regHPRx = 0, regLPTx = 0, regLPRx = 0;
@@ -262,7 +262,7 @@ static void halbtc8723b2ant_MonitorBtCtr(PBTC_COEXIST pBtCoexist)
        pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc);
 }
 
-static void halbtc8723b2ant_QueryBtInfo(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_QueryBtInfo(struct btc_coexist *pBtCoexist)
 {
        u8      H2C_Parameter[1] = {0};
 
@@ -279,7 +279,7 @@ static void halbtc8723b2ant_QueryBtInfo(PBTC_COEXIST pBtCoexist)
        pBtCoexist->fBtcFillH2c(pBtCoexist, 0x61, 1, H2C_Parameter);
 }
 
-static bool halbtc8723b2ant_IsWifiStatusChanged(PBTC_COEXIST pBtCoexist)
+static bool halbtc8723b2ant_IsWifiStatusChanged(struct btc_coexist *pBtCoexist)
 {
        static bool     bPreWifiBusy, bPreUnder4way, bPreBtHsOn;
        bool bWifiBusy = false, bUnder4way = false, bBtHsOn = false;
@@ -310,9 +310,9 @@ static bool halbtc8723b2ant_IsWifiStatusChanged(PBTC_COEXIST pBtCoexist)
        return false;
 }
 
-static void halbtc8723b2ant_UpdateBtLinkInfo(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_UpdateBtLinkInfo(struct btc_coexist *pBtCoexist)
 {
-       PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
+       struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
        bool bBtHsOn = false;
 
        pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
@@ -374,9 +374,9 @@ static void halbtc8723b2ant_UpdateBtLinkInfo(PBTC_COEXIST pBtCoexist)
                pBtLinkInfo->bHidOnly = false;
 }
 
-static u8 halbtc8723b2ant_ActionAlgorithm(PBTC_COEXIST pBtCoexist)
+static u8 halbtc8723b2ant_ActionAlgorithm(struct btc_coexist *pBtCoexist)
 {
-       PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
+       struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
        bool bBtHsOn = false;
        u8 algorithm = BT_8723B_2ANT_COEX_ALGO_UNDEFINED;
        u8 numOfDiffProfile = 0;
@@ -549,7 +549,7 @@ static u8 halbtc8723b2ant_ActionAlgorithm(PBTC_COEXIST pBtCoexist)
 }
 
 static void halbtc8723b2ant_SetFwDacSwingLevel(
-       PBTC_COEXIST pBtCoexist, u8 dacSwingLvl
+       struct btc_coexist *pBtCoexist, u8 dacSwingLvl
 )
 {
        u8      H2C_Parameter[1] = {0};
@@ -573,7 +573,7 @@ static void halbtc8723b2ant_SetFwDacSwingLevel(
 }
 
 static void halbtc8723b2ant_SetFwDecBtPwr(
-       PBTC_COEXIST pBtCoexist, u8 decBtPwrLvl
+       struct btc_coexist *pBtCoexist, u8 decBtPwrLvl
 )
 {
        u8      H2C_Parameter[1] = {0};
@@ -594,7 +594,7 @@ static void halbtc8723b2ant_SetFwDecBtPwr(
 }
 
 static void halbtc8723b2ant_DecBtPwr(
-       PBTC_COEXIST pBtCoexist, bool bForceExec, u8 decBtPwrLvl
+       struct btc_coexist *pBtCoexist, bool bForceExec, u8 decBtPwrLvl
 )
 {
        BTC_PRINT(
@@ -628,7 +628,7 @@ static void halbtc8723b2ant_DecBtPwr(
 }
 
 static void halbtc8723b2ant_FwDacSwingLvl(
-       PBTC_COEXIST pBtCoexist, bool bForceExec, u8 fwDacSwingLvl
+       struct btc_coexist *pBtCoexist, bool bForceExec, u8 fwDacSwingLvl
 )
 {
        BTC_PRINT(
@@ -663,7 +663,7 @@ static void halbtc8723b2ant_FwDacSwingLvl(
 }
 
 static void halbtc8723b2ant_SetSwRfRxLpfCorner(
-       PBTC_COEXIST pBtCoexist,
+       struct btc_coexist *pBtCoexist,
        bool bRxRfShrinkOn
 )
 {
@@ -686,7 +686,7 @@ static void halbtc8723b2ant_SetSwRfRxLpfCorner(
 }
 
 static void halbtc8723b2ant_RfShrink(
-       PBTC_COEXIST pBtCoexist, bool bForceExec, bool bRxRfShrinkOn
+       struct btc_coexist *pBtCoexist, bool bForceExec, bool bRxRfShrinkOn
 )
 {
        BTC_PRINT(
@@ -720,7 +720,7 @@ static void halbtc8723b2ant_RfShrink(
 }
 
 static void halbtc8723b2ant_SetSwPenaltyTxRateAdaptive(
-       PBTC_COEXIST pBtCoexist, bool bLowPenaltyRa
+       struct btc_coexist *pBtCoexist, bool bLowPenaltyRa
 )
 {
        u8      H2C_Parameter[6] = {0};
@@ -748,7 +748,7 @@ static void halbtc8723b2ant_SetSwPenaltyTxRateAdaptive(
 }
 
 static void halbtc8723b2ant_LowPenaltyRa(
-       PBTC_COEXIST pBtCoexist, bool bForceExec, bool bLowPenaltyRa
+       struct btc_coexist *pBtCoexist, bool bForceExec, bool bLowPenaltyRa
 )
 {
        /* return; */
@@ -782,7 +782,7 @@ static void halbtc8723b2ant_LowPenaltyRa(
        pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa;
 }
 
-static void halbtc8723b2ant_SetDacSwingReg(PBTC_COEXIST pBtCoexist, u32 level)
+static void halbtc8723b2ant_SetDacSwingReg(struct btc_coexist *pBtCoexist, u32 level)
 {
        u8 val = (u8)level;
 
@@ -795,7 +795,7 @@ static void halbtc8723b2ant_SetDacSwingReg(PBTC_COEXIST pBtCoexist, u32 level)
 }
 
 static void halbtc8723b2ant_SetSwFullTimeDacSwing(
-       PBTC_COEXIST pBtCoexist, bool bSwDacSwingOn, u32 swDacSwingLvl
+       struct btc_coexist *pBtCoexist, bool bSwDacSwingOn, u32 swDacSwingLvl
 )
 {
        if (bSwDacSwingOn)
@@ -806,7 +806,7 @@ static void halbtc8723b2ant_SetSwFullTimeDacSwing(
 
 
 static void halbtc8723b2ant_DacSwing(
-       PBTC_COEXIST pBtCoexist,
+       struct btc_coexist *pBtCoexist,
        bool bForceExec,
        bool bDacSwingOn,
        u32 dacSwingLvl
@@ -850,7 +850,7 @@ static void halbtc8723b2ant_DacSwing(
 }
 
 static void halbtc8723b2ant_SetAgcTable(
-       PBTC_COEXIST pBtCoexist, bool bAgcTableEn
+       struct btc_coexist *pBtCoexist, bool bAgcTableEn
 )
 {
        u8 rssiAdjustVal = 0;
@@ -910,7 +910,7 @@ static void halbtc8723b2ant_SetAgcTable(
 }
 
 static void halbtc8723b2ant_AgcTable(
-       PBTC_COEXIST pBtCoexist, bool bForceExec, bool bAgcTableEn
+       struct btc_coexist *pBtCoexist, bool bForceExec, bool bAgcTableEn
 )
 {
        BTC_PRINT(
@@ -944,7 +944,7 @@ static void halbtc8723b2ant_AgcTable(
 }
 
 static void halbtc8723b2ant_SetCoexTable(
-       PBTC_COEXIST pBtCoexist,
+       struct btc_coexist *pBtCoexist,
        u32 val0x6c0,
        u32 val0x6c4,
        u32 val0x6c8,
@@ -981,7 +981,7 @@ static void halbtc8723b2ant_SetCoexTable(
 }
 
 static void halbtc8723b2ant_CoexTable(
-       PBTC_COEXIST pBtCoexist,
+       struct btc_coexist *pBtCoexist,
        bool bForceExec,
        u32 val0x6c0,
        u32 val0x6c4,
@@ -1047,7 +1047,7 @@ static void halbtc8723b2ant_CoexTable(
 }
 
 static void halbtc8723b2ant_CoexTableWithType(
-       PBTC_COEXIST pBtCoexist, bool bForceExec, u8 type
+       struct btc_coexist *pBtCoexist, bool bForceExec, u8 type
 )
 {
        switch (type) {
@@ -1096,7 +1096,7 @@ static void halbtc8723b2ant_CoexTableWithType(
 }
 
 static void halbtc8723b2ant_SetFwIgnoreWlanAct(
-       PBTC_COEXIST pBtCoexist, bool bEnable
+       struct btc_coexist *pBtCoexist, bool bEnable
 )
 {
        u8      H2C_Parameter[1] = {0};
@@ -1117,7 +1117,7 @@ static void halbtc8723b2ant_SetFwIgnoreWlanAct(
 }
 
 static void halbtc8723b2ant_IgnoreWlanAct(
-       PBTC_COEXIST pBtCoexist, bool bForceExec, bool bEnable
+       struct btc_coexist *pBtCoexist, bool bForceExec, bool bEnable
 )
 {
        BTC_PRINT(
@@ -1145,7 +1145,7 @@ static void halbtc8723b2ant_IgnoreWlanAct(
 }
 
 static void halbtc8723b2ant_SetFwPstdma(
-       PBTC_COEXIST pBtCoexist,
+       struct btc_coexist *pBtCoexist,
        u8 byte1,
        u8 byte2,
        u8 byte3,
@@ -1184,7 +1184,7 @@ static void halbtc8723b2ant_SetFwPstdma(
 }
 
 static void halbtc8723b2ant_SwMechanism1(
-       PBTC_COEXIST pBtCoexist,
+       struct btc_coexist *pBtCoexist,
        bool bShrinkRxLPF,
        bool bLowPenaltyRA,
        bool bLimitedDIG,
@@ -1196,7 +1196,7 @@ static void halbtc8723b2ant_SwMechanism1(
 }
 
 static void halbtc8723b2ant_SwMechanism2(
-       PBTC_COEXIST pBtCoexist,
+       struct btc_coexist *pBtCoexist,
        bool bAGCTableShift,
        bool bADCBackOff,
        bool bSWDACSwing,
@@ -1208,10 +1208,10 @@ static void halbtc8723b2ant_SwMechanism2(
 }
 
 static void halbtc8723b2ant_SetAntPath(
-       PBTC_COEXIST pBtCoexist, u8 antPosType, bool bInitHwCfg, bool bWifiOff
+       struct btc_coexist *pBtCoexist, u8 antPosType, bool bInitHwCfg, bool bWifiOff
 )
 {
-       PBTC_BOARD_INFO pBoardInfo = &pBtCoexist->boardInfo;
+       struct btc_board_info *pBoardInfo = &pBtCoexist->boardInfo;
        u32 fwVer = 0, u4Tmp = 0;
        bool bPgExtSwitch = false;
        bool bUseExtSwitch = false;
@@ -1302,7 +1302,7 @@ static void halbtc8723b2ant_SetAntPath(
 }
 
 static void halbtc8723b2ant_PsTdma(
-       PBTC_COEXIST pBtCoexist, bool bForceExec, bool bTurnOn, u8 type
+       struct btc_coexist *pBtCoexist, bool bForceExec, bool bTurnOn, u8 type
 )
 {
        BTC_PRINT(
@@ -1434,7 +1434,7 @@ static void halbtc8723b2ant_PsTdma(
        pCoexDm->prePsTdma = pCoexDm->curPsTdma;
 }
 
-static void halbtc8723b2ant_CoexAllOff(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_CoexAllOff(struct btc_coexist *pBtCoexist)
 {
        /*  fw all off */
        halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 1);
@@ -1450,7 +1450,7 @@ static void halbtc8723b2ant_CoexAllOff(PBTC_COEXIST pBtCoexist)
        halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
 }
 
-static void halbtc8723b2ant_InitCoexDm(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_InitCoexDm(struct btc_coexist *pBtCoexist)
 {
        /*  force to reset coex mechanism */
 
@@ -1462,7 +1462,7 @@ static void halbtc8723b2ant_InitCoexDm(PBTC_COEXIST pBtCoexist)
        halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
 }
 
-static void halbtc8723b2ant_ActionBtInquiry(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_ActionBtInquiry(struct btc_coexist *pBtCoexist)
 {
        bool bWifiConnected = false;
        bool bLowPwrDisable = true;
@@ -1490,7 +1490,7 @@ static void halbtc8723b2ant_ActionBtInquiry(PBTC_COEXIST pBtCoexist)
        halbtc8723b2ant_SetAntPath(pBtCoexist, BTC_ANT_WIFI_AT_AUX, false, false);
 }
 
-static bool halbtc8723b2ant_IsCommonAction(PBTC_COEXIST pBtCoexist)
+static bool halbtc8723b2ant_IsCommonAction(struct btc_coexist *pBtCoexist)
 {
        u8 btRssiState = BTC_RSSI_STATE_HIGH;
        bool bCommon = false, bWifiConnected = false, bWifiBusy = false;
@@ -1591,7 +1591,7 @@ static bool halbtc8723b2ant_IsCommonAction(PBTC_COEXIST pBtCoexist)
 }
 
 static void halbtc8723b2ant_TdmaDurationAdjust(
-       PBTC_COEXIST pBtCoexist, bool bScoHid, bool bTxPause, u8 maxInterval
+       struct btc_coexist *pBtCoexist, bool bScoHid, bool bTxPause, u8 maxInterval
 )
 {
        static s32 up, dn, m, n, WaitCount;
@@ -2041,7 +2041,7 @@ static void halbtc8723b2ant_TdmaDurationAdjust(
 }
 
 /*  SCO only or SCO+PAN(HS) */
-static void halbtc8723b2ant_ActionSco(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_ActionSco(struct btc_coexist *pBtCoexist)
 {
        u8 wifiRssiState, btRssiState;
        u32 wifiBw;
@@ -2096,7 +2096,7 @@ static void halbtc8723b2ant_ActionSco(PBTC_COEXIST pBtCoexist)
 }
 
 
-static void halbtc8723b2ant_ActionHid(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_ActionHid(struct btc_coexist *pBtCoexist)
 {
        u8 wifiRssiState, btRssiState;
        u32 wifiBw;
@@ -2157,7 +2157,7 @@ static void halbtc8723b2ant_ActionHid(PBTC_COEXIST pBtCoexist)
 }
 
 /* A2DP only / PAN(EDR) only/ A2DP+PAN(HS) */
-static void halbtc8723b2ant_ActionA2dp(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_ActionA2dp(struct btc_coexist *pBtCoexist)
 {
        u8 wifiRssiState, wifiRssiState1, btRssiState;
        u32 wifiBw;
@@ -2238,7 +2238,7 @@ static void halbtc8723b2ant_ActionA2dp(PBTC_COEXIST pBtCoexist)
        }
 }
 
-static void halbtc8723b2ant_ActionA2dpPanHs(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_ActionA2dpPanHs(struct btc_coexist *pBtCoexist)
 {
        u8 wifiRssiState, btRssiState;
        u32 wifiBw;
@@ -2288,7 +2288,7 @@ static void halbtc8723b2ant_ActionA2dpPanHs(PBTC_COEXIST pBtCoexist)
        }
 }
 
-static void halbtc8723b2ant_ActionPanEdr(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_ActionPanEdr(struct btc_coexist *pBtCoexist)
 {
        u8 wifiRssiState, btRssiState;
        u32 wifiBw;
@@ -2346,7 +2346,7 @@ static void halbtc8723b2ant_ActionPanEdr(PBTC_COEXIST pBtCoexist)
 
 
 /* PAN(HS) only */
-static void halbtc8723b2ant_ActionPanHs(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_ActionPanHs(struct btc_coexist *pBtCoexist)
 {
        u8 wifiRssiState, btRssiState;
        u32 wifiBw;
@@ -2396,7 +2396,7 @@ static void halbtc8723b2ant_ActionPanHs(PBTC_COEXIST pBtCoexist)
 }
 
 /* PAN(EDR)+A2DP */
-static void halbtc8723b2ant_ActionPanEdrA2dp(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_ActionPanEdrA2dp(struct btc_coexist *pBtCoexist)
 {
        u8 wifiRssiState, btRssiState;
        u32 wifiBw;
@@ -2457,7 +2457,7 @@ static void halbtc8723b2ant_ActionPanEdrA2dp(PBTC_COEXIST pBtCoexist)
        }
 }
 
-static void halbtc8723b2ant_ActionPanEdrHid(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_ActionPanEdrHid(struct btc_coexist *pBtCoexist)
 {
        u8 wifiRssiState, btRssiState;
        u32 wifiBw;
@@ -2521,7 +2521,7 @@ static void halbtc8723b2ant_ActionPanEdrHid(PBTC_COEXIST pBtCoexist)
 }
 
 /*  HID+A2DP+PAN(EDR) */
-static void halbtc8723b2ant_ActionHidA2dpPanEdr(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_ActionHidA2dpPanEdr(struct btc_coexist *pBtCoexist)
 {
        u8 wifiRssiState, btRssiState;
        u32 wifiBw;
@@ -2581,7 +2581,7 @@ static void halbtc8723b2ant_ActionHidA2dpPanEdr(PBTC_COEXIST pBtCoexist)
        }
 }
 
-static void halbtc8723b2ant_ActionHidA2dp(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_ActionHidA2dp(struct btc_coexist *pBtCoexist)
 {
        u8 wifiRssiState, btRssiState;
        u32 wifiBw;
@@ -2656,7 +2656,7 @@ static void halbtc8723b2ant_ActionHidA2dp(PBTC_COEXIST pBtCoexist)
        }
 }
 
-static void halbtc8723b2ant_RunCoexistMechanism(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_RunCoexistMechanism(struct btc_coexist *pBtCoexist)
 {
        u8 algorithm = 0;
 
@@ -2755,7 +2755,7 @@ static void halbtc8723b2ant_RunCoexistMechanism(PBTC_COEXIST pBtCoexist)
        }
 }
 
-static void halbtc8723b2ant_WifiOffHwCfg(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_WifiOffHwCfg(struct btc_coexist *pBtCoexist)
 {
        bool bIsInMpMode = false;
        u8 H2C_Parameter[2] = {0};
@@ -2780,7 +2780,7 @@ static void halbtc8723b2ant_WifiOffHwCfg(PBTC_COEXIST pBtCoexist)
                pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x1); /* BT select s0/s1 is controlled by WiFi */
 }
 
-static void halbtc8723b2ant_InitHwConfig(PBTC_COEXIST pBtCoexist, bool bBackUp)
+static void halbtc8723b2ant_InitHwConfig(struct btc_coexist *pBtCoexist, bool bBackUp)
 {
        u8 u1Tmp = 0;
 
@@ -2814,9 +2814,9 @@ static void halbtc8723b2ant_InitHwConfig(PBTC_COEXIST pBtCoexist, bool bBackUp)
 /*  */
 /*  extern function start with EXhalbtc8723b2ant_ */
 /*  */
-void EXhalbtc8723b2ant_PowerOnSetting(PBTC_COEXIST pBtCoexist)
+void EXhalbtc8723b2ant_PowerOnSetting(struct btc_coexist *pBtCoexist)
 {
-       PBTC_BOARD_INFO pBoardInfo = &pBtCoexist->boardInfo;
+       struct btc_board_info *pBoardInfo = &pBtCoexist->boardInfo;
        u8 u1Tmp = 0x4; /* Set BIT2 by default since it's 2ant case */
        u16 u2Tmp = 0x0;
 
@@ -2866,23 +2866,23 @@ void EXhalbtc8723b2ant_PowerOnSetting(PBTC_COEXIST pBtCoexist)
        }
 }
 
-void EXhalbtc8723b2ant_InitHwConfig(PBTC_COEXIST pBtCoexist, bool bWifiOnly)
+void EXhalbtc8723b2ant_InitHwConfig(struct btc_coexist *pBtCoexist, bool bWifiOnly)
 {
        halbtc8723b2ant_InitHwConfig(pBtCoexist, true);
 }
 
-void EXhalbtc8723b2ant_InitCoexDm(PBTC_COEXIST pBtCoexist)
+void EXhalbtc8723b2ant_InitCoexDm(struct btc_coexist *pBtCoexist)
 {
        BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], Coex Mechanism Init!!\n"));
 
        halbtc8723b2ant_InitCoexDm(pBtCoexist);
 }
 
-void EXhalbtc8723b2ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist)
+void EXhalbtc8723b2ant_DisplayCoexInfo(struct btc_coexist *pBtCoexist)
 {
-       PBTC_BOARD_INFO pBoardInfo = &pBtCoexist->boardInfo;
-       PBTC_STACK_INFO pStackInfo = &pBtCoexist->stackInfo;
-       PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
+       struct btc_board_info *pBoardInfo = &pBtCoexist->boardInfo;
+       struct btc_stack_info *pStackInfo = &pBtCoexist->stackInfo;
+       struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
        u8 *cliBuf = pBtCoexist->cliBuf;
        u8 u1Tmp[4], i, btInfoExt, psTdmaCase = 0;
        u32 u4Tmp[4];
@@ -3259,7 +3259,7 @@ void EXhalbtc8723b2ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist)
 }
 
 
-void EXhalbtc8723b2ant_IpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
+void EXhalbtc8723b2ant_IpsNotify(struct btc_coexist *pBtCoexist, u8 type)
 {
        if (BTC_IPS_ENTER == type) {
                BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS ENTER notify\n"));
@@ -3276,7 +3276,7 @@ void EXhalbtc8723b2ant_IpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
        }
 }
 
-void EXhalbtc8723b2ant_LpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
+void EXhalbtc8723b2ant_LpsNotify(struct btc_coexist *pBtCoexist, u8 type)
 {
        if (BTC_LPS_ENABLE == type) {
                BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS ENABLE notify\n"));
@@ -3287,7 +3287,7 @@ void EXhalbtc8723b2ant_LpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
        }
 }
 
-void EXhalbtc8723b2ant_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type)
+void EXhalbtc8723b2ant_ScanNotify(struct btc_coexist *pBtCoexist, u8 type)
 {
        if (BTC_SCAN_START == type) {
                BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN START notify\n"));
@@ -3296,7 +3296,7 @@ void EXhalbtc8723b2ant_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type)
        }
 }
 
-void EXhalbtc8723b2ant_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 type)
+void EXhalbtc8723b2ant_ConnectNotify(struct btc_coexist *pBtCoexist, u8 type)
 {
        if (BTC_ASSOCIATE_START == type) {
                BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT START notify\n"));
@@ -3305,7 +3305,7 @@ void EXhalbtc8723b2ant_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 type)
        }
 }
 
-void EXhalbtc8723b2ant_MediaStatusNotify(PBTC_COEXIST pBtCoexist, u8 type)
+void EXhalbtc8723b2ant_MediaStatusNotify(struct btc_coexist *pBtCoexist, u8 type)
 {
        u8 H2C_Parameter[3] = {0};
        u32 wifiBw;
@@ -3351,7 +3351,7 @@ void EXhalbtc8723b2ant_MediaStatusNotify(PBTC_COEXIST pBtCoexist, u8 type)
        pBtCoexist->fBtcFillH2c(pBtCoexist, 0x66, 3, H2C_Parameter);
 }
 
-void EXhalbtc8723b2ant_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 type)
+void EXhalbtc8723b2ant_SpecialPacketNotify(struct btc_coexist *pBtCoexist, u8 type)
 {
        if (type == BTC_PACKET_DHCP) {
                BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], DHCP Packet notify\n"));
@@ -3359,7 +3359,7 @@ void EXhalbtc8723b2ant_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 type)
 }
 
 void EXhalbtc8723b2ant_BtInfoNotify(
-       PBTC_COEXIST pBtCoexist, u8 *tmpBuf, u8 length
+       struct btc_coexist *pBtCoexist, u8 *tmpBuf, u8 length
 )
 {
        u8      btInfo = 0;
@@ -3503,7 +3503,7 @@ void EXhalbtc8723b2ant_BtInfoNotify(
        halbtc8723b2ant_RunCoexistMechanism(pBtCoexist);
 }
 
-void EXhalbtc8723b2ant_HaltNotify(PBTC_COEXIST pBtCoexist)
+void EXhalbtc8723b2ant_HaltNotify(struct btc_coexist *pBtCoexist)
 {
        BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Halt notify\n"));
 
@@ -3514,7 +3514,7 @@ void EXhalbtc8723b2ant_HaltNotify(PBTC_COEXIST pBtCoexist)
        EXhalbtc8723b2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
 }
 
-void EXhalbtc8723b2ant_PnpNotify(PBTC_COEXIST pBtCoexist, u8 pnpState)
+void EXhalbtc8723b2ant_PnpNotify(struct btc_coexist *pBtCoexist, u8 pnpState)
 {
        BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify\n"));
 
@@ -3528,7 +3528,7 @@ void EXhalbtc8723b2ant_PnpNotify(PBTC_COEXIST pBtCoexist, u8 pnpState)
        }
 }
 
-void EXhalbtc8723b2ant_Periodical(PBTC_COEXIST pBtCoexist)
+void EXhalbtc8723b2ant_Periodical(struct btc_coexist *pBtCoexist)
 {
        static u8 disVerInfoCnt;
        u32 fwVer = 0, btPatchVer = 0;
index 9d4b5f51bd186b9053c997a9639378a767dd4795..1c220257e2e40cef41721aae913f5a5d67c1f9f4 100644 (file)
 
 #define                BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT             2
 
-enum BT_INFO_SRC_8723B_2ANT {
+enum bt_info_src_8723b_2ant {
        BT_INFO_SRC_8723B_2ANT_WIFI_FW        = 0x0,
        BT_INFO_SRC_8723B_2ANT_BT_RSP         = 0x1,
        BT_INFO_SRC_8723B_2ANT_BT_ACTIVE_SEND = 0x2,
        BT_INFO_SRC_8723B_2ANT_MAX
 };
 
-enum BT_8723B_2ANT_BT_STATUS {
+enum bt_8723b_2ant_bt_status {
        BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE = 0x0,
        BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE     = 0x1,
        BT_8723B_2ANT_BT_STATUS_INQ_PAGE           = 0x2,
@@ -33,7 +33,7 @@ enum BT_8723B_2ANT_BT_STATUS {
        BT_8723B_2ANT_BT_STATUS_MAX
 };
 
-enum BT_8723B_2ANT_COEX_ALGO {
+enum bt_8723b_2ant_coex_algo {
        BT_8723B_2ANT_COEX_ALGO_UNDEFINED       = 0x0,
        BT_8723B_2ANT_COEX_ALGO_SCO             = 0x1,
        BT_8723B_2ANT_COEX_ALGO_HID             = 0x2,
@@ -48,7 +48,7 @@ enum BT_8723B_2ANT_COEX_ALGO {
        BT_8723B_2ANT_COEX_ALGO_MAX             = 0xb,
 };
 
-struct COEX_DM_8723B_2ANT {
+struct coex_dm_8723b_2ant {
        /*  fw mechanism */
        u8 preBtDecPwrLvl;
        u8 curBtDecPwrLvl;
@@ -101,7 +101,7 @@ struct COEX_DM_8723B_2ANT {
        u32 backup0x948;
 };
 
-struct COEX_STA_8723B_2ANT {
+struct coex_sta_8723b_2ant {
        bool bBtLinkExist;
        bool bScoExist;
        bool bA2dpExist;
@@ -129,19 +129,19 @@ struct COEX_STA_8723B_2ANT {
 /*  */
 /*  The following is interface which will notify coex module. */
 /*  */
-void EXhalbtc8723b2ant_PowerOnSetting(PBTC_COEXIST pBtCoexist);
-void EXhalbtc8723b2ant_InitHwConfig(PBTC_COEXIST pBtCoexist, bool bWifiOnly);
-void EXhalbtc8723b2ant_InitCoexDm(PBTC_COEXIST pBtCoexist);
-void EXhalbtc8723b2ant_IpsNotify(PBTC_COEXIST pBtCoexist, u8 type);
-void EXhalbtc8723b2ant_LpsNotify(PBTC_COEXIST pBtCoexist, u8 type);
-void EXhalbtc8723b2ant_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type);
-void EXhalbtc8723b2ant_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 type);
-void EXhalbtc8723b2ant_MediaStatusNotify(PBTC_COEXIST pBtCoexist, u8 type);
-void EXhalbtc8723b2ant_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 type);
+void EXhalbtc8723b2ant_PowerOnSetting(struct btc_coexist *pBtCoexist);
+void EXhalbtc8723b2ant_InitHwConfig(struct btc_coexist *pBtCoexist, bool bWifiOnly);
+void EXhalbtc8723b2ant_InitCoexDm(struct btc_coexist *pBtCoexist);
+void EXhalbtc8723b2ant_IpsNotify(struct btc_coexist *pBtCoexist, u8 type);
+void EXhalbtc8723b2ant_LpsNotify(struct btc_coexist *pBtCoexist, u8 type);
+void EXhalbtc8723b2ant_ScanNotify(struct btc_coexist *pBtCoexist, u8 type);
+void EXhalbtc8723b2ant_ConnectNotify(struct btc_coexist *pBtCoexist, u8 type);
+void EXhalbtc8723b2ant_MediaStatusNotify(struct btc_coexist *pBtCoexist, u8 type);
+void EXhalbtc8723b2ant_SpecialPacketNotify(struct btc_coexist *pBtCoexist, u8 type);
 void EXhalbtc8723b2ant_BtInfoNotify(
-       PBTC_COEXIST pBtCoexist, u8 *tmpBuf, u8 length
+       struct btc_coexist *pBtCoexist, u8 *tmpBuf, u8 length
 );
-void EXhalbtc8723b2ant_HaltNotify(PBTC_COEXIST pBtCoexist);
-void EXhalbtc8723b2ant_PnpNotify(PBTC_COEXIST pBtCoexist, u8 pnpState);
-void EXhalbtc8723b2ant_Periodical(PBTC_COEXIST pBtCoexist);
-void EXhalbtc8723b2ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist);
+void EXhalbtc8723b2ant_HaltNotify(struct btc_coexist *pBtCoexist);
+void EXhalbtc8723b2ant_PnpNotify(struct btc_coexist *pBtCoexist, u8 pnpState);
+void EXhalbtc8723b2ant_Periodical(struct btc_coexist *pBtCoexist);
+void EXhalbtc8723b2ant_DisplayCoexInfo(struct btc_coexist *pBtCoexist);
index c758d143c57f3b0fac2cb808cc9a8c6d5e2cc7bc..10c021024b244a79d503a798f94e101f6d934819 100644 (file)
 #define BTC_ANT_WIFI_AT_CPL_MAIN       0
 #define BTC_ANT_WIFI_AT_CPL_AUX                1
 
-typedef enum _BTC_POWERSAVE_TYPE {
+enum btc_powersave_type {
        BTC_PS_WIFI_NATIVE      = 0,    /*  wifi original power save behavior */
        BTC_PS_LPS_ON           = 1,
        BTC_PS_LPS_OFF          = 2,
        BTC_PS_MAX
-} BTC_POWERSAVE_TYPE, *PBTC_POWERSAVE_TYPE;
+};
 
-typedef enum _BTC_BT_REG_TYPE {
+enum btc_bt_reg_type {
        BTC_BT_REG_RF           = 0,
        BTC_BT_REG_MODEM        = 1,
        BTC_BT_REG_BLUEWIZE     = 2,
        BTC_BT_REG_VENDOR       = 3,
        BTC_BT_REG_LE           = 4,
        BTC_BT_REG_MAX
-} BTC_BT_REG_TYPE, *PBTC_BT_REG_TYPE;
+};
 
-typedef enum _BTC_CHIP_INTERFACE {
+enum btc_chip_interface {
        BTC_INTF_UNKNOWN        = 0,
        BTC_INTF_PCI            = 1,
        BTC_INTF_USB            = 2,
        BTC_INTF_SDIO           = 3,
        BTC_INTF_MAX
-} BTC_CHIP_INTERFACE, *PBTC_CHIP_INTERFACE;
+};
 
-typedef enum _BTC_CHIP_TYPE {
+enum btc_chip_type {
        BTC_CHIP_UNDEF          = 0,
        BTC_CHIP_CSR_BC4        = 1,
        BTC_CHIP_CSR_BC8        = 2,
@@ -76,13 +76,13 @@ typedef enum _BTC_CHIP_TYPE {
        BTC_CHIP_RTL8821        = 4,
        BTC_CHIP_RTL8723B       = 5,
        BTC_CHIP_MAX
-} BTC_CHIP_TYPE, *PBTC_CHIP_TYPE;
+};
 
-typedef enum _BTC_MSG_TYPE {
+enum btc_msg_type {
        BTC_MSG_INTERFACE       = 0x0,
        BTC_MSG_ALGORITHM       = 0x1,
        BTC_MSG_MAX
-} BTC_MSG_TYPE;
+};
 extern u32             GLBtcDbgType[];
 
 /*  following is for BTC_MSG_INTERFACE */
@@ -120,14 +120,6 @@ extern u32                 GLBtcDbgType[];
                DbgPrint printstr;\
 }
 
-#define BTC_PRINT_F(dbgtype, dbgflag, printstr)\
-{\
-       if (GLBtcDbgType[dbgtype] & dbgflag) {\
-               DbgPrint("%s(): ", __func__);\
-               DbgPrint printstr;\
-       } \
-}
-
 #define BTC_PRINT_ADDR(dbgtype, dbgflag, printstr, _Ptr)\
 {\
        if (GLBtcDbgType[dbgtype] & dbgflag) {\
@@ -164,7 +156,7 @@ extern u32          GLBtcDbgType[];
                        no_printk("%s %p %zu", _TitleString, _HexData, _HexDataLen)
 #endif
 
-typedef struct _BTC_BOARD_INFO {
+struct btc_board_info {
        /*  The following is some board information */
        u8 btChipType;
        u8 pgAntNum;    /*  pg ant number */
@@ -172,9 +164,9 @@ typedef struct _BTC_BOARD_INFO {
        u8 btdmAntPos;          /* Bryant Add to indicate Antenna Position for (pgAntNum = 2) && (btdmAntNum = 1)  (DPDT+1Ant case) */
        u8 singleAntPath;       /*  current used for 8723b only, 1 =>s0,  0 =>s1 */
        /* bool                         bBtExist; */
-} BTC_BOARD_INFO, *PBTC_BOARD_INFO;
+};
 
-typedef enum _BTC_DBG_OPCODE {
+enum btc_dbg_opcode {
        BTC_DBG_SET_COEX_NORMAL                     = 0x0,
        BTC_DBG_SET_COEX_WIFI_ONLY                  = 0x1,
        BTC_DBG_SET_COEX_BT_ONLY                    = 0x2,
@@ -182,9 +174,9 @@ typedef enum _BTC_DBG_OPCODE {
        BTC_DBG_SET_COEX_BT_AFH_MAP                 = 0x4,
        BTC_DBG_SET_COEX_BT_IGNORE_WLAN_ACT     = 0x5,
        BTC_DBG_MAX
-} BTC_DBG_OPCODE, *PBTC_DBG_OPCODE;
+};
 
-typedef enum _BTC_RSSI_STATE {
+enum btc_rssi_state {
        BTC_RSSI_STATE_HIGH                         = 0x0,
        BTC_RSSI_STATE_MEDIUM                   = 0x1,
        BTC_RSSI_STATE_LOW                          = 0x2,
@@ -192,40 +184,40 @@ typedef enum _BTC_RSSI_STATE {
        BTC_RSSI_STATE_STAY_MEDIUM              = 0x4,
        BTC_RSSI_STATE_STAY_LOW                 = 0x5,
        BTC_RSSI_MAX
-} BTC_RSSI_STATE, *PBTC_RSSI_STATE;
+};
 #define BTC_RSSI_HIGH(_rssi_)  ((_rssi_ == BTC_RSSI_STATE_HIGH || _rssi_ == BTC_RSSI_STATE_STAY_HIGH) ? true : false)
 #define BTC_RSSI_MEDIUM(_rssi_)        ((_rssi_ == BTC_RSSI_STATE_MEDIUM || _rssi_ == BTC_RSSI_STATE_STAY_MEDIUM) ? true : false)
 #define BTC_RSSI_LOW(_rssi_)   ((_rssi_ == BTC_RSSI_STATE_LOW || _rssi_ == BTC_RSSI_STATE_STAY_LOW) ? true : false)
 
-typedef enum _BTC_WIFI_ROLE {
+enum btc_wifi_role {
        BTC_ROLE_STATION                        = 0x0,
        BTC_ROLE_AP                                     = 0x1,
        BTC_ROLE_IBSS                           = 0x2,
        BTC_ROLE_HS_MODE                        = 0x3,
        BTC_ROLE_MAX
-} BTC_WIFI_ROLE, *PBTC_WIFI_ROLE;
+};
 
-typedef enum _BTC_WIFI_BW_MODE {
+enum btc_wifi_bw_mode {
        BTC_WIFI_BW_LEGACY                      = 0x0,
        BTC_WIFI_BW_HT20                        = 0x1,
        BTC_WIFI_BW_HT40                        = 0x2,
        BTC_WIFI_BW_MAX
-} BTC_WIFI_BW_MODE, *PBTC_WIFI_BW_MODE;
+};
 
-typedef enum _BTC_WIFI_TRAFFIC_DIR {
+enum btc_wifi_traffic_dir {
        BTC_WIFI_TRAFFIC_TX                     = 0x0,
        BTC_WIFI_TRAFFIC_RX                     = 0x1,
        BTC_WIFI_TRAFFIC_MAX
-} BTC_WIFI_TRAFFIC_DIR, *PBTC_WIFI_TRAFFIC_DIR;
+};
 
-typedef enum _BTC_WIFI_PNP {
+enum btc_wifi_pnp {
        BTC_WIFI_PNP_WAKE_UP            = 0x0,
        BTC_WIFI_PNP_SLEEP                      = 0x1,
        BTC_WIFI_PNP_MAX
-} BTC_WIFI_PNP, *PBTC_WIFI_PNP;
+};
 
 /* for 8723b-d cut large current issue */
-typedef enum _BT_WIFI_COEX_STATE {
+enum bt_wifi_coex_state {
        BTC_WIFI_STAT_INIT,
        BTC_WIFI_STAT_IQK,
        BTC_WIFI_STAT_NORMAL_OFF,
@@ -233,10 +225,10 @@ typedef enum _BT_WIFI_COEX_STATE {
        BTC_WIFI_STAT_NORMAL,
        BTC_WIFI_STAT_ANT_DIV,
        BTC_WIFI_STAT_MAX
-} BT_WIFI_COEX_STATE, *PBT_WIFI_COEX_STATE;
+};
 
 /*  defined for BFP_BTC_GET */
-typedef enum _BTC_GET_TYPE {
+enum btc_get_type {
        /*  type bool */
        BTC_GET_BL_HS_OPERATION,
        BTC_GET_BL_HS_CONNECTING,
@@ -275,10 +267,10 @@ typedef enum _BTC_GET_TYPE {
        BTC_GET_U1_LPS_MODE,
 
        BTC_GET_MAX
-} BTC_GET_TYPE, *PBTC_GET_TYPE;
+};
 
 /*  defined for BFP_BTC_SET */
-typedef enum _BTC_SET_TYPE {
+enum btc_set_type {
        /*  type bool */
        BTC_SET_BL_BT_DISABLE,
        BTC_SET_BL_BT_TRAFFIC_BUSY,
@@ -316,65 +308,65 @@ typedef enum _BTC_SET_TYPE {
        BTC_SET_ACT_CTRL_8723B_ANT,
        /*  */
        BTC_SET_MAX
-} BTC_SET_TYPE, *PBTC_SET_TYPE;
+};
 
-typedef enum _BTC_DBG_DISP_TYPE {
+enum btc_dbg_disp_type {
        BTC_DBG_DISP_COEX_STATISTICS            = 0x0,
        BTC_DBG_DISP_BT_LINK_INFO                       = 0x1,
        BTC_DBG_DISP_FW_PWR_MODE_CMD            = 0x2,
        BTC_DBG_DISP_MAX
-} BTC_DBG_DISP_TYPE, *PBTC_DBG_DISP_TYPE;
+};
 
-typedef enum _BTC_NOTIFY_TYPE_IPS {
+enum btc_notify_type_ips {
        BTC_IPS_LEAVE                                           = 0x0,
        BTC_IPS_ENTER                                           = 0x1,
        BTC_IPS_MAX
-} BTC_NOTIFY_TYPE_IPS, *PBTC_NOTIFY_TYPE_IPS;
+};
 
-typedef enum _BTC_NOTIFY_TYPE_LPS {
+enum btc_notify_type_lps {
        BTC_LPS_DISABLE                                         = 0x0,
        BTC_LPS_ENABLE                                          = 0x1,
        BTC_LPS_MAX
-} BTC_NOTIFY_TYPE_LPS, *PBTC_NOTIFY_TYPE_LPS;
+};
 
-typedef enum _BTC_NOTIFY_TYPE_SCAN {
+enum btc_notify_type_scan {
        BTC_SCAN_FINISH                                         = 0x0,
        BTC_SCAN_START                                          = 0x1,
        BTC_SCAN_MAX
-} BTC_NOTIFY_TYPE_SCAN, *PBTC_NOTIFY_TYPE_SCAN;
+};
 
-typedef enum _BTC_NOTIFY_TYPE_ASSOCIATE {
+enum btc_notify_type_associate {
        BTC_ASSOCIATE_FINISH                            = 0x0,
        BTC_ASSOCIATE_START                                     = 0x1,
        BTC_ASSOCIATE_MAX
-} BTC_NOTIFY_TYPE_ASSOCIATE, *PBTC_NOTIFY_TYPE_ASSOCIATE;
+};
 
-typedef enum _BTC_NOTIFY_TYPE_MEDIA_STATUS {
+enum btc_notify_type_media_status {
        BTC_MEDIA_DISCONNECT                            = 0x0,
        BTC_MEDIA_CONNECT                                       = 0x1,
        BTC_MEDIA_MAX
-} BTC_NOTIFY_TYPE_MEDIA_STATUS, *PBTC_NOTIFY_TYPE_MEDIA_STATUS;
+};
 
-typedef enum _BTC_NOTIFY_TYPE_SPECIAL_PACKET {
+enum btc_notify_type_special_packet {
        BTC_PACKET_UNKNOWN                                      = 0x0,
        BTC_PACKET_DHCP                                         = 0x1,
        BTC_PACKET_ARP                                          = 0x2,
        BTC_PACKET_EAPOL                                        = 0x3,
        BTC_PACKET_MAX
-} BTC_NOTIFY_TYPE_SPECIAL_PACKET, *PBTC_NOTIFY_TYPE_SPECIAL_PACKET;
+};
 
-typedef enum _BTC_NOTIFY_TYPE_STACK_OPERATION {
+enum btc_notify_type_stack_operation {
        BTC_STACK_OP_NONE                                       = 0x0,
        BTC_STACK_OP_INQ_PAGE_PAIR_START        = 0x1,
        BTC_STACK_OP_INQ_PAGE_PAIR_FINISH       = 0x2,
        BTC_STACK_OP_MAX
-} BTC_NOTIFY_TYPE_STACK_OPERATION, *PBTC_NOTIFY_TYPE_STACK_OPERATION;
+};
 
 /* Bryant Add */
-typedef enum _BTC_ANTENNA_POS {
+enum btc_antenna_pos {
        BTC_ANTENNA_AT_MAIN_PORT = 0x1,
        BTC_ANTENNA_AT_AUX_PORT  = 0x2,
-} BTC_ANTENNA_POS, *PBTC_ANTENNA_POS;
+};
 
 typedef u8 (*BFP_BTC_R1)(void *pBtcContext, u32 RegAddr);
 typedef u16(*BFP_BTC_R2)(void *pBtcContext, u32 RegAddr);
@@ -409,7 +401,7 @@ typedef void (*BFP_BTC_SET_BT_REG)(
 typedef u32 (*BFP_BTC_GET_BT_REG)(void *pBtcContext, u8 regType, u32 offset);
 typedef void (*BFP_BTC_DISP_DBG_MSG)(void *pBtCoexist, u8 dispType);
 
-typedef struct _BTC_BT_INFO {
+struct btc_bt_info {
        bool bBtDisabled;
        u8 rssiAdjustForAgcTableOn;
        u8 rssiAdjustFor1AntCoexType;
@@ -435,9 +427,9 @@ typedef struct _BTC_BT_INFO {
        u8 lpsVal;
        u8 rpwmVal;
        u32 raMask;
-} BTC_BT_INFO, *PBTC_BT_INFO;
+};
 
-typedef struct _BTC_STACK_INFO {
+struct btc_stack_info {
        bool bProfileNotified;
        u16 hciVersion; /*  stack hci version */
        u8 numOfLink;
@@ -450,9 +442,9 @@ typedef struct _BTC_STACK_INFO {
        bool bPanExist;
        bool bUnknownAclExist;
        s8 minBtRssi;
-} BTC_STACK_INFO, *PBTC_STACK_INFO;
+};
 
-typedef struct _BTC_BT_LINK_INFO {
+struct btc_bt_link_info {
        bool bBtLinkExist;
        bool bScoExist;
        bool bScoOnly;
@@ -463,9 +455,9 @@ typedef struct _BTC_BT_LINK_INFO {
        bool bPanExist;
        bool bPanOnly;
        bool bSlaveRole;
-} BTC_BT_LINK_INFO, *PBTC_BT_LINK_INFO;
+};
 
-typedef struct _BTC_STATISTICS {
+struct btc_statistics {
        u32 cntBind;
        u32 cntPowerOn;
        u32 cntInitHwConfig;
@@ -482,22 +474,22 @@ typedef struct _BTC_STATISTICS {
        u32 cntCoexDmSwitch;
        u32 cntStackOperationNotify;
        u32 cntDbgCtrl;
-} BTC_STATISTICS, *PBTC_STATISTICS;
+};
 
-typedef struct _BTC_COEXIST {
+struct btc_coexist {
        bool bBinded;           /*  make sure only one adapter can bind the data context */
        void *Adapter;          /*  default adapter */
-       BTC_BOARD_INFO boardInfo;
-       BTC_BT_INFO btInfo;             /*  some bt info referenced by non-bt module */
-       BTC_STACK_INFO stackInfo;
-       BTC_BT_LINK_INFO btLinkInfo;
-       BTC_CHIP_INTERFACE chipInterface;
+       struct btc_board_info boardInfo;
+       struct btc_bt_info btInfo;              /*  some bt info referenced by non-bt module */
+       struct btc_stack_info stackInfo;
+       struct btc_bt_link_info btLinkInfo;
+       enum btc_chip_interface chipInterface;
 
        bool bInitilized;
        bool bStopCoexDm;
        bool bManualControl;
        u8 *cliBuf;
-       BTC_STATISTICS statistics;
+       struct btc_statistics statistics;
        u8 pwrModeVal[10];
 
        /*  function pointers */
@@ -528,30 +520,30 @@ typedef struct _BTC_COEXIST {
 
        BFP_BTC_GET_BT_REG fBtcGetBtReg;
        BFP_BTC_SET_BT_REG fBtcSetBtReg;
-} BTC_COEXIST, *PBTC_COEXIST;
+};
 
-extern BTC_COEXIST GLBtCoexist;
+extern struct btc_coexist GLBtCoexist;
 
-void EXhalbtcoutsrc_PowerOnSetting(PBTC_COEXIST pBtCoexist);
-void EXhalbtcoutsrc_InitHwConfig(PBTC_COEXIST pBtCoexist, u8 bWifiOnly);
-void EXhalbtcoutsrc_InitCoexDm(PBTC_COEXIST pBtCoexist);
-void EXhalbtcoutsrc_IpsNotify(PBTC_COEXIST pBtCoexist, u8 type);
-void EXhalbtcoutsrc_LpsNotify(PBTC_COEXIST pBtCoexist, u8 type);
-void EXhalbtcoutsrc_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type);
-void EXhalbtcoutsrc_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 action);
+void EXhalbtcoutsrc_PowerOnSetting(struct btc_coexist *pBtCoexist);
+void EXhalbtcoutsrc_InitHwConfig(struct btc_coexist *pBtCoexist, u8 bWifiOnly);
+void EXhalbtcoutsrc_InitCoexDm(struct btc_coexist *pBtCoexist);
+void EXhalbtcoutsrc_IpsNotify(struct btc_coexist *pBtCoexist, u8 type);
+void EXhalbtcoutsrc_LpsNotify(struct btc_coexist *pBtCoexist, u8 type);
+void EXhalbtcoutsrc_ScanNotify(struct btc_coexist *pBtCoexist, u8 type);
+void EXhalbtcoutsrc_ConnectNotify(struct btc_coexist *pBtCoexist, u8 action);
 void EXhalbtcoutsrc_MediaStatusNotify(
-       PBTC_COEXIST pBtCoexist, RT_MEDIA_STATUS mediaStatus
+       struct btc_coexist *pBtCoexist, enum rt_media_status mediaStatus
 );
-void EXhalbtcoutsrc_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 pktType);
+void EXhalbtcoutsrc_SpecialPacketNotify(struct btc_coexist *pBtCoexist, u8 pktType);
 void EXhalbtcoutsrc_BtInfoNotify(
-       PBTC_COEXIST pBtCoexist, u8 *tmpBuf, u8 length
+       struct btc_coexist *pBtCoexist, u8 *tmpBuf, u8 length
 );
-void EXhalbtcoutsrc_HaltNotify(PBTC_COEXIST pBtCoexist);
-void EXhalbtcoutsrc_PnpNotify(PBTC_COEXIST pBtCoexist, u8 pnpState);
-void EXhalbtcoutsrc_Periodical(PBTC_COEXIST pBtCoexist);
+void EXhalbtcoutsrc_HaltNotify(struct btc_coexist *pBtCoexist);
+void EXhalbtcoutsrc_PnpNotify(struct btc_coexist *pBtCoexist, u8 pnpState);
+void EXhalbtcoutsrc_Periodical(struct btc_coexist *pBtCoexist);
 void EXhalbtcoutsrc_SetChipType(u8 chipType);
 void EXhalbtcoutsrc_SetAntNum(u8 type, u8 antNum);
 void EXhalbtcoutsrc_SetSingleAntPath(u8 singleAntPath);
-void EXhalbtcoutsrc_DisplayBtCoexInfo(PBTC_COEXIST pBtCoexist);
+void EXhalbtcoutsrc_DisplayBtCoexInfo(struct btc_coexist *pBtCoexist);
 
 #endif
index 19856e806b1f174a58707d15235cf423fd3d66b9..016d257b90a07acbf814c46f2a631f5307898707 100644 (file)
@@ -9,7 +9,7 @@
 #include "odm_precomp.h"
 
 static bool CheckPositive(
-       PDM_ODM_T pDM_Odm, const u32 Condition1, const u32 Condition2
+       struct dm_odm_t *pDM_Odm, const u32 Condition1, const u32 Condition2
 )
 {
        u8 _BoardType =
@@ -112,7 +112,7 @@ static bool CheckPositive(
 }
 
 static bool CheckNegative(
-       PDM_ODM_T pDM_Odm, const u32  Condition1, const u32 Condition2
+       struct dm_odm_t *pDM_Odm, const u32  Condition1, const u32 Condition2
 )
 {
        return true;
@@ -257,7 +257,7 @@ static u32 Array_MP_8723B_AGC_TAB[] = {
 
 };
 
-void ODM_ReadAndConfig_MP_8723B_AGC_TAB(PDM_ODM_T pDM_Odm)
+void ODM_ReadAndConfig_MP_8723B_AGC_TAB(struct dm_odm_t *pDM_Odm)
 {
        u32 i = 0;
        u32 ArrayLen = ARRAY_SIZE(Array_MP_8723B_AGC_TAB);
@@ -526,7 +526,7 @@ static u32 Array_MP_8723B_PHY_REG[] = {
 
 };
 
-void ODM_ReadAndConfig_MP_8723B_PHY_REG(PDM_ODM_T pDM_Odm)
+void ODM_ReadAndConfig_MP_8723B_PHY_REG(struct dm_odm_t *pDM_Odm)
 {
        u32 i = 0;
        u32 ArrayLen = ARRAY_SIZE(Array_MP_8723B_PHY_REG);
@@ -606,7 +606,7 @@ static u32 Array_MP_8723B_PHY_REG_PG[] = {
        0, 0, 0, 0x00000e14, 0xffffffff, 0x26303436
 };
 
-void ODM_ReadAndConfig_MP_8723B_PHY_REG_PG(PDM_ODM_T pDM_Odm)
+void ODM_ReadAndConfig_MP_8723B_PHY_REG_PG(struct dm_odm_t *pDM_Odm)
 {
        u32 i = 0;
        u32 *Array = Array_MP_8723B_PHY_REG_PG;
index c1fbe91cd4f341433d88e0a7e23094190863ca55..186007ce57d52000baa38f6adbd3fa04840517f9 100644 (file)
@@ -15,7 +15,7 @@
 
 void
 ODM_ReadAndConfig_MP_8723B_AGC_TAB(/*  TC: Test Chip, MP: MP Chip */
-       PDM_ODM_T  pDM_Odm
+       struct dm_odm_t *pDM_Odm
 );
 
 /******************************************************************************
@@ -24,7 +24,7 @@ ODM_ReadAndConfig_MP_8723B_AGC_TAB(/*  TC: Test Chip, MP: MP Chip */
 
 void
 ODM_ReadAndConfig_MP_8723B_PHY_REG(/*  TC: Test Chip, MP: MP Chip */
-       PDM_ODM_T  pDM_Odm
+       struct dm_odm_t *pDM_Odm
 );
 
 /******************************************************************************
@@ -33,7 +33,7 @@ ODM_ReadAndConfig_MP_8723B_PHY_REG(/*  TC: Test Chip, MP: MP Chip */
 
 void
 ODM_ReadAndConfig_MP_8723B_PHY_REG_PG(/*  TC: Test Chip, MP: MP Chip */
-       PDM_ODM_T  pDM_Odm
+       struct dm_odm_t *pDM_Odm
 );
 u32 ODM_GetVersion_MP_8723B_PHY_REG_PG(void);
 
index b80c5b11796bb8f9e8e8a80f871b29db22c0ce5a..677bcfa10b0d51fea7830c9052adbec42dd2d010 100644 (file)
@@ -9,7 +9,7 @@
 #include "odm_precomp.h"
 
 static bool CheckPositive(
-       PDM_ODM_T pDM_Odm, const u32 Condition1, const u32 Condition2
+       struct dm_odm_t *pDM_Odm, const u32 Condition1, const u32 Condition2
 )
 {
        u8 _BoardType =
@@ -111,7 +111,7 @@ static bool CheckPositive(
 }
 
 static bool CheckNegative(
-       PDM_ODM_T pDM_Odm, const u32 Condition1, const u32 Condition2
+       struct dm_odm_t *pDM_Odm, const u32 Condition1, const u32 Condition2
 )
 {
        return true;
@@ -228,7 +228,7 @@ static u32 Array_MP_8723B_MAC_REG[] = {
 
 };
 
-void ODM_ReadAndConfig_MP_8723B_MAC_REG(PDM_ODM_T pDM_Odm)
+void ODM_ReadAndConfig_MP_8723B_MAC_REG(struct dm_odm_t *pDM_Odm)
 {
        u32 i = 0;
        u32 ArrayLen = ARRAY_SIZE(Array_MP_8723B_MAC_REG);
index 788fdca1337b7a7518eb34a084568421c4c3beb9..50429c159feeba23f1d0673c7e54b74cf87d5c25 100644 (file)
@@ -15,6 +15,6 @@
 
 void
 ODM_ReadAndConfig_MP_8723B_MAC_REG(/*  TC: Test Chip, MP: MP Chip */
-       PDM_ODM_T  pDM_Odm
+       struct dm_odm_t *pDM_Odm
 );
 #endif
index 426f68b8f0d2b1374d222b0244a6bc7c5d87d5a7..2c450c1ce7e7cd3bed3847821b96d80f6d77846c 100644 (file)
@@ -9,7 +9,7 @@
 #include "odm_precomp.h"
 
 static bool CheckPositive(
-       PDM_ODM_T pDM_Odm, const u32 Condition1, const u32 Condition2
+       struct dm_odm_t *pDM_Odm, const u32 Condition1, const u32 Condition2
 )
 {
        u8 _BoardType =
@@ -121,7 +121,7 @@ static bool CheckPositive(
 }
 
 static bool CheckNegative(
-       PDM_ODM_T pDM_Odm, const u32  Condition1, const u32 Condition2
+       struct dm_odm_t *pDM_Odm, const u32  Condition1, const u32 Condition2
 )
 {
        return true;
@@ -259,7 +259,7 @@ static u32 Array_MP_8723B_RadioA[] = {
 
 };
 
-void ODM_ReadAndConfig_MP_8723B_RadioA(PDM_ODM_T pDM_Odm)
+void ODM_ReadAndConfig_MP_8723B_RadioA(struct dm_odm_t *pDM_Odm)
 {
        u32 i = 0;
        u32 ArrayLen = ARRAY_SIZE(Array_MP_8723B_RadioA);
@@ -420,9 +420,9 @@ static u8 gDeltaSwingTableIdx_MP_2GCCKA_P_TxPowerTrack_SDIO_8723B[] = {
        8,  8,  9,  9,  9, 10, 10, 11, 11, 12, 12, 13, 14, 15
 };
 
-void ODM_ReadAndConfig_MP_8723B_TxPowerTrack_SDIO(PDM_ODM_T pDM_Odm)
+void ODM_ReadAndConfig_MP_8723B_TxPowerTrack_SDIO(struct dm_odm_t *pDM_Odm)
 {
-       PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo);
+       struct odm_rf_cal_t *pRFCalibrateInfo = &pDM_Odm->RFCalibrateInfo;
 
        ODM_RT_TRACE(
                pDM_Odm,
@@ -755,7 +755,7 @@ static u8 *Array_MP_8723B_TXPWR_LMT[] = {
        "MKK", "2.4G", "40M", "HT", "2T", "14", "63"
 };
 
-void ODM_ReadAndConfig_MP_8723B_TXPWR_LMT(PDM_ODM_T pDM_Odm)
+void ODM_ReadAndConfig_MP_8723B_TXPWR_LMT(struct dm_odm_t *pDM_Odm)
 {
        u32 i = 0;
        u8 **Array = Array_MP_8723B_TXPWR_LMT;
index 36a47437f97420c0c7be3e87edd810903ed05045..acf5679d188cf62488ea215725c5b5f5a93b1c0d 100644 (file)
@@ -15,7 +15,7 @@
 
 void
 ODM_ReadAndConfig_MP_8723B_RadioA(/*  TC: Test Chip, MP: MP Chip */
-       PDM_ODM_T  pDM_Odm
+       struct dm_odm_t *pDM_Odm
 );
 
 /******************************************************************************
@@ -24,7 +24,7 @@ ODM_ReadAndConfig_MP_8723B_RadioA(/*  TC: Test Chip, MP: MP Chip */
 
 void
 ODM_ReadAndConfig_MP_8723B_TxPowerTrack_SDIO(/*  TC: Test Chip, MP: MP Chip */
-       PDM_ODM_T  pDM_Odm
+       struct dm_odm_t *pDM_Odm
 );
 u32 ODM_GetVersion_MP_8723B_TxPowerTrack_SDIO(void);
 
@@ -34,7 +34,7 @@ u32 ODM_GetVersion_MP_8723B_TxPowerTrack_SDIO(void);
 
 void
 ODM_ReadAndConfig_MP_8723B_TXPWR_LMT(/*  TC: Test Chip, MP: MP Chip */
-       PDM_ODM_T  pDM_Odm
+       struct dm_odm_t *pDM_Odm
 );
 u32 ODM_GetVersion_MP_8723B_TXPWR_LMT(void);
 
index 491bf735c6f11a48d16bfef44e505aec948e2737..14426151faaeced45a7ed39c0a25e8ef391b8ed0 100644 (file)
@@ -23,7 +23,7 @@
        } while (0)
 
 
-void ConfigureTxpowerTrack(PDM_ODM_T pDM_Odm, struct TXPWRTRACK_CFG * pConfig)
+void ConfigureTxpowerTrack(struct dm_odm_t *pDM_Odm, struct txpwrtrack_cfg *pConfig)
 {
        ConfigureTxpowerTrack_8723B(pConfig);
 }
@@ -36,7 +36,7 @@ void ConfigureTxpowerTrack(PDM_ODM_T pDM_Odm, struct TXPWRTRACK_CFG * pConfig)
 /*  NOTE: If Tx BB swing or Tx scaling is varified during run-time, still */
 /*        need to call this function. */
 /*  */
-void ODM_ClearTxPowerTrackingState(PDM_ODM_T pDM_Odm)
+void ODM_ClearTxPowerTrackingState(struct dm_odm_t *pDM_Odm)
 {
        struct hal_com_data *pHalData = GET_HAL_DATA(pDM_Odm->Adapter);
        u8 p = 0;
@@ -74,7 +74,7 @@ void ODM_TXPowerTrackingCallback_ThermalMeter(struct adapter *Adapter)
 {
 
        struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
-       PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+       struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
 
        u8 ThermalValue = 0, delta, delta_LCK, delta_IQK, p = 0, i = 0;
        u8 ThermalValue_AVG_count = 0;
@@ -83,7 +83,7 @@ void ODM_TXPowerTrackingCallback_ThermalMeter(struct adapter *Adapter)
        u8 OFDM_min_index = 0;  /*  OFDM BB Swing should be less than +3.0dB, which is required by Arthur */
        u8 Indexforchannel = 0; /*  GetRightChnlPlaceforIQK(pHalData->CurrentChannel) */
 
-       struct TXPWRTRACK_CFG c;
+       struct txpwrtrack_cfg c;
 
 
        /* 4 1. The following TWO tables decide the final index of OFDM/CCK swing table. */
index 5adccb98184586a3ead9c84996a5b00cb3671f6d..d7eda508d04db4ebfcd293a336201fa2ad187a5f 100644 (file)
@@ -8,23 +8,23 @@
  #ifndef __HAL_PHY_RF_H__
  #define __HAL_PHY_RF_H__
 
-enum SPUR_CAL_METHOD {
+enum spur_cal_method {
        PLL_RESET,
        AFE_PHASE_SEL
 };
 
-enum PWRTRACK_METHOD {
+enum pwrtrack_method {
        BBSWING,
        TXAGC,
        MIX_MODE
 };
 
-typedef void (*FuncSetPwr)(PDM_ODM_T, enum PWRTRACK_METHOD, u8, u8);
-typedef void (*FuncIQK)(PDM_ODM_T, u8, u8, u8);
-typedef void (*FuncLCK)(PDM_ODM_T);
-typedef void (*FuncSwing)(PDM_ODM_T, u8 **, u8 **, u8 **, u8 **);
+typedef void (*FuncSetPwr)(struct dm_odm_t *, enum pwrtrack_method, u8, u8);
+typedef void (*FuncIQK)(struct dm_odm_t *, u8, u8, u8);
+typedef void (*FuncLCK)(struct dm_odm_t *);
+typedef void (*FuncSwing)(struct dm_odm_t *, u8 **, u8 **, u8 **, u8 **);
 
-struct TXPWRTRACK_CFG {
+struct txpwrtrack_cfg {
        u8 SwingTableSize_CCK;
        u8 SwingTableSize_OFDM;
        u8 Threshold_IQK;
@@ -37,10 +37,10 @@ struct TXPWRTRACK_CFG {
        FuncSwing GetDeltaSwingTable;
 };
 
-void ConfigureTxpowerTrack(PDM_ODM_T pDM_Odm, struct TXPWRTRACK_CFG * pConfig);
+void ConfigureTxpowerTrack(struct dm_odm_t *pDM_Odm, struct txpwrtrack_cfg *pConfig);
 
 
-void ODM_ClearTxPowerTrackingState(PDM_ODM_T pDM_Odm);
+void ODM_ClearTxPowerTrackingState(struct dm_odm_t *pDM_Odm);
 
 void ODM_TXPowerTrackingCallback_ThermalMeter(struct adapter *Adapter);
 
index d8b3b20955443b0992747a3bcf2f50aad718061d..12f0e36015317583ea5e09cdf03abd8fbd9bc00c 100644 (file)
@@ -54,7 +54,7 @@ static u8 DeltaSwingTableIdx_2GA_P_8188E[] = {
 
 
 static void setIqkMatrix_8723B(
-       PDM_ODM_T pDM_Odm,
+       struct dm_odm_t *pDM_Odm,
        u8 OFDM_index,
        u8 RFPath,
        s32 IqkResult_X,
@@ -135,7 +135,7 @@ static void setIqkMatrix_8723B(
 }
 
 
-static void setCCKFilterCoefficient(PDM_ODM_T pDM_Odm, u8 CCKSwingIndex)
+static void setCCKFilterCoefficient(struct dm_odm_t *pDM_Odm, u8 CCKSwingIndex)
 {
        if (!pDM_Odm->RFCalibrateInfo.bCCKinCH14) {
                rtw_write8(pDM_Odm->Adapter, 0xa22, CCKSwingTable_Ch1_Ch13_New[CCKSwingIndex][0]);
@@ -159,7 +159,7 @@ static void setCCKFilterCoefficient(PDM_ODM_T pDM_Odm, u8 CCKSwingIndex)
 }
 
 void DoIQK_8723B(
-       PDM_ODM_T pDM_Odm,
+       struct dm_odm_t *pDM_Odm,
        u8 DeltaThermalIndex,
        u8 ThermalValue,
        u8 Threshold
@@ -185,8 +185,8 @@ void DoIQK_8723B(
  *
  *---------------------------------------------------------------------------*/
 void ODM_TxPwrTrackSetPwr_8723B(
-       PDM_ODM_T pDM_Odm,
-       enum PWRTRACK_METHOD Method,
+       struct dm_odm_t *pDM_Odm,
+       enum pwrtrack_method Method,
        u8 RFPath,
        u8 ChannelMappedIndex
 )
@@ -360,7 +360,7 @@ void ODM_TxPwrTrackSetPwr_8723B(
 }
 
 static void GetDeltaSwingTable_8723B(
-       PDM_ODM_T pDM_Odm,
+       struct dm_odm_t *pDM_Odm,
        u8 **TemperatureUP_A,
        u8 **TemperatureDOWN_A,
        u8 **TemperatureUP_B,
@@ -368,7 +368,7 @@ static void GetDeltaSwingTable_8723B(
 )
 {
        struct adapter *Adapter = pDM_Odm->Adapter;
-       PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo);
+       struct odm_rf_cal_t *pRFCalibrateInfo = &pDM_Odm->RFCalibrateInfo;
        struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
        u16 rate = *(pDM_Odm->pForcedDataRate);
        u8 channel = pHalData->CurrentChannel;
@@ -409,7 +409,7 @@ static void GetDeltaSwingTable_8723B(
 }
 
 
-void ConfigureTxpowerTrack_8723B(struct TXPWRTRACK_CFG * pConfig)
+void ConfigureTxpowerTrack_8723B(struct txpwrtrack_cfg *pConfig)
 {
        pConfig->SwingTableSize_CCK = CCK_TABLE_SIZE;
        pConfig->SwingTableSize_OFDM = OFDM_TABLE_SIZE;
@@ -437,7 +437,7 @@ static u8 phy_PathA_IQK_8723B(
        u8 result = 0x00;
 
        struct hal_com_data     *pHalData = GET_HAL_DATA(padapter);
-       PDM_ODM_T               pDM_Odm = &pHalData->odmpriv;
+       struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
 
        /*  Save RF Path */
        Path_SEL_BB = PHY_QueryBBReg(pDM_Odm->Adapter, 0x948, bMaskDWord);
@@ -548,7 +548,7 @@ static u8 phy_PathA_RxIQK8723B(
        u32 regEAC, regE94, regE9C, regEA4, u4tmp, tmp, Path_SEL_BB;
        u8 result = 0x00;
        struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
-       PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+       struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
 
 /*     ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A Rx IQK!\n")); */
 
@@ -762,7 +762,7 @@ static u8 phy_PathB_IQK_8723B(struct adapter *padapter)
        u32 regEAC, regE94, regE9C, tmp, Path_SEL_BB/*, regEC4, regECC, Path_SEL_BB*/;
        u8 result = 0x00;
        struct hal_com_data     *pHalData = GET_HAL_DATA(padapter);
-       PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+       struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
 
        ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD,  ("Path B IQK!\n"));
 
@@ -869,7 +869,7 @@ static u8 phy_PathB_RxIQK8723B(struct adapter *padapter, bool configPathB)
        u32 regE94, regE9C, regEA4, regEAC, u4tmp, tmp, Path_SEL_BB;
        u8 result = 0x00;
        struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
-       PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+       struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
 
 /*     ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path B Rx IQK!\n")); */
 
@@ -1092,9 +1092,9 @@ static void _PHY_PathAFillIQKMatrix8723B(
        u32 Oldval_0, X, TX0_A, reg;
        s32 Y, TX0_C;
        struct hal_com_data     *pHalData = GET_HAL_DATA(padapter);
-       PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+       struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
 
-       PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo);
+       struct odm_rf_cal_t *pRFCalibrateInfo = &pDM_Odm->RFCalibrateInfo;
 
        ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD,  ("Path A IQ Calibration %s !\n", (bIQKOK)?"Success":"Failed"));
 
@@ -1172,9 +1172,9 @@ static void _PHY_PathBFillIQKMatrix8723B(
        u32 Oldval_1, X, TX1_A, reg;
        s32     Y, TX1_C;
        struct hal_com_data     *pHalData = GET_HAL_DATA(padapter);
-       PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+       struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
 
-       PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo);
+       struct odm_rf_cal_t *pRFCalibrateInfo = &pDM_Odm->RFCalibrateInfo;
 
        ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path B IQ Calibration %s !\n", (bIQKOK)?"Success":"Failed"));
 
@@ -1247,10 +1247,10 @@ static void _PHY_PathBFillIQKMatrix8723B(
 /*  */
 /*  MP Already declare in odm.c */
 
-void ODM_SetIQCbyRFpath(PDM_ODM_T pDM_Odm, u32 RFpath)
+void ODM_SetIQCbyRFpath(struct dm_odm_t *pDM_Odm, u32 RFpath)
 {
 
-       PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo);
+       struct odm_rf_cal_t *pRFCalibrateInfo = &pDM_Odm->RFCalibrateInfo;
 
        if (
                (pRFCalibrateInfo->TxIQC_8723B[PATH_S0][IDX_0xC80][VAL] != 0x0) &&
@@ -1292,7 +1292,7 @@ static void _PHY_SaveADDARegisters8723B(
 {
        u32 i;
        struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
-       PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+       struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
 
        if (!ODM_CheckPowerStatus(padapter))
                return;
@@ -1310,7 +1310,7 @@ static void _PHY_SaveMACRegisters8723B(
 {
        u32 i;
        struct hal_com_data     *pHalData = GET_HAL_DATA(padapter);
-       PDM_ODM_T               pDM_Odm = &pHalData->odmpriv;
+       struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
 
        ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Save MAC parameters.\n"));
        for (i = 0 ; i < (IQK_MAC_REG_NUM - 1); i++) {
@@ -1330,7 +1330,7 @@ static void _PHY_ReloadADDARegisters8723B(
 {
        u32 i;
        struct hal_com_data     *pHalData = GET_HAL_DATA(padapter);
-       PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+       struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
 
        ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Reload ADDA power saving parameters !\n"));
        for (i = 0 ; i < RegiesterNum; i++) {
@@ -1360,7 +1360,7 @@ static void _PHY_PathADDAOn8723B(
        u32 pathOn;
        u32 i;
        struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
-       PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+       struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
 
        ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("ADDA ON.\n"));
 
@@ -1384,7 +1384,7 @@ static void _PHY_MACSettingCalibration8723B(
 {
        u32 i = 0;
        struct hal_com_data     *pHalData = GET_HAL_DATA(padapter);
-       PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+       struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
 
        ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("MAC settings for Calibration.\n"));
 
@@ -1489,7 +1489,7 @@ static void phy_IQCalibrate_8723B(
 )
 {
        struct hal_com_data     *pHalData = GET_HAL_DATA(padapter);
-       PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+       struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
 
        u32 i;
        u8 PathAOK, PathBOK;
@@ -1697,7 +1697,7 @@ static void phy_IQCalibrate_8723B(
 }
 
 
-static void phy_LCCalibrate_8723B(PDM_ODM_T pDM_Odm, bool is2T)
+static void phy_LCCalibrate_8723B(struct dm_odm_t *pDM_Odm, bool is2T)
 {
        u8 tmpReg;
        u32 RF_Amode = 0, RF_Bmode = 0, LC_Cal;
@@ -1784,7 +1784,7 @@ void PHY_IQCalibrate_8723B(
 {
        struct hal_com_data     *pHalData = GET_HAL_DATA(padapter);
 
-       PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+       struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
 
        s32 result[4][8];       /* last is final result */
        u8 i, final_candidate;
@@ -1830,7 +1830,7 @@ void PHY_IQCalibrate_8723B(
        if (bRestore) {
                u32 offset, data;
                u8 path, bResult = SUCCESS;
-               PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo);
+               struct odm_rf_cal_t *pRFCalibrateInfo = &pDM_Odm->RFCalibrateInfo;
 
                path = (PHY_QueryBBReg(pDM_Odm->Adapter, rS0S1_PathSwitch, bMaskByte0) == 0x00) ? ODM_RF_PATH_A : ODM_RF_PATH_B;
 
@@ -2038,7 +2038,7 @@ void PHY_IQCalibrate_8723B(
 }
 
 
-void PHY_LCCalibrate_8723B(PDM_ODM_T pDM_Odm)
+void PHY_LCCalibrate_8723B(struct dm_odm_t *pDM_Odm)
 {
        bool            bSingleTone = false, bCarrierSuppression = false;
        u32             timeout = 2000, timecount = 0;
index c61d39acb6a41359753adb4105c4f39c9767ca97..775095ad0921c751fad4ecd838b6e9fc30a6f5ce 100644 (file)
 #define        RF_T_METER_8723B                                        0x42    /*  */
 
 
-void ConfigureTxpowerTrack_8723B(struct TXPWRTRACK_CFG * pConfig);
+void ConfigureTxpowerTrack_8723B(struct txpwrtrack_cfg *pConfig);
 
 void DoIQK_8723B(
-       PDM_ODM_T pDM_Odm,
+       struct dm_odm_t *pDM_Odm,
        u8 DeltaThermalIndex,
        u8 ThermalValue,
        u8 Threshold
 );
 
 void ODM_TxPwrTrackSetPwr_8723B(
-       PDM_ODM_T pDM_Odm,
-       enum PWRTRACK_METHOD Method,
+       struct dm_odm_t *pDM_Odm,
+       enum pwrtrack_method Method,
        u8 RFPath,
        u8 ChannelMappedIndex
 );
@@ -41,12 +41,12 @@ void PHY_IQCalibrate_8723B(
        u8 RF_Path
 );
 
-void ODM_SetIQCbyRFpath(PDM_ODM_T pDM_Odm, u32 RFpath);
+void ODM_SetIQCbyRFpath(struct dm_odm_t *pDM_Odm, u32 RFpath);
 
 /*  */
 /*  LC calibrate */
 /*  */
-void PHY_LCCalibrate_8723B(PDM_ODM_T pDM_Odm);
+void PHY_LCCalibrate_8723B(struct dm_odm_t *pDM_Odm);
 
 /*  */
 /*  AP calibrate */
index 3b34a516075fc548c02405de2965ab52ea3117ea..932b31fda6ad8421e955a64126c4945f6c7e06ed 100644 (file)
@@ -39,10 +39,10 @@ u8 HalPwrSeqCmdParsing(
        u8 CutVersion,
        u8 FabVersion,
        u8 InterfaceType,
-       WLAN_PWR_CFG PwrSeqCmd[]
+       struct wlan_pwr_cfg PwrSeqCmd[]
 )
 {
-       WLAN_PWR_CFG PwrCfgCmd;
+       struct wlan_pwr_cfg PwrCfgCmd;
        u8 bPollingBit = false;
        u32 AryIdx = 0;
        u8 value = 0;
index 3705a60a0546219663d7a55dcca17caccf094a35..d42cc24c7535c94f215d60cdecc743f992d970d8 100644 (file)
 
 /*             Global variables */
 
-BTC_COEXIST GLBtCoexist;
+struct btc_coexist GLBtCoexist;
 static u8 GLBtcWiFiInScanState;
 static u8 GLBtcWiFiInIQKState;
 
 u32 GLBtcDbgType[BTC_MSG_MAX];
 static u8 GLBtcDbgBuf[BT_TMP_BUF_SIZE];
 
-typedef struct _btcoexdbginfo {
+struct btcdbginfo { /* _btcoexdbginfo */
        u8 *info;
        u32 size; /*  buffer total size */
        u32 len; /*  now used length */
-} BTCDBGINFO, *PBTCDBGINFO;
+};
 
-static BTCDBGINFO GLBtcDbgInfo;
+static struct btcdbginfo GLBtcDbgInfo;
 
 #define        BT_Operation(Adapter)                                           false
 
-static void DBG_BT_INFO_INIT(PBTCDBGINFO pinfo, u8 *pbuf, u32 size)
+static void DBG_BT_INFO_INIT(struct btcdbginfo *pinfo, u8 *pbuf, u32 size)
 {
        if (!pinfo)
                return;
 
-       memset(pinfo, 0, sizeof(BTCDBGINFO));
+       memset(pinfo, 0, sizeof(struct btcdbginfo));
 
        if (pbuf && size) {
                pinfo->info = pbuf;
@@ -45,7 +45,7 @@ static void DBG_BT_INFO_INIT(PBTCDBGINFO pinfo, u8 *pbuf, u32 size)
 
 void DBG_BT_INFO(u8 *dbgmsg)
 {
-       PBTCDBGINFO pinfo;
+       struct btcdbginfo *pinfo;
        u32 msglen;
        u8 *pbuf;
 
@@ -67,7 +67,7 @@ void DBG_BT_INFO(u8 *dbgmsg)
 /*  */
 /*             Debug related function */
 /*  */
-static u8 halbtcoutsrc_IsBtCoexistAvailable(PBTC_COEXIST pBtCoexist)
+static u8 halbtcoutsrc_IsBtCoexistAvailable(struct btc_coexist *pBtCoexist)
 {
        if (!pBtCoexist->bBinded || !pBtCoexist->Adapter)
                return false;
@@ -101,7 +101,7 @@ static void halbtcoutsrc_DbgInit(void)
                        0;
 }
 
-static void halbtcoutsrc_LeaveLps(PBTC_COEXIST pBtCoexist)
+static void halbtcoutsrc_LeaveLps(struct btc_coexist *pBtCoexist)
 {
        struct adapter *padapter;
 
@@ -114,7 +114,7 @@ static void halbtcoutsrc_LeaveLps(PBTC_COEXIST pBtCoexist)
        rtw_btcoex_LPS_Leave(padapter);
 }
 
-static void halbtcoutsrc_EnterLps(PBTC_COEXIST pBtCoexist)
+static void halbtcoutsrc_EnterLps(struct btc_coexist *pBtCoexist)
 {
        struct adapter *padapter;
 
@@ -127,7 +127,7 @@ static void halbtcoutsrc_EnterLps(PBTC_COEXIST pBtCoexist)
        rtw_btcoex_LPS_Enter(padapter);
 }
 
-static void halbtcoutsrc_NormalLps(PBTC_COEXIST pBtCoexist)
+static void halbtcoutsrc_NormalLps(struct btc_coexist *pBtCoexist)
 {
        struct adapter *padapter;
 
@@ -149,7 +149,7 @@ static void halbtcoutsrc_NormalLps(PBTC_COEXIST pBtCoexist)
  *  Constraint:
  *   1. this function will request pwrctrl->lock
  */
-static void halbtcoutsrc_LeaveLowPower(PBTC_COEXIST pBtCoexist)
+static void halbtcoutsrc_LeaveLowPower(struct btc_coexist *pBtCoexist)
 {
        struct adapter *padapter;
        s32 ready;
@@ -184,7 +184,7 @@ static void halbtcoutsrc_LeaveLowPower(PBTC_COEXIST pBtCoexist)
  *  Constraint:
  *   1. this function will request pwrctrl->lock
  */
-static void halbtcoutsrc_NormalLowPower(PBTC_COEXIST pBtCoexist)
+static void halbtcoutsrc_NormalLowPower(struct btc_coexist *pBtCoexist)
 {
        struct adapter *padapter;
 
@@ -193,7 +193,7 @@ static void halbtcoutsrc_NormalLowPower(PBTC_COEXIST pBtCoexist)
        rtw_unregister_task_alive(padapter, BTCOEX_ALIVE);
 }
 
-static void halbtcoutsrc_DisableLowPower(PBTC_COEXIST pBtCoexist, u8 bLowPwrDisable)
+static void halbtcoutsrc_DisableLowPower(struct btc_coexist *pBtCoexist, u8 bLowPwrDisable)
 {
        pBtCoexist->btInfo.bBtDisableLowPwr = bLowPwrDisable;
        if (bLowPwrDisable)
@@ -202,7 +202,7 @@ static void halbtcoutsrc_DisableLowPower(PBTC_COEXIST pBtCoexist, u8 bLowPwrDisa
                halbtcoutsrc_NormalLowPower(pBtCoexist);        /*  original 32k low power behavior. */
 }
 
-static void halbtcoutsrc_AggregationCheck(PBTC_COEXIST pBtCoexist)
+static void halbtcoutsrc_AggregationCheck(struct btc_coexist *pBtCoexist)
 {
        struct adapter *padapter;
        bool bNeedToAct;
@@ -280,7 +280,7 @@ static u32 _halbtcoutsrc_GetWifiLinkStatus(struct adapter *padapter)
        return portConnectedStatus;
 }
 
-static u32 halbtcoutsrc_GetWifiLinkStatus(PBTC_COEXIST pBtCoexist)
+static u32 halbtcoutsrc_GetWifiLinkStatus(struct btc_coexist *pBtCoexist)
 {
        /*  */
        /*  return value: */
@@ -308,7 +308,7 @@ static u32 halbtcoutsrc_GetWifiLinkStatus(PBTC_COEXIST pBtCoexist)
        return retVal;
 }
 
-static u32 halbtcoutsrc_GetBtPatchVer(PBTC_COEXIST pBtCoexist)
+static u32 halbtcoutsrc_GetBtPatchVer(struct btc_coexist *pBtCoexist)
 {
        return pBtCoexist->btInfo.btRealFwVer;
 }
@@ -339,7 +339,7 @@ static u8 halbtcoutsrc_GetWifiScanAPNum(struct adapter *padapter)
 
 static u8 halbtcoutsrc_Get(void *pBtcContext, u8 getType, void *pOutBuf)
 {
-       PBTC_COEXIST pBtCoexist;
+       struct btc_coexist *pBtCoexist;
        struct adapter *padapter;
        struct hal_com_data *pHalData;
        struct mlme_ext_priv *mlmeext;
@@ -349,7 +349,7 @@ static u8 halbtcoutsrc_Get(void *pBtcContext, u8 getType, void *pOutBuf)
        u8 ret;
 
 
-       pBtCoexist = (PBTC_COEXIST)pBtcContext;
+       pBtCoexist = (struct btc_coexist *)pBtcContext;
        if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
                return false;
 
@@ -445,7 +445,7 @@ static u8 halbtcoutsrc_Get(void *pBtcContext, u8 getType, void *pOutBuf)
 
        case BTC_GET_U4_WIFI_TRAFFIC_DIRECTION:
                {
-                       PRT_LINK_DETECT_T plinkinfo;
+                       struct rt_link_detect_t *plinkinfo;
                        plinkinfo = &padapter->mlmepriv.LinkDetectInfo;
 
                        if (plinkinfo->NumTxOkInPeriod > plinkinfo->NumRxOkInPeriod)
@@ -507,14 +507,14 @@ static u8 halbtcoutsrc_Get(void *pBtcContext, u8 getType, void *pOutBuf)
 
 static u8 halbtcoutsrc_Set(void *pBtcContext, u8 setType, void *pInBuf)
 {
-       PBTC_COEXIST pBtCoexist;
+       struct btc_coexist *pBtCoexist;
        struct adapter *padapter;
        u8 *pu8;
        u32 *pU4Tmp;
        u8 ret;
 
 
-       pBtCoexist = (PBTC_COEXIST)pBtcContext;
+       pBtCoexist = (struct btc_coexist *)pBtcContext;
        padapter = pBtCoexist->Adapter;
        pu8 = pInBuf;
        pU4Tmp = pInBuf;
@@ -642,7 +642,7 @@ static u8 halbtcoutsrc_Set(void *pBtcContext, u8 setType, void *pInBuf)
        return ret;
 }
 
-static void halbtcoutsrc_DisplayFwPwrModeCmd(PBTC_COEXIST pBtCoexist)
+static void halbtcoutsrc_DisplayFwPwrModeCmd(struct btc_coexist *pBtCoexist)
 {
        u8 *cliBuf = pBtCoexist->cliBuf;
 
@@ -658,11 +658,11 @@ static void halbtcoutsrc_DisplayFwPwrModeCmd(PBTC_COEXIST pBtCoexist)
 /*  */
 static u8 halbtcoutsrc_Read1Byte(void *pBtcContext, u32 RegAddr)
 {
-       PBTC_COEXIST pBtCoexist;
+       struct btc_coexist *pBtCoexist;
        struct adapter *padapter;
 
 
-       pBtCoexist = (PBTC_COEXIST)pBtcContext;
+       pBtCoexist = (struct btc_coexist *)pBtcContext;
        padapter = pBtCoexist->Adapter;
 
        return rtw_read8(padapter, RegAddr);
@@ -670,11 +670,11 @@ static u8 halbtcoutsrc_Read1Byte(void *pBtcContext, u32 RegAddr)
 
 static u16 halbtcoutsrc_Read2Byte(void *pBtcContext, u32 RegAddr)
 {
-       PBTC_COEXIST pBtCoexist;
+       struct btc_coexist *pBtCoexist;
        struct adapter *padapter;
 
 
-       pBtCoexist = (PBTC_COEXIST)pBtcContext;
+       pBtCoexist = (struct btc_coexist *)pBtcContext;
        padapter = pBtCoexist->Adapter;
 
        return  rtw_read16(padapter, RegAddr);
@@ -682,11 +682,11 @@ static u16 halbtcoutsrc_Read2Byte(void *pBtcContext, u32 RegAddr)
 
 static u32 halbtcoutsrc_Read4Byte(void *pBtcContext, u32 RegAddr)
 {
-       PBTC_COEXIST pBtCoexist;
+       struct btc_coexist *pBtCoexist;
        struct adapter *padapter;
 
 
-       pBtCoexist = (PBTC_COEXIST)pBtcContext;
+       pBtCoexist = (struct btc_coexist *)pBtcContext;
        padapter = pBtCoexist->Adapter;
 
        return  rtw_read32(padapter, RegAddr);
@@ -694,11 +694,11 @@ static u32 halbtcoutsrc_Read4Byte(void *pBtcContext, u32 RegAddr)
 
 static void halbtcoutsrc_Write1Byte(void *pBtcContext, u32 RegAddr, u8 Data)
 {
-       PBTC_COEXIST pBtCoexist;
+       struct btc_coexist *pBtCoexist;
        struct adapter *padapter;
 
 
-       pBtCoexist = (PBTC_COEXIST)pBtcContext;
+       pBtCoexist = (struct btc_coexist *)pBtcContext;
        padapter = pBtCoexist->Adapter;
 
        rtw_write8(padapter, RegAddr, Data);
@@ -706,13 +706,13 @@ static void halbtcoutsrc_Write1Byte(void *pBtcContext, u32 RegAddr, u8 Data)
 
 static void halbtcoutsrc_BitMaskWrite1Byte(void *pBtcContext, u32 regAddr, u8 bitMask, u8 data1b)
 {
-       PBTC_COEXIST pBtCoexist;
+       struct btc_coexist *pBtCoexist;
        struct adapter *padapter;
        u8 originalValue, bitShift;
        u8 i;
 
 
-       pBtCoexist = (PBTC_COEXIST)pBtcContext;
+       pBtCoexist = (struct btc_coexist *)pBtcContext;
        padapter = pBtCoexist->Adapter;
        originalValue = 0;
        bitShift = 0;
@@ -734,11 +734,11 @@ static void halbtcoutsrc_BitMaskWrite1Byte(void *pBtcContext, u32 regAddr, u8 bi
 
 static void halbtcoutsrc_Write2Byte(void *pBtcContext, u32 RegAddr, u16 Data)
 {
-       PBTC_COEXIST pBtCoexist;
+       struct btc_coexist *pBtCoexist;
        struct adapter *padapter;
 
 
-       pBtCoexist = (PBTC_COEXIST)pBtcContext;
+       pBtCoexist = (struct btc_coexist *)pBtcContext;
        padapter = pBtCoexist->Adapter;
 
        rtw_write16(padapter, RegAddr, Data);
@@ -746,11 +746,11 @@ static void halbtcoutsrc_Write2Byte(void *pBtcContext, u32 RegAddr, u16 Data)
 
 static void halbtcoutsrc_Write4Byte(void *pBtcContext, u32 RegAddr, u32 Data)
 {
-       PBTC_COEXIST pBtCoexist;
+       struct btc_coexist *pBtCoexist;
        struct adapter *padapter;
 
 
-       pBtCoexist = (PBTC_COEXIST)pBtcContext;
+       pBtCoexist = (struct btc_coexist *)pBtcContext;
        padapter = pBtCoexist->Adapter;
 
        rtw_write32(padapter, RegAddr, Data);
@@ -758,7 +758,7 @@ static void halbtcoutsrc_Write4Byte(void *pBtcContext, u32 RegAddr, u32 Data)
 
 static void halbtcoutsrc_WriteLocalReg1Byte(void *pBtcContext, u32 RegAddr, u8 Data)
 {
-       PBTC_COEXIST            pBtCoexist = (PBTC_COEXIST)pBtcContext;
+       struct btc_coexist *pBtCoexist = (struct btc_coexist *)pBtcContext;
        struct adapter *Adapter = pBtCoexist->Adapter;
 
        if (BTC_INTF_SDIO == pBtCoexist->chipInterface)
@@ -769,11 +769,11 @@ static void halbtcoutsrc_WriteLocalReg1Byte(void *pBtcContext, u32 RegAddr, u8 D
 
 static void halbtcoutsrc_SetBbReg(void *pBtcContext, u32 RegAddr, u32 BitMask, u32 Data)
 {
-       PBTC_COEXIST pBtCoexist;
+       struct btc_coexist *pBtCoexist;
        struct adapter *padapter;
 
 
-       pBtCoexist = (PBTC_COEXIST)pBtcContext;
+       pBtCoexist = (struct btc_coexist *)pBtcContext;
        padapter = pBtCoexist->Adapter;
 
        PHY_SetBBReg(padapter, RegAddr, BitMask, Data);
@@ -782,11 +782,11 @@ static void halbtcoutsrc_SetBbReg(void *pBtcContext, u32 RegAddr, u32 BitMask, u
 
 static u32 halbtcoutsrc_GetBbReg(void *pBtcContext, u32 RegAddr, u32 BitMask)
 {
-       PBTC_COEXIST pBtCoexist;
+       struct btc_coexist *pBtCoexist;
        struct adapter *padapter;
 
 
-       pBtCoexist = (PBTC_COEXIST)pBtcContext;
+       pBtCoexist = (struct btc_coexist *)pBtcContext;
        padapter = pBtCoexist->Adapter;
 
        return PHY_QueryBBReg(padapter, RegAddr, BitMask);
@@ -794,11 +794,11 @@ static u32 halbtcoutsrc_GetBbReg(void *pBtcContext, u32 RegAddr, u32 BitMask)
 
 static void halbtcoutsrc_SetRfReg(void *pBtcContext, u8 eRFPath, u32 RegAddr, u32 BitMask, u32 Data)
 {
-       PBTC_COEXIST pBtCoexist;
+       struct btc_coexist *pBtCoexist;
        struct adapter *padapter;
 
 
-       pBtCoexist = (PBTC_COEXIST)pBtcContext;
+       pBtCoexist = (struct btc_coexist *)pBtcContext;
        padapter = pBtCoexist->Adapter;
 
        PHY_SetRFReg(padapter, eRFPath, RegAddr, BitMask, Data);
@@ -806,11 +806,11 @@ static void halbtcoutsrc_SetRfReg(void *pBtcContext, u8 eRFPath, u32 RegAddr, u3
 
 static u32 halbtcoutsrc_GetRfReg(void *pBtcContext, u8 eRFPath, u32 RegAddr, u32 BitMask)
 {
-       PBTC_COEXIST pBtCoexist;
+       struct btc_coexist *pBtCoexist;
        struct adapter *padapter;
 
 
-       pBtCoexist = (PBTC_COEXIST)pBtcContext;
+       pBtCoexist = (struct btc_coexist *)pBtcContext;
        padapter = pBtCoexist->Adapter;
 
        return PHY_QueryRFReg(padapter, eRFPath, RegAddr, BitMask);
@@ -818,7 +818,7 @@ static u32 halbtcoutsrc_GetRfReg(void *pBtcContext, u8 eRFPath, u32 RegAddr, u32
 
 static void halbtcoutsrc_SetBtReg(void *pBtcContext, u8 RegType, u32 RegAddr, u32 Data)
 {
-       PBTC_COEXIST pBtCoexist;
+       struct btc_coexist *pBtCoexist;
        struct adapter *padapter;
        u8 CmdBuffer1[4] = {0};
        u8 CmdBuffer2[4] = {0};
@@ -827,7 +827,7 @@ static void halbtcoutsrc_SetBtReg(void *pBtcContext, u8 RegType, u32 RegAddr, u3
        u8 OperVer = 0;
        u8 ReqNum = 0;
 
-       pBtCoexist = (PBTC_COEXIST)pBtcContext;
+       pBtCoexist = (struct btc_coexist *)pBtcContext;
        padapter = pBtCoexist->Adapter;
 
        CmdBuffer1[0] |= (OperVer & 0x0f);                                              /* Set OperVer */
@@ -854,11 +854,11 @@ static u32 halbtcoutsrc_GetBtReg(void *pBtcContext, u8 RegType, u32 RegAddr)
 
 static void halbtcoutsrc_FillH2cCmd(void *pBtcContext, u8 elementId, u32 cmdLen, u8 *pCmdBuffer)
 {
-       PBTC_COEXIST pBtCoexist;
+       struct btc_coexist *pBtCoexist;
        struct adapter *padapter;
 
 
-       pBtCoexist = (PBTC_COEXIST)pBtcContext;
+       pBtCoexist = (struct btc_coexist *)pBtcContext;
        padapter = pBtCoexist->Adapter;
 
        rtw_hal_fill_h2c_cmd(padapter, elementId, cmdLen, pCmdBuffer);
@@ -866,10 +866,10 @@ static void halbtcoutsrc_FillH2cCmd(void *pBtcContext, u8 elementId, u32 cmdLen,
 
 static void halbtcoutsrc_DisplayDbgMsg(void *pBtcContext, u8 dispType)
 {
-       PBTC_COEXIST pBtCoexist;
+       struct btc_coexist *pBtCoexist;
 
 
-       pBtCoexist = (PBTC_COEXIST)pBtcContext;
+       pBtCoexist = (struct btc_coexist *)pBtcContext;
        switch (dispType) {
        case BTC_DBG_DISP_COEX_STATISTICS:
                break;
@@ -888,7 +888,7 @@ static void halbtcoutsrc_DisplayDbgMsg(void *pBtcContext, u8 dispType)
 /*  */
 static u8 EXhalbtcoutsrc_BindBtCoexWithAdapter(void *padapter)
 {
-       PBTC_COEXIST            pBtCoexist = &GLBtCoexist;
+       struct btc_coexist *pBtCoexist = &GLBtCoexist;
 
        if (pBtCoexist->bBinded)
                return false;
@@ -914,7 +914,7 @@ static u8 EXhalbtcoutsrc_BindBtCoexWithAdapter(void *padapter)
 
 void hal_btcoex_Initialize(void *padapter)
 {
-       PBTC_COEXIST pBtCoexist;
+       struct btc_coexist *pBtCoexist;
 
        memset(&GLBtCoexist, 0, sizeof(GLBtCoexist));
 
@@ -960,7 +960,7 @@ void hal_btcoex_Initialize(void *padapter)
        GLBtcWiFiInIQKState = false;
 }
 
-void EXhalbtcoutsrc_PowerOnSetting(PBTC_COEXIST pBtCoexist)
+void EXhalbtcoutsrc_PowerOnSetting(struct btc_coexist *pBtCoexist)
 {
        if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
                return;
@@ -972,7 +972,7 @@ void EXhalbtcoutsrc_PowerOnSetting(PBTC_COEXIST pBtCoexist)
                EXhalbtc8723b1ant_PowerOnSetting(pBtCoexist);
 }
 
-void EXhalbtcoutsrc_InitHwConfig(PBTC_COEXIST pBtCoexist, u8 bWifiOnly)
+void EXhalbtcoutsrc_InitHwConfig(struct btc_coexist *pBtCoexist, u8 bWifiOnly)
 {
        if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
                return;
@@ -985,7 +985,7 @@ void EXhalbtcoutsrc_InitHwConfig(PBTC_COEXIST pBtCoexist, u8 bWifiOnly)
                EXhalbtc8723b1ant_InitHwConfig(pBtCoexist, bWifiOnly);
 }
 
-void EXhalbtcoutsrc_InitCoexDm(PBTC_COEXIST pBtCoexist)
+void EXhalbtcoutsrc_InitCoexDm(struct btc_coexist *pBtCoexist)
 {
        if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
                return;
@@ -1000,7 +1000,7 @@ void EXhalbtcoutsrc_InitCoexDm(PBTC_COEXIST pBtCoexist)
        pBtCoexist->bInitilized = true;
 }
 
-void EXhalbtcoutsrc_IpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
+void EXhalbtcoutsrc_IpsNotify(struct btc_coexist *pBtCoexist, u8 type)
 {
        u8 ipsType;
 
@@ -1027,7 +1027,7 @@ void EXhalbtcoutsrc_IpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
 /*     halbtcoutsrc_NormalLowPower(pBtCoexist); */
 }
 
-void EXhalbtcoutsrc_LpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
+void EXhalbtcoutsrc_LpsNotify(struct btc_coexist *pBtCoexist, u8 type)
 {
        u8 lpsType;
 
@@ -1050,7 +1050,7 @@ void EXhalbtcoutsrc_LpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
                EXhalbtc8723b1ant_LpsNotify(pBtCoexist, lpsType);
 }
 
-void EXhalbtcoutsrc_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type)
+void EXhalbtcoutsrc_ScanNotify(struct btc_coexist *pBtCoexist, u8 type)
 {
        u8 scanType;
 
@@ -1079,7 +1079,7 @@ void EXhalbtcoutsrc_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type)
 /*     halbtcoutsrc_NormalLowPower(pBtCoexist); */
 }
 
-void EXhalbtcoutsrc_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 action)
+void EXhalbtcoutsrc_ConnectNotify(struct btc_coexist *pBtCoexist, u8 action)
 {
        u8 assoType;
 
@@ -1105,7 +1105,8 @@ void EXhalbtcoutsrc_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 action)
 /*     halbtcoutsrc_NormalLowPower(pBtCoexist); */
 }
 
-void EXhalbtcoutsrc_MediaStatusNotify(PBTC_COEXIST pBtCoexist, RT_MEDIA_STATUS mediaStatus)
+void EXhalbtcoutsrc_MediaStatusNotify(struct btc_coexist *pBtCoexist, enum
+       rt_media_status mediaStatus)
 {
        u8 mStatus;
 
@@ -1132,7 +1133,7 @@ void EXhalbtcoutsrc_MediaStatusNotify(PBTC_COEXIST pBtCoexist, RT_MEDIA_STATUS m
 /*     halbtcoutsrc_NormalLowPower(pBtCoexist); */
 }
 
-void EXhalbtcoutsrc_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 pktType)
+void EXhalbtcoutsrc_SpecialPacketNotify(struct btc_coexist *pBtCoexist, u8 pktType)
 {
        u8 packetType;
 
@@ -1163,7 +1164,7 @@ void EXhalbtcoutsrc_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 pktType)
 /*     halbtcoutsrc_NormalLowPower(pBtCoexist); */
 }
 
-void EXhalbtcoutsrc_BtInfoNotify(PBTC_COEXIST pBtCoexist, u8 *tmpBuf, u8 length)
+void EXhalbtcoutsrc_BtInfoNotify(struct btc_coexist *pBtCoexist, u8 *tmpBuf, u8 length)
 {
        if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
                return;
@@ -1181,7 +1182,7 @@ void EXhalbtcoutsrc_BtInfoNotify(PBTC_COEXIST pBtCoexist, u8 *tmpBuf, u8 length)
 /*     halbtcoutsrc_NormalLowPower(pBtCoexist); */
 }
 
-void EXhalbtcoutsrc_HaltNotify(PBTC_COEXIST pBtCoexist)
+void EXhalbtcoutsrc_HaltNotify(struct btc_coexist *pBtCoexist)
 {
        if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
                return;
@@ -1194,7 +1195,7 @@ void EXhalbtcoutsrc_HaltNotify(PBTC_COEXIST pBtCoexist)
        pBtCoexist->bBinded = false;
 }
 
-void EXhalbtcoutsrc_PnpNotify(PBTC_COEXIST pBtCoexist, u8 pnpState)
+void EXhalbtcoutsrc_PnpNotify(struct btc_coexist *pBtCoexist, u8 pnpState)
 {
        if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
                return;
@@ -1210,7 +1211,7 @@ void EXhalbtcoutsrc_PnpNotify(PBTC_COEXIST pBtCoexist, u8 pnpState)
                EXhalbtc8723b2ant_PnpNotify(pBtCoexist, pnpState);
 }
 
-void EXhalbtcoutsrc_Periodical(PBTC_COEXIST pBtCoexist)
+void EXhalbtcoutsrc_Periodical(struct btc_coexist *pBtCoexist)
 {
        if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
                return;
@@ -1255,7 +1256,7 @@ void EXhalbtcoutsrc_SetSingleAntPath(u8 singleAntPath)
        GLBtCoexist.boardInfo.singleAntPath = singleAntPath;
 }
 
-void EXhalbtcoutsrc_DisplayBtCoexInfo(PBTC_COEXIST pBtCoexist)
+void EXhalbtcoutsrc_DisplayBtCoexInfo(struct btc_coexist *pBtCoexist)
 {
        if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
                return;
@@ -1489,7 +1490,7 @@ void hal_btcoex_RecordPwrMode(struct adapter *padapter, u8 *pCmdBuf, u8 cmdLen)
 
 void hal_btcoex_DisplayBtCoexInfo(struct adapter *padapter, u8 *pbuf, u32 bufsize)
 {
-       PBTCDBGINFO pinfo;
+       struct btcdbginfo *pinfo;
 
 
        pinfo = &GLBtcDbgInfo;
index 173ccaba2537220d0e7c4adde379ff4973216ddc..98a3636988436e74742ef11da55b805b7a81314e 100644 (file)
@@ -38,7 +38,7 @@ void rtw_hal_data_deinit(struct adapter *padapter)
 }
 
 
-void dump_chip_info(HAL_VERSION        ChipVersion)
+void dump_chip_info(struct hal_version ChipVersion)
 {
        char buf[128];
        size_t cnt = 0;
@@ -132,10 +132,8 @@ u8 hal_com_config_channel_plan(
 
                hw_chnlPlan = hw_channel_plan & (~EEPROM_CHANNEL_PLAN_BY_HW_MASK);
                if (rtw_is_channel_plan_valid(hw_chnlPlan)) {
-#ifndef CONFIG_SW_CHANNEL_PLAN
                        if (hw_channel_plan & EEPROM_CHANNEL_PLAN_BY_HW_MASK)
                                pHalData->bDisableSWChannelPlan = true;
-#endif /*  !CONFIG_SW_CHANNEL_PLAN */
 
                        chnlPlan = hw_chnlPlan;
                }
@@ -1008,7 +1006,7 @@ void hw_var_port_switch(struct adapter *adapter)
 void SetHwReg(struct adapter *adapter, u8 variable, u8 *val)
 {
        struct hal_com_data *hal_data = GET_HAL_DATA(adapter);
-       DM_ODM_T *odm = &(hal_data->odmpriv);
+       struct dm_odm_t *odm = &(hal_data->odmpriv);
 
        switch (variable) {
        case HW_VAR_PORT_SWITCH:
@@ -1088,7 +1086,7 @@ void SetHwReg(struct adapter *adapter, u8 variable, u8 *val)
 void GetHwReg(struct adapter *adapter, u8 variable, u8 *val)
 {
        struct hal_com_data *hal_data = GET_HAL_DATA(adapter);
-       DM_ODM_T *odm = &(hal_data->odmpriv);
+       struct dm_odm_t *odm = &(hal_data->odmpriv);
 
        switch (variable) {
        case HW_VAR_BASIC_RATE:
@@ -1115,11 +1113,11 @@ void GetHwReg(struct adapter *adapter, u8 variable, u8 *val)
 
 
 u8 SetHalDefVar(
-       struct adapter *adapter, enum HAL_DEF_VARIABLE variable, void *value
+       struct adapter *adapter, enum hal_def_variable variable, void *value
 )
 {
        struct hal_com_data *hal_data = GET_HAL_DATA(adapter);
-       DM_ODM_T *odm = &(hal_data->odmpriv);
+       struct dm_odm_t *odm = &(hal_data->odmpriv);
        u8 bResult = _SUCCESS;
 
        switch (variable) {
@@ -1172,7 +1170,7 @@ u8 SetHalDefVar(
                        odm->SupportAbility  &= (~DYNAMIC_BB_ANT_DIV);
                } else if (dm_func == 6) {/* turn on all dynamic func */
                        if (!(odm->SupportAbility  & DYNAMIC_BB_DIG)) {
-                               DIG_T   *pDigTable = &odm->DM_DigTable;
+                               struct dig_t    *pDigTable = &odm->DM_DigTable;
                                pDigTable->CurIGValue = rtw_read8(adapter, 0xc50);
                        }
                        dm->DMFlag |= DYNAMIC_FUNC_BT;
@@ -1200,11 +1198,11 @@ u8 SetHalDefVar(
 }
 
 u8 GetHalDefVar(
-       struct adapter *adapter, enum HAL_DEF_VARIABLE variable, void *value
+       struct adapter *adapter, enum hal_def_variable variable, void *value
 )
 {
        struct hal_com_data *hal_data = GET_HAL_DATA(adapter);
-       DM_ODM_T *odm = &(hal_data->odmpriv);
+       struct dm_odm_t *odm = &(hal_data->odmpriv);
        u8 bResult = _SUCCESS;
 
        switch (variable) {
@@ -1256,26 +1254,12 @@ u8 GetHalDefVar(
 
 void GetHalODMVar(
        struct adapter *Adapter,
-       enum HAL_ODM_VARIABLE eVariable,
+       enum hal_odm_variable eVariable,
        void *pValue1,
        void *pValue2
 )
 {
        switch (eVariable) {
-#if defined(CONFIG_SIGNAL_DISPLAY_DBM) && defined(CONFIG_BACKGROUND_NOISE_MONITOR)
-       case HAL_ODM_NOISE_MONITOR:
-               {
-                       struct hal_com_data     *pHalData = GET_HAL_DATA(Adapter);
-                       u8 chan = *(u8 *)pValue1;
-                       *(s16 *)pValue2 = pHalData->noise[chan];
-                       #ifdef DBG_NOISE_MONITOR
-                       DBG_8192C("### Noise monitor chan(%d)-noise:%d (dBm) ###\n",
-                               chan, pHalData->noise[chan]);
-                       #endif
-
-               }
-               break;
-#endif/* ifdef CONFIG_BACKGROUND_NOISE_MONITOR */
        default:
                break;
        }
@@ -1283,13 +1267,13 @@ void GetHalODMVar(
 
 void SetHalODMVar(
        struct adapter *Adapter,
-       enum HAL_ODM_VARIABLE eVariable,
+       enum hal_odm_variable eVariable,
        void *pValue1,
        bool bSet
 )
 {
        struct hal_com_data     *pHalData = GET_HAL_DATA(Adapter);
-       PDM_ODM_T podmpriv = &pHalData->odmpriv;
+       struct dm_odm_t *podmpriv = &pHalData->odmpriv;
        /* _irqL irqL; */
        switch (eVariable) {
        case HAL_ODM_STA_INFO:
@@ -1313,27 +1297,6 @@ void SetHalODMVar(
        case HAL_ODM_WIFI_DISPLAY_STATE:
                        ODM_CmnInfoUpdate(podmpriv, ODM_CMNINFO_WIFI_DISPLAY, bSet);
                break;
-       #if defined(CONFIG_SIGNAL_DISPLAY_DBM) && defined(CONFIG_BACKGROUND_NOISE_MONITOR)
-       case HAL_ODM_NOISE_MONITOR:
-               {
-                       struct noise_info *pinfo = pValue1;
-
-                       #ifdef DBG_NOISE_MONITOR
-                       DBG_8192C("### Noise monitor chan(%d)-bPauseDIG:%d, IGIValue:0x%02x, max_time:%d (ms) ###\n",
-                               pinfo->chan, pinfo->bPauseDIG, pinfo->IGIValue, pinfo->max_time);
-                       #endif
-
-                       pHalData->noise[pinfo->chan] = ODM_InbandNoise_Monitor(podmpriv, pinfo->bPauseDIG, pinfo->IGIValue, pinfo->max_time);
-                       DBG_871X("chan_%d, noise = %d (dBm)\n", pinfo->chan, pHalData->noise[pinfo->chan]);
-                       #ifdef DBG_NOISE_MONITOR
-                       DBG_871X("noise_a = %d, noise_b = %d  noise_all:%d\n",
-                               podmpriv->noise_level.noise[ODM_RF_PATH_A],
-                               podmpriv->noise_level.noise[ODM_RF_PATH_B],
-                               podmpriv->noise_level.noise_all);
-                       #endif
-               }
-               break;
-       #endif/* ifdef CONFIG_BACKGROUND_NOISE_MONITOR */
 
        default:
                break;
index 10250642d30ae707842a5f905d807b3729487b05..9b16265b543ddb5c03867afa8787e0a16714f544 100644 (file)
@@ -12,7 +12,7 @@
 #include <linux/kernel.h>
 
 u8 PHY_GetTxPowerByRateBase(struct adapter *Adapter, u8 Band, u8 RfPath,
-                           u8 TxNum, enum RATE_SECTION RateSection)
+                           u8 TxNum, enum rate_section RateSection)
 {
        struct hal_com_data     *pHalData = GET_HAL_DATA(Adapter);
        u8      value = 0;
@@ -104,7 +104,7 @@ phy_SetTxPowerByRateBase(
        struct adapter *Adapter,
        u8 Band,
        u8 RfPath,
-       enum RATE_SECTION       RateSection,
+       enum rate_section       RateSection,
        u8 TxNum,
        u8 Value
 )
@@ -198,8 +198,6 @@ struct adapter *padapter
 {
        u8 path, base;
 
-       /* DBG_871X("===>%s\n", __func__); */
-
        for (path = ODM_RF_PATH_A; path <= ODM_RF_PATH_B; ++path) {
                base = PHY_GetTxPowerByRate(padapter, BAND_ON_2_4G, path, RF_1TX, MGN_11M);
                phy_SetTxPowerByRateBase(padapter, BAND_ON_2_4G, path, CCK, RF_1TX, base);
@@ -261,8 +259,6 @@ struct adapter *padapter
                phy_SetTxPowerByRateBase(padapter, BAND_ON_5G, path, VHT_3SSMCS0_3SSMCS9, RF_3TX, base);
                /* DBG_871X("Power index base of 5G path %d 3Tx VHT3SS = > 0x%x\n", path, base); */
        }
-
-       /* DBG_871X("<===%s\n", __func__); */
 }
 
 u8 PHY_GetRateSectionIndexOfTxPowerByRate(
@@ -270,7 +266,7 @@ u8 PHY_GetRateSectionIndexOfTxPowerByRate(
 )
 {
        struct hal_com_data     *pHalData = GET_HAL_DATA(padapter);
-       PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+       struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
        u8      index = 0;
 
        if (pDM_Odm->PhyRegPgVersion == 0) {
@@ -795,7 +791,7 @@ void PHY_StoreTxPowerByRate(
 )
 {
        struct hal_com_data     *pHalData = GET_HAL_DATA(padapter);
-       PDM_ODM_T               pDM_Odm = &pHalData->odmpriv;
+       struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
 
        if (pDM_Odm->PhyRegPgVersion > 0)
                PHY_StoreTxPowerByRateNew(padapter, Band, RfPath, TxNum, RegAddr, BitMask, Data);
@@ -1039,7 +1035,7 @@ u8 PHY_GetTxPowerIndexBase(
        struct adapter *padapter,
        u8 RFPath,
        u8 Rate,
-       enum CHANNEL_WIDTH      BandWidth,
+       enum channel_width      BandWidth,
        u8 Channel,
        bool *bIn24G
 )
@@ -1188,7 +1184,7 @@ u8 PHY_GetTxPowerIndexBase(
 s8 PHY_GetTxPowerTrackingOffset(struct adapter *padapter, u8 RFPath, u8 Rate)
 {
        struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
-       PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+       struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
        s8 offset = 0;
 
        if (pDM_Odm->RFCalibrateInfo.TxPowerTrackControl  == false)
@@ -1556,7 +1552,7 @@ void PHY_SetTxPowerLevelByPath(struct adapter *Adapter, u8 channel, u8 path)
 void PHY_SetTxPowerIndexByRateArray(
        struct adapter *padapter,
        u8 RFPath,
-       enum CHANNEL_WIDTH BandWidth,
+       enum channel_width BandWidth,
        u8 Channel,
        u8 *Rates,
        u8 RateArraySize
@@ -1610,7 +1606,7 @@ static s8 phy_GetChannelIndexOfTxPowerLimit(u8 Band, u8 Channel)
        return channelIndex;
 }
 
-static s16 get_bandwidth_idx(const enum CHANNEL_WIDTH bandwidth)
+static s16 get_bandwidth_idx(const enum channel_width bandwidth)
 {
        switch (bandwidth) {
        case CHANNEL_WIDTH_20:
@@ -1673,7 +1669,7 @@ static s16 get_rate_sctn_idx(const u8 rate)
 }
 
 s8 phy_get_tx_pwr_lmt(struct adapter *adapter, u32 reg_pwr_tbl_sel,
-                     enum BAND_TYPE band_type, enum CHANNEL_WIDTH bandwidth,
+                     enum band_type band_type, enum channel_width bandwidth,
                      u8 rf_path, u8 data_rate, u8 channel)
 {
        s16 idx_band       = -1;
index ac3066a91c84edacf926c99e4aef1dac0a73055a..aa43563276367bcbe9902eaa57726f35c6589187 100644 (file)
@@ -63,9 +63,9 @@ void rtw_hal_dm_deinit(struct adapter *padapter)
 
 static void rtw_hal_init_opmode(struct adapter *padapter)
 {
-       enum NDIS_802_11_NETWORK_INFRASTRUCTURE networkType = Ndis802_11InfrastructureMax;
+       enum ndis_802_11_network_infrastructure networkType = Ndis802_11InfrastructureMax;
        struct  mlme_priv *pmlmepriv = &(padapter->mlmepriv);
-       sint fw_state;
+       signed int fw_state;
 
        fw_state = get_fwstate(pmlmepriv);
 
@@ -111,12 +111,11 @@ uint rtw_hal_init(struct adapter *padapter)
        RT_TRACE(_module_hal_init_c_, _drv_err_, ("-rtl871x_hal_init:status = 0x%x\n", status));
 
        return status;
-
 }
 
 uint rtw_hal_deinit(struct adapter *padapter)
 {
-       uint    status = _SUCCESS;
+       uint status = _SUCCESS;
        struct dvobj_priv *dvobj = adapter_to_dvobj(padapter);
 
        status = padapter->HalFunc.hal_deinit(padapter);
@@ -148,27 +147,27 @@ void rtw_hal_set_hwreg_with_buf(struct adapter *padapter, u8 variable, u8 *pbuf,
                padapter->HalFunc.SetHwRegHandlerWithBuf(padapter, variable, pbuf, len);
 }
 
-u8 rtw_hal_set_def_var(struct adapter *padapter, enum HAL_DEF_VARIABLE eVariable, void *pValue)
+u8 rtw_hal_set_def_var(struct adapter *padapter, enum hal_def_variable eVariable, void *pValue)
 {
        if (padapter->HalFunc.SetHalDefVarHandler)
                return padapter->HalFunc.SetHalDefVarHandler(padapter, eVariable, pValue);
        return _FAIL;
 }
 
-u8 rtw_hal_get_def_var(struct adapter *padapter, enum HAL_DEF_VARIABLE eVariable, void *pValue)
+u8 rtw_hal_get_def_var(struct adapter *padapter, enum hal_def_variable eVariable, void *pValue)
 {
        if (padapter->HalFunc.GetHalDefVarHandler)
                return padapter->HalFunc.GetHalDefVarHandler(padapter, eVariable, pValue);
        return _FAIL;
 }
 
-void rtw_hal_set_odm_var(struct adapter *padapter, enum HAL_ODM_VARIABLE eVariable, void *pValue1, bool bSet)
+void rtw_hal_set_odm_var(struct adapter *padapter, enum hal_odm_variable eVariable, void *pValue1, bool bSet)
 {
        if (padapter->HalFunc.SetHalODMVarHandler)
                padapter->HalFunc.SetHalODMVarHandler(padapter, eVariable, pValue1, bSet);
 }
 
-void rtw_hal_get_odm_var(struct adapter *padapter, enum HAL_ODM_VARIABLE eVariable, void *pValue1, void *pValue2)
+void rtw_hal_get_odm_var(struct adapter *padapter, enum hal_odm_variable eVariable, void *pValue1, void *pValue2)
 {
        if (padapter->HalFunc.GetHalODMVarHandler)
                padapter->HalFunc.GetHalODMVarHandler(padapter, eVariable, pValue1, pValue2);
@@ -180,7 +179,6 @@ void rtw_hal_enable_interrupt(struct adapter *padapter)
                padapter->HalFunc.enable_interrupt(padapter);
        else
                DBG_871X("%s: HalFunc.enable_interrupt is NULL!\n", __func__);
-
 }
 
 void rtw_hal_disable_interrupt(struct adapter *padapter)
@@ -189,7 +187,6 @@ void rtw_hal_disable_interrupt(struct adapter *padapter)
                padapter->HalFunc.disable_interrupt(padapter);
        else
                DBG_871X("%s: HalFunc.disable_interrupt is NULL!\n", __func__);
-
 }
 
 u8 rtw_hal_check_ips_status(struct adapter *padapter)
@@ -269,7 +266,6 @@ s32 rtw_hal_init_recv_priv(struct adapter *padapter)
 
 void rtw_hal_free_recv_priv(struct adapter *padapter)
 {
-
        if (padapter->HalFunc.free_recv_priv)
                padapter->HalFunc.free_recv_priv(padapter);
 }
@@ -346,7 +342,7 @@ void rtw_hal_set_chan(struct adapter *padapter, u8 channel)
 }
 
 void rtw_hal_set_chnl_bw(struct adapter *padapter, u8 channel,
-                        enum CHANNEL_WIDTH Bandwidth, u8 Offset40, u8 Offset80)
+                        enum channel_width Bandwidth, u8 Offset40, u8 Offset80)
 {
        if (padapter->HalFunc.set_chnl_bw_handler)
                padapter->HalFunc.set_chnl_bw_handler(padapter, channel,
@@ -358,7 +354,6 @@ void rtw_hal_dm_watchdog(struct adapter *padapter)
 {
        if (padapter->HalFunc.hal_dm_watchdog)
                padapter->HalFunc.hal_dm_watchdog(padapter);
-
 }
 
 void rtw_hal_dm_watchdog_in_lps(struct adapter *padapter)
@@ -422,7 +417,6 @@ s32 rtw_hal_macid_sleep(struct adapter *padapter, u32 macid)
 {
        u8 support;
 
-
        support = false;
        rtw_hal_get_def_var(padapter, HAL_DEF_MACID_SLEEP, &support);
        if (false == support)
@@ -437,7 +431,6 @@ s32 rtw_hal_macid_wakeup(struct adapter *padapter, u32 macid)
 {
        u8 support;
 
-
        support = false;
        rtw_hal_get_def_var(padapter, HAL_DEF_MACID_SLEEP, &support);
        if (false == support)
index 589e7aae7bbd817dd1489213d2dbad199f58dc71..fba67a7c069ce69e95fd570c3e3d43a04c197e7a 100644 (file)
@@ -21,7 +21,7 @@ Major Change History:
 
 /* drivers should parse below arrays and do the corresponding actions */
 /* 3 Power on  Array */
-WLAN_PWR_CFG rtl8723B_power_on_flow[
+struct wlan_pwr_cfg rtl8723B_power_on_flow[
        RTL8723B_TRANS_CARDEMU_TO_ACT_STEPS+
        RTL8723B_TRANS_END_STEPS
 ] = {
@@ -30,7 +30,7 @@ WLAN_PWR_CFG rtl8723B_power_on_flow[
 };
 
 /* 3Radio off GPIO Array */
-WLAN_PWR_CFG rtl8723B_radio_off_flow[
+struct wlan_pwr_cfg rtl8723B_radio_off_flow[
        RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+
        RTL8723B_TRANS_END_STEPS
 ] = {
@@ -39,7 +39,7 @@ WLAN_PWR_CFG rtl8723B_radio_off_flow[
 };
 
 /* 3Card Disable Array */
-WLAN_PWR_CFG rtl8723B_card_disable_flow[
+struct wlan_pwr_cfg rtl8723B_card_disable_flow[
        RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+
        RTL8723B_TRANS_CARDEMU_TO_PDN_STEPS+
        RTL8723B_TRANS_END_STEPS
@@ -50,7 +50,7 @@ WLAN_PWR_CFG rtl8723B_card_disable_flow[
 };
 
 /* 3 Card Enable Array */
-WLAN_PWR_CFG rtl8723B_card_enable_flow[
+struct wlan_pwr_cfg rtl8723B_card_enable_flow[
        RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+
        RTL8723B_TRANS_CARDEMU_TO_PDN_STEPS+
        RTL8723B_TRANS_END_STEPS
@@ -61,7 +61,7 @@ WLAN_PWR_CFG rtl8723B_card_enable_flow[
 };
 
 /* 3Suspend Array */
-WLAN_PWR_CFG rtl8723B_suspend_flow[
+struct wlan_pwr_cfg rtl8723B_suspend_flow[
        RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+
        RTL8723B_TRANS_CARDEMU_TO_SUS_STEPS+
        RTL8723B_TRANS_END_STEPS
@@ -72,7 +72,7 @@ WLAN_PWR_CFG rtl8723B_suspend_flow[
 };
 
 /* 3 Resume Array */
-WLAN_PWR_CFG rtl8723B_resume_flow[
+struct wlan_pwr_cfg rtl8723B_resume_flow[
        RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+
        RTL8723B_TRANS_CARDEMU_TO_SUS_STEPS+
        RTL8723B_TRANS_END_STEPS
@@ -83,7 +83,7 @@ WLAN_PWR_CFG rtl8723B_resume_flow[
 };
 
 /* 3HWPDN Array */
-WLAN_PWR_CFG rtl8723B_hwpdn_flow[
+struct wlan_pwr_cfg rtl8723B_hwpdn_flow[
        RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+
        RTL8723B_TRANS_CARDEMU_TO_PDN_STEPS+
        RTL8723B_TRANS_END_STEPS
@@ -94,7 +94,7 @@ WLAN_PWR_CFG rtl8723B_hwpdn_flow[
 };
 
 /* 3 Enter LPS */
-WLAN_PWR_CFG rtl8723B_enter_lps_flow[
+struct wlan_pwr_cfg rtl8723B_enter_lps_flow[
        RTL8723B_TRANS_ACT_TO_LPS_STEPS+RTL8723B_TRANS_END_STEPS
 ] = {
        /* FW behavior */
@@ -103,7 +103,7 @@ WLAN_PWR_CFG rtl8723B_enter_lps_flow[
 };
 
 /* 3 Leave LPS */
-WLAN_PWR_CFG rtl8723B_leave_lps_flow[
+struct wlan_pwr_cfg rtl8723B_leave_lps_flow[
        RTL8723B_TRANS_LPS_TO_ACT_STEPS+RTL8723B_TRANS_END_STEPS
 ] = {
        /* FW behavior */
@@ -112,7 +112,7 @@ WLAN_PWR_CFG rtl8723B_leave_lps_flow[
 };
 
 /* 3 Enter SW LPS */
-WLAN_PWR_CFG rtl8723B_enter_swlps_flow[
+struct wlan_pwr_cfg rtl8723B_enter_swlps_flow[
        RTL8723B_TRANS_ACT_TO_SWLPS_STEPS+RTL8723B_TRANS_END_STEPS
 ] = {
        /* SW behavior */
@@ -121,7 +121,7 @@ WLAN_PWR_CFG rtl8723B_enter_swlps_flow[
 };
 
 /* 3 Leave SW LPS */
-WLAN_PWR_CFG rtl8723B_leave_swlps_flow[
+struct wlan_pwr_cfg rtl8723B_leave_swlps_flow[
        RTL8723B_TRANS_SWLPS_TO_ACT_STEPS+RTL8723B_TRANS_END_STEPS
 ] = {
        /* SW behavior */
index 5e432f1bc150ce4297675857cd95f39621093cb5..3d92eee3a840d57b8dc3716bf023f1686315d245 100644 (file)
@@ -279,1128 +279,1057 @@ u32 TxScalingTable_Jaguar[TXSCALE_TABLE_SIZE] = {
        0x3FE  /*  36, +6.0dB */
 };
 
-/*  Local Function predefine. */
-
-/* START------------COMMON INFO RELATED--------------- */
-void odm_CommonInfoSelfInit(PDM_ODM_T pDM_Odm);
-
-void odm_CommonInfoSelfUpdate(PDM_ODM_T pDM_Odm);
-
-void odm_CmnInfoInit_Debug(PDM_ODM_T pDM_Odm);
-
-void odm_BasicDbgMessage(PDM_ODM_T pDM_Odm);
-
-/* END------------COMMON INFO RELATED--------------- */
+/* Remove Edca by Yu Chen */
 
-/* START---------------DIG--------------------------- */
 
-/* Remove by Yuchen */
+#define RxDefaultAnt1          0x65a9
+#define RxDefaultAnt2          0x569a
 
-/* END---------------DIG--------------------------- */
+static void odm_CommonInfoSelfInit(struct dm_odm_t *pDM_Odm)
+{
+       pDM_Odm->bCckHighPower = (bool) PHY_QueryBBReg(pDM_Odm->Adapter, ODM_REG(CCK_RPT_FORMAT, pDM_Odm), ODM_BIT(CCK_RPT_FORMAT, pDM_Odm));
+       pDM_Odm->RFPathRxEnable = (u8) PHY_QueryBBReg(pDM_Odm->Adapter, ODM_REG(BB_RX_PATH, pDM_Odm), ODM_BIT(BB_RX_PATH, pDM_Odm));
 
-/* START-------BB POWER SAVE----------------------- */
-/* Remove BB power Saving by YuChen */
-/* END---------BB POWER SAVE----------------------- */
+       ODM_InitDebugSetting(pDM_Odm);
 
-void odm_RefreshRateAdaptiveMaskCE(PDM_ODM_T pDM_Odm);
+       pDM_Odm->TxRate = 0xFF;
+}
 
-/* Remove by YuChen */
+static void odm_CommonInfoSelfUpdate(struct dm_odm_t *pDM_Odm)
+{
+       u8 EntryCnt = 0;
+       u8 i;
+       PSTA_INFO_T     pEntry;
 
-void odm_RSSIMonitorInit(PDM_ODM_T pDM_Odm);
+       if (*(pDM_Odm->pBandWidth) == ODM_BW40M) {
+               if (*(pDM_Odm->pSecChOffset) == 1)
+                       pDM_Odm->ControlChannel = *(pDM_Odm->pChannel)-2;
+               else if (*(pDM_Odm->pSecChOffset) == 2)
+                       pDM_Odm->ControlChannel = *(pDM_Odm->pChannel)+2;
+       } else
+               pDM_Odm->ControlChannel = *(pDM_Odm->pChannel);
 
-void odm_RSSIMonitorCheckCE(PDM_ODM_T pDM_Odm);
+       for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
+               pEntry = pDM_Odm->pODM_StaInfo[i];
+               if (IS_STA_VALID(pEntry))
+                       EntryCnt++;
+       }
 
-void odm_RSSIMonitorCheck(PDM_ODM_T pDM_Odm);
+       if (EntryCnt == 1)
+               pDM_Odm->bOneEntryOnly = true;
+       else
+               pDM_Odm->bOneEntryOnly = false;
+}
 
-void odm_SwAntDetectInit(PDM_ODM_T pDM_Odm);
+static void odm_CmnInfoInit_Debug(struct dm_odm_t *pDM_Odm)
+{
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_CmnInfoInit_Debug ==>\n"));
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportPlatform =%d\n", pDM_Odm->SupportPlatform));
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportAbility = 0x%x\n", pDM_Odm->SupportAbility));
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportInterface =%d\n", pDM_Odm->SupportInterface));
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportICType = 0x%x\n", pDM_Odm->SupportICType));
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("CutVersion =%d\n", pDM_Odm->CutVersion));
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("FabVersion =%d\n", pDM_Odm->FabVersion));
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("RFType =%d\n", pDM_Odm->RFType));
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("BoardType =%d\n", pDM_Odm->BoardType));
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtLNA =%d\n", pDM_Odm->ExtLNA));
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtPA =%d\n", pDM_Odm->ExtPA));
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtTRSW =%d\n", pDM_Odm->ExtTRSW));
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("PatchID =%d\n", pDM_Odm->PatchID));
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bInHctTest =%d\n", pDM_Odm->bInHctTest));
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bWIFITest =%d\n", pDM_Odm->bWIFITest));
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bDualMacSmartConcurrent =%d\n", pDM_Odm->bDualMacSmartConcurrent));
 
-void odm_SwAntDivChkAntSwitchCallback(void *FunctionContext);
+}
 
+static void odm_BasicDbgMessage(struct dm_odm_t *pDM_Odm)
+{
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_BasicDbgMsg ==>\n"));
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bLinked = %d, RSSI_Min = %d,\n",
+               pDM_Odm->bLinked, pDM_Odm->RSSI_Min));
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("RxRate = 0x%x, RSSI_A = %d, RSSI_B = %d\n",
+               pDM_Odm->RxRate, pDM_Odm->RSSI_A, pDM_Odm->RSSI_B));
+}
 
+/* 3 ============================================================ */
+/* 3 RATR MASK */
+/* 3 ============================================================ */
+/* 3 ============================================================ */
+/* 3 Rate Adaptive */
+/* 3 ============================================================ */
 
-void odm_GlobalAdapterCheck(void);
+static void odm_RateAdaptiveMaskInit(struct dm_odm_t *pDM_Odm)
+{
+       struct odm_rate_adaptive *pOdmRA = &pDM_Odm->RateAdaptive;
 
-void odm_RefreshRateAdaptiveMask(PDM_ODM_T pDM_Odm);
+       pOdmRA->Type = DM_Type_ByDriver;
+       if (pOdmRA->Type == DM_Type_ByDriver)
+               pDM_Odm->bUseRAMask = true;
+       else
+               pDM_Odm->bUseRAMask = false;
 
-void ODM_TXPowerTrackingCheck(PDM_ODM_T pDM_Odm);
+       pOdmRA->RATRState = DM_RATR_STA_INIT;
+       pOdmRA->LdpcThres = 35;
+       pOdmRA->bUseLdpc = false;
+       pOdmRA->HighRSSIThresh = 50;
+       pOdmRA->LowRSSIThresh = 20;
+}
 
-void odm_RateAdaptiveMaskInit(PDM_ODM_T pDM_Odm);
+u32 ODM_Get_Rate_Bitmap(
+       struct dm_odm_t *pDM_Odm,
+       u32 macid,
+       u32 ra_mask,
+       u8 rssi_level
+)
+{
+       PSTA_INFO_T     pEntry;
+       u32 rate_bitmap = 0;
+       u8 WirelessMode;
 
+       pEntry = pDM_Odm->pODM_StaInfo[macid];
+       if (!IS_STA_VALID(pEntry))
+               return ra_mask;
 
-void odm_TXPowerTrackingInit(PDM_ODM_T pDM_Odm);
+       WirelessMode = pEntry->wireless_mode;
 
-/* Remove Edca by Yu Chen */
+       switch (WirelessMode) {
+       case ODM_WM_B:
+               if (ra_mask & 0x0000000c)               /* 11M or 5.5M enable */
+                       rate_bitmap = 0x0000000d;
+               else
+                       rate_bitmap = 0x0000000f;
+               break;
 
+       case (ODM_WM_G):
+       case (ODM_WM_A):
+               if (rssi_level == DM_RATR_STA_HIGH)
+                       rate_bitmap = 0x00000f00;
+               else
+                       rate_bitmap = 0x00000ff0;
+               break;
 
-#define RxDefaultAnt1          0x65a9
-#define RxDefaultAnt2          0x569a
+       case (ODM_WM_B|ODM_WM_G):
+               if (rssi_level == DM_RATR_STA_HIGH)
+                       rate_bitmap = 0x00000f00;
+               else if (rssi_level == DM_RATR_STA_MIDDLE)
+                       rate_bitmap = 0x00000ff0;
+               else
+                       rate_bitmap = 0x00000ff5;
+               break;
 
-void odm_InitHybridAntDiv(PDM_ODM_T pDM_Odm);
+       case (ODM_WM_B|ODM_WM_G|ODM_WM_N24G):
+       case (ODM_WM_B|ODM_WM_N24G):
+       case (ODM_WM_G|ODM_WM_N24G):
+       case (ODM_WM_A|ODM_WM_N5G):
+               if (pDM_Odm->RFType == ODM_1T2R || pDM_Odm->RFType == ODM_1T1R) {
+                       if (rssi_level == DM_RATR_STA_HIGH)
+                               rate_bitmap = 0x000f0000;
+                       else if (rssi_level == DM_RATR_STA_MIDDLE)
+                               rate_bitmap = 0x000ff000;
+                       else {
+                               if (*(pDM_Odm->pBandWidth) == ODM_BW40M)
+                                       rate_bitmap = 0x000ff015;
+                               else
+                                       rate_bitmap = 0x000ff005;
+                       }
+               } else {
+                       if (rssi_level == DM_RATR_STA_HIGH)
+                               rate_bitmap = 0x0f8f0000;
+                       else if (rssi_level == DM_RATR_STA_MIDDLE)
+                               rate_bitmap = 0x0f8ff000;
+                       else {
+                               if (*(pDM_Odm->pBandWidth) == ODM_BW40M)
+                                       rate_bitmap = 0x0f8ff015;
+                               else
+                                       rate_bitmap = 0x0f8ff005;
+                       }
+               }
+               break;
 
-bool odm_StaDefAntSel(
-       PDM_ODM_T pDM_Odm,
-       u32 OFDM_Ant1_Cnt,
-       u32 OFDM_Ant2_Cnt,
-       u32 CCK_Ant1_Cnt,
-       u32 CCK_Ant2_Cnt,
-       u8 *pDefAnt
-);
+       case (ODM_WM_AC|ODM_WM_G):
+               if (rssi_level == 1)
+                       rate_bitmap = 0xfc3f0000;
+               else if (rssi_level == 2)
+                       rate_bitmap = 0xfffff000;
+               else
+                       rate_bitmap = 0xffffffff;
+               break;
 
-void odm_SetRxIdleAnt(PDM_ODM_T pDM_Odm, u8 Ant, bool bDualPath);
+       case (ODM_WM_AC|ODM_WM_A):
 
+               if (pDM_Odm->RFType == RF_1T1R) {
+                       if (rssi_level == 1)                            /*  add by Gary for ac-series */
+                               rate_bitmap = 0x003f8000;
+                       else if (rssi_level == 2)
+                               rate_bitmap = 0x003ff000;
+                       else
+                               rate_bitmap = 0x003ff010;
+               } else {
+                       if (rssi_level == 1)                            /*  add by Gary for ac-series */
+                               rate_bitmap = 0xfe3f8000;       /*  VHT 2SS MCS3~9 */
+                       else if (rssi_level == 2)
+                               rate_bitmap = 0xfffff000;       /*  VHT 2SS MCS0~9 */
+                       else
+                               rate_bitmap = 0xfffff010;       /*  All */
+               }
+               break;
 
+       default:
+               if (pDM_Odm->RFType == RF_1T2R)
+                       rate_bitmap = 0x000fffff;
+               else
+                       rate_bitmap = 0x0fffffff;
+               break;
+       }
 
-void odm_HwAntDiv(PDM_ODM_T pDM_Odm);
+       /* printk("%s ==> rssi_level:0x%02x, WirelessMode:0x%02x, rate_bitmap:0x%08x\n", __func__, rssi_level, WirelessMode, rate_bitmap); */
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, (" ==> rssi_level:0x%02x, WirelessMode:0x%02x, rate_bitmap:0x%08x\n", rssi_level, WirelessMode, rate_bitmap));
 
+       return ra_mask & rate_bitmap;
 
-/*  */
-/* 3 Export Interface */
-/*  */
+}
 
-/*  */
-/*  2011/09/21 MH Add to describe different team necessary resource allocate?? */
-/*  */
-void ODM_DMInit(PDM_ODM_T pDM_Odm)
+static void odm_RefreshRateAdaptiveMaskCE(struct dm_odm_t *pDM_Odm)
 {
+       u8 i;
+       struct adapter *padapter =  pDM_Odm->Adapter;
 
-       odm_CommonInfoSelfInit(pDM_Odm);
-       odm_CmnInfoInit_Debug(pDM_Odm);
-       odm_DIGInit(pDM_Odm);
-       odm_NHMCounterStatisticsInit(pDM_Odm);
-       odm_AdaptivityInit(pDM_Odm);
-       odm_RateAdaptiveMaskInit(pDM_Odm);
-       ODM_CfoTrackingInit(pDM_Odm);
-       ODM_EdcaTurboInit(pDM_Odm);
-       odm_RSSIMonitorInit(pDM_Odm);
-       odm_TXPowerTrackingInit(pDM_Odm);
+       if (padapter->bDriverStopped) {
+               ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("<---- odm_RefreshRateAdaptiveMask(): driver is going to unload\n"));
+               return;
+       }
 
-       ODM_ClearTxPowerTrackingState(pDM_Odm);
+       if (!pDM_Odm->bUseRAMask) {
+               ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("<---- odm_RefreshRateAdaptiveMask(): driver does not control rate adaptive mask\n"));
+               return;
+       }
 
-       if (*(pDM_Odm->mp_mode) != 1)
-               odm_PathDiversityInit(pDM_Odm);
+       for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
+               PSTA_INFO_T pstat = pDM_Odm->pODM_StaInfo[i];
 
-       odm_DynamicBBPowerSavingInit(pDM_Odm);
-       odm_DynamicTxPowerInit(pDM_Odm);
+               if (IS_STA_VALID(pstat)) {
+                       if (IS_MCAST(pstat->hwaddr))  /* if (psta->mac_id == 1) */
+                               continue;
 
-       odm_SwAntDetectInit(pDM_Odm);
+                       if (true == ODM_RAStateCheck(pDM_Odm, pstat->rssi_stat.UndecoratedSmoothedPWDB, false, &pstat->rssi_level)) {
+                               ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("RSSI:%d, RSSI_LEVEL:%d\n", pstat->rssi_stat.UndecoratedSmoothedPWDB, pstat->rssi_level));
+                               /* printk("RSSI:%d, RSSI_LEVEL:%d\n", pstat->rssi_stat.UndecoratedSmoothedPWDB, pstat->rssi_level); */
+                               rtw_hal_update_ra_mask(pstat, pstat->rssi_level);
+                       }
+
+               }
+       }
 }
 
-/*  */
-/*  2011/09/20 MH This is the entry pointer for all team to execute HW out source DM. */
-/*  You can not add any dummy function here, be care, you can only use DM structure */
-/*  to perform any new ODM_DM. */
-/*  */
-void ODM_DMWatchdog(PDM_ODM_T pDM_Odm)
+/*-----------------------------------------------------------------------------
+* Function:    odm_RefreshRateAdaptiveMask()
+*
+* Overview:    Update rate table mask according to rssi
+*
+* Input:               NONE
+*
+* Output:              NONE
+*
+* Return:              NONE
+*
+* Revised History:
+*When          Who             Remark
+*05/27/2009    hpfan   Create Version 0.
+*
+* --------------------------------------------------------------------------
+*/
+static void odm_RefreshRateAdaptiveMask(struct dm_odm_t *pDM_Odm)
 {
-       odm_CommonInfoSelfUpdate(pDM_Odm);
-       odm_BasicDbgMessage(pDM_Odm);
-       odm_FalseAlarmCounterStatistics(pDM_Odm);
-       odm_NHMCounterStatistics(pDM_Odm);
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): RSSI = 0x%x\n", pDM_Odm->RSSI_Min));
 
-       odm_RSSIMonitorCheck(pDM_Odm);
-
-       /* For CE Platform(SPRD or Tablet) */
-       /* 8723A or 8189ES platform */
-       /* NeilChen--2012--08--24-- */
-       /* Fix Leave LPS issue */
-       if ((adapter_to_pwrctl(pDM_Odm->Adapter)->pwr_mode != PS_MODE_ACTIVE) /*  in LPS mode */
-               /*  */
-               /* (pDM_Odm->SupportICType & (ODM_RTL8723A))|| */
-               /* (pDM_Odm->SupportICType & (ODM_RTL8188E) &&(&&(((pDM_Odm->SupportInterface  == ODM_ITRF_SDIO))) */
-               /*  */
-       ) {
-                       ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("----Step1: odm_DIG is in LPS mode\n"));
-                       ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("---Step2: 8723AS is in LPS mode\n"));
-                       odm_DIGbyRSSI_LPS(pDM_Odm);
-       } else
-               odm_DIG(pDM_Odm);
-
-       {
-               pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable;
-
-               odm_Adaptivity(pDM_Odm, pDM_DigTable->CurIGValue);
-       }
-       odm_CCKPacketDetectionThresh(pDM_Odm);
-
-       if (*(pDM_Odm->pbPowerSaving) == true)
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("odm_RefreshRateAdaptiveMask()---------->\n"));
+       if (!(pDM_Odm->SupportAbility & ODM_BB_RA_MASK)) {
+               ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("odm_RefreshRateAdaptiveMask(): Return cos not supported\n"));
                return;
-
-
-       odm_RefreshRateAdaptiveMask(pDM_Odm);
-       odm_EdcaTurboCheck(pDM_Odm);
-       odm_PathDiversity(pDM_Odm);
-       ODM_CfoTracking(pDM_Odm);
-
-       ODM_TXPowerTrackingCheck(pDM_Odm);
-
-       /* odm_EdcaTurboCheck(pDM_Odm); */
-
-       /* 2010.05.30 LukeLee: For CE platform, files in IC subfolders may not be included to be compiled, */
-       /*  so compile flags must be left here to prevent from compile errors */
-       pDM_Odm->PhyDbgInfo.NumQryBeaconPkt = 0;
+       }
+       odm_RefreshRateAdaptiveMaskCE(pDM_Odm);
 }
 
-
-/*  */
-/*  Init /.. Fixed HW value. Only init time. */
-/*  */
-void ODM_CmnInfoInit(PDM_ODM_T pDM_Odm, ODM_CMNINFO_E CmnInfo, u32 Value)
+/*  Return Value: bool */
+/*  - true: RATRState is changed. */
+bool ODM_RAStateCheck(
+       struct dm_odm_t *pDM_Odm,
+       s32 RSSI,
+       bool bForceUpdate,
+       u8 *pRATRState
+)
 {
-       /*  */
-       /*  This section is used for init value */
-       /*  */
-       switch (CmnInfo) {
-       /*  */
-       /*  Fixed ODM value. */
-       /*  */
-       case ODM_CMNINFO_ABILITY:
-               pDM_Odm->SupportAbility = (u32)Value;
-               break;
+       struct odm_rate_adaptive *pRA = &pDM_Odm->RateAdaptive;
+       const u8 GoUpGap = 5;
+       u8 HighRSSIThreshForRA = pRA->HighRSSIThresh;
+       u8 LowRSSIThreshForRA = pRA->LowRSSIThresh;
+       u8 RATRState;
 
-       case ODM_CMNINFO_RF_TYPE:
-               pDM_Odm->RFType = (u8)Value;
+       /*  Threshold Adjustment: */
+       /*  when RSSI state trends to go up one or two levels, make sure RSSI is high enough. */
+       /*  Here GoUpGap is added to solve the boundary's level alternation issue. */
+       switch (*pRATRState) {
+       case DM_RATR_STA_INIT:
+       case DM_RATR_STA_HIGH:
                break;
 
-       case ODM_CMNINFO_PLATFORM:
-               pDM_Odm->SupportPlatform = (u8)Value;
+       case DM_RATR_STA_MIDDLE:
+               HighRSSIThreshForRA += GoUpGap;
                break;
 
-       case ODM_CMNINFO_INTERFACE:
-               pDM_Odm->SupportInterface = (u8)Value;
+       case DM_RATR_STA_LOW:
+               HighRSSIThreshForRA += GoUpGap;
+               LowRSSIThreshForRA += GoUpGap;
                break;
 
-       case ODM_CMNINFO_MP_TEST_CHIP:
-               pDM_Odm->bIsMPChip = (u8)Value;
+       default:
+               ODM_RT_ASSERT(pDM_Odm, false, ("wrong rssi level setting %d !", *pRATRState));
                break;
+       }
 
-       case ODM_CMNINFO_IC_TYPE:
-               pDM_Odm->SupportICType = Value;
-               break;
+       /*  Decide RATRState by RSSI. */
+       if (RSSI > HighRSSIThreshForRA)
+               RATRState = DM_RATR_STA_HIGH;
+       else if (RSSI > LowRSSIThreshForRA)
+               RATRState = DM_RATR_STA_MIDDLE;
+       else
+               RATRState = DM_RATR_STA_LOW;
+       /* printk("==>%s, RATRState:0x%02x , RSSI:%d\n", __func__, RATRState, RSSI); */
 
-       case ODM_CMNINFO_CUT_VER:
-               pDM_Odm->CutVersion = (u8)Value;
-               break;
+       if (*pRATRState != RATRState || bForceUpdate) {
+               ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("RSSI Level %d -> %d\n", *pRATRState, RATRState));
+               *pRATRState = RATRState;
+               return true;
+       }
 
-       case ODM_CMNINFO_FAB_VER:
-               pDM_Odm->FabVersion = (u8)Value;
-               break;
+       return false;
+}
 
-       case ODM_CMNINFO_RFE_TYPE:
-               pDM_Odm->RFEType = (u8)Value;
-               break;
+/*  */
 
-       case    ODM_CMNINFO_RF_ANTENNA_TYPE:
-               pDM_Odm->AntDivType = (u8)Value;
-               break;
+/* 3 ============================================================ */
+/* 3 RSSI Monitor */
+/* 3 ============================================================ */
 
-       case ODM_CMNINFO_BOARD_TYPE:
-               pDM_Odm->BoardType = (u8)Value;
-               break;
+static void odm_RSSIMonitorInit(struct dm_odm_t *pDM_Odm)
+{
+       struct ra_t *pRA_Table = &pDM_Odm->DM_RA_Table;
 
-       case ODM_CMNINFO_PACKAGE_TYPE:
-               pDM_Odm->PackageType = (u8)Value;
-               break;
+       pRA_Table->firstconnect = false;
 
-       case ODM_CMNINFO_EXT_LNA:
-               pDM_Odm->ExtLNA = (u8)Value;
-               break;
+}
 
-       case ODM_CMNINFO_5G_EXT_LNA:
-               pDM_Odm->ExtLNA5G = (u8)Value;
-               break;
+static void FindMinimumRSSI(struct adapter *padapter)
+{
+       struct hal_com_data     *pHalData = GET_HAL_DATA(padapter);
+       struct dm_priv *pdmpriv = &pHalData->dmpriv;
+       struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
 
-       case ODM_CMNINFO_EXT_PA:
-               pDM_Odm->ExtPA = (u8)Value;
-               break;
+       /* 1 1.Determine the minimum RSSI */
 
-       case ODM_CMNINFO_5G_EXT_PA:
-               pDM_Odm->ExtPA5G = (u8)Value;
-               break;
+       if (
+               (pDM_Odm->bLinked != true) &&
+               (pdmpriv->EntryMinUndecoratedSmoothedPWDB == 0)
+       ) {
+               pdmpriv->MinUndecoratedPWDBForDM = 0;
+               /* ODM_RT_TRACE(pDM_Odm, COMP_BB_POWERSAVING, DBG_LOUD, ("Not connected to any\n")); */
+       } else
+               pdmpriv->MinUndecoratedPWDBForDM = pdmpriv->EntryMinUndecoratedSmoothedPWDB;
 
-       case ODM_CMNINFO_GPA:
-               pDM_Odm->TypeGPA = (ODM_TYPE_GPA_E)Value;
-               break;
-       case ODM_CMNINFO_APA:
-               pDM_Odm->TypeAPA = (ODM_TYPE_APA_E)Value;
-               break;
-       case ODM_CMNINFO_GLNA:
-               pDM_Odm->TypeGLNA = (ODM_TYPE_GLNA_E)Value;
-               break;
-       case ODM_CMNINFO_ALNA:
-               pDM_Odm->TypeALNA = (ODM_TYPE_ALNA_E)Value;
-               break;
+       /* DBG_8192C("%s =>MinUndecoratedPWDBForDM(%d)\n", __func__, pdmpriv->MinUndecoratedPWDBForDM); */
+       /* ODM_RT_TRACE(pDM_Odm, COMP_DIG, DBG_LOUD, ("MinUndecoratedPWDBForDM =%d\n", pHalData->MinUndecoratedPWDBForDM)); */
+}
 
-       case ODM_CMNINFO_EXT_TRSW:
-               pDM_Odm->ExtTRSW = (u8)Value;
-               break;
-       case ODM_CMNINFO_PATCH_ID:
-               pDM_Odm->PatchID = (u8)Value;
-               break;
-       case ODM_CMNINFO_BINHCT_TEST:
-               pDM_Odm->bInHctTest = (bool)Value;
-               break;
-       case ODM_CMNINFO_BWIFI_TEST:
-               pDM_Odm->bWIFITest = (bool)Value;
-               break;
+static void odm_RSSIMonitorCheckCE(struct dm_odm_t *pDM_Odm)
+{
+       struct adapter *Adapter = pDM_Odm->Adapter;
+       struct hal_com_data     *pHalData = GET_HAL_DATA(Adapter);
+       struct dm_priv *pdmpriv = &pHalData->dmpriv;
+       int i;
+       int tmpEntryMaxPWDB = 0, tmpEntryMinPWDB = 0xff;
+       u8 sta_cnt = 0;
+       u32 PWDB_rssi[NUM_STA] = {0};/* 0~15]:MACID, [16~31]:PWDB_rssi */
+       struct ra_t *pRA_Table = &pDM_Odm->DM_RA_Table;
 
-       case ODM_CMNINFO_SMART_CONCURRENT:
-               pDM_Odm->bDualMacSmartConcurrent = (bool)Value;
-               break;
+       if (pDM_Odm->bLinked != true)
+               return;
 
-       /* To remove the compiler warning, must add an empty default statement to handle the other values. */
-       default:
-               /* do nothing */
-               break;
-       }
+       pRA_Table->firstconnect = pDM_Odm->bLinked;
 
-}
+       /* if (check_fwstate(&Adapter->mlmepriv, WIFI_AP_STATE|WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE) == true) */
+       {
+               struct sta_info *psta;
 
+               for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
+                       psta = pDM_Odm->pODM_StaInfo[i];
+                       if (IS_STA_VALID(psta)) {
+                               if (IS_MCAST(psta->hwaddr))  /* if (psta->mac_id == 1) */
+                                       continue;
 
-void ODM_CmnInfoHook(PDM_ODM_T pDM_Odm, ODM_CMNINFO_E CmnInfo, void *pValue)
-{
-       /*  */
-       /*  Hook call by reference pointer. */
-       /*  */
-       switch (CmnInfo) {
-       /*  */
-       /*  Dynamic call by reference pointer. */
-       /*  */
-       case ODM_CMNINFO_MAC_PHY_MODE:
-               pDM_Odm->pMacPhyMode = pValue;
-               break;
+                               if (psta->rssi_stat.UndecoratedSmoothedPWDB == (-1))
+                                       continue;
 
-       case ODM_CMNINFO_TX_UNI:
-               pDM_Odm->pNumTxBytesUnicast = pValue;
-               break;
+                               if (psta->rssi_stat.UndecoratedSmoothedPWDB < tmpEntryMinPWDB)
+                                       tmpEntryMinPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB;
 
-       case ODM_CMNINFO_RX_UNI:
-               pDM_Odm->pNumRxBytesUnicast = pValue;
-               break;
+                               if (psta->rssi_stat.UndecoratedSmoothedPWDB > tmpEntryMaxPWDB)
+                                       tmpEntryMaxPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB;
 
-       case ODM_CMNINFO_WM_MODE:
-               pDM_Odm->pwirelessmode = pValue;
-               break;
+                               if (psta->rssi_stat.UndecoratedSmoothedPWDB != (-1))
+                                       PWDB_rssi[sta_cnt++] = (psta->mac_id | (psta->rssi_stat.UndecoratedSmoothedPWDB<<16));
+                       }
+               }
 
-       case ODM_CMNINFO_BAND:
-               pDM_Odm->pBandType = pValue;
-               break;
+               /* printk("%s ==> sta_cnt(%d)\n", __func__, sta_cnt); */
 
-       case ODM_CMNINFO_SEC_CHNL_OFFSET:
-               pDM_Odm->pSecChOffset = pValue;
-               break;
+               for (i = 0; i < sta_cnt; i++) {
+                       if (PWDB_rssi[i] != (0)) {
+                               if (pHalData->fw_ractrl == true)/*  Report every sta's RSSI to FW */
+                                       rtl8723b_set_rssi_cmd(Adapter, (u8 *)(&PWDB_rssi[i]));
+                       }
+               }
+       }
 
-       case ODM_CMNINFO_SEC_MODE:
-               pDM_Odm->pSecurity = pValue;
-               break;
 
-       case ODM_CMNINFO_BW:
-               pDM_Odm->pBandWidth = pValue;
-               break;
 
-       case ODM_CMNINFO_CHNL:
-               pDM_Odm->pChannel = pValue;
-               break;
+       if (tmpEntryMaxPWDB != 0)       /*  If associated entry is found */
+               pdmpriv->EntryMaxUndecoratedSmoothedPWDB = tmpEntryMaxPWDB;
+       else
+               pdmpriv->EntryMaxUndecoratedSmoothedPWDB = 0;
 
-       case ODM_CMNINFO_DMSP_GET_VALUE:
-               pDM_Odm->pbGetValueFromOtherMac = pValue;
-               break;
+       if (tmpEntryMinPWDB != 0xff) /*  If associated entry is found */
+               pdmpriv->EntryMinUndecoratedSmoothedPWDB = tmpEntryMinPWDB;
+       else
+               pdmpriv->EntryMinUndecoratedSmoothedPWDB = 0;
 
-       case ODM_CMNINFO_BUDDY_ADAPTOR:
-               pDM_Odm->pBuddyAdapter = pValue;
-               break;
+       FindMinimumRSSI(Adapter);/* get pdmpriv->MinUndecoratedPWDBForDM */
 
-       case ODM_CMNINFO_DMSP_IS_MASTER:
-               pDM_Odm->pbMasterOfDMSP = pValue;
-               break;
+       pDM_Odm->RSSI_Min = pdmpriv->MinUndecoratedPWDBForDM;
+       /* ODM_CmnInfoUpdate(&pHalData->odmpriv , ODM_CMNINFO_RSSI_MIN, pdmpriv->MinUndecoratedPWDBForDM); */
+}
 
-       case ODM_CMNINFO_SCAN:
-               pDM_Odm->pbScanInProcess = pValue;
-               break;
+static void odm_RSSIMonitorCheck(struct dm_odm_t *pDM_Odm)
+{
+       if (!(pDM_Odm->SupportAbility & ODM_BB_RSSI_MONITOR))
+               return;
 
-       case ODM_CMNINFO_POWER_SAVING:
-               pDM_Odm->pbPowerSaving = pValue;
-               break;
+       odm_RSSIMonitorCheckCE(pDM_Odm);
 
-       case ODM_CMNINFO_ONE_PATH_CCA:
-               pDM_Odm->pOnePathCCA = pValue;
-               break;
+}      /*  odm_RSSIMonitorCheck */
 
-       case ODM_CMNINFO_DRV_STOP:
-               pDM_Odm->pbDriverStopped =  pValue;
-               break;
+/* 3 ============================================================ */
+/* 3 SW Antenna Diversity */
+/* 3 ============================================================ */
+static void odm_SwAntDetectInit(struct dm_odm_t *pDM_Odm)
+{
+       struct swat_t *pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table;
 
-       case ODM_CMNINFO_PNP_IN:
-               pDM_Odm->pbDriverIsGoingToPnpSetPowerSleep =  pValue;
-               break;
+       pDM_SWAT_Table->SWAS_NoLink_BK_Reg92c = rtw_read32(pDM_Odm->Adapter, rDPDT_control);
+       pDM_SWAT_Table->PreAntenna = MAIN_ANT;
+       pDM_SWAT_Table->CurAntenna = MAIN_ANT;
+       pDM_SWAT_Table->SWAS_NoLink_State = 0;
+}
 
-       case ODM_CMNINFO_INIT_ON:
-               pDM_Odm->pinit_adpt_in_progress =  pValue;
-               break;
+/* 3 ============================================================ */
+/* 3 Tx Power Tracking */
+/* 3 ============================================================ */
 
-       case ODM_CMNINFO_ANT_TEST:
-               pDM_Odm->pAntennaTest =  pValue;
-               break;
+static u8 getSwingIndex(struct dm_odm_t *pDM_Odm)
+{
+       struct adapter *Adapter = pDM_Odm->Adapter;
+       u8 i = 0;
+       u32 bbSwing;
+       u32 swingTableSize;
+       u32 *pSwingTable;
 
-       case ODM_CMNINFO_NET_CLOSED:
-               pDM_Odm->pbNet_closed = pValue;
-               break;
+       bbSwing = PHY_QueryBBReg(Adapter, rOFDM0_XATxIQImbalance, 0xFFC00000);
 
-       case ODM_CMNINFO_FORCED_RATE:
-               pDM_Odm->pForcedDataRate = pValue;
-               break;
+       pSwingTable = OFDMSwingTable_New;
+       swingTableSize = OFDM_TABLE_SIZE;
 
-       case ODM_CMNINFO_FORCED_IGI_LB:
-               pDM_Odm->pu1ForcedIgiLb = pValue;
-               break;
+       for (i = 0; i < swingTableSize; ++i) {
+               u32 tableValue = pSwingTable[i];
 
-       case ODM_CMNINFO_MP_MODE:
-               pDM_Odm->mp_mode = pValue;
-               break;
+               if (tableValue >= 0x100000)
+                       tableValue >>= 22;
+               if (bbSwing == tableValue)
+                       break;
+       }
+       return i;
+}
 
-       /* case ODM_CMNINFO_RTSTA_AID: */
-       /* pDM_Odm->pAidMap =  (u8 *)pValue; */
-       /* break; */
+void odm_TXPowerTrackingInit(struct dm_odm_t *pDM_Odm)
+{
+       u8 defaultSwingIndex = getSwingIndex(pDM_Odm);
+       u8 p = 0;
+       struct adapter *Adapter = pDM_Odm->Adapter;
+       struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
 
-       /* case ODM_CMNINFO_BT_COEXIST: */
-       /* pDM_Odm->BTCoexist = (bool *)pValue; */
 
-       /* case ODM_CMNINFO_STA_STATUS: */
-       /* pDM_Odm->pODM_StaInfo[] = (PSTA_INFO_T)pValue; */
-       /* break; */
+       struct dm_priv *pdmpriv = &pHalData->dmpriv;
 
-       /* case ODM_CMNINFO_PHY_STATUS: */
-       /* pDM_Odm->pPhyInfo = (ODM_PHY_INFO *)pValue; */
-       /* break; */
+       pdmpriv->bTXPowerTracking = true;
+       pdmpriv->TXPowercount = 0;
+       pdmpriv->bTXPowerTrackingInit = false;
 
-       /* case ODM_CMNINFO_MAC_STATUS: */
-       /* pDM_Odm->pMacInfo = (struct odm_mac_status_info *)pValue; */
-       /* break; */
-       /* To remove the compiler warning, must add an empty default statement to handle the other values. */
-       default:
-               /* do nothing */
-               break;
-       }
+       if (*(pDM_Odm->mp_mode) != 1)
+               pdmpriv->TxPowerTrackControl = true;
+       else
+               pdmpriv->TxPowerTrackControl = false;
 
-}
 
+       /* MSG_8192C("pdmpriv->TxPowerTrackControl = %d\n", pdmpriv->TxPowerTrackControl); */
 
-void ODM_CmnInfoPtrArrayHook(
-       PDM_ODM_T pDM_Odm,
-       ODM_CMNINFO_E CmnInfo,
-       u16 Index,
-       void *pValue
-)
-{
-       /*  */
-       /*  Hook call by reference pointer. */
-       /*  */
-       switch (CmnInfo) {
-       /*  */
-       /*  Dynamic call by reference pointer. */
-       /*  */
-       case ODM_CMNINFO_STA_STATUS:
-               pDM_Odm->pODM_StaInfo[Index] = (PSTA_INFO_T)pValue;
-               break;
-       /* To remove the compiler warning, must add an empty default statement to handle the other values. */
-       default:
-               /* do nothing */
-               break;
+       /* pDM_Odm->RFCalibrateInfo.TxPowerTrackControl = true; */
+       pDM_Odm->RFCalibrateInfo.ThermalValue = pHalData->EEPROMThermalMeter;
+       pDM_Odm->RFCalibrateInfo.ThermalValue_IQK = pHalData->EEPROMThermalMeter;
+       pDM_Odm->RFCalibrateInfo.ThermalValue_LCK = pHalData->EEPROMThermalMeter;
+
+       /*  The index of "0 dB" in SwingTable. */
+       pDM_Odm->DefaultOfdmIndex = (defaultSwingIndex >= OFDM_TABLE_SIZE) ? 30 : defaultSwingIndex;
+       pDM_Odm->DefaultCckIndex = 20;
+
+       pDM_Odm->BbSwingIdxCckBase = pDM_Odm->DefaultCckIndex;
+       pDM_Odm->RFCalibrateInfo.CCK_index = pDM_Odm->DefaultCckIndex;
+
+       for (p = ODM_RF_PATH_A; p < MAX_RF_PATH; ++p) {
+               pDM_Odm->BbSwingIdxOfdmBase[p] = pDM_Odm->DefaultOfdmIndex;
+               pDM_Odm->RFCalibrateInfo.OFDM_index[p] = pDM_Odm->DefaultOfdmIndex;
+               pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[p] = 0;
+               pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[p] = 0;
+               pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p] = 0;
        }
 
 }
 
-
-/*  */
-/*  Update Band/CHannel/.. The values are dynamic but non-per-packet. */
-/*  */
-void ODM_CmnInfoUpdate(PDM_ODM_T pDM_Odm, u32 CmnInfo, u64 Value)
+void ODM_TXPowerTrackingCheck(struct dm_odm_t *pDM_Odm)
 {
-       /*  */
-       /*  This init variable may be changed in run time. */
-       /*  */
-       switch (CmnInfo) {
-       case ODM_CMNINFO_LINK_IN_PROGRESS:
-               pDM_Odm->bLinkInProcess = (bool)Value;
-               break;
-
-       case ODM_CMNINFO_ABILITY:
-               pDM_Odm->SupportAbility = (u32)Value;
-               break;
+       struct adapter *Adapter = pDM_Odm->Adapter;
 
-       case ODM_CMNINFO_RF_TYPE:
-               pDM_Odm->RFType = (u8)Value;
-               break;
+       if (!(pDM_Odm->SupportAbility & ODM_RF_TX_PWR_TRACK))
+               return;
 
-       case ODM_CMNINFO_WIFI_DIRECT:
-               pDM_Odm->bWIFI_Direct = (bool)Value;
-               break;
+       if (!pDM_Odm->RFCalibrateInfo.TM_Trigger) { /* at least delay 1 sec */
+               PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_T_METER_NEW, (BIT17 | BIT16), 0x03);
 
-       case ODM_CMNINFO_WIFI_DISPLAY:
-               pDM_Odm->bWIFI_Display = (bool)Value;
-               break;
+               /* DBG_871X("Trigger Thermal Meter!!\n"); */
 
-       case ODM_CMNINFO_LINK:
-               pDM_Odm->bLinked = (bool)Value;
-               break;
+               pDM_Odm->RFCalibrateInfo.TM_Trigger = 1;
+               return;
+       } else {
+               /* DBG_871X("Schedule TxPowerTracking direct call!!\n"); */
+               ODM_TXPowerTrackingCallback_ThermalMeter(Adapter);
+               pDM_Odm->RFCalibrateInfo.TM_Trigger = 0;
+       }
+}
 
-       case ODM_CMNINFO_STATION_STATE:
-               pDM_Odm->bsta_state = (bool)Value;
-               break;
+/*  */
+/* 3 Export Interface */
+/*  */
 
-       case ODM_CMNINFO_RSSI_MIN:
-               pDM_Odm->RSSI_Min = (u8)Value;
-               break;
+/*  */
+/*  2011/09/21 MH Add to describe different team necessary resource allocate?? */
+/*  */
+void ODM_DMInit(struct dm_odm_t *pDM_Odm)
+{
 
-       case ODM_CMNINFO_DBG_COMP:
-               pDM_Odm->DebugComponents = Value;
-               break;
+       odm_CommonInfoSelfInit(pDM_Odm);
+       odm_CmnInfoInit_Debug(pDM_Odm);
+       odm_DIGInit(pDM_Odm);
+       odm_NHMCounterStatisticsInit(pDM_Odm);
+       odm_AdaptivityInit(pDM_Odm);
+       odm_RateAdaptiveMaskInit(pDM_Odm);
+       ODM_CfoTrackingInit(pDM_Odm);
+       ODM_EdcaTurboInit(pDM_Odm);
+       odm_RSSIMonitorInit(pDM_Odm);
+       odm_TXPowerTrackingInit(pDM_Odm);
 
-       case ODM_CMNINFO_DBG_LEVEL:
-               pDM_Odm->DebugLevel = (u32)Value;
-               break;
-       case ODM_CMNINFO_RA_THRESHOLD_HIGH:
-               pDM_Odm->RateAdaptive.HighRSSIThresh = (u8)Value;
-               break;
+       ODM_ClearTxPowerTrackingState(pDM_Odm);
 
-       case ODM_CMNINFO_RA_THRESHOLD_LOW:
-               pDM_Odm->RateAdaptive.LowRSSIThresh = (u8)Value;
-               break;
-       /*  The following is for BT HS mode and BT coexist mechanism. */
-       case ODM_CMNINFO_BT_ENABLED:
-               pDM_Odm->bBtEnabled = (bool)Value;
-               break;
+       if (*(pDM_Odm->mp_mode) != 1)
+               odm_PathDiversityInit(pDM_Odm);
 
-       case ODM_CMNINFO_BT_HS_CONNECT_PROCESS:
-               pDM_Odm->bBtConnectProcess = (bool)Value;
-               break;
+       odm_DynamicBBPowerSavingInit(pDM_Odm);
+       odm_DynamicTxPowerInit(pDM_Odm);
 
-       case ODM_CMNINFO_BT_HS_RSSI:
-               pDM_Odm->btHsRssi = (u8)Value;
-               break;
+       odm_SwAntDetectInit(pDM_Odm);
+}
 
-       case ODM_CMNINFO_BT_OPERATION:
-               pDM_Odm->bBtHsOperation = (bool)Value;
-               break;
-
-       case ODM_CMNINFO_BT_LIMITED_DIG:
-               pDM_Odm->bBtLimitedDig = (bool)Value;
-               break;
-
-       case ODM_CMNINFO_BT_DISABLE_EDCA:
-               pDM_Odm->bBtDisableEdcaTurbo = (bool)Value;
-               break;
-
-/*
-       case    ODM_CMNINFO_OP_MODE:
-               pDM_Odm->OPMode = (u8)Value;
-               break;
-
-       case    ODM_CMNINFO_WM_MODE:
-               pDM_Odm->WirelessMode = (u8)Value;
-               break;
-
-       case    ODM_CMNINFO_BAND:
-               pDM_Odm->BandType = (u8)Value;
-               break;
-
-       case    ODM_CMNINFO_SEC_CHNL_OFFSET:
-               pDM_Odm->SecChOffset = (u8)Value;
-               break;
-
-       case    ODM_CMNINFO_SEC_MODE:
-               pDM_Odm->Security = (u8)Value;
-               break;
-
-       case    ODM_CMNINFO_BW:
-               pDM_Odm->BandWidth = (u8)Value;
-               break;
-
-       case    ODM_CMNINFO_CHNL:
-               pDM_Odm->Channel = (u8)Value;
-               break;
-*/
-       default:
-               /* do nothing */
-               break;
-       }
-
-
-}
-
-void odm_CommonInfoSelfInit(PDM_ODM_T pDM_Odm)
+/*  */
+/*  2011/09/20 MH This is the entry pointer for all team to execute HW out source DM. */
+/*  You can not add any dummy function here, be care, you can only use DM structure */
+/*  to perform any new ODM_DM. */
+/*  */
+void ODM_DMWatchdog(struct dm_odm_t *pDM_Odm)
 {
-       pDM_Odm->bCckHighPower = (bool) PHY_QueryBBReg(pDM_Odm->Adapter, ODM_REG(CCK_RPT_FORMAT, pDM_Odm), ODM_BIT(CCK_RPT_FORMAT, pDM_Odm));
-       pDM_Odm->RFPathRxEnable = (u8) PHY_QueryBBReg(pDM_Odm->Adapter, ODM_REG(BB_RX_PATH, pDM_Odm), ODM_BIT(BB_RX_PATH, pDM_Odm));
-
-       ODM_InitDebugSetting(pDM_Odm);
-
-       pDM_Odm->TxRate = 0xFF;
-}
+       odm_CommonInfoSelfUpdate(pDM_Odm);
+       odm_BasicDbgMessage(pDM_Odm);
+       odm_FalseAlarmCounterStatistics(pDM_Odm);
+       odm_NHMCounterStatistics(pDM_Odm);
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): RSSI = 0x%x\n", pDM_Odm->RSSI_Min));
 
-void odm_CommonInfoSelfUpdate(PDM_ODM_T pDM_Odm)
-{
-       u8 EntryCnt = 0;
-       u8 i;
-       PSTA_INFO_T     pEntry;
+       odm_RSSIMonitorCheck(pDM_Odm);
 
-       if (*(pDM_Odm->pBandWidth) == ODM_BW40M) {
-               if (*(pDM_Odm->pSecChOffset) == 1)
-                       pDM_Odm->ControlChannel = *(pDM_Odm->pChannel)-2;
-               else if (*(pDM_Odm->pSecChOffset) == 2)
-                       pDM_Odm->ControlChannel = *(pDM_Odm->pChannel)+2;
+       /* For CE Platform(SPRD or Tablet) */
+       /* 8723A or 8189ES platform */
+       /* NeilChen--2012--08--24-- */
+       /* Fix Leave LPS issue */
+       if ((adapter_to_pwrctl(pDM_Odm->Adapter)->pwr_mode != PS_MODE_ACTIVE) /*  in LPS mode */
+               /*  */
+               /* (pDM_Odm->SupportICType & (ODM_RTL8723A))|| */
+               /* (pDM_Odm->SupportICType & (ODM_RTL8188E) &&(&&(((pDM_Odm->SupportInterface  == ODM_ITRF_SDIO))) */
+               /*  */
+       ) {
+                       ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("----Step1: odm_DIG is in LPS mode\n"));
+                       ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("---Step2: 8723AS is in LPS mode\n"));
+                       odm_DIGbyRSSI_LPS(pDM_Odm);
        } else
-               pDM_Odm->ControlChannel = *(pDM_Odm->pChannel);
-
-       for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
-               pEntry = pDM_Odm->pODM_StaInfo[i];
-               if (IS_STA_VALID(pEntry))
-                       EntryCnt++;
-       }
-
-       if (EntryCnt == 1)
-               pDM_Odm->bOneEntryOnly = true;
-       else
-               pDM_Odm->bOneEntryOnly = false;
-}
-
-void odm_CmnInfoInit_Debug(PDM_ODM_T pDM_Odm)
-{
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_CmnInfoInit_Debug ==>\n"));
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportPlatform =%d\n", pDM_Odm->SupportPlatform));
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportAbility = 0x%x\n", pDM_Odm->SupportAbility));
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportInterface =%d\n", pDM_Odm->SupportInterface));
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportICType = 0x%x\n", pDM_Odm->SupportICType));
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("CutVersion =%d\n", pDM_Odm->CutVersion));
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("FabVersion =%d\n", pDM_Odm->FabVersion));
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("RFType =%d\n", pDM_Odm->RFType));
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("BoardType =%d\n", pDM_Odm->BoardType));
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtLNA =%d\n", pDM_Odm->ExtLNA));
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtPA =%d\n", pDM_Odm->ExtPA));
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtTRSW =%d\n", pDM_Odm->ExtTRSW));
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("PatchID =%d\n", pDM_Odm->PatchID));
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bInHctTest =%d\n", pDM_Odm->bInHctTest));
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bWIFITest =%d\n", pDM_Odm->bWIFITest));
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bDualMacSmartConcurrent =%d\n", pDM_Odm->bDualMacSmartConcurrent));
-
-}
-
-void odm_BasicDbgMessage(PDM_ODM_T pDM_Odm)
-{
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_BasicDbgMsg ==>\n"));
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bLinked = %d, RSSI_Min = %d,\n",
-               pDM_Odm->bLinked, pDM_Odm->RSSI_Min));
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("RxRate = 0x%x, RSSI_A = %d, RSSI_B = %d\n",
-               pDM_Odm->RxRate, pDM_Odm->RSSI_A, pDM_Odm->RSSI_B));
-}
-
-/* 3 ============================================================ */
-/* 3 DIG */
-/* 3 ============================================================ */
-/*-----------------------------------------------------------------------------
- * Function:   odm_DIGInit()
- *
- * Overview:   Set DIG scheme init value.
- *
- * Input:              NONE
- *
- * Output:             NONE
- *
- * Return:             NONE
- *
- * Revised History:
- *When         Who             Remark
- *
- *---------------------------------------------------------------------------
- */
-
-/* Remove DIG by yuchen */
+               odm_DIG(pDM_Odm);
 
-/* Remove DIG and FA check by Yu Chen */
+       {
+               struct dig_t *pDM_DigTable = &pDM_Odm->DM_DigTable;
 
+               odm_Adaptivity(pDM_Odm, pDM_DigTable->CurIGValue);
+       }
+       odm_CCKPacketDetectionThresh(pDM_Odm);
 
-/* 3 ============================================================ */
-/* 3 BB Power Save */
-/* 3 ============================================================ */
+       if (*(pDM_Odm->pbPowerSaving) == true)
+               return;
 
-/* Remove BB power saving by Yuchen */
 
-/* 3 ============================================================ */
-/* 3 RATR MASK */
-/* 3 ============================================================ */
-/* 3 ============================================================ */
-/* 3 Rate Adaptive */
-/* 3 ============================================================ */
+       odm_RefreshRateAdaptiveMask(pDM_Odm);
+       odm_EdcaTurboCheck(pDM_Odm);
+       odm_PathDiversity(pDM_Odm);
+       ODM_CfoTracking(pDM_Odm);
 
-void odm_RateAdaptiveMaskInit(PDM_ODM_T pDM_Odm)
-{
-       PODM_RATE_ADAPTIVE pOdmRA = &pDM_Odm->RateAdaptive;
+       ODM_TXPowerTrackingCheck(pDM_Odm);
 
-       pOdmRA->Type = DM_Type_ByDriver;
-       if (pOdmRA->Type == DM_Type_ByDriver)
-               pDM_Odm->bUseRAMask = true;
-       else
-               pDM_Odm->bUseRAMask = false;
+       /* odm_EdcaTurboCheck(pDM_Odm); */
 
-       pOdmRA->RATRState = DM_RATR_STA_INIT;
-       pOdmRA->LdpcThres = 35;
-       pOdmRA->bUseLdpc = false;
-       pOdmRA->HighRSSIThresh = 50;
-       pOdmRA->LowRSSIThresh = 20;
+       /* 2010.05.30 LukeLee: For CE platform, files in IC subfolders may not be included to be compiled, */
+       /*  so compile flags must be left here to prevent from compile errors */
+       pDM_Odm->PhyDbgInfo.NumQryBeaconPkt = 0;
 }
 
-u32 ODM_Get_Rate_Bitmap(
-       PDM_ODM_T pDM_Odm,
-       u32 macid,
-       u32 ra_mask,
-       u8 rssi_level
-)
-{
-       PSTA_INFO_T     pEntry;
-       u32 rate_bitmap = 0;
-       u8 WirelessMode;
-
-       pEntry = pDM_Odm->pODM_StaInfo[macid];
-       if (!IS_STA_VALID(pEntry))
-               return ra_mask;
-
-       WirelessMode = pEntry->wireless_mode;
-
-       switch (WirelessMode) {
-       case ODM_WM_B:
-               if (ra_mask & 0x0000000c)               /* 11M or 5.5M enable */
-                       rate_bitmap = 0x0000000d;
-               else
-                       rate_bitmap = 0x0000000f;
-               break;
 
-       case (ODM_WM_G):
-       case (ODM_WM_A):
-               if (rssi_level == DM_RATR_STA_HIGH)
-                       rate_bitmap = 0x00000f00;
-               else
-                       rate_bitmap = 0x00000ff0;
-               break;
-
-       case (ODM_WM_B|ODM_WM_G):
-               if (rssi_level == DM_RATR_STA_HIGH)
-                       rate_bitmap = 0x00000f00;
-               else if (rssi_level == DM_RATR_STA_MIDDLE)
-                       rate_bitmap = 0x00000ff0;
-               else
-                       rate_bitmap = 0x00000ff5;
+/*  */
+/*  Init /.. Fixed HW value. Only init time. */
+/*  */
+void ODM_CmnInfoInit(struct dm_odm_t *pDM_Odm, enum odm_cmninfo_e CmnInfo, u32 Value)
+{
+       /*  */
+       /*  This section is used for init value */
+       /*  */
+       switch (CmnInfo) {
+       /*  */
+       /*  Fixed ODM value. */
+       /*  */
+       case ODM_CMNINFO_ABILITY:
+               pDM_Odm->SupportAbility = (u32)Value;
                break;
 
-       case (ODM_WM_B|ODM_WM_G|ODM_WM_N24G):
-       case (ODM_WM_B|ODM_WM_N24G):
-       case (ODM_WM_G|ODM_WM_N24G):
-       case (ODM_WM_A|ODM_WM_N5G):
-               if (pDM_Odm->RFType == ODM_1T2R || pDM_Odm->RFType == ODM_1T1R) {
-                       if (rssi_level == DM_RATR_STA_HIGH)
-                               rate_bitmap = 0x000f0000;
-                       else if (rssi_level == DM_RATR_STA_MIDDLE)
-                               rate_bitmap = 0x000ff000;
-                       else {
-                               if (*(pDM_Odm->pBandWidth) == ODM_BW40M)
-                                       rate_bitmap = 0x000ff015;
-                               else
-                                       rate_bitmap = 0x000ff005;
-                       }
-               } else {
-                       if (rssi_level == DM_RATR_STA_HIGH)
-                               rate_bitmap = 0x0f8f0000;
-                       else if (rssi_level == DM_RATR_STA_MIDDLE)
-                               rate_bitmap = 0x0f8ff000;
-                       else {
-                               if (*(pDM_Odm->pBandWidth) == ODM_BW40M)
-                                       rate_bitmap = 0x0f8ff015;
-                               else
-                                       rate_bitmap = 0x0f8ff005;
-                       }
-               }
+       case ODM_CMNINFO_RF_TYPE:
+               pDM_Odm->RFType = (u8)Value;
                break;
 
-       case (ODM_WM_AC|ODM_WM_G):
-               if (rssi_level == 1)
-                       rate_bitmap = 0xfc3f0000;
-               else if (rssi_level == 2)
-                       rate_bitmap = 0xfffff000;
-               else
-                       rate_bitmap = 0xffffffff;
+       case ODM_CMNINFO_PLATFORM:
+               pDM_Odm->SupportPlatform = (u8)Value;
                break;
 
-       case (ODM_WM_AC|ODM_WM_A):
-
-               if (pDM_Odm->RFType == RF_1T1R) {
-                       if (rssi_level == 1)                            /*  add by Gary for ac-series */
-                               rate_bitmap = 0x003f8000;
-                       else if (rssi_level == 2)
-                               rate_bitmap = 0x003ff000;
-                       else
-                               rate_bitmap = 0x003ff010;
-               } else {
-                       if (rssi_level == 1)                            /*  add by Gary for ac-series */
-                               rate_bitmap = 0xfe3f8000;       /*  VHT 2SS MCS3~9 */
-                       else if (rssi_level == 2)
-                               rate_bitmap = 0xfffff000;       /*  VHT 2SS MCS0~9 */
-                       else
-                               rate_bitmap = 0xfffff010;       /*  All */
-               }
+       case ODM_CMNINFO_INTERFACE:
+               pDM_Odm->SupportInterface = (u8)Value;
                break;
 
-       default:
-               if (pDM_Odm->RFType == RF_1T2R)
-                       rate_bitmap = 0x000fffff;
-               else
-                       rate_bitmap = 0x0fffffff;
+       case ODM_CMNINFO_MP_TEST_CHIP:
+               pDM_Odm->bIsMPChip = (u8)Value;
                break;
-       }
-
-       /* printk("%s ==> rssi_level:0x%02x, WirelessMode:0x%02x, rate_bitmap:0x%08x\n", __func__, rssi_level, WirelessMode, rate_bitmap); */
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, (" ==> rssi_level:0x%02x, WirelessMode:0x%02x, rate_bitmap:0x%08x\n", rssi_level, WirelessMode, rate_bitmap));
-
-       return ra_mask & rate_bitmap;
-
-}
-
-/*-----------------------------------------------------------------------------
-* Function:    odm_RefreshRateAdaptiveMask()
-*
-* Overview:    Update rate table mask according to rssi
-*
-* Input:               NONE
-*
-* Output:              NONE
-*
-* Return:              NONE
-*
-* Revised History:
-*When          Who             Remark
-*05/27/2009    hpfan   Create Version 0.
-*
-* --------------------------------------------------------------------------
-*/
-void odm_RefreshRateAdaptiveMask(PDM_ODM_T pDM_Odm)
-{
 
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("odm_RefreshRateAdaptiveMask()---------->\n"));
-       if (!(pDM_Odm->SupportAbility & ODM_BB_RA_MASK)) {
-               ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("odm_RefreshRateAdaptiveMask(): Return cos not supported\n"));
-               return;
-       }
-       odm_RefreshRateAdaptiveMaskCE(pDM_Odm);
-}
+       case ODM_CMNINFO_IC_TYPE:
+               pDM_Odm->SupportICType = Value;
+               break;
 
-void odm_RefreshRateAdaptiveMaskCE(PDM_ODM_T pDM_Odm)
-{
-       u8 i;
-       struct adapter *padapter =  pDM_Odm->Adapter;
+       case ODM_CMNINFO_CUT_VER:
+               pDM_Odm->CutVersion = (u8)Value;
+               break;
 
-       if (padapter->bDriverStopped) {
-               ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("<---- odm_RefreshRateAdaptiveMask(): driver is going to unload\n"));
-               return;
-       }
+       case ODM_CMNINFO_FAB_VER:
+               pDM_Odm->FabVersion = (u8)Value;
+               break;
 
-       if (!pDM_Odm->bUseRAMask) {
-               ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("<---- odm_RefreshRateAdaptiveMask(): driver does not control rate adaptive mask\n"));
-               return;
-       }
+       case ODM_CMNINFO_RFE_TYPE:
+               pDM_Odm->RFEType = (u8)Value;
+               break;
 
-       /* printk("==> %s\n", __func__); */
+       case    ODM_CMNINFO_RF_ANTENNA_TYPE:
+               pDM_Odm->AntDivType = (u8)Value;
+               break;
 
-       for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
-               PSTA_INFO_T pstat = pDM_Odm->pODM_StaInfo[i];
+       case ODM_CMNINFO_BOARD_TYPE:
+               pDM_Odm->BoardType = (u8)Value;
+               break;
 
-               if (IS_STA_VALID(pstat)) {
-                       if (IS_MCAST(pstat->hwaddr))  /* if (psta->mac_id == 1) */
-                               continue;
+       case ODM_CMNINFO_PACKAGE_TYPE:
+               pDM_Odm->PackageType = (u8)Value;
+               break;
 
-                       if (true == ODM_RAStateCheck(pDM_Odm, pstat->rssi_stat.UndecoratedSmoothedPWDB, false, &pstat->rssi_level)) {
-                               ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("RSSI:%d, RSSI_LEVEL:%d\n", pstat->rssi_stat.UndecoratedSmoothedPWDB, pstat->rssi_level));
-                               /* printk("RSSI:%d, RSSI_LEVEL:%d\n", pstat->rssi_stat.UndecoratedSmoothedPWDB, pstat->rssi_level); */
-                               rtw_hal_update_ra_mask(pstat, pstat->rssi_level);
-                       }
+       case ODM_CMNINFO_EXT_LNA:
+               pDM_Odm->ExtLNA = (u8)Value;
+               break;
 
-               }
-       }
-}
+       case ODM_CMNINFO_5G_EXT_LNA:
+               pDM_Odm->ExtLNA5G = (u8)Value;
+               break;
 
-/*  Return Value: bool */
-/*  - true: RATRState is changed. */
-bool ODM_RAStateCheck(
-       PDM_ODM_T pDM_Odm,
-       s32 RSSI,
-       bool bForceUpdate,
-       u8 *pRATRState
-)
-{
-       PODM_RATE_ADAPTIVE pRA = &pDM_Odm->RateAdaptive;
-       const u8 GoUpGap = 5;
-       u8 HighRSSIThreshForRA = pRA->HighRSSIThresh;
-       u8 LowRSSIThreshForRA = pRA->LowRSSIThresh;
-       u8 RATRState;
+       case ODM_CMNINFO_EXT_PA:
+               pDM_Odm->ExtPA = (u8)Value;
+               break;
 
-       /*  Threshold Adjustment: */
-       /*  when RSSI state trends to go up one or two levels, make sure RSSI is high enough. */
-       /*  Here GoUpGap is added to solve the boundary's level alternation issue. */
-       switch (*pRATRState) {
-       case DM_RATR_STA_INIT:
-       case DM_RATR_STA_HIGH:
+       case ODM_CMNINFO_5G_EXT_PA:
+               pDM_Odm->ExtPA5G = (u8)Value;
                break;
 
-       case DM_RATR_STA_MIDDLE:
-               HighRSSIThreshForRA += GoUpGap;
+       case ODM_CMNINFO_GPA:
+               pDM_Odm->TypeGPA = (enum odm_type_gpa_e)Value;
+               break;
+       case ODM_CMNINFO_APA:
+               pDM_Odm->TypeAPA = (enum odm_type_apa_e)Value;
+               break;
+       case ODM_CMNINFO_GLNA:
+               pDM_Odm->TypeGLNA = (enum odm_type_glna_e)Value;
+               break;
+       case ODM_CMNINFO_ALNA:
+               pDM_Odm->TypeALNA = (enum odm_type_alna_e)Value;
                break;
 
-       case DM_RATR_STA_LOW:
-               HighRSSIThreshForRA += GoUpGap;
-               LowRSSIThreshForRA += GoUpGap;
+       case ODM_CMNINFO_EXT_TRSW:
+               pDM_Odm->ExtTRSW = (u8)Value;
+               break;
+       case ODM_CMNINFO_PATCH_ID:
+               pDM_Odm->PatchID = (u8)Value;
+               break;
+       case ODM_CMNINFO_BINHCT_TEST:
+               pDM_Odm->bInHctTest = (bool)Value;
+               break;
+       case ODM_CMNINFO_BWIFI_TEST:
+               pDM_Odm->bWIFITest = (bool)Value;
                break;
 
+       case ODM_CMNINFO_SMART_CONCURRENT:
+               pDM_Odm->bDualMacSmartConcurrent = (bool)Value;
+               break;
+
+       /* To remove the compiler warning, must add an empty default statement to handle the other values. */
        default:
-               ODM_RT_ASSERT(pDM_Odm, false, ("wrong rssi level setting %d !", *pRATRState));
+               /* do nothing */
                break;
        }
 
-       /*  Decide RATRState by RSSI. */
-       if (RSSI > HighRSSIThreshForRA)
-               RATRState = DM_RATR_STA_HIGH;
-       else if (RSSI > LowRSSIThreshForRA)
-               RATRState = DM_RATR_STA_MIDDLE;
-       else
-               RATRState = DM_RATR_STA_LOW;
-       /* printk("==>%s, RATRState:0x%02x , RSSI:%d\n", __func__, RATRState, RSSI); */
+}
 
-       if (*pRATRState != RATRState || bForceUpdate) {
-               ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("RSSI Level %d -> %d\n", *pRATRState, RATRState));
-               *pRATRState = RATRState;
-               return true;
-       }
 
-       return false;
-}
+void ODM_CmnInfoHook(struct dm_odm_t *pDM_Odm, enum odm_cmninfo_e CmnInfo, void *pValue)
+{
+       /*  */
+       /*  Hook call by reference pointer. */
+       /*  */
+       switch (CmnInfo) {
+       /*  */
+       /*  Dynamic call by reference pointer. */
+       /*  */
+       case ODM_CMNINFO_MAC_PHY_MODE:
+               pDM_Odm->pMacPhyMode = pValue;
+               break;
 
+       case ODM_CMNINFO_TX_UNI:
+               pDM_Odm->pNumTxBytesUnicast = pValue;
+               break;
 
-/*  */
+       case ODM_CMNINFO_RX_UNI:
+               pDM_Odm->pNumRxBytesUnicast = pValue;
+               break;
 
-/* 3 ============================================================ */
-/* 3 Dynamic Tx Power */
-/* 3 ============================================================ */
+       case ODM_CMNINFO_WM_MODE:
+               pDM_Odm->pwirelessmode = pValue;
+               break;
 
-/* Remove BY YuChen */
+       case ODM_CMNINFO_BAND:
+               pDM_Odm->pBandType = pValue;
+               break;
 
-/* 3 ============================================================ */
-/* 3 RSSI Monitor */
-/* 3 ============================================================ */
+       case ODM_CMNINFO_SEC_CHNL_OFFSET:
+               pDM_Odm->pSecChOffset = pValue;
+               break;
 
-void odm_RSSIMonitorInit(PDM_ODM_T pDM_Odm)
-{
-       pRA_T pRA_Table = &pDM_Odm->DM_RA_Table;
+       case ODM_CMNINFO_SEC_MODE:
+               pDM_Odm->pSecurity = pValue;
+               break;
 
-       pRA_Table->firstconnect = false;
+       case ODM_CMNINFO_BW:
+               pDM_Odm->pBandWidth = pValue;
+               break;
 
-}
+       case ODM_CMNINFO_CHNL:
+               pDM_Odm->pChannel = pValue;
+               break;
 
-void odm_RSSIMonitorCheck(PDM_ODM_T pDM_Odm)
-{
-       if (!(pDM_Odm->SupportAbility & ODM_BB_RSSI_MONITOR))
-               return;
+       case ODM_CMNINFO_DMSP_GET_VALUE:
+               pDM_Odm->pbGetValueFromOtherMac = pValue;
+               break;
 
-       odm_RSSIMonitorCheckCE(pDM_Odm);
+       case ODM_CMNINFO_BUDDY_ADAPTOR:
+               pDM_Odm->pBuddyAdapter = pValue;
+               break;
 
-}      /*  odm_RSSIMonitorCheck */
+       case ODM_CMNINFO_DMSP_IS_MASTER:
+               pDM_Odm->pbMasterOfDMSP = pValue;
+               break;
 
-static void FindMinimumRSSI(struct adapter *padapter)
-{
-       struct hal_com_data     *pHalData = GET_HAL_DATA(padapter);
-       struct dm_priv *pdmpriv = &pHalData->dmpriv;
-       PDM_ODM_T pDM_Odm = &(pHalData->odmpriv);
+       case ODM_CMNINFO_SCAN:
+               pDM_Odm->pbScanInProcess = pValue;
+               break;
 
-       /* 1 1.Determine the minimum RSSI */
+       case ODM_CMNINFO_POWER_SAVING:
+               pDM_Odm->pbPowerSaving = pValue;
+               break;
 
-       if (
-               (pDM_Odm->bLinked != true) &&
-               (pdmpriv->EntryMinUndecoratedSmoothedPWDB == 0)
-       ) {
-               pdmpriv->MinUndecoratedPWDBForDM = 0;
-               /* ODM_RT_TRACE(pDM_Odm, COMP_BB_POWERSAVING, DBG_LOUD, ("Not connected to any\n")); */
-       } else
-               pdmpriv->MinUndecoratedPWDBForDM = pdmpriv->EntryMinUndecoratedSmoothedPWDB;
+       case ODM_CMNINFO_ONE_PATH_CCA:
+               pDM_Odm->pOnePathCCA = pValue;
+               break;
 
-       /* DBG_8192C("%s =>MinUndecoratedPWDBForDM(%d)\n", __func__, pdmpriv->MinUndecoratedPWDBForDM); */
-       /* ODM_RT_TRACE(pDM_Odm, COMP_DIG, DBG_LOUD, ("MinUndecoratedPWDBForDM =%d\n", pHalData->MinUndecoratedPWDBForDM)); */
-}
+       case ODM_CMNINFO_DRV_STOP:
+               pDM_Odm->pbDriverStopped =  pValue;
+               break;
 
-void odm_RSSIMonitorCheckCE(PDM_ODM_T pDM_Odm)
-{
-       struct adapter *Adapter = pDM_Odm->Adapter;
-       struct hal_com_data     *pHalData = GET_HAL_DATA(Adapter);
-       struct dm_priv *pdmpriv = &pHalData->dmpriv;
-       int i;
-       int tmpEntryMaxPWDB = 0, tmpEntryMinPWDB = 0xff;
-       u8 sta_cnt = 0;
-       u32 PWDB_rssi[NUM_STA] = {0};/* 0~15]:MACID, [16~31]:PWDB_rssi */
-       pRA_T pRA_Table = &pDM_Odm->DM_RA_Table;
+       case ODM_CMNINFO_PNP_IN:
+               pDM_Odm->pbDriverIsGoingToPnpSetPowerSleep =  pValue;
+               break;
 
-       if (pDM_Odm->bLinked != true)
-               return;
+       case ODM_CMNINFO_INIT_ON:
+               pDM_Odm->pinit_adpt_in_progress =  pValue;
+               break;
 
-       pRA_Table->firstconnect = pDM_Odm->bLinked;
+       case ODM_CMNINFO_ANT_TEST:
+               pDM_Odm->pAntennaTest =  pValue;
+               break;
 
-       /* if (check_fwstate(&Adapter->mlmepriv, WIFI_AP_STATE|WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE) == true) */
-       {
-               struct sta_info *psta;
+       case ODM_CMNINFO_NET_CLOSED:
+               pDM_Odm->pbNet_closed = pValue;
+               break;
 
-               for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
-                       psta = pDM_Odm->pODM_StaInfo[i];
-                       if (IS_STA_VALID(psta)) {
-                               if (IS_MCAST(psta->hwaddr))  /* if (psta->mac_id == 1) */
-                                       continue;
+       case ODM_CMNINFO_FORCED_RATE:
+               pDM_Odm->pForcedDataRate = pValue;
+               break;
+
+       case ODM_CMNINFO_FORCED_IGI_LB:
+               pDM_Odm->pu1ForcedIgiLb = pValue;
+               break;
+
+       case ODM_CMNINFO_MP_MODE:
+               pDM_Odm->mp_mode = pValue;
+               break;
+
+       /* case ODM_CMNINFO_RTSTA_AID: */
+       /* pDM_Odm->pAidMap =  (u8 *)pValue; */
+       /* break; */
+
+       /* case ODM_CMNINFO_BT_COEXIST: */
+       /* pDM_Odm->BTCoexist = (bool *)pValue; */
 
-                               if (psta->rssi_stat.UndecoratedSmoothedPWDB == (-1))
-                                       continue;
+       /* case ODM_CMNINFO_STA_STATUS: */
+       /* pDM_Odm->pODM_StaInfo[] = (PSTA_INFO_T)pValue; */
+       /* break; */
 
-                               if (psta->rssi_stat.UndecoratedSmoothedPWDB < tmpEntryMinPWDB)
-                                       tmpEntryMinPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB;
+       /* case ODM_CMNINFO_PHY_STATUS: */
+       /* pDM_Odm->pPhyInfo = (ODM_PHY_INFO *)pValue; */
+       /* break; */
 
-                               if (psta->rssi_stat.UndecoratedSmoothedPWDB > tmpEntryMaxPWDB)
-                                       tmpEntryMaxPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB;
+       /* case ODM_CMNINFO_MAC_STATUS: */
+       /* pDM_Odm->pMacInfo = (struct odm_mac_status_info *)pValue; */
+       /* break; */
+       /* To remove the compiler warning, must add an empty default statement to handle the other values. */
+       default:
+               /* do nothing */
+               break;
+       }
 
-                               if (psta->rssi_stat.UndecoratedSmoothedPWDB != (-1))
-                                       PWDB_rssi[sta_cnt++] = (psta->mac_id | (psta->rssi_stat.UndecoratedSmoothedPWDB<<16));
-                       }
-               }
+}
 
-               /* printk("%s ==> sta_cnt(%d)\n", __func__, sta_cnt); */
 
-               for (i = 0; i < sta_cnt; i++) {
-                       if (PWDB_rssi[i] != (0)) {
-                               if (pHalData->fw_ractrl == true)/*  Report every sta's RSSI to FW */
-                                       rtl8723b_set_rssi_cmd(Adapter, (u8 *)(&PWDB_rssi[i]));
-                       }
-               }
+void ODM_CmnInfoPtrArrayHook(
+       struct dm_odm_t *pDM_Odm,
+       enum odm_cmninfo_e CmnInfo,
+       u16 Index,
+       void *pValue
+)
+{
+       /*  */
+       /*  Hook call by reference pointer. */
+       /*  */
+       switch (CmnInfo) {
+       /*  */
+       /*  Dynamic call by reference pointer. */
+       /*  */
+       case ODM_CMNINFO_STA_STATUS:
+               pDM_Odm->pODM_StaInfo[Index] = (PSTA_INFO_T)pValue;
+               break;
+       /* To remove the compiler warning, must add an empty default statement to handle the other values. */
+       default:
+               /* do nothing */
+               break;
        }
 
+}
 
 
-       if (tmpEntryMaxPWDB != 0)       /*  If associated entry is found */
-               pdmpriv->EntryMaxUndecoratedSmoothedPWDB = tmpEntryMaxPWDB;
-       else
-               pdmpriv->EntryMaxUndecoratedSmoothedPWDB = 0;
+/*  */
+/*  Update Band/CHannel/.. The values are dynamic but non-per-packet. */
+/*  */
+void ODM_CmnInfoUpdate(struct dm_odm_t *pDM_Odm, u32 CmnInfo, u64 Value)
+{
+       /*  */
+       /*  This init variable may be changed in run time. */
+       /*  */
+       switch (CmnInfo) {
+       case ODM_CMNINFO_LINK_IN_PROGRESS:
+               pDM_Odm->bLinkInProcess = (bool)Value;
+               break;
 
-       if (tmpEntryMinPWDB != 0xff) /*  If associated entry is found */
-               pdmpriv->EntryMinUndecoratedSmoothedPWDB = tmpEntryMinPWDB;
-       else
-               pdmpriv->EntryMinUndecoratedSmoothedPWDB = 0;
+       case ODM_CMNINFO_ABILITY:
+               pDM_Odm->SupportAbility = (u32)Value;
+               break;
 
-       FindMinimumRSSI(Adapter);/* get pdmpriv->MinUndecoratedPWDBForDM */
+       case ODM_CMNINFO_RF_TYPE:
+               pDM_Odm->RFType = (u8)Value;
+               break;
 
-       pDM_Odm->RSSI_Min = pdmpriv->MinUndecoratedPWDBForDM;
-       /* ODM_CmnInfoUpdate(&pHalData->odmpriv , ODM_CMNINFO_RSSI_MIN, pdmpriv->MinUndecoratedPWDBForDM); */
-}
+       case ODM_CMNINFO_WIFI_DIRECT:
+               pDM_Odm->bWIFI_Direct = (bool)Value;
+               break;
 
-/* 3 ============================================================ */
-/* 3 Tx Power Tracking */
-/* 3 ============================================================ */
+       case ODM_CMNINFO_WIFI_DISPLAY:
+               pDM_Odm->bWIFI_Display = (bool)Value;
+               break;
 
-static u8 getSwingIndex(PDM_ODM_T pDM_Odm)
-{
-       struct adapter *Adapter = pDM_Odm->Adapter;
-       u8 i = 0;
-       u32 bbSwing;
-       u32 swingTableSize;
-       u32 *pSwingTable;
+       case ODM_CMNINFO_LINK:
+               pDM_Odm->bLinked = (bool)Value;
+               break;
 
-       bbSwing = PHY_QueryBBReg(Adapter, rOFDM0_XATxIQImbalance, 0xFFC00000);
+       case ODM_CMNINFO_STATION_STATE:
+               pDM_Odm->bsta_state = (bool)Value;
+               break;
 
-       pSwingTable = OFDMSwingTable_New;
-       swingTableSize = OFDM_TABLE_SIZE;
+       case ODM_CMNINFO_RSSI_MIN:
+               pDM_Odm->RSSI_Min = (u8)Value;
+               break;
 
-       for (i = 0; i < swingTableSize; ++i) {
-               u32 tableValue = pSwingTable[i];
+       case ODM_CMNINFO_DBG_COMP:
+               pDM_Odm->DebugComponents = Value;
+               break;
 
-               if (tableValue >= 0x100000)
-                       tableValue >>= 22;
-               if (bbSwing == tableValue)
-                       break;
-       }
-       return i;
-}
+       case ODM_CMNINFO_DBG_LEVEL:
+               pDM_Odm->DebugLevel = (u32)Value;
+               break;
+       case ODM_CMNINFO_RA_THRESHOLD_HIGH:
+               pDM_Odm->RateAdaptive.HighRSSIThresh = (u8)Value;
+               break;
 
-void odm_TXPowerTrackingInit(PDM_ODM_T pDM_Odm)
-{
-       u8 defaultSwingIndex = getSwingIndex(pDM_Odm);
-       u8 p = 0;
-       struct adapter *Adapter = pDM_Odm->Adapter;
-       struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
+       case ODM_CMNINFO_RA_THRESHOLD_LOW:
+               pDM_Odm->RateAdaptive.LowRSSIThresh = (u8)Value;
+               break;
+       /*  The following is for BT HS mode and BT coexist mechanism. */
+       case ODM_CMNINFO_BT_ENABLED:
+               pDM_Odm->bBtEnabled = (bool)Value;
+               break;
 
+       case ODM_CMNINFO_BT_HS_CONNECT_PROCESS:
+               pDM_Odm->bBtConnectProcess = (bool)Value;
+               break;
 
-       struct dm_priv *pdmpriv = &pHalData->dmpriv;
+       case ODM_CMNINFO_BT_HS_RSSI:
+               pDM_Odm->btHsRssi = (u8)Value;
+               break;
 
-       pdmpriv->bTXPowerTracking = true;
-       pdmpriv->TXPowercount = 0;
-       pdmpriv->bTXPowerTrackingInit = false;
+       case ODM_CMNINFO_BT_OPERATION:
+               pDM_Odm->bBtHsOperation = (bool)Value;
+               break;
 
-       if (*(pDM_Odm->mp_mode) != 1)
-               pdmpriv->TxPowerTrackControl = true;
-       else
-               pdmpriv->TxPowerTrackControl = false;
+       case ODM_CMNINFO_BT_LIMITED_DIG:
+               pDM_Odm->bBtLimitedDig = (bool)Value;
+               break;
 
+       case ODM_CMNINFO_BT_DISABLE_EDCA:
+               pDM_Odm->bBtDisableEdcaTurbo = (bool)Value;
+               break;
 
-       /* MSG_8192C("pdmpriv->TxPowerTrackControl = %d\n", pdmpriv->TxPowerTrackControl); */
+/*
+       case    ODM_CMNINFO_OP_MODE:
+               pDM_Odm->OPMode = (u8)Value;
+               break;
 
-       /* pDM_Odm->RFCalibrateInfo.TxPowerTrackControl = true; */
-       pDM_Odm->RFCalibrateInfo.ThermalValue = pHalData->EEPROMThermalMeter;
-       pDM_Odm->RFCalibrateInfo.ThermalValue_IQK = pHalData->EEPROMThermalMeter;
-       pDM_Odm->RFCalibrateInfo.ThermalValue_LCK = pHalData->EEPROMThermalMeter;
+       case    ODM_CMNINFO_WM_MODE:
+               pDM_Odm->WirelessMode = (u8)Value;
+               break;
 
-       /*  The index of "0 dB" in SwingTable. */
-       pDM_Odm->DefaultOfdmIndex = (defaultSwingIndex >= OFDM_TABLE_SIZE) ? 30 : defaultSwingIndex;
-       pDM_Odm->DefaultCckIndex = 20;
+       case    ODM_CMNINFO_BAND:
+               pDM_Odm->BandType = (u8)Value;
+               break;
 
-       pDM_Odm->BbSwingIdxCckBase = pDM_Odm->DefaultCckIndex;
-       pDM_Odm->RFCalibrateInfo.CCK_index = pDM_Odm->DefaultCckIndex;
+       case    ODM_CMNINFO_SEC_CHNL_OFFSET:
+               pDM_Odm->SecChOffset = (u8)Value;
+               break;
 
-       for (p = ODM_RF_PATH_A; p < MAX_RF_PATH; ++p) {
-               pDM_Odm->BbSwingIdxOfdmBase[p] = pDM_Odm->DefaultOfdmIndex;
-               pDM_Odm->RFCalibrateInfo.OFDM_index[p] = pDM_Odm->DefaultOfdmIndex;
-               pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[p] = 0;
-               pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[p] = 0;
-               pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p] = 0;
+       case    ODM_CMNINFO_SEC_MODE:
+               pDM_Odm->Security = (u8)Value;
+               break;
+
+       case    ODM_CMNINFO_BW:
+               pDM_Odm->BandWidth = (u8)Value;
+               break;
+
+       case    ODM_CMNINFO_CHNL:
+               pDM_Odm->Channel = (u8)Value;
+               break;
+*/
+       default:
+               /* do nothing */
+               break;
        }
 
+
 }
 
-void ODM_TXPowerTrackingCheck(PDM_ODM_T pDM_Odm)
-{
-       struct adapter *Adapter = pDM_Odm->Adapter;
+/* 3 ============================================================ */
+/* 3 DIG */
+/* 3 ============================================================ */
+/*-----------------------------------------------------------------------------
+ * Function:   odm_DIGInit()
+ *
+ * Overview:   Set DIG scheme init value.
+ *
+ * Input:              NONE
+ *
+ * Output:             NONE
+ *
+ * Return:             NONE
+ *
+ * Revised History:
+ *When         Who             Remark
+ *
+ *---------------------------------------------------------------------------
+ */
 
-       if (!(pDM_Odm->SupportAbility & ODM_RF_TX_PWR_TRACK))
-               return;
+/* Remove DIG by yuchen */
 
-       if (!pDM_Odm->RFCalibrateInfo.TM_Trigger) { /* at least delay 1 sec */
-               PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_T_METER_NEW, (BIT17 | BIT16), 0x03);
+/* Remove DIG and FA check by Yu Chen */
 
-               /* DBG_871X("Trigger Thermal Meter!!\n"); */
+/* 3 ============================================================ */
+/* 3 BB Power Save */
+/* 3 ============================================================ */
 
-               pDM_Odm->RFCalibrateInfo.TM_Trigger = 1;
-               return;
-       } else {
-               /* DBG_871X("Schedule TxPowerTracking direct call!!\n"); */
-               ODM_TXPowerTrackingCallback_ThermalMeter(Adapter);
-               pDM_Odm->RFCalibrateInfo.TM_Trigger = 0;
-       }
-}
+/* Remove BB power saving by Yuchen */
 
 /* 3 ============================================================ */
-/* 3 SW Antenna Diversity */
+/* 3 Dynamic Tx Power */
 /* 3 ============================================================ */
-void odm_SwAntDetectInit(PDM_ODM_T pDM_Odm)
-{
-       pSWAT_T pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table;
 
-       pDM_SWAT_Table->SWAS_NoLink_BK_Reg92c = rtw_read32(pDM_Odm->Adapter, rDPDT_control);
-       pDM_SWAT_Table->PreAntenna = MAIN_ANT;
-       pDM_SWAT_Table->CurAntenna = MAIN_ANT;
-       pDM_SWAT_Table->SWAS_NoLink_State = 0;
-}
+/* Remove BY YuChen */
+
index 16e8f66a31714dceba9de1e48b8850d848c1535e..981de3710709714deddb06c04a088bfeb5e69d37 100644 (file)
@@ -92,11 +92,11 @@ struct dynamic_primary_CCA {
        u8 MF_state;
 };
 
-typedef struct _Rate_Adaptive_Table_ {
+struct ra_t {
        u8 firstconnect;
-} RA_T, *pRA_T;
+};
 
-typedef struct _RX_High_Power_ {
+struct rxhp_t {
        u8 RXHP_flag;
        u8 PSD_func_trigger;
        u8 PSD_bitmap_RXHP[80];
@@ -107,8 +107,8 @@ typedef struct _RX_High_Power_ {
        bool First_time_enter;
        bool RXHP_enable;
        u8 TP_Mode;
-       RT_TIMER PSDTimer;
-} RXHP_T, *pRXHP_T;
+       struct timer_list PSDTimer;
+};
 
 #define ASSOCIATE_ENTRY_NUM                                    32 /*  Max size of AsocEntry[]. */
 #define        ODM_ASSOCIATE_ENTRY_NUM                         ASSOCIATE_ENTRY_NUM
@@ -126,7 +126,7 @@ typedef struct _RX_High_Power_ {
 #define        TRAFFIC_HIGH    1
 #define        TRAFFIC_UltraLOW        2
 
-typedef struct _SW_Antenna_Switch_ {
+struct swat_t { /* _SW_Antenna_Switch_ */
        u8 Double_chk_flag;
        u8 try_flag;
        s32 PreRSSI;
@@ -169,16 +169,16 @@ typedef struct _SW_Antenna_Switch_ {
        u8 TrafficLoad;
        u8 Train_time;
        u8 Train_time_flag;
-       RT_TIMER SwAntennaSwitchTimer;
-       RT_TIMER SwAntennaSwitchTimer_8723B;
+       struct timer_list SwAntennaSwitchTimer;
+       struct timer_list SwAntennaSwitchTimer_8723B;
        u32 PktCnt_SWAntDivByCtrlFrame;
        bool bSWAntDivByCtrlFrame;
-} SWAT_T, *pSWAT_T;
+};
 
 /* Remove Edca by YuChen */
 
 
-typedef struct _ODM_RATE_ADAPTIVE {
+struct odm_rate_adaptive {
        u8 Type;                                /*  DM_Type_ByFW/DM_Type_ByDriver */
        u8 LdpcThres;                   /*  if RSSI > LdpcThres => switch from LPDC to BCC */
        bool bUseLdpc;
@@ -187,7 +187,7 @@ typedef struct _ODM_RATE_ADAPTIVE {
        u8 LowRSSIThresh;               /*  if RSSI <= LowRSSIThresh    => RATRState is DM_RATR_STA_LOW */
        u8 RATRState;                   /*  Current RSSI level, DM_RATR_STA_HIGH/DM_RATR_STA_MIDDLE/DM_RATR_STA_LOW */
 
-} ODM_RATE_ADAPTIVE, *PODM_RATE_ADAPTIVE;
+};
 
 #define IQK_MAC_REG_NUM                4
 #define IQK_ADDA_REG_NUM               16
@@ -277,7 +277,7 @@ struct odm_mac_status_info {
        u8 test;
 };
 
-typedef enum tag_Dynamic_ODM_Support_Ability_Type {
+enum ODM_Ability_E { /* tag_Dynamic_ODM_Support_Ability_Type */
        /*  BB Team */
        ODM_DIG                         = 0x00000001,
        ODM_HIGH_POWER          = 0x00000002,
@@ -291,41 +291,12 @@ typedef enum tag_Dynamic_ODM_Support_Ability_Type {
        ODM_2TPATHDIV           = 0x00000200,
        ODM_1TPATHDIV           = 0x00000400,
        ODM_PSD2AFH                     = 0x00000800
-} ODM_Ability_E;
-
-/*  */
-/*  2011/20/20 MH For MP driver RT_WLAN_STA =  STA_INFO_T */
-/*  Please declare below ODM relative info in your STA info structure. */
-/*  */
-typedef struct _ODM_STA_INFO {
-       /*  Driver Write */
-       bool bUsed;                             /*  record the sta status link or not? */
-       /* u8 WirelessMode;              */
-       u8 IOTPeer;                     /*  Enum value. HT_IOT_PEER_E */
-
-       /*  ODM Write */
-       /* 1 PHY_STATUS_INFO */
-       u8 RSSI_Path[4];                /*  */
-       u8 RSSI_Ave;
-       u8 RXEVM[4];
-       u8 RXSNR[4];
-
-       /*  ODM Write */
-       /* 1 TX_INFO (may changed by IC) */
-       /* TX_INFO_T            pTxInfo;                Define in IC folder. Move lower layer. */
-
-       /*  */
-       /*      Please use compile flag to disabe the strcutrue for other IC except 88E. */
-       /*      Move To lower layer. */
-       /*  */
-       /*  ODM Write Wilson will handle this part(said by Luke.Lee) */
-       /* TX_RPT_T             pTxRpt;                 Define in IC folder. Move lower layer. */
-} ODM_STA_INFO_T, *PODM_STA_INFO_T;
+};
 
 /*  */
 /*  2011/10/20 MH Define Common info enum for all team. */
 /*  */
-typedef enum _ODM_Common_Info_Definition {
+enum odm_cmninfo_e {
        /*  Fixed value: */
 
        /* HOOK BEFORE REG INIT----------- */
@@ -412,10 +383,10 @@ typedef enum _ODM_Common_Info_Definition {
        ODM_CMNINFO_MAC_STATUS,
 
        ODM_CMNINFO_MAX,
-} ODM_CMNINFO_E;
+};
 
 /*  2011/10/20 MH Define ODM support ability.  ODM_CMNINFO_ABILITY */
-typedef enum _ODM_Support_Ability_Definition {
+enum odm_ability_e { /* _ODM_Support_Ability_Definition */
        /*  */
        /*  BB ODM section BIT 0-15 */
        /*  */
@@ -443,21 +414,21 @@ typedef enum _ODM_Support_Ability_Definition {
        ODM_RF_TX_PWR_TRACK             = BIT24,
        ODM_RF_RX_GAIN_TRACK    = BIT25,
        ODM_RF_CALIBRATION              = BIT26,
-} ODM_ABILITY_E;
+};
 
 /*     ODM_CMNINFO_INTERFACE */
-typedef enum tag_ODM_Support_Interface_Definition {
+enum odm_interface_e { /* tag_ODM_Support_Interface_Definition */
        ODM_ITRF_SDIO   =       0x4,
        ODM_ITRF_ALL    =       0x7,
-} ODM_INTERFACE_E;
+};
 
 /*  ODM_CMNINFO_IC_TYPE */
-typedef enum tag_ODM_Support_IC_Type_Definition {
+enum odm_ic_type_e { /* tag_ODM_Support_IC_Type_Definition */
        ODM_RTL8723B    =       BIT8,
-} ODM_IC_TYPE_E;
+};
 
 /* ODM_CMNINFO_CUT_VER */
-typedef enum tag_ODM_Cut_Version_Definition {
+enum odm_cut_version_e { /* tag_ODM_Cut_Version_Definition */
        ODM_CUT_A               =       0,
        ODM_CUT_B               =       1,
        ODM_CUT_C               =       2,
@@ -469,19 +440,19 @@ typedef enum tag_ODM_Cut_Version_Definition {
        ODM_CUT_J               =       9,
        ODM_CUT_K               =       10,
        ODM_CUT_TEST    =       15,
-} ODM_CUT_VERSION_E;
+};
 
 /*  ODM_CMNINFO_FAB_VER */
-typedef enum tag_ODM_Fab_Version_Definition {
+enum odm_fab_e { /* tag_ODM_Fab_Version_Definition */
        ODM_TSMC        =       0,
        ODM_UMC         =       1,
-} ODM_FAB_E;
+};
 
 /*  ODM_CMNINFO_RF_TYPE */
 /*  */
 /*  For example 1T2R (A+AB = BIT0|BIT4|BIT5) */
 /*  */
-typedef enum tag_ODM_RF_Path_Bit_Definition {
+enum odm_rf_path_e { /* tag_ODM_RF_Path_Bit_Definition */
        ODM_RF_TX_A     =       BIT0,
        ODM_RF_TX_B     =       BIT1,
        ODM_RF_TX_C     =       BIT2,
@@ -490,9 +461,9 @@ typedef enum tag_ODM_RF_Path_Bit_Definition {
        ODM_RF_RX_B     =       BIT5,
        ODM_RF_RX_C     =       BIT6,
        ODM_RF_RX_D     =       BIT7,
-} ODM_RF_PATH_E;
+};
 
-typedef enum tag_ODM_RF_Type_Definition {
+enum odm_rf_type_e { /* tag_ODM_RF_Type_Definition */
        ODM_1T1R        =       0,
        ODM_1T2R        =       1,
        ODM_2T2R        =       2,
@@ -501,7 +472,7 @@ typedef enum tag_ODM_RF_Type_Definition {
        ODM_3T3R        =       5,
        ODM_3T4R        =       6,
        ODM_4T4R        =       7,
-} ODM_RF_TYPE_E;
+};
 
 /*  */
 /*  ODM Dynamic common info value definition */
@@ -513,21 +484,21 @@ typedef enum tag_ODM_RF_Type_Definition {
 /*     DUALMAC_SINGLEPHY, */
 /* MACPHY_MODE_8192D,*PMACPHY_MODE_8192D; */
 /*  Above is the original define in MP driver. Please use the same define. THX. */
-typedef enum tag_ODM_MAC_PHY_Mode_Definition {
+enum odm_mac_phy_mode_e { /* tag_ODM_MAC_PHY_Mode_Definition */
        ODM_SMSP        = 0,
        ODM_DMSP        = 1,
        ODM_DMDP        = 2,
-} ODM_MAC_PHY_MODE_E;
+};
 
-typedef enum tag_BT_Coexist_Definition {
+enum odm_bt_coexist_e { /* tag_BT_Coexist_Definition */
        ODM_BT_BUSY             = 1,
        ODM_BT_ON               = 2,
        ODM_BT_OFF              = 3,
        ODM_BT_NONE             = 4,
-} ODM_BT_COEXIST_E;
+};
 
 /*  ODM_CMNINFO_OP_MODE */
-typedef enum tag_Operation_Mode_Definition {
+enum odm_operation_mode_e { /* tag_Operation_Mode_Definition */
        ODM_NO_LINK      = BIT0,
        ODM_LINK         = BIT1,
        ODM_SCAN         = BIT2,
@@ -537,10 +508,10 @@ typedef enum tag_Operation_Mode_Definition {
        ODM_AD_HOC       = BIT6,
        ODM_WIFI_DIRECT  = BIT7,
        ODM_WIFI_DISPLAY = BIT8,
-} ODM_OPERATION_MODE_E;
+};
 
 /*  ODM_CMNINFO_WM_MODE */
-typedef enum tag_Wireless_Mode_Definition {
+enum odm_wireless_mode_e { /* tag_Wireless_Mode_Definition */
        ODM_WM_UNKNOWN    = 0x0,
        ODM_WM_B          = BIT0,
        ODM_WM_G          = BIT1,
@@ -549,25 +520,25 @@ typedef enum tag_Wireless_Mode_Definition {
        ODM_WM_N5G        = BIT4,
        ODM_WM_AUTO       = BIT5,
        ODM_WM_AC         = BIT6,
-} ODM_WIRELESS_MODE_E;
+};
 
 /*  ODM_CMNINFO_BAND */
-typedef enum tag_Band_Type_Definition {
+enum odm_band_type_e { /* tag_Band_Type_Definition */
        ODM_BAND_2_4G = 0,
        ODM_BAND_5G,
        ODM_BAND_ON_BOTH,
        ODM_BANDMAX
-} ODM_BAND_TYPE_E;
+};
 
 /*  ODM_CMNINFO_SEC_CHNL_OFFSET */
-typedef enum tag_Secondary_Channel_Offset_Definition {
+enum odm_sec_chnl_offset_e { /* tag_Secondary_Channel_Offset_Definition */
        ODM_DONT_CARE   = 0,
        ODM_BELOW               = 1,
        ODM_ABOVE               = 2
-} ODM_SEC_CHNL_OFFSET_E;
+};
 
 /*  ODM_CMNINFO_SEC_MODE */
-typedef enum tag_Security_Definition {
+enum odm_security_e { /* tag_Security_Definition */
        ODM_SEC_OPEN            = 0,
        ODM_SEC_WEP40           = 1,
        ODM_SEC_TKIP            = 2,
@@ -576,21 +547,21 @@ typedef enum tag_Security_Definition {
        ODM_SEC_WEP104          = 5,
        ODM_WEP_WPA_MIXED       = 6, /*  WEP + WPA */
        ODM_SEC_SMS4            = 7,
-} ODM_SECURITY_E;
+};
 
 /*  ODM_CMNINFO_BW */
-typedef enum tag_Bandwidth_Definition {
+enum odm_bw_e { /* tag_Bandwidth_Definition */
        ODM_BW20M               = 0,
        ODM_BW40M               = 1,
        ODM_BW80M               = 2,
        ODM_BW160M              = 3,
        ODM_BW10M               = 4,
-} ODM_BW_E;
+};
 
 /*  ODM_CMNINFO_BOARD_TYPE */
 /*  For non-AC-series IC , ODM_BOARD_5G_EXT_PA and ODM_BOARD_5G_EXT_LNA are ignored */
 /*  For AC-series IC, external PA & LNA can be indivisuallly added on 2.4G and/or 5G */
-typedef enum tag_Board_Definition {
+enum odm_board_type_e { /* tag_Board_Definition */
        ODM_BOARD_DEFAULT    = 0,      /*  The DEFAULT case. */
        ODM_BOARD_MINICARD   = BIT(0), /*  0 = non-mini card, 1 = mini card. */
        ODM_BOARD_SLIM       = BIT(1), /*  0 = non-slim card, 1 = slim card */
@@ -600,87 +571,55 @@ typedef enum tag_Board_Definition {
        ODM_BOARD_EXT_TRSW   = BIT(5), /*  0 = no ext-TRSW, 1 = existing ext-TRSW */
        ODM_BOARD_EXT_PA_5G  = BIT(6), /*  0 = no 5G ext-PA, 1 = existing 5G ext-PA */
        ODM_BOARD_EXT_LNA_5G = BIT(7), /*  0 = no 5G ext-LNA, 1 = existing 5G ext-LNA */
-} ODM_BOARD_TYPE_E;
+};
 
-typedef enum tag_ODM_Package_Definition {
+enum ODM_Package_TYPE_E { /* tag_ODM_Package_Definition */
        ODM_PACKAGE_DEFAULT      = 0,
        ODM_PACKAGE_QFN68        = BIT(0),
        ODM_PACKAGE_TFBGA90      = BIT(1),
        ODM_PACKAGE_TFBGA79      = BIT(2),
-} ODM_Package_TYPE_E;
+};
 
-typedef enum tag_ODM_TYPE_GPA_Definition {
+enum odm_type_gpa_e { /* tag_ODM_TYPE_GPA_Definition */
        TYPE_GPA0 = 0,
        TYPE_GPA1 = BIT(1)|BIT(0)
-} ODM_TYPE_GPA_E;
+};
 
-typedef enum tag_ODM_TYPE_APA_Definition {
+enum odm_type_apa_e { /* tag_ODM_TYPE_APA_Definition */
        TYPE_APA0 = 0,
        TYPE_APA1 = BIT(1)|BIT(0)
-} ODM_TYPE_APA_E;
+};
 
-typedef enum tag_ODM_TYPE_GLNA_Definition {
+enum odm_type_glna_e { /* tag_ODM_TYPE_GLNA_Definition */
        TYPE_GLNA0 = 0,
        TYPE_GLNA1 = BIT(2)|BIT(0),
        TYPE_GLNA2 = BIT(3)|BIT(1),
        TYPE_GLNA3 = BIT(3)|BIT(2)|BIT(1)|BIT(0)
-} ODM_TYPE_GLNA_E;
+};
 
-typedef enum tag_ODM_TYPE_ALNA_Definition {
+enum odm_type_alna_e { /* tag_ODM_TYPE_ALNA_Definition */
        TYPE_ALNA0 = 0,
        TYPE_ALNA1 = BIT(2)|BIT(0),
        TYPE_ALNA2 = BIT(3)|BIT(1),
        TYPE_ALNA3 = BIT(3)|BIT(2)|BIT(1)|BIT(0)
-} ODM_TYPE_ALNA_E;
+};
 
 /*  ODM_CMNINFO_ONE_PATH_CCA */
-typedef enum tag_CCA_Path {
+enum odm_cca_path_e { /* tag_CCA_Path */
        ODM_CCA_2R                      = 0,
        ODM_CCA_1R_A            = 1,
        ODM_CCA_1R_B            = 2,
-} ODM_CCA_PATH_E;
-
-typedef struct _ODM_RA_Info_ {
-       u8 RateID;
-       u32 RateMask;
-       u32 RAUseRate;
-       u8 RateSGI;
-       u8 RssiStaRA;
-       u8 PreRssiStaRA;
-       u8 SGIEnable;
-       u8 DecisionRate;
-       u8 PreRate;
-       u8 HighestRate;
-       u8 LowestRate;
-       u32 NscUp;
-       u32 NscDown;
-       u16 RTY[5];
-       u32 TOTAL;
-       u16 DROP;
-       u8 Active;
-       u16 RptTime;
-       u8 RAWaitingCounter;
-       u8 RAPendingCounter;
-       u8 PTActive;  /*  on or off */
-       u8 PTTryState;  /*  0 trying state, 1 for decision state */
-       u8 PTStage;  /*  0~6 */
-       u8 PTStopCount; /* Stop PT counter */
-       u8 PTPreRate;  /*  if rate change do PT */
-       u8 PTPreRssi; /*  if RSSI change 5% do PT */
-       u8 PTModeSS;  /*  decide whitch rate should do PT */
-       u8 RAstage;  /*  StageRA, decide how many times RA will be done between PT */
-       u8 PTSmoothFactor;
-} ODM_RA_INFO_T, *PODM_RA_INFO_T;
-
-typedef struct _IQK_MATRIX_REGS_SETTING {
+};
+
+struct iqk_matrix_regs_setting { /* _IQK_MATRIX_REGS_SETTING */
        bool bIQKDone;
        s32 Value[3][IQK_Matrix_REG_NUM];
        bool bBWIqkResultSaved[3];
-} IQK_MATRIX_REGS_SETTING, *PIQK_MATRIX_REGS_SETTING;
+};
 
 /* Remove PATHDIV_PARA struct to odm_PathDiv.h */
 
-typedef struct ODM_RF_Calibration_Structure {
+struct odm_rf_cal_t { /* ODM_RF_Calibration_Structure */
        /* for tx power tracking */
 
        u32 RegA24; /*  for TempCCK */
@@ -724,7 +663,7 @@ typedef struct ODM_RF_Calibration_Structure {
 
        u8 ThermalValue_HP[HP_THERMAL_NUM];
        u8 ThermalValue_HP_index;
-       IQK_MATRIX_REGS_SETTING IQKMatrixRegSetting[IQK_Matrix_Settings_NUM];
+       struct iqk_matrix_regs_setting IQKMatrixRegSetting[IQK_Matrix_Settings_NUM];
        bool bNeedIQK;
        bool bIQKInProgress;
        u8 Delta_IQK;
@@ -780,12 +719,12 @@ typedef struct ODM_RF_Calibration_Structure {
 
        u32 TxLOK[2];
 
-} ODM_RF_CAL_T, *PODM_RF_CAL_T;
+};
 /*  */
 /*  ODM Dynamic common info value definition */
 /*  */
 
-typedef struct _FAST_ANTENNA_TRAINNING_ {
+struct fat_t { /* _FAST_ANTENNA_TRAINNING_ */
        u8 Bssid[6];
        u8 antsel_rx_keep_0;
        u8 antsel_rx_keep_1;
@@ -823,14 +762,14 @@ typedef struct _FAST_ANTENNA_TRAINNING_ {
        u32 MainAnt_CtrlFrame_Cnt;
        u32 AuxAnt_CtrlFrame_Cnt;
 
-} FAT_T, *pFAT_T;
+};
 
-typedef enum _FAT_STATE {
+enum fat_state_e {
        FAT_NORMAL_STATE                        = 0,
        FAT_TRAINING_STATE              = 1,
-} FAT_STATE_E, *PFAT_STATE_E;
+};
 
-typedef enum _ANT_DIV_TYPE {
+enum ant_div_type_e {
        NO_ANTDIV                       = 0xFF,
        CG_TRX_HW_ANTDIV                = 0x01,
        CGCS_RX_HW_ANTDIV       = 0x02,
@@ -838,37 +777,37 @@ typedef enum _ANT_DIV_TYPE {
        CG_TRX_SMART_ANTDIV     = 0x04,
        CGCS_RX_SW_ANTDIV       = 0x05,
        S0S1_SW_ANTDIV          = 0x06 /* 8723B intrnal switch S0 S1 */
-} ANT_DIV_TYPE_E, *PANT_DIV_TYPE_E;
+};
 
-typedef struct _ODM_PATH_DIVERSITY_ {
+struct pathdiv_t { /* _ODM_PATH_DIVERSITY_ */
        u8 RespTxPath;
        u8 PathSel[ODM_ASSOCIATE_ENTRY_NUM];
        u32 PathA_Sum[ODM_ASSOCIATE_ENTRY_NUM];
        u32 PathB_Sum[ODM_ASSOCIATE_ENTRY_NUM];
        u32 PathA_Cnt[ODM_ASSOCIATE_ENTRY_NUM];
        u32 PathB_Cnt[ODM_ASSOCIATE_ENTRY_NUM];
-} PATHDIV_T, *pPATHDIV_T;
+};
 
-typedef enum _BASEBAND_CONFIG_PHY_REG_PG_VALUE_TYPE {
+enum phy_reg_pg_type { /* _BASEBAND_CONFIG_PHY_REG_PG_VALUE_TYPE */
        PHY_REG_PG_RELATIVE_VALUE = 0,
        PHY_REG_PG_EXACT_VALUE = 1
-} PHY_REG_PG_TYPE;
+};
 
 /*  */
 /*  Antenna detection information from single tone mechanism, added by Roger, 2012.11.27. */
 /*  */
-typedef struct _ANT_DETECTED_INFO {
+struct ant_detected_info {
        bool bAntDetected;
        u32 dBForAntA;
        u32 dBForAntB;
        u32 dBForAntO;
-} ANT_DETECTED_INFO, *PANT_DETECTED_INFO;
+};
 
 /*  */
 /*  2011/09/22 MH Copy from SD4 defined structure. We use to support PHY DM integration. */
 /*  */
-typedef  struct DM_Out_Source_Dynamic_Mechanism_Structure {
-       /* RT_TIMER     FastAntTrainingTimer; */
+struct dm_odm_t { /* DM_Out_Source_Dynamic_Mechanism_Structure */
+       /* struct timer_list    FastAntTrainingTimer; */
        /*  */
        /*      Add for different team use temporarily */
        /*  */
@@ -876,7 +815,7 @@ typedef  struct DM_Out_Source_Dynamic_Mechanism_Structure {
        /*  WHen you use Adapter or priv pointer, you must make sure the pointer is ready. */
        bool odm_ready;
 
-       PHY_REG_PG_TYPE PhyRegPgValueType;
+       enum phy_reg_pg_type PhyRegPgValueType;
        u8 PhyRegPgVersion;
 
        u64     DebugComponents;
@@ -1076,7 +1015,7 @@ typedef  struct DM_Out_Source_Dynamic_Mechanism_Structure {
        u8 Adaptivity_IGI_upper;
        u8 NHM_cnt_0;
 
-       ODM_NOISE_MONITOR noise_level;/* ODM_MAX_CHANNEL_NUM]; */
+       struct odm_noise_monitor noise_level;/* ODM_MAX_CHANNEL_NUM]; */
        /*  */
        /* 2 Define STA info. */
        /*  _ODM_STA_INFO */
@@ -1109,21 +1048,21 @@ typedef  struct DM_Out_Source_Dynamic_Mechanism_Structure {
        /*  */
        /* ODM Structure */
        /*  */
-       FAT_T DM_FatTable;
-       DIG_T DM_DigTable;
-       PS_T DM_PSTable;
+       struct fat_t DM_FatTable;
+       struct dig_t DM_DigTable;
+       struct ps_t DM_PSTable;
        struct dynamic_primary_CCA DM_PriCCA;
-       RXHP_T DM_RXHP_Table;
-       RA_T DM_RA_Table;
-       false_ALARM_STATISTICS FalseAlmCnt;
-       false_ALARM_STATISTICS FlaseAlmCntBuddyAdapter;
-       SWAT_T DM_SWAT_Table;
+       struct rxhp_t dM_RXHP_Table;
+       struct ra_t DM_RA_Table;
+       struct false_ALARM_STATISTICS FalseAlmCnt;
+       struct false_ALARM_STATISTICS FlaseAlmCntBuddyAdapter;
+       struct swat_t DM_SWAT_Table;
        bool RSSI_test;
-       CFO_TRACKING DM_CfoTrack;
+       struct cfo_tracking DM_CfoTrack;
 
-       EDCA_T DM_EDCA_Table;
+       struct edca_t DM_EDCA_Table;
        u32 WMMEDCA_BE;
-       PATHDIV_T DM_PathDiv;
+       struct pathdiv_t DM_PathDiv;
        /*  Copy from SD4 structure */
        /*  */
        /*  ================================================== */
@@ -1146,23 +1085,23 @@ typedef  struct DM_Out_Source_Dynamic_Mechanism_Structure {
 
        /* PSD */
        bool bUserAssignLevel;
-       RT_TIMER PSDTimer;
+       struct timer_list PSDTimer;
        u8 RSSI_BT;                     /* come from BT */
        bool bPSDinProcess;
        bool bPSDactive;
        bool bDMInitialGainEnable;
 
        /* MPT DIG */
-       RT_TIMER MPT_DIGTimer;
+       struct timer_list MPT_DIGTimer;
 
        /* for rate adaptive, in fact,  88c/92c fw will handle this */
        u8 bUseRAMask;
 
-       ODM_RATE_ADAPTIVE RateAdaptive;
+       struct odm_rate_adaptive RateAdaptive;
 
-       ANT_DETECTED_INFO AntDetectedInfo; /*  Antenna detected information for RSSI tool */
+       struct ant_detected_info AntDetectedInfo; /*  Antenna detected information for RSSI tool */
 
-       ODM_RF_CAL_T RFCalibrateInfo;
+       struct odm_rf_cal_t RFCalibrateInfo;
 
        /*  */
        /*  TX power tracking */
@@ -1194,21 +1133,21 @@ typedef  struct DM_Out_Source_Dynamic_Mechanism_Structure {
        /*  */
 
        /*  ODM relative time. */
-       RT_TIMER PathDivSwitchTimer;
+       struct timer_list PathDivSwitchTimer;
        /* 2011.09.27 add for Path Diversity */
-       RT_TIMER CCKPathDiversityTimer;
-       RT_TIMER FastAntTrainingTimer;
+       struct timer_list CCKPathDiversityTimer;
+       struct timer_list FastAntTrainingTimer;
 
        /*  ODM relative workitem. */
 
        #if (BEAMFORMING_SUPPORT == 1)
        RT_BEAMFORMING_INFO BeamformingInfo;
        #endif
-} DM_ODM_T, *PDM_ODM_T; /*  DM_Dynamic_Mechanism_Structure */
+};
 
 #define ODM_RF_PATH_MAX 2
 
-typedef enum _ODM_RF_RADIO_PATH {
+enum odm_rf_radio_path_e {
        ODM_RF_PATH_A = 0,   /* Radio Path A */
        ODM_RF_PATH_B = 1,   /* Radio Path B */
        ODM_RF_PATH_C = 2,   /* Radio Path C */
@@ -1224,16 +1163,16 @@ typedef enum _ODM_RF_RADIO_PATH {
        ODM_RF_PATH_BCD,
        ODM_RF_PATH_ABCD,
        /*   ODM_RF_PATH_MAX,    Max RF number 90 support */
-} ODM_RF_RADIO_PATH_E, *PODM_RF_RADIO_PATH_E;
+};
 
typedef enum _ODM_RF_CONTENT {
enum odm_rf_content {
        odm_radioa_txt = 0x1000,
        odm_radiob_txt = 0x1001,
        odm_radioc_txt = 0x1002,
        odm_radiod_txt = 0x1003
-} ODM_RF_CONTENT;
+};
 
-typedef enum _ODM_BB_Config_Type {
+enum ODM_BB_Config_Type {
        CONFIG_BB_PHY_REG,
        CONFIG_BB_AGC_TAB,
        CONFIG_BB_AGC_TAB_2G,
@@ -1241,14 +1180,14 @@ typedef enum _ODM_BB_Config_Type {
        CONFIG_BB_PHY_REG_PG,
        CONFIG_BB_PHY_REG_MP,
        CONFIG_BB_AGC_TAB_DIFF,
-} ODM_BB_Config_Type, *PODM_BB_Config_Type;
+};
 
-typedef enum _ODM_RF_Config_Type {
+enum ODM_RF_Config_Type {
        CONFIG_RF_RADIO,
        CONFIG_RF_TXPWR_LMT,
-} ODM_RF_Config_Type, *PODM_RF_Config_Type;
+};
 
-typedef enum _ODM_FW_Config_Type {
+enum ODM_FW_Config_Type {
        CONFIG_FW_NIC,
        CONFIG_FW_NIC_2,
        CONFIG_FW_AP,
@@ -1256,10 +1195,10 @@ typedef enum _ODM_FW_Config_Type {
        CONFIG_FW_WoWLAN_2,
        CONFIG_FW_AP_WoWLAN,
        CONFIG_FW_BT,
-} ODM_FW_Config_Type;
+};
 
 /*  Status code */
-typedef enum _RT_STATUS {
+enum rt_status {
        RT_STATUS_SUCCESS,
        RT_STATUS_FAILURE,
        RT_STATUS_PENDING,
@@ -1268,7 +1207,7 @@ typedef enum _RT_STATUS {
        RT_STATUS_INVALID_PARAMETER,
        RT_STATUS_NOT_SUPPORT,
        RT_STATUS_OS_API_FAILED,
-} RT_STATUS, *PRT_STATUS;
+};
 
 #ifdef REMOVE_PACK
 #pragma pack()
@@ -1316,26 +1255,26 @@ typedef enum _RT_STATUS {
 /* 3 BB Power Save */
 /* 3 =========================================================== */
 
-typedef enum tag_1R_CCA_Type_Definition {
+enum dm_1r_cca_e { /* tag_1R_CCA_Type_Definition */
        CCA_1R = 0,
        CCA_2R = 1,
        CCA_MAX = 2,
-} DM_1R_CCA_E;
+};
 
-typedef enum tag_RF_Type_Definition {
+enum dm_rf_e { /* tag_RF_Type_Definition */
        RF_Save = 0,
        RF_Normal = 1,
        RF_MAX = 2,
-} DM_RF_E;
+};
 
 /* 3 =========================================================== */
 /* 3 Antenna Diversity */
 /* 3 =========================================================== */
-typedef enum tag_SW_Antenna_Switch_Definition {
+enum dm_swas_e { /* tag_SW_Antenna_Switch_Definition */
        Antenna_A = 1,
        Antenna_B = 2,
        Antenna_MAX = 3,
-} DM_SWAS_E;
+};
 
 /*  Maximal number of antenna detection mechanism needs to perform, added by Roger, 2011.12.28. */
 #define        MAX_ANTENNA_DETECTION_CNT       10
@@ -1368,10 +1307,10 @@ extern  u32 TxScalingTable_Jaguar[TXSCALE_TABLE_SIZE];
 /* Remove BB power saving by Yuchen */
 
 #define dm_CheckTXPowerTracking ODM_TXPowerTrackingCheck
-void ODM_TXPowerTrackingCheck(PDM_ODM_T pDM_Odm);
+void ODM_TXPowerTrackingCheck(struct dm_odm_t *pDM_Odm);
 
 bool ODM_RAStateCheck(
-       PDM_ODM_T pDM_Odm,
+       struct dm_odm_t *pDM_Odm,
        s32     RSSI,
        bool bForceUpdate,
        u8 *pRATRState
@@ -1379,13 +1318,13 @@ bool ODM_RAStateCheck(
 
 #define dm_SWAW_RSSI_Check     ODM_SwAntDivChkPerPktRssi
 void ODM_SwAntDivChkPerPktRssi(
-       PDM_ODM_T pDM_Odm,
+       struct dm_odm_t *pDM_Odm,
        u8 StationID,
        struct odm_phy_info *pPhyInfo
 );
 
 u32 ODM_Get_Rate_Bitmap(
-       PDM_ODM_T pDM_Odm,
+       struct dm_odm_t *pDM_Odm,
        u32 macid,
        u32 ra_mask,
        u8 rssi_level
@@ -1395,38 +1334,38 @@ u32 ODM_Get_Rate_Bitmap(
 BEAMFORMING_CAP Beamforming_GetEntryBeamCapByMacId(PMGNT_INFO pMgntInfo, u8 MacId);
 #endif
 
-void odm_TXPowerTrackingInit(PDM_ODM_T pDM_Odm);
+void odm_TXPowerTrackingInit(struct dm_odm_t *pDM_Odm);
 
-void ODM_DMInit(PDM_ODM_T pDM_Odm);
+void ODM_DMInit(struct dm_odm_t *pDM_Odm);
 
-void ODM_DMWatchdog(PDM_ODM_T pDM_Odm); /*  For common use in the future */
+void ODM_DMWatchdog(struct dm_odm_t *pDM_Odm); /*  For common use in the future */
 
-void ODM_CmnInfoInit(PDM_ODM_T pDM_Odm, ODM_CMNINFO_E CmnInfo, u32 Value);
+void ODM_CmnInfoInit(struct dm_odm_t *pDM_Odm, enum odm_cmninfo_e CmnInfo, u32 Value);
 
-void ODM_CmnInfoHook(PDM_ODM_T pDM_Odm, ODM_CMNINFO_E CmnInfo, void *pValue);
+void ODM_CmnInfoHook(struct dm_odm_t *pDM_Odm, enum odm_cmninfo_e CmnInfo, void *pValue);
 
 void ODM_CmnInfoPtrArrayHook(
-       PDM_ODM_T pDM_Odm,
-       ODM_CMNINFO_E CmnInfo,
+       struct dm_odm_t *pDM_Odm,
+       enum odm_cmninfo_e CmnInfo,
        u16 Index,
        void *pValue
 );
 
-void ODM_CmnInfoUpdate(PDM_ODM_T pDM_Odm, u32 CmnInfo, u64 Value);
+void ODM_CmnInfoUpdate(struct dm_odm_t *pDM_Odm, u32 CmnInfo, u64 Value);
 
-void ODM_InitAllTimers(PDM_ODM_T pDM_Odm);
+void ODM_InitAllTimers(struct dm_odm_t *pDM_Odm);
 
-void ODM_CancelAllTimers(PDM_ODM_T pDM_Odm);
+void ODM_CancelAllTimers(struct dm_odm_t *pDM_Odm);
 
-void ODM_ReleaseAllTimers(PDM_ODM_T pDM_Odm);
+void ODM_ReleaseAllTimers(struct dm_odm_t *pDM_Odm);
 
 void ODM_AntselStatistics_88C(
-       PDM_ODM_T pDM_Odm,
+       struct dm_odm_t *pDM_Odm,
        u8 MacId,
        u32 PWDBAll,
        bool isCCKrate
 );
 
-void ODM_DynamicARFBSelect(PDM_ODM_T pDM_Odm, u8 rate, bool Collision_State);
+void ODM_DynamicARFBSelect(struct dm_odm_t *pDM_Odm, u8 rate, bool Collision_State);
 
 #endif
index 3ea1972545e5bd71b3e76993eaf6c4162929ed37..75471c6c168e7e888b551d08444ca1950a10969b 100644 (file)
@@ -9,8 +9,8 @@
 
 static void odm_SetCrystalCap(void *pDM_VOID, u8 CrystalCap)
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
-       PCFO_TRACKING pCfoTrack = &pDM_Odm->DM_CfoTrack;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
+       struct cfo_tracking *pCfoTrack = &pDM_Odm->DM_CfoTrack;
 
        if (pCfoTrack->CrystalCap == CrystalCap)
                return;
@@ -39,7 +39,7 @@ static void odm_SetCrystalCap(void *pDM_VOID, u8 CrystalCap)
 
 static u8 odm_GetDefaultCrytaltalCap(void *pDM_VOID)
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
 
        struct adapter *Adapter = pDM_Odm->Adapter;
        struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
@@ -49,8 +49,8 @@ static u8 odm_GetDefaultCrytaltalCap(void *pDM_VOID)
 
 static void odm_SetATCStatus(void *pDM_VOID, bool ATCStatus)
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
-       PCFO_TRACKING pCfoTrack = &pDM_Odm->DM_CfoTrack;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
+       struct cfo_tracking *pCfoTrack = &pDM_Odm->DM_CfoTrack;
 
        if (pCfoTrack->bATCStatus == ATCStatus)
                return;
@@ -67,7 +67,7 @@ static void odm_SetATCStatus(void *pDM_VOID, bool ATCStatus)
 static bool odm_GetATCStatus(void *pDM_VOID)
 {
        bool ATCStatus;
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
 
        ATCStatus = (bool)PHY_QueryBBReg(
                pDM_Odm->Adapter,
@@ -79,8 +79,8 @@ static bool odm_GetATCStatus(void *pDM_VOID)
 
 void ODM_CfoTrackingReset(void *pDM_VOID)
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
-       PCFO_TRACKING pCfoTrack = &pDM_Odm->DM_CfoTrack;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
+       struct cfo_tracking *pCfoTrack = &pDM_Odm->DM_CfoTrack;
 
        pCfoTrack->DefXCap = odm_GetDefaultCrytaltalCap(pDM_Odm);
        pCfoTrack->bAdjust = true;
@@ -91,8 +91,8 @@ void ODM_CfoTrackingReset(void *pDM_VOID)
 
 void ODM_CfoTrackingInit(void *pDM_VOID)
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
-       PCFO_TRACKING pCfoTrack = &pDM_Odm->DM_CfoTrack;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
+       struct cfo_tracking *pCfoTrack = &pDM_Odm->DM_CfoTrack;
 
        pCfoTrack->DefXCap =
                pCfoTrack->CrystalCap = odm_GetDefaultCrytaltalCap(pDM_Odm);
@@ -118,8 +118,8 @@ void ODM_CfoTrackingInit(void *pDM_VOID)
 
 void ODM_CfoTracking(void *pDM_VOID)
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
-       PCFO_TRACKING pCfoTrack = &pDM_Odm->DM_CfoTrack;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
+       struct cfo_tracking *pCfoTrack = &pDM_Odm->DM_CfoTrack;
        int CFO_kHz_A, CFO_kHz_B, CFO_ave = 0;
        int CFO_ave_diff;
        int CrystalCap = (int)pCfoTrack->CrystalCap;
@@ -297,9 +297,9 @@ void ODM_CfoTracking(void *pDM_VOID)
 
 void ODM_ParsingCFO(void *pDM_VOID, void *pPktinfo_VOID, s8 *pcfotail)
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
        struct odm_packet_info *pPktinfo = pPktinfo_VOID;
-       PCFO_TRACKING pCfoTrack = &pDM_Odm->DM_CfoTrack;
+       struct cfo_tracking *pCfoTrack = &pDM_Odm->DM_CfoTrack;
        u8 i;
 
        if (!(pDM_Odm->SupportAbility & ODM_BB_CFO_TRACKING))
index 81db63efe286c4a730bd3717e8c6017417f623a9..bb00d8c893bdf4485d5fff369738e145a80c5035 100644 (file)
@@ -12,7 +12,7 @@
 #define                CFO_TH_XTAL_LOW                 10              /*  kHz */
 #define                CFO_TH_ATC                      80              /*  kHz */
 
-typedef struct _CFO_TRACKING_ {
+struct cfo_tracking {
        bool bATCStatus;
        bool largeCFOHit;
        bool bAdjust;
@@ -25,7 +25,7 @@ typedef struct _CFO_TRACKING_ {
 
        bool bForceXtalCap;
        bool bReset;
-} CFO_TRACKING, *PCFO_TRACKING;
+};
 
 void ODM_CfoTrackingReset(void *pDM_VOID
 );
index 40fe43c62c45d9f5d1534244de97ada6fe0247e5..dcef7fb17389db7d089c5984d86e909d4d102149 100644 (file)
@@ -11,7 +11,7 @@
 
 void odm_NHMCounterStatisticsInit(void *pDM_VOID)
 {
-       PDM_ODM_T               pDM_Odm = (PDM_ODM_T)pDM_VOID;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
 
        /* PHY parameters initialize for n series */
        rtw_write16(pDM_Odm->Adapter, ODM_REG_NHM_TIMER_11N+2, 0x2710); /* 0x894[31:16]= 0x2710 Time duration for NHM unit: 4us, 0x2710 =40ms */
@@ -27,7 +27,7 @@ void odm_NHMCounterStatisticsInit(void *pDM_VOID)
 
 void odm_NHMCounterStatistics(void *pDM_VOID)
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
 
        /*  Get NHM report */
        odm_GetNHMCounterStatistics(pDM_Odm);
@@ -38,7 +38,7 @@ void odm_NHMCounterStatistics(void *pDM_VOID)
 
 void odm_GetNHMCounterStatistics(void *pDM_VOID)
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
        u32 value32 = 0;
 
        value32 = PHY_QueryBBReg(pDM_Odm->Adapter, ODM_REG_NHM_CNT_11N, bMaskDWord);
@@ -48,7 +48,7 @@ void odm_GetNHMCounterStatistics(void *pDM_VOID)
 
 void odm_NHMCounterStatisticsReset(void *pDM_VOID)
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
 
        PHY_SetBBReg(pDM_Odm->Adapter, ODM_REG_NHM_TH9_TH10_11N, BIT1, 0);
        PHY_SetBBReg(pDM_Odm->Adapter, ODM_REG_NHM_TH9_TH10_11N, BIT1, 1);
@@ -56,7 +56,7 @@ void odm_NHMCounterStatisticsReset(void *pDM_VOID)
 
 void odm_NHMBBInit(void *pDM_VOID)
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
 
        pDM_Odm->adaptivity_flag = 0;
        pDM_Odm->tolerance_cnt = 3;
@@ -69,9 +69,9 @@ void odm_NHMBBInit(void *pDM_VOID)
 /*  */
 void odm_NHMBB(void *pDM_VOID)
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
        /* u8 test_status; */
-       /* Pfalse_ALARM_STATISTICS pFalseAlmCnt = &(pDM_Odm->FalseAlmCnt); */
+       /* struct false_ALARM_STATISTICS *pFalseAlmCnt = &pDM_Odm->FalseAlmCnt; */
 
        pDM_Odm->NHMCurTxOkcnt =
                *(pDM_Odm->pNumTxBytesUnicast)-pDM_Odm->NHMLastTxOkcnt;
@@ -133,7 +133,7 @@ void odm_NHMBB(void *pDM_VOID)
 
 void odm_SearchPwdBLowerBound(void *pDM_VOID, u8 IGI_target)
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
        u32 value32 = 0;
        u8 cnt, IGI;
        bool bAdjust = true;
@@ -205,7 +205,7 @@ void odm_SearchPwdBLowerBound(void *pDM_VOID, u8 IGI_target)
 
 void odm_AdaptivityInit(void *pDM_VOID)
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
 
        if (pDM_Odm->Carrier_Sense_enable == false)
                pDM_Odm->TH_L2H_ini = 0xf7; /*  -7 */
@@ -233,7 +233,7 @@ void odm_AdaptivityInit(void *pDM_VOID)
 
 void odm_Adaptivity(void *pDM_VOID, u8 IGI)
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
        s8 TH_L2H_dmc, TH_H2L_dmc;
        s8 Diff, IGI_target;
        bool EDCCA_State = false;
@@ -322,8 +322,8 @@ void odm_Adaptivity(void *pDM_VOID, u8 IGI)
 
 void ODM_Write_DIG(void *pDM_VOID, u8 CurrentIGI)
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
-       pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
+       struct dig_t *pDM_DigTable = &pDM_Odm->DM_DigTable;
 
        if (pDM_DigTable->bStopDIG) {
                ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("Stop Writing IGI\n"));
@@ -358,12 +358,12 @@ void ODM_Write_DIG(void *pDM_VOID, u8 CurrentIGI)
 
 void odm_PauseDIG(
        void *pDM_VOID,
-       ODM_Pause_DIG_TYPE PauseType,
+       enum ODM_Pause_DIG_TYPE PauseType,
        u8 IGIValue
 )
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
-       pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
+       struct dig_t *pDM_DigTable = &pDM_Odm->DM_DigTable;
        static bool bPaused;
 
        ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_PauseDIG() =========>\n"));
@@ -435,7 +435,7 @@ void odm_PauseDIG(
 
 bool odm_DigAbort(void *pDM_VOID)
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
 
        /* SupportAbility */
        if (!(pDM_Odm->SupportAbility & ODM_BB_FA_CNT)) {
@@ -466,8 +466,8 @@ bool odm_DigAbort(void *pDM_VOID)
 
 void odm_DIGInit(void *pDM_VOID)
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
-       pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
+       struct dig_t *pDM_DigTable = &pDM_Odm->DM_DigTable;
 
        pDM_DigTable->bStopDIG = false;
        pDM_DigTable->bPSDInProgress = false;
@@ -504,11 +504,11 @@ void odm_DIGInit(void *pDM_VOID)
 
 void odm_DIG(void *pDM_VOID)
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
 
        /*  Common parameters */
-       pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable;
-       Pfalse_ALARM_STATISTICS pFalseAlmCnt = &pDM_Odm->FalseAlmCnt;
+       struct dig_t *pDM_DigTable = &pDM_Odm->DM_DigTable;
+       struct false_ALARM_STATISTICS *pFalseAlmCnt = &pDM_Odm->FalseAlmCnt;
        bool FirstConnect, FirstDisConnect;
        u8 DIG_MaxOfMin, DIG_Dynamic_MIN;
        u8 dm_dig_max, dm_dig_min;
@@ -823,8 +823,8 @@ void odm_DIG(void *pDM_VOID)
 
 void odm_DIGbyRSSI_LPS(void *pDM_VOID)
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
-       Pfalse_ALARM_STATISTICS pFalseAlmCnt = &pDM_Odm->FalseAlmCnt;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
+       struct false_ALARM_STATISTICS *pFalseAlmCnt = &pDM_Odm->FalseAlmCnt;
 
        u8 RSSI_Lower = DM_DIG_MIN_NIC;   /* 0x1E or 0x1C */
        u8 CurrentIGI = pDM_Odm->RSSI_Min;
@@ -892,8 +892,8 @@ void odm_DIGbyRSSI_LPS(void *pDM_VOID)
 
 void odm_FalseAlarmCounterStatistics(void *pDM_VOID)
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
-       Pfalse_ALARM_STATISTICS FalseAlmCnt = &(pDM_Odm->FalseAlmCnt);
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
+       struct false_ALARM_STATISTICS *FalseAlmCnt = &pDM_Odm->FalseAlmCnt;
        u32 ret_value;
 
        if (!(pDM_Odm->SupportAbility & ODM_BB_FA_CNT))
@@ -1062,7 +1062,7 @@ void odm_FAThresholdCheck(
        u32 *dm_FA_thres
 )
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
 
        if (pDM_Odm->bLinked && (bPerformance || bDFSBand)) {
                /*  For NIC */
@@ -1078,9 +1078,9 @@ void odm_FAThresholdCheck(
 
 u8 odm_ForbiddenIGICheck(void *pDM_VOID, u8 DIG_Dynamic_MIN, u8 CurrentIGI)
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
-       pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable;
-       Pfalse_ALARM_STATISTICS pFalseAlmCnt = &(pDM_Odm->FalseAlmCnt);
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
+       struct dig_t *pDM_DigTable = &pDM_Odm->DM_DigTable;
+       struct false_ALARM_STATISTICS *pFalseAlmCnt = &pDM_Odm->FalseAlmCnt;
        u8 rx_gain_range_min = pDM_DigTable->rx_gain_range_min;
 
        if (pFalseAlmCnt->Cnt_all > 10000) {
@@ -1134,8 +1134,8 @@ u8 odm_ForbiddenIGICheck(void *pDM_VOID, u8 DIG_Dynamic_MIN, u8 CurrentIGI)
 
 void odm_CCKPacketDetectionThresh(void *pDM_VOID)
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
-       Pfalse_ALARM_STATISTICS FalseAlmCnt = &(pDM_Odm->FalseAlmCnt);
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
+       struct false_ALARM_STATISTICS *FalseAlmCnt = &pDM_Odm->FalseAlmCnt;
        u8 CurCCK_CCAThres;
 
 
@@ -1195,8 +1195,8 @@ void odm_CCKPacketDetectionThresh(void *pDM_VOID)
 
 void ODM_Write_CCK_CCA_Thres(void *pDM_VOID, u8 CurCCK_CCAThres)
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
-       pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
+       struct dig_t *pDM_DigTable = &pDM_Odm->DM_DigTable;
 
        /* modify by Guo.Mingzhi 2012-01-03 */
        if (pDM_DigTable->CurCCK_CCAThres != CurCCK_CCAThres)
index f6777e97a24a27a2510a8344429028520cd5a3f8..20d4b88da9ffc9dc211fef82073b046c41eac907 100644 (file)
@@ -8,7 +8,7 @@
 #ifndef __ODMDIG_H__
 #define __ODMDIG_H__
 
-typedef struct _Dynamic_Initial_Gain_Threshold_ {
+struct dig_t { /* _Dynamic_Initial_Gain_Threshold_ */
        bool bStopDIG;
        bool bPSDInProgress;
 
@@ -57,9 +57,9 @@ typedef struct _Dynamic_Initial_Gain_Threshold_ {
        u32 RSSI_max;
 
        u8 *pbP2pLinkInProgress;
-} DIG_T, *pDIG_T;
+};
 
-typedef struct false_ALARM_STATISTICS {
+struct  false_ALARM_STATISTICS {
        u32 Cnt_Parity_Fail;
        u32 Cnt_Rate_Illegal;
        u32 Cnt_Crc8_fail;
@@ -75,9 +75,9 @@ typedef struct false_ALARM_STATISTICS {
        u32 Cnt_CCA_all;
        u32 Cnt_BW_USC; /* Gary */
        u32 Cnt_BW_LSC; /* Gary */
-} false_ALARM_STATISTICS, *Pfalse_ALARM_STATISTICS;
+};
 
-typedef enum tag_Dynamic_Init_Gain_Operation_Type_Definition {
+enum dm_dig_op_e { /* tag_Dynamic_Init_Gain_Operation_Type_Definition */
        DIG_TYPE_THRESH_HIGH = 0,
        DIG_TYPE_THRESH_LOW = 1,
        DIG_TYPE_BACKOFF = 2,
@@ -86,17 +86,17 @@ typedef enum tag_Dynamic_Init_Gain_Operation_Type_Definition {
        DIG_TYPE_ENABLE = 5,
        DIG_TYPE_DISABLE = 6,
        DIG_OP_TYPE_MAX
-} DM_DIG_OP_E;
+};
 
-typedef enum tag_ODM_PauseDIG_Type {
+enum ODM_Pause_DIG_TYPE {
        ODM_PAUSE_DIG = BIT0,
        ODM_RESUME_DIG = BIT1
-} ODM_Pause_DIG_TYPE;
+};
 
-typedef enum tag_ODM_PauseCCKPD_Type {
+enum ODM_Pause_CCKPD_TYPE {
        ODM_PAUSE_CCKPD = BIT0,
        ODM_RESUME_CCKPD = BIT1
-} ODM_Pause_CCKPD_TYPE;
+};
 
 #define                DM_DIG_THRESH_HIGH                      40
 #define                DM_DIG_THRESH_LOW                       35
@@ -157,7 +157,7 @@ void odm_Adaptivity(void *pDM_VOID, u8 IGI);
 
 void ODM_Write_DIG(void *pDM_VOID, u8 CurrentIGI);
 
-void odm_PauseDIG(void *pDM_VOID, ODM_Pause_DIG_TYPE PauseType, u8 IGIValue);
+void odm_PauseDIG(void *pDM_VOID, enum ODM_Pause_DIG_TYPE PauseType, u8 IGIValue);
 
 void odm_DIGInit(void *pDM_VOID);
 
index e18c9d65eee2b88f80369923af9007ff25725a7a..57c5736527d2fd7225d21c6c88b72b373174dd0d 100644 (file)
@@ -9,8 +9,8 @@
 
 void odm_DynamicBBPowerSavingInit(void *pDM_VOID)
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
-       pPS_T pDM_PSTable = &pDM_Odm->DM_PSTable;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
+       struct ps_t *pDM_PSTable = &pDM_Odm->DM_PSTable;
 
        pDM_PSTable->PreCCAState = CCA_MAX;
        pDM_PSTable->CurCCAState = CCA_MAX;
@@ -22,8 +22,8 @@ void odm_DynamicBBPowerSavingInit(void *pDM_VOID)
 
 void ODM_RF_Saving(void *pDM_VOID, u8 bForceInNormal)
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
-       pPS_T pDM_PSTable = &pDM_Odm->DM_PSTable;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
+       struct ps_t *pDM_PSTable = &pDM_Odm->DM_PSTable;
        u8 Rssi_Up_bound = 30;
        u8 Rssi_Low_bound = 25;
 
index dba19271d526c7921685b856d7de9e3ed83b0de9..3ebbbfd1dd1fe95c7f33e36698cf774723b5f38a 100644 (file)
@@ -8,7 +8,7 @@
 #ifndef        __ODMDYNAMICBBPOWERSAVING_H__
 #define    __ODMDYNAMICBBPOWERSAVING_H__
 
-typedef struct _Dynamic_Power_Saving_ {
+struct ps_t { /* _Dynamic_Power_Saving_ */
        u8 PreCCAState;
        u8 CurCCAState;
 
@@ -20,7 +20,7 @@ typedef struct _Dynamic_Power_Saving_ {
        u8 initialize;
        u32 Reg874, RegC70, Reg85C, RegA74;
 
-} PS_T, *pPS_T;
+};
 
 #define dm_RF_Saving ODM_RF_Saving
 
index 17f90f4cc1ad7be04f31a0b61cf0a9b07e48b3e6..398dfa13449d0bf0296e496abda5428298a89c88 100644 (file)
@@ -9,7 +9,7 @@
 
 void odm_DynamicTxPowerInit(void *pDM_VOID)
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
 
        struct adapter *Adapter = pDM_Odm->Adapter;
        struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
index b7ebce7a6ff92947cb90d178a88fb36a08dbb069..12b37c17ea0c0d8cfed3fc6506a85c85fc305397 100644 (file)
@@ -31,7 +31,7 @@ static u32 edca_setting_DL[HT_IOT_PEER_MAX] = {
 
 void ODM_EdcaTurboInit(void *pDM_VOID)
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
        struct adapter *Adapter = pDM_Odm->Adapter;
 
        pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA = false;
@@ -58,7 +58,7 @@ void odm_EdcaTurboCheck(void *pDM_VOID)
         *  operate at the same time. In stage2/3, we need to prove universal
         *  interface and merge all HW dynamic mechanism.
         */
-       PDM_ODM_T               pDM_Odm = (PDM_ODM_T)pDM_VOID;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
 
        ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD,
                     ("odm_EdcaTurboCheck ========================>\n"));
@@ -73,7 +73,7 @@ void odm_EdcaTurboCheck(void *pDM_VOID)
 
 void odm_EdcaTurboCheckCE(void *pDM_VOID)
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
        struct adapter *Adapter = pDM_Odm->Adapter;
        struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(Adapter);
        struct recv_priv *precvpriv = &(Adapter->recvpriv);
index bc574d2ad0657ae72e517462adbb591b2ff21b7f..e9f9f07221f2d7aa24c86fb8b267c2484f1e7d7d 100644 (file)
@@ -8,12 +8,12 @@
 #ifndef __ODMEDCATURBOCHECK_H__
 #define __ODMEDCATURBOCHECK_H__
 
-typedef struct _EDCA_TURBO_ {
+struct edca_t { /* _EDCA_TURBO_ */
        bool bCurrentTurboEDCA;
        bool bIsCurRDLState;
 
        u32 prv_traffic_idx; /*  edca turbo */
-} EDCA_T, *pEDCA_T;
+};
 
 void odm_EdcaTurboCheck(void *pDM_VOID);
 void ODM_EdcaTurboInit(void *pDM_VOID);
index 9c190b1024d8a7f59972d36acc47d3bf2155617c..638c16f5c66890cc51e5c1faf657a0e6213f1519 100644 (file)
@@ -23,7 +23,7 @@ static u8 odm_QueryRxPwrPercentage(s8 AntPower)
 
 }
 
-s32 odm_SignalScaleMapping(PDM_ODM_T pDM_Odm, s32 CurrSig)
+s32 odm_SignalScaleMapping(struct dm_odm_t *pDM_Odm, s32 CurrSig)
 {
        s32 RetSig = 0;
 
@@ -77,7 +77,7 @@ static u8 odm_EVMdbToPercentage(s8 Value)
 }
 
 static void odm_RxPhyStatus92CSeries_Parsing(
-       PDM_ODM_T pDM_Odm,
+       struct dm_odm_t *pDM_Odm,
        struct odm_phy_info *pPhyInfo,
        u8 *pPhyStatus,
        struct odm_packet_info *pPktinfo
@@ -90,7 +90,7 @@ static void odm_RxPhyStatus92CSeries_Parsing(
        bool isCCKrate = false;
        u8 rf_rx_num = 0;
        u8 LNA_idx, VGA_idx;
-       PPHY_STATUS_RPT_8192CD_T pPhyStaRpt = (PPHY_STATUS_RPT_8192CD_T)pPhyStatus;
+       struct phy_status_rpt_8192cd_t *pPhyStaRpt = (struct phy_status_rpt_8192cd_t *)pPhyStatus;
 
        isCCKrate = pPktinfo->data_rate <= DESC_RATE11M;
        pPhyInfo->rx_mimo_signal_quality[ODM_RF_PATH_A] = -1;
@@ -226,19 +226,10 @@ static void odm_RxPhyStatus92CSeries_Parsing(
        /* UI BSS List signal strength(in percentage), make it good looking, from 0~100. */
        /* It is assigned to the BSS List in GetValueFromBeaconOrProbeRsp(). */
        if (isCCKrate) {
-#ifdef CONFIG_SKIP_SIGNAL_SCALE_MAPPING
-               pPhyInfo->SignalStrength = (u8)PWDB_ALL;
-#else
                pPhyInfo->signal_strength = (u8)(odm_SignalScaleMapping(pDM_Odm, PWDB_ALL));/* PWDB_ALL; */
-#endif
        } else {
                if (rf_rx_num != 0) {
-#ifdef CONFIG_SKIP_SIGNAL_SCALE_MAPPING
-                       total_rssi /= rf_rx_num;
-                       pPhyInfo->signal_strength = (u8)total_rssi;
-#else
                        pPhyInfo->signal_strength = (u8)(odm_SignalScaleMapping(pDM_Odm, total_rssi /= rf_rx_num));
-#endif
                }
        }
 
@@ -247,7 +238,7 @@ static void odm_RxPhyStatus92CSeries_Parsing(
 }
 
 static void odm_Process_RSSIForDM(
-       PDM_ODM_T pDM_Odm, struct odm_phy_info *pPhyInfo, struct odm_packet_info *pPktinfo
+       struct dm_odm_t *pDM_Odm, struct odm_phy_info *pPhyInfo, struct odm_packet_info *pPktinfo
 )
 {
 
@@ -401,7 +392,7 @@ static void odm_Process_RSSIForDM(
 /*  Endianness before calling this API */
 /*  */
 static void ODM_PhyStatusQuery_92CSeries(
-       PDM_ODM_T pDM_Odm,
+       struct dm_odm_t *pDM_Odm,
        struct odm_phy_info *pPhyInfo,
        u8 *pPhyStatus,
        struct odm_packet_info *pPktinfo
@@ -415,7 +406,7 @@ static void ODM_PhyStatusQuery_92CSeries(
 }
 
 void ODM_PhyStatusQuery(
-       PDM_ODM_T pDM_Odm,
+       struct dm_odm_t *pDM_Odm,
        struct odm_phy_info *pPhyInfo,
        u8 *pPhyStatus,
        struct odm_packet_info *pPktinfo
@@ -430,10 +421,10 @@ void ODM_PhyStatusQuery(
 /*  */
 /*  */
 
-HAL_STATUS ODM_ConfigRFWithHeaderFile(
-       PDM_ODM_T pDM_Odm,
-       ODM_RF_Config_Type ConfigType,
-       ODM_RF_RADIO_PATH_E eRFPath
+enum hal_status ODM_ConfigRFWithHeaderFile(
+       struct dm_odm_t *pDM_Odm,
+       enum ODM_RF_Config_Type ConfigType,
+       enum odm_rf_radio_path_e eRFPath
 )
 {
        ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD,
@@ -450,7 +441,7 @@ HAL_STATUS ODM_ConfigRFWithHeaderFile(
        return HAL_STATUS_SUCCESS;
 }
 
-HAL_STATUS ODM_ConfigRFWithTxPwrTrackHeaderFile(PDM_ODM_T pDM_Odm)
+enum hal_status ODM_ConfigRFWithTxPwrTrackHeaderFile(struct dm_odm_t *pDM_Odm)
 {
        ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD,
                                 ("===>ODM_ConfigRFWithTxPwrTrackHeaderFile (%s)\n", (pDM_Odm->bIsMPChip) ? "MPChip" : "TestChip"));
@@ -464,8 +455,8 @@ HAL_STATUS ODM_ConfigRFWithTxPwrTrackHeaderFile(PDM_ODM_T pDM_Odm)
        return HAL_STATUS_SUCCESS;
 }
 
-HAL_STATUS ODM_ConfigBBWithHeaderFile(
-       PDM_ODM_T pDM_Odm, ODM_BB_Config_Type ConfigType
+enum hal_status ODM_ConfigBBWithHeaderFile(
+       struct dm_odm_t *pDM_Odm, enum ODM_BB_Config_Type ConfigType
 )
 {
        ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD,
index 945366bc37ce051d274ee4d26b780a5604c3361d..574f9cfe81900e13521e4671cf840f8ccca543ab 100644 (file)
 /*  structure and define */
 /*  */
 
-typedef struct _Phy_Rx_AGC_Info {
+struct phy_rx_agc_info_t {
        #if (ODM_ENDIAN_TYPE == ODM_ENDIAN_LITTLE)
                u8 gain:7, trsw:1;
        #else
                u8 trsw:1, gain:7;
        #endif
-} PHY_RX_AGC_INFO_T, *pPHY_RX_AGC_INFO_T;
+};
 
-typedef struct _Phy_Status_Rpt_8192cd {
-       PHY_RX_AGC_INFO_T path_agc[2];
+struct phy_status_rpt_8192cd_t {
+       struct phy_rx_agc_info_t path_agc[2];
        u8 ch_corr[2];
        u8 cck_sig_qual_ofdm_pwdb_all;
        u8 cck_agc_rpt_ofdm_cfosho_a;
@@ -74,79 +74,34 @@ typedef struct _Phy_Status_Rpt_8192cd {
        u8 sgi_en:1;
        u8 antsel_rx_keep_2:1;  /* ex_intf_flg:1; */
 #endif
-} PHY_STATUS_RPT_8192CD_T, *PPHY_STATUS_RPT_8192CD_T;
-
-
-typedef struct _Phy_Status_Rpt_8812 {
-       /* 2012.05.24 LukeLee: This structure should take big/little endian in consideration later..... */
-
-       /* DWORD 0 */
-       u8 gain_trsw[2];
-#if (ODM_ENDIAN_TYPE == ODM_ENDIAN_LITTLE)
-       u16 chl_num:10;
-       u16 sub_chnl:4;
-       u16 r_RFMOD:2;
-#else  /*  _BIG_ENDIAN_ */
-       u16 r_RFMOD:2;
-       u16 sub_chnl:4;
-       u16 chl_num:10;
-#endif
-
-       /* DWORD 1 */
-       u8 pwdb_all;
-       u8 cfosho[4];   /*  DW 1 byte 1 DW 2 byte 0 */
-
-       /* DWORD 2 */
-       s8 cfotail[4]; /*  DW 2 byte 1 DW 3 byte 0 */
-
-       /* DWORD 3 */
-       s8 rxevm[2]; /*  DW 3 byte 1 DW 3 byte 2 */
-       s8 rxsnr[2]; /*  DW 3 byte 3 DW 4 byte 0 */
-
-       /* DWORD 4 */
-       u8 PCTS_MSK_RPT[2];
-       u8 pdsnr[2]; /*  DW 4 byte 3 DW 5 Byte 0 */
-
-       /* DWORD 5 */
-       u8 csi_current[2];
-       u8 rx_gain_c;
-
-       /* DWORD 6 */
-       u8 rx_gain_d;
-       s8 sigevm;
-       u8 resvd_0;
-       u8 antidx_anta:3;
-       u8 antidx_antb:3;
-       u8 resvd_1:2;
-} PHY_STATUS_RPT_8812_T, *PPHY_STATUS_RPT_8812_T;
-
+};
 
 void ODM_PhyStatusQuery(
-       PDM_ODM_T pDM_Odm,
+       struct dm_odm_t *pDM_Odm,
        struct odm_phy_info *pPhyInfo,
        u8 *pPhyStatus,
        struct odm_packet_info *pPktinfo
 );
 
-HAL_STATUS ODM_ConfigRFWithTxPwrTrackHeaderFile(PDM_ODM_T pDM_Odm);
+enum hal_status ODM_ConfigRFWithTxPwrTrackHeaderFile(struct dm_odm_t *pDM_Odm);
 
-HAL_STATUS ODM_ConfigRFWithHeaderFile(
-       PDM_ODM_T pDM_Odm,
-       ODM_RF_Config_Type ConfigType,
-       ODM_RF_RADIO_PATH_E eRFPath
+enum hal_status ODM_ConfigRFWithHeaderFile(
+       struct dm_odm_t *pDM_Odm,
+       enum ODM_RF_Config_Type ConfigType,
+       enum odm_rf_radio_path_e eRFPath
 );
 
-HAL_STATUS ODM_ConfigBBWithHeaderFile(
-       PDM_ODM_T pDM_Odm, ODM_BB_Config_Type ConfigType
+enum hal_status ODM_ConfigBBWithHeaderFile(
+       struct dm_odm_t *pDM_Odm, enum ODM_BB_Config_Type ConfigType
 );
 
-HAL_STATUS ODM_ConfigFWWithHeaderFile(
-       PDM_ODM_T pDM_Odm,
-       ODM_FW_Config_Type ConfigType,
+enum hal_status ODM_ConfigFWWithHeaderFile(
+       struct dm_odm_t *pDM_Odm,
+       enum ODM_FW_Config_Type ConfigType,
        u8 *pFirmware,
        u32 *pSize
 );
 
-s32 odm_SignalScaleMapping(PDM_ODM_T pDM_Odm, s32 CurrSig);
+s32 odm_SignalScaleMapping(struct dm_odm_t *pDM_Odm, s32 CurrSig);
 
 #endif
index 6ca799816c08371e5ed5adfe09af77c1481c7c52..c3de123e2a487ed9a0d27ac2eb5cc71870e2581e 100644 (file)
@@ -19,7 +19,7 @@
 #define ValidCnt                               5
 
 static s16 odm_InbandNoise_Monitor_NSeries(
-       PDM_ODM_T pDM_Odm,
+       struct dm_odm_t *pDM_Odm,
        u8 bPauseDIG,
        u8 IGIValue,
        u32 max_time
index a7f13a85559c79dd943955f72f44e6547da75755..ab114543f39c3ff567e5dbdb4fa7deafd4b7d7eb 100644 (file)
@@ -24,10 +24,10 @@ struct noise_level {
 };
 
 
-typedef struct _ODM_NOISE_MONITOR_ {
+struct odm_noise_monitor {
        s8 noise[MAX_RF_PATH];
        s16 noise_all;
-} ODM_NOISE_MONITOR;
+};
 
 s16 ODM_InbandNoise_Monitor(
        void *pDM_VOID,
index 4d22360934f68a8a9eb7facf6ca437755658da3b..92b708265d4757e50f6c168c8ff38155f4290426 100644 (file)
@@ -9,7 +9,7 @@
 
 void odm_PathDiversityInit(void *pDM_VOID)
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
 
        if (!(pDM_Odm->SupportAbility & ODM_BB_PATH_DIV))
                ODM_RT_TRACE(
@@ -22,7 +22,7 @@ void odm_PathDiversityInit(void *pDM_VOID)
 
 void odm_PathDiversity(void *pDM_VOID)
 {
-       PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+       struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
 
        if (!(pDM_Odm->SupportAbility & ODM_BB_PATH_DIV))
                ODM_RT_TRACE(
index 39f989bf341078e77fdea5c1ee7b4e8567419e9b..63bf5ba3e0d5efec9b6d1d7ef5b21695a22db39b 100644 (file)
@@ -8,10 +8,10 @@
 #include "odm_precomp.h"
 
 void odm_ConfigRFReg_8723B(
-       PDM_ODM_T pDM_Odm,
+       struct dm_odm_t *pDM_Odm,
        u32 Addr,
        u32 Data,
-       ODM_RF_RADIO_PATH_E RF_PATH,
+       enum odm_rf_radio_path_e RF_PATH,
        u32 RegAddr
 )
 {
@@ -106,7 +106,7 @@ void odm_ConfigRFReg_8723B(
 }
 
 
-void odm_ConfigRF_RadioA_8723B(PDM_ODM_T pDM_Odm, u32 Addr, u32 Data)
+void odm_ConfigRF_RadioA_8723B(struct dm_odm_t *pDM_Odm, u32 Addr, u32 Data)
 {
        u32  content = 0x1000; /*  RF_Content: radioa_txt */
        u32 maskforPhySet = (u32)(content&0xE000);
@@ -131,7 +131,7 @@ void odm_ConfigRF_RadioA_8723B(PDM_ODM_T pDM_Odm, u32 Addr, u32 Data)
        );
 }
 
-void odm_ConfigMAC_8723B(PDM_ODM_T pDM_Odm, u32 Addr, u8 Data)
+void odm_ConfigMAC_8723B(struct dm_odm_t *pDM_Odm, u32 Addr, u8 Data)
 {
        rtw_write8(pDM_Odm->Adapter, Addr, Data);
        ODM_RT_TRACE(
@@ -147,7 +147,7 @@ void odm_ConfigMAC_8723B(PDM_ODM_T pDM_Odm, u32 Addr, u8 Data)
 }
 
 void odm_ConfigBB_AGC_8723B(
-       PDM_ODM_T pDM_Odm,
+       struct dm_odm_t *pDM_Odm,
        u32 Addr,
        u32 Bitmask,
        u32 Data
@@ -170,7 +170,7 @@ void odm_ConfigBB_AGC_8723B(
 }
 
 void odm_ConfigBB_PHY_REG_PG_8723B(
-       PDM_ODM_T pDM_Odm,
+       struct dm_odm_t *pDM_Odm,
        u32 Band,
        u32 RfPath,
        u32 TxNum,
@@ -198,7 +198,7 @@ void odm_ConfigBB_PHY_REG_PG_8723B(
 }
 
 void odm_ConfigBB_PHY_8723B(
-       PDM_ODM_T pDM_Odm,
+       struct dm_odm_t *pDM_Odm,
        u32 Addr,
        u32 Bitmask,
        u32 Data
@@ -226,7 +226,7 @@ void odm_ConfigBB_PHY_8723B(
 }
 
 void odm_ConfigBB_TXPWR_LMT_8723B(
-       PDM_ODM_T pDM_Odm,
+       struct dm_odm_t *pDM_Odm,
        u8 *Regulation,
        u8 *Band,
        u8 *Bandwidth,
index 07b585950cf96f561bfc8e7b7f2ae80683240b4b..b392d14c389d5dc79eabb4374efe33c46d6c8b7a 100644 (file)
@@ -7,24 +7,24 @@
 #ifndef __INC_ODM_REGCONFIG_H_8723B
 #define __INC_ODM_REGCONFIG_H_8723B
 
-void odm_ConfigRFReg_8723B(PDM_ODM_T pDM_Odm,
+void odm_ConfigRFReg_8723B(struct dm_odm_t *pDM_Odm,
                           u32 Addr,
                           u32 Data,
-                          ODM_RF_RADIO_PATH_E RF_PATH,
+                          enum odm_rf_radio_path_e RF_PATH,
                           u32 RegAddr
 );
 
-void odm_ConfigRF_RadioA_8723B(PDM_ODM_T pDM_Odm, u32 Addr, u32 Data);
+void odm_ConfigRF_RadioA_8723B(struct dm_odm_t *pDM_Odm, u32 Addr, u32 Data);
 
-void odm_ConfigMAC_8723B(PDM_ODM_T pDM_Odm, u32 Addr, u8 Data);
+void odm_ConfigMAC_8723B(struct dm_odm_t *pDM_Odm, u32 Addr, u8 Data);
 
-void odm_ConfigBB_AGC_8723B(PDM_ODM_T pDM_Odm,
+void odm_ConfigBB_AGC_8723B(struct dm_odm_t *pDM_Odm,
                            u32 Addr,
                            u32 Bitmask,
                            u32 Data
 );
 
-void odm_ConfigBB_PHY_REG_PG_8723B(PDM_ODM_T pDM_Odm,
+void odm_ConfigBB_PHY_REG_PG_8723B(struct dm_odm_t *pDM_Odm,
                                   u32 Band,
                                   u32 RfPath,
                                   u32 TxNum,
@@ -33,13 +33,13 @@ void odm_ConfigBB_PHY_REG_PG_8723B(PDM_ODM_T pDM_Odm,
                                   u32 Data
 );
 
-void odm_ConfigBB_PHY_8723B(PDM_ODM_T pDM_Odm,
+void odm_ConfigBB_PHY_8723B(struct dm_odm_t *pDM_Odm,
                            u32 Addr,
                            u32 Bitmask,
                            u32 Data
 );
 
-void odm_ConfigBB_TXPWR_LMT_8723B(PDM_ODM_T pDM_Odm,
+void odm_ConfigBB_TXPWR_LMT_8723B(struct dm_odm_t *pDM_Odm,
                                  u8 *Regulation,
                                  u8 *Band,
                                  u8 *Bandwidth,
index b92422c8fb8e4336910136c0544df7545182f696..b35451bcb437e728f2b13e8910b20c42c386c7b8 100644 (file)
@@ -7,7 +7,7 @@
 
 #include "odm_precomp.h"
 
-void ODM_InitDebugSetting(PDM_ODM_T pDM_Odm)
+void ODM_InitDebugSetting(struct dm_odm_t *pDM_Odm)
 {
        pDM_Odm->DebugLevel = ODM_DBG_LOUD;
 
index a7381173d1a3cb0701e591ca58c9bbf93a662812..be0d4c49a7477de9342571bdb91d18d60e802ec9 100644 (file)
                        ASSERT(false);\
                } \
        } while (0)
-#define ODM_dbg_enter() { DbgPrint("==> %s\n", __func__); }
-#define ODM_dbg_exit() { DbgPrint("<== %s\n", __func__); }
 #define ODM_dbg_trace(str) { DbgPrint("%s:%s\n", __func__, str); }
 
 #define ODM_PRINT_ADDR(pDM_Odm, comp, level, title_str, ptr)\
        no_printk("%s %p", title_str, ptr)
 #endif
 
-void ODM_InitDebugSetting(PDM_ODM_T pDM_Odm);
+void ODM_InitDebugSetting(struct dm_odm_t *pDM_Odm);
 
 #endif /*  __ODM_DBG_H__ */
index 63f374f0bda7bdb553fff9fbad88d97a11bbe314..8159bbd06c22dbd425cbc0852d4f72d4ad6ac55e 100644 (file)
@@ -39,13 +39,13 @@ ODM_REG(DIG, _pDM_Odm)
 #define ODM_REG(_name, _pDM_Odm)       _cat(_name, _pDM_Odm->SupportICType, _reg)
 #define ODM_BIT(_name, _pDM_Odm)       _cat(_name, _pDM_Odm->SupportICType, _bit)
 
-typedef enum _ODM_H2C_CMD {
+enum odm_h2c_cmd {
        ODM_H2C_RSSI_REPORT = 0,
        ODM_H2C_PSD_RESULT = 1,
        ODM_H2C_PathDiv = 2,
        ODM_H2C_WIFI_CALIBRATION = 3,
        ODM_MAX_H2CCMD
-} ODM_H2C_CMD;
+};
 
 
 #endif /*  __ODM_INTERFACE_H__ */
index c79fc1813c3fee0f344bb8eb17f93fe30e0052a9..0b1b3e14d451d1f5aa6d74d4114b62285a977d9a 100644 (file)
@@ -15,7 +15,7 @@
 
 #define GET_ODM(__padapter)    ((PDM_ODM_T)(&((GET_HAL_DATA(__padapter))->odmpriv)))
 
-typedef enum _HAL_STATUS {
+enum hal_status {
        HAL_STATUS_SUCCESS,
        HAL_STATUS_FAILURE,
        /*RT_STATUS_PENDING,
@@ -24,13 +24,13 @@ typedef enum _HAL_STATUS {
        RT_STATUS_INVALID_PARAMETER,
        RT_STATUS_NOT_SUPPORT,
        RT_STATUS_OS_API_FAILED,*/
-} HAL_STATUS, *PHAL_STATUS;
+};
 
 
 /*  */
 /*  Declare for ODM spin lock definition temporarily from compile pass. */
 /*  */
-typedef enum _RT_SPINLOCK_TYPE {
+enum rt_spinlock_type {
        RT_TX_SPINLOCK = 1,
        RT_RX_SPINLOCK = 2,
        RT_RM_SPINLOCK = 3,
@@ -66,7 +66,7 @@ typedef enum _RT_SPINLOCK_TYPE {
        RT_PENDED_OID_SPINLOCK = 39,
        RT_CHNLLIST_SPINLOCK = 40,
        RT_INDIC_SPINLOCK = 41, /* protect indication */
-} RT_SPINLOCK_TYPE;
+};
 
        #if defined(__LITTLE_ENDIAN)
                #define ODM_ENDIAN_TYPE                 ODM_ENDIAN_LITTLE
@@ -74,8 +74,6 @@ typedef enum _RT_SPINLOCK_TYPE {
                #define ODM_ENDIAN_TYPE                 ODM_ENDIAN_BIG
        #endif
 
-       typedef struct timer_list               RT_TIMER, *PRT_TIMER;
-       typedef  void *RT_TIMER_CALL_BACK;
        #define STA_INFO_T                      struct sta_info
        #define PSTA_INFO_T             struct sta_info *
 
index 86f31d98349abed01fad1969906f4586ec44220e..202974ccb7390bbce7fa686682e5ac237f3691ef 100644 (file)
@@ -31,10 +31,6 @@ static u8 _is_fw_read_cmd_down(struct adapter *padapter, u8 msgbox_num)
                if (0 == valid) {
                        read_down = true;
                }
-#ifdef CONFIG_WOWLAN
-               else
-                       msleep(1);
-#endif
        } while ((!read_down) && (retry_cnts--));
 
        return read_down;
@@ -316,513 +312,6 @@ static void ConstructNullFunctionData(
        *pLength = pktlen;
 }
 
-
-#ifdef CONFIG_WOWLAN
-/*  */
-/*  Description: */
-/*     Construct the ARP response packet to support ARP offload. */
-/*  */
-static void ConstructARPResponse(
-       struct adapter *padapter,
-       u8 *pframe,
-       u32 *pLength,
-       u8 *pIPAddress
-)
-{
-       struct ieee80211_hdr    *pwlanhdr;
-       __le16 *fctrl;
-       struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
-       struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
-       struct security_priv *psecuritypriv = &padapter->securitypriv;
-       static u8       ARPLLCHeader[8] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00, 0x08, 0x06};
-       u8              *pARPRspPkt = pframe;
-       /* for TKIP Cal MIC */
-       u8              *payload = pframe;
-       u8      EncryptionHeadOverhead = 0;
-       /* DBG_871X("%s:%d\n", __func__, bForcePowerSave); */
-
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *(fctrl) = 0;
-
-       /*  */
-       /*  MAC Header. */
-       /*  */
-       SetFrameType(fctrl, WIFI_DATA);
-       /* SetFrameSubType(fctrl, 0); */
-       SetToDs(fctrl);
-       memcpy(pwlanhdr->addr1, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN);
-       memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN);
-       memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN);
-
-       SetSeqNum(pwlanhdr, 0);
-       SetDuration(pwlanhdr, 0);
-       /* SET_80211_HDR_FRAME_CONTROL(pARPRspPkt, 0); */
-       /* SET_80211_HDR_TYPE_AND_SUBTYPE(pARPRspPkt, Type_Data); */
-       /* SET_80211_HDR_TO_DS(pARPRspPkt, 1); */
-       /* SET_80211_HDR_ADDRESS1(pARPRspPkt, pMgntInfo->Bssid); */
-       /* SET_80211_HDR_ADDRESS2(pARPRspPkt, Adapter->CurrentAddress); */
-       /* SET_80211_HDR_ADDRESS3(pARPRspPkt, pMgntInfo->Bssid); */
-
-       /* SET_80211_HDR_DURATION(pARPRspPkt, 0); */
-       /* SET_80211_HDR_FRAGMENT_SEQUENCE(pARPRspPkt, 0); */
-       *pLength = 24;
-
-       /*  */
-       /*  Security Header: leave space for it if necessary. */
-       /*  */
-
-       switch (psecuritypriv->dot11PrivacyAlgrthm) {
-       case _WEP40_:
-       case _WEP104_:
-               EncryptionHeadOverhead = 4;
-               break;
-       case _TKIP_:
-               EncryptionHeadOverhead = 8;
-               break;
-       case _AES_:
-               EncryptionHeadOverhead = 8;
-               break;
-       default:
-               EncryptionHeadOverhead = 0;
-       }
-
-       if (EncryptionHeadOverhead > 0) {
-               memset(&(pframe[*pLength]), 0, EncryptionHeadOverhead);
-               *pLength += EncryptionHeadOverhead;
-               SetPrivacy(fctrl);
-       }
-
-       /*  */
-       /*  Frame Body. */
-       /*  */
-       pARPRspPkt = (u8 *)(pframe + *pLength);
-       payload = pARPRspPkt; /* Get Payload pointer */
-       /*  LLC header */
-       memcpy(pARPRspPkt, ARPLLCHeader, 8);
-       *pLength += 8;
-
-       /*  ARP element */
-       pARPRspPkt += 8;
-       SET_ARP_PKT_HW(pARPRspPkt, 0x0100);
-       SET_ARP_PKT_PROTOCOL(pARPRspPkt, 0x0008);       /*  IP protocol */
-       SET_ARP_PKT_HW_ADDR_LEN(pARPRspPkt, 6);
-       SET_ARP_PKT_PROTOCOL_ADDR_LEN(pARPRspPkt, 4);
-       SET_ARP_PKT_OPERATION(pARPRspPkt, 0x0200); /*  ARP response */
-       SET_ARP_PKT_SENDER_MAC_ADDR(pARPRspPkt, myid(&(padapter->eeprompriv)));
-       SET_ARP_PKT_SENDER_IP_ADDR(pARPRspPkt, pIPAddress);
-       {
-               SET_ARP_PKT_TARGET_MAC_ADDR(pARPRspPkt, get_my_bssid(&(pmlmeinfo->network)));
-               SET_ARP_PKT_TARGET_IP_ADDR(pARPRspPkt, pIPAddress);
-               DBG_871X("%s Target Mac Addr:%pM\n", __func__, MAC_ARG(get_my_bssid(&(pmlmeinfo->network))));
-               DBG_871X("%s Target IP Addr:%pI4\n", __func__, IP_ARG(pIPAddress));
-       }
-
-       *pLength += 28;
-
-       if (psecuritypriv->dot11PrivacyAlgrthm == _TKIP_) {
-               u8 mic[8];
-               struct mic_data micdata;
-               struct sta_info *psta = NULL;
-               u8 priority[4] = {
-                       0x0, 0x0, 0x0, 0x0
-               };
-               u8 null_key[16] = {
-                       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-                       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
-               };
-
-               DBG_871X("%s(): Add MIC\n", __func__);
-
-               psta = rtw_get_stainfo(&padapter->stapriv, get_my_bssid(&(pmlmeinfo->network)));
-               if (psta) {
-                       if (!memcmp(&psta->dot11tkiptxmickey.skey[0], null_key, 16)) {
-                               DBG_871X("%s(): STA dot11tkiptxmickey == 0\n", __func__);
-                       }
-                       /* start to calculate the mic code */
-                       rtw_secmicsetkey(&micdata, &psta->dot11tkiptxmickey.skey[0]);
-               }
-
-               rtw_secmicappend(&micdata, pwlanhdr->addr3, 6);  /* DA */
-
-               rtw_secmicappend(&micdata, pwlanhdr->addr2, 6); /* SA */
-
-               priority[0] = 0;
-               rtw_secmicappend(&micdata, &priority[0], 4);
-
-               rtw_secmicappend(&micdata, payload, 36); /* payload length = 8 + 28 */
-
-               rtw_secgetmic(&micdata, &(mic[0]));
-
-               pARPRspPkt += 28;
-               memcpy(pARPRspPkt, &(mic[0]), 8);
-
-               *pLength += 8;
-       }
-}
-
-#ifdef CONFIG_PNO_SUPPORT
-static void ConstructPnoInfo(
-       struct adapter *padapter, u8 *pframe, u32 *pLength
-)
-{
-
-       struct pwrctrl_priv *pwrctl = adapter_to_pwrctl(padapter);
-
-       u8 *pPnoInfoPkt = pframe;
-       pPnoInfoPkt = (u8 *)(pframe + *pLength);
-       memcpy(pPnoInfoPkt, &pwrctl->pnlo_info->ssid_num, 4);
-
-       *pLength += 4;
-       pPnoInfoPkt += 4;
-       memcpy(pPnoInfoPkt, &pwrctl->pnlo_info->fast_scan_period, 4);
-
-       *pLength += 4;
-       pPnoInfoPkt += 4;
-       memcpy(pPnoInfoPkt, &pwrctl->pnlo_info->fast_scan_iterations, 4);
-
-       *pLength += 4;
-       pPnoInfoPkt += 4;
-       memcpy(pPnoInfoPkt, &pwrctl->pnlo_info->slow_scan_period, 4);
-
-       *pLength += 4;
-       pPnoInfoPkt += 4;
-       memcpy(pPnoInfoPkt, &pwrctl->pnlo_info->ssid_length,
-                       MAX_PNO_LIST_COUNT);
-
-       *pLength += MAX_PNO_LIST_COUNT;
-       pPnoInfoPkt += MAX_PNO_LIST_COUNT;
-       memcpy(pPnoInfoPkt, &pwrctl->pnlo_info->ssid_cipher_info,
-                       MAX_PNO_LIST_COUNT);
-
-       *pLength += MAX_PNO_LIST_COUNT;
-       pPnoInfoPkt += MAX_PNO_LIST_COUNT;
-       memcpy(pPnoInfoPkt, &pwrctl->pnlo_info->ssid_channel_info,
-                       MAX_PNO_LIST_COUNT);
-
-       *pLength += MAX_PNO_LIST_COUNT;
-       pPnoInfoPkt += MAX_PNO_LIST_COUNT;
-}
-
-static void ConstructSSIDList(
-       struct adapter *padapter, u8 *pframe, u32 *pLength
-)
-{
-       int i = 0;
-       u8 *pSSIDListPkt = pframe;
-       struct pwrctrl_priv *pwrctl = adapter_to_pwrctl(padapter);
-
-       pSSIDListPkt = (u8 *)(pframe + *pLength);
-
-       for (i = 0; i < pwrctl->pnlo_info->ssid_num ; i++) {
-               memcpy(pSSIDListPkt, &pwrctl->pno_ssid_list->node[i].SSID,
-                       pwrctl->pnlo_info->ssid_length[i]);
-
-               *pLength += WLAN_SSID_MAXLEN;
-               pSSIDListPkt += WLAN_SSID_MAXLEN;
-       }
-}
-
-static void ConstructScanInfo(
-       struct adapter *padapter, u8 *pframe, u32 *pLength
-)
-{
-       int i = 0;
-       u8 *pScanInfoPkt = pframe;
-       struct pwrctrl_priv *pwrctl = adapter_to_pwrctl(padapter);
-
-       pScanInfoPkt = (u8 *)(pframe + *pLength);
-
-       memcpy(pScanInfoPkt, &pwrctl->pscan_info->channel_num, 1);
-
-       *pLength += 1;
-       pScanInfoPkt += 1;
-       memcpy(pScanInfoPkt, &pwrctl->pscan_info->orig_ch, 1);
-
-
-       *pLength += 1;
-       pScanInfoPkt += 1;
-       memcpy(pScanInfoPkt, &pwrctl->pscan_info->orig_bw, 1);
-
-
-       *pLength += 1;
-       pScanInfoPkt += 1;
-       memcpy(pScanInfoPkt, &pwrctl->pscan_info->orig_40_offset, 1);
-
-       *pLength += 1;
-       pScanInfoPkt += 1;
-       memcpy(pScanInfoPkt, &pwrctl->pscan_info->orig_80_offset, 1);
-
-       *pLength += 1;
-       pScanInfoPkt += 1;
-       memcpy(pScanInfoPkt, &pwrctl->pscan_info->periodScan, 1);
-
-       *pLength += 1;
-       pScanInfoPkt += 1;
-       memcpy(pScanInfoPkt, &pwrctl->pscan_info->period_scan_time, 1);
-
-       *pLength += 1;
-       pScanInfoPkt += 1;
-       memcpy(pScanInfoPkt, &pwrctl->pscan_info->enableRFE, 1);
-
-       *pLength += 1;
-       pScanInfoPkt += 1;
-       memcpy(pScanInfoPkt, &pwrctl->pscan_info->rfe_type, 8);
-
-       *pLength += 8;
-       pScanInfoPkt += 8;
-
-       for (i = 0; i < MAX_SCAN_LIST_COUNT; i++) {
-               memcpy(pScanInfoPkt, &pwrctl->pscan_info->ssid_channel_info[i], 4);
-               *pLength += 4;
-               pScanInfoPkt += 4;
-       }
-}
-#endif
-
-#ifdef CONFIG_GTK_OL
-static void ConstructGTKResponse(
-       struct adapter *padapter, u8 *pframe, u32 *pLength
-)
-{
-       struct ieee80211_hdr *pwlanhdr;
-       u16 *fctrl;
-       struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
-       struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
-       struct security_priv *psecuritypriv = &padapter->securitypriv;
-       static u8 LLCHeader[8] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00, 0x88, 0x8E};
-       static u8 GTKbody_a[11] = {0x01, 0x03, 0x00, 0x5F, 0x02, 0x03, 0x12, 0x00, 0x10, 0x42, 0x0B};
-       u8 *pGTKRspPkt = pframe;
-       u8 EncryptionHeadOverhead = 0;
-       /* DBG_871X("%s:%d\n", __func__, bForcePowerSave); */
-
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       fctrl = &pwlanhdr->frame_control;
-       *(fctrl) = 0;
-
-       /*  */
-       /*  MAC Header. */
-       /*  */
-       SetFrameType(fctrl, WIFI_DATA);
-       /* SetFrameSubType(fctrl, 0); */
-       SetToDs(fctrl);
-       memcpy(pwlanhdr->addr1, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN);
-       memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN);
-       memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN);
-
-       SetSeqNum(pwlanhdr, 0);
-       SetDuration(pwlanhdr, 0);
-
-       *pLength = 24;
-
-       /*  */
-       /*  Security Header: leave space for it if necessary. */
-       /*  */
-
-       switch (psecuritypriv->dot11PrivacyAlgrthm) {
-       case _WEP40_:
-       case _WEP104_:
-               EncryptionHeadOverhead = 4;
-               break;
-       case _TKIP_:
-               EncryptionHeadOverhead = 8;
-               break;
-       case _AES_:
-               EncryptionHeadOverhead = 8;
-               break;
-       default:
-               EncryptionHeadOverhead = 0;
-       }
-
-       if (EncryptionHeadOverhead > 0) {
-               memset(&(pframe[*pLength]), 0, EncryptionHeadOverhead);
-               *pLength += EncryptionHeadOverhead;
-               /* GTK's privacy bit is done by FW */
-               /* SetPrivacy(fctrl); */
-       }
-
-       /*  */
-       /*  Frame Body. */
-       /*  */
-       pGTKRspPkt =  (u8 *)(pframe + *pLength);
-       /*  LLC header */
-       memcpy(pGTKRspPkt, LLCHeader, 8);
-       *pLength += 8;
-
-       /*  GTK element */
-       pGTKRspPkt += 8;
-
-       /* GTK frame body after LLC, part 1 */
-       memcpy(pGTKRspPkt, GTKbody_a, 11);
-       *pLength += 11;
-       pGTKRspPkt += 11;
-       /* GTK frame body after LLC, part 2 */
-       memset(&(pframe[*pLength]), 0, 88);
-       *pLength += 88;
-       pGTKRspPkt += 88;
-
-}
-#endif /* CONFIG_GTK_OL */
-
-#ifdef CONFIG_PNO_SUPPORT
-static void ConstructProbeReq(struct adapter *padapter, u8 *pframe, u32 *pLength)
-{
-       struct ieee80211_hdr *pwlanhdr;
-       u16 *fctrl;
-       u32 pktlen;
-       unsigned char *mac;
-       unsigned char bssrate[NumRates];
-       int bssrate_len = 0;
-       u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-       mac = myid(&(padapter->eeprompriv));
-
-       fctrl = &(pwlanhdr->frame_control);
-       *(fctrl) = 0;
-
-       /* broadcast probe request frame */
-       memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN);
-       memcpy(pwlanhdr->addr3, bc_addr, ETH_ALEN);
-
-       memcpy(pwlanhdr->addr2, mac, ETH_ALEN);
-
-       SetSeqNum(pwlanhdr, 0);
-       SetFrameSubType(pframe, WIFI_PROBEREQ);
-
-       pktlen = sizeof(struct ieee80211_hdr_3addr);
-       pframe += pktlen;
-
-       pframe = rtw_set_ie(pframe, WLAN_EID_SSID, 0, NULL, &pktlen);
-
-       get_rate_set(padapter, bssrate, &bssrate_len);
-
-       if (bssrate_len > 8) {
-               pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, 8, bssrate, &pktlen);
-               pframe = rtw_set_ie(pframe, WLAN_EID_EXT_SUPP_RATES, (bssrate_len - 8), (bssrate + 8), &pktlen);
-       } else
-               pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, bssrate_len, bssrate, &pktlen);
-
-       *pLength = pktlen;
-}
-#endif /* CONFIG_PNO_SUPPORT */
-#endif /* CONFIG_WOWLAN */
-
-#ifdef CONFIG_AP_WOWLAN
-static void ConstructProbeRsp(struct adapter *padapter, u8 *pframe, u32 *pLength, u8 *StaAddr, bool bHideSSID)
-{
-       struct ieee80211_hdr *pwlanhdr;
-       u16 *fctrl;
-       u8 *mac, *bssid;
-       u32 pktlen;
-       struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
-       struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
-       struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network);
-       u8 *pwps_ie;
-       uint wps_ielen;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-
-       /* DBG_871X("%s\n", __func__); */
-
-       pwlanhdr = (struct ieee80211_hdr *)pframe;
-
-       mac = myid(&(padapter->eeprompriv));
-       bssid = cur_network->MacAddress;
-
-       fctrl = &(pwlanhdr->frame_control);
-       *(fctrl) = 0;
-       memcpy(pwlanhdr->addr1, StaAddr, ETH_ALEN);
-       memcpy(pwlanhdr->addr2, mac, ETH_ALEN);
-       memcpy(pwlanhdr->addr3, bssid, ETH_ALEN);
-
-       DBG_871X("%s FW Mac Addr:%pM\n", __func__, MAC_ARG(mac));
-       DBG_871X("%s FW IP Addr:%pI4\n", __func__, IP_ARG(StaAddr));
-
-       SetSeqNum(pwlanhdr, 0);
-       SetFrameSubType(fctrl, WIFI_PROBERSP);
-
-       pktlen = sizeof(struct ieee80211_hdr_3addr);
-       pframe += pktlen;
-
-       if (cur_network->IELength > MAX_IE_SZ)
-               return;
-
-       pwps_ie = rtw_get_wps_ie(cur_network->IEs+_FIXED_IE_LENGTH_,
-                       cur_network->IELength-_FIXED_IE_LENGTH_, NULL, &wps_ielen);
-
-       /* inerset & update wps_probe_resp_ie */
-       if (pmlmepriv->wps_probe_resp_ie && pwps_ie && (wps_ielen > 0)) {
-               uint wps_offset, remainder_ielen;
-               u8 *premainder_ie;
-
-               wps_offset = (uint)(pwps_ie - cur_network->IEs);
-
-               premainder_ie = pwps_ie + wps_ielen;
-
-               remainder_ielen = cur_network->IELength - wps_offset - wps_ielen;
-
-               memcpy(pframe, cur_network->IEs, wps_offset);
-               pframe += wps_offset;
-               pktlen += wps_offset;
-
-               wps_ielen = (uint)pmlmepriv->wps_probe_resp_ie[1];/* to get ie data len */
-               if ((wps_offset+wps_ielen+2) <= MAX_IE_SZ) {
-                       memcpy(pframe, pmlmepriv->wps_probe_resp_ie, wps_ielen+2);
-                       pframe += wps_ielen+2;
-                       pktlen += wps_ielen+2;
-               }
-
-               if ((wps_offset+wps_ielen+2+remainder_ielen) <= MAX_IE_SZ) {
-                       memcpy(pframe, premainder_ie, remainder_ielen);
-                       pframe += remainder_ielen;
-                       pktlen += remainder_ielen;
-               }
-       } else {
-               memcpy(pframe, cur_network->IEs, cur_network->IELength);
-               pframe += cur_network->IELength;
-               pktlen += cur_network->IELength;
-       }
-
-       /* retrieve SSID IE from cur_network->Ssid */
-       {
-               u8 *ssid_ie;
-               sint ssid_ielen;
-               sint ssid_ielen_diff;
-               u8 buf[MAX_IE_SZ];
-               u8 *ies = pframe + sizeof(struct ieee80211_hdr_3addr);
-
-               ssid_ie = rtw_get_ie(ies+_FIXED_IE_LENGTH_, WLAN_EID_SSID, &ssid_ielen,
-                                       (pframe-ies)-_FIXED_IE_LENGTH_);
-
-               ssid_ielen_diff = cur_network->Ssid.SsidLength - ssid_ielen;
-
-               if (ssid_ie &&  cur_network->Ssid.SsidLength) {
-                       uint remainder_ielen;
-                       u8 *remainder_ie;
-                       remainder_ie = ssid_ie+2;
-                       remainder_ielen = (pframe-remainder_ie);
-
-                       if (remainder_ielen > MAX_IE_SZ) {
-                               DBG_871X_LEVEL(_drv_warning_, FUNC_ADPT_FMT" remainder_ielen > MAX_IE_SZ\n", FUNC_ADPT_ARG(padapter));
-                               remainder_ielen = MAX_IE_SZ;
-                       }
-
-                       memcpy(buf, remainder_ie, remainder_ielen);
-                       memcpy(remainder_ie+ssid_ielen_diff, buf, remainder_ielen);
-                       *(ssid_ie+1) = cur_network->Ssid.SsidLength;
-                       memcpy(ssid_ie+2, cur_network->Ssid.Ssid, cur_network->Ssid.SsidLength);
-                       pframe += ssid_ielen_diff;
-                       pktlen += ssid_ielen_diff;
-               }
-       }
-
-       *pLength = pktlen;
-
-}
-#endif /*  CONFIG_AP_WOWLAN */
-
 /*
  * To check if reserved page content is destroyed by beacon because beacon
  * is too large.
@@ -832,7 +321,7 @@ void CheckFwRsvdPageContent(struct adapter *Adapter)
 {
 }
 
-static void rtl8723b_set_FwRsvdPage_cmd(struct adapter *padapter, PRSVDPAGE_LOC rsvdpageloc)
+static void rtl8723b_set_FwRsvdPage_cmd(struct adapter *padapter, struct rsvdpage_loc *rsvdpageloc)
 {
        u8 u1H2CRsvdPageParm[H2C_RSVDPAGE_LOC_LEN] = {0};
 
@@ -851,79 +340,9 @@ static void rtl8723b_set_FwRsvdPage_cmd(struct adapter *padapter, PRSVDPAGE_LOC
        FillH2CCmd8723B(padapter, H2C_8723B_RSVD_PAGE, H2C_RSVDPAGE_LOC_LEN, u1H2CRsvdPageParm);
 }
 
-static void rtl8723b_set_FwAoacRsvdPage_cmd(struct adapter *padapter, PRSVDPAGE_LOC rsvdpageloc)
+static void rtl8723b_set_FwAoacRsvdPage_cmd(struct adapter *padapter, struct rsvdpage_loc *rsvdpageloc)
 {
-#ifdef CONFIG_WOWLAN
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       u8 u1H2CAoacRsvdPageParm[H2C_AOAC_RSVDPAGE_LOC_LEN] = {0};
-
-       DBG_871X("8723BAOACRsvdPageLoc: RWC =%d ArpRsp =%d NbrAdv =%d GtkRsp =%d GtkInfo =%d ProbeReq =%d NetworkList =%d\n",
-                       rsvdpageloc->LocRemoteCtrlInfo, rsvdpageloc->LocArpRsp,
-                       rsvdpageloc->LocNbrAdv, rsvdpageloc->LocGTKRsp,
-                       rsvdpageloc->LocGTKInfo, rsvdpageloc->LocProbeReq,
-                       rsvdpageloc->LocNetList);
-
-       if (check_fwstate(pmlmepriv, _FW_LINKED)) {
-               SET_H2CCMD_AOAC_RSVDPAGE_LOC_REMOTE_WAKE_CTRL_INFO(u1H2CAoacRsvdPageParm, rsvdpageloc->LocRemoteCtrlInfo);
-               SET_H2CCMD_AOAC_RSVDPAGE_LOC_ARP_RSP(u1H2CAoacRsvdPageParm, rsvdpageloc->LocArpRsp);
-               /* SET_H2CCMD_AOAC_RSVDPAGE_LOC_NEIGHBOR_ADV(u1H2CAoacRsvdPageParm, rsvdpageloc->LocNbrAdv); */
-               SET_H2CCMD_AOAC_RSVDPAGE_LOC_GTK_RSP(u1H2CAoacRsvdPageParm, rsvdpageloc->LocGTKRsp);
-               SET_H2CCMD_AOAC_RSVDPAGE_LOC_GTK_INFO(u1H2CAoacRsvdPageParm, rsvdpageloc->LocGTKInfo);
-#ifdef CONFIG_GTK_OL
-               SET_H2CCMD_AOAC_RSVDPAGE_LOC_GTK_EXT_MEM(u1H2CAoacRsvdPageParm, rsvdpageloc->LocGTKEXTMEM);
-#endif /*  CONFIG_GTK_OL */
-               RT_PRINT_DATA(_module_hal_init_c_, _drv_always_, "u1H2CAoacRsvdPageParm:", u1H2CAoacRsvdPageParm, H2C_AOAC_RSVDPAGE_LOC_LEN);
-               FillH2CCmd8723B(padapter, H2C_8723B_AOAC_RSVD_PAGE, H2C_AOAC_RSVDPAGE_LOC_LEN, u1H2CAoacRsvdPageParm);
-       } else {
-#ifdef CONFIG_PNO_SUPPORT
-               if (!pwrpriv->pno_in_resume) {
-                       DBG_871X("NLO_INFO =%d\n", rsvdpageloc->LocPNOInfo);
-                       memset(&u1H2CAoacRsvdPageParm, 0, sizeof(u1H2CAoacRsvdPageParm));
-                       SET_H2CCMD_AOAC_RSVDPAGE_LOC_NLO_INFO(u1H2CAoacRsvdPageParm, rsvdpageloc->LocPNOInfo);
-                       FillH2CCmd8723B(padapter, H2C_AOAC_RSVDPAGE3, H2C_AOAC_RSVDPAGE_LOC_LEN, u1H2CAoacRsvdPageParm);
-                       msleep(10);
-               }
-#endif
-       }
-
-#endif /*  CONFIG_WOWLAN */
-}
-
-#ifdef CONFIG_AP_WOWLAN
-static void rtl8723b_set_ap_wow_rsvdpage_cmd(
-       struct adapter *padapter, PRSVDPAGE_LOC rsvdpageloc
-)
-{
-       u8 header;
-       u8 rsvdparm[H2C_AOAC_RSVDPAGE_LOC_LEN] = {0};
-
-       header = rtw_read8(padapter, REG_BCNQ_BDNY);
-
-       DBG_871X("%s: beacon: %d, probeRsp: %d, header:0x%02x\n", __func__,
-                       rsvdpageloc->LocApOffloadBCN,
-                       rsvdpageloc->LocProbeRsp,
-                       header);
-
-       SET_H2CCMD_AP_WOWLAN_RSVDPAGE_LOC_BCN(rsvdparm,
-                       rsvdpageloc->LocApOffloadBCN + header);
-
-       FillH2CCmd8723B(padapter, H2C_8723B_BCN_RSVDPAGE,
-                       H2C_BCN_RSVDPAGE_LEN, rsvdparm);
-
-       msleep(10);
-
-       memset(&rsvdparm, 0, sizeof(rsvdparm));
-
-       SET_H2CCMD_AP_WOWLAN_RSVDPAGE_LOC_ProbeRsp(
-                       rsvdparm,
-                       rsvdpageloc->LocProbeRsp + header);
-
-       FillH2CCmd8723B(padapter, H2C_8723B_PROBERSP_RSVDPAGE,
-                       H2C_PROBERSP_RSVDPAGE_LEN, rsvdparm);
-
-       msleep(10);
 }
-#endif /* CONFIG_AP_WOWLAN */
 
 void rtl8723b_set_FwMediaStatusRpt_cmd(struct adapter *padapter, u8 mstatus, u8 macid)
 {
@@ -941,40 +360,6 @@ void rtl8723b_set_FwMediaStatusRpt_cmd(struct adapter *padapter, u8 mstatus, u8
        FillH2CCmd8723B(padapter, H2C_8723B_MEDIA_STATUS_RPT, H2C_MEDIA_STATUS_RPT_LEN, u1H2CMediaStatusRptParm);
 }
 
-#ifdef CONFIG_WOWLAN
-static void rtl8723b_set_FwKeepAlive_cmd(struct adapter *padapter, u8 benable, u8 pkt_type)
-{
-       u8 u1H2CKeepAliveParm[H2C_KEEP_ALIVE_CTRL_LEN] = {0};
-       u8 adopt = 1, check_period = 5;
-
-       DBG_871X("%s(): benable = %d\n", __func__, benable);
-       SET_8723B_H2CCMD_KEEPALIVE_PARM_ENABLE(u1H2CKeepAliveParm, benable);
-       SET_8723B_H2CCMD_KEEPALIVE_PARM_ADOPT(u1H2CKeepAliveParm, adopt);
-       SET_8723B_H2CCMD_KEEPALIVE_PARM_PKT_TYPE(u1H2CKeepAliveParm, pkt_type);
-       SET_8723B_H2CCMD_KEEPALIVE_PARM_CHECK_PERIOD(u1H2CKeepAliveParm, check_period);
-
-       RT_PRINT_DATA(_module_hal_init_c_, _drv_always_, "u1H2CKeepAliveParm:", u1H2CKeepAliveParm, H2C_KEEP_ALIVE_CTRL_LEN);
-
-       FillH2CCmd8723B(padapter, H2C_8723B_KEEP_ALIVE, H2C_KEEP_ALIVE_CTRL_LEN, u1H2CKeepAliveParm);
-}
-
-static void rtl8723b_set_FwDisconDecision_cmd(struct adapter *padapter, u8 benable)
-{
-       u8 u1H2CDisconDecisionParm[H2C_DISCON_DECISION_LEN] = {0};
-       u8 adopt = 1, check_period = 10, trypkt_num = 0;
-
-       DBG_871X("%s(): benable = %d\n", __func__, benable);
-       SET_8723B_H2CCMD_DISCONDECISION_PARM_ENABLE(u1H2CDisconDecisionParm, benable);
-       SET_8723B_H2CCMD_DISCONDECISION_PARM_ADOPT(u1H2CDisconDecisionParm, adopt);
-       SET_8723B_H2CCMD_DISCONDECISION_PARM_CHECK_PERIOD(u1H2CDisconDecisionParm, check_period);
-       SET_8723B_H2CCMD_DISCONDECISION_PARM_TRY_PKT_NUM(u1H2CDisconDecisionParm, trypkt_num);
-
-       RT_PRINT_DATA(_module_hal_init_c_, _drv_always_, "u1H2CDisconDecisionParm:", u1H2CDisconDecisionParm, H2C_DISCON_DECISION_LEN);
-
-       FillH2CCmd8723B(padapter, H2C_8723B_DISCON_DECISION, H2C_DISCON_DECISION_LEN, u1H2CDisconDecisionParm);
-}
-#endif /*  CONFIG_WOWLAN */
-
 void rtl8723b_set_FwMacIdConfig_cmd(struct adapter *padapter, u8 mac_id, u8 raid, u8 bw, u8 sgi, u32 mask)
 {
        u8 u1H2CMacIdConfigParm[H2C_MACID_CFG_LEN] = {0};
@@ -1025,21 +410,12 @@ void rtl8723b_set_FwPwrMode_cmd(struct adapter *padapter, u8 psmode)
        else
                DBG_871X("%s(): FW LPS mode = %d, SmartPS =%d\n", __func__, psmode, pwrpriv->smart_ps);
 
-#ifdef CONFIG_WOWLAN
-       if (psmode == PS_MODE_DTIM) { /* For WOWLAN LPS, DTIM = (awake_intvl - 1) */
+       if (pwrpriv->dtim > 0 && pwrpriv->dtim < 16)
+               awake_intvl = pwrpriv->dtim+1;/* DTIM = (awake_intvl - 1) */
+       else
                awake_intvl = 3;/* DTIM =2 */
-               rlbm = 2;
-       } else
-#endif /* CONFIG_WOWLAN */
-       {
-               if (pwrpriv->dtim > 0 && pwrpriv->dtim < 16)
-                       awake_intvl = pwrpriv->dtim+1;/* DTIM = (awake_intvl - 1) */
-               else
-                       awake_intvl = 3;/* DTIM =2 */
-
-               rlbm = 2;
-       }
 
+       rlbm = 2;
 
        if (padapter->registrypriv.wifi_spec == 1) {
                awake_intvl = 2;
@@ -1173,245 +549,6 @@ void rtl8723b_set_FwPwrModeInIPS_cmd(struct adapter *padapter, u8 cmd_param)
        FillH2CCmd8723B(padapter, H2C_8723B_FWLPS_IN_IPS_, 1, &cmd_param);
 }
 
-#ifdef CONFIG_WOWLAN
-static void rtl8723b_set_FwWoWlanCtrl_Cmd(struct adapter *padapter, u8 bFuncEn)
-{
-       struct security_priv *psecpriv = &padapter->securitypriv;
-       u8 u1H2CWoWlanCtrlParm[H2C_WOWLAN_LEN] = {0};
-       u8 discont_wake = 1, gpionum = 0, gpio_dur = 0, hw_unicast = 0;
-       u8 sdio_wakeup_enable = 1;
-       u8 gpio_high_active = 0; /* 0: low active, 1: high active */
-       u8 magic_pkt = 0;
-
-#ifdef CONFIG_GPIO_WAKEUP
-       gpionum = WAKEUP_GPIO_IDX;
-       sdio_wakeup_enable = 0;
-#endif
-
-#ifdef CONFIG_PNO_SUPPORT
-       if (!ppwrpriv->wowlan_pno_enable)
-               magic_pkt = 1;
-#endif
-
-       if (psecpriv->dot11PrivacyAlgrthm == _WEP40_ || psecpriv->dot11PrivacyAlgrthm == _WEP104_)
-               hw_unicast = 1;
-
-       DBG_871X("%s(): bFuncEn =%d\n", __func__, bFuncEn);
-
-       SET_H2CCMD_WOWLAN_FUNC_ENABLE(u1H2CWoWlanCtrlParm, bFuncEn);
-       SET_H2CCMD_WOWLAN_PATTERN_MATCH_ENABLE(u1H2CWoWlanCtrlParm, 0);
-       SET_H2CCMD_WOWLAN_MAGIC_PKT_ENABLE(u1H2CWoWlanCtrlParm, magic_pkt);
-       SET_H2CCMD_WOWLAN_UNICAST_PKT_ENABLE(u1H2CWoWlanCtrlParm, hw_unicast);
-       SET_H2CCMD_WOWLAN_ALL_PKT_DROP(u1H2CWoWlanCtrlParm, 0);
-       SET_H2CCMD_WOWLAN_GPIO_ACTIVE(u1H2CWoWlanCtrlParm, gpio_high_active);
-       SET_H2CCMD_WOWLAN_DISCONNECT_WAKE_UP(u1H2CWoWlanCtrlParm, discont_wake);
-       SET_H2CCMD_WOWLAN_GPIONUM(u1H2CWoWlanCtrlParm, gpionum);
-       SET_H2CCMD_WOWLAN_DATAPIN_WAKE_UP(u1H2CWoWlanCtrlParm, sdio_wakeup_enable);
-       SET_H2CCMD_WOWLAN_GPIO_DURATION(u1H2CWoWlanCtrlParm, gpio_dur);
-       /* SET_H2CCMD_WOWLAN_GPIO_PULSE_EN(u1H2CWoWlanCtrlParm, 1); */
-       SET_H2CCMD_WOWLAN_GPIO_PULSE_COUNT(u1H2CWoWlanCtrlParm, 0x09);
-
-       RT_PRINT_DATA(_module_hal_init_c_, _drv_always_, "u1H2CWoWlanCtrlParm:", u1H2CWoWlanCtrlParm, H2C_WOWLAN_LEN);
-
-       FillH2CCmd8723B(padapter, H2C_8723B_WOWLAN, H2C_WOWLAN_LEN, u1H2CWoWlanCtrlParm);
-}
-
-static void rtl8723b_set_FwRemoteWakeCtrl_Cmd(struct adapter *padapter, u8 benable)
-{
-       u8 u1H2CRemoteWakeCtrlParm[H2C_REMOTE_WAKE_CTRL_LEN] = {0};
-       struct security_priv *psecuritypriv = &(padapter->securitypriv);
-       struct pwrctrl_priv *ppwrpriv = adapter_to_pwrctl(padapter);
-
-       DBG_871X("%s(): Enable =%d\n", __func__, benable);
-
-       if (!ppwrpriv->wowlan_pno_enable) {
-               SET_H2CCMD_REMOTE_WAKECTRL_ENABLE(u1H2CRemoteWakeCtrlParm, benable);
-               SET_H2CCMD_REMOTE_WAKE_CTRL_ARP_OFFLOAD_EN(u1H2CRemoteWakeCtrlParm, 1);
-#ifdef CONFIG_GTK_OL
-               if (psecuritypriv->binstallKCK_KEK &&
-                   psecuritypriv->dot11PrivacyAlgrthm == _AES_) {
-                       SET_H2CCMD_REMOTE_WAKE_CTRL_GTK_OFFLOAD_EN(u1H2CRemoteWakeCtrlParm, 1);
-               } else {
-                       DBG_871X("no kck or security is not AES\n");
-                       SET_H2CCMD_REMOTE_WAKE_CTRL_GTK_OFFLOAD_EN(u1H2CRemoteWakeCtrlParm, 0);
-               }
-#endif /* CONFIG_GTK_OL */
-
-               SET_H2CCMD_REMOTE_WAKE_CTRL_FW_UNICAST_EN(u1H2CRemoteWakeCtrlParm, 1);
-
-               if ((psecuritypriv->dot11PrivacyAlgrthm == _AES_) ||
-                   (psecuritypriv->dot11PrivacyAlgrthm == _NO_PRIVACY_))
-                       SET_H2CCMD_REMOTE_WAKE_CTRL_ARP_ACTION(u1H2CRemoteWakeCtrlParm, 0);
-               else
-                       SET_H2CCMD_REMOTE_WAKE_CTRL_ARP_ACTION(u1H2CRemoteWakeCtrlParm, 1);
-       }
-#ifdef CONFIG_PNO_SUPPORT
-       else {
-               SET_H2CCMD_REMOTE_WAKECTRL_ENABLE(u1H2CRemoteWakeCtrlParm, benable);
-               SET_H2CCMD_REMOTE_WAKE_CTRL_NLO_OFFLOAD_EN(u1H2CRemoteWakeCtrlParm, benable);
-       }
-#endif
-       RT_PRINT_DATA(_module_hal_init_c_, _drv_always_, "u1H2CRemoteWakeCtrlParm:", u1H2CRemoteWakeCtrlParm, H2C_REMOTE_WAKE_CTRL_LEN);
-       FillH2CCmd8723B(padapter, H2C_8723B_REMOTE_WAKE_CTRL,
-               H2C_REMOTE_WAKE_CTRL_LEN, u1H2CRemoteWakeCtrlParm);
-#ifdef CONFIG_PNO_SUPPORT
-       if (ppwrpriv->wowlan_pno_enable && !ppwrpriv->pno_in_resume) {
-               res = rtw_read8(padapter, REG_PNO_STATUS);
-               DBG_871X("cmd: 0x81 REG_PNO_STATUS: 0x%02x\n", res);
-               while (!(res&BIT(7)) && count < 25) {
-                       DBG_871X("[%d] cmd: 0x81 REG_PNO_STATUS: 0x%02x\n", count, res);
-                       res = rtw_read8(padapter, REG_PNO_STATUS);
-                       count++;
-                       msleep(2);
-               }
-               DBG_871X("cmd: 0x81 REG_PNO_STATUS: 0x%02x\n", res);
-       }
-#endif /* CONFIG_PNO_SUPPORT */
-}
-
-static void rtl8723b_set_FwAOACGlobalInfo_Cmd(struct adapter *padapter,  u8 group_alg, u8 pairwise_alg)
-{
-       u8 u1H2CAOACGlobalInfoParm[H2C_AOAC_GLOBAL_INFO_LEN] = {0};
-
-       DBG_871X("%s(): group_alg =%d pairwise_alg =%d\n", __func__, group_alg, pairwise_alg);
-
-       SET_H2CCMD_AOAC_GLOBAL_INFO_PAIRWISE_ENC_ALG(u1H2CAOACGlobalInfoParm, pairwise_alg);
-       SET_H2CCMD_AOAC_GLOBAL_INFO_GROUP_ENC_ALG(u1H2CAOACGlobalInfoParm, group_alg);
-
-       RT_PRINT_DATA(_module_hal_init_c_, _drv_always_, "u1H2CAOACGlobalInfoParm:", u1H2CAOACGlobalInfoParm, H2C_AOAC_GLOBAL_INFO_LEN);
-
-       FillH2CCmd8723B(padapter, H2C_8723B_AOAC_GLOBAL_INFO, H2C_AOAC_GLOBAL_INFO_LEN, u1H2CAOACGlobalInfoParm);
-}
-
-#ifdef CONFIG_PNO_SUPPORT
-static void rtl8723b_set_FwScanOffloadInfo_cmd(struct adapter *padapter, PRSVDPAGE_LOC rsvdpageloc, u8 enable)
-{
-       u8 u1H2CScanOffloadInfoParm[H2C_SCAN_OFFLOAD_CTRL_LEN] = {0};
-
-       DBG_871X("%s: loc_probe_packet:%d, loc_scan_info: %d loc_ssid_info:%d\n",
-               __func__, rsvdpageloc->LocProbePacket, rsvdpageloc->LocScanInfo, rsvdpageloc->LocSSIDInfo);
-
-       SET_H2CCMD_AOAC_NLO_FUN_EN(u1H2CScanOffloadInfoParm, enable);
-       SET_H2CCMD_AOAC_RSVDPAGE_LOC_SCAN_INFO(u1H2CScanOffloadInfoParm, rsvdpageloc->LocScanInfo);
-       SET_H2CCMD_AOAC_RSVDPAGE_LOC_PROBE_PACKET(u1H2CScanOffloadInfoParm, rsvdpageloc->LocProbePacket);
-       SET_H2CCMD_AOAC_RSVDPAGE_LOC_SSID_INFO(u1H2CScanOffloadInfoParm, rsvdpageloc->LocSSIDInfo);
-
-       RT_PRINT_DATA(_module_hal_init_c_, _drv_always_, "u1H2CScanOffloadInfoParm:", u1H2CScanOffloadInfoParm, H2C_SCAN_OFFLOAD_CTRL_LEN);
-       FillH2CCmd8723B(padapter, H2C_8723B_D0_SCAN_OFFLOAD_INFO, H2C_SCAN_OFFLOAD_CTRL_LEN, u1H2CScanOffloadInfoParm);
-
-       msleep(20);
-}
-#endif /* CONFIG_PNO_SUPPORT */
-
-void rtl8723b_set_wowlan_cmd(struct adapter *padapter, u8 enable)
-{
-       struct security_priv *psecpriv = &padapter->securitypriv;
-       struct pwrctrl_priv *ppwrpriv = adapter_to_pwrctl(padapter);
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct sta_info *psta = NULL;
-       u8 pkt_type = 0;
-
-       DBG_871X_LEVEL(_drv_always_, "+%s()+: enable =%d\n", __func__, enable);
-       if (enable) {
-               rtl8723b_set_FwAOACGlobalInfo_Cmd(padapter, psecpriv->dot118021XGrpPrivacy, psecpriv->dot11PrivacyAlgrthm);
-
-               rtl8723b_set_FwJoinBssRpt_cmd(padapter, RT_MEDIA_CONNECT);      /* RT_MEDIA_CONNECT will confuse in the future */
-
-               if (!(ppwrpriv->wowlan_pno_enable)) {
-                       psta = rtw_get_stainfo(&padapter->stapriv, get_bssid(pmlmepriv));
-                       if (psta)
-                               rtl8723b_set_FwMediaStatusRpt_cmd(padapter, RT_MEDIA_CONNECT, psta->mac_id);
-               } else
-                       DBG_871X("%s(): Disconnected, no FwMediaStatusRpt CONNECT\n", __func__);
-
-               msleep(2);
-
-               if (!(ppwrpriv->wowlan_pno_enable)) {
-                       rtl8723b_set_FwDisconDecision_cmd(padapter, enable);
-                       msleep(2);
-
-                       if ((psecpriv->dot11PrivacyAlgrthm != _WEP40_) || (psecpriv->dot11PrivacyAlgrthm != _WEP104_))
-                               pkt_type = 1;
-
-                       rtl8723b_set_FwKeepAlive_cmd(padapter, enable, pkt_type);
-                       msleep(2);
-               }
-
-               rtl8723b_set_FwWoWlanCtrl_Cmd(padapter, enable);
-               msleep(2);
-
-               rtl8723b_set_FwRemoteWakeCtrl_Cmd(padapter, enable);
-       } else {
-               rtl8723b_set_FwRemoteWakeCtrl_Cmd(padapter, enable);
-               msleep(2);
-               rtl8723b_set_FwWoWlanCtrl_Cmd(padapter, enable);
-       }
-
-       DBG_871X_LEVEL(_drv_always_, "-%s()-\n", __func__);
-}
-#endif /* CONFIG_WOWLAN */
-
-#ifdef CONFIG_AP_WOWLAN
-static void rtl8723b_set_FwAPWoWlanCtrl_Cmd(struct adapter *padapter, u8 bFuncEn)
-{
-       u8 u1H2CAPWoWlanCtrlParm[H2C_WOWLAN_LEN] = {0};
-       u8 gpionum = 0, gpio_dur = 0;
-       u8 gpio_high_active = 1; /* 0: low active, 1: high active */
-       u8 gpio_pulse = bFuncEn;
-#ifdef CONFIG_GPIO_WAKEUP
-       gpionum = WAKEUP_GPIO_IDX;
-#endif
-
-       DBG_871X("%s(): bFuncEn =%d\n", __func__, bFuncEn);
-
-       if (bFuncEn)
-               gpio_dur = 16;
-       else
-               gpio_dur = 0;
-
-       SET_H2CCMD_AP_WOW_GPIO_CTRL_INDEX(u1H2CAPWoWlanCtrlParm,
-                       gpionum);
-       SET_H2CCMD_AP_WOW_GPIO_CTRL_PLUS(u1H2CAPWoWlanCtrlParm,
-                       gpio_pulse);
-       SET_H2CCMD_AP_WOW_GPIO_CTRL_HIGH_ACTIVE(u1H2CAPWoWlanCtrlParm,
-                       gpio_high_active);
-       SET_H2CCMD_AP_WOW_GPIO_CTRL_EN(u1H2CAPWoWlanCtrlParm,
-                       bFuncEn);
-       SET_H2CCMD_AP_WOW_GPIO_CTRL_DURATION(u1H2CAPWoWlanCtrlParm,
-                       gpio_dur);
-
-       FillH2CCmd8723B(padapter, H2C_8723B_AP_WOW_GPIO_CTRL,
-                       H2C_AP_WOW_GPIO_CTRL_LEN, u1H2CAPWoWlanCtrlParm);
-}
-
-static void rtl8723b_set_Fw_AP_Offload_Cmd(struct adapter *padapter, u8 bFuncEn)
-{
-       u8 u1H2CAPOffloadCtrlParm[H2C_WOWLAN_LEN] = {0};
-
-       DBG_871X("%s(): bFuncEn =%d\n", __func__, bFuncEn);
-
-       SET_H2CCMD_AP_WOWLAN_EN(u1H2CAPOffloadCtrlParm, bFuncEn);
-
-       FillH2CCmd8723B(padapter, H2C_8723B_AP_OFFLOAD,
-                       H2C_AP_OFFLOAD_LEN, u1H2CAPOffloadCtrlParm);
-}
-
-void rtl8723b_set_ap_wowlan_cmd(struct adapter *padapter, u8 enable)
-{
-       DBG_871X_LEVEL(_drv_always_, "+%s()+: enable =%d\n", __func__, enable);
-       if (enable) {
-               rtl8723b_set_FwJoinBssRpt_cmd(padapter, RT_MEDIA_CONNECT);
-               issue_beacon(padapter, 0);
-       }
-
-       rtl8723b_set_FwAPWoWlanCtrl_Cmd(padapter, enable);
-       msleep(10);
-       rtl8723b_set_Fw_AP_Offload_Cmd(padapter, enable);
-       msleep(10);
-       DBG_871X_LEVEL(_drv_always_, "-%s()-\n", __func__);
-}
-#endif /* CONFIG_AP_WOWLAN */
-
 /*
  * Description: Fill the reserved packets that FW will use to RSVD page.
  * Now we just send 4 types packet to rsvd page.
@@ -1444,18 +581,8 @@ static void rtl8723b_set_FwRsvdPagePkt(
        u8 TotalPageNum = 0, CurtPktPageNum = 0, RsvdPageNum = 0;
        u16 BufIndex, PageSize = 128;
        u32 TotalPacketLen, MaxRsvdPageBufSize = 0;
-       RSVDPAGE_LOC RsvdPageLoc;
-#ifdef CONFIG_WOWLAN
-       u32 ARPLegnth = 0, GTKLegnth = 0;
-       u8 currentip[4];
-       u8 cur_dot11txpn[8];
-#ifdef CONFIG_GTK_OL
-       struct sta_priv *pstapriv = &padapter->stapriv;
-       struct sta_info *psta;
-       u8 kek[RTW_KEK_LEN];
-       u8 kck[RTW_KCK_LEN];
-#endif
-#endif
+
+       struct rsvdpage_loc RsvdPageLoc;
 
        /* DBG_871X("%s---->\n", __func__); */
 
@@ -1474,7 +601,7 @@ static void rtl8723b_set_FwRsvdPagePkt(
        }
 
        ReservedPagePacket = pcmdframe->buf_addr;
-       memset(&RsvdPageLoc, 0, sizeof(RSVDPAGE_LOC));
+       memset(&RsvdPageLoc, 0, sizeof(struct rsvdpage_loc));
 
        /* 3 (1) beacon */
        BufIndex = TxDescOffset;
@@ -1565,202 +692,7 @@ static void rtl8723b_set_FwRsvdPagePkt(
 
        BufIndex += (CurtPktPageNum*PageSize);
 
-#ifdef CONFIG_WOWLAN
-       if (check_fwstate(pmlmepriv, _FW_LINKED)) {
-       /* if (pwrctl->wowlan_mode == true) { */
-               /* BufIndex += (CurtPktPageNum*PageSize); */
-
-       /* 3(7) ARP RSP */
-       rtw_get_current_ip_address(padapter, currentip);
-       RsvdPageLoc.LocArpRsp = TotalPageNum;
-       {
-       ConstructARPResponse(
-               padapter,
-               &ReservedPagePacket[BufIndex],
-               &ARPLegnth,
-               currentip
-               );
-       rtl8723b_fill_fake_txdesc(padapter, &ReservedPagePacket[BufIndex-TxDescLen], ARPLegnth, false, false, true);
-
-       /* DBG_871X("%s(): HW_VAR_SET_TX_CMD: ARP RSP %p %d\n", */
-       /*      __func__, &ReservedPagePacket[BufIndex-TxDescLen], (ARPLegnth+TxDescLen)); */
-
-       CurtPktPageNum = (u8)PageNum_128(TxDescLen + ARPLegnth);
-       }
-       TotalPageNum += CurtPktPageNum;
-
-       BufIndex += (CurtPktPageNum*PageSize);
-
-       /* 3(8) SEC IV */
-       rtw_get_sec_iv(padapter, cur_dot11txpn, get_my_bssid(&pmlmeinfo->network));
-       RsvdPageLoc.LocRemoteCtrlInfo = TotalPageNum;
-       memcpy(ReservedPagePacket+BufIndex-TxDescLen, cur_dot11txpn, _AES_IV_LEN_);
-
-       /* DBG_871X("%s(): HW_VAR_SET_TX_CMD: SEC IV %p %d\n", */
-       /*      __func__, &ReservedPagePacket[BufIndex-TxDescLen], _AES_IV_LEN_); */
-
-       CurtPktPageNum = (u8)PageNum_128(_AES_IV_LEN_);
-
-       TotalPageNum += CurtPktPageNum;
-
-#ifdef CONFIG_GTK_OL
-       BufIndex += (CurtPktPageNum*PageSize);
-
-       /* if the ap station info. exists, get the kek, kck from station info. */
-       psta = rtw_get_stainfo(pstapriv, get_bssid(pmlmepriv));
-       if (!psta) {
-               memset(kek, 0, RTW_KEK_LEN);
-               memset(kck, 0, RTW_KCK_LEN);
-               DBG_8192C("%s, KEK, KCK download rsvd page all zero\n", __func__);
-       } else {
-               memcpy(kek, psta->kek, RTW_KEK_LEN);
-               memcpy(kck, psta->kck, RTW_KCK_LEN);
-       }
-
-       /* 3(9) KEK, KCK */
-       RsvdPageLoc.LocGTKInfo = TotalPageNum;
-       memcpy(ReservedPagePacket+BufIndex-TxDescLen, kck, RTW_KCK_LEN);
-       memcpy(ReservedPagePacket+BufIndex-TxDescLen+RTW_KCK_LEN, kek, RTW_KEK_LEN);
-
-       /* DBG_871X("%s(): HW_VAR_SET_TX_CMD: KEK KCK %p %d\n", */
-       /*      __func__, &ReservedPagePacket[BufIndex-TxDescLen], (TxDescLen + RTW_KCK_LEN + RTW_KEK_LEN)); */
-
-       CurtPktPageNum = (u8)PageNum_128(TxDescLen + RTW_KCK_LEN + RTW_KEK_LEN);
-
-       TotalPageNum += CurtPktPageNum;
-
-       BufIndex += (CurtPktPageNum*PageSize);
-
-       /* 3(10) GTK Response */
-       RsvdPageLoc.LocGTKRsp = TotalPageNum;
-       ConstructGTKResponse(
-               padapter,
-               &ReservedPagePacket[BufIndex],
-               &GTKLegnth
-       );
-
-       rtl8723b_fill_fake_txdesc(padapter, &ReservedPagePacket[BufIndex-TxDescLen], GTKLegnth, false, false, true);
-       /* DBG_871X("%s(): HW_VAR_SET_TX_CMD: GTK RSP %p %d\n", */
-       /*      __func__, &ReservedPagePacket[BufIndex-TxDescLen], (TxDescLen + GTKLegnth)); */
-
-       CurtPktPageNum = (u8)PageNum_128(TxDescLen + GTKLegnth);
-
-       TotalPageNum += CurtPktPageNum;
-
-       BufIndex += (CurtPktPageNum*PageSize);
-
-       /* below page is empty for GTK extension memory */
-       /* 3(11) GTK EXT MEM */
-       RsvdPageLoc.LocGTKEXTMEM = TotalPageNum;
-
-       CurtPktPageNum = 2;
-
-       TotalPageNum += CurtPktPageNum;
-
-       TotalPacketLen = BufIndex-TxDescLen + 256; /* extension memory for FW */
-#else
-       TotalPacketLen = BufIndex - TxDescLen + sizeof(union pn48); /* IV len */
-#endif /* CONFIG_GTK_OL */
-       } else
-#endif /* CONFIG_WOWLAN */
-       {
-#ifdef CONFIG_PNO_SUPPORT
-               if (!pwrctl->pno_in_resume && pwrctl->pno_inited) {
-                       /* Probe Request */
-                       RsvdPageLoc.LocProbePacket = TotalPageNum;
-                       ConstructProbeReq(
-                               padapter,
-                               &ReservedPagePacket[BufIndex],
-                               &ProbeReqLength);
-
-                       rtl8723b_fill_fake_txdesc(padapter,
-                               &ReservedPagePacket[BufIndex-TxDescLen],
-                               ProbeReqLength, false, false, false);
-#ifdef CONFIG_PNO_SET_DEBUG
-       {
-                       int gj;
-                       printk("probe req pkt =>\n");
-                       for (gj = 0; gj < ProbeReqLength+TxDescLen; gj++) {
-                               printk(" %02x ", ReservedPagePacket[BufIndex-TxDescLen+gj]);
-                               if ((gj+1)%8 == 0)
-                                       printk("\n");
-                       }
-                       printk(" <=end\n");
-       }
-#endif
-                       CurtPktPageNum =
-                               (u8)PageNum_128(TxDescLen + ProbeReqLength);
-
-                       TotalPageNum += CurtPktPageNum;
-
-                       BufIndex += (CurtPktPageNum*PageSize);
-
-                       /* PNO INFO Page */
-                       RsvdPageLoc.LocPNOInfo = TotalPageNum;
-                       ConstructPnoInfo(padapter, &ReservedPagePacket[BufIndex-TxDescLen], &PNOLength);
-#ifdef CONFIG_PNO_SET_DEBUG
-       {
-                       int gj;
-                       printk("PNO pkt =>\n");
-                       for (gj = 0; gj < PNOLength; gj++) {
-                               printk(" %02x ", ReservedPagePacket[BufIndex-TxDescLen+gj]);
-                               if ((gj + 1)%8 == 0)
-                                       printk("\n");
-                       }
-                       printk(" <=end\n");
-       }
-#endif
-
-                       CurtPktPageNum = (u8)PageNum_128(PNOLength);
-                       TotalPageNum += CurtPktPageNum;
-                       BufIndex += (CurtPktPageNum*PageSize);
-
-                       /* SSID List Page */
-                       RsvdPageLoc.LocSSIDInfo = TotalPageNum;
-                       ConstructSSIDList(padapter, &ReservedPagePacket[BufIndex-TxDescLen], &SSIDLegnth);
-#ifdef CONFIG_PNO_SET_DEBUG
-       {
-                       int gj;
-                       printk("SSID list pkt =>\n");
-                       for (gj = 0; gj < SSIDLegnth; gj++) {
-                               printk(" %02x ", ReservedPagePacket[BufIndex-TxDescLen+gj]);
-                               if ((gj + 1)%8 == 0)
-                                       printk("\n");
-                       }
-                       printk(" <=end\n");
-       }
-#endif
-                       CurtPktPageNum = (u8)PageNum_128(SSIDLegnth);
-                       TotalPageNum += CurtPktPageNum;
-                       BufIndex += (CurtPktPageNum*PageSize);
-
-                       /* Scan Info Page */
-                       RsvdPageLoc.LocScanInfo = TotalPageNum;
-                       ConstructScanInfo(padapter, &ReservedPagePacket[BufIndex-TxDescLen], &ScanInfoLength);
-#ifdef CONFIG_PNO_SET_DEBUG
-       {
-                       int gj;
-                       printk("Scan info pkt =>\n");
-                       for (gj = 0; gj < ScanInfoLength; gj++) {
-                               printk(" %02x ", ReservedPagePacket[BufIndex-TxDescLen+gj]);
-                               if ((gj + 1)%8 == 0)
-                                       printk("\n");
-                       }
-                       printk(" <=end\n");
-       }
-#endif
-                       CurtPktPageNum = (u8)PageNum_128(ScanInfoLength);
-                       TotalPageNum += CurtPktPageNum;
-                       BufIndex += (CurtPktPageNum*PageSize);
-
-                       TotalPacketLen = BufIndex + ScanInfoLength;
-               } else {
-               TotalPacketLen = BufIndex + BTQosNullLength;
-       }
-#else /* CONFIG_PNO_SUPPORT */
-               TotalPacketLen = BufIndex + BTQosNullLength;
-#endif
-       }
+       TotalPacketLen = BufIndex + BTQosNullLength;
 
        if (TotalPacketLen > MaxRsvdPageBufSize) {
                DBG_871X("%s(): ERROR: The rsvd page size is not enough!!TotalPacketLen %d, MaxRsvdPageBufSize %d\n", __func__,
@@ -1781,14 +713,6 @@ static void rtl8723b_set_FwRsvdPagePkt(
                rtl8723b_set_FwAoacRsvdPage_cmd(padapter, &RsvdPageLoc);
        } else {
                rtl8723b_set_FwAoacRsvdPage_cmd(padapter, &RsvdPageLoc);
-#ifdef CONFIG_PNO_SUPPORT
-               if (pwrctl->pno_in_resume)
-                       rtl8723b_set_FwScanOffloadInfo_cmd(padapter,
-                                       &RsvdPageLoc, 0);
-               else
-                       rtl8723b_set_FwScanOffloadInfo_cmd(padapter,
-                                       &RsvdPageLoc, 1);
-#endif
        }
        return;
 
@@ -1797,134 +721,9 @@ error:
        rtw_free_xmitframe(pxmitpriv, pcmdframe);
 }
 
-#ifdef CONFIG_AP_WOWLAN
-/*
- * Description: Fill the reserved packets that FW will use to RSVD page.
- * Now we just send 2 types packet to rsvd page. (1)Beacon, (2)ProbeRsp.
- *
- * Input: bDLFinished
- *
- * false: At the first time we will send all the packets as a large packet to
- * Hw, so we need to set the packet length to total length.
- *
- * true: At the second time, we should send the first packet (default:beacon)
- * to Hw again and set the length in descriptor to the real beacon length.
- */
-/* 2009.10.15 by tynli. */
-static void rtl8723b_set_AP_FwRsvdPagePkt(
-       struct adapter *padapter, bool bDLFinished
-)
-{
-       struct hal_com_data *pHalData;
-       struct xmit_frame *pcmdframe;
-       struct pkt_attrib *pattrib;
-       struct xmit_priv *pxmitpriv;
-       struct mlme_ext_priv *pmlmeext;
-       struct mlme_ext_info *pmlmeinfo;
-       struct pwrctrl_priv *pwrctl;
-       u32 BeaconLength = 0, ProbeRspLength = 0;
-       u8 *ReservedPagePacket;
-       u8 TxDescLen = TXDESC_SIZE, TxDescOffset = TXDESC_OFFSET;
-       u8 TotalPageNum = 0, CurtPktPageNum = 0, RsvdPageNum = 0;
-       u8 currentip[4];
-       u16 BufIndex, PageSize = 128;
-       u32 TotalPacketLen = 0, MaxRsvdPageBufSize = 0;
-       RSVDPAGE_LOC RsvdPageLoc;
-
-       /* DBG_871X("%s---->\n", __func__); */
-       DBG_8192C("+" FUNC_ADPT_FMT ": iface_type =%d\n",
-               FUNC_ADPT_ARG(padapter), get_iface_type(padapter));
-
-       pHalData = GET_HAL_DATA(padapter);
-       pxmitpriv = &padapter->xmitpriv;
-       pmlmeext = &padapter->mlmeextpriv;
-       pmlmeinfo = &pmlmeext->mlmext_info;
-       pwrctl = adapter_to_pwrctl(padapter);
-
-       RsvdPageNum = BCNQ_PAGE_NUM_8723B + AP_WOWLAN_PAGE_NUM_8723B;
-       MaxRsvdPageBufSize = RsvdPageNum*PageSize;
-
-       pcmdframe = rtw_alloc_cmdxmitframe(pxmitpriv);
-       if (!pcmdframe) {
-               DBG_871X("%s: alloc ReservedPagePacket fail!\n", __func__);
-               return;
-       }
-
-       ReservedPagePacket = pcmdframe->buf_addr;
-       memset(&RsvdPageLoc, 0, sizeof(RSVDPAGE_LOC));
-
-       /* 3 (1) beacon */
-       BufIndex = TxDescOffset;
-       ConstructBeacon(padapter, &ReservedPagePacket[BufIndex], &BeaconLength);
-
-       /*  When we count the first page size, we need to reserve description size for the RSVD */
-       /*  packet, it will be filled in front of the packet in TXPKTBUF. */
-       CurtPktPageNum = (u8)PageNum_128(TxDescLen + BeaconLength);
-       /* If we don't add 1 more page, the WOWLAN function has a problem. Baron thinks it's a bug of firmware */
-       if (CurtPktPageNum == 1)
-               CurtPktPageNum += 1;
-       TotalPageNum += CurtPktPageNum;
-
-       BufIndex += (CurtPktPageNum*PageSize);
-
-       /* 2 (4) probe response */
-       RsvdPageLoc.LocProbeRsp = TotalPageNum;
-
-       rtw_get_current_ip_address(padapter, currentip);
-
-       ConstructProbeRsp(
-               padapter,
-               &ReservedPagePacket[BufIndex],
-               &ProbeRspLength,
-               currentip,
-               false);
-       rtl8723b_fill_fake_txdesc(padapter,
-                       &ReservedPagePacket[BufIndex-TxDescLen],
-                       ProbeRspLength,
-                       false, false, false);
-
-       DBG_871X("%s(): HW_VAR_SET_TX_CMD: PROBE RSP %p %d\n",
-               __func__, &ReservedPagePacket[BufIndex-TxDescLen],
-               (ProbeRspLength+TxDescLen));
-
-       CurtPktPageNum = (u8)PageNum_128(TxDescLen + ProbeRspLength);
-
-       TotalPageNum += CurtPktPageNum;
-
-       BufIndex += (CurtPktPageNum*PageSize);
-
-       TotalPacketLen = BufIndex + ProbeRspLength;
-
-       if (TotalPacketLen > MaxRsvdPageBufSize) {
-               DBG_871X("%s(): ERROR: The rsvd page size is not enough \
-                               !!TotalPacketLen %d, MaxRsvdPageBufSize %d\n",
-                               __func__, TotalPacketLen, MaxRsvdPageBufSize);
-               goto error;
-       } else {
-               /*  update attribute */
-               pattrib = &pcmdframe->attrib;
-               update_mgntframe_attrib(padapter, pattrib);
-               pattrib->qsel = 0x10;
-               pattrib->pktlen = TotalPacketLen - TxDescOffset;
-               pattrib->last_txcmdsz = TotalPacketLen - TxDescOffset;
-               dump_mgntframe_and_wait(padapter, pcmdframe, 100);
-       }
-
-       DBG_871X("%s: Set RSVD page location to Fw , TotalPacketLen(%d), TotalPageNum(%d)\n", __func__, TotalPacketLen, TotalPageNum);
-       rtl8723b_set_ap_wow_rsvdpage_cmd(padapter, &RsvdPageLoc);
-
-       return;
-error:
-       rtw_free_xmitframe(pxmitpriv, pcmdframe);
-}
-#endif /* CONFIG_AP_WOWLAN */
-
 void rtl8723b_download_rsvd_page(struct adapter *padapter, u8 mstatus)
 {
        struct hal_com_data     *pHalData = GET_HAL_DATA(padapter);
-#ifdef CONFIG_AP_WOWLAN
-       struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter);
-#endif
        struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
        struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
        bool bcn_valid = false;
@@ -1971,15 +770,8 @@ void rtl8723b_download_rsvd_page(struct adapter *padapter, u8 mstatus)
                DLBcnCount = 0;
                poll = 0;
                do {
-#ifdef CONFIG_AP_WOWLAN
-                       if (pwrpriv->wowlan_ap_mode)
-                               rtl8723b_set_AP_FwRsvdPagePkt(padapter, 0);
-                       else
-                               rtl8723b_set_FwRsvdPagePkt(padapter, 0);
-#else
                        /*  download rsvd page. */
                        rtl8723b_set_FwRsvdPagePkt(padapter, 0);
-#endif
                        DLBcnCount++;
                        do {
                                yield();
@@ -2136,7 +928,7 @@ static void SetFwRsvdPagePkt_BTCoex(struct adapter *padapter)
        u8 TotalPageNum = 0, CurtPktPageNum = 0, RsvdPageNum = 0;
        u16 BufIndex, PageSize;
        u32 TotalPacketLen, MaxRsvdPageBufSize = 0;
-       RSVDPAGE_LOC RsvdPageLoc;
+       struct rsvdpage_loc RsvdPageLoc;
 
 
 /*     DBG_8192C("+" FUNC_ADPT_FMT "\n", FUNC_ADPT_ARG(padapter)); */
@@ -2156,7 +948,7 @@ static void SetFwRsvdPagePkt_BTCoex(struct adapter *padapter)
        }
 
        ReservedPagePacket = pcmdframe->buf_addr;
-       memset(&RsvdPageLoc, 0, sizeof(RSVDPAGE_LOC));
+       memset(&RsvdPageLoc, 0, sizeof(struct rsvdpage_loc));
 
        /* 3 (1) beacon */
        BufIndex = TxDescOffset;
index 650fbedd34e828037d703b9a7bb1b52acc311247..3792280f93d592ec129b99aad91957b6b94e5cfe 100644 (file)
@@ -25,7 +25,7 @@ static void Init_ODM_ComInfo_8723b(struct adapter *Adapter)
 {
 
        struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
-       PDM_ODM_T pDM_Odm = &(pHalData->odmpriv);
+       struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
        struct dm_priv *pdmpriv = &pHalData->dmpriv;
        u8 cut_ver, fab_ver;
 
@@ -74,7 +74,7 @@ static void Update_ODM_ComInfo_8723b(struct adapter *Adapter)
        struct dvobj_priv *dvobj = adapter_to_dvobj(Adapter);
        struct pwrctrl_priv *pwrctrlpriv = adapter_to_pwrctl(Adapter);
        struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
-       PDM_ODM_T pDM_Odm = &(pHalData->odmpriv);
+       struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
        struct dm_priv *pdmpriv = &pHalData->dmpriv;
        int i;
        u8 zero = 0;
@@ -91,9 +91,6 @@ static void Update_ODM_ComInfo_8723b(struct adapter *Adapter)
                | ODM_MAC_EDCA_TURBO
                | ODM_RF_TX_PWR_TRACK
                | ODM_RF_CALIBRATION
-#ifdef CONFIG_ODM_ADAPTIVITY
-               | ODM_BB_ADAPTIVITY
-#endif
                ;
 
        /*  */
@@ -129,7 +126,7 @@ void rtl8723b_InitHalDm(struct adapter *Adapter)
 {
        struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
        struct dm_priv *pdmpriv = &pHalData->dmpriv;
-       PDM_ODM_T pDM_Odm = &(pHalData->odmpriv);
+       struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
 
        pdmpriv->DM_Type = DM_Type_ByDriver;
        pdmpriv->DMFlag = DYNAMIC_FUNC_DISABLE;
@@ -203,7 +200,7 @@ void rtl8723b_hal_dm_in_lps(struct adapter *padapter)
        u32 PWDB_rssi = 0;
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
-       PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+       struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
        struct sta_priv *pstapriv = &padapter->stapriv;
        struct sta_info *psta = NULL;
 
@@ -229,8 +226,8 @@ void rtl8723b_HalDmWatchDog_in_LPS(struct adapter *Adapter)
        struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
        struct mlme_priv *pmlmepriv = &Adapter->mlmepriv;
        struct dm_priv *pdmpriv = &pHalData->dmpriv;
-       PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
-       pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable;
+       struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
+       struct dig_t *pDM_DigTable = &pDM_Odm->DM_DigTable;
        struct sta_priv *pstapriv = &Adapter->stapriv;
        struct sta_info *psta = NULL;
 
index 84e963909283f9b0c1059ecc01962ab7f7b27d6b..0081fe0a431f9660764904af0b44691764c5d6a6 100644 (file)
@@ -369,9 +369,6 @@ s32 rtl8723b_FirmwareDownload(struct adapter *padapter, bool  bUsedWoWLANFw)
        u8 tmp_ps;
 
        RT_TRACE(_module_hal_init_c_, _drv_info_, ("+%s\n", __func__));
-#ifdef CONFIG_WOWLAN
-       RT_TRACE(_module_hal_init_c_, _drv_notice_, ("+%s, bUsedWoWLANFw:%d\n", __func__, bUsedWoWLANFw));
-#endif
        pFirmware = kzalloc(sizeof(struct rt_firmware), GFP_KERNEL);
        if (!pFirmware)
                return _FAIL;
@@ -393,12 +390,7 @@ s32 rtl8723b_FirmwareDownload(struct adapter *padapter, bool  bUsedWoWLANFw)
                pdbgpriv->dbg_downloadfw_pwr_state_cnt++;
        }
 
-#ifdef CONFIG_WOWLAN
-       if (bUsedWoWLANFw)
-               fwfilepath = "rtlwifi/rtl8723bs_wowlan.bin";
-       else
-#endif /*  CONFIG_WOWLAN */
-               fwfilepath = "rtlwifi/rtl8723bs_nic.bin";
+       fwfilepath = "rtlwifi/rtl8723bs_nic.bin";
 
        pr_info("rtl8723bs: acquire FW from file:%s\n", fwfilepath);
 
@@ -535,39 +527,6 @@ void rtl8723b_InitializeFirmwareVars(struct adapter *padapter)
 /* pHalData->H2CStopInsertQueue = false; */
 }
 
-#if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN)
-/*  */
-
-/*  */
-/*  Description: Prepare some information to Fw for WoWLAN. */
-/* (1) Download wowlan Fw. */
-/* (2) Download RSVD page packets. */
-/* (3) Enable AP offload if needed. */
-/*  */
-/*  2011.04.12 by tynli. */
-/*  */
-void SetFwRelatedForWoWLAN8723b(
-       struct adapter *padapter, u8 bHostIsGoingtoSleep
-)
-{
-       int     status = _FAIL;
-       /*  */
-       /*  1. Before WoWLAN we need to re-download WoWLAN Fw. */
-       /*  */
-       status = rtl8723b_FirmwareDownload(padapter, bHostIsGoingtoSleep);
-       if (status != _SUCCESS) {
-               DBG_871X("SetFwRelatedForWoWLAN8723b(): Re-Download Firmware failed!!\n");
-               return;
-       } else {
-               DBG_871X("SetFwRelatedForWoWLAN8723b(): Re-Download Firmware Success !!\n");
-       }
-       /*  */
-       /*  2. Re-Init the variables about Fw related setting. */
-       /*  */
-       rtl8723b_InitializeFirmwareVars(padapter);
-}
-#endif /* CONFIG_WOWLAN */
-
 static void rtl8723b_free_hal_data(struct adapter *padapter)
 {
 }
@@ -583,7 +542,7 @@ static u8 hal_EfuseSwitchToBank(
        u32 value32 = 0;
 #ifdef HAL_EFUSE_MEMORY
        struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
-       PEFUSE_HAL pEfuseHal = &pHalData->EfuseHal;
+       struct efuse_hal *pEfuseHal = &pHalData->EfuseHal;
 #endif
 
 
@@ -864,7 +823,7 @@ static void hal_ReadEFuse_WiFi(
 {
 #ifdef HAL_EFUSE_MEMORY
        struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
-       PEFUSE_HAL pEfuseHal = &pHalData->EfuseHal;
+       struct efuse_hal *pEfuseHal = &pHalData->EfuseHal;
 #endif
        u8 *efuseTbl = NULL;
        u16 eFuse_Addr = 0;
@@ -1003,7 +962,7 @@ static void hal_ReadEFuse_BT(
 {
 #ifdef HAL_EFUSE_MEMORY
        struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
-       PEFUSE_HAL pEfuseHal = &pHalData->EfuseHal;
+       struct efuse_hal *pEfuseHal = &pHalData->EfuseHal;
 #endif
        u8 *efuseTbl;
        u8 bank;
@@ -1146,7 +1105,7 @@ static u16 hal_EfuseGetCurrentSize_WiFi(
 {
 #ifdef HAL_EFUSE_MEMORY
        struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
-       PEFUSE_HAL              pEfuseHal = &pHalData->EfuseHal;
+       struct efuse_hal *pEfuseHal = &pHalData->EfuseHal;
 #endif
        u16 efuse_addr = 0;
        u16 start_addr = 0; /*  for debug */
@@ -1244,7 +1203,7 @@ static u16 hal_EfuseGetCurrentSize_BT(struct adapter *padapter, u8 bPseudoTest)
 {
 #ifdef HAL_EFUSE_MEMORY
        struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
-       PEFUSE_HAL pEfuseHal = &pHalData->EfuseHal;
+       struct efuse_hal *pEfuseHal = &pHalData->EfuseHal;
 #endif
        u16 btusedbytes;
        u16 efuse_addr;
@@ -1549,7 +1508,7 @@ static void hal_EfuseConstructPGPkt(
        u8 offset,
        u8 word_en,
        u8 *pData,
-       PPGPKT_STRUCT pTargetPkt
+       struct pgpkt_struct *pTargetPkt
 )
 {
        memset(pTargetPkt->data, 0xFF, PGPKT_DATA_SIZE);
@@ -1563,12 +1522,12 @@ static u8 hal_EfusePartialWriteCheck(
        struct adapter *padapter,
        u8 efuseType,
        u16 *pAddr,
-       PPGPKT_STRUCT pTargetPkt,
+       struct pgpkt_struct *pTargetPkt,
        u8 bPseudoTest
 )
 {
        struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
-       PEFUSE_HAL pEfuseHal = &pHalData->EfuseHal;
+       struct efuse_hal *pEfuseHal = &pHalData->EfuseHal;
        u8 bRet = false;
        u16 startAddr = 0, efuse_max_available_len = 0, efuse_max = 0;
        u8 efuse_data = 0;
@@ -1681,7 +1640,7 @@ static u8 hal_EfusePgPacketWrite1ByteHeader(
        struct adapter *padapter,
        u8 efuseType,
        u16 *pAddr,
-       PPGPKT_STRUCT pTargetPkt,
+       struct pgpkt_struct *pTargetPkt,
        u8 bPseudoTest
 )
 {
@@ -1689,8 +1648,6 @@ static u8 hal_EfusePgPacketWrite1ByteHeader(
        u16 efuse_addr = *pAddr;
        u8 repeatcnt = 0;
 
-
-/*     DBG_8192C("%s\n", __func__); */
        pg_header = ((pTargetPkt->offset << 4) & 0xf0) | pTargetPkt->word_en;
 
        do {
@@ -1718,7 +1675,7 @@ static u8 hal_EfusePgPacketWrite2ByteHeader(
        struct adapter *padapter,
        u8 efuseType,
        u16 *pAddr,
-       PPGPKT_STRUCT pTargetPkt,
+       struct pgpkt_struct *pTargetPkt,
        u8 bPseudoTest
 )
 {
@@ -1726,8 +1683,6 @@ static u8 hal_EfusePgPacketWrite2ByteHeader(
        u8 pg_header = 0, tmp_header = 0;
        u8 repeatcnt = 0;
 
-
-/*     DBG_8192C("%s\n", __func__); */
        EFUSE_GetEfuseDefinition(padapter, efuseType, TYPE_AVAILABLE_EFUSE_BYTES_BANK, &efuse_max_available_len, bPseudoTest);
 
        efuse_addr = *pAddr;
@@ -1785,7 +1740,7 @@ static u8 hal_EfusePgPacketWriteHeader(
        struct adapter *padapter,
        u8 efuseType,
        u16 *pAddr,
-       PPGPKT_STRUCT pTargetPkt,
+       struct pgpkt_struct *pTargetPkt,
        u8 bPseudoTest
 )
 {
@@ -1803,7 +1758,7 @@ static u8 hal_EfusePgPacketWriteData(
        struct adapter *padapter,
        u8 efuseType,
        u16 *pAddr,
-       PPGPKT_STRUCT pTargetPkt,
+       struct pgpkt_struct *pTargetPkt,
        u8 bPseudoTest
 )
 {
@@ -1830,7 +1785,7 @@ static s32 Hal_EfusePgPacketWrite(
        bool bPseudoTest
 )
 {
-       PGPKT_STRUCT targetPkt;
+       struct pgpkt_struct targetPkt;
        u16 startAddr = 0;
        u8 efuseType = EFUSE_WIFI;
 
@@ -1859,7 +1814,7 @@ static bool Hal_EfusePgPacketWrite_BT(
        bool bPseudoTest
 )
 {
-       PGPKT_STRUCT targetPkt;
+       struct pgpkt_struct targetPkt;
        u16 startAddr = 0;
        u8 efuseType = EFUSE_BT;
 
@@ -1880,10 +1835,10 @@ static bool Hal_EfusePgPacketWrite_BT(
        return true;
 }
 
-static HAL_VERSION ReadChipVersion8723B(struct adapter *padapter)
+static struct hal_version ReadChipVersion8723B(struct adapter *padapter)
 {
        u32 value32;
-       HAL_VERSION ChipVersion;
+       struct hal_version ChipVersion;
        struct hal_com_data *pHalData;
 
 /* YJ, TODO, move read chip type here */
@@ -2094,7 +2049,7 @@ static void rtl8723b_SetBeaconRelatedRegisters(struct adapter *padapter)
 
 static void rtl8723b_GetHalODMVar(
        struct adapter *Adapter,
-       enum HAL_ODM_VARIABLE eVariable,
+       enum hal_odm_variable eVariable,
        void *pValue1,
        void *pValue2
 )
@@ -2104,7 +2059,7 @@ static void rtl8723b_GetHalODMVar(
 
 static void rtl8723b_SetHalODMVar(
        struct adapter *Adapter,
-       enum HAL_ODM_VARIABLE eVariable,
+       enum hal_odm_variable eVariable,
        void *pValue1,
        bool bSet
 )
@@ -2156,16 +2111,6 @@ static void UpdateHalRAMask8723B(struct adapter *padapter, u32 mac_id, u8 rssi_l
        rate_bitmap = hal_btcoex_GetRaMask(padapter);
        mask &= ~rate_bitmap;
 
-#ifdef CONFIG_CMCC_TEST
-       if (pmlmeext->cur_wireless_mode & WIRELESS_11G) {
-               if (mac_id == 0) {
-                       DBG_871X("CMCC_BT update raid entry, mask = 0x%x\n", mask);
-                       mask &= 0xffffff00; /* disable CCK & <24M OFDM rate for 11G mode for CMCC */
-                       DBG_871X("CMCC_BT update raid entry, mask = 0x%x\n", mask);
-               }
-       }
-#endif
-
        if (pHalData->fw_ractrl) {
                rtl8723b_set_FwMacIdConfig_cmd(padapter, mac_id, psta->raid, psta->bw_mode, shortGIrate, mask);
        }
@@ -2999,7 +2944,7 @@ static u8 fill_txdesc_sectype(struct pkt_attrib *pattrib)
        return sectype;
 }
 
-static void fill_txdesc_vcs_8723b(struct adapter *padapter, struct pkt_attrib *pattrib, PTXDESC_8723B ptxdesc)
+static void fill_txdesc_vcs_8723b(struct adapter *padapter, struct pkt_attrib *pattrib, struct txdesc_8723b *ptxdesc)
 {
        /* DBG_8192C("cvs_mode =%d\n", pattrib->vcs_mode); */
 
@@ -3032,7 +2977,7 @@ static void fill_txdesc_vcs_8723b(struct adapter *padapter, struct pkt_attrib *p
        }
 }
 
-static void fill_txdesc_phy_8723b(struct adapter *padapter, struct pkt_attrib *pattrib, PTXDESC_8723B ptxdesc)
+static void fill_txdesc_phy_8723b(struct adapter *padapter, struct pkt_attrib *pattrib, struct txdesc_8723b *ptxdesc)
 {
        /* DBG_8192C("bwmode =%d, ch_off =%d\n", pattrib->bwmode, pattrib->ch_offset); */
 
@@ -3052,7 +2997,7 @@ static void rtl8723b_fill_default_txdesc(
        struct mlme_ext_priv *pmlmeext;
        struct mlme_ext_info *pmlmeinfo;
        struct pkt_attrib *pattrib;
-       PTXDESC_8723B ptxdesc;
+       struct txdesc_8723b *ptxdesc;
        s32 bmcst;
 
        memset(pbuf, 0, TXDESC_SIZE);
@@ -3065,7 +3010,7 @@ static void rtl8723b_fill_default_txdesc(
        pattrib = &pxmitframe->attrib;
        bmcst = IS_MCAST(pattrib->ra);
 
-       ptxdesc = (PTXDESC_8723B)pbuf;
+       ptxdesc = (struct txdesc_8723b *)pbuf;
 
        if (pxmitframe->frame_tag == DATA_FRAMETAG) {
                u8 drv_userate = 0;
@@ -3087,9 +3032,6 @@ static void rtl8723b_fill_default_txdesc(
                        (pattrib->ether_type != 0x88B4) &&
                        (pattrib->dhcp_pkt != 1) &&
                        (drv_userate != 1)
-#ifdef CONFIG_AUTO_AP_MODE
-                       && (!pattrib->pctrl)
-#endif
                ) {
                        /*  Non EAP & ARP & DHCP type data packet */
 
@@ -3126,10 +3068,6 @@ static void rtl8723b_fill_default_txdesc(
                                ptxdesc->data_ldpc = 1;
                        if (pattrib->stbc)
                                ptxdesc->data_stbc = 1;
-
-#ifdef CONFIG_CMCC_TEST
-                       ptxdesc->data_short = 1; /* use cck short premble */
-#endif
                } else {
                        /*  EAP data packet and ARP packet. */
                        /*  Use the 1M data rate to send the EAP/ARP packet. */
@@ -3330,17 +3268,6 @@ static void hw_var_set_opmode(struct adapter *padapter, u8 variable, u8 *val)
                if ((mode == _HW_STATE_STATION_) || (mode == _HW_STATE_NOLINK_)) {
                        {
                                StopTxBeacon(padapter);
-#ifdef CONFIG_INTERRUPT_BASED_TXBCN
-#ifdef CONFIG_INTERRUPT_BASED_TXBCN_EARLY_INT
-                               rtw_write8(padapter, REG_DRVERLYINT, 0x05); /*  restore early int time to 5ms */
-                               UpdateInterruptMask8812AU(padapter, true, 0, IMR_BCNDMAINT0_8723B);
-#endif /*  CONFIG_INTERRUPT_BASED_TXBCN_EARLY_INT */
-
-#ifdef CONFIG_INTERRUPT_BASED_TXBCN_BCN_OK_ERR
-                               UpdateInterruptMask8812AU(padapter, true, 0, (IMR_TXBCN0ERR_8723B|IMR_TXBCN0OK_8723B));
-#endif /*  CONFIG_INTERRUPT_BASED_TXBCN_BCN_OK_ERR */
-
-#endif /*  CONFIG_INTERRUPT_BASED_TXBCN */
                        }
 
                        /*  disable atim wnd */
@@ -3350,16 +3277,6 @@ static void hw_var_set_opmode(struct adapter *padapter, u8 variable, u8 *val)
                        ResumeTxBeacon(padapter);
                        rtw_write8(padapter, REG_BCN_CTRL, DIS_TSF_UDT|EN_BCN_FUNCTION|DIS_BCNQ_SUB);
                } else if (mode == _HW_STATE_AP_) {
-#ifdef CONFIG_INTERRUPT_BASED_TXBCN
-#ifdef CONFIG_INTERRUPT_BASED_TXBCN_EARLY_INT
-                       UpdateInterruptMask8723BU(padapter, true, IMR_BCNDMAINT0_8723B, 0);
-#endif /*  CONFIG_INTERRUPT_BASED_TXBCN_EARLY_INT */
-
-#ifdef CONFIG_INTERRUPT_BASED_TXBCN_BCN_OK_ERR
-                       UpdateInterruptMask8723BU(padapter, true, (IMR_TXBCN0ERR_8723B|IMR_TXBCN0OK_8723B), 0);
-#endif /*  CONFIG_INTERRUPT_BASED_TXBCN_BCN_OK_ERR */
-
-#endif /*  CONFIG_INTERRUPT_BASED_TXBCN */
 
                        ResumeTxBeacon(padapter);
 
@@ -3706,7 +3623,7 @@ exit:
        return ret;
 }
 
-static void process_c2h_event(struct adapter *padapter, PC2H_EVT_HDR pC2hEvent, u8 *c2hBuf)
+static void process_c2h_event(struct adapter *padapter, struct c2h_evt_hdr_t *pC2hEvent, u8 *c2hBuf)
 {
        u8 index = 0;
 
@@ -3750,16 +3667,8 @@ static void process_c2h_event(struct adapter *padapter, PC2H_EVT_HDR pC2hEvent,
 
 void C2HPacketHandler_8723B(struct adapter *padapter, u8 *pbuffer, u16 length)
 {
-       C2H_EVT_HDR     C2hEvent;
+       struct c2h_evt_hdr_t    C2hEvent;
        u8 *tmpBuf = NULL;
-#ifdef CONFIG_WOWLAN
-       struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter);
-
-       if (pwrpriv->wowlan_mode) {
-               DBG_871X("%s(): return because wowolan_mode ==true! CMDID =%d\n", __func__, pbuffer[0]);
-               return;
-       }
-#endif
        C2hEvent.CmdID = pbuffer[0];
        C2hEvent.CmdSeq = pbuffer[1];
        C2hEvent.CmdLen = length-2;
@@ -3819,11 +3728,6 @@ void SetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val)
                BrateCfg &= rrsr_2g_allow_mask;
                masked = BrateCfg;
 
-               #ifdef CONFIG_CMCC_TEST
-               BrateCfg |= (RRSR_11M|RRSR_5_5M|RRSR_1M); /* use 11M to send ACK */
-               BrateCfg |= (RRSR_24M|RRSR_18M|RRSR_12M); /* CMCC_OFDM_ACK 12/18/24M */
-               #endif
-
                /* IOT consideration */
                if (mlmext_info->assoc_AP_vendor == HT_IOT_PEER_CISCO) {
                        /* if peer is cisco and didn't use ofdm rate, we enable 6M ack */
@@ -4066,7 +3970,7 @@ void SetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val)
 
        case HW_VAR_INITIAL_GAIN:
                {
-                       DIG_T *pDigTable = &pHalData->odmpriv.DM_DigTable;
+                       struct dig_t *pDigTable = &pHalData->odmpriv.DM_DigTable;
                        u32 rx_gain = *(u32 *)val;
 
                        if (rx_gain == 0xff) {/* restore rx gain */
@@ -4314,19 +4218,6 @@ void GetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val)
                val16 = rtw_read16(padapter, REG_TXPKT_EMPTY);
                *val = (val16 & BIT(10)) ? true:false;
                break;
-#ifdef CONFIG_WOWLAN
-       case HW_VAR_RPWM_TOG:
-               *val = rtw_read8(padapter, SDIO_LOCAL_BASE|SDIO_REG_HRPWM1) & BIT7;
-               break;
-       case HW_VAR_WAKEUP_REASON:
-               *val = rtw_read8(padapter, REG_WOWLAN_WAKE_REASON);
-               if (*val == 0xEA)
-                       *val = 0;
-               break;
-       case HW_VAR_SYS_CLKR:
-               *val = rtw_read8(padapter, REG_SYS_CLKR);
-               break;
-#endif
        default:
                GetHwReg(padapter, variable, val);
                break;
@@ -4336,7 +4227,7 @@ void GetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val)
 /* Description:
  *     Change default setting of specified variable.
  */
-u8 SetHalDefVar8723B(struct adapter *padapter, enum HAL_DEF_VARIABLE variable, void *pval)
+u8 SetHalDefVar8723B(struct adapter *padapter, enum hal_def_variable variable, void *pval)
 {
        u8 bResult;
 
@@ -4354,7 +4245,7 @@ u8 SetHalDefVar8723B(struct adapter *padapter, enum HAL_DEF_VARIABLE variable, v
 /* Description:
  *     Query setting of specified variable.
  */
-u8 GetHalDefVar8723B(struct adapter *padapter, enum HAL_DEF_VARIABLE variable, void *pval)
+u8 GetHalDefVar8723B(struct adapter *padapter, enum hal_def_variable variable, void *pval)
 {
        u8 bResult;
 
@@ -4461,29 +4352,18 @@ u8 GetHalDefVar8723B(struct adapter *padapter, enum HAL_DEF_VARIABLE variable, v
        return bResult;
 }
 
-#ifdef CONFIG_WOWLAN
-void Hal_DetectWoWMode(struct adapter *padapter)
-{
-       adapter_to_pwrctl(padapter)->bSupportRemoteWakeup = true;
-       DBG_871X("%s\n", __func__);
-}
-#endif /* CONFIG_WOWLAN */
-
 void rtl8723b_start_thread(struct adapter *padapter)
 {
-#ifndef CONFIG_SDIO_TX_TASKLET
        struct xmit_priv *xmitpriv = &padapter->xmitpriv;
 
        xmitpriv->SdioXmitThread = kthread_run(rtl8723bs_xmit_thread, padapter, "RTWHALXT");
        if (IS_ERR(xmitpriv->SdioXmitThread)) {
                RT_TRACE(_module_hal_xmit_c_, _drv_err_, ("%s: start rtl8723bs_xmit_thread FAIL!!\n", __func__));
        }
-#endif
 }
 
 void rtl8723b_stop_thread(struct adapter *padapter)
 {
-#ifndef CONFIG_SDIO_TX_TASKLET
        struct xmit_priv *xmitpriv = &padapter->xmitpriv;
 
        /*  stop xmit_buf_thread */
@@ -4492,36 +4372,4 @@ void rtl8723b_stop_thread(struct adapter *padapter)
                wait_for_completion(&xmitpriv->SdioXmitTerminate);
                xmitpriv->SdioXmitThread = NULL;
        }
-#endif
 }
-
-#if defined(CONFIG_CHECK_BT_HANG)
-extern void check_bt_status_work(void *data);
-void rtl8723bs_init_checkbthang_workqueue(struct adapter *adapter)
-{
-       adapter->priv_checkbt_wq = alloc_workqueue("sdio_wq", 0, 0);
-       INIT_DELAYED_WORK(&adapter->checkbt_work, (void *)check_bt_status_work);
-}
-
-void rtl8723bs_free_checkbthang_workqueue(struct adapter *adapter)
-{
-       if (adapter->priv_checkbt_wq) {
-               cancel_delayed_work_sync(&adapter->checkbt_work);
-               flush_workqueue(adapter->priv_checkbt_wq);
-               destroy_workqueue(adapter->priv_checkbt_wq);
-               adapter->priv_checkbt_wq = NULL;
-       }
-}
-
-void rtl8723bs_cancle_checkbthang_workqueue(struct adapter *adapter)
-{
-       if (adapter->priv_checkbt_wq)
-               cancel_delayed_work_sync(&adapter->checkbt_work);
-}
-
-void rtl8723bs_hal_check_bt_hang(struct adapter *adapter)
-{
-       if (adapter->priv_checkbt_wq)
-               queue_delayed_work(adapter->priv_checkbt_wq, &(adapter->checkbt_work), 0);
-}
-#endif
index 22365926a9f8a5c0e134f2a744f35a5dd87dca62..2abff4673be23ba9d82a15d4763591ec56b07314 100644 (file)
@@ -108,7 +108,7 @@ void PHY_SetBBReg_8723B(
 /*  */
 
 static u32 phy_RFSerialRead_8723B(
-       struct adapter *Adapter, enum RF_PATH eRFPath, u32 Offset
+       struct adapter *Adapter, enum rf_path eRFPath, u32 Offset
 )
 {
        u32 retValue = 0;
@@ -202,7 +202,7 @@ static u32 phy_RFSerialRead_8723B(
  */
 static void phy_RFSerialWrite_8723B(
        struct adapter *Adapter,
-       enum RF_PATH eRFPath,
+       enum rf_path eRFPath,
        u32 Offset,
        u32 Data
 )
@@ -559,7 +559,7 @@ u8 PHY_GetTxPowerIndex(
        struct adapter *padapter,
        u8 RFPath,
        u8 Rate,
-       enum CHANNEL_WIDTH BandWidth,
+       enum channel_width BandWidth,
        u8 Channel
 )
 {
@@ -594,8 +594,8 @@ u8 PHY_GetTxPowerIndex(
 void PHY_SetTxPowerLevel8723B(struct adapter *Adapter, u8 Channel)
 {
        struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
-       PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
-       pFAT_T pDM_FatTable = &pDM_Odm->DM_FatTable;
+       struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
+       struct fat_t *pDM_FatTable = &pDM_Odm->DM_FatTable;
        u8 RFPath = ODM_RF_PATH_A;
 
        if (pHalData->AntDivCfg) {/*  antenna diversity Enable */
@@ -616,7 +616,7 @@ void PHY_GetTxPowerLevel8723B(struct adapter *Adapter, s32 *powerlevel)
 }
 
 static void phy_SetRegBW_8723B(
-       struct adapter *Adapter, enum CHANNEL_WIDTH CurrentBW
+       struct adapter *Adapter, enum channel_width CurrentBW
 )
 {
        u16 RegRfMod_BW, u2tmp = 0;
@@ -806,16 +806,16 @@ static void PHY_HandleSwChnlAndSetBW8723B(
        bool bSwitchChannel,
        bool bSetBandWidth,
        u8 ChannelNum,
-       enum CHANNEL_WIDTH ChnlWidth,
-       enum EXTCHNL_OFFSET ExtChnlOffsetOf40MHz,
-       enum EXTCHNL_OFFSET ExtChnlOffsetOf80MHz,
+       enum channel_width ChnlWidth,
+       enum extchnl_offset ExtChnlOffsetOf40MHz,
+       enum extchnl_offset ExtChnlOffsetOf80MHz,
        u8 CenterFrequencyIndex1
 )
 {
        /* static bool          bInitialzed = false; */
        struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
        u8 tmpChannel = pHalData->CurrentChannel;
-       enum CHANNEL_WIDTH tmpBW = pHalData->CurrentChannelBW;
+       enum channel_width tmpBW = pHalData->CurrentChannelBW;
        u8 tmpnCur40MhzPrimeSC = pHalData->nCur40MhzPrimeSC;
        u8 tmpnCur80MhzPrimeSC = pHalData->nCur80MhzPrimeSC;
        u8 tmpCenterFrequencyIndex1 = pHalData->CurrentCenterFrequencyIndex1;
@@ -874,7 +874,7 @@ static void PHY_HandleSwChnlAndSetBW8723B(
 
 void PHY_SetBWMode8723B(
        struct adapter *Adapter,
-       enum CHANNEL_WIDTH Bandwidth, /*  20M or 40M */
+       enum channel_width Bandwidth, /*  20M or 40M */
        unsigned char Offset /*  Upper, Lower, or Don't care */
 )
 {
@@ -892,7 +892,7 @@ void PHY_SwChnl8723B(struct adapter *Adapter, u8 channel)
 void PHY_SetSwChnlBWMode8723B(
        struct adapter *Adapter,
        u8 channel,
-       enum CHANNEL_WIDTH Bandwidth,
+       enum channel_width Bandwidth,
        u8 Offset40,
        u8 Offset80
 )
index aafceaf9b1394c2e44d1c0a64ce4056acb9c1152..73b47f053549ffa0f6d3ad735265a2687253281d 100644 (file)
@@ -55,7 +55,7 @@
  * Note:               For RF type 0222D
  *---------------------------------------------------------------------------*/
 void PHY_RF6052SetBandwidth8723B(
-       struct adapter *Adapter, enum CHANNEL_WIDTH Bandwidth
+       struct adapter *Adapter, enum channel_width Bandwidth
 ) /* 20M or 40M */
 {
        struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
index 2d15a5f7648d5486114c47ce06373704f44d2bde..17a3e7bf66efff4a690fb697f272b4cdc3664c36 100644 (file)
@@ -98,7 +98,7 @@ static void update_recvframe_phyinfo(union recv_frame *precvframe,
                .is_beacon   = false,
        };
 
-       /* _irqL                irqL; */
+       /* unsigned long                irqL; */
        struct sta_priv *pstapriv;
        struct sta_info *psta;
 
@@ -242,7 +242,7 @@ static void rtl8723bs_recv_tasklet(struct tasklet_struct *t)
        struct __queue *recv_buf_queue;
        u8 *ptr;
        u32 pkt_offset, skb_len, alloc_sz;
-       _pkt *pkt_copy = NULL;
+       struct sk_buff *pkt_copy = NULL;
        u8 shift_sz = 0, rx_report_sz = 0;
 
        p_hal_data = GET_HAL_DATA(padapter);
@@ -349,7 +349,7 @@ static void rtl8723bs_recv_tasklet(struct tasklet_struct *t)
                                                RT_TRACE(_module_rtl871x_recv_c_, _drv_dump_, ("%s: rtw_recv_entry(precvframe) != _SUCCESS\n", __func__));
                                        }
                                } else if (pattrib->pkt_rpt_type == C2H_PACKET) {
-                                       C2H_EVT_HDR     C2hEvent;
+                                       struct c2h_evt_hdr_t    C2hEvent;
 
                                        u16 len_c2h = pattrib->pkt_len;
                                        u8 *pbuf_c2h = precvframe->u.hdr.rx_data;
index a3bd9c2002c9936c53455e82eb59b379a6167c1d..597cf3a88c518c64c7dbfa403991a9b4f666cc29 100644 (file)
@@ -124,10 +124,6 @@ free_xmitbuf:
        /* pxmitbuf->priv_data = NULL; */
        rtw_free_xmitbuf(pxmitpriv, pxmitbuf);
 
-#ifdef CONFIG_SDIO_TX_TASKLET
-       tasklet_hi_schedule(&pxmitpriv->xmit_tasklet);
-#endif
-
        return _FAIL;
 }
 
@@ -601,11 +597,7 @@ s32        rtl8723bs_hal_xmitframe_enqueue(
 
                pxmitpriv->tx_drop++;
        } else {
-#ifdef CONFIG_SDIO_TX_TASKLET
-               tasklet_hi_schedule(&pxmitpriv->xmit_tasklet);
-#else
                complete(&pxmitpriv->SdioXmitStart);
-#endif
        }
 
        return err;
index 718ee9eee87c05b1a6c6d1ede337113e40dcec47..b1c4bbf29790985c8fdda164e8e027ce00221339 100644 (file)
@@ -42,63 +42,6 @@ static u8 CardEnable(struct adapter *padapter)
        return ret;
 }
 
-#ifdef CONFIG_GPIO_WAKEUP
-/* we set it high under init and fw will */
-/* give us Low Pulse when host wake up */
-void HostWakeUpGpioClear(struct adapter *Adapter)
-{
-       u32 value32;
-
-       value32 = rtw_read32(Adapter, REG_GPIO_PIN_CTRL_2);
-
-       /* set GPIO 12 1 */
-       value32 |= BIT(12);/* 4+8 */
-       /* GPIO 12 out put */
-       value32 |= BIT(20);/* 4+16 */
-
-       rtw_write32(Adapter, REG_GPIO_PIN_CTRL_2, value32);
-} /* HostWakeUpGpioClear */
-
-void HalSetOutPutGPIO(struct adapter *padapter, u8 index, u8 OutPutValue)
-{
-       if (index <= 7) {
-               /* config GPIO mode */
-               rtw_write8(padapter, REG_GPIO_PIN_CTRL + 3, rtw_read8(padapter, REG_GPIO_PIN_CTRL + 3) & ~BIT(index));
-
-               /* config GPIO Sel */
-               /* 0: input */
-               /* 1: output */
-               rtw_write8(padapter, REG_GPIO_PIN_CTRL + 2, rtw_read8(padapter, REG_GPIO_PIN_CTRL + 2) | BIT(index));
-
-               /* set output value */
-               if (OutPutValue)
-                       rtw_write8(padapter, REG_GPIO_PIN_CTRL + 1, rtw_read8(padapter, REG_GPIO_PIN_CTRL + 1) | BIT(index));
-               else
-                       rtw_write8(padapter, REG_GPIO_PIN_CTRL + 1, rtw_read8(padapter, REG_GPIO_PIN_CTRL + 1) & ~BIT(index));
-       } else {
-               /* 88C Series: */
-               /* index: 11~8 transform to 3~0 */
-               /* 8723 Series: */
-               /* index: 12~8 transform to 4~0 */
-               index -= 8;
-
-               /* config GPIO mode */
-               rtw_write8(padapter, REG_GPIO_PIN_CTRL_2 + 3, rtw_read8(padapter, REG_GPIO_PIN_CTRL_2 + 3) & ~BIT(index));
-
-               /* config GPIO Sel */
-               /* 0: input */
-               /* 1: output */
-               rtw_write8(padapter, REG_GPIO_PIN_CTRL_2 + 2, rtw_read8(padapter, REG_GPIO_PIN_CTRL_2 + 2) | BIT(index));
-
-               /* set output value */
-               if (OutPutValue)
-                       rtw_write8(padapter, REG_GPIO_PIN_CTRL_2 + 1, rtw_read8(padapter, REG_GPIO_PIN_CTRL_2 + 1) | BIT(index));
-               else
-                       rtw_write8(padapter, REG_GPIO_PIN_CTRL_2 + 1, rtw_read8(padapter, REG_GPIO_PIN_CTRL_2 + 1) & ~BIT(index));
-       }
-}
-#endif
-
 static
 u8 _InitPowerOn_8723BS(struct adapter *padapter)
 {
@@ -110,20 +53,6 @@ u8 _InitPowerOn_8723BS(struct adapter *padapter)
 
 
        /*  all of these MUST be configured before power on */
-#ifdef CONFIG_EXT_CLK
-       /*  Use external crystal(XTAL) */
-       value8 = rtw_read8(padapter, REG_PAD_CTRL1_8723B + 2);
-       value8 |=  BIT(7);
-       rtw_write8(padapter, REG_PAD_CTRL1_8723B + 2, value8);
-
-       /*  CLK_REQ High active or Low Active */
-       /*  Request GPIO polarity: */
-       /*  0: low active */
-       /*  1: high active */
-       value8 = rtw_read8(padapter, REG_MULTI_FUNC_CTRL + 1);
-       value8 |= BIT(5);
-       rtw_write8(padapter, REG_MULTI_FUNC_CTRL + 1, value8);
-#endif /*  CONFIG_EXT_CLK */
 
        /*  only cmd52 can be used before power on(card enable) */
        ret = CardEnable(padapter);
@@ -190,10 +119,6 @@ u8 _InitPowerOn_8723BS(struct adapter *padapter)
        rtw_write8(padapter, REG_PAD_CTRL1_8723B, value8);
 /*     DBG_8192C("%s: REG_PAD_CTRL1(0x%x) = 0x%02X\n", __func__, REG_PAD_CTRL1_8723B, rtw_read8(padapter, REG_PAD_CTRL1_8723B)); */
 
-#ifdef CONFIG_GPIO_WAKEUP
-       HostWakeUpGpioClear(padapter);
-#endif
-
        return _SUCCESS;
 }
 
@@ -750,30 +675,6 @@ static u32 rtl8723bs_hal_init(struct adapter *padapter)
                return _SUCCESS;
        }
 
-#ifdef CONFIG_WOWLAN
-       if (rtw_read8(padapter, REG_MCUFWDL) & BIT7) {
-               u8 reg_val = 0;
-               DBG_871X("+Reset Entry+\n");
-               rtw_write8(padapter, REG_MCUFWDL, 0x00);
-               _8051Reset8723(padapter);
-               /* reset BB */
-               reg_val = rtw_read8(padapter, REG_SYS_FUNC_EN);
-               reg_val &= ~(BIT(0) | BIT(1));
-               rtw_write8(padapter, REG_SYS_FUNC_EN, reg_val);
-               /* reset RF */
-               rtw_write8(padapter, REG_RF_CTRL, 0);
-               /* reset TRX path */
-               rtw_write16(padapter, REG_CR, 0);
-               /* reset MAC, Digital Core */
-               reg_val = rtw_read8(padapter, REG_SYS_FUNC_EN + 1);
-               reg_val &= ~(BIT(4) | BIT(7));
-               rtw_write8(padapter, REG_SYS_FUNC_EN + 1, reg_val);
-               reg_val = rtw_read8(padapter, REG_SYS_FUNC_EN + 1);
-               reg_val |= BIT(4) | BIT(7);
-               rtw_write8(padapter, REG_SYS_FUNC_EN + 1, reg_val);
-               DBG_871X("-Reset Entry-\n");
-       }
-#endif /* CONFIG_WOWLAN */
        /*  Disable Interrupt first. */
 /*     rtw_hal_disable_interrupt(padapter); */
 
@@ -850,9 +751,9 @@ static u32 rtl8723bs_hal_init(struct adapter *padapter)
        /*  Joseph Note: Keep RfRegChnlVal for later use. */
        /*  */
        pHalData->RfRegChnlVal[0] =
-               PHY_QueryRFReg(padapter, (enum RF_PATH)0, RF_CHNLBW, bRFRegOffsetMask);
+               PHY_QueryRFReg(padapter, (enum rf_path)0, RF_CHNLBW, bRFRegOffsetMask);
        pHalData->RfRegChnlVal[1] =
-               PHY_QueryRFReg(padapter, (enum RF_PATH)1, RF_CHNLBW, bRFRegOffsetMask);
+               PHY_QueryRFReg(padapter, (enum rf_path)1, RF_CHNLBW, bRFRegOffsetMask);
 
 
        /* if (!pHalData->bMACFuncEnable) { */
@@ -1289,10 +1190,6 @@ static void _ReadEfuseInfo8723BS(struct adapter *padapter)
 
        Hal_EfuseParseVoltage_8723B(padapter, hwinfo, pEEPROM->bautoload_fail_flag);
 
-#ifdef CONFIG_WOWLAN
-       Hal_DetectWoWMode(padapter);
-#endif
-
        Hal_ReadRFGainOffset(padapter, hwinfo, pEEPROM->bautoload_fail_flag);
 
        RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("<==== _ReadEfuseInfo8723BS()\n"));
@@ -1383,23 +1280,6 @@ static void SetHwReg8723BS(struct adapter *padapter, u8 variable, u8 *val)
 {
        u8 val8;
 
-#if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN)
-       struct wowlan_ioctl_param *poidparam;
-       struct pwrctrl_priv *pwrctl = adapter_to_pwrctl(padapter);
-       int res;
-       u32 tmp;
-       u16 len = 0;
-       u8 trycnt = 100;
-       u32 himr = 0;
-#if defined(CONFIG_WOWLAN)
-       struct security_priv *psecuritypriv = &padapter->securitypriv;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct sta_info *psta = NULL;
-       u64 iv_low = 0, iv_high = 0;
-       u8 mstatus = (*(u8 *)val);
-#endif
-#endif
-
        switch (variable) {
        case HW_VAR_SET_RPWM:
                /*  rpwm value only use BIT0(clock bit) , BIT6(Ack bit), and BIT7(Toggle bit) */
@@ -1424,322 +1304,6 @@ static void SetHwReg8723BS(struct adapter *padapter, u8 variable, u8 *val)
                val8 = *val;
                break;
 
-#ifdef CONFIG_WOWLAN
-       case HW_VAR_WOWLAN:
-       {
-               poidparam = (struct wowlan_ioctl_param *)val;
-               switch (poidparam->subcode) {
-               case WOWLAN_ENABLE:
-                       DBG_871X_LEVEL(_drv_always_, "WOWLAN_ENABLE\n");
-
-                       /* backup data rate to register 0x8b for wowlan FW */
-                       rtw_write8(padapter, 0x8d, 1);
-                       rtw_write8(padapter, 0x8c, 0);
-                       rtw_write8(padapter, 0x8f, 0x40);
-                       rtw_write8(padapter, 0x8b,
-                       rtw_read8(padapter, 0x2f0));
-
-                       /*  1. Download WOWLAN FW */
-                       DBG_871X_LEVEL(_drv_always_, "Re-download WoWlan FW!\n");
-                       SetFwRelatedForWoWLAN8723b(padapter, true);
-
-                       /*  2. RX DMA stop */
-                       DBG_871X_LEVEL(_drv_always_, "Pause DMA\n");
-                       rtw_write32(padapter, REG_RXPKT_NUM, (rtw_read32(padapter, REG_RXPKT_NUM) | RW_RELEASE_EN));
-                       do {
-                               if ((rtw_read32(padapter, REG_RXPKT_NUM) & RXDMA_IDLE)) {
-                                       DBG_871X_LEVEL(_drv_always_, "RX_DMA_IDLE is true\n");
-                                       break;
-                               } else {
-                                       /*  If RX_DMA is not idle, receive one pkt from DMA */
-                                       res = sdio_local_read(padapter, SDIO_REG_RX0_REQ_LEN, 4, (u8 *)&tmp);
-                                       len = le16_to_cpu(tmp);
-                                       DBG_871X_LEVEL(_drv_always_, "RX len:%d\n", len);
-                                       if (len > 0)
-                                               res = RecvOnePkt(padapter, len);
-                                       else
-                                               DBG_871X_LEVEL(_drv_always_, "read length fail %d\n", len);
-
-                                       DBG_871X_LEVEL(_drv_always_, "RecvOnePkt Result: %d\n", res);
-                               }
-                       } while (trycnt--);
-                       if (trycnt == 0)
-                               DBG_871X_LEVEL(_drv_always_, "Stop RX DMA failed......\n");
-
-                       /*  3. Clear IMR and ISR */
-                       DBG_871X_LEVEL(_drv_always_, "Clear IMR and ISR\n");
-                       tmp = 0;
-                       sdio_local_write(padapter, SDIO_REG_HIMR_ON, 4, (u8 *)&tmp);
-                       sdio_local_write(padapter, SDIO_REG_HIMR, 4, (u8 *)&tmp);
-                       sdio_local_read(padapter, SDIO_REG_HISR, 4, (u8 *)&tmp);
-                       sdio_local_write(padapter, SDIO_REG_HISR, 4, (u8 *)&tmp);
-
-                       /*  4. Enable CPWM2 only */
-                       DBG_871X_LEVEL(_drv_always_, "Enable only CPWM2\n");
-                       sdio_local_read(padapter, SDIO_REG_HIMR, 4, (u8 *)&tmp);
-                       DBG_871X("DisableInterruptButCpwm28723BSdio(): Read SDIO_REG_HIMR: 0x%08x\n", tmp);
-
-                       himr = cpu_to_le32(SDIO_HIMR_DISABLED) | SDIO_HIMR_CPWM2_MSK;
-                       sdio_local_write(padapter, SDIO_REG_HIMR, 4, (u8 *)&himr);
-
-                       sdio_local_read(padapter, SDIO_REG_HIMR, 4, (u8 *)&tmp);
-                       DBG_871X("DisableInterruptButCpwm28723BSdio(): Read again SDIO_REG_HIMR: 0x%08x\n", tmp);
-
-                       /*  5. Set Enable WOWLAN H2C command. */
-                       DBG_871X_LEVEL(_drv_always_, "Set Enable WOWLan cmd\n");
-                       rtl8723b_set_wowlan_cmd(padapter, 1);
-
-                       /*  6. Check EnableWoWlan CMD is ready */
-                       if (!pwrctl->wowlan_pno_enable) {
-                               DBG_871X_LEVEL(_drv_always_, "Check EnableWoWlan CMD is ready\n");
-                               mstatus = rtw_read8(padapter, REG_WOW_CTRL);
-                               trycnt = 10;
-                               while (!(mstatus & BIT1) && trycnt > 1) {
-                                       mstatus = rtw_read8(padapter, REG_WOW_CTRL);
-                                       DBG_871X("Loop index: %d :0x%02x\n", trycnt, mstatus);
-                                       trycnt--;
-                                       msleep(2);
-                               }
-                       }
-                       break;
-
-               case WOWLAN_DISABLE:
-                       DBG_871X_LEVEL(_drv_always_, "WOWLAN_DISABLE\n");
-
-                       psta = rtw_get_stainfo(&padapter->stapriv, get_bssid(pmlmepriv));
-                       if (psta)
-                               rtl8723b_set_FwMediaStatusRpt_cmd(padapter, RT_MEDIA_DISCONNECT, psta->mac_id);
-                       else
-                               DBG_871X("psta is null\n");
-
-                       /*  1. Read wakeup reason */
-                       pwrctl->wowlan_wake_reason = rtw_read8(padapter, REG_WOWLAN_WAKE_REASON);
-                       DBG_871X_LEVEL(
-                               _drv_always_,
-                               "wakeup_reason: 0x%02x, mac_630 = 0x%08x, mac_634 = 0x%08x, mac_1c0 = 0x%08x, mac_1c4 = 0x%08x"
-                               ", mac_494 = 0x%08x, , mac_498 = 0x%08x, mac_49c = 0x%08x, mac_608 = 0x%08x, mac_4a0 = 0x%08x, mac_4a4 = 0x%08x\n"
-                               ", mac_1cc = 0x%08x, mac_2f0 = 0x%08x, mac_2f4 = 0x%08x, mac_2f8 = 0x%08x, mac_2fc = 0x%08x, mac_8c = 0x%08x",
-                               pwrctl->wowlan_wake_reason,
-                               rtw_read32(padapter, REG_WOWLAN_GTK_DBG1),
-                               rtw_read32(padapter, REG_WOWLAN_GTK_DBG2),
-                               rtw_read32(padapter, 0x1c0),
-                               rtw_read32(padapter, 0x1c4),
-                               rtw_read32(padapter, 0x494),
-                               rtw_read32(padapter, 0x498),
-                               rtw_read32(padapter, 0x49c),
-                               rtw_read32(padapter, 0x608),
-                               rtw_read32(padapter, 0x4a0),
-                               rtw_read32(padapter, 0x4a4),
-                               rtw_read32(padapter, 0x1cc),
-                               rtw_read32(padapter, 0x2f0),
-                               rtw_read32(padapter, 0x2f4),
-                               rtw_read32(padapter, 0x2f8),
-                               rtw_read32(padapter, 0x2fc),
-                               rtw_read32(padapter, 0x8c)
-                       );
-#ifdef CONFIG_PNO_SET_DEBUG
-                       DBG_871X("0x1b9: 0x%02x, 0x632: 0x%02x\n", rtw_read8(padapter, 0x1b9), rtw_read8(padapter, 0x632));
-                       DBG_871X("0x4fc: 0x%02x, 0x4fd: 0x%02x\n", rtw_read8(padapter, 0x4fc), rtw_read8(padapter, 0x4fd));
-                       DBG_871X("TXDMA STATUS: 0x%08x\n", rtw_read32(padapter, REG_TXDMA_STATUS));
-#endif
-
-                       {
-                               /*  2.  Set Disable WOWLAN H2C command. */
-                               DBG_871X_LEVEL(_drv_always_, "Set Disable WOWLan cmd\n");
-                               rtl8723b_set_wowlan_cmd(padapter, 0);
-
-                               /*  3. Check Disable WoWlan CMD ready. */
-                               DBG_871X_LEVEL(_drv_always_, "Check DisableWoWlan CMD is ready\n");
-                               mstatus = rtw_read8(padapter, REG_WOW_CTRL);
-                               trycnt = 50;
-                               while (mstatus & BIT1 && trycnt > 1) {
-                                       mstatus = rtw_read8(padapter, REG_WOW_CTRL);
-                                       DBG_871X_LEVEL(_drv_always_, "Loop index: %d :0x%02x\n", trycnt, mstatus);
-                                       trycnt--;
-                                       msleep(10);
-                               }
-
-                               if (mstatus & BIT1) {
-                                       DBG_871X_LEVEL(_drv_always_, "Disable WOW mode fail!!\n");
-                                       DBG_871X("Set 0x690 = 0x00\n");
-                                       rtw_write8(padapter, REG_WOW_CTRL, (rtw_read8(padapter, REG_WOW_CTRL) & 0xf0));
-                                       DBG_871X_LEVEL(_drv_always_, "Release RXDMA\n");
-                                       rtw_write32(padapter, REG_RXPKT_NUM, (rtw_read32(padapter, REG_RXPKT_NUM) & (~RW_RELEASE_EN)));
-                               }
-
-                               /*  3.1 read fw iv */
-                               iv_low = rtw_read32(padapter, REG_TXPKTBUF_IV_LOW);
-                                       /* only low two bytes is PN, check AES_IV macro for detail */
-                               iv_low &= 0xffff;
-                               iv_high = rtw_read32(padapter, REG_TXPKTBUF_IV_HIGH);
-                                       /* get the real packet number */
-                               pwrctl->wowlan_fw_iv = iv_high << 16 | iv_low;
-                               DBG_871X_LEVEL(_drv_always_, "fw_iv: 0x%016llx\n", pwrctl->wowlan_fw_iv);
-                               /* Update TX iv data. */
-                               rtw_set_sec_pn(padapter);
-
-                               /*  3.2 read GTK index and key */
-                               if (
-                                       psecuritypriv->binstallKCK_KEK == true &&
-                                       psecuritypriv->dot11PrivacyAlgrthm == _AES_
-                               ) {
-                                       u8 gtk_keyindex = 0;
-                                       u8 get_key[16];
-                                       /* read gtk key index */
-                                       gtk_keyindex = rtw_read8(padapter, 0x48c);
-
-                                       if (gtk_keyindex < 4) {
-                                               psecuritypriv->dot118021XGrpKeyid = gtk_keyindex;
-                                               read_cam(padapter, gtk_keyindex, get_key);
-                                               memcpy(psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey, get_key, 16);
-                                               DBG_871X_LEVEL(
-                                                       _drv_always_,
-                                                       "GTK (%d) = 0x%08x, 0x%08x, 0x%08x, 0x%08x\n",
-                                                       gtk_keyindex,
-                                                       psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].lkey[0],
-                                                       psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].lkey[1],
-                                                       psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].lkey[2],
-                                                       psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].lkey[3]
-                                               );
-                                       } else
-                                               DBG_871X_LEVEL(_drv_always_, "GTK index =%d\n", gtk_keyindex);
-                               }
-
-                               /*  4. Re-download Normal FW. */
-                               DBG_871X_LEVEL(_drv_always_, "Re-download Normal FW!\n");
-                               SetFwRelatedForWoWLAN8723b(padapter, false);
-                       }
-#ifdef CONFIG_GPIO_WAKEUP
-                       DBG_871X_LEVEL(_drv_always_, "Set Wake GPIO to high for default.\n");
-                       HalSetOutPutGPIO(padapter, WAKEUP_GPIO_IDX, 1);
-#endif
-
-                       /*  5. Download reserved pages and report media status if needed. */
-                       if (
-                               (pwrctl->wowlan_wake_reason != FWDecisionDisconnect) &&
-                               (pwrctl->wowlan_wake_reason != Rx_Pairwisekey) &&
-                               (pwrctl->wowlan_wake_reason != Rx_DisAssoc) &&
-                               (pwrctl->wowlan_wake_reason != Rx_DeAuth)
-                       ) {
-                               rtl8723b_set_FwJoinBssRpt_cmd(padapter, RT_MEDIA_CONNECT);
-                               if (psta)
-                                       rtl8723b_set_FwMediaStatusRpt_cmd(padapter, RT_MEDIA_CONNECT, psta->mac_id);
-                       }
-#ifdef CONFIG_PNO_SUPPORT
-                       rtw_write8(padapter, 0x1b8, 0);
-                       DBG_871X("reset 0x1b8: %d\n", rtw_read8(padapter, 0x1b8));
-                       rtw_write8(padapter, 0x1b9, 0);
-                       DBG_871X("reset 0x1b9: %d\n", rtw_read8(padapter, 0x1b9));
-                       rtw_write8(padapter, REG_PNO_STATUS, 0);
-                       DBG_871X("reset REG_PNO_STATUS: %d\n", rtw_read8(padapter, REG_PNO_STATUS));
-#endif
-                       break;
-
-               default:
-                       break;
-               }
-       }
-       break;
-#endif /* CONFIG_WOWLAN */
-#ifdef CONFIG_AP_WOWLAN
-       case HW_VAR_AP_WOWLAN:
-       {
-               poidparam = (struct wowlan_ioctl_param *)val;
-               switch (poidparam->subcode) {
-               case WOWLAN_AP_ENABLE:
-                       DBG_871X("%s, WOWLAN_AP_ENABLE\n", __func__);
-                       /*  1. Download WOWLAN FW */
-                       DBG_871X_LEVEL(_drv_always_, "Re-download WoWlan FW!\n");
-                       SetFwRelatedForWoWLAN8723b(padapter, true);
-
-                       /*  2. RX DMA stop */
-                       DBG_871X_LEVEL(_drv_always_, "Pause DMA\n");
-                       rtw_write32(padapter, REG_RXPKT_NUM,
-                               (rtw_read32(padapter, REG_RXPKT_NUM) | RW_RELEASE_EN));
-                       do {
-                               if ((rtw_read32(padapter, REG_RXPKT_NUM) & RXDMA_IDLE)) {
-                                       DBG_871X_LEVEL(_drv_always_, "RX_DMA_IDLE is true\n");
-                                       break;
-                               } else {
-                                       /*  If RX_DMA is not idle, receive one pkt from DMA */
-                                       res = sdio_local_read(padapter, SDIO_REG_RX0_REQ_LEN, 4, (u8 *)&tmp);
-                                       len = le16_to_cpu(tmp);
-
-                                       DBG_871X_LEVEL(_drv_always_, "RX len:%d\n", len);
-                                       if (len > 0)
-                                               res = RecvOnePkt(padapter, len);
-                                       else
-                                               DBG_871X_LEVEL(_drv_always_, "read length fail %d\n", len);
-
-                                       DBG_871X_LEVEL(_drv_always_, "RecvOnePkt Result: %d\n", res);
-                               }
-                       } while (trycnt--);
-
-                       if (trycnt == 0)
-                               DBG_871X_LEVEL(_drv_always_, "Stop RX DMA failed......\n");
-
-                       /*  3. Clear IMR and ISR */
-                       DBG_871X_LEVEL(_drv_always_, "Clear IMR and ISR\n");
-                       tmp = 0;
-                       sdio_local_write(padapter, SDIO_REG_HIMR_ON, 4, (u8 *)&tmp);
-                       sdio_local_write(padapter, SDIO_REG_HIMR, 4, (u8 *)&tmp);
-                       sdio_local_read(padapter, SDIO_REG_HISR, 4, (u8 *)&tmp);
-                       sdio_local_write(padapter, SDIO_REG_HISR, 4, (u8 *)&tmp);
-
-                       /*  4. Enable CPWM2 only */
-                       DBG_871X_LEVEL(_drv_always_, "Enable only CPWM2\n");
-                       sdio_local_read(padapter, SDIO_REG_HIMR, 4, (u8 *)&tmp);
-                       DBG_871X("DisableInterruptButCpwm28723BSdio(): Read SDIO_REG_HIMR: 0x%08x\n", tmp);
-
-                       himr = cpu_to_le32(SDIO_HIMR_DISABLED) | SDIO_HIMR_CPWM2_MSK;
-                       sdio_local_write(padapter, SDIO_REG_HIMR, 4, (u8 *)&himr);
-
-                       sdio_local_read(padapter, SDIO_REG_HIMR, 4, (u8 *)&tmp);
-                       DBG_871X("DisableInterruptButCpwm28723BSdio(): Read again SDIO_REG_HIMR: 0x%08x\n", tmp);
-
-                       /*  5. Set Enable WOWLAN H2C command. */
-                       DBG_871X_LEVEL(_drv_always_, "Set Enable AP WOWLan cmd\n");
-                       rtl8723b_set_ap_wowlan_cmd(padapter, 1);
-                       /*  6. add some delay for H2C cmd ready */
-                       msleep(10);
-
-                       rtw_write8(padapter, REG_WOWLAN_WAKE_REASON, 0);
-                       break;
-               case WOWLAN_AP_DISABLE:
-                       DBG_871X("%s, WOWLAN_AP_DISABLE\n", __func__);
-                       /*  1. Read wakeup reason */
-                       pwrctl->wowlan_wake_reason =
-                               rtw_read8(padapter, REG_WOWLAN_WAKE_REASON);
-
-                       DBG_871X_LEVEL(_drv_always_, "wakeup_reason: 0x%02x\n",
-                                       pwrctl->wowlan_wake_reason);
-
-                       /*  2.  Set Disable WOWLAN H2C command. */
-                       DBG_871X_LEVEL(_drv_always_, "Set Disable WOWLan cmd\n");
-                       rtl8723b_set_ap_wowlan_cmd(padapter, 0);
-                       /*  6. add some delay for H2C cmd ready */
-                       msleep(2);
-
-                       DBG_871X_LEVEL(_drv_always_, "Release RXDMA\n");
-
-                       rtw_write32(padapter, REG_RXPKT_NUM,
-                               (rtw_read32(padapter, REG_RXPKT_NUM) & (~RW_RELEASE_EN)));
-
-                       SetFwRelatedForWoWLAN8723b(padapter, false);
-
-#ifdef CONFIG_GPIO_WAKEUP
-               DBG_871X_LEVEL(_drv_always_, "Set Wake GPIO to high for default.\n");
-               HalSetOutPutGPIO(padapter, WAKEUP_GPIO_IDX, 1);
-#endif /* CONFIG_GPIO_WAKEUP */
-               rtl8723b_set_FwJoinBssRpt_cmd(padapter, RT_MEDIA_CONNECT);
-               issue_beacon(padapter, 0);
-               break;
-               default:
-                       break;
-       }
-}
-       break;
-#endif /* CONFIG_AP_WOWLAN */
        case HW_VAR_DM_IN_LPS:
                rtl8723b_hal_dm_in_lps(padapter);
                break;
@@ -1789,7 +1353,7 @@ static void SetHwRegWithBuf8723B(struct adapter *padapter, u8 variable, u8 *pbuf
 /*             Query setting of specified variable. */
 /*  */
 static u8 GetHalDefVar8723BSDIO(
-       struct adapter *Adapter, enum HAL_DEF_VARIABLE eVariable, void *pValue
+       struct adapter *Adapter, enum hal_def_variable eVariable, void *pValue
 )
 {
        u8      bResult = _SUCCESS;
@@ -1817,7 +1381,7 @@ static u8 GetHalDefVar8723BSDIO(
 /*             Change default setting of specified variable. */
 /*  */
 static u8 SetHalDefVar8723BSDIO(struct adapter *Adapter,
-                               enum HAL_DEF_VARIABLE eVariable, void *pValue)
+                               enum hal_def_variable eVariable, void *pValue)
 {
        return SetHalDefVar8723B(Adapter, eVariable, pValue);
 }
@@ -1847,9 +1411,6 @@ void rtl8723bs_set_hal_ops(struct adapter *padapter)
        pHalFunc->enable_interrupt = &EnableInterrupt8723BSdio;
        pHalFunc->disable_interrupt = &DisableInterrupt8723BSdio;
        pHalFunc->check_ips_status = &CheckIPSStatus;
-#ifdef CONFIG_WOWLAN
-       pHalFunc->clear_interrupt = &ClearInterrupt8723BSdio;
-#endif
        pHalFunc->SetHwRegHandler = &SetHwReg8723BS;
        pHalFunc->GetHwRegHandler = &GetHwReg8723BS;
        pHalFunc->SetHwRegHandlerWithBuf = &SetHwRegWithBuf8723B;
@@ -1859,11 +1420,4 @@ void rtl8723bs_set_hal_ops(struct adapter *padapter)
        pHalFunc->hal_xmit = &rtl8723bs_hal_xmit;
        pHalFunc->mgnt_xmit = &rtl8723bs_mgnt_xmit;
        pHalFunc->hal_xmitframe_enqueue = &rtl8723bs_hal_xmitframe_enqueue;
-
-#if defined(CONFIG_CHECK_BT_HANG)
-       pHalFunc->hal_init_checkbthang_workqueue = &rtl8723bs_init_checkbthang_workqueue;
-       pHalFunc->hal_free_checkbthang_workqueue = &rtl8723bs_free_checkbthang_workqueue;
-       pHalFunc->hal_cancle_checkbthang_workqueue = &rtl8723bs_cancle_checkbthang_workqueue;
-       pHalFunc->hal_checke_bt_hang = &rtl8723bs_hal_check_bt_hang;
-#endif
 }
index 369f55d115192d42a70887975c47f5b6a41d8586..170a28f4b19117ccae24b1aa34e5239db39c7403 100644 (file)
@@ -974,7 +974,6 @@ void sd_int_dpc(struct adapter *adapter)
 
        if (hal->sdio_hisr & SDIO_HISR_TXBCNERR)
                DBG_8192C("%s: SDIO_HISR_TXBCNERR\n", __func__);
-#ifndef CONFIG_C2H_PACKET_EN
        if (hal->sdio_hisr & SDIO_HISR_C2HCMD) {
                struct c2h_evt_hdr_88xx *c2h_evt;
 
@@ -997,7 +996,6 @@ void sd_int_dpc(struct adapter *adapter)
                        _set_workitem(&adapter->evtpriv.c2h_wk);
                }
        }
-#endif
 
        if (hal->sdio_hisr & SDIO_HISR_RXFOVW)
                DBG_8192C("%s: Rx Overflow\n", __func__);
@@ -1114,39 +1112,4 @@ void HalQueryTxOQTBufferStatus8723BSdio(struct adapter *adapter)
        haldata->SdioTxOQTFreeSpace = SdioLocalCmd52Read1Byte(adapter, SDIO_REG_OQT_FREE_PG);
 }
 
-#if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN)
-u8 RecvOnePkt(struct adapter *adapter, u32 size)
-{
-       struct recv_buf *recvbuf;
-       struct dvobj_priv *sddev;
-       struct sdio_func *func;
-
-       u8 res = false;
-
-       DBG_871X("+%s: size: %d+\n", __func__, size);
-
-       if (!adapter) {
-               DBG_871X(KERN_ERR "%s: adapter is NULL!\n", __func__);
-               return false;
-       }
 
-       sddev = adapter_to_dvobj(adapter);
-       psdio_data = &sddev->intf_data;
-       func = psdio_data->func;
-
-       if (size) {
-               sdio_claim_host(func);
-               recvbuf = sd_recv_rxfifo(adapter, size);
-
-               if (recvbuf) {
-                       sd_rxhandler(adapter, recvbuf);
-                       res = true;
-               } else {
-                       res = false;
-               }
-               sdio_release_host(func);
-       }
-       DBG_871X("-%s-\n", __func__);
-       return res;
-}
-#endif /* CONFIG_WOWLAN */
index 459f2f9d4bbbe14497d3ed12cf20830f50a24491..ba9b033685ecdac51f0188a23773fb46de516591 100644 (file)
 #define        PWR_CUT_ALL_MSK                 0xFF
 
 
-typedef enum _PWRSEQ_CMD_DELAY_UNIT_ {
+enum pwrseq_cmd_delay_unit {
        PWRSEQ_DELAY_US,
        PWRSEQ_DELAY_MS,
-} PWRSEQ_DELAY_UNIT;
+};
 
-typedef struct _WL_PWR_CFG_ {
+struct wlan_pwr_cfg {
        u16 offset;
        u8 cut_msk;
        u8 fab_msk:4;
@@ -96,7 +96,7 @@ typedef struct _WL_PWR_CFG_ {
        u8 cmd:4;
        u8 msk;
        u8 value;
-} WLAN_PWR_CFG, *PWLAN_PWR_CFG;
+};
 
 
 #define GET_PWR_CFG_OFFSET(__PWR_CMD)          __PWR_CMD.offset
@@ -113,10 +113,10 @@ typedef struct _WL_PWR_CFG_ {
 /*     Prototype of protected function. */
 /*  */
 u8 HalPwrSeqCmdParsing(
-       struct adapter *        padapter,
+       struct adapter *padapter,
        u8              CutVersion,
        u8              FabVersion,
        u8              InterfaceType,
-       WLAN_PWR_CFG    PwrCfgCmd[]);
+       struct wlan_pwr_cfg     PwrCfgCmd[]);
 
 #endif
index b4744be2cbe171b19b92d77c5a860960b338afb9..bab226f77b24cf4e930bbd4dc6634162d444db66 100644 (file)
@@ -7,8 +7,8 @@
 #ifndef __HAL_VERSION_DEF_H__
 #define __HAL_VERSION_DEF_H__
 
-/*  HAL_IC_TYPE_E */
-typedef enum tag_HAL_IC_Type_Definition {
+/*  hal_ic_type_e */
+enum hal_ic_type_e { /* tag_HAL_IC_Type_Definition */
        CHIP_8192S      =       0,
        CHIP_8188C      =       1,
        CHIP_8192C      =       2,
@@ -19,17 +19,17 @@ typedef enum tag_HAL_IC_Type_Definition {
        CHIP_8821       =       7,
        CHIP_8723B      =       8,
        CHIP_8192E      =       9,
-} HAL_IC_TYPE_E;
+};
 
-/* HAL_CHIP_TYPE_E */
-typedef enum tag_HAL_CHIP_Type_Definition {
+/* hal_chip_type_e */
+enum hal_chip_type_e { /* tag_HAL_CHIP_Type_Definition */
        TEST_CHIP               =       0,
        NORMAL_CHIP     =       1,
        FPGA                    =       2,
-} HAL_CHIP_TYPE_E;
+};
 
-/* HAL_CUT_VERSION_E */
-typedef enum tag_HAL_Cut_Version_Definition {
+/* hal_cut_version_e */
+enum hal_cut_version_e { /* tag_HAL_Cut_Version_Definition */
        A_CUT_VERSION           =       0,
        B_CUT_VERSION           =       1,
        C_CUT_VERSION           =       2,
@@ -41,16 +41,16 @@ typedef enum tag_HAL_Cut_Version_Definition {
        I_CUT_VERSION           =       8,
        J_CUT_VERSION           =       9,
        K_CUT_VERSION           =       10,
-} HAL_CUT_VERSION_E;
+};
 
 /*  HAL_Manufacturer */
-typedef enum tag_HAL_Manufacturer_Version_Definition {
+enum hal_vendor_e { /* tag_HAL_Manufacturer_Version_Definition */
        CHIP_VENDOR_TSMC        =       0,
        CHIP_VENDOR_UMC         =       1,
        CHIP_VENDOR_SMIC        =       2,
-} HAL_VENDOR_E;
+};
 
-typedef enum tag_HAL_RF_Type_Definition {
+enum hal_rf_type_e { /* tag_HAL_RF_Type_Definition */
        RF_TYPE_1T1R    =       0,
        RF_TYPE_1T2R    =       1,
        RF_TYPE_2T2R    =       2,
@@ -59,38 +59,38 @@ typedef enum tag_HAL_RF_Type_Definition {
        RF_TYPE_3T3R    =       5,
        RF_TYPE_3T4R    =       6,
        RF_TYPE_4T4R    =       7,
-} HAL_RF_TYPE_E;
+};
 
-typedef        struct tag_HAL_VERSION {
-       HAL_IC_TYPE_E           ICType;
-       HAL_CHIP_TYPE_E         ChipType;
-       HAL_CUT_VERSION_E       CUTVersion;
-       HAL_VENDOR_E            VendorType;
-       HAL_RF_TYPE_E           RFType;
+struct hal_version { /* tag_HAL_VERSION */
+       enum hal_ic_type_e              ICType;
+       enum hal_chip_type_e            ChipType;
+       enum hal_cut_version_e  CUTVersion;
+       enum hal_vendor_e               VendorType;
+       enum hal_rf_type_e              RFType;
        u8                      ROMVer;
-} HAL_VERSION, *PHAL_VERSION;
+};
 
 /* VERSION_8192C                       VersionID; */
-/* HAL_VERSION                 VersionID; */
+/* hal_version                 VersionID; */
 
 /*  Get element */
-#define GET_CVID_IC_TYPE(version)                      ((HAL_IC_TYPE_E)((version).ICType))
-#define GET_CVID_CHIP_TYPE(version)                    ((HAL_CHIP_TYPE_E)((version).ChipType))
-#define GET_CVID_RF_TYPE(version)                      ((HAL_RF_TYPE_E)((version).RFType))
-#define GET_CVID_MANUFACTUER(version)          ((HAL_VENDOR_E)((version).VendorType))
-#define GET_CVID_CUT_VERSION(version)          ((HAL_CUT_VERSION_E)((version).CUTVersion))
+#define GET_CVID_IC_TYPE(version)                      ((enum hal_ic_type_e)((version).ICType))
+#define GET_CVID_CHIP_TYPE(version)                    ((enum hal_chip_type_e)((version).ChipType))
+#define GET_CVID_RF_TYPE(version)                      ((enum hal_rf_type_e)((version).RFType))
+#define GET_CVID_MANUFACTUER(version)          ((enum hal_vendor_e)((version).VendorType))
+#define GET_CVID_CUT_VERSION(version)          ((enum hal_cut_version_e)((version).CUTVersion))
 #define GET_CVID_ROM_VERSION(version)          (((version).ROMVer) & ROM_VERSION_MASK)
 
 /*  */
 /* Common Macro. -- */
 /*  */
-/* HAL_VERSION VersionID */
+/* hal_version VersionID */
 
-/* HAL_CHIP_TYPE_E */
+/* hal_chip_type_e */
 #define IS_TEST_CHIP(version)                  ((GET_CVID_CHIP_TYPE(version) == TEST_CHIP) ? true : false)
 #define IS_NORMAL_CHIP(version)                        ((GET_CVID_CHIP_TYPE(version) == NORMAL_CHIP) ? true : false)
 
-/* HAL_CUT_VERSION_E */
+/* hal_cut_version_e */
 #define IS_A_CUT(version)                              ((GET_CVID_CUT_VERSION(version) == A_CUT_VERSION) ? true : false)
 #define IS_B_CUT(version)                              ((GET_CVID_CUT_VERSION(version) == B_CUT_VERSION) ? true : false)
 #define IS_C_CUT(version)                              ((GET_CVID_CUT_VERSION(version) == C_CUT_VERSION) ? true : false)
@@ -100,12 +100,12 @@ typedef   struct tag_HAL_VERSION {
 #define IS_J_CUT(version)                              ((GET_CVID_CUT_VERSION(version) == J_CUT_VERSION) ? true : false)
 #define IS_K_CUT(version)                              ((GET_CVID_CUT_VERSION(version) == K_CUT_VERSION) ? true : false)
 
-/* HAL_VENDOR_E */
+/* hal_vendor_e */
 #define IS_CHIP_VENDOR_TSMC(version)   ((GET_CVID_MANUFACTUER(version) == CHIP_VENDOR_TSMC) ? true : false)
 #define IS_CHIP_VENDOR_UMC(version)    ((GET_CVID_MANUFACTUER(version) == CHIP_VENDOR_UMC) ? true : false)
 #define IS_CHIP_VENDOR_SMIC(version)   ((GET_CVID_MANUFACTUER(version) == CHIP_VENDOR_SMIC) ? true : false)
 
-/* HAL_RF_TYPE_E */
+/* hal_rf_type_e */
 #define IS_1T1R(version)                                       ((GET_CVID_RF_TYPE(version) == RF_TYPE_1T1R) ? true : false)
 #define IS_1T2R(version)                                       ((GET_CVID_RF_TYPE(version) == RF_TYPE_1T2R) ? true : false)
 #define IS_2T2R(version)                                       ((GET_CVID_RF_TYPE(version) == RF_TYPE_2T2R) ? true : false)
index 86cf09ca5f06ee1baa50dc16dc58e4f25b1200d3..996198750814e83eb29a549ed89d668b1209320b 100644 (file)
@@ -40,9 +40,6 @@
  * Platform dependent
  */
 #define WAKEUP_GPIO_IDX        12      /* WIFI Chip Side */
-#ifdef CONFIG_WOWLAN
-#define CONFIG_GTK_OL
-#endif /* CONFIG_WOWLAN */
 
 /*
  * Debug Related Config
index bab9811aeb5fa242cfa75f0a0c1c6f0590e08b90..76304086107a1dc02662f0dd525944ad471deb04 100644 (file)
@@ -13,9 +13,7 @@
 
 #include <linux/types.h>
 
-typedef        signed int sint;
-
-#define FIELD_OFFSET(s, field) ((__kernel_ssize_t)&((s*)(0))->field)
+#define FIELD_OFFSET(s, field) ((__kernel_ssize_t)&((s *)(0))->field)
 
 #define SIZE_PTR __kernel_size_t
 #define SSIZE_PTR __kernel_ssize_t
index 7fc88b07a25ede494d140e8dcdbaa48616854f83..9cef9ce589a1c5713e0876dce4636b4f2fe11a5d 100644 (file)
@@ -8,16 +8,6 @@
 #define __DRV_CONF_H__
 #include "autoconf.h"
 
-//About USB VENDOR REQ
-#if defined(CONFIG_USB_VENDOR_REQ_BUFFER_PREALLOC) && !defined(CONFIG_USB_VENDOR_REQ_MUTEX)
-       #warning "define CONFIG_USB_VENDOR_REQ_MUTEX for CONFIG_USB_VENDOR_REQ_BUFFER_PREALLOC automatically"
-       #define CONFIG_USB_VENDOR_REQ_MUTEX
-#endif
-#if defined(CONFIG_VENDOR_REQ_RETRY) &&  !defined(CONFIG_USB_VENDOR_REQ_MUTEX)
-       #warning "define CONFIG_USB_VENDOR_REQ_MUTEX for CONFIG_VENDOR_REQ_RETRY automatically"
-       #define CONFIG_USB_VENDOR_REQ_MUTEX
-#endif
-
 #define DYNAMIC_CAMID_ALLOC
 
 #ifndef CONFIG_RTW_HIQ_FILTER
index cfde6e3ba4004be78b821d448efcd230d32d7486..1658450b386e544c203c20b5731d330a19092a8c 100644 (file)
@@ -24,7 +24,7 @@
 #include <wifi.h>
 #include <ieee80211.h>
 
-enum _NIC_VERSION {
+enum _nic_version {
 
        RTL8711_NIC,
        RTL8712_NIC,
@@ -77,15 +77,6 @@ enum _NIC_VERSION {
 #define SPEC_DEV_ID_RF_CONFIG_2T2R BIT(4)
 #define SPEC_DEV_ID_ASSIGN_IFNAME BIT(5)
 
-struct specific_device_id {
-
-       u32     flags;
-
-       u16     idVendor;
-       u16     idProduct;
-
-};
-
 struct registry_priv {
        u8 chip_version;
        u8 rfintfs;
@@ -196,9 +187,6 @@ struct registry_priv {
        u8 RFE_Type;
        u8  check_fw_ps;
 
-#ifdef CONFIG_MULTI_VIR_IFACES
-       u8 ext_iface_num;/* primary/secondary iface is excluded */
-#endif
        u8 qos_opt_enable;
 
        u8 hiq_filter;
@@ -207,7 +195,7 @@ struct registry_priv {
 
 /* For registry parameters */
 #define RGTRY_OFT(field) ((u32)FIELD_OFFSET(struct registry_priv, field))
-#define RGTRY_SZ(field)   sizeof(((struct registry_priv*) 0)->field)
+#define RGTRY_SZ(field)   sizeof(((struct registry_priv *)0)->field)
 #define BSSID_OFT(field) ((u32)FIELD_OFFSET(struct wlan_bssid_ex, field))
 #define BSSID_SZ(field)   sizeof(((struct wlan_bssid_ex *) 0)->field)
 
@@ -277,7 +265,7 @@ struct rtw_traffic_statistics {
 };
 
 struct cam_ctl_t {
-       _lock lock;
+       spinlock_t lock;
        u64 bitmap;
 };
 
@@ -303,13 +291,13 @@ struct dvobj_priv {
 
        /* for local/global synchronization */
        /*  */
-       _lock   lock;
+       spinlock_t      lock;
        int macid[NUM_STA];
 
-       _mutex hw_init_mutex;
-       _mutex h2c_fwcmd_mutex;
-       _mutex setch_mutex;
-       _mutex setbw_mutex;
+       struct mutex hw_init_mutex;
+       struct mutex h2c_fwcmd_mutex;
+       struct mutex setch_mutex;
+       struct mutex setbw_mutex;
 
        unsigned char oper_channel; /* saved channel info when call set_channel_bw */
        unsigned char oper_bwmode;
@@ -359,23 +347,23 @@ static inline struct device *dvobj_to_dev(struct dvobj_priv *dvobj)
 
 struct adapter *dvobj_get_port0_adapter(struct dvobj_priv *dvobj);
 
-enum _IFACE_TYPE {
+enum _iface_type {
        IFACE_PORT0, /* mapping to port0 for C/D series chips */
        IFACE_PORT1, /* mapping to port1 for C/D series chip */
        MAX_IFACE_PORT,
 };
 
-enum ADAPTER_TYPE {
+enum adapter_type {
        PRIMARY_ADAPTER,
        SECONDARY_ADAPTER,
        MAX_ADAPTER = 0xFF,
 };
 
-typedef enum _DRIVER_STATE {
+enum driver_state {
        DRIVER_NORMAL = 0,
        DRIVER_DISAPPEAR = 1,
        DRIVER_REPLACE_DONGLE = 2,
-} DRIVER_STATE;
+};
 
 struct adapter {
        int     DriverState;/*  for disable driver using module, use dongle to replace module. */
@@ -393,7 +381,7 @@ struct adapter {
        struct  recv_priv recvpriv;
        struct  sta_priv stapriv;
        struct  security_priv securitypriv;
-       _lock   security_key_mutex; /*  add for CONFIG_IEEE80211W, none 11w also can use */
+       spinlock_t   security_key_mutex; /*  add for CONFIG_IEEE80211W, none 11w also can use */
        struct  registry_priv registrypriv;
        struct  eeprom_priv eeprompriv;
 
@@ -401,7 +389,7 @@ struct adapter {
 
        u32 setband;
 
-       void *          HalData;
+       void *HalData;
        u32 hal_data_sz;
        struct hal_ops  HalFunc;
 
@@ -429,15 +417,15 @@ struct adapter {
        void (*intf_free_irq)(struct dvobj_priv *dvobj);
 
 
-       void (*intf_start)(struct adapter * adapter);
-       void (*intf_stop)(struct adapter * adapter);
+       void (*intf_start)(struct adapter *adapter);
+       void (*intf_stop)(struct adapter *adapter);
 
-       _nic_hdl pnetdev;
+       struct net_device *pnetdev;
        char old_ifname[IFNAMSIZ];
 
        /*  used by rtw_rereg_nd_name related function */
        struct rereg_nd_name_data {
-               _nic_hdl old_pnetdev;
+               struct net_device *old_pnetdev;
                char old_ifname[IFNAMSIZ];
                u8 old_ips_mode;
                u8 old_bRegUseLed;
@@ -528,17 +516,6 @@ static inline void RTW_ENABLE_FUNC(struct adapter *padapter, int func_bit)
                         (padapter)->bSurpriseRemoved || \
                         RTW_IS_FUNC_DISABLED((padapter), DF_TX_BIT))
 
-#ifdef CONFIG_GPIO_API
-int rtw_get_gpio(struct net_device *netdev, int gpio_num);
-int rtw_set_gpio_output_value(struct net_device *netdev, int gpio_num, bool isHigh);
-int rtw_config_gpio(struct net_device *netdev, int gpio_num, bool isOutput);
-#endif
-
-#ifdef CONFIG_WOWLAN
-void rtw_suspend_wow(struct adapter *padapter);
-int rtw_resume_process_wow(struct adapter *padapter);
-#endif
-
 static inline u8 *myid(struct eeprom_priv *peepriv)
 {
        return peepriv->mac_addr;
index 5e079838f59cbec286aa87c0c286f93bc12eff1e..25b3c3a39ee44a009b82041cb96759a5b0d17244 100644 (file)
        #include <linux/mmc/sdio_func.h>
        #include <linux/mmc/sdio_ids.h>
 
-#if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN)
-       #include <linux/mmc/host.h>
-       #include <linux/mmc/card.h>
-#endif
-
 struct sdio_data {
        u8  func_number;
 
index 29318b49c3ff36c82092435e0f75f17257cb5687..3c03be210d8748cf03d22d7646cfa89e5bb53cd4 100644 (file)
 
 /*  Some variables can't get from outsrc BT-Coex, */
 /*  so we need to save here */
-typedef struct _BT_COEXIST {
+struct bt_coexist {
        u8 bBtExist;
        u8 btTotalAntNum;
        u8 btChipType;
        u8 bInitlized;
-} BT_COEXIST, *PBT_COEXIST;
+};
 
 void DBG_BT_INFO(u8 *dbgmsg);
 
index fe7e2efce0e3a7dfbf0d9fda31e488506e6b49ca..28451385dec3a8a45781010a229d1faba3150d1d 100644 (file)
@@ -165,13 +165,13 @@ enum{
        UP_LINK,
        DOWN_LINK,
 };
-typedef enum _RT_MEDIA_STATUS {
+enum rt_media_status {
        RT_MEDIA_DISCONNECT = 0,
        RT_MEDIA_CONNECT       = 1
-} RT_MEDIA_STATUS;
+};
 
 #define MAX_DLFW_PAGE_SIZE                     4096    /*  @ page : 4k bytes */
-enum FIRMWARE_SOURCE {
+enum firmware_source {
        FW_SOURCE_IMG_FILE = 0,
        FW_SOURCE_HEADER_FILE = 1,              /* from header file */
 };
@@ -193,7 +193,7 @@ enum FIRMWARE_SOURCE {
 u8 rtw_hal_data_init(struct adapter *padapter);
 void rtw_hal_data_deinit(struct adapter *padapter);
 
-void dump_chip_info(HAL_VERSION        ChipVersion);
+void dump_chip_info(struct hal_version ChipVersion);
 
 u8 /* return the final channel plan decision */
 hal_com_config_channel_plan(
@@ -215,9 +215,9 @@ u8 MRateToHwRate(u8 rate);
 u8 HwRateToMRate(u8 rate);
 
 void HalSetBrateCfg(
-       struct adapter *        Adapter,
-       u8      *mBratesOS,
-       u16             *pBrateCfg);
+       struct adapter *Adapter,
+       u8 *mBratesOS,
+       u16     *pBrateCfg);
 
 bool
 Hal_MappingOutPipe(
@@ -227,7 +227,7 @@ u8 NumOutPipe
 
 void hal_init_macaddr(struct adapter *adapter);
 
-void rtw_init_hal_com_default_value(struct adapter * Adapter);
+void rtw_init_hal_com_default_value(struct adapter *Adapter);
 
 void c2h_evt_clear(struct adapter *adapter);
 s32 c2h_evt_read_88xx(struct adapter *adapter, u8 *buf);
@@ -241,9 +241,9 @@ void SetHwReg(struct adapter *padapter, u8 variable, u8 *val);
 void GetHwReg(struct adapter *padapter, u8 variable, u8 *val);
 void rtw_hal_check_rxfifo_full(struct adapter *adapter);
 
-u8 SetHalDefVar(struct adapter *adapter, enum HAL_DEF_VARIABLE variable,
+u8 SetHalDefVar(struct adapter *adapter, enum hal_def_variable variable,
                void *value);
-u8 GetHalDefVar(struct adapter *adapter, enum HAL_DEF_VARIABLE variable,
+u8 GetHalDefVar(struct adapter *adapter, enum hal_def_variable variable,
                void *value);
 
 bool eqNByte(u8 *str1, u8 *str2, u32 num);
@@ -278,22 +278,12 @@ void rtw_dump_raw_rssi_info(struct adapter *padapter);
 void rtw_bb_rf_gain_offset(struct adapter *padapter);
 
 void GetHalODMVar(struct adapter *Adapter,
-       enum HAL_ODM_VARIABLE           eVariable,
-       void *                          pValue1,
-       void *                          pValue2);
+       enum hal_odm_variable           eVariable,
+       void *pValue1,
+       void *pValue2);
 void SetHalODMVar(
-       struct adapter *                        Adapter,
-       enum HAL_ODM_VARIABLE           eVariable,
-       void *                          pValue1,
+       struct adapter *Adapter,
+       enum hal_odm_variable           eVariable,
+       void *pValue1,
        bool                                    bSet);
-
-#ifdef CONFIG_BACKGROUND_NOISE_MONITOR
-struct noise_info {
-       u8 bPauseDIG;
-       u8 IGIValue;
-       u32 max_time;/* ms */
-       u8 chan;
-};
-#endif
-
 #endif /* __HAL_COMMON_H__ */
index b951bc288b89438d3e951bc30fec053b5158b139..65e9548c7b68b9e080d2b220303c87e788eb94bf 100644 (file)
@@ -95,60 +95,6 @@ enum h2c_cmd {
 #define H2C_BCN_RSVDPAGE_LEN           5
 #define H2C_PROBERSP_RSVDPAGE_LEN      5
 
-#ifdef CONFIG_WOWLAN
-#define eqMacAddr(a, b)                (((a)[0] == (b)[0] && (a)[1] == (b)[1] && (a)[2] == (b)[2] && (a)[3] == (b)[3] && (a)[4] == (b)[4] && (a)[5] == (b)[5]) ? 1 : 0)
-#define cpMacAddr(des, src)    ((des)[0] = (src)[0], (des)[1] = (src)[1], (des)[2] = (src)[2], (des)[3] = (src)[3], (des)[4] = (src)[4], (des)[5] = (src)[5])
-#define cpIpAddr(des, src)     ((des)[0] = (src)[0], (des)[1] = (src)[1], (des)[2] = (src)[2], (des)[3] = (src)[3])
-
-/*  */
-/*  ARP packet */
-/*  */
-/*  LLC Header */
-#define GET_ARP_PKT_LLC_TYPE(__pHeader)                        ReadEF2Byte(((u8 *)(__pHeader)) + 6)
-
-/* ARP element */
-#define GET_ARP_PKT_OPERATION(__pHeader)               ReadEF2Byte(((u8 *)(__pHeader)) + 6)
-#define GET_ARP_PKT_SENDER_MAC_ADDR(__pHeader, _val)   cpMacAddr((u8 *)(_val), ((u8 *)(__pHeader))+8)
-#define GET_ARP_PKT_SENDER_IP_ADDR(__pHeader, _val)    cpIpAddr((u8 *)(_val), ((u8 *)(__pHeader))+14)
-#define GET_ARP_PKT_TARGET_MAC_ADDR(__pHeader, _val)   cpMacAddr((u8 *)(_val), ((u8 *)(__pHeader))+18)
-#define GET_ARP_PKT_TARGET_IP_ADDR(__pHeader, _val)    cpIpAddr((u8 *)(_val), ((u8 *)(__pHeader))+24)
-
-#define SET_ARP_PKT_HW(__pHeader, __Value)             WRITEEF2BYTE(((u8 *)(__pHeader)) + 0, __Value)
-#define SET_ARP_PKT_PROTOCOL(__pHeader, __Value)       WRITEEF2BYTE(((u8 *)(__pHeader)) + 2, __Value)
-#define SET_ARP_PKT_HW_ADDR_LEN(__pHeader, __Value)    WRITEEF1BYTE(((u8 *)(__pHeader)) + 4, __Value)
-#define SET_ARP_PKT_PROTOCOL_ADDR_LEN(__pHeader, __Value)      WRITEEF1BYTE(((u8 *)(__pHeader)) + 5, __Value)
-#define SET_ARP_PKT_OPERATION(__pHeader, __Value)      WRITEEF2BYTE(((u8 *)(__pHeader)) + 6, __Value)
-#define SET_ARP_PKT_SENDER_MAC_ADDR(__pHeader, _val)   cpMacAddr(((u8 *)(__pHeader))+8, (u8 *)(_val))
-#define SET_ARP_PKT_SENDER_IP_ADDR(__pHeader, _val)    cpIpAddr(((u8 *)(__pHeader))+14, (u8 *)(_val))
-#define SET_ARP_PKT_TARGET_MAC_ADDR(__pHeader, _val)   cpMacAddr(((u8 *)(__pHeader))+18, (u8 *)(_val))
-#define SET_ARP_PKT_TARGET_IP_ADDR(__pHeader, _val)    cpIpAddr(((u8 *)(__pHeader))+24, (u8 *)(_val))
-
-#define FW_WOWLAN_FUN_EN                       BIT(0)
-#define FW_WOWLAN_PATTERN_MATCH                        BIT(1)
-#define FW_WOWLAN_MAGIC_PKT                    BIT(2)
-#define FW_WOWLAN_UNICAST                      BIT(3)
-#define FW_WOWLAN_ALL_PKT_DROP                 BIT(4)
-#define FW_WOWLAN_GPIO_ACTIVE                  BIT(5)
-#define FW_WOWLAN_REKEY_WAKEUP                 BIT(6)
-#define FW_WOWLAN_DEAUTH_WAKEUP                        BIT(7)
-
-#define FW_WOWLAN_GPIO_WAKEUP_EN               BIT(0)
-#define FW_FW_PARSE_MAGIC_PKT                  BIT(1)
-
-#define FW_REMOTE_WAKE_CTRL_EN                 BIT(0)
-#define FW_REALWOWLAN_EN                       BIT(5)
-
-#define FW_WOWLAN_KEEP_ALIVE_EN                        BIT(0)
-#define FW_ADOPT_USER                          BIT(1)
-#define FW_WOWLAN_KEEP_ALIVE_PKT_TYPE          BIT(2)
-
-#define FW_REMOTE_WAKE_CTRL_EN                 BIT(0)
-#define FW_ARP_EN                              BIT(1)
-#define FW_REALWOWLAN_EN                       BIT(5)
-#define FW_WOW_FW_UNICAST_EN                   BIT(7)
-
-#endif /* CONFIG_WOWLAN */
-
 /* _RSVDPAGE_LOC_CMD_0x00 */
 #define SET_H2CCMD_RSVDPAGE_LOC_PROBE_RSP(__pH2CCmd, __Value)          SET_BITS_TO_LE_1BYTE_8BIT(__pH2CCmd, 0, 8, __Value)
 #define SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(__pH2CCmd, __Value)                     SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+1, 0, 8, __Value)
@@ -174,28 +120,6 @@ enum h2c_cmd {
 #define SET_H2CCMD_DISCONDECISION_PARM_CHECK_PERIOD(__pH2CCmd, __Value)        SET_BITS_TO_LE_1BYTE_8BIT(__pH2CCmd+1, 0, 8, __Value)
 #define SET_H2CCMD_DISCONDECISION_PARM_TRY_PKT_NUM(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE_8BIT(__pH2CCmd+2, 0, 8, __Value)
 
-#ifdef CONFIG_AP_WOWLAN
-/* _AP_Offload 0x08 */
-#define SET_H2CCMD_AP_WOWLAN_EN(__pH2CCmd, __Value)                    SET_BITS_TO_LE_1BYTE_8BIT(__pH2CCmd, 0, 8, __Value)
-/* _BCN_RsvdPage       0x09 */
-#define SET_H2CCMD_AP_WOWLAN_RSVDPAGE_LOC_BCN(__pH2CCmd, __Value)              SET_BITS_TO_LE_1BYTE_8BIT(__pH2CCmd, 0, 8, __Value)
-/* _Probersp_RsvdPage 0x0a */
-#define SET_H2CCMD_AP_WOWLAN_RSVDPAGE_LOC_ProbeRsp(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE_8BIT(__pH2CCmd, 0, 8, __Value)
-/* _Probersp_RsvdPage 0x13 */
-#define SET_H2CCMD_AP_WOW_GPIO_CTRL_INDEX(__pH2CCmd, __Value)          SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 4, __Value)
-#define SET_H2CCMD_AP_WOW_GPIO_CTRL_C2H_EN(__pH2CCmd, __Value)         SET_BITS_TO_LE_1BYTE(__pH2CCmd, 4, 1, __Value)
-#define SET_H2CCMD_AP_WOW_GPIO_CTRL_PLUS(__pH2CCmd, __Value)           SET_BITS_TO_LE_1BYTE(__pH2CCmd, 5, 1, __Value)
-#define SET_H2CCMD_AP_WOW_GPIO_CTRL_HIGH_ACTIVE(__pH2CCmd, __Value)    SET_BITS_TO_LE_1BYTE(__pH2CCmd, 6, 1, __Value)
-#define SET_H2CCMD_AP_WOW_GPIO_CTRL_EN(__pH2CCmd, __Value)             SET_BITS_TO_LE_1BYTE(__pH2CCmd, 7, 1, __Value)
-#define SET_H2CCMD_AP_WOW_GPIO_CTRL_DURATION(__pH2CCmd, __Value)       SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+1, 0, 8, __Value)
-#define SET_H2CCMD_AP_WOW_GPIO_CTRL_C2H_DURATION(__pH2CCmd, __Value)SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+2, 0, 8, __Value)
-/* _AP_PS 0x26 */
-#define SET_H2CCMD_AP_WOW_PS_EN(__pH2CCmd, __Value)                    SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 1, __Value)
-#define SET_H2CCMD_AP_WOW_PS_32K_EN(__pH2CCmd, __Value)                SET_BITS_TO_LE_1BYTE(__pH2CCmd, 1, 1, __Value)
-#define SET_H2CCMD_AP_WOW_PS_RF(__pH2CCmd, __Value)                    SET_BITS_TO_LE_1BYTE(__pH2CCmd, 2, 1, __Value)
-#define SET_H2CCMD_AP_WOW_PS_DURATION(__pH2CCmd, __Value)      SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+1, 0, 8, __Value)
-#endif
-
 /*  _WoWLAN PARAM_CMD_0x80 */
 #define SET_H2CCMD_WOWLAN_FUNC_ENABLE(__pH2CCmd, __Value)                      SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 1, __Value)
 #define SET_H2CCMD_WOWLAN_PATTERN_MATCH_ENABLE(__pH2CCmd, __Value)     SET_BITS_TO_LE_1BYTE(__pH2CCmd, 1, 1, __Value)
@@ -230,56 +154,16 @@ enum h2c_cmd {
 #define SET_H2CCMD_AOAC_RSVDPAGE_LOC_NEIGHBOR_ADV(__pH2CCmd, __Value)          SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+2, 0, 8, __Value)
 #define SET_H2CCMD_AOAC_RSVDPAGE_LOC_GTK_RSP(__pH2CCmd, __Value)               SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+3, 0, 8, __Value)
 #define SET_H2CCMD_AOAC_RSVDPAGE_LOC_GTK_INFO(__pH2CCmd, __Value)              SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+4, 0, 8, __Value)
-#ifdef CONFIG_GTK_OL
-#define SET_H2CCMD_AOAC_RSVDPAGE_LOC_GTK_EXT_MEM(__pH2CCmd, __Value)           SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+5, 0, 8, __Value)
-#endif /* CONFIG_GTK_OL */
-#ifdef CONFIG_PNO_SUPPORT
-#define SET_H2CCMD_AOAC_RSVDPAGE_LOC_NLO_INFO(__pH2CCmd, __Value)              SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd), 0, 8, __Value)
-#endif
-
-#ifdef CONFIG_PNO_SUPPORT
-/*  D0_Scan_Offload_Info_0x86 */
-#define SET_H2CCMD_AOAC_NLO_FUN_EN(__pH2CCmd, __Value)                 SET_BITS_TO_LE_1BYTE((__pH2CCmd), 3, 1, __Value)
-#define SET_H2CCMD_AOAC_RSVDPAGE_LOC_PROBE_PACKET(__pH2CCmd, __Value)  SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+1, 0, 8, __Value)
-#define SET_H2CCMD_AOAC_RSVDPAGE_LOC_SCAN_INFO(__pH2CCmd, __Value)     SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+2, 0, 8, __Value)
-#define SET_H2CCMD_AOAC_RSVDPAGE_LOC_SSID_INFO(__pH2CCmd, __Value)     SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+3, 0, 8, __Value)
-#endif /* CONFIG_PNO_SUPPORT */
 
 /*  */
 /*     Structure    -------------------------------------------------- */
 /*  */
-typedef struct _RSVDPAGE_LOC {
+struct rsvdpage_loc {
        u8 LocProbeRsp;
        u8 LocPsPoll;
        u8 LocNullData;
        u8 LocQosNull;
        u8 LocBTQosNull;
-#ifdef CONFIG_WOWLAN
-       u8 LocRemoteCtrlInfo;
-       u8 LocArpRsp;
-       u8 LocNbrAdv;
-       u8 LocGTKRsp;
-       u8 LocGTKInfo;
-       u8 LocProbeReq;
-       u8 LocNetList;
-#ifdef CONFIG_GTK_OL
-       u8 LocGTKEXTMEM;
-#endif /* CONFIG_GTK_OL */
-#ifdef CONFIG_PNO_SUPPORT
-       u8 LocPNOInfo;
-       u8 LocScanInfo;
-       u8 LocSSIDInfo;
-       u8 LocProbePacket;
-#endif /* CONFIG_PNO_SUPPORT */
-#endif /* CONFIG_WOWLAN */
-#ifdef CONFIG_AP_WOWLAN
-       u8 LocApOffloadBCN;
-#endif /* CONFIG_AP_WOWLAN */
-} RSVDPAGE_LOC, *PRSVDPAGE_LOC;
+};
 
 #endif
-#if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN)
-void rtw_get_current_ip_address(struct adapter *padapter, u8 *pcurrentip);
-void rtw_get_sec_iv(struct adapter *padapter, u8*pcur_dot11txpn, u8 *StaAddr);
-void rtw_set_sec_pn(struct adapter *padapter);
-#endif
index 9fff4aa36546761778db3555c6bb1fd16008847d..51eef4d5c86136c89e982a7f8a8c208ba9b0891f 100644 (file)
@@ -12,7 +12,7 @@
 #define                PathC           0x2
 #define                PathD           0x3
 
-enum RATE_SECTION {
+enum rate_section {
        CCK = 0,
        OFDM,
        HT_MCS0_MCS7,
@@ -25,7 +25,7 @@ enum RATE_SECTION {
        VHT_4SSMCS0_4SSMCS9,
 };
 
-enum RF_TX_NUM {
+enum rf_tx_num {
        RF_1TX = 0,
        RF_2TX,
        RF_3TX,
@@ -36,7 +36,7 @@ enum RF_TX_NUM {
 
 #define MAX_POWER_INDEX                        0x3F
 
-enum _REGULATION_TXPWR_LMT {
+enum _regulation_txpwr_lmt {
        TXPWR_LMT_FCC = 0,
        TXPWR_LMT_MKK,
        TXPWR_LMT_ETSI,
@@ -72,11 +72,11 @@ struct bb_register_def {
 
 u8
 PHY_GetTxPowerByRateBase(
-struct adapter *       Adapter,
+struct adapter *Adapter,
 u8             Band,
 u8             RfPath,
 u8             TxNum,
-enum RATE_SECTION      RateSection
+enum rate_section      RateSection
        );
 
 u8
@@ -92,9 +92,9 @@ struct adapter *padapter,
 u32            RegAddr,
 u32            BitMask,
 u32            Value,
-       u8*             RateIndex,
-       s8*             PwrByRateVal,
-       u8*             RateNum
+u8             *RateIndex,
+s8             *PwrByRateVal,
+u8             *RateNum
        );
 
 u8
@@ -104,7 +104,7 @@ u8 Rate
 
 void
 PHY_SetTxPowerIndexByRateSection(
-struct adapter *       padapter,
+struct adapter *padapter,
 u8             RFPath,
 u8             Channel,
 u8             RateSection
@@ -138,11 +138,11 @@ u8        path
 
 void
 PHY_SetTxPowerIndexByRateArray(
-struct adapter *       padapter,
+struct adapter *padapter,
 u8             RFPath,
-enum CHANNEL_WIDTH     BandWidth,
+enum channel_width     BandWidth,
 u8             Channel,
-u8*                    Rates,
+u8             *Rates,
 u8             RateArraySize
        );
 
@@ -164,21 +164,21 @@ u32               Data
 
 void
 PHY_TxPowerByRateConfiguration(
-       struct adapter *                padapter
+       struct adapter *padapter
        );
 
 u8
 PHY_GetTxPowerIndexBase(
-struct adapter *       padapter,
+struct adapter *padapter,
 u8             RFPath,
 u8             Rate,
-enum CHANNEL_WIDTH     BandWidth,
+enum channel_width     BandWidth,
 u8             Channel,
        bool            *bIn24G
        );
 
 s8 phy_get_tx_pwr_lmt(struct adapter *adapter, u32 RegPwrTblSel,
-                       enum BAND_TYPE Band, enum CHANNEL_WIDTH Bandwidth,
+                       enum band_type Band, enum channel_width Bandwidth,
 u8             RfPath,
 u8             DataRate,
 u8             Channel
@@ -186,7 +186,7 @@ u8          Channel
 
 void
 PHY_SetTxPowerLimit(
-struct adapter *               Adapter,
+struct adapter *Adapter,
 u8                     *Regulation,
 u8                     *Band,
 u8                     *Bandwidth,
@@ -198,12 +198,12 @@ u8                        *PowerLimit
 
 void
 PHY_ConvertTxPowerLimitToPowerIndex(
-struct adapter *               Adapter
+struct adapter *Adapter
        );
 
 void
 PHY_InitTxPowerLimit(
-struct adapter *               Adapter
+struct adapter *Adapter
        );
 
 s8
@@ -215,7 +215,7 @@ PHY_GetTxPowerTrackingOffset(
 
 void
 Hal_ChannelPlanToRegulation(
-struct adapter *       Adapter,
+struct adapter *Adapter,
 u16                    ChannelPlan
        );
 
index 37fa59a352d60e24a700c963a301238082d16d43..b555826760d06f3c510730a04321b5e03f243996 100644 (file)
@@ -1002,9 +1002,9 @@ Current IOREG MAP
        /*               8192C (TXPAUSE) transmission pause     (Offset 0x522, 8 bits) */
        /*  */
 /*  Note: */
-/*     The the bits of stoping AC(VO/VI/BE/BK) queue in datasheet RTL8192S/RTL8192C are wrong, */
-/*     the correct arragement is VO - Bit0, VI - Bit1, BE - Bit2, and BK - Bit3. */
-/*     8723 and 88E may be not correct either in the eralier version. Confirmed with DD Tim. */
+/*     The  bits of stopping AC(VO/VI/BE/BK) queue in datasheet RTL8192S/RTL8192C are wrong, */
+/*     the correct arrangement is VO - Bit0, VI - Bit1, BE - Bit2, and BK - Bit3. */
+/*     8723 and 88E may be not correct either in the earlier version. Confirmed with DD Tim. */
 /*  By Bruce, 2011-09-22. */
 #define StopBecon              BIT6
 #define StopHigh                       BIT5
index fa5d70016f0582846e83a1049b32486ad209e845..b5a0be35a6ce55ff145d05ee358d3c08858b66b9 100644 (file)
@@ -15,7 +15,7 @@
 /*  */
 /*  <Roger_Notes> For RTL8723 WiFi/BT/GPS multi-function configuration. 2010.10.06. */
 /*  */
-enum RT_MULTI_FUNC {
+enum rt_multi_func {
        RT_MULTI_FUNC_NONE      = 0x00,
        RT_MULTI_FUNC_WIFI      = 0x01,
        RT_MULTI_FUNC_BT                = 0x02,
@@ -24,18 +24,18 @@ enum RT_MULTI_FUNC {
 /*  */
 /*  <Roger_Notes> For RTL8723 WiFi PDn/GPIO polarity control configuration. 2010.10.08. */
 /*  */
-enum RT_POLARITY_CTL {
+enum rt_polarity_ctl {
        RT_POLARITY_LOW_ACT     = 0,
        RT_POLARITY_HIGH_ACT    = 1,
 };
 
 /*  For RTL8723 regulator mode. by tynli. 2011.01.14. */
-enum RT_REGULATOR_MODE {
+enum rt_regulator_mode {
        RT_SWITCHING_REGULATOR  = 0,
        RT_LDO_REGULATOR        = 1,
 };
 
-enum RT_AMPDU_BURST {
+enum rt_ampdu_burst {
        RT_AMPDU_BURST_NONE     = 0,
        RT_AMPDU_BURST_92D      = 1,
        RT_AMPDU_BURST_88E      = 2,
@@ -176,10 +176,10 @@ struct dm_priv {
 
 
 struct hal_com_data {
-       HAL_VERSION VersionID;
-       enum RT_MULTI_FUNC MultiFunc; /*  For multi-function consideration. */
-       enum RT_POLARITY_CTL PolarityCtl; /*  For Wifi PDn Polarity control. */
-       enum RT_REGULATOR_MODE  RegulatorMode; /*  switching regulator or LDO */
+       struct hal_version VersionID;
+       enum rt_multi_func MultiFunc; /*  For multi-function consideration. */
+       enum rt_polarity_ctl PolarityCtl; /*  For Wifi PDn Polarity control. */
+       enum rt_regulator_mode  RegulatorMode; /*  switching regulator or LDO */
 
        u16 FirmwareVersion;
        u16 FirmwareVersionRev;
@@ -187,10 +187,10 @@ struct hal_com_data {
        u16 FirmwareSignature;
 
        /* current WIFI_PHY values */
-       enum WIRELESS_MODE CurrentWirelessMode;
-       enum CHANNEL_WIDTH CurrentChannelBW;
-       enum BAND_TYPE CurrentBandType; /* 0:2.4G, 1:5G */
-       enum BAND_TYPE BandSet;
+       enum wireless_mode CurrentWirelessMode;
+       enum channel_width CurrentChannelBW;
+       enum band_type CurrentBandType; /* 0:2.4G, 1:5G */
+       enum band_type BandSet;
        u8 CurrentChannel;
        u8 CurrentCenterFrequencyIndex1;
        u8 nCur40MhzPrimeSC;/*  Control channel sub-carrier */
@@ -233,7 +233,7 @@ struct hal_com_data {
        bool            EepromOrEfuse;
        u8              EfuseUsedPercentage;
        u16                     EfuseUsedBytes;
-       EFUSE_HAL               EfuseHal;
+       struct efuse_hal                EfuseHal;
 
        /* 3 [2.4G] */
        u8 Index24G_CCK_Base[MAX_RF_PATH][CHANNEL_MAX_NUMBER];
@@ -411,7 +411,7 @@ struct hal_com_data {
        u8 RegIQKFWOffload;
        struct submit_ctx       iqk_sctx;
 
-       enum RT_AMPDU_BURST     AMPDUBurstMode; /* 92C maybe not use, but for compile successfully */
+       enum rt_ampdu_burst     AMPDUBurstMode; /* 92C maybe not use, but for compile successfully */
 
        u32             sdio_himr;
        u32             sdio_hisr;
@@ -419,7 +419,7 @@ struct hal_com_data {
        /*  SDIO Tx FIFO related. */
        /*  HIQ, MID, LOW, PUB free pages; padapter->xmitpriv.free_txpg */
        u8      SdioTxFIFOFreePage[SDIO_TX_FREE_PG_QUEUE];
-       _lock           SdioTxFIFOFreePageLock;
+       spinlock_t              SdioTxFIFOFreePageLock;
        u8      SdioTxOQTMaxFreeSpace;
        u8      SdioTxOQTFreeSpace;
 
@@ -431,19 +431,14 @@ struct hal_com_data {
        u32             sdio_tx_max_len[SDIO_MAX_TX_QUEUE];/*  H, N, L, used for sdio tx aggregation max length per queue */
 
        struct dm_priv dmpriv;
-       DM_ODM_T                odmpriv;
+       struct dm_odm_t         odmpriv;
 
        /*  For bluetooth co-existance */
-       BT_COEXIST              bt_coexist;
+       struct bt_coexist               bt_coexist;
 
        /*  Interrupt related register information. */
        u32             SysIntrStatus;
        u32             SysIntrMask;
-
-#ifdef CONFIG_BACKGROUND_NOISE_MONITOR
-       s16 noise[ODM_MAX_CHANNEL_NUM];
-#endif
-
 };
 
 #define GET_HAL_DATA(__padapter)       ((struct hal_com_data *)((__padapter)->HalData))
index 426c8d58c444ab045e49189e3e38a56eb5180bfe..3cd46a670e6dea15ad1cadfc77042c0587504c95 100644 (file)
@@ -8,14 +8,14 @@
 #define __HAL_INTF_H__
 
 
-enum RTL871X_HCI_TYPE {
+enum rtl871x_hci_type {
        RTW_PCIE        = BIT0,
        RTW_USB         = BIT1,
        RTW_SDIO        = BIT2,
        RTW_GSPI        = BIT3,
 };
 
-enum HW_VARIABLES {
+enum hw_variables {
        HW_VAR_MEDIA_STATUS,
        HW_VAR_MEDIA_STATUS1,
        HW_VAR_SET_OPMODE,
@@ -85,14 +85,6 @@ enum HW_VARIABLES {
        HW_VAR_APFM_ON_MAC, /* Auto FSM to Turn On, include clock, isolation, power control for MAC only */
        /*  The valid upper nav range for the HW updating, if the true value is larger than the upper range, the HW won't update it. */
        /*  Unit in microsecond. 0 means disable this function. */
-#ifdef CONFIG_WOWLAN
-       HW_VAR_WOWLAN,
-       HW_VAR_WAKEUP_REASON,
-       HW_VAR_RPWM_TOG,
-#endif
-#ifdef CONFIG_AP_WOWLAN
-       HW_VAR_AP_WOWLAN,
-#endif
        HW_VAR_SYS_CLKR,
        HW_VAR_NAV_UPPER,
        HW_VAR_C2H_HANDLE,
@@ -120,7 +112,7 @@ enum HW_VARIABLES {
        HW_VAR_MACID_WAKEUP,
 };
 
-enum HAL_DEF_VARIABLE {
+enum hal_def_variable {
        HAL_DEF_UNDERCORATEDSMOOTHEDPWDB,
        HAL_DEF_IS_SUPPORT_ANT_DIV,
        HAL_DEF_CURRENT_ANTENNA,
@@ -155,14 +147,14 @@ enum HAL_DEF_VARIABLE {
        HAL_DEF_DBG_RX_INFO_DUMP,
 };
 
-enum HAL_ODM_VARIABLE {
+enum hal_odm_variable {
        HAL_ODM_STA_INFO,
        HAL_ODM_P2P_STATE,
        HAL_ODM_WIFI_DISPLAY_STATE,
        HAL_ODM_NOISE_MONITOR,
 };
 
-enum HAL_INTF_PS_FUNC {
+enum hal_intf_ps_func {
        HAL_USB_SELECT_SUSPEND,
        HAL_MAX_ID,
 };
@@ -202,9 +194,9 @@ struct hal_ops {
        u8 (*check_ips_status)(struct adapter *padapter);
        s32             (*interrupt_handler)(struct adapter *padapter);
        void    (*clear_interrupt)(struct adapter *padapter);
-       void (*set_bwmode_handler)(struct adapter *padapter, enum CHANNEL_WIDTH Bandwidth, u8 Offset);
+       void (*set_bwmode_handler)(struct adapter *padapter, enum channel_width Bandwidth, u8 Offset);
        void (*set_channel_handler)(struct adapter *padapter, u8 channel);
-       void (*set_chnl_bw_handler)(struct adapter *padapter, u8 channel, enum CHANNEL_WIDTH Bandwidth, u8 Offset40, u8 Offset80);
+       void (*set_chnl_bw_handler)(struct adapter *padapter, u8 channel, enum channel_width Bandwidth, u8 Offset40, u8 Offset80);
 
        void (*set_tx_power_level_handler)(struct adapter *padapter, u8 channel);
        void (*get_tx_power_level_handler)(struct adapter *padapter, s32 *powerlevel);
@@ -218,11 +210,11 @@ struct hal_ops {
 
        void (*SetHwRegHandlerWithBuf)(struct adapter *padapter, u8 variable, u8 *pbuf, int len);
 
-       u8 (*GetHalDefVarHandler)(struct adapter *padapter, enum HAL_DEF_VARIABLE eVariable, void *pValue);
-       u8 (*SetHalDefVarHandler)(struct adapter *padapter, enum HAL_DEF_VARIABLE eVariable, void *pValue);
+       u8 (*GetHalDefVarHandler)(struct adapter *padapter, enum hal_def_variable eVariable, void *pValue);
+       u8 (*SetHalDefVarHandler)(struct adapter *padapter, enum hal_def_variable eVariable, void *pValue);
 
-       void (*GetHalODMVarHandler)(struct adapter *padapter, enum HAL_ODM_VARIABLE eVariable, void *pValue1, void *pValue2);
-       void (*SetHalODMVarHandler)(struct adapter *padapter, enum HAL_ODM_VARIABLE eVariable, void *pValue1, bool bSet);
+       void (*GetHalODMVarHandler)(struct adapter *padapter, enum hal_odm_variable eVariable, void *pValue1, void *pValue2);
+       void (*SetHalODMVarHandler)(struct adapter *padapter, enum hal_odm_variable eVariable, void *pValue1, bool bSet);
 
        void (*UpdateRAMaskHandler)(struct adapter *padapter, u32 mac_id, u8 rssi_level);
        void (*SetBeaconRelatedRegistersHandler)(struct adapter *padapter);
@@ -232,7 +224,7 @@ struct hal_ops {
        void (*run_thread)(struct adapter *padapter);
        void (*cancel_thread)(struct adapter *padapter);
 
-       u8 (*interface_ps_func)(struct adapter *padapter, enum HAL_INTF_PS_FUNC efunc_id, u8 *val);
+       u8 (*interface_ps_func)(struct adapter *padapter, enum hal_intf_ps_func efunc_id, u8 *val);
 
        s32     (*hal_xmit)(struct adapter *padapter, struct xmit_frame *pxmitframe);
        /*
@@ -265,7 +257,7 @@ struct hal_ops {
        s32 (*fill_h2c_cmd)(struct adapter *, u8 ElementID, u32 CmdLen, u8 *pCmdBuffer);
 };
 
-enum RT_EEPROM_TYPE {
+enum rt_eeprom_type {
        EEPROM_93C46,
        EEPROM_93C56,
        EEPROM_BOOT_EFUSE,
@@ -296,14 +288,6 @@ enum wowlan_subcode {
        WOWLAN_AP_DISABLE               = 13
 };
 
-struct wowlan_ioctl_param {
-       unsigned int subcode;
-       unsigned int subcode_value;
-       unsigned int wakeup_reason;
-       unsigned int len;
-       unsigned char pattern[0];
-};
-
 #define Rx_Pairwisekey                 0x01
 #define Rx_GTK                                 0x02
 #define Rx_DisAssoc                            0x04
@@ -335,11 +319,11 @@ void rtw_hal_chip_configure(struct adapter *padapter);
 void rtw_hal_read_chip_info(struct adapter *padapter);
 void rtw_hal_read_chip_version(struct adapter *padapter);
 
-u8 rtw_hal_set_def_var(struct adapter *padapter, enum HAL_DEF_VARIABLE eVariable, void *pValue);
-u8 rtw_hal_get_def_var(struct adapter *padapter, enum HAL_DEF_VARIABLE eVariable, void *pValue);
+u8 rtw_hal_set_def_var(struct adapter *padapter, enum hal_def_variable eVariable, void *pValue);
+u8 rtw_hal_get_def_var(struct adapter *padapter, enum hal_def_variable eVariable, void *pValue);
 
-void rtw_hal_set_odm_var(struct adapter *padapter, enum HAL_ODM_VARIABLE eVariable, void *pValue1, bool bSet);
-void rtw_hal_get_odm_var(struct adapter *padapter, enum HAL_ODM_VARIABLE eVariable, void *pValue1, void *pValue2);
+void rtw_hal_set_odm_var(struct adapter *padapter, enum hal_odm_variable eVariable, void *pValue1, bool bSet);
+void rtw_hal_get_odm_var(struct adapter *padapter, enum hal_odm_variable eVariable, void *pValue1, void *pValue2);
 
 void rtw_hal_enable_interrupt(struct adapter *padapter);
 void rtw_hal_disable_interrupt(struct adapter *padapter);
@@ -378,7 +362,7 @@ void rtw_hal_write_rfreg(struct adapter *padapter, u32 eRFPath, u32 RegAddr, u32
 #define PHY_QueryMacReg PHY_QueryBBReg
 
 void rtw_hal_set_chan(struct adapter *padapter, u8 channel);
-void rtw_hal_set_chnl_bw(struct adapter *padapter, u8 channel, enum CHANNEL_WIDTH Bandwidth, u8 Offset40, u8 Offset80);
+void rtw_hal_set_chnl_bw(struct adapter *padapter, u8 channel, enum channel_width Bandwidth, u8 Offset40, u8 Offset80);
 void rtw_hal_dm_watchdog(struct adapter *padapter);
 void rtw_hal_dm_watchdog_in_lps(struct adapter *padapter);
 
index ed0caa0574e393d97cf24ffdc3b15840c441a6b9..90bb5d7846744a7fb9dc710d988a722f58f64c10 100644 (file)
 
 
 /*--------------------------Define Parameters-------------------------------*/
-enum BAND_TYPE {
+enum band_type {
        BAND_ON_2_4G = 0,
        BAND_ON_5G,
        BAND_ON_BOTH,
        BANDMAX
 };
 
-enum RF_TYPE {
+enum rf_type {
        RF_TYPE_MIN = 0,        /*  0 */
        RF_8225 = 1,            /*  1 11b/g RF for verification only */
        RF_8256 = 2,            /*  2 11b/g/n */
@@ -59,7 +59,7 @@ enum RF_TYPE {
        RF_TYPE_MAX
 };
 
-enum RF_PATH {
+enum rf_path {
        RF_PATH_A = 0,
        RF_PATH_B,
        RF_PATH_C,
@@ -74,7 +74,7 @@ enum RF_PATH {
 #define        RF_PATH_MAX_92C_88E             2
 #define        RF_PATH_MAX_90_8812             4       /* Max RF number 90 support */
 
-enum ANTENNA_PATH {
+enum antenna_path {
        ANTENNA_NONE    = 0,
        ANTENNA_D       = 1,
        ANTENNA_C       = 2,
@@ -93,7 +93,7 @@ enum ANTENNA_PATH {
        ANTENNA_ABCD    = 15
 };
 
-enum RF_CONTENT {
+enum rf_content {
        radioa_txt = 0x1000,
        radiob_txt = 0x1001,
        radioc_txt = 0x1002,
@@ -108,7 +108,7 @@ enum BaseBand_Config_Type {
        BaseBand_Config_PHY_REG_PG
 };
 
-enum HW_BLOCK {
+enum hw_block {
        HW_BLOCK_MAC = 0,
        HW_BLOCK_PHY0 = 1,
        HW_BLOCK_PHY1 = 2,
@@ -116,7 +116,7 @@ enum HW_BLOCK {
        HW_BLOCK_MAXIMUM = 4, /*  Never use this */
 };
 
-enum WIRELESS_MODE {
+enum wireless_mode {
        WIRELESS_MODE_UNKNOWN = 0x00,
        WIRELESS_MODE_A = 0x01,
        WIRELESS_MODE_B = 0x02,
@@ -146,30 +146,6 @@ struct SwChnlCmd {
        u32                     msDelay;
 };
 
-struct R_ANTENNA_SELECT_OFDM {
-#ifdef __LITTLE_ENDIAN
-       u32             r_tx_antenna:4;
-       u32             r_ant_l:4;
-       u32             r_ant_non_ht:4;
-       u32             r_ant_ht1:4;
-       u32             r_ant_ht2:4;
-       u32             r_ant_ht_s1:4;
-       u32             r_ant_non_ht_s1:4;
-       u32             OFDM_TXSC:2;
-       u32             Reserved:2;
-#else
-       u32             Reserved:2;
-       u32             OFDM_TXSC:2;
-       u32             r_ant_non_ht_s1:4;
-       u32             r_ant_ht_s1:4;
-       u32             r_ant_ht2:4;
-       u32             r_ant_ht1:4;
-       u32             r_ant_non_ht:4;
-       u32             r_ant_l:4;
-       u32             r_tx_antenna:4;
-#endif
-};
-
 /*--------------------------Exported Function prototype---------------------*/
 
 #endif /* __HAL_COMMON_H__ */
index ed3488a09d7982a106c8ee7b4ae4e366a3507ae8..ea494bcf830b81e5e62053eca557b94478abec0c 100644 (file)
@@ -47,20 +47,20 @@ void PHY_SetTxPowerIndex(struct adapter *Adapter, u32 PowerIndex,
                         u8 RFPath, u8 Rate);
 
 u8 PHY_GetTxPowerIndex(struct adapter *padapter, u8 RFPath, u8 Rate,
-                       enum CHANNEL_WIDTH BandWidth, u8 Channel);
+                       enum channel_width BandWidth, u8 Channel);
 
 void PHY_GetTxPowerLevel8723B(struct adapter *Adapter, s32 *powerlevel);
 
 void PHY_SetTxPowerLevel8723B(struct adapter *Adapter, u8 channel);
 
-void PHY_SetBWMode8723B(struct adapter *Adapter, enum CHANNEL_WIDTH Bandwidth,
+void PHY_SetBWMode8723B(struct adapter *Adapter, enum channel_width Bandwidth,
                        unsigned char Offset);
 
 /*  Call after initialization */
 void PHY_SwChnl8723B(struct adapter *Adapter, u8 channel);
 
 void PHY_SetSwChnlBWMode8723B(struct adapter *Adapter, u8 channel,
-                               enum CHANNEL_WIDTH Bandwidth,
+                               enum channel_width Bandwidth,
                                u8 Offset40, u8 Offset80);
 
 /*--------------------------Exported Function prototype End---------------------*/
index 28aca047dce63ad7c3247b50bb610e3891951cd7..0837506b6be8b5115b06af577e809b38be1227e2 100644 (file)
        {0xFFFF, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, 0, PWR_CMD_END, 0, 0}, 
 
 
-extern WLAN_PWR_CFG rtl8723B_power_on_flow[RTL8723B_TRANS_CARDEMU_TO_ACT_STEPS+RTL8723B_TRANS_END_STEPS];
-extern WLAN_PWR_CFG rtl8723B_radio_off_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+RTL8723B_TRANS_END_STEPS];
-extern WLAN_PWR_CFG rtl8723B_card_disable_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+RTL8723B_TRANS_CARDEMU_TO_PDN_STEPS+RTL8723B_TRANS_END_STEPS];
-extern WLAN_PWR_CFG rtl8723B_card_enable_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+RTL8723B_TRANS_CARDEMU_TO_PDN_STEPS+RTL8723B_TRANS_END_STEPS];
-extern WLAN_PWR_CFG rtl8723B_suspend_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+RTL8723B_TRANS_CARDEMU_TO_SUS_STEPS+RTL8723B_TRANS_END_STEPS];
-extern WLAN_PWR_CFG rtl8723B_resume_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+RTL8723B_TRANS_CARDEMU_TO_SUS_STEPS+RTL8723B_TRANS_END_STEPS];
-extern WLAN_PWR_CFG rtl8723B_hwpdn_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+RTL8723B_TRANS_CARDEMU_TO_PDN_STEPS+RTL8723B_TRANS_END_STEPS];
-extern WLAN_PWR_CFG rtl8723B_enter_lps_flow[RTL8723B_TRANS_ACT_TO_LPS_STEPS+RTL8723B_TRANS_END_STEPS];
-extern WLAN_PWR_CFG rtl8723B_leave_lps_flow[RTL8723B_TRANS_LPS_TO_ACT_STEPS+RTL8723B_TRANS_END_STEPS];
-extern WLAN_PWR_CFG rtl8723B_enter_swlps_flow[RTL8723B_TRANS_ACT_TO_SWLPS_STEPS+RTL8723B_TRANS_END_STEPS];
-extern WLAN_PWR_CFG rtl8723B_leave_swlps_flow[RTL8723B_TRANS_SWLPS_TO_ACT_STEPS+RTL8723B_TRANS_END_STEPS];
+extern struct wlan_pwr_cfg rtl8723B_power_on_flow[RTL8723B_TRANS_CARDEMU_TO_ACT_STEPS+RTL8723B_TRANS_END_STEPS];
+extern struct wlan_pwr_cfg rtl8723B_radio_off_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+RTL8723B_TRANS_END_STEPS];
+extern struct wlan_pwr_cfg rtl8723B_card_disable_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+RTL8723B_TRANS_CARDEMU_TO_PDN_STEPS+RTL8723B_TRANS_END_STEPS];
+extern struct wlan_pwr_cfg rtl8723B_card_enable_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+RTL8723B_TRANS_CARDEMU_TO_PDN_STEPS+RTL8723B_TRANS_END_STEPS];
+extern struct wlan_pwr_cfg rtl8723B_suspend_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+RTL8723B_TRANS_CARDEMU_TO_SUS_STEPS+RTL8723B_TRANS_END_STEPS];
+extern struct wlan_pwr_cfg rtl8723B_resume_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+RTL8723B_TRANS_CARDEMU_TO_SUS_STEPS+RTL8723B_TRANS_END_STEPS];
+extern struct wlan_pwr_cfg rtl8723B_hwpdn_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+RTL8723B_TRANS_CARDEMU_TO_PDN_STEPS+RTL8723B_TRANS_END_STEPS];
+extern struct wlan_pwr_cfg rtl8723B_enter_lps_flow[RTL8723B_TRANS_ACT_TO_LPS_STEPS+RTL8723B_TRANS_END_STEPS];
+extern struct wlan_pwr_cfg rtl8723B_leave_lps_flow[RTL8723B_TRANS_LPS_TO_ACT_STEPS+RTL8723B_TRANS_END_STEPS];
+extern struct wlan_pwr_cfg rtl8723B_enter_swlps_flow[RTL8723B_TRANS_ACT_TO_SWLPS_STEPS+RTL8723B_TRANS_END_STEPS];
+extern struct wlan_pwr_cfg rtl8723B_leave_swlps_flow[RTL8723B_TRANS_SWLPS_TO_ACT_STEPS+RTL8723B_TRANS_END_STEPS];
 #endif
index f80db2c984a4ee5cd59aed5466c6dba9087781ad..8a10bca876b81eefb3bdf5fc0f8d9c8d63d2e39c 100644 (file)
@@ -125,7 +125,7 @@ extern u8 RSN_CIPHER_SUITE_CCMP[];
 extern u8 RSN_CIPHER_SUITE_WEP104[];
 
 
-typedef enum _RATEID_IDX_ {
+enum rateid_idx {
        RATEID_IDX_BGN_40M_2SS = 0,
        RATEID_IDX_BGN_40M_1SS = 1,
        RATEID_IDX_BGN_20M_2SS_BN = 2,
@@ -137,9 +137,9 @@ typedef enum _RATEID_IDX_ {
        RATEID_IDX_B = 8,
        RATEID_IDX_VHT_2SS = 9,
        RATEID_IDX_VHT_1SS = 10,
-} RATEID_IDX, *PRATEID_IDX;
+};
 
-typedef enum _RATR_TABLE_MODE {
+enum ratr_table_mode {
        RATR_INX_WIRELESS_NGB = 0,      /*  BGN 40 Mhz 2SS 1SS */
        RATR_INX_WIRELESS_NG = 1,               /*  GN or N */
        RATR_INX_WIRELESS_NB = 2,               /*  BGN 20 Mhz 2SS 1SS  or BN */
@@ -149,10 +149,10 @@ typedef enum _RATR_TABLE_MODE {
        RATR_INX_WIRELESS_B = 6,
        RATR_INX_WIRELESS_MC = 7,
        RATR_INX_WIRELESS_AC_N = 8,
-} RATR_TABLE_MODE, *PRATR_TABLE_MODE;
+};
 
 
-enum NETWORK_TYPE {
+enum network_type {
        WIRELESS_INVALID = 0,
        /* Sub-Element */
        WIRELESS_11B = BIT(0), /*  tx: cck only , rx: cck only, hw: cck */
@@ -266,14 +266,6 @@ struct sta_data {
 /* this is stolen from ipw2200 driver */
 #define IEEE_IBSS_MAC_HASH_SIZE 31
 
-struct ieee_ibss_seq {
-       u8 mac[ETH_ALEN];
-       u16 seq_num;
-       u16 frag_num;
-       unsigned long packet_time;
-       struct list_head        list;
-};
-
 struct eapol {
        u8 snap[6];
        u16 ethertype;
@@ -423,7 +415,7 @@ struct ieee80211_snap_hdr {
 #define IEEE80211_OFDM_SHIFT_MASK_A         4
 
 
-enum MGN_RATE {
+enum mgn_rate {
        MGN_1M          = 0x02,
        MGN_2M          = 0x04,
        MGN_5_5M        = 0x0B,
@@ -521,16 +513,6 @@ enum MGN_RATE {
 /* NOTE: This data is for statistical purposes; not all hardware provides this
  *       information for frames received.  Not setting these will not cause
  *       any adverse affects. */
-struct ieee80211_rx_stats {
-       s8 rssi;
-       u8 signal;
-       u8 noise;
-       u8 received_channel;
-       u16 rate; /* in 100 kbps */
-       u8 mask;
-       u8 freq;
-       u16 len;
-};
 
 /* IEEE 802.11 requires that STA supports concurrent reception of at least
  * three fragmented frames. This define can be increased to support more
@@ -538,61 +520,6 @@ struct ieee80211_rx_stats {
  * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
 #define IEEE80211_FRAG_CACHE_LEN 4
 
-struct ieee80211_frag_entry {
-       u32 first_frag_time;
-       uint seq;
-       uint last_frag;
-       uint qos;   /* jackson */
-       uint tid;       /* jackson */
-       struct sk_buff *skb;
-       u8 src_addr[ETH_ALEN];
-       u8 dst_addr[ETH_ALEN];
-};
-
-struct ieee80211_stats {
-       uint tx_unicast_frames;
-       uint tx_multicast_frames;
-       uint tx_fragments;
-       uint tx_unicast_octets;
-       uint tx_multicast_octets;
-       uint tx_deferred_transmissions;
-       uint tx_single_retry_frames;
-       uint tx_multiple_retry_frames;
-       uint tx_retry_limit_exceeded;
-       uint tx_discards;
-       uint rx_unicast_frames;
-       uint rx_multicast_frames;
-       uint rx_fragments;
-       uint rx_unicast_octets;
-       uint rx_multicast_octets;
-       uint rx_fcs_errors;
-       uint rx_discards_no_buffer;
-       uint tx_discards_wrong_sa;
-       uint rx_discards_undecryptable;
-       uint rx_message_in_msg_fragments;
-       uint rx_message_in_bad_msg_fragments;
-};
-
-struct ieee80211_softmac_stats {
-       uint rx_ass_ok;
-       uint rx_ass_err;
-       uint rx_probe_rq;
-       uint tx_probe_rs;
-       uint tx_beacons;
-       uint rx_auth_rq;
-       uint rx_auth_rs_ok;
-       uint rx_auth_rs_err;
-       uint tx_auth_rq;
-       uint no_auth_rs;
-       uint no_ass_rs;
-       uint tx_ass_rq;
-       uint rx_ass_rq;
-       uint tx_probe_rq;
-       uint reassoc;
-       uint swtxstop;
-       uint swtxawake;
-};
-
 #define SEC_KEY_1         (1<<0)
 #define SEC_KEY_2         (1<<1)
 #define SEC_KEY_3         (1<<2)
@@ -615,18 +542,6 @@ struct ieee80211_softmac_stats {
 #define BIP_MAX_KEYID 5
 #define BIP_AAD_SIZE  20
 
-struct ieee80211_security {
-       u16 active_key:2,
-            enabled:1,
-           auth_mode:2,
-            auth_algo:4,
-            unicast_uses_group:1;
-       u8 key_sizes[WEP_KEYS];
-       u8 keys[WEP_KEYS][WEP_KEY_LEN];
-       u8 level;
-       u16 flags;
-} __attribute__ ((packed));
-
 /*
 
  802.11 data frame from AP
@@ -642,15 +557,6 @@ Total: 28-2340 bytes
 
 */
 
-struct ieee80211_header_data {
-       u16 frame_ctl;
-       u16 duration_id;
-       u8 addr1[6];
-       u8 addr2[6];
-       u8 addr3[6];
-       u16 seq_ctrl;
-};
-
 #define BEACON_PROBE_SSID_ID_POSITION 12
 
 /* Management Frame Information Element Types */
@@ -799,7 +705,7 @@ enum rtw_ieee80211_category {
        RTW_WLAN_CATEGORY_P2P = 0x7f,/* P2P action frames */
 };
 
-enum _PUBLIC_ACTION {
+enum _public_action {
        ACT_PUBLIC_BSSCOEXIST = 0, /*  20/40 BSS Coexistence */
        ACT_PUBLIC_DSE_ENABLE = 1,
        ACT_PUBLIC_DSE_DEENABLE = 2,
@@ -983,14 +889,14 @@ struct rtw_ieee802_11_elems {
        u8 vht_op_mode_notify_len;
 };
 
-typedef enum { ParseOK = 0, ParseUnknown = 1, ParseFailed = -1 } ParseRes;
+enum ParseRes { ParseOK = 0, ParseUnknown = 1, ParseFailed = -1 };
 
-ParseRes rtw_ieee802_11_parse_elems(u8 *start, uint len,
+enum ParseRes rtw_ieee802_11_parse_elems(u8 *start, uint len,
                                struct rtw_ieee802_11_elems *elems,
                                int show_errors);
 
 u8 *rtw_set_fixed_ie(unsigned char *pbuf, unsigned int len, unsigned char *source, unsigned int *frlen);
-u8 *rtw_set_ie(u8 *pbuf, sint index, uint len, u8 *source, uint *frlen);
+u8 *rtw_set_ie(u8 *pbuf, signed int index, uint len, u8 *source, uint *frlen);
 
 enum secondary_ch_offset {
        SCN = 0, /* no secondary channel */
@@ -998,7 +904,7 @@ enum secondary_ch_offset {
        SCB = 3,  /* secondary channel below */
 };
 
-u8 *rtw_get_ie(u8*pbuf, sint index, sint *len, sint limit);
+u8 *rtw_get_ie(u8 *pbuf, signed int index, signed int *len, signed int limit);
 u8 *rtw_get_ie_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui, u8 oui_len, u8 *ie, uint *ielen);
 int rtw_ies_remove_ie(u8 *ies, uint *ies_len, uint offset, u8 eid, u8 *oui, u8 oui_len);
 
@@ -1026,7 +932,8 @@ u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8
  * @buf_len:
  */
 #define for_each_ie(ie, buf, buf_len) \
-       for (ie = (void*)buf; (((u8 *)ie) - ((u8 *)buf) + 1) < buf_len; ie = (void*)(((u8 *)ie) + *(((u8 *)ie)+1) + 2))
+       for (ie = (void *)buf; (((u8 *)ie) - ((u8 *)buf) + 1) < buf_len; \
+               ie = (void *)(((u8 *)ie) + *(((u8 *)ie) + 1) + 2))
 
 uint   rtw_get_rateset_len(u8 *rateset);
 
@@ -1046,7 +953,7 @@ void rtw_get_bcn_info(struct wlan_network *pnetwork);
 
 void rtw_macaddr_cfg(struct device *dev, u8 *mac_addr);
 
-u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI, unsigned char * MCS_rate);
+u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI, unsigned char *MCS_rate);
 
 int rtw_action_frame_parse(const u8 *frame, u32 frame_len, u8 *category, u8 *action);
 const char *action_public_str(u8 action);
index 44d0a098265970c93cb8029f5c6a42e61e0e1bd1..7c86d05084d89e99ca3170f209633051a4170962 100644 (file)
@@ -67,7 +67,7 @@ struct rtw_wdev_priv {
        struct adapter *padapter;
 
        struct cfg80211_scan_request *scan_request;
-       _lock scan_req_lock;
+       spinlock_t scan_req_lock;
 
        struct net_device *pmon_ndev;/* for monitor interface */
        char ifname_mon[IFNAMSIZ + 1]; /* interface name for monitor interface */
@@ -106,7 +106,7 @@ void rtw_cfg80211_indicate_scan_done(struct adapter *adapter, bool aborted);
 void rtw_cfg80211_indicate_sta_assoc(struct adapter *padapter, u8 *pmgmt_frame, uint frame_len);
 void rtw_cfg80211_indicate_sta_disassoc(struct adapter *padapter, unsigned char *da, unsigned short reason);
 
-void rtw_cfg80211_rx_action(struct adapter *adapter, u8 *frame, uint frame_len, const char*msg);
+void rtw_cfg80211_rx_action(struct adapter *adapter, u8 *frame, uint frame_len, const char *msg);
 
 bool rtw_cfg80211_pwr_mgmt(struct adapter *adapter);
 
index c59c1384944b4ea1d5cafc44116dfac467430d0c..48c90f00cc2ebb1d38b305d41d171e023baba8f6 100644 (file)
@@ -32,15 +32,9 @@ Under Async. IRP (SDIO/USB)
 The protection mechanism is through the pending queue.
 */
 
-       _mutex ioctl_mutex;
+       struct mutex ioctl_mutex;
 };
 
-
-#ifdef CONFIG_R871X_TEST
-int rtw_start_pseudo_adhoc(struct adapter *padapter);
-int rtw_stop_pseudo_adhoc(struct adapter *padapter);
-#endif
-
 struct dvobj_priv *devobj_init(void);
 void devobj_deinit(struct dvobj_priv *pdvobj);
 
@@ -70,9 +64,11 @@ int rtw_ips_pwr_up(struct adapter *padapter);
 void rtw_ips_pwr_down(struct adapter *padapter);
 
 int rtw_drv_register_netdev(struct adapter *padapter);
-void rtw_ndev_destructor(_nic_hdl ndev);
+void rtw_ndev_destructor(struct net_device *ndev);
 
 int rtw_suspend_common(struct adapter *padapter);
 int rtw_resume_common(struct adapter *padapter);
 
+int netdev_open(struct net_device *pnetdev);
+
 #endif /* _OSDEP_INTF_H_ */
index dcc3cdce6d4b7a497751c64af26daea6638b60a8..c4d29d65187f930f45b02a0a71b6c912e87a9c46 100644 (file)
@@ -80,11 +80,11 @@ enum mstat_f {
 #define mstat_tf_idx(flags) ((flags)&0xff)
 #define mstat_ff_idx(flags) (((flags)&0xff00) >> 8)
 
-typedef enum mstat_status {
+enum mstat_status {
        MSTAT_ALLOC_SUCCESS = 0,
        MSTAT_ALLOC_FAIL,
        MSTAT_FREE
-} MSTAT_STATUS;
+};
 
 #define rtw_mstat_update(flag, status, sz) do {} while (0)
 #define rtw_mstat_dump(sel) do {} while (0)
@@ -94,7 +94,7 @@ void _kfree(u8 *pbuf, u32 sz);
 
 struct sk_buff *_rtw_skb_alloc(u32 sz);
 struct sk_buff *_rtw_skb_copy(const struct sk_buff *skb);
-int _rtw_netif_rx(_nic_hdl ndev, struct sk_buff *skb);
+int _rtw_netif_rx(struct net_device *ndev, struct sk_buff *skb);
 
 #define rtw_malloc(sz)                 _rtw_malloc((sz))
 #define rtw_zmalloc(sz)                        _rtw_zmalloc((sz))
@@ -136,15 +136,8 @@ static inline int rtw_bug_check(void *parg1, void *parg2, void *parg3, void *par
 #define MAC_ARG(x) (x)
 #endif
 
-
-#ifdef CONFIG_AP_WOWLAN
-extern void rtw_softap_lock_suspend(void);
-extern void rtw_softap_unlock_suspend(void);
-#endif
-
 extern void rtw_free_netdev(struct net_device * netdev);
 
-
 /* Macros for handling unaligned memory accesses */
 
 void rtw_buf_free(u8 **buf, u32 *buf_len);
index 9194dea217fb670548c7959b9fbdd579f2a36d53..3492ec1efd1e05af2a1ec919941700615a3035fc 100644 (file)
         #include <net/ieee80211_radiotap.h>
        #include <net/cfg80211.h>
 
-       typedef spinlock_t      _lock;
-       typedef struct mutex            _mutex;
-       typedef struct timer_list _timer;
-
        struct  __queue {
                struct  list_head       queue;
-               _lock   lock;
+               spinlock_t      lock;
        };
 
-       typedef struct sk_buff  _pkt;
-       typedef unsigned char _buffer;
-
-       typedef int     _OS_STATUS;
-       /* typedef u32 _irqL; */
-       typedef unsigned long _irqL;
-       typedef struct  net_device * _nic_hdl;
-
        #define thread_exit() complete_and_exit(NULL, 0)
 
-       typedef void timer_hdl_return;
-       typedef void* timer_hdl_context;
-
-       typedef struct work_struct _workitem;
-
 static inline struct list_head *get_next(struct list_head      *list)
 {
        return list->next;
@@ -74,22 +57,22 @@ static inline struct list_head      *get_list_head(struct __queue   *queue)
        return (&(queue->queue));
 }
 
-static inline void _set_timer(_timer *ptimer, u32 delay_time)
+static inline void _set_timer(struct timer_list *ptimer, u32 delay_time)
 {
        mod_timer(ptimer, (jiffies + (delay_time * HZ / 1000)));
 }
 
-static inline void _init_workitem(_workitem *pwork, void *pfunc, void *cntx)
+static inline void _init_workitem(struct work_struct *pwork, void *pfunc, void *cntx)
 {
        INIT_WORK(pwork, pfunc);
 }
 
-static inline void _set_workitem(_workitem *pwork)
+static inline void _set_workitem(struct work_struct *pwork)
 {
        schedule_work(pwork);
 }
 
-static inline void _cancel_workitem_sync(_workitem *pwork)
+static inline void _cancel_workitem_sync(struct work_struct *pwork)
 {
        cancel_work_sync(pwork);
 }
@@ -137,6 +120,6 @@ static inline struct adapter *rtw_netdev_priv(struct net_device *netdev)
 }
 
 struct net_device *rtw_alloc_etherdev_with_old_priv(int sizeof_priv, void *old_priv);
-extern struct net_device * rtw_alloc_etherdev(int sizeof_priv);
+extern struct net_device *rtw_alloc_etherdev(int sizeof_priv);
 
 #endif
index e85aafc93f6d89837d8d728e4a6cd4f4e65edc0b..83330ea98fbf7381b28ec82d85dc72c452be6f7a 100644 (file)
@@ -8,13 +8,13 @@
 #define __RECV_OSDEP_H_
 
 
-extern sint _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter);
+extern signed int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter);
 extern void _rtw_free_recv_priv(struct recv_priv *precvpriv);
 
 
 extern s32  rtw_recv_entry(union recv_frame *precv_frame);
 extern int rtw_recv_indicatepkt(struct adapter *adapter, union recv_frame *precv_frame);
-extern void rtw_recv_returnpacket(_nic_hdl cnxt, _pkt *preturnedpkt);
+extern void rtw_recv_returnpacket(struct net_device *cnxt, struct sk_buff *preturnedpkt);
 
 extern void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup);
 
@@ -31,8 +31,8 @@ void rtw_os_free_recvframe(union recv_frame *precvframe);
 
 void rtw_os_recvbuf_resource_free(struct adapter *padapter, struct recv_buf *precvbuf);
 
-_pkt *rtw_os_alloc_msdu_pkt(union recv_frame *prframe, u16 nSubframe_Length, u8 *pdata);
-void rtw_os_recv_indicate_pkt(struct adapter *padapter, _pkt *pkt, struct rx_pkt_attrib *pattrib);
+struct sk_buff *rtw_os_alloc_msdu_pkt(union recv_frame *prframe, u16 nSubframe_Length, u8 *pdata);
+void rtw_os_recv_indicate_pkt(struct adapter *padapter, struct sk_buff *pkt, struct rx_pkt_attrib *pattrib);
 
 void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl);
 
index 3bfb0e9be58214ac184eba2ff33027c94df96bed..9629a8844c2d2992ac1701f6a9e89a9fcd116a51 100644 (file)
@@ -177,12 +177,6 @@ void rtl8723b_download_BTCoex_AP_mode_rsvd_page(struct adapter *padapter);
 
 void CheckFwRsvdPageContent(struct adapter *padapter);
 
-#if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN)
-void rtl8723b_set_wowlan_cmd(struct adapter *padapter, u8 enable);
-void rtl8723b_set_ap_wowlan_cmd(struct adapter *padapter, u8 enable);
-void SetFwRelatedForWoWLAN8723b(struct adapter *padapter, u8 bHostIsGoingtoSleep);
-#endif/* CONFIG_WOWLAN */
-
 void rtl8723b_set_FwPwrModeInIPS_cmd(struct adapter *padapter, u8 cmd_param);
 
 s32 FillH2CCmd8723B(struct adapter *padapter, u8 ElementID, u32 CmdLen, u8 *pCmdBuffer);
index 8e6e972dd8436175c81fc1a526a480f7641378a6..9b043251ff30a4b0e966f39f008d86eb0f16ae91 100644 (file)
@@ -92,29 +92,11 @@ struct rt_firmware_hdr {
 #define BCNQ_PAGE_NUM_8723B  0x08
 #define BCNQ1_PAGE_NUM_8723B 0x00
 
-#ifdef CONFIG_PNO_SUPPORT
-#undef BCNQ1_PAGE_NUM_8723B
-#define BCNQ1_PAGE_NUM_8723B 0x00 /* 0x04 */
-#endif
-
 #define MAX_RX_DMA_BUFFER_SIZE_8723B 0x2800 /* RX 10K */
 
 /* For WoWLan, more reserved page */
 /* ARP Rsp:1, RWC:1, GTK Info:1, GTK RSP:2, GTK EXT MEM:2, PNO: 6 */
-#ifdef CONFIG_WOWLAN
-#define WOWLAN_PAGE_NUM_8723B 0x07
-#else
 #define WOWLAN_PAGE_NUM_8723B 0x00
-#endif
-
-#ifdef CONFIG_PNO_SUPPORT
-#undef WOWLAN_PAGE_NUM_8723B
-#define WOWLAN_PAGE_NUM_8723B 0x0d
-#endif
-
-#ifdef CONFIG_AP_WOWLAN
-#define AP_WOWLAN_PAGE_NUM_8723B 0x02
-#endif
 
 #define TX_TOTAL_PAGE_NUMBER_8723B     \
        (0xFF - BCNQ_PAGE_NUM_8723B  - \
@@ -170,7 +152,7 @@ struct rt_firmware_hdr {
 /* Description: Determine the types of C2H events that are the same in driver
  * and FW; First constructed by tynli. 2009.10.09.
  */
-typedef enum _C2H_EVT {
+enum c2h_evt {
        C2H_DBG = 0,
        C2H_TSF = 1,
        C2H_AP_RPT_RSP = 2,
@@ -184,21 +166,21 @@ typedef enum _C2H_EVT {
        C2H_HW_INFO_EXCH = 10,
        C2H_8723B_BT_MP_INFO = 11,
        MAX_C2HEVENT
-} C2H_EVT;
+};
 
-typedef struct _C2H_EVT_HDR {
+struct c2h_evt_hdr_t {
        u8 CmdID;
        u8 CmdLen;
        u8 CmdSeq;
-} __attribute__((__packed__)) C2H_EVT_HDR, *PC2H_EVT_HDR;
+} __attribute__((__packed__));
 
-typedef enum tag_Package_Definition {
+enum package_type_e { /* tag_Package_Definition */
        PACKAGE_DEFAULT,
        PACKAGE_QFN68,
        PACKAGE_TFBGA90,
        PACKAGE_TFBGA80,
        PACKAGE_TFBGA79
-} PACKAGE_TYPE_E;
+};
 
 #define INCLUDE_MULTI_FUNC_BT(_Adapter)  \
        (GET_HAL_DATA(_Adapter)->MultiFunc & RT_MULTI_FUNC_BT)
@@ -245,33 +227,19 @@ void C2HPacketHandler_8723B(struct adapter *padapter, u8 *pbuffer, u16 length);
 void rtl8723b_set_hal_ops(struct hal_ops *pHalFunc);
 void SetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val);
 void GetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val);
-u8 SetHalDefVar8723B(struct adapter *padapter, enum HAL_DEF_VARIABLE variable,
+u8 SetHalDefVar8723B(struct adapter *padapter, enum hal_def_variable variable,
                     void *pval);
-u8 GetHalDefVar8723B(struct adapter *padapter, enum HAL_DEF_VARIABLE variable,
+u8 GetHalDefVar8723B(struct adapter *padapter, enum hal_def_variable variable,
                     void *pval);
 
 /*  register */
 void rtl8723b_InitBeaconParameters(struct adapter *padapter);
 void _InitBurstPktLen_8723BS(struct adapter *adapter);
 void _8051Reset8723(struct adapter *padapter);
-#ifdef CONFIG_WOWLAN
-void Hal_DetectWoWMode(struct adapter *padapter);
-#endif /* CONFIG_WOWLAN */
 
 void rtl8723b_start_thread(struct adapter *padapter);
 void rtl8723b_stop_thread(struct adapter *padapter);
 
-#if defined(CONFIG_CHECK_BT_HANG)
-void rtl8723bs_init_checkbthang_workqueue(struct adapter *adapter);
-void rtl8723bs_free_checkbthang_workqueue(struct adapter *adapter);
-void rtl8723bs_cancle_checkbthang_workqueue(struct adapter *adapter);
-void rtl8723bs_hal_check_bt_hang(struct adapter *adapter);
-#endif
-
-#ifdef CONFIG_GPIO_WAKEUP
-void HalSetOutPutGPIO(struct adapter *padapter, u8 index, u8 OutPutValue);
-#endif
-
 int FirmwareDownloadBT(struct adapter *adapter, struct rt_firmware *firmware);
 
 void CCX_FwC2HTxRpt_8723b(struct adapter *padapter, u8 *pdata, u8 len);
index 60a1df703c8e48b2326e5b592153794c3d06d14c..a108ce89bce43298d6a154c403737f6b714c457c 100644 (file)
@@ -81,50 +81,6 @@ struct rxreport_8723b {
        u32 tsfl;
 };
 
-struct phystatus_8723b {
-       u32 rxgain_a:7;
-       u32 trsw_a:1;
-       u32 rxgain_b:7;
-       u32 trsw_b:1;
-       u32 chcorr_l:16;
-
-       u32 sigqualcck:8;
-       u32 cfo_a:8;
-       u32 cfo_b:8;
-       u32 chcorr_h:8;
-
-       u32 noisepwrdb_h:8;
-       u32 cfo_tail_a:8;
-       u32 cfo_tail_b:8;
-       u32 rsvd0824:8;
-
-       u32 rsvd1200:8;
-       u32 rxevm_a:8;
-       u32 rxevm_b:8;
-       u32 rxsnr_a:8;
-
-       u32 rxsnr_b:8;
-       u32 noisepwrdb_l:8;
-       u32 rsvd1616:8;
-       u32 postsnr_a:8;
-
-       u32 postsnr_b:8;
-       u32 csi_a:8;
-       u32 csi_b:8;
-       u32 targetcsi_a:8;
-
-       u32 targetcsi_b:8;
-       u32 sigevm:8;
-       u32 maxexpwr:8;
-       u32 exintflag:1;
-       u32 sgien:1;
-       u32 rxsc:2;
-       u32 idlelong:1;
-       u32 anttrainen:1;
-       u32 antselb:1;
-       u32 antsel:1;
-};
-
 s32 rtl8723bs_init_recv_priv(struct adapter *padapter);
 void rtl8723bs_free_recv_priv(struct adapter *padapter);
 
index d712c6d36a0849e25165980d8032219e47b491cc..525eb2facca068d7b2ed765de36ff57e867f75dd 100644 (file)
@@ -12,6 +12,6 @@ int   PHY_RF6052_Config8723B(struct adapter *Adapter);
 
 void
 PHY_RF6052SetBandwidth8723B(struct adapter *Adapter,
-       enum CHANNEL_WIDTH              Bandwidth);
+       enum channel_width              Bandwidth);
 
 #endif
index 9149fe5985456f143b14e6844c0b8d15ed89e915..999555476ebcc291cb1b9b4300747e65c9696333 100644 (file)
 #define REG_TXPKTBUF_BCNQ_BDNY_8723B   0x0424
 #define REG_TXPKTBUF_MGQ_BDNY_8723B    0x0425
 #define REG_TXPKTBUF_WMAC_LBK_BF_HD_8723B      0x045D
-#ifdef CONFIG_WOWLAN
-#define REG_TXPKTBUF_IV_LOW             0x0484
-#define REG_TXPKTBUF_IV_HIGH            0x0488
-#endif
 #define REG_AMPDU_BURST_MODE_8723B     0x04BC
 
 /*  */
 #define BIT_USB_RXDMA_AGG_EN   BIT(31)
 #define RXDMA_AGG_MODE_EN              BIT(1)
 
-#ifdef CONFIG_WOWLAN
-#define RXPKT_RELEASE_POLL             BIT(16)
-#define RXDMA_IDLE                             BIT(17)
-#define RW_RELEASE_EN                  BIT(18)
-#endif
-
 /*  */
 /*  */
 /*     0x0400h ~ 0x047Fh       Protocol Configuration */
index 243d36d9bc7bd88249f0185710c8f90b15b64622..56bdc14af47d19002b06205eb8be988eeedffd52 100644 (file)
@@ -59,7 +59,7 @@
 /*  */
 /* defined for TX DESC Operation */
 /*  */
-typedef struct txdesc_8723b {
+struct txdesc_8723b {
        /*  Offset 0 */
        u32 pktlen:16;
        u32 offset:8;
@@ -175,7 +175,7 @@ typedef struct txdesc_8723b {
        u32 txbf_path:1;
        u32 seq:12;
        u32 final_data_rate:8;
-} TXDESC_8723B, *PTXDESC_8723B;
+};
 
 #ifndef __INC_HAL8723BDESC_H
 #define __INC_HAL8723BDESC_H
@@ -443,7 +443,7 @@ s32 rtl8723bs_xmit_buf_handler(struct adapter *padapter);
 int rtl8723bs_xmit_thread(void *context);
 #define hal_xmit_handler rtl8723bs_xmit_buf_handler
 
-u8 BWMapping_8723B(struct adapter * Adapter, struct pkt_attrib *pattrib);
-u8 SCMapping_8723B(struct adapter * Adapter, struct pkt_attrib *pattrib);
+u8 BWMapping_8723B(struct adapter *Adapter, struct pkt_attrib *pattrib);
+u8 SCMapping_8723B(struct adapter *Adapter, struct pkt_attrib *pattrib);
 
 #endif
index 56c77bc7ca815cdfd0b64e6e8506a709ae60c2e0..88cbc12ce5d4e06ed9e82c059e20cf0d7c838aa7 100644 (file)
                /* u8 cmdthd_running; */
                u8 stop_req;
                struct adapter *padapter;
-               _mutex sctx_mutex;
+               struct mutex sctx_mutex;
        };
 
        struct  evt_priv {
-               _workitem c2h_wk;
+               struct work_struct c2h_wk;
                bool c2h_wk_alive;
                struct rtw_cbuf *c2h_queue;
                #define C2H_QUEUE_MAX_LEN 10
@@ -107,21 +107,6 @@ struct c2h_evt_hdr_88xx {
 
 #define c2h_evt_valid(c2h_evt) ((c2h_evt)->id || (c2h_evt)->plen)
 
-struct P2P_PS_Offload_t {
-       u8 Offload_En:1;
-       u8 role:1; /*  1: Owner, 0: Client */
-       u8 CTWindow_En:1;
-       u8 NoA0_En:1;
-       u8 NoA1_En:1;
-       u8 AllStaSleep:1; /*  Only valid in Owner */
-       u8 discovery:1;
-       u8 rsvd:1;
-};
-
-struct P2P_PS_CTWPeriod_t {
-       u8 CTWPeriod;   /* TU */
-};
-
 int rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj);
 extern struct cmd_obj *rtw_dequeue_cmd(struct cmd_priv *pcmdpriv);
 extern void rtw_free_cmd_obj(struct cmd_obj *pcmd);
@@ -158,7 +143,7 @@ enum rtw_drvextra_cmd_id {
        MAX_WK_CID
 };
 
-enum LPS_CTRL_TYPE {
+enum lps_ctrl_type {
        LPS_CTRL_SCAN = 0,
        LPS_CTRL_JOINBSS = 1,
        LPS_CTRL_CONNECT = 2,
@@ -168,24 +153,12 @@ enum LPS_CTRL_TYPE {
        LPS_CTRL_TRAFFIC_BUSY = 6,
 };
 
-enum RFINTFS {
+enum rfintfs {
        SWSI,
        HWSI,
        HWPI,
 };
 
-/*
-Caller Mode: Infra, Ad-HoC(C)
-
-Notes: To enter USB suspend mode
-
-Command Mode
-
-*/
-struct usb_suspend_parm {
-       u32 action;/*  1: sleep, 0:resume */
-};
-
 /*
 Caller Mode: Infra, Ad-HoC
 
@@ -265,7 +238,7 @@ Command-Event Mode
 #define RTW_SSID_SCAN_AMOUNT 9 /*  for WEXT_CSCAN_AMOUNT 9 */
 #define RTW_CHANNEL_SCAN_AMOUNT (14+37)
 struct sitesurvey_parm {
-       sint scan_mode; /* active: 1, passive: 0 */
+       signed int scan_mode;   /* active: 1, passive: 0 */
        u8 ssid_num;
        u8 ch_num;
        struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT];
@@ -399,10 +372,6 @@ struct getbasicrate_parm {
        u32 rsvd;
 };
 
-struct getbasicrate_rsp {
-       u8 basicrates[NumRates];
-};
-
 /*
 Caller Mode: Any
 
@@ -428,10 +397,6 @@ struct getdatarate_parm {
        u32 rsvd;
 
 };
-struct getdatarate_rsp {
-       u8 datarates[NumRates];
-};
-
 
 /*
 Caller Mode: Any
@@ -456,11 +421,6 @@ struct     getphyinfo_parm {
        u32 rsvd;
 };
 
-struct getphyinfo_rsp {
-       struct regulatory_class class_sets[NUM_REGULATORYS];
-       u8 status;
-};
-
 /*
 Caller Mode: Any
 
@@ -487,46 +447,6 @@ struct     getphy_parm {
        u32 rsvd;
 
 };
-struct getphy_rsp {
-       u8 rfchannel;
-       u8 modem;
-};
-
-struct readBB_parm {
-       u8 offset;
-};
-struct readBB_rsp {
-       u8 value;
-};
-
-struct readTSSI_parm {
-       u8 offset;
-};
-struct readTSSI_rsp {
-       u8 value;
-};
-
-struct writeBB_parm {
-       u8 offset;
-       u8 value;
-};
-
-struct readRF_parm {
-       u8 offset;
-};
-struct readRF_rsp {
-       u32 value;
-};
-
-struct writeRF_parm {
-       u32 offset;
-       u32 value;
-};
-
-struct getrfintfs_parm {
-       u8 rfintfs;
-};
-
 
 struct Tx_Beacon_param {
        struct wlan_bssid_ex network;
@@ -596,161 +516,10 @@ struct drvextra_cmd_parm {
 
 /*------------------- Below are used for RF/BB tunning ---------------------*/
 
-struct setantenna_parm {
-       u8 tx_antset;
-       u8 rx_antset;
-       u8 tx_antenna;
-       u8 rx_antenna;
-};
-
-struct enrateadaptive_parm {
-       u32 en;
-};
-
-struct settxagctbl_parm {
-       u32 txagc[MAX_RATES_LENGTH];
-};
-
-struct gettxagctbl_parm {
-       u32 rsvd;
-};
-struct gettxagctbl_rsp {
-       u32 txagc[MAX_RATES_LENGTH];
-};
-
-struct setagcctrl_parm {
-       u32 agcctrl;            /*  0: pure hw, 1: fw */
-};
-
-
-struct setssup_parm    {
-       u32 ss_ForceUp[MAX_RATES_LENGTH];
-};
-
-struct getssup_parm    {
-       u32 rsvd;
-};
-struct getssup_rsp     {
-       u8 ss_ForceUp[MAX_RATES_LENGTH];
-};
-
-
-struct setssdlevel_parm        {
-       u8 ss_DLevel[MAX_RATES_LENGTH];
-};
-
-struct getssdlevel_parm        {
-       u32 rsvd;
-};
-struct getssdlevel_rsp {
-       u8 ss_DLevel[MAX_RATES_LENGTH];
-};
-
-struct setssulevel_parm        {
-       u8 ss_ULevel[MAX_RATES_LENGTH];
-};
-
-struct getssulevel_parm        {
-       u32 rsvd;
-};
-struct getssulevel_rsp {
-       u8 ss_ULevel[MAX_RATES_LENGTH];
-};
-
-
-struct setcountjudge_parm {
-       u8 count_judge[MAX_RATES_LENGTH];
-};
-
-struct getcountjudge_parm {
-       u32 rsvd;
-};
 struct getcountjudge_rsp {
        u8 count_judge[MAX_RATES_LENGTH];
 };
 
-
-struct setratable_parm {
-       u8 ss_ForceUp[NumRates];
-       u8 ss_ULevel[NumRates];
-       u8 ss_DLevel[NumRates];
-       u8 count_judge[NumRates];
-};
-
-struct getratable_parm {
-                uint rsvd;
-};
-struct getratable_rsp {
-        u8 ss_ForceUp[NumRates];
-        u8 ss_ULevel[NumRates];
-        u8 ss_DLevel[NumRates];
-        u8 count_judge[NumRates];
-};
-
-
-/* to get TX, RX retry count */
-struct gettxretrycnt_parm {
-       unsigned int rsvd;
-};
-struct gettxretrycnt_rsp {
-       unsigned long tx_retrycnt;
-};
-
-struct getrxretrycnt_parm {
-       unsigned int rsvd;
-};
-struct getrxretrycnt_rsp {
-       unsigned long rx_retrycnt;
-};
-
-/* to get BCNOK, BCNERR count */
-struct getbcnokcnt_parm {
-       unsigned int rsvd;
-};
-struct getbcnokcnt_rsp {
-       unsigned long  bcnokcnt;
-};
-
-struct getbcnerrcnt_parm {
-       unsigned int rsvd;
-};
-struct getbcnerrcnt_rsp {
-       unsigned long bcnerrcnt;
-};
-
-/*  to get current TX power level */
-struct getcurtxpwrlevel_parm {
-       unsigned int rsvd;
-};
-struct getcurtxpwrlevel_rsp {
-       unsigned short tx_power;
-};
-
-struct setprobereqextraie_parm {
-       unsigned char e_id;
-       unsigned char ie_len;
-       unsigned char ie[0];
-};
-
-struct setassocreqextraie_parm {
-       unsigned char e_id;
-       unsigned char ie_len;
-       unsigned char ie[0];
-};
-
-struct setproberspextraie_parm {
-       unsigned char e_id;
-       unsigned char ie_len;
-       unsigned char ie[0];
-};
-
-struct setassocrspextraie_parm {
-       unsigned char e_id;
-       unsigned char ie_len;
-       unsigned char ie[0];
-};
-
-
 struct addBaReq_parm {
        unsigned int tid;
        u8 addr[ETH_ALEN];
@@ -786,7 +555,7 @@ struct TDLSoption_param {
 
 /*H2C Handler index: 64 */
 struct RunInThread_param {
-       void (*func)(void*);
+       void (*func)(void *);
        void *context;
 };
 
@@ -824,9 +593,9 @@ struct sta_info;
 extern u8 rtw_setstakey_cmd(struct adapter  *padapter, struct sta_info *sta, u8 unicast_key, bool enqueue);
 extern u8 rtw_clearstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 enqueue);
 
-extern u8 rtw_joinbss_cmd(struct adapter  *padapter, struct wlan_network* pnetwork);
+extern u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork);
 u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueue);
-extern u8 rtw_setopmode_cmd(struct adapter  *padapter, enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype, bool enqueue);
+extern u8 rtw_setopmode_cmd(struct adapter  *padapter, enum ndis_802_11_network_infrastructure networktype, bool enqueue);
 extern u8 rtw_setdatarate_cmd(struct adapter  *padapter, u8 *rateset);
 extern u8 rtw_setrfintfs_cmd(struct adapter  *padapter, u8 mode);
 
index 78f34f6cebb4b8d7ae68e32bea34bf96968db96c..da7f14aadaa024c1f4b2bcc58e3b16cf2bc7f978 100644 (file)
@@ -42,7 +42,7 @@
 /*  Besides, CustomerID of registry has precedence of that of EEPROM. */
 /*  defined below. 060703, by rcnjko. */
 /*  */
-typedef enum _RT_CUSTOMER_ID {
+enum rt_customer_id {
        RT_CID_DEFAULT = 0,
        RT_CID_8187_ALPHA0 = 1,
        RT_CID_8187_SERCOMM_PS = 2,
@@ -90,7 +90,7 @@ typedef enum _RT_CUSTOMER_ID {
        RT_CID_819x_ALPHA_Dlink = 44,/* add by ylb 20121012 for customer led for alpha */
        RT_CID_WNC_NEC = 45,/* add by page for NEC */
        RT_CID_DNI_BUFFALO = 46,/* add by page for NEC */
-} RT_CUSTOMER_ID, *PRT_CUSTOMER_ID;
+};
 
 struct eeprom_priv {
        u8 bautoload_fail_flag;
index 4abcbbc8f513b8501ea2612cfa3ff8266afc184b..5bae46ecd9de43df869c4a4c4b9b106335c750ab 100644 (file)
@@ -25,7 +25,7 @@
 #define        EFUSE_WIFI                              0
 #define        EFUSE_BT                                1
 
-enum _EFUSE_DEF_TYPE {
+enum _efuse_def_type {
        TYPE_EFUSE_MAX_SECTION                          = 0,
        TYPE_EFUSE_REAL_CONTENT_LEN                     = 1,
        TYPE_AVAILABLE_EFUSE_BYTES_BANK         = 2,
@@ -57,15 +57,15 @@ enum _EFUSE_DEF_TYPE {
 #define                EFUSE_MAX_WORD_UNIT                     4
 
 /*------------------------------Define structure----------------------------*/
-typedef struct PG_PKT_STRUCT_A {
+struct pgpkt_struct {
        u8 offset;
        u8 word_en;
        u8 data[8];
        u8 word_cnts;
-} PGPKT_STRUCT, *PPGPKT_STRUCT;
+};
 
 /*------------------------------Define structure----------------------------*/
-typedef struct _EFUSE_HAL {
+struct efuse_hal {
        u8 fakeEfuseBank;
        u32 fakeEfuseUsedBytes;
        u8 fakeEfuseContent[EFUSE_MAX_HW_SIZE];
@@ -82,7 +82,7 @@ typedef struct _EFUSE_HAL {
        u8 fakeBTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE];
        u8 fakeBTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN];
        u8 fakeBTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN];
-} EFUSE_HAL, *PEFUSE_HAL;
+};
 
 
 /*------------------------Export global variable----------------------------*/
index 560521c80ace919809edbad35b859c00ef771fd2..d48bae5416fe62dfb943da113c0f2f49600a755c 100644 (file)
@@ -60,10 +60,6 @@ struct stadel_event {
  int mac_id;
 };
 
-struct addba_event {
-       unsigned int tid;
-};
-
 struct wmm_event {
        unsigned char wmm;
 };
@@ -88,13 +84,6 @@ struct event_node {
        int     caller_ff_sz;
 };
 
-struct c2hevent_queue {
-       volatile int    head;
-       volatile int    tail;
-       struct  event_node      nodes[C2HEVENT_SZ];
-       unsigned char seq;
-};
-
 #define NETWORK_QUEUE_SZ       4
 
 struct network_queue {
index a72f51031f89ee2a83fdc1672ca1c57eed0e4faf..fb321d20d276bb444b95c5dc853d1afd786c9d58 100644 (file)
@@ -37,7 +37,7 @@ struct ht_priv {
 
 };
 
-typedef enum AGGRE_SIZE {
+enum aggre_size_e {
        HT_AGG_SIZE_8K = 0,
        HT_AGG_SIZE_16K = 1,
        HT_AGG_SIZE_32K = 2,
@@ -46,9 +46,9 @@ typedef enum AGGRE_SIZE {
        VHT_AGG_SIZE_256K = 5,
        VHT_AGG_SIZE_512K = 6,
        VHT_AGG_SIZE_1024K = 7,
-} AGGRE_SIZE_E, *PAGGRE_SIZE_E;
+};
 
-typedef enum _RT_HT_INF0_CAP {
+enum rt_ht_inf0_capbility {
        RT_HT_CAP_USE_TURBO_AGGR = 0x01,
        RT_HT_CAP_USE_LONG_PREAMBLE = 0x02,
        RT_HT_CAP_USE_AMPDU = 0x04,
@@ -57,13 +57,13 @@ typedef enum _RT_HT_INF0_CAP {
        RT_HT_CAP_USE_92SE = 0x20,
        RT_HT_CAP_USE_88C_92C = 0x40,
        RT_HT_CAP_USE_AP_CLIENT_MODE = 0x80,    /*  AP team request to reserve this bit, by Emily */
-} RT_HT_INF0_CAPBILITY, *PRT_HT_INF0_CAPBILITY;
+};
 
-typedef enum _RT_HT_INF1_CAP {
+enum rt_ht_inf1_capbility {
        RT_HT_CAP_USE_VIDEO_CLIENT = 0x01,
        RT_HT_CAP_USE_JAGUAR_BCUT = 0x02,
        RT_HT_CAP_USE_JAGUAR_CCUT = 0x04,
-} RT_HT_INF1_CAPBILITY, *PRT_HT_INF1_CAPBILITY;
+};
 
 #define        LDPC_HT_ENABLE_RX                       BIT0
 #define        LDPC_HT_ENABLE_TX                       BIT1
index b7076b590d84a3bdc9abc061380bcf876ac9f8e5..fbb73e698e09d3a7223a6aa08a8c10c1d0fed4c8 100644 (file)
@@ -127,117 +127,6 @@ struct    intf_hdl {
        struct _io_ops  io_ops;
 };
 
-struct reg_protocol_rd {
-
-#ifdef __LITTLE_ENDIAN
-
-       /* DW1 */
-       u32     NumOfTrans:4;
-       u32     Reserved1:4;
-       u32     Reserved2:24;
-       /* DW2 */
-       u32     ByteCount:7;
-       u32     WriteEnable:1;          /* 0:read, 1:write */
-       u32     FixOrContinuous:1;      /* 0:continuous, 1: Fix */
-       u32     BurstMode:1;
-       u32     Byte1Access:1;
-       u32     Byte2Access:1;
-       u32     Byte4Access:1;
-       u32     Reserved3:3;
-       u32     Reserved4:16;
-       /* DW3 */
-       u32     BusAddress;
-       /* DW4 */
-       /* u32  Value; */
-#else
-
-
-/* DW1 */
-       u32 Reserved1  :4;
-       u32 NumOfTrans :4;
-
-       u32 Reserved2  :24;
-
-       /* DW2 */
-       u32 WriteEnable : 1;
-       u32 ByteCount :7;
-
-
-       u32 Reserved3 : 3;
-       u32 Byte4Access : 1;
-
-       u32 Byte2Access : 1;
-       u32 Byte1Access : 1;
-       u32 BurstMode :1;
-       u32 FixOrContinuous : 1;
-
-       u32 Reserved4 : 16;
-
-       /* DW3 */
-       u32     BusAddress;
-
-       /* DW4 */
-       /* u32  Value; */
-
-#endif
-
-};
-
-
-struct reg_protocol_wt {
-
-
-#ifdef __LITTLE_ENDIAN
-
-       /* DW1 */
-       u32     NumOfTrans:4;
-       u32     Reserved1:4;
-       u32     Reserved2:24;
-       /* DW2 */
-       u32     ByteCount:7;
-       u32     WriteEnable:1;          /* 0:read, 1:write */
-       u32     FixOrContinuous:1;      /* 0:continuous, 1: Fix */
-       u32     BurstMode:1;
-       u32     Byte1Access:1;
-       u32     Byte2Access:1;
-       u32     Byte4Access:1;
-       u32     Reserved3:3;
-       u32     Reserved4:16;
-       /* DW3 */
-       u32     BusAddress;
-       /* DW4 */
-       u32     Value;
-
-#else
-       /* DW1 */
-       u32 Reserved1  :4;
-       u32 NumOfTrans :4;
-
-       u32 Reserved2  :24;
-
-       /* DW2 */
-       u32 WriteEnable : 1;
-       u32 ByteCount :7;
-
-       u32 Reserved3 : 3;
-       u32 Byte4Access : 1;
-
-       u32 Byte2Access : 1;
-       u32 Byte1Access : 1;
-       u32 BurstMode :1;
-       u32 FixOrContinuous : 1;
-
-       u32 Reserved4 : 16;
-
-       /* DW3 */
-       u32     BusAddress;
-
-       /* DW4 */
-       u32     Value;
-
-#endif
-
-};
 #define SD_IO_TRY_CNT (8)
 #define MAX_CONTINUAL_IO_ERR SD_IO_TRY_CNT
 
@@ -250,7 +139,7 @@ Below is the data structure used by _io_handler
 */
 
 struct io_queue {
-       _lock   lock;
+       spinlock_t      lock;
        struct list_head        free_ioreqs;
        struct list_head                pending;                /* The io_req list that will be served in the single protocol read/write. */
        struct list_head                processing;
index f0457e91d00f3f01fe810590afddee095725b4ea..31424bf2d9261da9a5d49d9236274006438bd9cb 100644 (file)
 
 typedef u8 NDIS_802_11_PMKID_VALUE[16];
 
-typedef struct _BSSIDInfo {
-       NDIS_802_11_MAC_ADDRESS  BSSID;
-       NDIS_802_11_PMKID_VALUE  PMKID;
-} BSSIDInfo, *PBSSIDInfo;
-
-
-u8 rtw_set_802_11_authentication_mode(struct adapter *pdapter, enum NDIS_802_11_AUTHENTICATION_MODE authmode);
+u8 rtw_set_802_11_authentication_mode(struct adapter *pdapter, enum ndis_802_11_authentication_mode authmode);
 u8 rtw_set_802_11_bssid(struct adapter *padapter, u8 *bssid);
-u8 rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep * wep);
+u8 rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep *wep);
 u8 rtw_set_802_11_disassociate(struct adapter *padapter);
 u8 rtw_set_802_11_bssid_list_scan(struct adapter *padapter, struct ndis_802_11_ssid *pssid, int ssid_max_num);
-u8 rtw_set_802_11_infrastructure_mode(struct adapter *padapter, enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype);
-u8 rtw_set_802_11_ssid(struct adapter *padapter, struct ndis_802_11_ssid * ssid);
+u8 rtw_set_802_11_infrastructure_mode(struct adapter *padapter, enum ndis_802_11_network_infrastructure networktype);
+u8 rtw_set_802_11_ssid(struct adapter *padapter, struct ndis_802_11_ssid *ssid);
 u8 rtw_set_802_11_connect(struct adapter *padapter, u8 *bssid, struct ndis_802_11_ssid *ssid);
 
 u8 rtw_validate_bssid(u8 *bssid);
 u8 rtw_validate_ssid(struct ndis_802_11_ssid *ssid);
 
+u8 rtw_do_join(struct adapter *padapter);
+
 u16 rtw_get_cur_max_rate(struct adapter *adapter);
 
 #endif
index d8655cb619a19f9c0f53dfdda1cbe92872fc5dcc..25cfb4cc021b100dcda70dfff488d5500689a148 100644 (file)
@@ -81,13 +81,13 @@ enum dot11AuthAlgrthmNum {
 };
 
 /*  Scan type including active and passive scan. */
-typedef enum _RT_SCAN_TYPE {
+enum rt_scan_type {
        SCAN_PASSIVE,
        SCAN_ACTIVE,
        SCAN_MIX,
-} RT_SCAN_TYPE, *PRT_SCAN_TYPE;
+};
 
-enum  _BAND {
+enum  _band {
        GHZ24_50 = 0,
        GHZ_50,
        GHZ_24,
@@ -101,7 +101,7 @@ enum DriverInterface {
        DRIVER_CFG80211 = 2
 };
 
-enum SCAN_RESULT_TYPE {
+enum scan_result_type {
        SCAN_RESULT_P2P_ONLY = 0,               /*      Will return all the P2P devices. */
        SCAN_RESULT_ALL = 1,                    /*      Will return all the scanned device, include AP. */
        SCAN_RESULT_WFD_TYPE = 2                /*      Will just return the correct WFD device. */
@@ -130,11 +130,11 @@ SHALL not lock up more than one locks at a time!
 struct sitesurvey_ctrl {
        u64     last_tx_pkts;
        uint    last_rx_pkts;
-       sint    traffic_busy;
-       _timer  sitesurvey_ctrl_timer;
+       signed int      traffic_busy;
+       struct timer_list       sitesurvey_ctrl_timer;
 };
 
-typedef struct _RT_LINK_DETECT_T {
+struct rt_link_detect_t {
        u32                     NumTxOkInPeriod;
        u32                     NumRxOkInPeriod;
        u32                     NumRxUnicastOkInPeriod;
@@ -147,7 +147,7 @@ typedef struct _RT_LINK_DETECT_T {
        /* u8 TrafficBusyState; */
        u8 TrafficTransitionCount;
        u32 LowPowerTransitionCount;
-} RT_LINK_DETECT_T, *PRT_LINK_DETECT_T;
+};
 
 struct profile_info {
        u8 ssidlen;
@@ -202,25 +202,15 @@ struct scan_limit_info {
        u8                      operation_ch[2];                                /*      Store the operation channel of invitation request frame */
 };
 
-struct cfg80211_wifidirect_info {
-       _timer                                  remain_on_ch_timer;
-       u8                              restore_channel;
-       struct ieee80211_channel        remain_on_ch_channel;
-       enum nl80211_channel_type       remain_on_ch_type;
-       u64                                             remain_on_ch_cookie;
-       bool is_ro_ch;
-       unsigned long last_ro_ch_time; /* this will be updated at the beginning and end of ro_ch */
-};
-
 struct wifidirect_info {
        struct adapter                          *padapter;
-       _timer                                  find_phase_timer;
-       _timer                                  restore_p2p_state_timer;
+       struct timer_list                                       find_phase_timer;
+       struct timer_list                                       restore_p2p_state_timer;
 
        /*      Used to do the scanning. After confirming the peer is availalble, the driver transmits the P2P frame to peer. */
-       _timer                                  pre_tx_scan_timer;
-       _timer                                  reset_ch_sitesurvey;
-       _timer                                  reset_ch_sitesurvey2;   /*      Just for resetting the scan limit function by using p2p nego */
+       struct timer_list                                       pre_tx_scan_timer;
+       struct timer_list                                       reset_ch_sitesurvey;
+       struct timer_list                                       reset_ch_sitesurvey2;   /*      Just for resetting the scan limit function by using p2p nego */
        struct tx_provdisc_req_info tx_prov_disc_info;
        struct rx_provdisc_req_info rx_prov_disc_info;
        struct tx_invite_req_info invitereq_info;
@@ -230,9 +220,9 @@ struct wifidirect_info {
        struct group_id_info    groupid_info;   /*      Store the group id information when doing the group negotiation handshake. */
        struct scan_limit_info  rx_invitereq_info;      /*      Used for get the limit scan channel from the Invitation procedure */
        struct scan_limit_info  p2p_info;               /*      Used for get the limit scan channel from the P2P negotiation handshake */
-       enum P2P_ROLE                   role;
-       enum P2P_STATE                  pre_p2p_state;
-       enum P2P_STATE                  p2p_state;
+       enum p2p_role                   role;
+       enum p2p_state                  pre_p2p_state;
+       enum p2p_state                  p2p_state;
        u8                              device_addr[ETH_ALEN];  /*      The device address should be the mac address of this device. */
        u8                              interface_addr[ETH_ALEN];
        u8                              social_chan[4];
@@ -275,7 +265,7 @@ struct wifidirect_info {
                                                                                                                /*      In this case, the driver can issue the tdls setup request frame */
                                                                                                                /*      even the current security is weak security. */
 
-       enum    P2P_WPSINFO             ui_got_wps_info;                        /*      This field will store the WPS value (PIN value or PBC) that UI had got from the user. */
+       enum    p2p_wpsinfo             ui_got_wps_info;                        /*      This field will store the WPS value (PIN value or PBC) that UI had got from the user. */
        u16                                     supported_wps_cm;                       /*      This field describes the WPS config method which this driver supported. */
                                                                                                                /*      The value should be the combination of config method defined in page104 of WPS v2.0 spec. */
        u8                              external_uuid;                          /*  UUID flag */
@@ -292,34 +282,6 @@ struct tdls_ss_record {    /* signal strength record */
        u8 is_tdls_sta; /*  true: direct link sta, false: else */
 };
 
-struct tdls_info {
-       u8                      ap_prohibited;
-       u8                      link_established;
-       u8                      sta_cnt;
-       u8                      sta_maximum;    /*  1:tdls sta is equal (NUM_STA-1), reach max direct link number; 0: else; */
-       struct tdls_ss_record   ss_record;
-       u8                      ch_sensing;
-       u8                      cur_channel;
-       u8                      candidate_ch;
-       u8                      collect_pkt_num[MAX_CHANNEL_NUM];
-       _lock                           cmd_lock;
-       _lock                           hdl_lock;
-       u8                      watchdog_count;
-       u8                      dev_discovered;         /* WFD_TDLS: for sigma test */
-       u8                      tdls_enable;
-       u8                      external_setup; /*  true: setup is handled by wpa_supplicant */
-};
-
-struct tdls_txmgmt {
-       u8 peer[ETH_ALEN];
-       u8 action_code;
-       u8 dialog_token;
-       u16 status_code;
-       u8 *buf;
-       size_t len;
-       u8 external_support;
-};
-
 /* used for mlme_priv.roam_flags */
 enum {
        RTW_ROAM_ON_EXPIRED = BIT0,
@@ -329,8 +291,8 @@ enum {
 
 struct mlme_priv {
 
-       _lock   lock;
-       sint    fw_state;       /* shall we protect this variable? maybe not necessarily... */
+       spinlock_t      lock;
+       signed int      fw_state;       /* shall we protect this variable? maybe not necessarily... */
        u8 bScanInProcess;
        u8 to_join; /* flag */
 
@@ -361,15 +323,15 @@ struct mlme_priv {
 
        u32 auto_scan_int_ms;
 
-       _timer assoc_timer;
+       struct timer_list assoc_timer;
 
        uint assoc_by_bssid;
        uint assoc_by_rssi;
 
-       _timer scan_to_timer; /*  driver itself handles scan_timeout status. */
+       struct timer_list scan_to_timer; /*  driver itself handles scan_timeout status. */
        unsigned long scan_start_time; /*  used to evaluate the time spent in scanning */
 
-       _timer set_scan_deny_timer;
+       struct timer_list set_scan_deny_timer;
        atomic_t set_scan_deny; /* 0: allowed, 1: deny */
 
        struct qos_priv qospriv;
@@ -385,12 +347,12 @@ struct mlme_priv {
 
        struct ht_priv htpriv;
 
-       RT_LINK_DETECT_T        LinkDetectInfo;
-       _timer  dynamic_chk_timer; /* dynamic/periodic check timer */
+       struct rt_link_detect_t LinkDetectInfo;
+       struct timer_list       dynamic_chk_timer; /* dynamic/periodic check timer */
 
        u8 acm_mask; /*  for wmm acm mask */
        u8 ChannelPlan;
-       RT_SCAN_TYPE    scan_mode; /*  active: 1, passive: 0 */
+       enum rt_scan_type       scan_mode; /*  active: 1, passive: 0 */
 
        u8 *wps_probe_req_ie;
        u32 wps_probe_req_ie_len;
@@ -448,7 +410,7 @@ struct mlme_priv {
        u32 p2p_go_probe_resp_ie_len; /* for GO */
        u32 p2p_assoc_req_ie_len;
 
-       _lock   bcn_update_lock;
+       spinlock_t      bcn_update_lock;
        u8 update_bcn;
 
        u8 NumOfBcnInfoChkFail;
@@ -490,9 +452,9 @@ extern int rtw_init_mlme_priv(struct adapter *adapter);/*  (struct mlme_priv *pm
 extern void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv);
 
 
-extern sint rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv);
-extern sint rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, sint keyid, u8 set_tx, bool enqueue);
-extern sint rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv);
+extern signed int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv);
+extern signed int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, signed int keyid, u8 set_tx, bool enqueue);
+extern signed int rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv);
 
 static inline u8 *get_bssid(struct mlme_priv *pmlmepriv)
 {      /* if sta_mode:pmlmepriv->cur_network.network.MacAddress => bssid */
@@ -500,7 +462,7 @@ static inline u8 *get_bssid(struct mlme_priv *pmlmepriv)
        return pmlmepriv->cur_network.network.MacAddress;
 }
 
-static inline sint check_fwstate(struct mlme_priv *pmlmepriv, sint state)
+static inline signed int check_fwstate(struct mlme_priv *pmlmepriv, signed int state)
 {
        if (pmlmepriv->fw_state & state)
                return true;
@@ -508,7 +470,7 @@ static inline sint check_fwstate(struct mlme_priv *pmlmepriv, sint state)
        return false;
 }
 
-static inline sint get_fwstate(struct mlme_priv *pmlmepriv)
+static inline signed int get_fwstate(struct mlme_priv *pmlmepriv)
 {
        return pmlmepriv->fw_state;
 }
@@ -520,7 +482,7 @@ static inline sint get_fwstate(struct mlme_priv *pmlmepriv)
  * ### NOTE:#### (!!!!)
  * MUST TAKE CARE THAT BEFORE CALLING THIS FUNC, YOU SHOULD HAVE LOCKED pmlmepriv->lock
  */
-static inline void set_fwstate(struct mlme_priv *pmlmepriv, sint state)
+static inline void set_fwstate(struct mlme_priv *pmlmepriv, signed int state)
 {
        pmlmepriv->fw_state |= state;
        /* FOR HW integration */
@@ -528,7 +490,7 @@ static inline void set_fwstate(struct mlme_priv *pmlmepriv, sint state)
                pmlmepriv->bScanInProcess = true;
 }
 
-static inline void _clr_fwstate_(struct mlme_priv *pmlmepriv, sint state)
+static inline void _clr_fwstate_(struct mlme_priv *pmlmepriv, signed int state)
 {
        pmlmepriv->fw_state &= ~state;
        /* FOR HW integration */
@@ -540,7 +502,7 @@ static inline void _clr_fwstate_(struct mlme_priv *pmlmepriv, sint state)
  * No Limit on the calling context,
  * therefore set it to be the critical section...
  */
-static inline void clr_fwstate(struct mlme_priv *pmlmepriv, sint state)
+static inline void clr_fwstate(struct mlme_priv *pmlmepriv, signed int state)
 {
        spin_lock_bh(&pmlmepriv->lock);
        if (check_fwstate(pmlmepriv, state) == true)
@@ -548,7 +510,7 @@ static inline void clr_fwstate(struct mlme_priv *pmlmepriv, sint state)
        spin_unlock_bh(&pmlmepriv->lock);
 }
 
-static inline void set_scanned_network_val(struct mlme_priv *pmlmepriv, sint val)
+static inline void set_scanned_network_val(struct mlme_priv *pmlmepriv, signed int val)
 {
        spin_lock_bh(&pmlmepriv->lock);
        pmlmepriv->num_of_scanned = val;
@@ -600,9 +562,9 @@ extern void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_ne
 
 extern struct wlan_network *_rtw_find_network(struct __queue *scanned_queue, u8 *addr);
 
-extern sint rtw_if_up(struct adapter *padapter);
+extern signed int rtw_if_up(struct adapter *padapter);
 
-sint rtw_linked_check(struct adapter *padapter);
+signed int rtw_linked_check(struct adapter *padapter);
 
 u8 *rtw_get_capability_from_ie(u8 *ie);
 u8 *rtw_get_beacon_interval_from_ie(u8 *ie);
index 1567831caf914a7453492a9e33e07eff919c8224..fb283dc04ee2b36f03ad0f6efae41d7711509667 100644 (file)
@@ -113,9 +113,9 @@ extern unsigned char WMM_PARA_OUI[];
 /*     We just add new channel plan when the new channel plan is different from any of the following */
 /*     channel plan. */
 /*     If you just wnat to customize the acitions(scan period or join actions) about one of the channel plan, */
-/*     customize them in RT_CHANNEL_INFO in the RT_CHANNEL_LIST. */
+/*     customize them in rt_channel_info in the RT_CHANNEL_LIST. */
 /*  */
-typedef enum _RT_CHANNEL_DOMAIN {
+enum rt_channel_domain {
        /*  old channel plan mapping ===== */
        RT_CHANNEL_DOMAIN_FCC = 0x00,
        RT_CHANNEL_DOMAIN_IC = 0x01,
@@ -181,9 +181,9 @@ typedef enum _RT_CHANNEL_DOMAIN {
        /*  Add new channel plan above this line =============== */
        RT_CHANNEL_DOMAIN_MAX,
        RT_CHANNEL_DOMAIN_REALTEK_DEFINE = 0x7F,
-} RT_CHANNEL_DOMAIN, *PRT_CHANNEL_DOMAIN;
+};
 
-typedef enum _RT_CHANNEL_DOMAIN_2G {
+enum rt_channel_domain_2g {
        RT_CHANNEL_DOMAIN_2G_WORLD = 0x00,              /* Worldwird 13 */
        RT_CHANNEL_DOMAIN_2G_ETSI1 = 0x01,              /* Europe */
        RT_CHANNEL_DOMAIN_2G_FCC1 = 0x02,               /* US */
@@ -193,9 +193,9 @@ typedef enum _RT_CHANNEL_DOMAIN_2G {
        RT_CHANNEL_DOMAIN_2G_NULL = 0x06,
        /*  Add new channel plan above this line =============== */
        RT_CHANNEL_DOMAIN_2G_MAX,
-} RT_CHANNEL_DOMAIN_2G, *PRT_CHANNEL_DOMAIN_2G;
+};
 
-typedef enum _RT_CHANNEL_DOMAIN_5G {
+enum rt_channel_domain_5g {
        RT_CHANNEL_DOMAIN_5G_NULL = 0x00,
        RT_CHANNEL_DOMAIN_5G_ETSI1 = 0x01,              /* Europe */
        RT_CHANNEL_DOMAIN_5G_ETSI2 = 0x02,              /* Australia, New Zealand */
@@ -234,29 +234,29 @@ typedef enum _RT_CHANNEL_DOMAIN_5G {
        RT_CHANNEL_DOMAIN_5G_JAPAN_NO_DFS = 0x21,
        RT_CHANNEL_DOMAIN_5G_FCC4_NO_DFS = 0x22,
        RT_CHANNEL_DOMAIN_5G_MAX,
-} RT_CHANNEL_DOMAIN_5G, *PRT_CHANNEL_DOMAIN_5G;
+};
 
 #define rtw_is_channel_plan_valid(chplan) (chplan < RT_CHANNEL_DOMAIN_MAX || chplan == RT_CHANNEL_DOMAIN_REALTEK_DEFINE)
 
-typedef struct _RT_CHANNEL_PLAN {
+struct rt_channel_plan {
        unsigned char Channel[MAX_CHANNEL_NUM];
        unsigned char Len;
-} RT_CHANNEL_PLAN, *PRT_CHANNEL_PLAN;
+};
 
-typedef struct _RT_CHANNEL_PLAN_2G {
+struct rt_channel_plan_2g {
        unsigned char Channel[MAX_CHANNEL_NUM_2G];
        unsigned char Len;
-} RT_CHANNEL_PLAN_2G, *PRT_CHANNEL_PLAN_2G;
+};
 
-typedef struct _RT_CHANNEL_PLAN_5G {
+struct rt_channel_plan_5g {
        unsigned char Channel[MAX_CHANNEL_NUM_5G];
        unsigned char Len;
-} RT_CHANNEL_PLAN_5G, *PRT_CHANNEL_PLAN_5G;
+};
 
-typedef struct _RT_CHANNEL_PLAN_MAP {
+struct rt_channel_plan_map {
        unsigned char Index2G;
        unsigned char Index5G;
-} RT_CHANNEL_PLAN_MAP, *PRT_CHANNEL_PLAN_MAP;
+};
 
 enum Associated_AP {
        atherosAP       = 0,
@@ -270,7 +270,7 @@ enum Associated_AP {
        maxAP,
 };
 
-typedef enum _HT_IOT_PEER {
+enum ht_iot_peer_e {
        HT_IOT_PEER_UNKNOWN                     = 0,
        HT_IOT_PEER_REALTEK                     = 1,
        HT_IOT_PEER_REALTEK_92SE                = 2,
@@ -290,10 +290,10 @@ typedef enum _HT_IOT_PEER {
        HT_IOT_PEER_REALTEK_JAGUAR_BCUTAP = 16,
        HT_IOT_PEER_REALTEK_JAGUAR_CCUTAP = 17,
        HT_IOT_PEER_MAX                                 = 18
-} HT_IOT_PEER_E, *PHTIOT_PEER_E;
+};
 
 
-enum SCAN_STATE {
+enum scan_state {
        SCAN_DISABLE = 0,
        SCAN_START = 1,
        SCAN_TXNULL = 2,
@@ -304,13 +304,13 @@ enum SCAN_STATE {
 
 struct mlme_handler {
        unsigned int   num;
-       charstr;
+       char *str;
        unsigned int (*func)(struct adapter *padapter, union recv_frame *precv_frame);
 };
 
 struct action_handler {
        unsigned int   num;
-       charstr;
+       char *str;
        unsigned int (*func)(struct adapter *padapter, union recv_frame *precv_frame);
 };
 
@@ -417,12 +417,12 @@ struct mlme_ext_info {
 };
 
 /*  The channel information about this channel including joining, scanning, and power constraints. */
-typedef struct _RT_CHANNEL_INFO {
+struct rt_channel_info {
        u8              ChannelNum;             /*  The channel number. */
-       RT_SCAN_TYPE    ScanType;               /*  Scan type such as passive or active scan. */
-} RT_CHANNEL_INFO, *PRT_CHANNEL_INFO;
+       enum rt_scan_type       ScanType;               /*  Scan type such as passive or active scan. */
+};
 
-int rtw_ch_set_search_ch(RT_CHANNEL_INFO *ch_set, const u32 ch);
+int rtw_ch_set_search_ch(struct rt_channel_info *ch_set, const u32 ch);
 bool rtw_mlme_band_check(struct adapter *adapter, const u32 ch);
 
 /*  P2P_MAX_REG_CLASSES - Maximum number of regulatory classes */
@@ -474,7 +474,7 @@ struct mlme_ext_priv {
        unsigned char cur_wireless_mode;        /*  NETWORK_TYPE */
 
        unsigned char max_chan_nums;
-       RT_CHANNEL_INFO         channel_set[MAX_CHANNEL_NUM];
+       struct rt_channel_info          channel_set[MAX_CHANNEL_NUM];
        struct p2p_channels channel_list;
        unsigned char basicrate[NumRates];
        unsigned char datarate[NumRates];
@@ -483,10 +483,10 @@ struct mlme_ext_priv {
        struct ss_res           sitesurvey_res;
        struct mlme_ext_info mlmext_info;/* for sta/adhoc mode, including current scanning/connecting/connected related info. */
                                                      /* for ap mode, network includes ap's cap_info */
-       _timer          survey_timer;
-       _timer          link_timer;
-       _timer          sa_query_timer;
-       /* _timer               ADDBA_timer; */
+       struct timer_list               survey_timer;
+       struct timer_list               link_timer;
+       struct timer_list               sa_query_timer;
+       /* struct timer_list            ADDBA_timer; */
        u16             chan_scan_time;
        unsigned long last_scan_time;
        u8 scan_abort;
@@ -589,21 +589,21 @@ int is_IBSS_empty(struct adapter *padapter);
 
 unsigned char check_assoc_AP(u8 *pframe, uint len);
 
-int WMM_param_handler(struct adapter *padapter, struct ndis_80211_var_ie *     pIE);
+int WMM_param_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE);
 void WMMOnAssocRsp(struct adapter *padapter);
 
-void HT_caps_handler(struct adapter *padapter, struct ndis_80211_var_ie * pIE);
-void HT_info_handler(struct adapter *padapter, struct ndis_80211_var_ie * pIE);
+void HT_caps_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE);
+void HT_info_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE);
 void HTOnAssocRsp(struct adapter *padapter);
 
-void ERP_IE_handler(struct adapter *padapter, struct ndis_80211_var_ie * pIE);
+void ERP_IE_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE);
 void VCS_update(struct adapter *padapter, struct sta_info *psta);
 void update_ldpc_stbc_cap(struct sta_info *psta);
 
 void update_beacon_info(struct adapter *padapter, u8 *pframe, uint len, struct sta_info *psta);
 int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len);
 void update_IOT_info(struct adapter *padapter);
-void update_capinfo(struct adapter * Adapter, u16 updateCap);
+void update_capinfo(struct adapter *Adapter, u16 updateCap);
 void update_wireless_mode(struct adapter *padapter);
 void update_sta_basic_rate(struct sta_info *psta, u8 wireless_mode);
 int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie, uint var_ie_len, int cam_idx);
@@ -630,8 +630,8 @@ extern u8 rtw_search_max_mac_id(struct adapter *padapter);
 void report_join_res(struct adapter *padapter, int res);
 void report_survey_event(struct adapter *padapter, union recv_frame *precv_frame);
 void report_surveydone_event(struct adapter *padapter);
-void report_del_sta_event(struct adapter *padapter, unsigned charMacAddr, unsigned short reason);
-void report_add_sta_event(struct adapter *padapter, unsigned charMacAddr, int cam_idx);
+void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsigned short reason);
+void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int cam_idx);
 void report_wmm_edca_update(struct adapter *padapter);
 
 u8 chk_bmc_sleepq_cmd(struct adapter *padapter);
index 2ea7100c3a4cc302de8375acf70572e73b51fc5b..ead63cf09fe089dc46b9ad0ca01b67a851cb2b17 100644 (file)
@@ -15,7 +15,7 @@ struct mp_xmit_frame {
 
        struct pkt_attrib attrib;
 
-       _pkt *pkt;
+       struct sk_buff *pkt;
 
        int frame_tag;
 
@@ -49,14 +49,14 @@ struct mp_tx {
 #define MP_MAX_LINES_BYTES     256
 
 typedef void (*MPT_WORK_ITEM_HANDLER)(void *Adapter);
-typedef struct _MPT_CONTEXT {
+struct mpt_context {
        /*  Indicate if we have started Mass Production Test. */
        bool                    bMassProdTest;
 
        /*  Indicate if the driver is unloading or unloaded. */
        bool                    bMptDrvUnload;
 
-       _timer                  MPh2c_timeout_timer;
+       struct timer_list                       MPh2c_timeout_timer;
 /*  Event used to sync H2c for BT control */
 
        bool            MptH2cRspEvent;
@@ -89,7 +89,7 @@ typedef struct _MPT_CONTEXT {
        /*  The RfPath of IO operation is depend of MptActType. */
        u32             MptRfPath;
 
-       enum WIRELESS_MODE              MptWirelessModeToSw;    /*  Wireless mode to switch. */
+       enum wireless_mode              MptWirelessModeToSw;    /*  Wireless mode to switch. */
        u8      MptChannelToSw;         /*  Channel to switch. */
        u8      MptInitGainToSet;       /*  Initial gain to set. */
        u32             MptBandWidth;           /*  bandwidth to switch. */
@@ -148,7 +148,7 @@ typedef struct _MPT_CONTEXT {
        u32             mptOutLen;
     u8          mptOutBuf[100];
 
-} MPT_CONTEXT, *PMPT_CONTEXT;
+};
 /* endif */
 
 /* E-Fuse */
@@ -189,12 +189,6 @@ enum {
        CTA_TEST,
        MP_DISABLE_BT_COEXIST,
        MP_PwrCtlDM,
-#ifdef CONFIG_WOWLAN
-       MP_WOW_ENABLE,
-#endif
-#ifdef CONFIG_AP_WOWLAN
-       MP_AP_WOW_ENABLE,
-#endif
        MP_NULL,
        MP_GET_TXPOWER_INX,
 };
@@ -260,28 +254,11 @@ struct mp_priv {
        bool bSetRxBssid;
        bool bTxBufCkFail;
 
-       MPT_CONTEXT MptCtx;
+       struct mpt_context MptCtx;
 
        u8 *TXradomBuffer;
 };
 
-typedef struct _IOCMD_STRUCT_ {
-       u8 cmdclass;
-       u16 value;
-       u8 index;
-} IOCMD_STRUCT;
-
-struct rf_reg_param {
-       u32 path;
-       u32 offset;
-       u32 value;
-};
-
-struct bb_reg_param {
-       u32 offset;
-       u32 value;
-};
-
 #define LOWER  true
 #define RAISE  false
 
@@ -289,7 +266,7 @@ struct bb_reg_param {
 #define BB_REG_BASE_ADDR               0x800
 
 /* MP variables */
-enum MP_MODE {
+enum mp_mode {
        MP_OFF,
        MP_ON,
        MP_ERR,
@@ -306,7 +283,7 @@ enum MP_MODE {
 extern u8 mpdatarate[NumRates];
 
 /* MP set force data rate base on the definition. */
-enum MPT_RATE_INDEX {
+enum mpt_rate_index {
        /* CCK rate. */
        MPT_RATE_1M = 0,        /* 0 */
        MPT_RATE_2M,
@@ -366,13 +343,13 @@ enum MPT_RATE_INDEX {
 
 #define MAX_TX_PWR_INDEX_N_MODE 64     /*  0x3F */
 
-enum POWER_MODE {
+enum power_mode {
        POWER_LOW = 0,
        POWER_NORMAL
 };
 
 /*  The following enumeration is used to define the value of Reg0xD00[30:28] or JaguarReg0x914[18:16]. */
-enum OFDM_TX_MODE {
+enum ofdm_tx_mode {
        OFDM_ALL_OFF            = 0,
        OFDM_ContinuousTx       = 1,
        OFDM_SingleCarrier      = 2,
@@ -394,14 +371,14 @@ enum OFDM_TX_MODE {
 #define Mac_HT_FasleAlarm              0x90000000
 #define Mac_DropPacket                 0xA0000000
 
-enum ENCRY_CTRL_STATE {
+enum encry_ctrl_state {
        HW_CONTROL,             /* hw encryption& decryption */
        SW_CONTROL,             /* sw encryption& decryption */
        HW_ENCRY_SW_DECRY,      /* hw encryption & sw decryption */
        SW_ENCRY_HW_DECRY       /* sw encryption & hw decryption */
 };
 
-enum MPT_TXPWR_DEF {
+enum mpt_txpwr_def {
        MPT_CCK,
        MPT_OFDM, /*  L and HT OFDM */
        MPT_VHT_OFDM
index 0987891e85aee339f9f55e07fec4d32671aded05..cec9fc0cf7940be4b93bd75f4284725bcdc582e6 100644 (file)
@@ -46,11 +46,6 @@ enum Power_Mgnt {
        PS_MODE_NUM,
 };
 
-#ifdef CONFIG_PNO_SUPPORT
-#define MAX_PNO_LIST_COUNT 16
-#define MAX_SCAN_LIST_COUNT 14 /* 2.4G only */
-#endif
-
 /*
        BIT[2:0] = HW state
        BIT[3] = Protocol PS state,   0: register active state , 1: register sleep state
@@ -146,7 +141,7 @@ enum { /*  for ips_mode */
 };
 
 /*  Design for pwrctrl_priv.ips_deny, 32 bits for 32 reasons at most */
-enum PS_DENY_REASON {
+enum ps_deny_reason {
        PS_DENY_DRV_INITIAL = 0,
        PS_DENY_SCAN,
        PS_DENY_JOIN,
@@ -158,47 +153,6 @@ enum PS_DENY_REASON {
        PS_DENY_OTHERS = 31
 };
 
-#ifdef CONFIG_PNO_SUPPORT
-struct pno_nlo_info {
-       u32 fast_scan_period;                           /* Fast scan period */
-       u32 ssid_num;                           /* number of entry */
-       u32 slow_scan_period;                   /* slow scan period */
-       u32 fast_scan_iterations;                       /* Fast scan iterations */
-       u8 ssid_length[MAX_PNO_LIST_COUNT];     /* SSID Length Array */
-       u8 ssid_cipher_info[MAX_PNO_LIST_COUNT];        /* Cipher information for security */
-       u8 ssid_channel_info[MAX_PNO_LIST_COUNT];       /* channel information */
-};
-
-struct pno_ssid {
-       u32     SSID_len;
-       u8 SSID[32];
-};
-
-struct pno_ssid_list {
-       struct pno_ssid node[MAX_PNO_LIST_COUNT];
-};
-
-struct pno_scan_channel_info {
-       u8 channel;
-       u8 tx_power;
-       u8 timeout;
-       u8 active;                              /* set 1 means active scan, or pasivite scan. */
-};
-
-struct pno_scan_info {
-       u8 enableRFE;                   /* Enable RFE */
-       u8 period_scan_time;            /* exclusive with fast_scan_period and slow_scan_period */
-       u8 periodScan;                  /* exclusive with fast_scan_period and slow_scan_period */
-       u8 orig_80_offset;                      /* original channel 80 offset */
-       u8 orig_40_offset;                      /* original channel 40 offset */
-       u8 orig_bw;                     /* original bandwidth */
-       u8 orig_ch;                     /* original channel */
-       u8 channel_num;                 /* number of channel */
-       u64     rfe_type;                       /* rfe_type && 0x00000000000000ff */
-       struct pno_scan_channel_info ssid_channel_info[MAX_SCAN_LIST_COUNT];
-};
-#endif /* CONFIG_PNO_SUPPORT */
-
 struct pwrctrl_priv {
        struct mutex lock;
        volatile u8 rpwm; /*  requested power state for fw */
@@ -212,10 +166,10 @@ struct pwrctrl_priv {
        u8 dtim;
 
        u32 alives;
-       _workitem cpwm_event;
+       struct work_struct cpwm_event;
        u8 brpwmtimeout;
-       _workitem rpwmtimeoutwi;
-       _timer pwr_rpwm_timer;
+       struct work_struct rpwmtimeoutwi;
+       struct timer_list pwr_rpwm_timer;
        u8 bpower_saving; /* for LPS/IPS */
 
        u8 b_hw_radio_off;
@@ -238,7 +192,7 @@ struct pwrctrl_priv {
        u8 pre_ips_type;/*  0: default flow, 1: carddisbale flow */
 
        /*  ps_deny: if 0, power save is free to go; otherwise deny all kinds of power save. */
-       /*  Use PS_DENY_REASON to decide reason. */
+       /*  Use enum ps_deny_reason to decide reason. */
        /*  Don't access this variable directly without control function, */
        /*  and this variable should be protected by lock. */
        u32 ps_deny;
@@ -266,23 +220,7 @@ struct pwrctrl_priv {
        u8 wowlan_wake_reason;
        u8 wowlan_ap_mode;
        u8 wowlan_mode;
-#ifdef CONFIG_WOWLAN
-       u8 wowlan_pattern;
-       u8 wowlan_magic;
-       u8 wowlan_unicast;
-       u8 wowlan_pattern_idx;
-       u8 wowlan_pno_enable;
-#ifdef CONFIG_PNO_SUPPORT
-       u8 pno_in_resume;
-       u8 pno_inited;
-       struct pno_nlo_info *pnlo_info;
-       struct pno_scan_info *pscan_info;
-       struct pno_ssid_list *pno_ssid_list;
-#endif
-       u32     wowlan_pattern_context[8][5];
-       u64             wowlan_fw_iv;
-#endif /*  CONFIG_WOWLAN */
-       _timer  pwr_state_check_timer;
+       struct timer_list       pwr_state_check_timer;
        struct adapter *adapter;
        int             pwr_state_check_interval;
        u8 pwr_state_check_cnts;
@@ -352,8 +290,8 @@ int _rtw_pwr_wakeup(struct adapter *padapter, u32 ips_deffer_ms, const char *cal
 int rtw_pm_set_ips(struct adapter *padapter, u8 mode);
 int rtw_pm_set_lps(struct adapter *padapter, u8 mode);
 
-void rtw_ps_deny(struct adapter *padapter, enum PS_DENY_REASON reason);
-void rtw_ps_deny_cancel(struct adapter *padapter, enum PS_DENY_REASON reason);
+void rtw_ps_deny(struct adapter *padapter, enum ps_deny_reason reason);
+void rtw_ps_deny_cancel(struct adapter *padapter, enum ps_deny_reason reason);
 u32 rtw_ps_deny_get(struct adapter *padapter);
 
 #endif  /* __RTL871X_PWRCTRL_H_ */
index b4aeb44d5d6e2142640571ccc2a0a1e9dc58a604..2709c9413dbcbf7dedc5661d3fb2f6a306e50353 100644 (file)
@@ -7,13 +7,9 @@
 #ifndef _RTW_RECV_H_
 #define _RTW_RECV_H_
 
-       #ifdef CONFIG_SINGLE_RECV_BUF
-               #define NR_RECVBUFF (1)
-       #else
-               #define NR_RECVBUFF (8)
-       #endif /* CONFIG_SINGLE_RECV_BUF */
+#define NR_RECVBUFF (8)
 
-       #define NR_PREALLOC_RECV_SKB (8)
+#define NR_PREALLOC_RECV_SKB (8)
 
 #define NR_RECVFRAME 256
 
@@ -47,7 +43,7 @@ struct recv_reorder_ctrl {
        u16 wend_b;
        u8 wsize_b;
        struct __queue pending_recvframe_queue;
-       _timer reordering_ctrl_timer;
+       struct timer_list reordering_ctrl_timer;
 };
 
 struct stainfo_rxcache {
@@ -73,13 +69,6 @@ struct       stainfo_rxcache {
 };
 
 
-struct smooth_rssi_data {
-       u32 elements[100];      /* array to store values */
-       u32 index;                      /* index to current array to store */
-       u32 total_num;          /* num of valid elements */
-       u32 total_val;          /* sum of valid elements */
-};
-
 struct signal_stat {
        u8 update_req;          /* used to indicate */
        u8 avg_val;             /* avg of valid elements */
@@ -159,11 +148,6 @@ struct rx_pkt_attrib       {
 
        u8 ack_policy;
 
-/* ifdef CONFIG_TCP_CSUM_OFFLOAD_RX */
-       u8 tcpchk_valid; /*  0: invalid, 1: valid */
-       u8 ip_chkrpt; /* 0: incorrect, 1: correct */
-       u8 tcp_chkrpt; /* 0: incorrect, 1: correct */
-/* endif */
        u8 key_index;
 
        u8 data_rate;
@@ -214,7 +198,7 @@ accesser of recv_priv: rtw_recv_entry(dispatch / passive level); recv_thread(pas
 using enter_critical section to protect
 */
 struct recv_priv {
-       _lock   lock;
+       spinlock_t      lock;
        struct __queue  free_recv_queue;
        struct __queue  recv_pending_queue;
        struct __queue  uc_swdec_pending_queue;
@@ -235,10 +219,6 @@ struct recv_priv {
        struct tasklet_struct recv_tasklet;
        struct sk_buff_head free_recv_skb_queue;
        struct sk_buff_head rx_skb_queue;
-#ifdef CONFIG_RX_INDICATE_QUEUE
-       struct task rx_indicate_tasklet;
-       struct ifqueue rx_indicate_queue;
-#endif /*  CONFIG_RX_INDICATE_QUEUE */
 
        u8 *pallocated_recv_buf;
        u8 *precv_buf;    /*  4 alignment */
@@ -264,7 +244,7 @@ struct recv_priv {
        /* int FalseAlmCnt_all; */
 
 
-       _timer signal_stat_timer;
+       struct timer_list signal_stat_timer;
        u32 signal_stat_sampling_interval;
        /* u32 signal_stat_converging_constant; */
        struct signal_stat signal_qual_data;
@@ -275,8 +255,8 @@ struct recv_priv {
 
 struct sta_recv_priv {
 
-       _lock   lock;
-       sint    option;
+       spinlock_t      lock;
+       signed int      option;
 
        /* struct __queue       blk_strms[MAX_RX_NUMBLKS]; */
        struct __queue defrag_q;         /* keeping the fragment frame until defrag */
@@ -293,7 +273,7 @@ struct sta_recv_priv {
 struct recv_buf {
        struct list_head list;
 
-       _lock recvbuf_lock;
+       spinlock_t recvbuf_lock;
 
        u32 ref_cnt;
 
@@ -308,7 +288,7 @@ struct recv_buf {
        u8 *ptail;
        u8 *pend;
 
-       _pkt    *pskb;
+       struct sk_buff  *pskb;
        u8 reuse;
 };
 
@@ -330,13 +310,8 @@ struct recv_buf {
 */
 struct recv_frame_hdr {
        struct list_head        list;
-#ifndef CONFIG_BSD_RX_USE_MBUF
        struct sk_buff   *pkt;
        struct sk_buff   *pkt_newalloc;
-#else /*  CONFIG_BSD_RX_USE_MBUF */
-       _pkt    *pkt;
-       _pkt *pkt_newalloc;
-#endif /*  CONFIG_BSD_RX_USE_MBUF */
 
        struct adapter  *adapter;
 
@@ -374,7 +349,7 @@ union recv_frame {
 
 };
 
-enum RX_PACKET_TYPE {
+enum rx_packet_type {
        NORMAL_RX,/* Normal rx packet */
        TX_REPORT1,/* CCX */
        TX_REPORT2,/* TX RPT */
@@ -393,8 +368,8 @@ extern int rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *q
 extern void rtw_free_recvframe_queue(struct __queue *pframequeue,  struct __queue *pfree_recv_queue);
 u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter);
 
-sint rtw_enqueue_recvbuf_to_head(struct recv_buf *precvbuf, struct __queue *queue);
-sint rtw_enqueue_recvbuf(struct recv_buf *precvbuf, struct __queue *queue);
+signed int rtw_enqueue_recvbuf_to_head(struct recv_buf *precvbuf, struct __queue *queue);
+signed int rtw_enqueue_recvbuf(struct recv_buf *precvbuf, struct __queue *queue);
 struct recv_buf *rtw_dequeue_recvbuf(struct __queue *queue);
 
 void rtw_reordering_ctrl_timeout_handler(struct timer_list *t);
@@ -419,7 +394,7 @@ static inline u8 *get_recvframe_data(union recv_frame *precvframe)
 
 }
 
-static inline u8 *recvframe_pull(union recv_frame *precvframe, sint sz)
+static inline u8 *recvframe_pull(union recv_frame *precvframe, signed int sz)
 {
        /*  rx_data += sz; move rx_data sz bytes  hereafter */
 
@@ -444,7 +419,7 @@ static inline u8 *recvframe_pull(union recv_frame *precvframe, sint sz)
 
 }
 
-static inline u8 *recvframe_put(union recv_frame *precvframe, sint sz)
+static inline u8 *recvframe_put(union recv_frame *precvframe, signed int sz)
 {
        /*  rx_tai += sz; move rx_tail sz bytes  hereafter */
 
@@ -473,7 +448,7 @@ static inline u8 *recvframe_put(union recv_frame *precvframe, sint sz)
 
 
 
-static inline u8 *recvframe_pull_tail(union recv_frame *precvframe, sint sz)
+static inline u8 *recvframe_pull_tail(union recv_frame *precvframe, signed int sz)
 {
        /*  rmv data from rx_tail (by yitsen) */
 
@@ -507,7 +482,7 @@ static inline union recv_frame *rxmem_to_recvframe(u8 *rxmem)
 
 }
 
-static inline sint get_recvframe_len(union recv_frame *precvframe)
+static inline signed int get_recvframe_len(union recv_frame *precvframe)
 {
        return precvframe->u.hdr.len;
 }
@@ -517,14 +492,9 @@ static inline s32 translate_percentage_to_dbm(u32 SignalStrengthIndex)
 {
        s32     SignalPower; /*  in dBm. */
 
-#ifdef CONFIG_SKIP_SIGNAL_SCALE_MAPPING
-       /*  Translate to dBm (x =y-100) */
-       SignalPower = SignalStrengthIndex - 100;
-#else
        /*  Translate to dBm (x = 0.5y-95). */
        SignalPower = (s32)((SignalStrengthIndex + 1) >> 1);
        SignalPower -= 95;
-#endif
 
        return SignalPower;
 }
index d3a8e4b7069affcba3a686da5415af0f42dcdb0c..a8ddd6fe5f9515a749ffcacb14615c4e68735741 100644 (file)
@@ -49,7 +49,7 @@ struct        regulatory_class {
        u8 modem;
 };
 
-enum CAPABILITY {
+enum capability {
        cESS                    = 0x0001,
        cIBSS                   = 0x0002,
        cPollable               = 0x0004,
@@ -68,13 +68,13 @@ enum CAPABILITY {
        cImmediateBA            = 0x8000,
 };
 
-enum   _REG_PREAMBLE_MODE {
+enum   _reg_preamble_mode {
        PREAMBLE_LONG   = 1,
        PREAMBLE_AUTO   = 2,
        PREAMBLE_SHORT  = 3,
 };
 
-enum _RTL8712_RF_MIMO_CONFIG_ {
+enum _rtl8712_rf_mimo_config_ {
        RTL8712_RFCONFIG_1T = 0x10,
        RTL8712_RFCONFIG_2T = 0x20,
        RTL8712_RFCONFIG_1R = 0x01,
@@ -85,7 +85,7 @@ enum _RTL8712_RF_MIMO_CONFIG_ {
        RTL8712_RFCONFIG_2T2R = 0x22
 };
 
-enum RF90_RADIO_PATH {
+enum rf90_radio_path {
        RF90_PATH_A = 0,                /* Radio Path A */
        RF90_PATH_B = 1,                /* Radio Path B */
        RF90_PATH_C = 2,                /* Radio Path C */
@@ -98,7 +98,7 @@ enum RF90_RADIO_PATH {
 #define HAL_PRIME_CHNL_OFFSET_UPPER    2
 
 /*  Represent Channel Width in HT Capabilities */
-enum CHANNEL_WIDTH {
+enum channel_width {
        CHANNEL_WIDTH_20 = 0,
        CHANNEL_WIDTH_40 = 1,
        CHANNEL_WIDTH_80 = 2,
@@ -109,14 +109,14 @@ enum CHANNEL_WIDTH {
 
 /*  Represent Extension Channel Offset in HT Capabilities */
 /*  This is available only in 40Mhz mode. */
-enum EXTCHNL_OFFSET {
+enum extchnl_offset {
        EXTCHNL_OFFSET_NO_EXT = 0,
        EXTCHNL_OFFSET_UPPER = 1,
        EXTCHNL_OFFSET_NO_DEF = 2,
        EXTCHNL_OFFSET_LOWER = 3,
 };
 
-enum VHT_DATA_SC {
+enum vht_data_sc {
        VHT_DATA_SC_DONOT_CARE = 0,
        VHT_DATA_SC_20_UPPER_OF_80MHZ = 1,
        VHT_DATA_SC_20_LOWER_OF_80MHZ = 2,
@@ -130,14 +130,14 @@ enum VHT_DATA_SC {
        VHT_DATA_SC_40_LOWER_OF_80MHZ = 10,
 };
 
-enum PROTECTION_MODE {
+enum protection_mode {
        PROTECTION_MODE_AUTO = 0,
        PROTECTION_MODE_FORCE_ENABLE = 1,
        PROTECTION_MODE_FORCE_DISABLE = 2,
 };
 
 /* 2007/11/15 MH Define different RF type. */
-enum RT_RF_TYPE_DEFINITION {
+enum rt_rf_type_definition {
        RF_1T2R = 0,
        RF_2T4R = 1,
        RF_2T2R = 2,
index 85ffd4ec4ce538af0a0192e6d794796854e281e6..60b05a620eee46152f2045f725fff798b321f96c 100644 (file)
@@ -84,14 +84,14 @@ union Keytype {
 };
 
 
-typedef struct _RT_PMKID_LIST {
+struct rt_pmkid_list {
        u8                              bUsed;
        u8                              Bssid[6];
        u8                              PMKID[16];
        u8                              SsidBuf[33];
        u8 *ssid_octet;
        u16                                     ssid_length;
-} RT_PMKID_LIST, *PRT_PMKID_LIST;
+};
 
 
 struct security_priv {
@@ -129,9 +129,6 @@ struct security_priv {
 
 
        u8 binstallGrpkey;
-#ifdef CONFIG_GTK_OL
-       u8 binstallKCK_KEK;
-#endif /* CONFIG_GTK_OL */
        u8 binstallBIPkey;
        u8 busetkipkey;
        /* _timer tkip_timer; */
@@ -145,7 +142,7 @@ struct security_priv {
 
 
        /* keeps the auth_type & enc_status from upper layer ioctl(wpa_supplicant or wzc) */
-       u32 ndisauthtype;       /*  enum NDIS_802_11_AUTHENTICATION_MODE */
+       u32 ndisauthtype;       /*  enum ndis_802_11_authentication_mode */
        u32 ndisencryptstatus;  /*  NDIS_802_11_ENCRYPTION_STATUS */
 
        struct wlan_bssid_ex sec_bss;  /* for joinbss (h2c buffer) usage */
@@ -166,7 +163,7 @@ struct security_priv {
        u32 btkip_countermeasure_time;
 
        /*  For WPA2 Pre-Authentication. */
-       RT_PMKID_LIST           PMKIDList[NUM_PMKID_CACHE];     /*  Renamed from PreAuthKey[NUM_PRE_AUTH_KEY]. Annie, 2006-10-13. */
+       struct rt_pmkid_list            PMKIDList[NUM_PMKID_CACHE];     /*  Renamed from PreAuthKey[NUM_PRE_AUTH_KEY]. Annie, 2006-10-13. */
        u8              PMKIDIndex;
 
        u8 bWepDefaultKeyIdxSet;
@@ -196,12 +193,6 @@ struct security_priv {
 #endif /* DBG_SW_SEC_CNT */
 };
 
-struct sha256_state {
-       u64 length;
-       u32 state[8], curlen;
-       u8 buf[64];
-};
-
 #define GET_ENCRY_ALGO(psecuritypriv, psta, encry_algo, bmcst)\
 do {\
        switch (psecuritypriv->dot11AuthAlgrthm)\
index f798b0c744a4fc028cb6833b4795ca49b6673cc2..66bf3d1b1d5a1005117fca6b556a5e21a7edca9a 100644 (file)
@@ -8,11 +8,6 @@
 #ifndef __RTW_WIFI_REGD_H__
 #define __RTW_WIFI_REGD_H__
 
-struct country_code_to_enum_rd {
-       u16 countrycode;
-       const char *iso_name;
-};
-
 enum country_code_type_t {
        COUNTRY_CODE_USER = 0,
 
index c04318573f8f9b5176f245c62c2d6d17a6d8fcbb..4d4fa157daa9f1ca3227e56b9569ae8a12892ceb 100644 (file)
@@ -83,7 +83,7 @@ do {\
 
 #define TXDESC_OFFSET TXDESC_SIZE
 
-enum TXDESC_SC {
+enum txdesc_sc {
        SC_DONT_CARE = 0x00,
        SC_UPPER = 0x01,
        SC_LOWER = 0x02,
@@ -128,11 +128,11 @@ union txdesc {
 };
 
 struct hw_xmit {
-       /* _lock xmit_lock; */
+       /* spinlock_t xmit_lock; */
        /* struct list_head     pending; */
        struct __queue *sta_queue;
        /* struct hw_txqueue *phwtxqueue; */
-       /* sint txcmdcnt; */
+       /* signed int   txcmdcnt; */
        int     accnt;
 };
 
@@ -284,7 +284,7 @@ struct xmit_frame {
 
        struct pkt_attrib attrib;
 
-       _pkt *pkt;
+       struct sk_buff *pkt;
 
        int     frame_tag;
 
@@ -312,9 +312,9 @@ struct tx_servq {
 
 
 struct sta_xmit_priv {
-       _lock   lock;
-       sint    option;
-       sint    apsd_setting;   /* When bit mask is on, the associated edca queue supports APSD. */
+       spinlock_t      lock;
+       signed int      option;
+       signed int      apsd_setting;   /* When bit mask is on, the associated edca queue supports APSD. */
 
 
        /* struct tx_servq blk_q[MAX_NUMBLKS]; */
@@ -336,19 +336,14 @@ struct sta_xmit_priv {
 
 
 struct hw_txqueue      {
-       volatile sint   head;
-       volatile sint   tail;
-       volatile sint   free_sz;        /* in units of 64 bytes */
-       volatile sint      free_cmdsz;
-       volatile sint    txsz[8];
+       volatile signed int     head;
+       volatile signed int     tail;
+       volatile signed int     free_sz;        /* in units of 64 bytes */
+       volatile signed int      free_cmdsz;
+       volatile signed int      txsz[8];
        uint    ff_hwaddr;
        uint    cmd_hwaddr;
-       sint    ac_tag;
-};
-
-struct agg_pkt_info {
-       u16 offset;
-       u16 pkt_len;
+       signed int      ac_tag;
 };
 
 enum cmdbuf_type {
@@ -359,7 +354,7 @@ enum cmdbuf_type {
 
 struct xmit_priv {
 
-       _lock   lock;
+       spinlock_t      lock;
 
        struct completion xmit_comp;
        struct completion terminate_xmitthread_comp;
@@ -412,13 +407,9 @@ struct     xmit_priv {
 
        u8 wmm_para_seq[4];/* sequence for wmm ac parameter strength from large to small. it's value is 0->vo, 1->vi, 2->be, 3->bk. */
 
-#ifdef CONFIG_SDIO_TX_TASKLET
-       struct tasklet_struct xmit_tasklet;
-#else
        void *SdioXmitThread;
        struct completion SdioXmitStart;
        struct completion SdioXmitTerminate;
-#endif /* CONFIG_SDIO_TX_TASKLET */
 
        struct __queue free_xmitbuf_queue;
        struct __queue pending_xmitbuf_queue;
@@ -436,10 +427,10 @@ struct    xmit_priv {
        u16 nqos_ssn;
 
        int     ack_tx;
-       _mutex ack_tx_mutex;
+       struct mutex ack_tx_mutex;
        struct submit_ctx ack_tx_ops;
        u8 seq_no;
-       _lock lock_sctx;
+       spinlock_t lock_sctx;
 };
 
 extern struct xmit_frame *__rtw_alloc_cmdxmitframe(struct xmit_priv *pxmitpriv,
@@ -463,20 +454,20 @@ struct xmit_frame *rtw_alloc_xmitframe_ext(struct xmit_priv *pxmitpriv);
 struct xmit_frame *rtw_alloc_xmitframe_once(struct xmit_priv *pxmitpriv);
 extern s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitframe);
 extern void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, struct __queue *pframequeue);
-struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, struct sta_info *psta, sint up, u8 *ac);
+struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, struct sta_info *psta, signed int up, u8 *ac);
 extern s32 rtw_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitframe);
 
 extern s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe);
 extern u32 rtw_calculate_wlan_pkt_size_by_attribue(struct pkt_attrib *pattrib);
 #define rtw_wlan_pkt_size(f) rtw_calculate_wlan_pkt_size_by_attribue(&f->attrib)
-extern s32 rtw_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit_frame *pxmitframe);
-extern s32 rtw_mgmt_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit_frame *pxmitframe);
+extern s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct xmit_frame *pxmitframe);
+extern s32 rtw_mgmt_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct xmit_frame *pxmitframe);
 s32 _rtw_init_hw_txqueue(struct hw_txqueue *phw_txqueue, u8 ac_tag);
 void _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv);
 
 
 s32 rtw_txframes_pending(struct adapter *padapter);
-void rtw_init_hwxmits(struct hw_xmit *phwxmit, sint entry);
+void rtw_init_hwxmits(struct hw_xmit *phwxmit, signed int entry);
 
 
 s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter);
@@ -487,10 +478,10 @@ s32 rtw_alloc_hwxmits(struct adapter *padapter);
 void rtw_free_hwxmits(struct adapter *padapter);
 
 
-s32 rtw_xmit(struct adapter *padapter, _pkt **pkt);
+s32 rtw_xmit(struct adapter *padapter, struct sk_buff **pkt);
 bool xmitframe_hiq_filter(struct xmit_frame *xmitframe);
 
-sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_frame *pxmitframe);
+signed int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_frame *pxmitframe);
 void stop_sta_xmit(struct adapter *padapter, struct sta_info *psta);
 void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta);
 void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *psta);
@@ -503,7 +494,7 @@ void enqueue_pending_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmit
 void enqueue_pending_xmitbuf_to_head(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf);
 struct xmit_buf *dequeue_pending_xmitbuf(struct xmit_priv *pxmitpriv);
 struct xmit_buf *dequeue_pending_xmitbuf_under_survey(struct xmit_priv *pxmitpriv);
-sint   check_pending_xmitbuf(struct xmit_priv *pxmitpriv);
+signed int     check_pending_xmitbuf(struct xmit_priv *pxmitpriv);
 int    rtw_xmit_thread(void *context);
 
 u32 rtw_get_ff_hwaddr(struct xmit_frame        *pxmitframe);
index 6b0446be6d19c902bb8e33d0fd2a94c23b2bc3a1..c7559a884608f87a877c38e02f57fd6a28ef748d 100644 (file)
@@ -25,17 +25,10 @@ s32 _sdio_write32(struct adapter *padapter, u32 addr, u32 val);
 extern void sd_int_hdl(struct adapter *padapter);
 extern u8 CheckIPSStatus(struct adapter *padapter);
 
-#if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN)
-extern u8 RecvOnePkt(struct adapter *padapter, u32 size);
-#endif /*  CONFIG_WOWLAN */
 extern void InitInterrupt8723BSdio(struct adapter *padapter);
 extern void InitSysInterrupt8723BSdio(struct adapter *padapter);
 extern void EnableInterrupt8723BSdio(struct adapter *padapter);
 extern void DisableInterrupt8723BSdio(struct adapter *padapter);
 extern u8 HalQueryTxBufferStatus8723BSdio(struct adapter *padapter);
 extern void HalQueryTxOQTBufferStatus8723BSdio(struct adapter *padapter);
-#if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN)
-extern void ClearInterrupt8723BSdio(struct adapter *padapter);
-#endif /* CONFIG_WOWLAN */
-
 #endif /*  !__SDIO_OPS_H__ */
index 734f4e2ecd66d417fd4a77c7c4bcf44909b8b0aa..abde3e3df9887efda9dbd2bff28e46da4fe56313 100644 (file)
@@ -31,13 +31,13 @@ struct wlan_acl_pool {
        struct __queue  acl_node_q;
 };
 
-typedef struct _RSSI_STA {
+struct rssi_sta {
        s32     UndecoratedSmoothedPWDB;
        s32     UndecoratedSmoothedCCK;
        s32     UndecoratedSmoothedOFDM;
        u64     PacketMap;
        u8 ValidBit;
-} RSSI_STA, *PRSSI_STA;
+};
 
 struct stainfo_stats   {
 
@@ -69,7 +69,7 @@ struct        stainfo_stats   {
 
 struct sta_info {
 
-       _lock   lock;
+       spinlock_t      lock;
        struct list_head        list; /* free_sta_queue */
        struct list_head        hash_list; /* sta_hash */
        struct adapter *padapter;
@@ -92,11 +92,6 @@ struct sta_info {
        union Keytype   dot11tkiprxmickey;
        union Keytype   dot118021x_UncstKey;
        union pn48              dot11txpn;                      /*  PN48 used for Unicast xmit */
-#ifdef CONFIG_GTK_OL
-       u8 kek[RTW_KEK_LEN];
-       u8 kck[RTW_KCK_LEN];
-       u8 replay_ctr[RTW_REPLAY_CTR_LEN];
-#endif /* CONFIG_GTK_OL */
        union pn48              dot11wtxpn;                     /*  PN48 used for Unicast mgmt xmit. */
        union pn48              dot11rxpn;                      /*  PN48 used for Unicast recv. */
 
@@ -121,7 +116,7 @@ struct sta_info {
        struct stainfo_stats sta_stats;
 
        /* for A-MPDU TX, ADDBA timeout check */
-       _timer addba_retry_timer;
+       struct timer_list addba_retry_timer;
 
        /* for A-MPDU Rx reordering buffer control */
        struct recv_reorder_ctrl recvreorder_ctrl[16];
@@ -187,16 +182,11 @@ struct sta_info {
 
        u8 keep_alive_trycnt;
 
-#ifdef CONFIG_AUTO_AP_MODE
-       u8 isrc; /* this device is rc */
-       u16 pid; /*  pairing id */
-#endif
-
        u8 *passoc_req;
        u32 assoc_req_len;
 
        /* for DM */
-       RSSI_STA         rssi_stat;
+       struct rssi_sta  rssi_stat;
 
        /* ODM_STA_INFO_T */
        /*  ================ODM Relative Info ======================= */
@@ -314,7 +304,7 @@ struct      sta_priv {
        u8 *pstainfo_buf;
        struct __queue  free_sta_queue;
 
-       _lock sta_hash_lock;
+       spinlock_t sta_hash_lock;
        struct list_head   sta_hash[NUM_STA];
        int asoc_sta_count;
        struct __queue sleep_q;
@@ -324,8 +314,8 @@ struct      sta_priv {
 
        struct list_head asoc_list;
        struct list_head auth_list;
-       _lock asoc_list_lock;
-       _lock auth_list_lock;
+       spinlock_t asoc_list_lock;
+       spinlock_t auth_list_lock;
        u8 asoc_list_cnt;
        u8 auth_list_cnt;
 
index fe984fcb66a9416afec6486f87ef575af2a343fc..efef549bf811d2095ea17af3e9319131fb567925 100644 (file)
 /*  This test verifies the WLAN NIC can update the NAV through sending the CTS with large duration. */
 #define        WiFiNavUpperUs                          30000   /*  30 ms */
 
-enum WIFI_FRAME_TYPE {
+enum wifi_frame_type {
        WIFI_MGT_TYPE  =        (0),
        WIFI_CTRL_TYPE =        (BIT(2)),
        WIFI_DATA_TYPE =        (BIT(3)),
        WIFI_QOS_DATA_TYPE      = (BIT(7)|BIT(3)),      /*  QoS Data */
 };
 
-enum WIFI_FRAME_SUBTYPE {
+enum wifi_frame_subtype {
 
     /*  below is for mgt frame */
     WIFI_ASSOCREQ       = (0 | WIFI_MGT_TYPE),
@@ -88,7 +88,7 @@ enum WIFI_FRAME_SUBTYPE {
     WIFI_QOS_DATA_NULL = (BIT(6) | WIFI_QOS_DATA_TYPE),
 };
 
-enum WIFI_REG_DOMAIN {
+enum wifi_reg_domain {
        DOMAIN_FCC              = 1,
        DOMAIN_IC               = 2,
        DOMAIN_ETSI             = 3,
@@ -435,21 +435,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe)
 
 #define ACT_CAT_VENDOR                         0x7F/* 127 */
 
-/**
- * struct rtw_ieee80211_bar - HT Block Ack Request
- *
- * This structure refers to "HT BlockAckReq" as
- * described in 802.11n draft section 7.2.1.7.1
- */
-struct rtw_ieee80211_bar {
-       __le16 frame_control;
-       __le16 duration;
-       unsigned char ra[6];
-       unsigned char ta[6];
-       __le16 control;
-       __le16 start_seq_num;
-} __attribute__((packed));
-
 /**
  * struct rtw_ieee80211_ht_cap - HT additional information
  *
@@ -719,7 +704,7 @@ struct ADDBA_request {
 
 #define        P2P_WILDCARD_SSID_LEN                           7
 
-#define        P2P_FINDPHASE_EX_NONE                           0       /*  default value, used when: (1)p2p disabed or (2)p2p enabled but only do 1 scan phase */
+#define        P2P_FINDPHASE_EX_NONE                           0       /*  default value, used when: (1)p2p disabled or (2)p2p enabled but only do 1 scan phase */
 #define        P2P_FINDPHASE_EX_FULL                           1       /*  used when p2p enabled and want to do 1 scan phase and P2P_FINDPHASE_EX_MAX-1 find phase */
 #define        P2P_FINDPHASE_EX_SOCIAL_FIRST           (P2P_FINDPHASE_EX_FULL+1)
 #define        P2P_FINDPHASE_EX_MAX                                    4
@@ -751,14 +736,14 @@ struct ADDBA_request {
 #define        WPS_CM_SW_DISPLAY_PIN                           0x2008
 #define        WPS_CM_LCD_DISPLAY_PIN                          0x4008
 
-enum P2P_ROLE {
+enum p2p_role {
        P2P_ROLE_DISABLE = 0,
        P2P_ROLE_DEVICE = 1,
        P2P_ROLE_CLIENT = 2,
        P2P_ROLE_GO = 3
 };
 
-enum P2P_STATE {
+enum p2p_state {
        P2P_STATE_NONE = 0,                                                     /*      P2P disable */
        P2P_STATE_IDLE = 1,                                                             /*      P2P had enabled and do nothing */
        P2P_STATE_LISTEN = 2,                                                   /*      In pure listen state */
@@ -784,7 +769,7 @@ enum P2P_STATE {
        P2P_STATE_TX_INFOR_NOREADY = 22,                        /*  sending p2p negotiation response with information is not available */
 };
 
-enum P2P_WPSINFO {
+enum p2p_wpsinfo {
        P2P_NO_WPSINFO                                          = 0,
        P2P_GOT_WPSINFO_PEER_DISPLAY_PIN        = 1,
        P2P_GOT_WPSINFO_SELF_DISPLAY_PIN        = 2,
@@ -793,7 +778,7 @@ enum P2P_WPSINFO {
 
 #define        P2P_PRIVATE_IOCTL_SET_LEN               64
 
-enum P2P_PROTO_WK_ID {
+enum p2p_proto_wk_id {
        P2P_FIND_PHASE_WK = 0,
        P2P_RESTORE_STATE_WK = 1,
        P2P_PRE_TX_PROVDISC_PROCESS_WK = 2,
index 27cd2c5d90af07f4be39fb970314c153eed5f5bc..9d63dc0037954d21ff72ad31ad38db4d37b7f16e 100644 (file)
@@ -24,7 +24,7 @@ struct ndis_802_11_ssid {
        u8  Ssid[32];
 };
 
-enum NDIS_802_11_NETWORK_TYPE {
+enum ndis_802_11_network_type {
        Ndis802_11FH,
        Ndis802_11DS,
        Ndis802_11OFDM5,
@@ -51,7 +51,7 @@ struct ndis_802_11_conf {
        struct ndis_802_11_conf_fh    FHConfig;
 };
 
-enum NDIS_802_11_NETWORK_INFRASTRUCTURE {
+enum ndis_802_11_network_infrastructure {
        Ndis802_11IBSS,
        Ndis802_11Infrastructure,
        Ndis802_11AutoUnknown,
@@ -74,13 +74,13 @@ struct ndis_80211_var_ie {
 /* Length is the 4 bytes multiples of the sum of
  * sizeof (NDIS_802_11_MAC_ADDRESS) + 2 +
  * sizeof (struct ndis_802_11_ssid) + sizeof (u32) +
- * sizeof (long) + sizeof (enum NDIS_802_11_NETWORK_TYPE) +
+ * sizeof (long) + sizeof (enum ndis_802_11_network_type) +
  * sizeof (struct ndis_802_11_conf) + sizeof (NDIS_802_11_RATES_EX) + IELength
  *
  * Except for IELength, all other fields are fixed length. Therefore, we can
  * define a macro to present the partial sum.
  */
-enum NDIS_802_11_AUTHENTICATION_MODE {
+enum ndis_802_11_authentication_mode {
        Ndis802_11AuthModeOpen,
        Ndis802_11AuthModeShared,
        Ndis802_11AuthModeAutoSwitch,
@@ -91,7 +91,7 @@ enum NDIS_802_11_AUTHENTICATION_MODE {
        Ndis802_11AuthModeMax   /*  Not a real mode, defined as upper bound */
 };
 
-enum NDIS_802_11_WEP_STATUS {
+enum ndis_802_11_wep_status {
        Ndis802_11WEPEnabled,
        Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
        Ndis802_11WEPDisabled,
@@ -127,38 +127,12 @@ struct ndis_801_11_ai_resfi {
        u16 AssociationId;
 };
 
-typedef struct _NDIS_802_11_ASSOCIATION_INFORMATION {
-       u32                   Length;
-       u16                  AvailableRequestFixedIEs;
-       struct ndis_802_11_ai_reqfi    RequestFixedIEs;
-       u32                   RequestIELength;
-       u32                   OffsetRequestIEs;
-       u16                  AvailableResponseFixedIEs;
-       struct ndis_801_11_ai_resfi    ResponseFixedIEs;
-       u32                   ResponseIELength;
-       u32                   OffsetResponseIEs;
-} NDIS_802_11_ASSOCIATION_INFORMATION, *PNDIS_802_11_ASSOCIATION_INFORMATION;
-
-enum NDIS_802_11_RELOAD_DEFAULTS {
+enum ndis_802_11_reload_defaults {
        Ndis802_11ReloadWEPKeys
 };
 
 
 /*  Key mapping keys require a BSSID */
-typedef struct _NDIS_802_11_KEY {
-       u32           Length;             /*  Length of this structure */
-       u32           KeyIndex;
-       u32           KeyLength;          /*  length of key in bytes */
-       NDIS_802_11_MAC_ADDRESS BSSID;
-       unsigned long long KeyRSC;
-       u8           KeyMaterial[32];     /*  variable length depending on above field */
-} NDIS_802_11_KEY, *PNDIS_802_11_KEY;
-
-typedef struct _NDIS_802_11_REMOVE_KEY {
-       u32                   Length;        /*  Length of this structure */
-       u32                   KeyIndex;
-       NDIS_802_11_MAC_ADDRESS BSSID;
-} NDIS_802_11_REMOVE_KEY, *PNDIS_802_11_REMOVE_KEY;
 
 struct ndis_802_11_wep {
        u32 Length;        /*  Length of this structure */
@@ -211,9 +185,9 @@ struct wlan_bssid_ex {
        struct ndis_802_11_ssid  Ssid;
        u32  Privacy;
        long  Rssi;/* in dBM, raw data , get from PHY) */
-       enum NDIS_802_11_NETWORK_TYPE  NetworkTypeInUse;
+       enum ndis_802_11_network_type  NetworkTypeInUse;
        struct ndis_802_11_conf  Configuration;
-       enum NDIS_802_11_NETWORK_INFRASTRUCTURE  InfrastructureMode;
+       enum ndis_802_11_network_infrastructure  InfrastructureMode;
        NDIS_802_11_RATES_EX  SupportedRates;
        struct wlan_phy_info PhyInfo;
        u32  IELength;
@@ -236,13 +210,13 @@ struct    wlan_network {
        struct wlan_bcn_info    BcnInfo;
 };
 
-enum VRTL_CARRIER_SENSE {
+enum vrtl_carrier_sense {
        DISABLE_VCS,
        ENABLE_VCS,
        AUTO_VCS
 };
 
-enum VCS_TYPE {
+enum vcs_type {
        NONE_VCS,
        RTS_CTS,
        CTS_TO_SELF
@@ -254,7 +228,7 @@ enum VCS_TYPE {
 #define PWR_UAPSD 3
 #define PWR_VOIP 4
 
-enum UAPSD_MAX_SP {
+enum uapsd_max_sp {
        NO_LIMIT,
        TWO_MSDU,
        FOUR_MSDU,
index e9ff274f7474616ca754d97c6597f48b971a7ab1..e781cd5dfd01eb864173533825b8a4739d82671a 100644 (file)
@@ -9,9 +9,9 @@
 
 
 struct pkt_file {
-       _pkt *pkt;
+       struct sk_buff *pkt;
        __kernel_size_t pkt_len;         /* the remainder length of the open_file */
-       _buffer *cur_buffer;
+       unsigned char *cur_buffer;
        u8 *buf_start;
        u8 *cur_addr;
        __kernel_size_t buf_len;
@@ -25,8 +25,8 @@ struct sta_xmit_priv;
 struct xmit_frame;
 struct xmit_buf;
 
-extern int _rtw_xmit_entry(_pkt *pkt, _nic_hdl pnetdev);
-extern int rtw_xmit_entry(_pkt *pkt, _nic_hdl pnetdev);
+extern int _rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev);
+extern int rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev);
 
 void rtw_os_xmit_schedule(struct adapter *padapter);
 
@@ -34,11 +34,11 @@ int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitb
 void rtw_os_xmit_resource_free(struct adapter *padapter, struct xmit_buf *pxmitbuf, u32 free_sz, u8 flag);
 
 extern uint rtw_remainder_len(struct pkt_file *pfile);
-extern void _rtw_open_pktfile(_pkt *pkt, struct pkt_file *pfile);
+extern void _rtw_open_pktfile(struct sk_buff *pkt, struct pkt_file *pfile);
 extern uint _rtw_pktfile_read(struct pkt_file *pfile, u8 *rmem, uint rlen);
-extern sint rtw_endofpktfile(struct pkt_file *pfile);
+extern signed int rtw_endofpktfile(struct pkt_file *pfile);
 
-extern void rtw_os_pkt_complete(struct adapter *padapter, _pkt *pkt);
+extern void rtw_os_pkt_complete(struct adapter *padapter, struct sk_buff *pkt);
 extern void rtw_os_xmit_complete(struct adapter *padapter, struct xmit_frame *pxframe);
 
 #endif /* __XMIT_OSDEP_H_ */
index ff164a8c8679a080ad72b71aa2fb492847da84a7..03a784558d79febe163699c63198da7b503be9ad 100644 (file)
@@ -235,9 +235,6 @@ struct cfg80211_bss *rtw_cfg80211_inform_bss(struct adapter *padapter, struct wl
        struct wiphy *wiphy = wdev->wiphy;
        struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
 
-
-       /* DBG_8192C("%s\n", __func__); */
-
        bssinf_len = pnetwork->network.IELength + sizeof(struct ieee80211_hdr_3addr);
        if (bssinf_len > MAX_BSSINFO_LEN) {
                DBG_871X("%s IE Length too long > %d byte\n", __func__, MAX_BSSINFO_LEN);
@@ -566,8 +563,6 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, struct ieee_pa
        struct security_priv *psecuritypriv =  &(padapter->securitypriv);
        struct sta_priv *pstapriv = &padapter->stapriv;
 
-       DBG_8192C("%s\n", __func__);
-
        param->u.crypt.err = 0;
        param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0';
 
@@ -851,8 +846,6 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, struct ieee_param
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct security_priv *psecuritypriv = &padapter->securitypriv;
 
-       DBG_8192C("%s\n", __func__);
-
        param->u.crypt.err = 0;
        param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0';
 
@@ -1266,15 +1259,13 @@ exit:
        return ret;
 }
 
-extern int netdev_open(struct net_device *pnetdev);
-
 static int cfg80211_rtw_change_iface(struct wiphy *wiphy,
                                     struct net_device *ndev,
                                     enum nl80211_iftype type,
                                     struct vif_params *params)
 {
        enum nl80211_iftype old_type;
-       enum NDIS_802_11_NETWORK_INFRASTRUCTURE networkType;
+       enum ndis_802_11_network_infrastructure networkType;
        struct adapter *padapter = rtw_netdev_priv(ndev);
        struct wireless_dev *rtw_wdev = padapter->rtw_wdev;
        struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
@@ -1404,10 +1395,6 @@ void rtw_cfg80211_surveydone_event_callback(struct adapter *padapter)
        struct __queue *queue   = &(pmlmepriv->scanned_queue);
        struct  wlan_network    *pnetwork = NULL;
 
-#ifdef DEBUG_CFG80211
-       DBG_8192C("%s\n", __func__);
-#endif
-
        spin_lock_bh(&(pmlmepriv->scanned_queue.lock));
 
        phead = get_list_head(queue);
@@ -1642,12 +1629,9 @@ exit:
 
 static int cfg80211_rtw_set_wiphy_params(struct wiphy *wiphy, u32 changed)
 {
-       DBG_8192C("%s\n", __func__);
        return 0;
 }
 
-
-
 static int rtw_cfg80211_set_wpa_version(struct security_priv *psecuritypriv, u32 wpa_version)
 {
        DBG_8192C("%s, wpa_version =%d\n", __func__, wpa_version);
@@ -2017,7 +2001,7 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev,
                                 struct cfg80211_connect_params *sme)
 {
        int ret = 0;
-       enum NDIS_802_11_AUTHENTICATION_MODE authmode;
+       enum ndis_802_11_authentication_mode authmode;
        struct ndis_802_11_ssid ndis_ssid;
        struct adapter *padapter = rtw_netdev_priv(ndev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
@@ -2219,7 +2203,6 @@ static int cfg80211_rtw_set_txpower(struct wiphy *wiphy,
        struct wireless_dev *wdev,
        enum nl80211_tx_power_setting type, int mbm)
 {
-       DBG_8192C("%s\n", __func__);
        return 0;
 }
 
@@ -2227,8 +2210,6 @@ static int cfg80211_rtw_get_txpower(struct wiphy *wiphy,
        struct wireless_dev *wdev,
        int *dbm)
 {
-       DBG_8192C("%s\n", __func__);
-
        *dbm = (12);
 
        return 0;
@@ -2346,7 +2327,7 @@ static int cfg80211_rtw_flush_pmksa(struct wiphy *wiphy,
 
        DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev));
 
-       memset(&psecuritypriv->PMKIDList[0], 0x00, sizeof(RT_PMKID_LIST) * NUM_PMKID_CACHE);
+       memset(&psecuritypriv->PMKIDList[0], 0x00, sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
        psecuritypriv->PMKIDIndex = 0;
 
        return 0;
@@ -3095,54 +3076,6 @@ exit:
        return ret;
 }
 
-#if defined(CONFIG_PNO_SUPPORT)
-static int cfg80211_rtw_sched_scan_start(struct wiphy *wiphy, struct net_device *dev,
-                                        struct cfg80211_sched_scan_request *request)
-{
-       struct adapter *padapter = rtw_netdev_priv(dev);
-       struct  mlme_priv *pmlmepriv = &(padapter->mlmepriv);
-       int ret;
-
-       if (padapter->bup == false) {
-               DBG_871X("%s: net device is down.\n", __func__);
-               return -EIO;
-       }
-
-       if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true ||
-               check_fwstate(pmlmepriv, _FW_LINKED) == true  ||
-               check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) {
-               DBG_871X("%s: device is busy.\n", __func__);
-               rtw_scan_abort(padapter);
-       }
-
-       if (request == NULL) {
-               DBG_871X("%s: invalid cfg80211_requests parameters.\n", __func__);
-               return -EINVAL;
-       }
-
-       ret = rtw_android_cfg80211_pno_setup(dev, request->ssids,
-                       request->n_ssids, request->interval);
-
-       if (ret < 0) {
-               DBG_871X("%s ret: %d\n", __func__, ret);
-               goto exit;
-       }
-
-       ret = rtw_android_pno_enable(dev, true);
-       if (ret < 0) {
-               DBG_871X("%s ret: %d\n", __func__, ret);
-               goto exit;
-       }
-exit:
-       return ret;
-}
-
-static int cfg80211_rtw_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev)
-{
-       return rtw_android_pno_enable(dev, false);
-}
-#endif /* CONFIG_PNO_SUPPORT */
-
 static void rtw_cfg80211_init_ht_capab(struct ieee80211_sta_ht_cap *ht_cap, enum nl80211_band band, u8 rf_type)
 {
 
@@ -3248,9 +3181,6 @@ static void rtw_cfg80211_preinit_wiphy(struct adapter *padapter, struct wiphy *w
 
 #if defined(CONFIG_PM)
        wiphy->max_sched_scan_reqs = 1;
-#ifdef CONFIG_PNO_SUPPORT
-       wiphy->max_sched_scan_ssids = MAX_PNO_LIST_COUNT;
-#endif
 #endif
 
 #if defined(CONFIG_PM)
@@ -3297,11 +3227,6 @@ static struct cfg80211_ops rtw_cfg80211_ops = {
        .change_bss = cfg80211_rtw_change_bss,
 
        .mgmt_tx = cfg80211_rtw_mgmt_tx,
-
-#if defined(CONFIG_PNO_SUPPORT)
-       .sched_scan_start = cfg80211_rtw_sched_scan_start,
-       .sched_scan_stop = cfg80211_rtw_sched_scan_stop,
-#endif /* CONFIG_PNO_SUPPORT */
 };
 
 int rtw_wdev_alloc(struct adapter *padapter, struct device *dev)
index 78ba2423ed65d0f6ed0d0724e343f44ca632f012..9909dece0b0134ca3443981dd7239c76a9ceaaf9 100644 (file)
@@ -313,15 +313,7 @@ static char *translate_scan(struct adapter *padapter,
        /* Add quality statistics */
        iwe.cmd = IWEVQUAL;
        iwe.u.qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED
-       #if defined(CONFIG_SIGNAL_DISPLAY_DBM) && defined(CONFIG_BACKGROUND_NOISE_MONITOR)
-               | IW_QUAL_NOISE_UPDATED
-       #else
-               | IW_QUAL_NOISE_INVALID
-       #endif
-       #ifdef CONFIG_SIGNAL_DISPLAY_DBM
-               | IW_QUAL_DBM
-       #endif
-       ;
+               | IW_QUAL_NOISE_INVALID;
 
        if (check_fwstate(pmlmepriv, _FW_LINKED) == true &&
                is_same_network(&pmlmepriv->cur_network.network, &pnetwork->network, 0)) {
@@ -333,33 +325,11 @@ static char *translate_scan(struct adapter *padapter,
        }
 
 
-       #ifdef CONFIG_SIGNAL_DISPLAY_DBM
-       iwe.u.qual.level = (u8)translate_percentage_to_dbm(ss);/* dbm */
-       #else
-       #ifdef CONFIG_SKIP_SIGNAL_SCALE_MAPPING
-       {
-               /* Do signal scale mapping when using percentage as the unit of signal strength, since the scale mapping is skipped in odm */
-
-               struct hal_com_data *pHal = GET_HAL_DATA(padapter);
-
-               iwe.u.qual.level = (u8)odm_SignalScaleMapping(&pHal->odmpriv, ss);
-       }
-       #else
        iwe.u.qual.level = (u8)ss;/*  */
-       #endif
-       #endif
 
        iwe.u.qual.qual = (u8)sq;   /*  signal quality */
 
-       #if defined(CONFIG_SIGNAL_DISPLAY_DBM) && defined(CONFIG_BACKGROUND_NOISE_MONITOR)
-       {
-               s16 tmp_noise = 0;
-               rtw_hal_get_odm_var(padapter, HAL_ODM_NOISE_MONITOR, &(pnetwork->network.Configuration.DSConfig), &(tmp_noise));
-               iwe.u.qual.noise = tmp_noise;
-       }
-       #else
        iwe.u.qual.noise = 0; /*  noise level */
-       #endif
 
        /* DBG_871X("iqual =%d, ilevel =%d, inoise =%d, iupdated =%d\n", iwe.u.qual.qual, iwe.u.qual.level , iwe.u.qual.noise, iwe.u.qual.updated); */
 
@@ -847,7 +817,7 @@ static int rtw_wx_set_mode(struct net_device *dev, struct iw_request_info *a,
                             union iwreq_data *wrqu, char *b)
 {
        struct adapter *padapter = rtw_netdev_priv(dev);
-       enum NDIS_802_11_NETWORK_INFRASTRUCTURE networkType;
+       enum ndis_802_11_network_infrastructure networkType;
        int ret = 0;
 
        if (_FAIL == rtw_pwr_wakeup(padapter)) {
@@ -999,7 +969,7 @@ static int rtw_wx_set_pmkid(struct net_device *dev,
                }
        } else if (pPMK->cmd == IW_PMKSA_FLUSH) {
                DBG_871X("[rtw_wx_set_pmkid] IW_PMKSA_FLUSH!\n");
-               memset(&psecuritypriv->PMKIDList[0], 0x00, sizeof(RT_PMKID_LIST) * NUM_PMKID_CACHE);
+               memset(&psecuritypriv->PMKIDList[0], 0x00, sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
                psecuritypriv->PMKIDIndex = 0;
                intReturn = true;
        }
@@ -1133,7 +1103,7 @@ static int rtw_wx_set_wap(struct net_device *dev,
        u8 *dst_bssid, *src_bssid;
        struct __queue  *queue  = &(pmlmepriv->scanned_queue);
        struct  wlan_network    *pnetwork = NULL;
-       enum NDIS_802_11_AUTHENTICATION_MODE    authmode;
+       enum ndis_802_11_authentication_mode    authmode;
 
        rtw_ps_deny(padapter, PS_DENY_JOIN);
        if (_FAIL == rtw_pwr_wakeup(padapter)) {
@@ -1234,8 +1204,6 @@ static int rtw_wx_set_mlme(struct net_device *dev,
        if (mlme == NULL)
                return -1;
 
-       DBG_871X("%s\n", __func__);
-
        reason = mlme->reason_code;
 
        DBG_871X("%s, cmd =%d, reason =%d\n", __func__, mlme->cmd, reason);
@@ -1423,7 +1391,7 @@ static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a,
        char *ev = extra;
        char *stop = ev + wrqu->data.length;
        u32 ret = 0;
-       sint wait_status;
+       signed int wait_status;
 
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_scan\n"));
        RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, (" Start of Query SIOCGIWSCAN .\n"));
@@ -1499,7 +1467,7 @@ static int rtw_wx_set_essid(struct net_device *dev,
        struct __queue *queue = &pmlmepriv->scanned_queue;
        struct list_head *phead;
        struct wlan_network *pnetwork = NULL;
-       enum NDIS_802_11_AUTHENTICATION_MODE authmode;
+       enum ndis_802_11_authentication_mode authmode;
        struct ndis_802_11_ssid ndis_ssid;
        u8 *dst_ssid, *src_ssid;
 
@@ -1534,7 +1502,6 @@ static int rtw_wx_set_essid(struct net_device *dev,
        }
 
        authmode = padapter->securitypriv.ndisauthtype;
-       DBG_871X("=>%s\n", __func__);
        if (wrqu->essid.flags && wrqu->essid.length) {
                len = (wrqu->essid.length < IW_ESSID_MAX_SIZE) ? wrqu->essid.length : IW_ESSID_MAX_SIZE;
 
@@ -1837,7 +1804,7 @@ static int rtw_wx_set_enc(struct net_device *dev,
        u32 key, ret = 0;
        u32 keyindex_provided;
        struct ndis_802_11_wep   wep;
-       enum NDIS_802_11_AUTHENTICATION_MODE authmode;
+       enum ndis_802_11_authentication_mode authmode;
 
        struct iw_point *erq = &(wrqu->encoding);
        struct adapter *padapter = rtw_netdev_priv(dev);
@@ -3083,23 +3050,6 @@ static int rtw_dbg_port(struct net_device *dev,
                                                }
                                        }
                                        break;
-#ifdef CONFIG_BACKGROUND_NOISE_MONITOR
-                               case 0x1e:
-                                       {
-                                               struct hal_com_data     *pHalData = GET_HAL_DATA(padapter);
-                                               PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
-                                               u8 chan = rtw_get_oper_ch(padapter);
-                                               DBG_871X("===========================================\n");
-                                               ODM_InbandNoise_Monitor(pDM_Odm, true, 0x1e, 100);
-                                               DBG_871X("channel(%d), noise_a = %d, noise_b = %d , noise_all:%d\n",
-                                                       chan, pDM_Odm->noise_level.noise[ODM_RF_PATH_A],
-                                                       pDM_Odm->noise_level.noise[ODM_RF_PATH_B],
-                                                       pDM_Odm->noise_level.noise_all);
-                                               DBG_871X("===========================================\n");
-
-                                       }
-                                       break;
-#endif
                                case 0x23:
                                        {
                                                DBG_871X("turn %s the bNotifyChannelChange Variable\n", (extra_arg == 1)?"on":"off");
@@ -3110,46 +3060,6 @@ static int rtw_dbg_port(struct net_device *dev,
                                        {
                                                break;
                                        }
-#ifdef CONFIG_GPIO_API
-                           case 0x25: /* Get GPIO register */
-                                   {
-                                           /*
-                                           * dbg 0x7f250000 [gpio_num], Get gpio value, gpio_num:0~7
-                                           */
-
-                                           int value;
-                                           DBG_871X("Read GPIO Value  extra_arg = %d\n", extra_arg);
-                                           value = rtw_get_gpio(dev, extra_arg);
-                                           DBG_871X("Read GPIO Value = %d\n", value);
-                                           break;
-                                   }
-                           case 0x26: /* Set GPIO direction */
-                                   {
-
-                                           /* dbg 0x7f26000x [y], Set gpio direction,
-                                           * x: gpio_num, 4~7  y: indicate direction, 0~1
-                                           */
-
-                                           int value;
-                                           DBG_871X("Set GPIO Direction! arg = %d , extra_arg =%d\n", arg, extra_arg);
-                                           value = rtw_config_gpio(dev, arg, extra_arg);
-                                           DBG_871X("Set GPIO Direction %s\n", (value == -1) ? "Fail!!!" : "Success");
-                                           break;
-                                       }
-                               case 0x27: /* Set GPIO output direction value */
-                                       {
-                                               /*
-                                               * dbg 0x7f27000x [y], Set gpio output direction value,
-                                               * x: gpio_num, 4~7  y: indicate direction, 0~1
-                                               */
-
-                                               int value;
-                                               DBG_871X("Set GPIO Value! arg = %d , extra_arg =%d\n", arg, extra_arg);
-                                               value = rtw_set_gpio_output_value(dev, arg, extra_arg);
-                                               DBG_871X("Set GPIO Value %s\n", (value == -1) ? "Fail!!!" : "Success");
-                                               break;
-                                       }
-#endif
                                case 0xaa:
                                        {
                                                if ((extra_arg & 0x7F) > 0x3F)
@@ -3434,8 +3344,6 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
        struct security_priv *psecuritypriv = &(padapter->securitypriv);
        struct sta_priv *pstapriv = &padapter->stapriv;
 
-       DBG_871X("%s\n", __func__);
-
        param->u.crypt.err = 0;
        param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0';
 
@@ -3731,8 +3639,6 @@ static void rtw_hostapd_sta_flush(struct net_device *dev)
        struct adapter *padapter = rtw_netdev_priv(dev);
        /* struct sta_priv *pstapriv = &padapter->stapriv; */
 
-       DBG_871X("%s\n", __func__);
-
        flush_all_cam_entry(padapter);  /* clear CAM */
 
        rtw_sta_flush(padapter);
@@ -4086,7 +3992,7 @@ static int rtw_set_hidden_ssid(struct net_device *dev, struct ieee_param *param,
        int ie_len;
        u8 *ssid_ie;
        char ssid[NDIS_802_11_LENGTH_SSID + 1];
-       sint ssid_len;
+       signed int ssid_len;
        u8 ignore_broadcast_ssid;
 
        if (check_fwstate(mlmepriv, WIFI_AP_STATE) != true)
@@ -4187,8 +4093,6 @@ static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p)
        int ret = 0;
        struct adapter *padapter = rtw_netdev_priv(dev);
 
-       /* DBG_871X("%s\n", __func__); */
-
        /*
        * this function is expect to call in master mode, which allows no power saving
        * so, we just check hw_init_completed
@@ -4668,13 +4572,6 @@ static const struct iw_priv_args rtw_private_args[] = {
                SIOCIWFIRSTPRIV + 0x1D,
                IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_CHAR | 0x7FF, "test"
        },
-
-#ifdef CONFIG_WOWLAN
-               { MP_WOW_ENABLE, IW_PRIV_TYPE_CHAR | 1024, 0, "wow_mode" }, /* set */
-#endif
-#ifdef CONFIG_AP_WOWLAN
-               { MP_AP_WOW_ENABLE, IW_PRIV_TYPE_CHAR | 1024, 0, "ap_wow_mode" }, /* set */
-#endif
 };
 
 static iw_handler rtw_private_handler[] = {
@@ -4735,41 +4632,8 @@ static struct iw_statistics *rtw_get_wireless_stats(struct net_device *dev)
                piwstats->qual.noise = 0;
                /* DBG_871X("No link  level:%d, qual:%d, noise:%d\n", tmp_level, tmp_qual, tmp_noise); */
        } else {
-               #ifdef CONFIG_SIGNAL_DISPLAY_DBM
-               tmp_level = translate_percentage_to_dbm(padapter->recvpriv.signal_strength);
-               #else
-               #ifdef CONFIG_SKIP_SIGNAL_SCALE_MAPPING
-               {
-                       /* Do signal scale mapping when using percentage as the unit of signal strength, since the scale mapping is skipped in odm */
-
-                       struct hal_com_data *pHal = GET_HAL_DATA(padapter);
-
-                       tmp_level = (u8)odm_SignalScaleMapping(&pHal->odmpriv, padapter->recvpriv.signal_strength);
-               }
-               #else
                tmp_level = padapter->recvpriv.signal_strength;
-               #endif
-               #endif
-
                tmp_qual = padapter->recvpriv.signal_qual;
-#if defined(CONFIG_SIGNAL_DISPLAY_DBM) && defined(CONFIG_BACKGROUND_NOISE_MONITOR)
-               if (rtw_linked_check(padapter)) {
-                       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-                       struct noise_info info;
-                       info.bPauseDIG = true;
-                       info.IGIValue = 0x1e;
-                       info.max_time = 100;/* ms */
-                       info.chan = pmlmeext->cur_channel ;/* rtw_get_oper_ch(padapter); */
-                       rtw_ps_deny(padapter, PS_DENY_IOCTL);
-                       LeaveAllPowerSaveModeDirect(padapter);
-
-                       rtw_hal_set_odm_var(padapter, HAL_ODM_NOISE_MONITOR, &info, false);
-                       /* ODM_InbandNoise_Monitor(podmpriv, true, 0x20, 100); */
-                       rtw_ps_deny_cancel(padapter, PS_DENY_IOCTL);
-                       rtw_hal_get_odm_var(padapter, HAL_ODM_NOISE_MONITOR, &(info.chan), &(padapter->recvpriv.noise));
-                       DBG_871X("chan:%d, noise_level:%d\n", info.chan, padapter->recvpriv.noise);
-               }
-#endif
                tmp_noise = padapter->recvpriv.noise;
                DBG_871X("level:%d, qual:%d, noise:%d, rssi (%d)\n", tmp_level, tmp_qual, tmp_noise, padapter->recvpriv.rssi);
 
@@ -4779,10 +4643,6 @@ static struct iw_statistics *rtw_get_wireless_stats(struct net_device *dev)
        }
        piwstats->qual.updated = IW_QUAL_ALL_UPDATED ;/* IW_QUAL_DBM; */
 
-       #ifdef CONFIG_SIGNAL_DISPLAY_DBM
-       piwstats->qual.updated = piwstats->qual.updated | IW_QUAL_DBM;
-       #endif
-
        return &padapter->iwstats;
 }
 
index 20899b2cff4399150bff13855b18a0768f7fc901..ba4d3789a41e3b15dcfcace086a00532cf93da6a 100644 (file)
@@ -65,7 +65,7 @@ void rtw_os_indicate_scan_done(struct adapter *padapter, bool aborted)
        indicate_wx_scan_complete_event(padapter);
 }
 
-static RT_PMKID_LIST   backupPMKIDList[NUM_PMKID_CACHE];
+static struct rt_pmkid_list   backupPMKIDList[NUM_PMKID_CACHE];
 void rtw_reset_securitypriv(struct adapter *adapter)
 {
        u8 backupPMKIDIndex = 0;
@@ -84,7 +84,7 @@ void rtw_reset_securitypriv(struct adapter *adapter)
                /*  Backup the btkip_countermeasure information. */
                /*  When the countermeasure is trigger, the driver have to disconnect with AP for 60 seconds. */
 
-               memcpy(&backupPMKIDList[0], &adapter->securitypriv.PMKIDList[0], sizeof(RT_PMKID_LIST) * NUM_PMKID_CACHE);
+               memcpy(&backupPMKIDList[0], &adapter->securitypriv.PMKIDList[0], sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
                backupPMKIDIndex = adapter->securitypriv.PMKIDIndex;
                backupTKIPCountermeasure = adapter->securitypriv.btkip_countermeasure;
                backupTKIPcountermeasure_time = adapter->securitypriv.btkip_countermeasure_time;
@@ -96,7 +96,7 @@ void rtw_reset_securitypriv(struct adapter *adapter)
 
                /*  Added by Albert 2009/02/18 */
                /*  Restore the PMK information to securitypriv structure for the following connection. */
-               memcpy(&adapter->securitypriv.PMKIDList[0], &backupPMKIDList[0], sizeof(RT_PMKID_LIST) * NUM_PMKID_CACHE);
+               memcpy(&adapter->securitypriv.PMKIDList[0], &backupPMKIDList[0], sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
                adapter->securitypriv.PMKIDIndex = backupPMKIDIndex;
                adapter->securitypriv.btkip_countermeasure = backupTKIPCountermeasure;
                adapter->securitypriv.btkip_countermeasure_time = backupTKIPcountermeasure_time;
@@ -127,7 +127,7 @@ void rtw_reset_securitypriv(struct adapter *adapter)
 
 void rtw_os_indicate_disconnect(struct adapter *adapter)
 {
-       /* RT_PMKID_LIST   backupPMKIDList[ NUM_PMKID_CACHE ]; */
+       /* struct rt_pmkid_list   backupPMKIDList[ NUM_PMKID_CACHE ]; */
 
        netif_carrier_off(adapter->pnetdev); /*  Do it first for tx broadcast pkt after disconnection issue! */
 
index b62fe9238e6d92524ac9ef7f07edaaf88b0346d4..405aa95af579311acc92fd9a468a10fb3a94012a 100644 (file)
@@ -113,11 +113,7 @@ static int rtw_enusbss;/* 0:disable, 1:enable */
 
 static int rtw_hwpdn_mode = 2;/* 0:disable, 1:enable, 2: by EFUSE config */
 
-#ifdef CONFIG_HW_PWRP_DETECTION
-static int rtw_hwpwrp_detect = 1;
-#else
 static int rtw_hwpwrp_detect; /* HW power  ping detect 0:disable , 1:enable */
-#endif
 
 static int rtw_hw_wps_pbc;
 
@@ -125,11 +121,7 @@ int rtw_mc2u_disable = 0;
 
 static int rtw_80211d;
 
-#ifdef CONFIG_QOS_OPTIMIZATION
-static int rtw_qos_opt_enable = 1;/* 0: disable, 1:enable */
-#else
 static int rtw_qos_opt_enable;/* 0: disable, 1:enable */
-#endif
 module_param(rtw_qos_opt_enable, int, 0644);
 
 static char *ifname = "wlan%d";
@@ -201,11 +193,9 @@ MODULE_PARM_DESC(rtw_tx_pwr_lmt_enable, "0:Disable, 1:Enable, 2: Depend on efuse
 module_param(rtw_tx_pwr_by_rate, int, 0644);
 MODULE_PARM_DESC(rtw_tx_pwr_by_rate, "0:Disable, 1:Enable, 2: Depend on efuse");
 
-int _netdev_open(struct net_device *pnetdev);
-int netdev_open(struct net_device *pnetdev);
 static int netdev_close(struct net_device *pnetdev);
 
-static void loadparam(struct adapter *padapter, _nic_hdl pnetdev)
+static void loadparam(struct adapter *padapter, struct net_device *pnetdev)
 {
        struct registry_priv  *registry_par = &padapter->registrypriv;
 
@@ -596,9 +586,6 @@ static void rtw_init_default_value(struct adapter *padapter)
        /* security_priv */
        /* rtw_get_encrypt_decrypt_from_registrypriv(padapter); */
        psecuritypriv->binstallGrpkey = _FAIL;
-#ifdef CONFIG_GTK_OL
-       psecuritypriv->binstallKCK_KEK = _FAIL;
-#endif /* CONFIG_GTK_OL */
        psecuritypriv->sw_encrypt = pregistrypriv->software_encrypt;
        psecuritypriv->sw_decrypt = pregistrypriv->software_decrypt;
 
@@ -886,7 +873,7 @@ int rtw_drv_register_netdev(struct adapter *if1)
        return _rtw_drv_register_netdev(padapter, name);
 }
 
-int _netdev_open(struct net_device *pnetdev)
+static int _netdev_open(struct net_device *pnetdev)
 {
        uint status;
        struct adapter *padapter = rtw_netdev_priv(pnetdev);
@@ -985,9 +972,6 @@ static int  ips_netdrv_open(struct adapter *padapter)
 
        padapter->net_closed = false;
 
-       DBG_871X("===> %s.........\n", __func__);
-
-
        padapter->bDriverStopped = false;
        padapter->bCardDisableWOHSM = false;
        /* padapter->bup = true; */
@@ -1038,14 +1022,11 @@ void rtw_ips_pwr_down(struct adapter *padapter)
 
 void rtw_ips_dev_unload(struct adapter *padapter)
 {
-       DBG_871X("====> %s...\n", __func__);
-
 
        if (!padapter->bSurpriseRemoved)
                rtw_hal_deinit(padapter);
 }
 
-
 static int pm_netdev_open(struct net_device *pnetdev, u8 bnormal)
 {
        int status = -1;
@@ -1135,7 +1116,6 @@ void rtw_dev_unload(struct adapter *padapter)
        RT_TRACE(_module_hci_intfs_c_, _drv_notice_, ("+%s\n", __func__));
 
        if (padapter->bup) {
-               DBG_871X("===> %s\n", __func__);
 
                padapter->bDriverStopped = true;
                if (padapter->xmitpriv.ack_tx)
@@ -1174,16 +1154,10 @@ void rtw_dev_unload(struct adapter *padapter)
 
                if (!padapter->bSurpriseRemoved) {
                        hal_btcoex_IpsNotify(padapter, pwrctl->ips_mode_req);
-#ifdef CONFIG_WOWLAN
-                       if (pwrctl->bSupportRemoteWakeup && pwrctl->wowlan_mode) {
-                               DBG_871X_LEVEL(_drv_always_, "%s bSupportRemoteWakeup ==true  do not run rtw_hal_deinit()\n", __func__);
-                       }
-                       else
-#endif
-                       {
-                               /* amy modify 20120221 for power seq is different between driver open and ips */
-                               rtw_hal_deinit(padapter);
-                       }
+
+                       /* amy modify 20120221 for power seq is different between driver open and ips */
+                       rtw_hal_deinit(padapter);
+
                        padapter->bSurpriseRemoved = true;
                }
                RT_TRACE(_module_hci_intfs_c_, _drv_notice_,
@@ -1191,7 +1165,6 @@ void rtw_dev_unload(struct adapter *padapter)
 
                padapter->bup = false;
 
-               DBG_871X("<=== %s\n", __func__);
        } else {
                RT_TRACE(_module_hci_intfs_c_, _drv_notice_, ("%s: bup ==false\n", __func__));
                DBG_871X("%s: bup ==false\n", __func__);
@@ -1244,133 +1217,6 @@ static int rtw_suspend_free_assoc_resource(struct adapter *padapter)
        return _SUCCESS;
 }
 
-#ifdef CONFIG_WOWLAN
-void rtw_suspend_wow(struct adapter *padapter)
-{
-       u8 ch, bw, offset;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct net_device *pnetdev = padapter->pnetdev;
-       struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter);
-       struct wowlan_ioctl_param poidparam;
-
-       DBG_871X("==> " FUNC_ADPT_FMT " entry....\n", FUNC_ADPT_ARG(padapter));
-
-
-       DBG_871X("wowlan_mode: %d\n", pwrpriv->wowlan_mode);
-       DBG_871X("wowlan_pno_enable: %d\n", pwrpriv->wowlan_pno_enable);
-
-       if (pwrpriv->wowlan_mode) {
-               if (pnetdev)
-                       rtw_netif_stop_queue(pnetdev);
-               /*  1. stop thread */
-               padapter->bDriverStopped = true;        /* for stop thread */
-               rtw_stop_drv_threads(padapter);
-               padapter->bDriverStopped = false;       /* for 32k command */
-
-               /*  2. disable interrupt */
-               if (padapter->intf_stop)
-                       padapter->intf_stop(padapter);
-
-               /*  2.1 clean interrupt */
-               if (padapter->HalFunc.clear_interrupt)
-                       padapter->HalFunc.clear_interrupt(padapter);
-
-               /*  2.2 free irq */
-               /* sdio_free_irq(adapter_to_dvobj(padapter)); */
-               if (padapter->intf_free_irq)
-                       padapter->intf_free_irq(adapter_to_dvobj(padapter));
-
-               poidparam.subcode = WOWLAN_ENABLE;
-               padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_WOWLAN, (u8 *)&poidparam);
-               if (rtw_chk_roam_flags(padapter, RTW_ROAM_ON_RESUME)) {
-                       if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) && check_fwstate(pmlmepriv, _FW_LINKED)) {
-                               DBG_871X("%s %s(%pM), length:%d assoc_ssid.length:%d\n", __func__,
-                                               pmlmepriv->cur_network.network.Ssid.Ssid,
-                                               MAC_ARG(pmlmepriv->cur_network.network.MacAddress),
-                                               pmlmepriv->cur_network.network.Ssid.SsidLength,
-                                               pmlmepriv->assoc_ssid.SsidLength);
-
-                               rtw_set_to_roam(padapter, 0);
-                       }
-               }
-
-               DBG_871X_LEVEL(_drv_always_, "%s: wowmode suspending\n", __func__);
-
-               if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) {
-                       DBG_871X_LEVEL(_drv_always_, "%s: fw_under_survey\n", __func__);
-                       rtw_indicate_scan_done(padapter, 1);
-                       clr_fwstate(pmlmepriv, _FW_UNDER_SURVEY);
-               }
-
-               if (rtw_get_ch_setting_union(padapter, &ch, &bw, &offset) != 0) {
-                       DBG_871X(FUNC_ADPT_FMT " back to linked/linking union - ch:%u, bw:%u, offset:%u\n",
-                               FUNC_ADPT_ARG(padapter), ch, bw, offset);
-                       set_channel_bwmode(padapter, ch, offset, bw);
-               }
-
-               if (pwrpriv->wowlan_pno_enable)
-                       DBG_871X_LEVEL(_drv_always_, "%s: pno: %d\n", __func__, pwrpriv->wowlan_pno_enable);
-               else
-                       rtw_set_ps_mode(padapter, PS_MODE_DTIM, 0, 0, "WOWLAN");
-       } else {
-               DBG_871X_LEVEL(_drv_always_, "%s: ### ERROR ### wowlan_mode =%d\n", __func__, pwrpriv->wowlan_mode);
-       }
-       DBG_871X("<== " FUNC_ADPT_FMT " exit....\n", FUNC_ADPT_ARG(padapter));
-}
-#endif /* ifdef CONFIG_WOWLAN */
-
-#ifdef CONFIG_AP_WOWLAN
-void rtw_suspend_ap_wow(struct adapter *padapter)
-{
-       u8 ch, bw, offset;
-       struct net_device *pnetdev = padapter->pnetdev;
-       struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter);
-       struct wowlan_ioctl_param poidparam;
-
-       DBG_871X("==> " FUNC_ADPT_FMT " entry....\n", FUNC_ADPT_ARG(padapter));
-
-       pwrpriv->wowlan_ap_mode = true;
-
-       DBG_871X("wowlan_ap_mode: %d\n", pwrpriv->wowlan_ap_mode);
-
-       if (pnetdev)
-               rtw_netif_stop_queue(pnetdev);
-       /*  1. stop thread */
-       padapter->bDriverStopped = true;        /* for stop thread */
-       rtw_stop_drv_threads(padapter);
-       padapter->bDriverStopped = false;       /* for 32k command */
-
-       /*  2. disable interrupt */
-       rtw_hal_disable_interrupt(padapter); /*  It need wait for leaving 32K. */
-
-       /*  2.1 clean interrupt */
-       if (padapter->HalFunc.clear_interrupt)
-               padapter->HalFunc.clear_interrupt(padapter);
-
-       /*  2.2 free irq */
-       /* sdio_free_irq(adapter_to_dvobj(padapter)); */
-       if (padapter->intf_free_irq)
-               padapter->intf_free_irq(adapter_to_dvobj(padapter));
-
-       poidparam.subcode = WOWLAN_AP_ENABLE;
-       padapter->HalFunc.SetHwRegHandler(padapter,
-                                       HW_VAR_AP_WOWLAN, (u8 *)&poidparam);
-
-       DBG_871X_LEVEL(_drv_always_, "%s: wowmode suspending\n", __func__);
-
-       if (rtw_get_ch_setting_union(padapter, &ch, &bw, &offset) != 0) {
-               DBG_871X(FUNC_ADPT_FMT " back to linked/linking union - ch:%u, bw:%u, offset:%u\n",
-                        FUNC_ADPT_ARG(padapter), ch, bw, offset);
-               set_channel_bwmode(padapter, ch, offset, bw);
-       }
-
-       rtw_set_ps_mode(padapter, PS_MODE_MIN, 0, 0, "AP-WOWLAN");
-
-       DBG_871X("<== " FUNC_ADPT_FMT " exit....\n", FUNC_ADPT_ARG(padapter));
-}
-#endif /* ifdef CONFIG_AP_WOWLAN */
-
-
 static void rtw_suspend_normal(struct adapter *padapter)
 {
        struct net_device *pnetdev = padapter->pnetdev;
@@ -1440,26 +1286,9 @@ int rtw_suspend_common(struct adapter *padapter)
        rtw_ps_deny_cancel(padapter, PS_DENY_SUSPEND);
 
        if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
-       #ifdef CONFIG_WOWLAN
-               if (check_fwstate(pmlmepriv, _FW_LINKED))
-                       pwrpriv->wowlan_mode = true;
-               else if (pwrpriv->wowlan_pno_enable)
-                       pwrpriv->wowlan_mode |= pwrpriv->wowlan_pno_enable;
-
-               if (pwrpriv->wowlan_mode)
-                       rtw_suspend_wow(padapter);
-               else
-                       rtw_suspend_normal(padapter);
-
-       #else /* CONFIG_WOWLAN */
                rtw_suspend_normal(padapter);
-       #endif /* CONFIG_WOWLAN */
        } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
-       #ifdef CONFIG_AP_WOWLAN
-               rtw_suspend_ap_wow(padapter);
-       #else
                rtw_suspend_normal(padapter);
-       #endif /* CONFIG_AP_WOWLAN */
        } else {
                rtw_suspend_normal(padapter);
        }
@@ -1474,202 +1303,6 @@ exit:
        return ret;
 }
 
-#ifdef CONFIG_WOWLAN
-int rtw_resume_process_wow(struct adapter *padapter)
-{
-       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-       struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
-       struct net_device *pnetdev = padapter->pnetdev;
-       struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter);
-       struct dvobj_priv *psdpriv = padapter->dvobj;
-       struct debug_priv *pdbgpriv = &psdpriv->drv_dbg;
-       struct wowlan_ioctl_param poidparam;
-       struct sta_info *psta = NULL;
-       int ret = _SUCCESS;
-
-       DBG_871X("==> " FUNC_ADPT_FMT " entry....\n", FUNC_ADPT_ARG(padapter));
-
-       if (padapter) {
-               pnetdev = padapter->pnetdev;
-               pwrpriv = adapter_to_pwrctl(padapter);
-       } else {
-               pdbgpriv->dbg_resume_error_cnt++;
-               ret = -1;
-               goto exit;
-       }
-
-       if (padapter->bDriverStopped || padapter->bSurpriseRemoved) {
-               DBG_871X("%s pdapter %p bDriverStopped %d bSurpriseRemoved %d\n",
-                               __func__, padapter, padapter->bDriverStopped,
-                               padapter->bSurpriseRemoved);
-               goto exit;
-       }
-
-#ifdef CONFIG_PNO_SUPPORT
-       pwrpriv->pno_in_resume = true;
-#endif
-
-       if (pwrpriv->wowlan_mode) {
-               rtw_set_ps_mode(padapter, PS_MODE_ACTIVE, 0, 0, "WOWLAN");
-
-               pwrpriv->bFwCurrentInPSMode = false;
-
-               if (padapter->intf_stop)
-                       padapter->intf_stop(padapter);
-
-               if (padapter->HalFunc.clear_interrupt)
-                       padapter->HalFunc.clear_interrupt(padapter);
-
-               /* if (sdio_alloc_irq(adapter_to_dvobj(padapter)) != _SUCCESS) { */
-               if ((padapter->intf_alloc_irq) && (padapter->intf_alloc_irq(adapter_to_dvobj(padapter)) != _SUCCESS)) {
-                       ret = -1;
-                       RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("%s: sdio_alloc_irq Failed!!\n", __func__));
-                       goto exit;
-               }
-
-               /* Disable WOW, set H2C command */
-               poidparam.subcode = WOWLAN_DISABLE;
-               padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_WOWLAN, (u8 *)&poidparam);
-
-               psta = rtw_get_stainfo(&padapter->stapriv, get_bssid(&padapter->mlmepriv));
-               if (psta)
-                       set_sta_rate(padapter, psta);
-
-               padapter->bDriverStopped = false;
-               DBG_871X("%s: wowmode resuming, DriverStopped:%d\n", __func__, padapter->bDriverStopped);
-               rtw_start_drv_threads(padapter);
-
-               if (padapter->intf_start)
-                       padapter->intf_start(padapter);
-
-               /*  start netif queue */
-               if (pnetdev) {
-                       if (!rtw_netif_queue_stopped(pnetdev))
-                               rtw_netif_start_queue(pnetdev);
-                       else
-                               rtw_netif_wake_queue(pnetdev);
-               }
-       } else {
-               DBG_871X_LEVEL(_drv_always_, "%s: ### ERROR ### wowlan_mode =%d\n", __func__, pwrpriv->wowlan_mode);
-       }
-
-       if (padapter->pid[1] != 0) {
-               DBG_871X("pid[1]:%d\n", padapter->pid[1]);
-               rtw_signal_process(padapter->pid[1], SIGUSR2);
-       }
-
-       if (rtw_chk_roam_flags(padapter, RTW_ROAM_ON_RESUME)) {
-               if (pwrpriv->wowlan_wake_reason == FWDecisionDisconnect ||
-                       pwrpriv->wowlan_wake_reason == Rx_DisAssoc ||
-                       pwrpriv->wowlan_wake_reason == Rx_DeAuth) {
-                       DBG_871X("%s: disconnect reason: %02x\n", __func__,
-                                               pwrpriv->wowlan_wake_reason);
-                       rtw_indicate_disconnect(padapter);
-
-                       rtw_sta_media_status_rpt(padapter,
-                               rtw_get_stainfo(&padapter->stapriv,
-                                       get_bssid(&padapter->mlmepriv)), 0);
-
-                       rtw_free_assoc_resources(padapter, 1);
-                       pmlmeinfo->state = WIFI_FW_NULL_STATE;
-
-               } else {
-                       DBG_871X("%s: do roaming\n", __func__);
-                       rtw_roaming(padapter, NULL);
-               }
-       }
-
-       if (pwrpriv->wowlan_mode) {
-               pwrpriv->bips_processing = false;
-               _set_timer(&padapter->mlmepriv.dynamic_chk_timer, 2000);
-       } else {
-               DBG_871X_LEVEL(_drv_always_, "do not reset timer\n");
-       }
-
-       pwrpriv->wowlan_mode = false;
-
-       /* clean driver side wake up reason. */
-       pwrpriv->wowlan_wake_reason = 0;
-exit:
-       DBG_871X("<== " FUNC_ADPT_FMT " exit....\n", FUNC_ADPT_ARG(padapter));
-       return ret;
-}
-#endif /* ifdef CONFIG_WOWLAN */
-
-#ifdef CONFIG_AP_WOWLAN
-int rtw_resume_process_ap_wow(struct adapter *padapter)
-{
-       struct net_device *pnetdev = padapter->pnetdev;
-       struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter);
-       struct dvobj_priv *psdpriv = padapter->dvobj;
-       struct debug_priv *pdbgpriv = &psdpriv->drv_dbg;
-       struct wowlan_ioctl_param poidparam;
-       int ret = _SUCCESS;
-
-       DBG_871X("==> " FUNC_ADPT_FMT " entry....\n", FUNC_ADPT_ARG(padapter));
-
-       if (padapter) {
-               pnetdev = padapter->pnetdev;
-               pwrpriv = adapter_to_pwrctl(padapter);
-       } else {
-               pdbgpriv->dbg_resume_error_cnt++;
-               ret = -1;
-               goto exit;
-       }
-
-       rtw_set_ps_mode(padapter, PS_MODE_ACTIVE, 0, 0, "AP-WOWLAN");
-
-       pwrpriv->bFwCurrentInPSMode = false;
-
-       rtw_hal_disable_interrupt(padapter);
-
-       if (padapter->HalFunc.clear_interrupt)
-               padapter->HalFunc.clear_interrupt(padapter);
-
-       /* if (sdio_alloc_irq(adapter_to_dvobj(padapter)) != _SUCCESS) { */
-       if ((padapter->intf_alloc_irq) && (padapter->intf_alloc_irq(adapter_to_dvobj(padapter)) != _SUCCESS)) {
-               ret = -1;
-               RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("%s: sdio_alloc_irq Failed!!\n", __func__));
-               goto exit;
-       }
-
-       /* Disable WOW, set H2C command */
-       poidparam.subcode = WOWLAN_AP_DISABLE;
-       padapter->HalFunc.SetHwRegHandler(padapter,
-               HW_VAR_AP_WOWLAN, (u8 *)&poidparam);
-       pwrpriv->wowlan_ap_mode = false;
-
-       padapter->bDriverStopped = false;
-       DBG_871X("%s: wowmode resuming, DriverStopped:%d\n", __func__, padapter->bDriverStopped);
-       rtw_start_drv_threads(padapter);
-
-       if (padapter->intf_start)
-               padapter->intf_start(padapter);
-
-       /*  start netif queue */
-       if (pnetdev) {
-               if (!rtw_netif_queue_stopped(pnetdev))
-                       rtw_netif_start_queue(pnetdev);
-               else
-                       rtw_netif_wake_queue(pnetdev);
-       }
-
-       if (padapter->pid[1] != 0) {
-               DBG_871X("pid[1]:%d\n", padapter->pid[1]);
-               rtw_signal_process(padapter->pid[1], SIGUSR2);
-       }
-
-       pwrpriv->bips_processing = false;
-       _set_timer(&padapter->mlmepriv.dynamic_chk_timer, 2000);
-
-       /* clean driver side wake up reason. */
-       pwrpriv->wowlan_wake_reason = 0;
-exit:
-       DBG_871X("<== " FUNC_ADPT_FMT " exit....\n", FUNC_ADPT_ARG(padapter));
-       return ret;
-}
-#endif /* ifdef CONFIG_APWOWLAN */
-
 static int rtw_resume_process_normal(struct adapter *padapter)
 {
        struct net_device *pnetdev;
@@ -1757,21 +1390,9 @@ int rtw_resume_common(struct adapter *padapter)
        DBG_871X("==> %s (%s:%d)\n", __func__, current->comm, current->pid);
 
        if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
-       #ifdef CONFIG_WOWLAN
-               if (pwrpriv->wowlan_mode)
-                       rtw_resume_process_wow(padapter);
-               else
-                       rtw_resume_process_normal(padapter);
-       #else
                rtw_resume_process_normal(padapter);
-       #endif
-
        } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
-       #ifdef CONFIG_AP_WOWLAN
-               rtw_resume_process_ap_wow(padapter);
-       #else
                rtw_resume_process_normal(padapter);
-       #endif /* CONFIG_AP_WOWLAN */
        } else {
                rtw_resume_process_normal(padapter);
        }
@@ -1780,9 +1401,6 @@ int rtw_resume_common(struct adapter *padapter)
 
        if (pwrpriv) {
                pwrpriv->bInSuspend = false;
-       #ifdef CONFIG_PNO_SUPPORT
-               pwrpriv->pno_in_resume = false;
-       #endif
        }
        DBG_871X_LEVEL(_drv_always_, "%s:%d in %d ms\n", __func__, ret,
                jiffies_to_msecs(jiffies - start_time));
index 3c71d2fafabff689c3c1fcd763c544bf1bc22d5a..843003b91ea2298ae54187db5e6e87054ccf3037 100644 (file)
@@ -47,7 +47,7 @@ inline struct sk_buff *_rtw_skb_copy(const struct sk_buff *skb)
        return skb_copy(skb, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
 }
 
-inline int _rtw_netif_rx(_nic_hdl ndev, struct sk_buff *skb)
+inline int _rtw_netif_rx(struct net_device *ndev, struct sk_buff *skb)
 {
        skb->dev = ndev;
        return netif_rx(skb);
index f52802f24466a715c6d35b65b26a4ffaf59dc972..fbdbcd04d44ac19908aa40798d8c9cb8864eb718 100644 (file)
@@ -30,7 +30,7 @@ void rtw_os_recv_resource_alloc(struct adapter *padapter, union recv_frame *prec
 /* free os related resource in union recv_frame */
 void rtw_os_recv_resource_free(struct recv_priv *precvpriv)
 {
-       sint i;
+       signed int i;
        union recv_frame *precvframe;
 
        precvframe = (union recv_frame *) precvpriv->precv_frame_buf;
@@ -53,10 +53,10 @@ void rtw_os_recvbuf_resource_free(struct adapter *padapter, struct recv_buf *pre
        }
 }
 
-_pkt *rtw_os_alloc_msdu_pkt(union recv_frame *prframe, u16 nSubframe_Length, u8 *pdata)
+struct sk_buff *rtw_os_alloc_msdu_pkt(union recv_frame *prframe, u16 nSubframe_Length, u8 *pdata)
 {
        u16 eth_type;
-       _pkt *sub_skb;
+       struct sk_buff *sub_skb;
        struct rx_pkt_attrib *pattrib;
 
        pattrib = &prframe->u.hdr.attrib;
@@ -95,7 +95,7 @@ _pkt *rtw_os_alloc_msdu_pkt(union recv_frame *prframe, u16 nSubframe_Length, u8
        return sub_skb;
 }
 
-void rtw_os_recv_indicate_pkt(struct adapter *padapter, _pkt *pkt, struct rx_pkt_attrib *pattrib)
+void rtw_os_recv_indicate_pkt(struct adapter *padapter, struct sk_buff *pkt, struct rx_pkt_attrib *pattrib)
 {
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        int ret;
@@ -103,7 +103,7 @@ void rtw_os_recv_indicate_pkt(struct adapter *padapter, _pkt *pkt, struct rx_pkt
        /* Indicate the packets to upper layer */
        if (pkt) {
                if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) {
-                       _pkt *pskb2 = NULL;
+                       struct sk_buff *pskb2 = NULL;
                        struct sta_info *psta = NULL;
                        struct sta_priv *pstapriv = &padapter->stapriv;
                        int bmcast = IS_MCAST(pattrib->dst);
@@ -138,15 +138,7 @@ void rtw_os_recv_indicate_pkt(struct adapter *padapter, _pkt *pkt, struct rx_pkt
                pkt->protocol = eth_type_trans(pkt, padapter->pnetdev);
                pkt->dev = padapter->pnetdev;
 
-#ifdef CONFIG_TCP_CSUM_OFFLOAD_RX
-               if ((pattrib->tcpchk_valid == 1) && (pattrib->tcp_chkrpt == 1))
-                       pkt->ip_summed = CHECKSUM_UNNECESSARY;
-               else
-                       pkt->ip_summed = CHECKSUM_NONE;
-
-#else /* !CONFIG_TCP_CSUM_OFFLOAD_RX */
                pkt->ip_summed = CHECKSUM_NONE;
-#endif /* CONFIG_TCP_CSUM_OFFLOAD_RX */
 
                ret = rtw_netif_rx(padapter->pnetdev, pkt);
        }
@@ -198,44 +190,11 @@ void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup)
        wrqu.data.length = sizeof(ev);
 }
 
-#ifdef CONFIG_AUTO_AP_MODE
-static void rtw_os_ksocket_send(struct adapter *padapter, union recv_frame *precv_frame)
-{
-       _pkt *skb = precv_frame->u.hdr.pkt;
-       struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
-       struct sta_info *psta = precv_frame->u.hdr.psta;
-
-       DBG_871X("eth rx: got eth_type = 0x%x\n", pattrib->eth_type);
-
-       if (psta && psta->isrc && psta->pid > 0) {
-               u16 rx_pid;
-
-               rx_pid = *(u16 *)(skb->data+ETH_HLEN);
-
-               DBG_871X("eth rx(pid = 0x%x): sta(%pM) pid = 0x%x\n",
-                       rx_pid, MAC_ARG(psta->hwaddr), psta->pid);
-
-               if (rx_pid == psta->pid) {
-                       int i;
-                       u16 len = *(u16 *)(skb->data+ETH_HLEN+2);
-                       DBG_871X("eth, RC: len = 0x%x\n", len);
-
-                       for (i = 0; i < len; i++)
-                               DBG_871X("0x%x\n", *(skb->data+ETH_HLEN+4+i));
-
-                       DBG_871X("eth, RC-end\n");
-               }
-
-       }
-
-}
-#endif /* CONFIG_AUTO_AP_MODE */
-
 int rtw_recv_indicatepkt(struct adapter *padapter, union recv_frame *precv_frame)
 {
        struct recv_priv *precvpriv;
        struct __queue  *pfree_recv_queue;
-       _pkt *skb;
+       struct sk_buff *skb;
        struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
 
        precvpriv = &(padapter->recvpriv);
@@ -259,14 +218,6 @@ int rtw_recv_indicatepkt(struct adapter *padapter, union recv_frame *precv_frame
 
        RT_TRACE(_module_recv_osdep_c_, _drv_info_, ("\n skb->head =%p skb->data =%p skb->tail =%p skb->end =%p skb->len =%d\n", skb->head, skb->data, skb_tail_pointer(skb), skb_end_pointer(skb), skb->len));
 
-#ifdef CONFIG_AUTO_AP_MODE
-       if (0x8899 == pattrib->eth_type) {
-               rtw_os_ksocket_send(padapter, precv_frame);
-
-               /* goto _recv_indicatepkt_drop; */
-       }
-#endif /* CONFIG_AUTO_AP_MODE */
-
        rtw_os_recv_indicate_pkt(padapter, skb, pattrib);
 
        /* pointers to NULL before rtw_free_recvframe() */
index 301ffff12e82ba590e74e971d1a8796fb0239df7..156ad91d33eed02872b7d61a5689829e710aa55e 100644 (file)
@@ -117,55 +117,6 @@ static void sdio_free_irq(struct dvobj_priv *dvobj)
        }
 }
 
-#ifdef CONFIG_GPIO_WAKEUP
-extern unsigned int oob_irq;
-static irqreturn_t gpio_hostwakeup_irq_thread(int irq, void *data)
-{
-       struct adapter *padapter = data;
-       DBG_871X_LEVEL(_drv_always_, "gpio_hostwakeup_irq_thread\n");
-       /* Disable interrupt before calling handler */
-       /* disable_irq_nosync(oob_irq); */
-       rtw_lock_suspend_timeout(HZ/2);
-       return IRQ_HANDLED;
-}
-
-static u8 gpio_hostwakeup_alloc_irq(struct adapter *padapter)
-{
-       int err;
-
-       if (oob_irq == 0) {
-               DBG_871X("oob_irq ZERO!\n");
-               return _FAIL;
-       }
-       /* dont set it IRQF_TRIGGER_LOW, or wowlan */
-       /* power is high after suspend */
-       /* and failing can prevent can not sleep issue if */
-       /* wifi gpio12 pin is not linked with CPU */
-       err = request_threaded_irq(oob_irq, gpio_hostwakeup_irq_thread, NULL,
-               /* IRQF_TRIGGER_LOW | IRQF_ONESHOT, */
-               IRQF_TRIGGER_FALLING,
-               "rtw_wifi_gpio_wakeup", padapter);
-       if (err < 0) {
-               DBG_871X("Oops: can't allocate gpio irq %d err:%d\n", oob_irq, err);
-               return false;
-       } else {
-               DBG_871X("allocate gpio irq %d ok\n", oob_irq);
-       }
-
-       enable_irq_wake(oob_irq);
-       return _SUCCESS;
-}
-
-static void gpio_hostwakeup_free_irq(struct adapter *padapter)
-{
-       if (oob_irq == 0)
-               return;
-
-       disable_irq_wake(oob_irq);
-       free_irq(oob_irq, padapter);
-}
-#endif
-
 static u32 sdio_init(struct dvobj_priv *dvobj)
 {
        struct sdio_data *psdio_data;
@@ -424,17 +375,8 @@ static void rtw_sdio_if1_deinit(struct adapter *if1)
 
        free_mlme_ap_info(if1);
 
-#ifdef CONFIG_GPIO_WAKEUP
-       gpio_hostwakeup_free_irq(if1);
-#endif
-
        rtw_cancel_all_timer(if1);
 
-#ifdef CONFIG_WOWLAN
-       adapter_to_pwrctl(if1)->wowlan_mode = false;
-       DBG_871X_LEVEL(_drv_always_, "%s wowlan_mode:%d\n", __func__, adapter_to_pwrctl(if1)->wowlan_mode);
-#endif /* CONFIG_WOWLAN */
-
        rtw_dev_unload(if1);
        DBG_871X("+r871xu_dev_remove, hw_init_completed =%d\n", if1->hw_init_completed);
 
@@ -482,10 +424,6 @@ static int rtw_drv_init(
        if (sdio_alloc_irq(dvobj) != _SUCCESS)
                goto free_if2;
 
-#ifdef CONFIG_GPIO_WAKEUP
-       gpio_hostwakeup_alloc_irq(if1);
-#endif
-
        RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-871x_drv - drv_init, success!\n"));
 
        rtw_ndev_notifier_register();
@@ -544,9 +482,6 @@ static void rtw_dev_remove(struct sdio_func *func)
        RT_TRACE(_module_hci_intfs_c_, _drv_notice_, ("-rtw_dev_remove\n"));
 }
 
-extern int pm_netdev_open(struct net_device *pnetdev, u8 bnormal);
-extern int pm_netdev_close(struct net_device *pnetdev, u8 bnormal);
-
 static int rtw_sdio_suspend(struct device *dev)
 {
        struct sdio_func *func = dev_to_sdio_func(dev);
index 3f04b7a954ba07b3b151074adb94c6def5868d5d..0084589499b9fd67e39709538e76f5d919d20683 100644 (file)
@@ -61,7 +61,7 @@ static void _rtw_reg_apply_flags(struct wiphy *wiphy)
 {
        struct adapter *padapter = wiphy_to_adapter(wiphy);
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
-       RT_CHANNEL_INFO *channel_set = pmlmeext->channel_set;
+       struct rt_channel_info *channel_set = pmlmeext->channel_set;
        u8 max_chan_nums = pmlmeext->max_chan_nums;
 
        struct ieee80211_supported_band *sband;
@@ -150,7 +150,5 @@ void rtw_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request)
 {
        struct rtw_regulatory *reg = NULL;
 
-       DBG_8192C("%s\n", __func__);
-
        _rtw_reg_notifier_apply(wiphy, request, reg);
 }
index a89b88eaed39ffb1daa7fb0d8373e52ac177a6c7..a3b6584ca0d0294a56411f915b2f4747b0a4e878 100644 (file)
@@ -15,7 +15,7 @@ uint rtw_remainder_len(struct pkt_file *pfile)
        return (pfile->buf_len - ((SIZE_PTR)(pfile->cur_addr) - (SIZE_PTR)(pfile->buf_start)));
 }
 
-void _rtw_open_pktfile(_pkt *pktptr, struct pkt_file *pfile)
+void _rtw_open_pktfile(struct sk_buff *pktptr, struct pkt_file *pfile)
 {
        pfile->pkt = pktptr;
        pfile->cur_addr = pfile->buf_start = pktptr->data;
@@ -39,7 +39,7 @@ uint _rtw_pktfile_read(struct pkt_file *pfile, u8 *rmem, uint rlen)
        return len;
 }
 
-sint rtw_endofpktfile(struct pkt_file *pfile)
+signed int rtw_endofpktfile(struct pkt_file *pfile)
 {
        if (pfile->pkt_len == 0)
                return true;
@@ -67,7 +67,7 @@ void rtw_os_xmit_resource_free(struct adapter *padapter, struct xmit_buf *pxmitb
 
 #define WMM_XMIT_THRESHOLD     (NR_XMITFRAME * 2 / 5)
 
-void rtw_os_pkt_complete(struct adapter *padapter, _pkt *pkt)
+void rtw_os_pkt_complete(struct adapter *padapter, struct sk_buff *pkt)
 {
        u16 queue;
        struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
@@ -104,7 +104,7 @@ void rtw_os_xmit_schedule(struct adapter *padapter)
                complete(&pri_adapter->xmitpriv.xmit_comp);
 }
 
-static void rtw_check_xmit_resource(struct adapter *padapter, _pkt *pkt)
+static void rtw_check_xmit_resource(struct adapter *padapter, struct sk_buff *pkt)
 {
        struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
        u16 queue;
@@ -189,7 +189,7 @@ static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb)
        return true;
 }
 
-int _rtw_xmit_entry(_pkt *pkt, _nic_hdl pnetdev)
+int _rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev)
 {
        struct adapter *padapter = rtw_netdev_priv(pnetdev);
        struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
@@ -244,7 +244,7 @@ exit:
        return 0;
 }
 
-int rtw_xmit_entry(_pkt *pkt, _nic_hdl pnetdev)
+int rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev)
 {
        int ret = 0;
 
index 9097bcbd67d8226bc68315235af1de25e09cf5e4..06bca7be5203ff888e3578596600b5a3c00b34ac 100644 (file)
@@ -432,7 +432,7 @@ buffer_from_host(struct vchiq_mmal_instance *instance,
        m.u.buffer_from_host.buffer_header.pts = MMAL_TIME_UNKNOWN;
        m.u.buffer_from_host.buffer_header.dts = MMAL_TIME_UNKNOWN;
 
-       /* clear buffer type sepecific data */
+       /* clear buffer type specific data */
        memset(&m.u.buffer_from_host.buffer_header_type_specific, 0,
               sizeof(m.u.buffer_from_host.buffer_header_type_specific));
 
@@ -927,7 +927,7 @@ release_msg:
        return ret;
 }
 
-/* create comonent on vc */
+/* create component on vc */
 static int create_component(struct vchiq_mmal_instance *instance,
                            struct vchiq_mmal_component *component,
                            const char *name)
index 1aa675241599e8ee24f381c88b393802bed0528e..d89163299172c6a37bf0548f507be93248a976f7 100644 (file)
@@ -52,7 +52,7 @@
 /*---------------------  Static Variables  --------------------------*/
 
 #define CB_VT3253_INIT_FOR_RFMD 446
-static const unsigned char byVT3253InitTab_RFMD[CB_VT3253_INIT_FOR_RFMD][2] = {
+static const unsigned char by_vt3253_init_tab_rfmd[CB_VT3253_INIT_FOR_RFMD][2] = {
        {0x00, 0x30},
        {0x01, 0x00},
        {0x02, 0x00},
@@ -2002,8 +2002,8 @@ bool bb_vt3253_init(struct vnt_private *priv)
                if (by_local_id <= REV_ID_VT3253_A1) {
                        for (ii = 0; ii < CB_VT3253_INIT_FOR_RFMD; ii++)
                                result &= bb_write_embedded(priv,
-                                       byVT3253InitTab_RFMD[ii][0],
-                                       byVT3253InitTab_RFMD[ii][1]);
+                                       by_vt3253_init_tab_rfmd[ii][0],
+                                       by_vt3253_init_tab_rfmd[ii][1]);
 
                } else {
                        for (ii = 0; ii < CB_VT3253B0_INIT_FOR_RFMD; ii++)
index 889fc22f19bd15e38059322786498a0665062cd2..cf46ee63681a5701a5d817ff7ba096f5a60fe579 100644 (file)
@@ -114,40 +114,38 @@ static struct ieee80211_supported_band vnt_supported_5ghz_band = {
        .n_bitrates = ARRAY_SIZE(vnt_rates_a),
 };
 
-void vnt_init_bands(struct vnt_private *priv)
+static void vnt_init_band(struct vnt_private *priv,
+                         struct ieee80211_supported_band *supported_band,
+                         enum nl80211_band band)
 {
-       struct ieee80211_channel *ch;
        int i;
 
+       for (i = 0; i < supported_band->n_channels; i++) {
+               supported_band->channels[i].max_power = 0x3f;
+               supported_band->channels[i].flags =
+                       IEEE80211_CHAN_NO_HT40;
+       }
+
+       priv->hw->wiphy->bands[band] = supported_band;
+}
+
+void vnt_init_bands(struct vnt_private *priv)
+{
        switch (priv->byRFType) {
        case RF_AIROHA7230:
        case RF_UW2452:
        case RF_NOTHING:
        default:
-               ch = vnt_channels_5ghz;
-
-               for (i = 0; i < ARRAY_SIZE(vnt_channels_5ghz); i++) {
-                       ch[i].max_power = 0x3f;
-                       ch[i].flags = IEEE80211_CHAN_NO_HT40;
-               }
-
-               priv->hw->wiphy->bands[NL80211_BAND_5GHZ] =
-                                               &vnt_supported_5ghz_band;
+               vnt_init_band(priv, &vnt_supported_5ghz_band,
+                             NL80211_BAND_5GHZ);
                fallthrough;
        case RF_RFMD2959:
        case RF_AIROHA:
        case RF_AL2230S:
        case RF_UW2451:
        case RF_VT3226:
-               ch = vnt_channels_2ghz;
-
-               for (i = 0; i < ARRAY_SIZE(vnt_channels_2ghz); i++) {
-                       ch[i].max_power = 0x3f;
-                       ch[i].flags = IEEE80211_CHAN_NO_HT40;
-               }
-
-               priv->hw->wiphy->bands[NL80211_BAND_2GHZ] =
-                                               &vnt_supported_2ghz_band;
+               vnt_init_band(priv, &vnt_supported_2ghz_band,
+                             NL80211_BAND_2GHZ);
                break;
        }
 }
@@ -155,8 +153,8 @@ void vnt_init_bands(struct vnt_private *priv)
 /**
  * set_channel() - Set NIC media channel
  *
- * @pDeviceHandler: The adapter to be set
- * @uConnectionChannel: Channel to be set
+ * @priv: The adapter to be set
+ * @ch: Channel to be set
  *
  * Return Value: true if succeeded; false if failed.
  *
index e7061d3833062f25ff532f36486f8d0c80cc97a4..c3c2c156688282aa2bcaac8abde308fa38498c23 100644 (file)
@@ -150,7 +150,7 @@ struct vnt_cts {
        u16 reserved;
        struct ieee80211_cts data;
        u16 reserved2;
-} __packed;
+} __packed __aligned(2);
 
 struct vnt_cts_fb {
        struct vnt_phy_field b;
@@ -160,7 +160,7 @@ struct vnt_cts_fb {
        __le16 cts_duration_ba_f1;
        struct ieee80211_cts data;
        u16 reserved2;
-} __packed;
+} __packed __aligned(2);
 
 struct vnt_tx_fifo_head {
        u8 tx_key[WLAN_KEY_LEN_CCMP];
index cd6bcfdfbe9a6fb158007b9f596c5bca56444952..ed53d0b455927d7387add3f913c16a4761b48924 100644 (file)
@@ -5,6 +5,7 @@
  * Copyright (c) 2017-2020, Silicon Laboratories, Inc.
  * Copyright (c) 2010, ST-Ericsson
  */
+#include <linux/gpio/consumer.h>
 #include <net/mac80211.h>
 
 #include "bh.h"
index 92ef3298d4ac015bd62b034d36700f1f2f3ec2bc..78c49329e22a64359b1db1460f5cf59c71f27ddb 100644 (file)
@@ -8,6 +8,10 @@
 #ifndef WFX_BH_H
 #define WFX_BH_H
 
+#include <linux/atomic.h>
+#include <linux/wait.h>
+#include <linux/workqueue.h>
+
 struct wfx_dev;
 
 struct wfx_hif {
index ea39114853074cb1a8cdca98d31f368d2ef1c523..ca04b3da6204eec818d7c273e3a98a78d44ea80a 100644 (file)
@@ -8,6 +8,9 @@
 #ifndef WFX_BUS_H
 #define WFX_BUS_H
 
+#include <linux/mmc/sdio_func.h>
+#include <linux/spi/spi.h>
+
 #define WFX_REG_CONFIG        0x0
 #define WFX_REG_CONTROL       0x1
 #define WFX_REG_IN_OUT_QUEUE  0x2
index 588edce448546209b12b0b359826dc7678ce0fd1..e06d7e1ebe9c318dac085d03627c7cc9a410b1d8 100644 (file)
@@ -5,13 +5,19 @@
  * Copyright (c) 2017-2020, Silicon Laboratories, Inc.
  * Copyright (c) 2010, ST-Ericsson
  */
+#include <linux/module.h>
 #include <linux/mmc/sdio.h>
 #include <linux/mmc/sdio_func.h>
 #include <linux/mmc/card.h>
+#include <linux/interrupt.h>
 #include <linux/of_irq.h>
+#include <linux/irq.h>
 
 #include "bus.h"
 #include "wfx.h"
+#include "hwio.h"
+#include "main.h"
+#include "bh.h"
 
 static const struct wfx_platform_data wfx_sdio_pdata = {
        .file_fw = "wfm_wf200",
index f89855abe9f8de5cd4c3acd3de11cd9b3bd95c64..a99125d1a30d52a96cbb140d100037580c5cbd3d 100644 (file)
@@ -6,12 +6,19 @@
  * Copyright (c) 2011, Sagrad Inc.
  * Copyright (c) 2010, ST-Ericsson
  */
+#include <linux/module.h>
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
 #include <linux/spi/spi.h>
+#include <linux/interrupt.h>
 #include <linux/irq.h>
 #include <linux/of.h>
 
 #include "bus.h"
 #include "wfx.h"
+#include "hwio.h"
+#include "main.h"
+#include "bh.h"
 
 #define SET_WRITE 0x7FFF        /* usage: and operation */
 #define SET_READ 0x8000         /* usage: or operation */
index 2cfa162792208270f4b392a5aac91b1e5a8f91e6..385f2d42a0e2de437def92744b39025f803c7e15 100644 (file)
@@ -5,8 +5,13 @@
  * Copyright (c) 2017-2020, Silicon Laboratories, Inc.
  * Copyright (c) 2010, ST-Ericsson
  */
+#include <linux/etherdevice.h>
+#include <net/mac80211.h>
+
 #include "data_rx.h"
 #include "wfx.h"
+#include "bh.h"
+#include "sta.h"
 
 static void wfx_rx_handle_ba(struct wfx_vif *wvif, struct ieee80211_mgmt *mgmt)
 {
index 76f26e3c4381ca87438e6f1d26d99e25f45fad1d..77fb104efdec171b0bccb54b93cd6b84b3d70b9a 100644 (file)
@@ -6,9 +6,14 @@
  * Copyright (c) 2010, ST-Ericsson
  */
 #include <net/mac80211.h>
+#include <linux/etherdevice.h>
 
+#include "data_tx.h"
 #include "wfx.h"
+#include "bh.h"
 #include "sta.h"
+#include "queue.h"
+#include "debug.h"
 #include "traces.h"
 #include "hif_tx_mib.h"
 
index 6b3020097efaab40e324e35d5d983296f3b5477e..401363d6b563a954151ee941b14f94ab3f289510 100644 (file)
@@ -8,6 +8,9 @@
 #ifndef WFX_DATA_TX_H
 #define WFX_DATA_TX_H
 
+#include <linux/list.h>
+#include <net/mac80211.h>
+
 #include "hif_api_cmd.h"
 #include "hif_api_mib.h"
 
index 3e87d13eb358805b132589268b755487d5232cb1..eedada78c25f96f7c56b15304279a36619770ade 100644 (file)
@@ -5,9 +5,15 @@
  * Copyright (c) 2017-2020, Silicon Laboratories, Inc.
  * Copyright (c) 2010, ST-Ericsson
  */
+#include <linux/debugfs.h>
+#include <linux/seq_file.h>
+#include <linux/crc32.h>
+
 #include "debug.h"
 #include "wfx.h"
 #include "sta.h"
+#include "main.h"
+#include "hif_tx.h"
 #include "hif_tx_mib.h"
 
 #define CREATE_TRACE_POINTS
index 1bb9054871c41da8231cc84b315aa010cb6858d4..1b8aec02d169264462a3fb16e4009e4af44602e2 100644 (file)
@@ -6,6 +6,8 @@
  * Copyright (c) 2010, ST-Ericsson
  */
 #include <linux/firmware.h>
+#include <linux/slab.h>
+#include <linux/mm.h>
 #include <linux/bitfield.h>
 
 #include "fwio.h"
index 8b671c9ab97cb07caa7a593ebf61bb6636f77db1..58c9bb036011a22939a180cbc0f09e4243dd1af0 100644 (file)
@@ -8,6 +8,10 @@
 #ifndef WFX_HIF_API_CMD_H
 #define WFX_HIF_API_CMD_H
 
+#include <linux/ieee80211.h>
+
+#include "hif_api_general.h"
+
 enum hif_requests_ids {
        HIF_REQ_ID_RESET                = 0x0a,
        HIF_REQ_ID_READ_MIB             = 0x05,
index 70b253d0265d2faee24b480d1bf8b1de582d01d5..24188945718d6c8c027863ee4be001d3b9c615f2 100644 (file)
@@ -8,6 +8,15 @@
 #ifndef WFX_HIF_API_GENERAL_H
 #define WFX_HIF_API_GENERAL_H
 
+#ifdef __KERNEL__
+#include <linux/types.h>
+#include <linux/if_ether.h>
+#else
+#include <net/ethernet.h>
+#include <stdint.h>
+#define __packed __attribute__((__packed__))
+#endif
+
 #define HIF_ID_IS_INDICATION      0x80
 #define HIF_COUNTER_MAX           7
 
index 17dc1332197872353fce62a7bec4488ba5842b6f..63b437261eb727fcf6879d870e5c556a707e5fd1 100644 (file)
@@ -6,7 +6,11 @@
  * Copyright (c) 2017-2020, Silicon Laboratories, Inc.
  * Copyright (c) 2010, ST-Ericsson
  */
+#include <linux/etherdevice.h>
+
+#include "hif_tx.h"
 #include "wfx.h"
+#include "bh.h"
 #include "hwio.h"
 #include "debug.h"
 #include "sta.h"
index 6432ed86505c5bf5e0919799cbd8961c8d4db0c4..1926cf1b62be9205983d6173f173aa68afcf21d4 100644 (file)
@@ -6,8 +6,13 @@
  * Copyright (c) 2010, ST-Ericsson
  * Copyright (C) 2010, ST-Ericsson SA
  */
+
+#include <linux/etherdevice.h>
+
 #include "wfx.h"
+#include "hif_tx.h"
 #include "hif_tx_mib.h"
+#include "hif_api_mib.h"
 
 int hif_set_output_power(struct wfx_vif *wvif, int val)
 {
index 089bb41be14908866c39e4fe9b1b821aeef46b33..36fbc5b5d64cefe2894a3e4802f10528685c89a6 100644 (file)
@@ -5,10 +5,13 @@
  * Copyright (c) 2017-2020, Silicon Laboratories, Inc.
  * Copyright (c) 2010, ST-Ericsson
  */
+#include <linux/kernel.h>
+#include <linux/delay.h>
 #include <linux/slab.h>
 
 #include "hwio.h"
 #include "wfx.h"
+#include "bus.h"
 #include "traces.h"
 
 /*
index 8bb9bcfc318204cc24822796d991237af478d77b..0b8e4f7157dfcf19ece8bbfb9eedaab71aaa0b07 100644 (file)
@@ -8,6 +8,8 @@
 #ifndef WFX_HWIO_H
 #define WFX_HWIO_H
 
+#include <linux/types.h>
+
 struct wfx_dev;
 
 int wfx_data_read(struct wfx_dev *wdev, void *buf, size_t buf_len);
index c93d07dcdc10c6f0424ccc0480657fad5c4b4826..2ab82bed4c1bcd8d29a3ecdb381ca8d03d758684 100644 (file)
@@ -5,10 +5,12 @@
  * Copyright (c) 2017-2020, Silicon Laboratories, Inc.
  * Copyright (c) 2010, ST-Ericsson
  */
+#include <linux/etherdevice.h>
 #include <net/mac80211.h>
 
 #include "key.h"
 #include "wfx.h"
+#include "hif_tx_mib.h"
 
 static int wfx_alloc_key(struct wfx_dev *wdev)
 {
index 4dc9feadaba2cbcbdb53bcf970d4cc38084e1a0d..70a44d0ca35e8bc0b0bb7c4ab56474e63e188fb4 100644 (file)
@@ -8,6 +8,8 @@
 #ifndef WFX_KEY_H
 #define WFX_KEY_H
 
+#include <net/mac80211.h>
+
 struct wfx_dev;
 struct wfx_vif;
 
index b9ea9a93fe1aad59d0f78a9c9f1430a4b4eae4ca..e7bc1988124a828cb8049a03e538069275a83efb 100644 (file)
  * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net>
  * Copyright (c) 2004-2006 Jean-Baptiste Note <jbnote@gmail.com>, et al.
  */
+#include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_net.h>
+#include <linux/gpio/consumer.h>
 #include <linux/mmc/sdio_func.h>
 #include <linux/spi/spi.h>
+#include <linux/etherdevice.h>
 #include <linux/firmware.h>
 
+#include "main.h"
 #include "wfx.h"
 #include "fwio.h"
 #include "hwio.h"
 #include "bus.h"
+#include "bh.h"
 #include "sta.h"
 #include "key.h"
 #include "scan.h"
 #include "debug.h"
+#include "data_tx.h"
 #include "hif_tx_mib.h"
+#include "hif_api_cmd.h"
 
 #define WFX_PDS_MAX_SIZE 1500
 
index 086bcc041b906d743e0455a5b91868bbb54399bc..a0db322383a3ac54cbc35fe3c16cb18776a7c88b 100644 (file)
 #ifndef WFX_MAIN_H
 #define WFX_MAIN_H
 
+#include <linux/device.h>
 #include <linux/gpio/consumer.h>
 
+#include "hif_api_general.h"
+
 struct wfx_dev;
 struct hwbus_ops;
 
index 3bddf282a4cec1d499856b21222e871f9bd15f71..31c37f69c295a94b4fcc75eae3ad0c5e0bd1df99 100644 (file)
@@ -5,9 +5,13 @@
  * Copyright (c) 2017-2020, Silicon Laboratories, Inc.
  * Copyright (c) 2010, ST-Ericsson
  */
+#include <linux/sched.h>
 #include <net/mac80211.h>
 
+#include "queue.h"
 #include "wfx.h"
+#include "sta.h"
+#include "data_tx.h"
 #include "traces.h"
 
 void wfx_tx_lock(struct wfx_dev *wdev)
index e43aa9dfbc4522f743749a9f02b6ebaf92cd02d2..80ba19455ef35781e4e0de99d32f0775f076edc9 100644 (file)
@@ -8,6 +8,9 @@
 #ifndef WFX_QUEUE_H
 #define WFX_QUEUE_H
 
+#include <linux/skbuff.h>
+#include <linux/atomic.h>
+
 struct wfx_dev;
 struct wfx_vif;
 
index e5b7eef78858602ba4efc07719be54c8f8edf909..c7496a7664785709f3cf4d76f4aa0f6820250bc6 100644 (file)
@@ -8,6 +8,8 @@
 #ifndef WFX_SCAN_H
 #define WFX_SCAN_H
 
+#include <net/mac80211.h>
+
 struct wfx_dev;
 struct wfx_vif;
 
index 8c57338efc719650c5cf61a5cb556d61d4dca497..cb7e8abdf43cea1137ec5b0ae46204709c05abfa 100644 (file)
@@ -5,11 +5,17 @@
  * Copyright (c) 2017-2020, Silicon Laboratories, Inc.
  * Copyright (c) 2010, ST-Ericsson
  */
+#include <linux/etherdevice.h>
 #include <net/mac80211.h>
 
 #include "sta.h"
 #include "wfx.h"
+#include "fwio.h"
+#include "bh.h"
+#include "key.h"
 #include "scan.h"
+#include "debug.h"
+#include "hif_tx.h"
 #include "hif_tx_mib.h"
 
 #define HIF_MAX_ARP_IP_ADDRTABLE_ENTRIES 2
index a3fb9fc93fa44025aad0831cbce7bd205062d987..d7b5df5ea4e6f10c55a92fb648a6cc81dfda9c0a 100644 (file)
@@ -8,6 +8,8 @@
 #ifndef WFX_STA_H
 #define WFX_STA_H
 
+#include <net/mac80211.h>
+
 struct wfx_dev;
 struct wfx_vif;
 
index afe1074e09b330437047875b64288f9e2c20ccef..e34c7a538c65ac7886b8ef4793a618f956e8c74c 100644 (file)
 #define _WFX_TRACE_H
 
 #include <linux/tracepoint.h>
+#include <net/mac80211.h>
 
 #include "bus.h"
+#include "hif_api_cmd.h"
+#include "hif_api_mib.h"
 
 /* The hell below need some explanations. For each symbolic number, we need to
  * define it with TRACE_DEFINE_ENUM() and in a list for __print_symbolic.
index a185b82795c4aae7cb782b6d6ce56fe633a898ce..94898680ccdee076dd2f84dc5808259c997b571f 100644 (file)
@@ -10,6 +10,9 @@
 #ifndef WFX_H
 #define WFX_H
 
+#include <linux/completion.h>
+#include <linux/workqueue.h>
+#include <linux/mutex.h>
 #include <linux/nospec.h>
 #include <net/mac80211.h>
 
diff --git a/drivers/staging/wimax/Documentation/i2400m.rst b/drivers/staging/wimax/Documentation/i2400m.rst
deleted file mode 100644 (file)
index 194388c..0000000
+++ /dev/null
@@ -1,283 +0,0 @@
-.. include:: <isonum.txt>
-
-====================================================
-Driver for the Intel Wireless Wimax Connection 2400m
-====================================================
-
-:Copyright: |copy| 2008 Intel Corporation < linux-wimax@intel.com >
-
-   This provides a driver for the Intel Wireless WiMAX Connection 2400m
-   and a basic Linux kernel WiMAX stack.
-
-1. Requirements
-===============
-
-     * Linux installation with Linux kernel 2.6.22 or newer (if building
-       from a separate tree)
-     * Intel i2400m Echo Peak or Baxter Peak; this includes the Intel
-       Wireless WiMAX/WiFi Link 5x50 series.
-     * build tools:
-
-          + Linux kernel development package for the target kernel; to
-            build against your currently running kernel, you need to have
-            the kernel development package corresponding to the running
-            image installed (usually if your kernel is named
-            linux-VERSION, the development package is called
-            linux-dev-VERSION or linux-headers-VERSION).
-          + GNU C Compiler, make
-
-2. Compilation and installation
-===============================
-
-2.1. Compilation of the drivers included in the kernel
-------------------------------------------------------
-
-   Configure the kernel; to enable the WiMAX drivers select Drivers >
-   Networking Drivers > WiMAX device support. Enable all of them as
-   modules (easier).
-
-   If USB or SDIO are not enabled in the kernel configuration, the options
-   to build the i2400m USB or SDIO drivers will not show. Enable said
-   subsystems and go back to the WiMAX menu to enable the drivers.
-
-   Compile and install your kernel as usual.
-
-2.2. Compilation of the drivers distributed as an standalone module
--------------------------------------------------------------------
-
-   To compile::
-
-       $ cd source/directory
-       $ make
-
-   Once built you can load and unload using the provided load.sh script;
-   load.sh will load the modules, load.sh u will unload them.
-
-   To install in the default kernel directories (and enable auto loading
-   when the device is plugged)::
-
-       $ make install
-       $ depmod -a
-
-   If your kernel development files are located in a non standard
-   directory or if you want to build for a kernel that is not the
-   currently running one, set KDIR to the right location::
-
-       $ make KDIR=/path/to/kernel/dev/tree
-
-   For more information, please contact linux-wimax@intel.com.
-
-3. Installing the firmware
---------------------------
-
-   The firmware can be obtained from http://linuxwimax.org or might have
-   been supplied with your hardware.
-
-   It has to be installed in the target system::
-
-       $ cp FIRMWAREFILE.sbcf /lib/firmware/i2400m-fw-BUSTYPE-1.3.sbcf
-
-     * NOTE: if your firmware came in an .rpm or .deb file, just install
-       it as normal, with the rpm (rpm -i FIRMWARE.rpm) or dpkg
-       (dpkg -i FIRMWARE.deb) commands. No further action is needed.
-     * BUSTYPE will be usb or sdio, depending on the hardware you have.
-       Each hardware type comes with its own firmware and will not work
-       with other types.
-
-4. Design
-=========
-
-   This package contains two major parts: a WiMAX kernel stack and a
-   driver for the Intel i2400m.
-
-   The WiMAX stack is designed to provide for common WiMAX control
-   services to current and future WiMAX devices from any vendor; please
-   see README.wimax for details.
-
-   The i2400m kernel driver is broken up in two main parts: the bus
-   generic driver and the bus-specific drivers. The bus generic driver
-   forms the drivercore and contain no knowledge of the actual method we
-   use to connect to the device. The bus specific drivers are just the
-   glue to connect the bus-generic driver and the device. Currently only
-   USB and SDIO are supported. See drivers/net/wimax/i2400m/i2400m.h for
-   more information.
-
-   The bus generic driver is logically broken up in two parts: OS-glue and
-   hardware-glue. The OS-glue interfaces with Linux. The hardware-glue
-   interfaces with the device on using an interface provided by the
-   bus-specific driver. The reason for this breakup is to be able to
-   easily reuse the hardware-glue to write drivers for other OSes; note
-   the hardware glue part is written as a native Linux driver; no
-   abstraction layers are used, so to port to another OS, the Linux kernel
-   API calls should be replaced with the target OS's.
-
-5. Usage
-========
-
-   To load the driver, follow the instructions in the install section;
-   once the driver is loaded, plug in the device (unless it is permanently
-   plugged in). The driver will enumerate the device, upload the firmware
-   and output messages in the kernel log (dmesg, /var/log/messages or
-   /var/log/kern.log) such as::
-
-       ...
-       i2400m_usb 5-4:1.0: firmware interface version 8.0.0
-       i2400m_usb 5-4:1.0: WiMAX interface wmx0 (00:1d:e1:01:94:2c) ready
-
-   At this point the device is ready to work.
-
-   Current versions require the Intel WiMAX Network Service in userspace
-   to make things work. See the network service's README for instructions
-   on how to scan, connect and disconnect.
-
-5.1. Module parameters
-----------------------
-
-   Module parameters can be set at kernel or module load time or by
-   echoing values::
-
-       $ echo VALUE > /sys/module/MODULENAME/parameters/PARAMETERNAME
-
-   To make changes permanent, for example, for the i2400m module, you can
-   also create a file named /etc/modprobe.d/i2400m containing::
-
-       options i2400m idle_mode_disabled=1
-
-   To find which parameters are supported by a module, run::
-
-       $ modinfo path/to/module.ko
-
-   During kernel bootup (if the driver is linked in the kernel), specify
-   the following to the kernel command line::
-
-       i2400m.PARAMETER=VALUE
-
-5.1.1. i2400m: idle_mode_disabled
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-   The i2400m module supports a parameter to disable idle mode. This
-   parameter, once set, will take effect only when the device is
-   reinitialized by the driver (eg: following a reset or a reconnect).
-
-5.2. Debug operations: debugfs entries
---------------------------------------
-
-   The driver will register debugfs entries that allow the user to tweak
-   debug settings. There are three main container directories where
-   entries are placed, which correspond to the three blocks a i2400m WiMAX
-   driver has:
-
-     * /sys/kernel/debug/wimax:DEVNAME/ for the generic WiMAX stack
-       controls
-     * /sys/kernel/debug/wimax:DEVNAME/i2400m for the i2400m generic
-       driver controls
-     * /sys/kernel/debug/wimax:DEVNAME/i2400m-usb (or -sdio) for the
-       bus-specific i2400m-usb or i2400m-sdio controls).
-
-   Of course, if debugfs is mounted in a directory other than
-   /sys/kernel/debug, those paths will change.
-
-5.2.1. Increasing debug output
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-   The files named *dl_* indicate knobs for controlling the debug output
-   of different submodules::
-
-       # find /sys/kernel/debug/wimax\:wmx0 -name \*dl_\*
-       /sys/kernel/debug/wimax:wmx0/i2400m-usb/dl_tx
-       /sys/kernel/debug/wimax:wmx0/i2400m-usb/dl_rx
-       /sys/kernel/debug/wimax:wmx0/i2400m-usb/dl_notif
-       /sys/kernel/debug/wimax:wmx0/i2400m-usb/dl_fw
-       /sys/kernel/debug/wimax:wmx0/i2400m-usb/dl_usb
-       /sys/kernel/debug/wimax:wmx0/i2400m/dl_tx
-       /sys/kernel/debug/wimax:wmx0/i2400m/dl_rx
-       /sys/kernel/debug/wimax:wmx0/i2400m/dl_rfkill
-       /sys/kernel/debug/wimax:wmx0/i2400m/dl_netdev
-       /sys/kernel/debug/wimax:wmx0/i2400m/dl_fw
-       /sys/kernel/debug/wimax:wmx0/i2400m/dl_debugfs
-       /sys/kernel/debug/wimax:wmx0/i2400m/dl_driver
-       /sys/kernel/debug/wimax:wmx0/i2400m/dl_control
-       /sys/kernel/debug/wimax:wmx0/wimax_dl_stack
-       /sys/kernel/debug/wimax:wmx0/wimax_dl_op_rfkill
-       /sys/kernel/debug/wimax:wmx0/wimax_dl_op_reset
-       /sys/kernel/debug/wimax:wmx0/wimax_dl_op_msg
-       /sys/kernel/debug/wimax:wmx0/wimax_dl_id_table
-       /sys/kernel/debug/wimax:wmx0/wimax_dl_debugfs
-
-   By reading the file you can obtain the current value of said debug
-   level; by writing to it, you can set it.
-
-   To increase the debug level of, for example, the i2400m's generic TX
-   engine, just write::
-
-       $ echo 3 > /sys/kernel/debug/wimax:wmx0/i2400m/dl_tx
-
-   Increasing numbers yield increasing debug information; for details of
-   what is printed and the available levels, check the source. The code
-   uses 0 for disabled and increasing values until 8.
-
-5.2.2. RX and TX statistics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-   The i2400m/rx_stats and i2400m/tx_stats provide statistics about the
-   data reception/delivery from the device::
-
-       $ cat /sys/kernel/debug/wimax:wmx0/i2400m/rx_stats
-       45 1 3 34 3104 48 480
-
-   The numbers reported are:
-
-     * packets/RX-buffer: total, min, max
-     * RX-buffers: total RX buffers received, accumulated RX buffer size
-       in bytes, min size received, max size received
-
-   Thus, to find the average buffer size received, divide accumulated
-   RX-buffer / total RX-buffers.
-
-   To clear the statistics back to 0, write anything to the rx_stats file::
-
-       $ echo 1 > /sys/kernel/debug/wimax:wmx0/i2400m_rx_stats
-
-   Likewise for TX.
-
-   Note the packets this debug file refers to are not network packet, but
-   packets in the sense of the device-specific protocol for communication
-   to the host. See drivers/net/wimax/i2400m/tx.c.
-
-5.2.3. Tracing messages received from user space
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-   To echo messages received from user space into the trace pipe that the
-   i2400m driver creates, set the debug file i2400m/trace_msg_from_user to
-   1::
-
-       $ echo 1 > /sys/kernel/debug/wimax:wmx0/i2400m/trace_msg_from_user
-
-5.2.4. Performing a device reset
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-   By writing a 0, a 1 or a 2 to the file
-   /sys/kernel/debug/wimax:wmx0/reset, the driver performs a warm (without
-   disconnecting from the bus), cold (disconnecting from the bus) or bus
-   (bus specific) reset on the device.
-
-5.2.5. Asking the device to enter power saving mode
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-   By writing any value to the /sys/kernel/debug/wimax:wmx0 file, the
-   device will attempt to enter power saving mode.
-
-6. Troubleshooting
-==================
-
-6.1. Driver complains about ``i2400m-fw-usb-1.2.sbcf: request failed``
-----------------------------------------------------------------------
-
-   If upon connecting the device, the following is output in the kernel
-   log::
-
-       i2400m_usb 5-4:1.0: fw i2400m-fw-usb-1.3.sbcf: request failed: -2
-
-   This means that the driver cannot locate the firmware file named
-   /lib/firmware/i2400m-fw-usb-1.2.sbcf. Check that the file is present in
-   the right location.
diff --git a/drivers/staging/wimax/Documentation/index.rst b/drivers/staging/wimax/Documentation/index.rst
deleted file mode 100644 (file)
index fdf7c1f..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-.. SPDX-License-Identifier: GPL-2.0
-
-===============
-WiMAX subsystem
-===============
-
-.. toctree::
-   :maxdepth: 2
-
-   wimax
-
-   i2400m
-
-.. only::  subproject and html
-
-   Indices
-   =======
-
-   * :ref:`genindex`
diff --git a/drivers/staging/wimax/Documentation/wimax.rst b/drivers/staging/wimax/Documentation/wimax.rst
deleted file mode 100644 (file)
index 817ee8b..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-.. include:: <isonum.txt>
-
-========================
-Linux kernel WiMAX stack
-========================
-
-:Copyright: |copy| 2008 Intel Corporation < linux-wimax@intel.com >
-
-   This provides a basic Linux kernel WiMAX stack to provide a common
-   control API for WiMAX devices, usable from kernel and user space.
-
-1. Design
-=========
-
-   The WiMAX stack is designed to provide for common WiMAX control
-   services to current and future WiMAX devices from any vendor.
-
-   Because currently there is only one and we don't know what would be the
-   common services, the APIs it currently provides are very minimal.
-   However, it is done in such a way that it is easily extensible to
-   accommodate future requirements.
-
-   The stack works by embedding a struct wimax_dev in your device's
-   control structures. This provides a set of callbacks that the WiMAX
-   stack will call in order to implement control operations requested by
-   the user. As well, the stack provides API functions that the driver
-   calls to notify about changes of state in the device.
-
-   The stack exports the API calls needed to control the device to user
-   space using generic netlink as a marshalling mechanism. You can access
-   them using your own code or use the wrappers provided for your
-   convenience in libwimax (in the wimax-tools package).
-
-   For detailed information on the stack, please see
-   include/linux/wimax.h.
-
-2. Usage
-========
-
-   For usage in a driver (registration, API, etc) please refer to the
-   instructions in the header file include/linux/wimax.h.
-
-   When a device is registered with the WiMAX stack, a set of debugfs
-   files will appear in /sys/kernel/debug/wimax:wmxX can tweak for
-   control.
-
-2.1. Obtaining debug information: debugfs entries
--------------------------------------------------
-
-   The WiMAX stack is compiled, by default, with debug messages that can
-   be used to diagnose issues. By default, said messages are disabled.
-
-   The drivers will register debugfs entries that allow the user to tweak
-   debug settings.
-
-   Each driver, when registering with the stack, will cause a debugfs
-   directory named wimax:DEVICENAME to be created; optionally, it might
-   create more subentries below it.
-
-2.1.1. Increasing debug output
-------------------------------
-
-   The files named *dl_* indicate knobs for controlling the debug output
-   of different submodules of the WiMAX stack::
-
-       # find /sys/kernel/debug/wimax\:wmx0 -name \*dl_\*
-       /sys/kernel/debug/wimax:wmx0/wimax_dl_stack
-       /sys/kernel/debug/wimax:wmx0/wimax_dl_op_rfkill
-       /sys/kernel/debug/wimax:wmx0/wimax_dl_op_reset
-       /sys/kernel/debug/wimax:wmx0/wimax_dl_op_msg
-       /sys/kernel/debug/wimax:wmx0/wimax_dl_id_table
-       /sys/kernel/debug/wimax:wmx0/wimax_dl_debugfs
-       /sys/kernel/debug/wimax:wmx0/.... # other driver specific files
-
-   NOTE:
-       Of course, if debugfs is mounted in a directory other than
-       /sys/kernel/debug, those paths will change.
-
-   By reading the file you can obtain the current value of said debug
-   level; by writing to it, you can set it.
-
-   To increase the debug level of, for example, the id-table submodule,
-   just write:
-
-       $ echo 3 > /sys/kernel/debug/wimax:wmx0/wimax_dl_id_table
-
-   Increasing numbers yield increasing debug information; for details of
-   what is printed and the available levels, check the source. The code
-   uses 0 for disabled and increasing values until 8.
diff --git a/drivers/staging/wimax/Kconfig b/drivers/staging/wimax/Kconfig
deleted file mode 100644 (file)
index 113c350..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-#
-# WiMAX LAN device configuration
-#
-
-menuconfig WIMAX
-       tristate "WiMAX Wireless Broadband support"
-       depends on NET
-       depends on RFKILL || !RFKILL
-       help
-
-         Select to configure support for devices that provide
-         wireless broadband connectivity using the WiMAX protocol
-         (IEEE 802.16).
-
-         Please note that most of these devices require signing up
-         for a service plan with a provider.
-
-         The different WiMAX drivers can be enabled in the menu entry
-
-         Device Drivers > Network device support > WiMAX Wireless
-         Broadband devices
-
-         If unsure, it is safe to select M (module).
-
-if WIMAX
-
-config WIMAX_DEBUG_LEVEL
-       int "WiMAX debug level"
-       depends on WIMAX
-       default 8
-       help
-
-         Select the maximum debug verbosity level to be compiled into
-         the WiMAX stack code.
-
-         By default, debug messages are disabled at runtime and can
-         be selectively enabled for different parts of the code using
-         the sysfs debug-levels file.
-
-         If set at zero, this will compile out all the debug code.
-
-         It is recommended that it is left at 8.
-
-source "drivers/staging/wimax/i2400m/Kconfig"
-
-endif
diff --git a/drivers/staging/wimax/Makefile b/drivers/staging/wimax/Makefile
deleted file mode 100644 (file)
index 0e3f988..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-
-obj-$(CONFIG_WIMAX)            += wimax.o
-
-wimax-y :=             \
-       id-table.o      \
-       op-msg.o        \
-       op-reset.o      \
-       op-rfkill.o     \
-       op-state-get.o  \
-       stack.o
-
-wimax-$(CONFIG_DEBUG_FS) += debugfs.o
-
-obj-$(CONFIG_WIMAX_I2400M)     += i2400m/
diff --git a/drivers/staging/wimax/TODO b/drivers/staging/wimax/TODO
deleted file mode 100644 (file)
index 26e4cb9..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-There are no known users of this driver as of October 2020, and it will
-be removed unless someone turns out to still need it in future releases.
-
-According to https://en.wikipedia.org/wiki/List_of_WiMAX_networks, there
-have been many public wimax networks, but it appears that many of these
-have migrated to LTE or discontinued their service altogether.  As most
-PCs and phones lack WiMAX hardware support, the remaining networks tend
-to use standalone routers. These almost certainly run Linux, but not a
-modern kernel or the mainline wimax driver stack.
-
-NetworkManager appears to have dropped userspace support in 2015
-https://bugzilla.gnome.org/show_bug.cgi?id=747846, the www.linuxwimax.org
-site had already shut down earlier.
-
-WiMax is apparently still being deployed on airport campus networks
-("AeroMACS"), but in a frequency band that was not supported by the old
-Intel 2400m (used in Sandy Bridge laptops and earlier), which is the
-only driver using the kernel's wimax stack.
diff --git a/drivers/staging/wimax/debug-levels.h b/drivers/staging/wimax/debug-levels.h
deleted file mode 100644 (file)
index b854802..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Linux WiMAX Stack
- * Debug levels control file for the wimax module
- *
- * Copyright (C) 2007-2008 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- */
-#ifndef __debug_levels__h__
-#define __debug_levels__h__
-
-/* Maximum compile and run time debug level for all submodules */
-#define D_MODULENAME wimax
-#define D_MASTER CONFIG_WIMAX_DEBUG_LEVEL
-
-#include "linux-wimax-debug.h"
-
-/* List of all the enabled modules */
-enum d_module {
-       D_SUBMODULE_DECLARE(debugfs),
-       D_SUBMODULE_DECLARE(id_table),
-       D_SUBMODULE_DECLARE(op_msg),
-       D_SUBMODULE_DECLARE(op_reset),
-       D_SUBMODULE_DECLARE(op_rfkill),
-       D_SUBMODULE_DECLARE(op_state_get),
-       D_SUBMODULE_DECLARE(stack),
-};
-
-#endif /* #ifndef __debug_levels__h__ */
diff --git a/drivers/staging/wimax/debugfs.c b/drivers/staging/wimax/debugfs.c
deleted file mode 100644 (file)
index e11bff6..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Linux WiMAX
- * Debugfs support
- *
- * Copyright (C) 2005-2006 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- */
-#include <linux/debugfs.h>
-#include "linux-wimax.h"
-#include "wimax-internal.h"
-
-#define D_SUBMODULE debugfs
-#include "debug-levels.h"
-
-void wimax_debugfs_add(struct wimax_dev *wimax_dev)
-{
-       struct net_device *net_dev = wimax_dev->net_dev;
-       struct dentry *dentry;
-       char buf[128];
-
-       snprintf(buf, sizeof(buf), "wimax:%s", net_dev->name);
-       dentry = debugfs_create_dir(buf, NULL);
-       wimax_dev->debugfs_dentry = dentry;
-
-       d_level_register_debugfs("wimax_dl_", debugfs, dentry);
-       d_level_register_debugfs("wimax_dl_", id_table, dentry);
-       d_level_register_debugfs("wimax_dl_", op_msg, dentry);
-       d_level_register_debugfs("wimax_dl_", op_reset, dentry);
-       d_level_register_debugfs("wimax_dl_", op_rfkill, dentry);
-       d_level_register_debugfs("wimax_dl_", op_state_get, dentry);
-       d_level_register_debugfs("wimax_dl_", stack, dentry);
-}
-
-void wimax_debugfs_rm(struct wimax_dev *wimax_dev)
-{
-       debugfs_remove_recursive(wimax_dev->debugfs_dentry);
-}
diff --git a/drivers/staging/wimax/i2400m/Kconfig b/drivers/staging/wimax/i2400m/Kconfig
deleted file mode 100644 (file)
index 843b905..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-
-config WIMAX_I2400M
-       tristate
-       depends on WIMAX
-       select FW_LOADER
-
-comment "Enable USB support to see WiMAX USB drivers"
-       depends on USB = n
-
-config WIMAX_I2400M_USB
-       tristate "Intel Wireless WiMAX Connection 2400 over USB (including 5x50)"
-       depends on WIMAX && USB
-       select WIMAX_I2400M
-       help
-         Select if you have a device based on the Intel WiMAX
-         Connection 2400 over USB (like any of the Intel Wireless
-         WiMAX/WiFi Link 5x50 series).
-
-         If unsure, it is safe to select M (module).
-
-config WIMAX_I2400M_DEBUG_LEVEL
-       int "WiMAX i2400m debug level"
-       depends on WIMAX_I2400M
-       default 8
-       help
-
-         Select the maximum debug verbosity level to be compiled into
-         the WiMAX i2400m driver code.
-
-         By default, this is disabled at runtime and can be
-         selectively enabled at runtime for different parts of the
-         code using the sysfs debug-levels file.
-
-         If set at zero, this will compile out all the debug code.
-
-         It is recommended that it is left at 8.
diff --git a/drivers/staging/wimax/i2400m/Makefile b/drivers/staging/wimax/i2400m/Makefile
deleted file mode 100644 (file)
index b1db1ef..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-
-obj-$(CONFIG_WIMAX_I2400M) += i2400m.o
-obj-$(CONFIG_WIMAX_I2400M_USB) += i2400m-usb.o
-
-i2400m-y :=            \
-       control.o       \
-       driver.o        \
-       fw.o            \
-       op-rfkill.o     \
-       sysfs.o         \
-       netdev.o        \
-       tx.o            \
-       rx.o
-
-i2400m-$(CONFIG_DEBUG_FS) += debugfs.o
-
-i2400m-usb-y :=                        \
-       usb-fw.o                \
-       usb-notif.o             \
-       usb-tx.o                \
-       usb-rx.o                \
-       usb.o
diff --git a/drivers/staging/wimax/i2400m/control.c b/drivers/staging/wimax/i2400m/control.c
deleted file mode 100644 (file)
index b6b2788..0000000
+++ /dev/null
@@ -1,1434 +0,0 @@
-/*
- * Intel Wireless WiMAX Connection 2400m
- * Miscellaneous control functions for managing the device
- *
- *
- * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   * Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in
- *     the documentation and/or other materials provided with the
- *     distribution.
- *   * Neither the name of Intel Corporation nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *
- * Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *  - Initial implementation
- *
- * This is a collection of functions used to control the device (plus
- * a few helpers).
- *
- * There are utilities for handling TLV buffers, hooks on the device's
- * reports to act on device changes of state [i2400m_report_hook()],
- * on acks to commands [i2400m_msg_ack_hook()], a helper for sending
- * commands to the device and blocking until a reply arrives
- * [i2400m_msg_to_dev()], a few high level commands for manipulating
- * the device state, powersving mode and configuration plus the
- * routines to setup the device once communication is stablished with
- * it [i2400m_dev_initialize()].
- *
- * ROADMAP
- *
- * i2400m_dev_initialize()       Called by i2400m_dev_start()
- *   i2400m_set_init_config()
- *   i2400m_cmd_get_state()
- * i2400m_dev_shutdown()        Called by i2400m_dev_stop()
- *   i2400m_reset()
- *
- * i2400m_{cmd,get,set}_*()
- *   i2400m_msg_to_dev()
- *   i2400m_msg_check_status()
- *
- * i2400m_report_hook()         Called on reception of an event
- *   i2400m_report_state_hook()
- *     i2400m_tlv_buffer_walk()
- *     i2400m_tlv_match()
- *     i2400m_report_tlv_system_state()
- *     i2400m_report_tlv_rf_switches_status()
- *     i2400m_report_tlv_media_status()
- *   i2400m_cmd_enter_powersave()
- *
- * i2400m_msg_ack_hook()        Called on reception of a reply to a
- *                              command, get or set
- */
-
-#include <stdarg.h>
-#include "i2400m.h"
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include "linux-wimax-i2400m.h"
-#include <linux/export.h>
-#include <linux/moduleparam.h>
-
-
-#define D_SUBMODULE control
-#include "debug-levels.h"
-
-static int i2400m_idle_mode_disabled;/* 0 (idle mode enabled) by default */
-module_param_named(idle_mode_disabled, i2400m_idle_mode_disabled, int, 0644);
-MODULE_PARM_DESC(idle_mode_disabled,
-                "If true, the device will not enable idle mode negotiation "
-                "with the base station (when connected) to save power.");
-
-/* 0 (power saving enabled) by default */
-static int i2400m_power_save_disabled;
-module_param_named(power_save_disabled, i2400m_power_save_disabled, int, 0644);
-MODULE_PARM_DESC(power_save_disabled,
-                "If true, the driver will not tell the device to enter "
-                "power saving mode when it reports it is ready for it. "
-                "False by default (so the device is told to do power "
-                "saving).");
-
-static int i2400m_passive_mode;        /* 0 (passive mode disabled) by default */
-module_param_named(passive_mode, i2400m_passive_mode, int, 0644);
-MODULE_PARM_DESC(passive_mode,
-                "If true, the driver will not do any device setup "
-                "and leave it up to user space, who must be properly "
-                "setup.");
-
-
-/*
- * Return if a TLV is of a give type and size
- *
- * @tlv_hdr: pointer to the TLV
- * @tlv_type: type of the TLV we are looking for
- * @tlv_size: expected size of the TLV we are looking for (if -1,
- *            don't check the size). This includes the header
- * Returns: 0 if the TLV matches
- *          < 0 if it doesn't match at all
- *          > 0 total TLV + payload size, if the type matches, but not
- *              the size
- */
-static
-ssize_t i2400m_tlv_match(const struct i2400m_tlv_hdr *tlv,
-                    enum i2400m_tlv tlv_type, ssize_t tlv_size)
-{
-       if (le16_to_cpu(tlv->type) != tlv_type) /* Not our type? skip */
-               return -1;
-       if (tlv_size != -1
-           && le16_to_cpu(tlv->length) + sizeof(*tlv) != tlv_size) {
-               size_t size = le16_to_cpu(tlv->length) + sizeof(*tlv);
-               printk(KERN_WARNING "W: tlv type 0x%x mismatched because of "
-                      "size (got %zu vs %zd expected)\n",
-                      tlv_type, size, tlv_size);
-               return size;
-       }
-       return 0;
-}
-
-
-/*
- * Given a buffer of TLVs, iterate over them
- *
- * @i2400m: device instance
- * @tlv_buf: pointer to the beginning of the TLV buffer
- * @buf_size: buffer size in bytes
- * @tlv_pos: seek position; this is assumed to be a pointer returned
- *           by i2400m_tlv_buffer_walk() [and thus, validated]. The
- *           TLV returned will be the one following this one.
- *
- * Usage:
- *
- * tlv_itr = NULL;
- * while (tlv_itr = i2400m_tlv_buffer_walk(i2400m, buf, size, tlv_itr))  {
- *         ...
- *         // Do stuff with tlv_itr, DON'T MODIFY IT
- *         ...
- * }
- */
-static
-const struct i2400m_tlv_hdr *i2400m_tlv_buffer_walk(
-       struct i2400m *i2400m,
-       const void *tlv_buf, size_t buf_size,
-       const struct i2400m_tlv_hdr *tlv_pos)
-{
-       struct device *dev = i2400m_dev(i2400m);
-       const struct i2400m_tlv_hdr *tlv_top = tlv_buf + buf_size;
-       size_t offset, length, avail_size;
-       unsigned type;
-
-       if (tlv_pos == NULL)    /* Take the first one? */
-               tlv_pos = tlv_buf;
-       else                    /* Nope, the next one */
-               tlv_pos = (void *) tlv_pos
-                       + le16_to_cpu(tlv_pos->length) + sizeof(*tlv_pos);
-       if (tlv_pos == tlv_top) {       /* buffer done */
-               tlv_pos = NULL;
-               goto error_beyond_end;
-       }
-       if (tlv_pos > tlv_top) {
-               tlv_pos = NULL;
-               WARN_ON(1);
-               goto error_beyond_end;
-       }
-       offset = (void *) tlv_pos - (void *) tlv_buf;
-       avail_size = buf_size - offset;
-       if (avail_size < sizeof(*tlv_pos)) {
-               dev_err(dev, "HW BUG? tlv_buf %p [%zu bytes], tlv @%zu: "
-                       "short header\n", tlv_buf, buf_size, offset);
-               goto error_short_header;
-       }
-       type = le16_to_cpu(tlv_pos->type);
-       length = le16_to_cpu(tlv_pos->length);
-       if (avail_size < sizeof(*tlv_pos) + length) {
-               dev_err(dev, "HW BUG? tlv_buf %p [%zu bytes], "
-                       "tlv type 0x%04x @%zu: "
-                       "short data (%zu bytes vs %zu needed)\n",
-                       tlv_buf, buf_size, type, offset, avail_size,
-                       sizeof(*tlv_pos) + length);
-               goto error_short_header;
-       }
-error_short_header:
-error_beyond_end:
-       return tlv_pos;
-}
-
-
-/*
- * Find a TLV in a buffer of sequential TLVs
- *
- * @i2400m: device descriptor
- * @tlv_hdr: pointer to the first TLV in the sequence
- * @size: size of the buffer in bytes; all TLVs are assumed to fit
- *        fully in the buffer (otherwise we'll complain).
- * @tlv_type: type of the TLV we are looking for
- * @tlv_size: expected size of the TLV we are looking for (if -1,
- *            don't check the size). This includes the header
- *
- * Returns: NULL if the TLV is not found, otherwise a pointer to
- *          it. If the sizes don't match, an error is printed and NULL
- *          returned.
- */
-static
-const struct i2400m_tlv_hdr *i2400m_tlv_find(
-       struct i2400m *i2400m,
-       const struct i2400m_tlv_hdr *tlv_hdr, size_t size,
-       enum i2400m_tlv tlv_type, ssize_t tlv_size)
-{
-       ssize_t match;
-       struct device *dev = i2400m_dev(i2400m);
-       const struct i2400m_tlv_hdr *tlv = NULL;
-       while ((tlv = i2400m_tlv_buffer_walk(i2400m, tlv_hdr, size, tlv))) {
-               match = i2400m_tlv_match(tlv, tlv_type, tlv_size);
-               if (match == 0)         /* found it :) */
-                       break;
-               if (match > 0)
-                       dev_warn(dev, "TLV type 0x%04x found with size "
-                                "mismatch (%zu vs %zd needed)\n",
-                                tlv_type, match, tlv_size);
-       }
-       return tlv;
-}
-
-
-static const struct
-{
-       char *msg;
-       int errno;
-} ms_to_errno[I2400M_MS_MAX] = {
-       [I2400M_MS_DONE_OK] = { "", 0 },
-       [I2400M_MS_DONE_IN_PROGRESS] = { "", 0 },
-       [I2400M_MS_INVALID_OP] = { "invalid opcode", -ENOSYS },
-       [I2400M_MS_BAD_STATE] = { "invalid state", -EILSEQ },
-       [I2400M_MS_ILLEGAL_VALUE] = { "illegal value", -EINVAL },
-       [I2400M_MS_MISSING_PARAMS] = { "missing parameters", -ENOMSG },
-       [I2400M_MS_VERSION_ERROR] = { "bad version", -EIO },
-       [I2400M_MS_ACCESSIBILITY_ERROR] = { "accesibility error", -EIO },
-       [I2400M_MS_BUSY] = { "busy", -EBUSY },
-       [I2400M_MS_CORRUPTED_TLV] = { "corrupted TLV", -EILSEQ },
-       [I2400M_MS_UNINITIALIZED] = { "uninitialized", -EILSEQ },
-       [I2400M_MS_UNKNOWN_ERROR] = { "unknown error", -EIO },
-       [I2400M_MS_PRODUCTION_ERROR] = { "production error", -EIO },
-       [I2400M_MS_NO_RF] = { "no RF", -EIO },
-       [I2400M_MS_NOT_READY_FOR_POWERSAVE] =
-               { "not ready for powersave", -EACCES },
-       [I2400M_MS_THERMAL_CRITICAL] = { "thermal critical", -EL3HLT },
-};
-
-
-/*
- * i2400m_msg_check_status - translate a message's status code
- *
- * @i2400m: device descriptor
- * @l3l4_hdr: message header
- * @strbuf: buffer to place a formatted error message (unless NULL).
- * @strbuf_size: max amount of available space; larger messages will
- * be truncated.
- *
- * Returns: errno code corresponding to the status code in @l3l4_hdr
- *          and a message in @strbuf describing the error.
- */
-int i2400m_msg_check_status(const struct i2400m_l3l4_hdr *l3l4_hdr,
-                           char *strbuf, size_t strbuf_size)
-{
-       int result;
-       enum i2400m_ms status = le16_to_cpu(l3l4_hdr->status);
-       const char *str;
-
-       if (status == 0)
-               return 0;
-       if (status >= ARRAY_SIZE(ms_to_errno)) {
-               str = "unknown status code";
-               result = -EBADR;
-       } else {
-               str = ms_to_errno[status].msg;
-               result = ms_to_errno[status].errno;
-       }
-       if (strbuf)
-               snprintf(strbuf, strbuf_size, "%s (%d)", str, status);
-       return result;
-}
-
-
-/*
- * Act on a TLV System State reported by the device
- *
- * @i2400m: device descriptor
- * @ss: validated System State TLV
- */
-static
-void i2400m_report_tlv_system_state(struct i2400m *i2400m,
-                                   const struct i2400m_tlv_system_state *ss)
-{
-       struct device *dev = i2400m_dev(i2400m);
-       struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
-       enum i2400m_system_state i2400m_state = le32_to_cpu(ss->state);
-
-       d_fnstart(3, dev, "(i2400m %p ss %p [%u])\n", i2400m, ss, i2400m_state);
-
-       if (i2400m->state != i2400m_state) {
-               i2400m->state = i2400m_state;
-               wake_up_all(&i2400m->state_wq);
-       }
-       switch (i2400m_state) {
-       case I2400M_SS_UNINITIALIZED:
-       case I2400M_SS_INIT:
-       case I2400M_SS_CONFIG:
-       case I2400M_SS_PRODUCTION:
-               wimax_state_change(wimax_dev, WIMAX_ST_UNINITIALIZED);
-               break;
-
-       case I2400M_SS_RF_OFF:
-       case I2400M_SS_RF_SHUTDOWN:
-               wimax_state_change(wimax_dev, WIMAX_ST_RADIO_OFF);
-               break;
-
-       case I2400M_SS_READY:
-       case I2400M_SS_STANDBY:
-       case I2400M_SS_SLEEPACTIVE:
-               wimax_state_change(wimax_dev, WIMAX_ST_READY);
-               break;
-
-       case I2400M_SS_CONNECTING:
-       case I2400M_SS_WIMAX_CONNECTED:
-               wimax_state_change(wimax_dev, WIMAX_ST_READY);
-               break;
-
-       case I2400M_SS_SCAN:
-       case I2400M_SS_OUT_OF_ZONE:
-               wimax_state_change(wimax_dev, WIMAX_ST_SCANNING);
-               break;
-
-       case I2400M_SS_IDLE:
-               d_printf(1, dev, "entering BS-negotiated idle mode\n");
-               fallthrough;
-       case I2400M_SS_DISCONNECTING:
-       case I2400M_SS_DATA_PATH_CONNECTED:
-               wimax_state_change(wimax_dev, WIMAX_ST_CONNECTED);
-               break;
-
-       default:
-               /* Huh? just in case, shut it down */
-               dev_err(dev, "HW BUG? unknown state %u: shutting down\n",
-                       i2400m_state);
-               i2400m_reset(i2400m, I2400M_RT_WARM);
-               break;
-       }
-       d_fnend(3, dev, "(i2400m %p ss %p [%u]) = void\n",
-               i2400m, ss, i2400m_state);
-}
-
-
-/*
- * Parse and act on a TLV Media Status sent by the device
- *
- * @i2400m: device descriptor
- * @ms: validated Media Status TLV
- *
- * This will set the carrier up on down based on the device's link
- * report. This is done asides of what the WiMAX stack does based on
- * the device's state as sometimes we need to do a link-renew (the BS
- * wants us to renew a DHCP lease, for example).
- *
- * In fact, doc says that every time we get a link-up, we should do a
- * DHCP negotiation...
- */
-static
-void i2400m_report_tlv_media_status(struct i2400m *i2400m,
-                                   const struct i2400m_tlv_media_status *ms)
-{
-       struct device *dev = i2400m_dev(i2400m);
-       struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
-       struct net_device *net_dev = wimax_dev->net_dev;
-       enum i2400m_media_status status = le32_to_cpu(ms->media_status);
-
-       d_fnstart(3, dev, "(i2400m %p ms %p [%u])\n", i2400m, ms, status);
-
-       switch (status) {
-       case I2400M_MEDIA_STATUS_LINK_UP:
-               netif_carrier_on(net_dev);
-               break;
-       case I2400M_MEDIA_STATUS_LINK_DOWN:
-               netif_carrier_off(net_dev);
-               break;
-       /*
-        * This is the network telling us we need to retrain the DHCP
-        * lease -- so far, we are trusting the WiMAX Network Service
-        * in user space to pick this up and poke the DHCP client.
-        */
-       case I2400M_MEDIA_STATUS_LINK_RENEW:
-               netif_carrier_on(net_dev);
-               break;
-       default:
-               dev_err(dev, "HW BUG? unknown media status %u\n",
-                       status);
-       }
-       d_fnend(3, dev, "(i2400m %p ms %p [%u]) = void\n",
-               i2400m, ms, status);
-}
-
-
-/*
- * Process a TLV from a 'state report'
- *
- * @i2400m: device descriptor
- * @tlv: pointer to the TLV header; it has been already validated for
- *     consistent size.
- * @tag: for error messages
- *
- * Act on the TLVs from a 'state report'.
- */
-static
-void i2400m_report_state_parse_tlv(struct i2400m *i2400m,
-                                  const struct i2400m_tlv_hdr *tlv,
-                                  const char *tag)
-{
-       struct device *dev = i2400m_dev(i2400m);
-       const struct i2400m_tlv_media_status *ms;
-       const struct i2400m_tlv_system_state *ss;
-       const struct i2400m_tlv_rf_switches_status *rfss;
-
-       if (0 == i2400m_tlv_match(tlv, I2400M_TLV_SYSTEM_STATE, sizeof(*ss))) {
-               ss = container_of(tlv, typeof(*ss), hdr);
-               d_printf(2, dev, "%s: system state TLV "
-                        "found (0x%04x), state 0x%08x\n",
-                        tag, I2400M_TLV_SYSTEM_STATE,
-                        le32_to_cpu(ss->state));
-               i2400m_report_tlv_system_state(i2400m, ss);
-       }
-       if (0 == i2400m_tlv_match(tlv, I2400M_TLV_RF_STATUS, sizeof(*rfss))) {
-               rfss = container_of(tlv, typeof(*rfss), hdr);
-               d_printf(2, dev, "%s: RF status TLV "
-                        "found (0x%04x), sw 0x%02x hw 0x%02x\n",
-                        tag, I2400M_TLV_RF_STATUS,
-                        rfss->sw_rf_switch,
-                        rfss->hw_rf_switch);
-               i2400m_report_tlv_rf_switches_status(i2400m, rfss);
-       }
-       if (0 == i2400m_tlv_match(tlv, I2400M_TLV_MEDIA_STATUS, sizeof(*ms))) {
-               ms = container_of(tlv, typeof(*ms), hdr);
-               d_printf(2, dev, "%s: Media Status TLV: %u\n",
-                        tag, le32_to_cpu(ms->media_status));
-               i2400m_report_tlv_media_status(i2400m, ms);
-       }
-}
-
-
-/*
- * Parse a 'state report' and extract information
- *
- * @i2400m: device descriptor
- * @l3l4_hdr: pointer to message; it has been already validated for
- *            consistent size.
- * @size: size of the message (header + payload). The header length
- *        declaration is assumed to be congruent with @size (as in
- *        sizeof(*l3l4_hdr) + l3l4_hdr->length == size)
- *
- * Walk over the TLVs in a report state and act on them.
- */
-static
-void i2400m_report_state_hook(struct i2400m *i2400m,
-                             const struct i2400m_l3l4_hdr *l3l4_hdr,
-                             size_t size, const char *tag)
-{
-       struct device *dev = i2400m_dev(i2400m);
-       const struct i2400m_tlv_hdr *tlv;
-       size_t tlv_size = le16_to_cpu(l3l4_hdr->length);
-
-       d_fnstart(4, dev, "(i2400m %p, l3l4_hdr %p, size %zu, %s)\n",
-                 i2400m, l3l4_hdr, size, tag);
-       tlv = NULL;
-
-       while ((tlv = i2400m_tlv_buffer_walk(i2400m, &l3l4_hdr->pl,
-                                            tlv_size, tlv)))
-               i2400m_report_state_parse_tlv(i2400m, tlv, tag);
-       d_fnend(4, dev, "(i2400m %p, l3l4_hdr %p, size %zu, %s) = void\n",
-               i2400m, l3l4_hdr, size, tag);
-}
-
-
-/*
- * i2400m_report_hook - (maybe) act on a report
- *
- * @i2400m: device descriptor
- * @l3l4_hdr: pointer to message; it has been already validated for
- *            consistent size.
- * @size: size of the message (header + payload). The header length
- *        declaration is assumed to be congruent with @size (as in
- *        sizeof(*l3l4_hdr) + l3l4_hdr->length == size)
- *
- * Extract information we might need (like carrien on/off) from a
- * device report.
- */
-void i2400m_report_hook(struct i2400m *i2400m,
-                       const struct i2400m_l3l4_hdr *l3l4_hdr, size_t size)
-{
-       struct device *dev = i2400m_dev(i2400m);
-       unsigned msg_type;
-
-       d_fnstart(3, dev, "(i2400m %p l3l4_hdr %p size %zu)\n",
-                 i2400m, l3l4_hdr, size);
-       /* Chew on the message, we might need some information from
-        * here */
-       msg_type = le16_to_cpu(l3l4_hdr->type);
-       switch (msg_type) {
-       case I2400M_MT_REPORT_STATE:    /* carrier detection... */
-               i2400m_report_state_hook(i2400m,
-                                        l3l4_hdr, size, "REPORT STATE");
-               break;
-       /* If the device is ready for power save, then ask it to do
-        * it. */
-       case I2400M_MT_REPORT_POWERSAVE_READY:  /* zzzzz */
-               if (l3l4_hdr->status == cpu_to_le16(I2400M_MS_DONE_OK)) {
-                       if (i2400m_power_save_disabled)
-                               d_printf(1, dev, "ready for powersave, "
-                                        "not requesting (disabled by module "
-                                        "parameter)\n");
-                       else {
-                               d_printf(1, dev, "ready for powersave, "
-                                        "requesting\n");
-                               i2400m_cmd_enter_powersave(i2400m);
-                       }
-               }
-               break;
-       }
-       d_fnend(3, dev, "(i2400m %p l3l4_hdr %p size %zu) = void\n",
-               i2400m, l3l4_hdr, size);
-}
-
-
-/*
- * i2400m_msg_ack_hook - process cmd/set/get ack for internal status
- *
- * @i2400m: device descriptor
- * @l3l4_hdr: pointer to message; it has been already validated for
- *            consistent size.
- * @size: size of the message
- *
- * Extract information we might need from acks to commands and act on
- * it. This is akin to i2400m_report_hook(). Note most of this
- * processing should be done in the function that calls the
- * command. This is here for some cases where it can't happen...
- */
-static void i2400m_msg_ack_hook(struct i2400m *i2400m,
-                                const struct i2400m_l3l4_hdr *l3l4_hdr,
-                                size_t size)
-{
-       int result;
-       struct device *dev = i2400m_dev(i2400m);
-       unsigned int ack_type;
-       char strerr[32];
-
-       /* Chew on the message, we might need some information from
-        * here */
-       ack_type = le16_to_cpu(l3l4_hdr->type);
-       switch (ack_type) {
-       case I2400M_MT_CMD_ENTER_POWERSAVE:
-               /* This is just left here for the sake of example, as
-                * the processing is done somewhere else. */
-               if (0) {
-                       result = i2400m_msg_check_status(
-                               l3l4_hdr, strerr, sizeof(strerr));
-                       if (result >= 0)
-                               d_printf(1, dev, "ready for power save: %zd\n",
-                                        size);
-               }
-               break;
-       }
-}
-
-
-/*
- * i2400m_msg_size_check() - verify message size and header are congruent
- *
- * It is ok if the total message size is larger than the expected
- * size, as there can be padding.
- */
-int i2400m_msg_size_check(struct i2400m *i2400m,
-                         const struct i2400m_l3l4_hdr *l3l4_hdr,
-                         size_t msg_size)
-{
-       int result;
-       struct device *dev = i2400m_dev(i2400m);
-       size_t expected_size;
-       d_fnstart(4, dev, "(i2400m %p l3l4_hdr %p msg_size %zu)\n",
-                 i2400m, l3l4_hdr, msg_size);
-       if (msg_size < sizeof(*l3l4_hdr)) {
-               dev_err(dev, "bad size for message header "
-                       "(expected at least %zu, got %zu)\n",
-                       (size_t) sizeof(*l3l4_hdr), msg_size);
-               result = -EIO;
-               goto error_hdr_size;
-       }
-       expected_size = le16_to_cpu(l3l4_hdr->length) + sizeof(*l3l4_hdr);
-       if (msg_size < expected_size) {
-               dev_err(dev, "bad size for message code 0x%04x (expected %zu, "
-                       "got %zu)\n", le16_to_cpu(l3l4_hdr->type),
-                       expected_size, msg_size);
-               result = -EIO;
-       } else
-               result = 0;
-error_hdr_size:
-       d_fnend(4, dev,
-               "(i2400m %p l3l4_hdr %p msg_size %zu) = %d\n",
-               i2400m, l3l4_hdr, msg_size, result);
-       return result;
-}
-
-
-
-/*
- * Cancel a wait for a command ACK
- *
- * @i2400m: device descriptor
- * @code: [negative] errno code to cancel with (don't use
- *     -EINPROGRESS)
- *
- * If there is an ack already filled out, free it.
- */
-void i2400m_msg_to_dev_cancel_wait(struct i2400m *i2400m, int code)
-{
-       struct sk_buff *ack_skb;
-       unsigned long flags;
-
-       spin_lock_irqsave(&i2400m->rx_lock, flags);
-       ack_skb = i2400m->ack_skb;
-       if (ack_skb && !IS_ERR(ack_skb))
-               kfree_skb(ack_skb);
-       i2400m->ack_skb = ERR_PTR(code);
-       spin_unlock_irqrestore(&i2400m->rx_lock, flags);
-}
-
-
-/**
- * i2400m_msg_to_dev - Send a control message to the device and get a response
- *
- * @i2400m: device descriptor
- *
- * @buf: pointer to the buffer containing the message to be sent; it
- *           has to start with a &struct i2400M_l3l4_hdr and then
- *           followed by the payload. Once this function returns, the
- *           buffer can be reused.
- *
- * @buf_len: buffer size
- *
- * Returns:
- *
- * Pointer to skb containing the ack message. You need to check the
- * pointer with IS_ERR(), as it might be an error code. Error codes
- * could happen because:
- *
- *  - the message wasn't formatted correctly
- *  - couldn't send the message
- *  - failed waiting for a response
- *  - the ack message wasn't formatted correctly
- *
- * The returned skb has been allocated with wimax_msg_to_user_alloc(),
- * it contains the response in a netlink attribute and is ready to be
- * passed up to user space with wimax_msg_to_user_send(). To access
- * the payload and its length, use wimax_msg_{data,len}() on the skb.
- *
- * The skb has to be freed with kfree_skb() once done.
- *
- * Description:
- *
- * This function delivers a message/command to the device and waits
- * for an ack to be received. The format is described in
- * linux/wimax/i2400m.h. In summary, a command/get/set is followed by an
- * ack.
- *
- * This function will not check the ack status, that's left up to the
- * caller.  Once done with the ack skb, it has to be kfree_skb()ed.
- *
- * The i2400m handles only one message at the same time, thus we need
- * the mutex to exclude other players.
- *
- * We write the message and then wait for an answer to come back. The
- * RX path intercepts control messages and handles them in
- * i2400m_rx_ctl(). Reports (notifications) are (maybe) processed
- * locally and then forwarded (as needed) to user space on the WiMAX
- * stack message pipe. Acks are saved and passed back to us through an
- * skb in i2400m->ack_skb which is ready to be given to generic
- * netlink if need be.
- */
-struct sk_buff *i2400m_msg_to_dev(struct i2400m *i2400m,
-                                 const void *buf, size_t buf_len)
-{
-       int result;
-       struct device *dev = i2400m_dev(i2400m);
-       const struct i2400m_l3l4_hdr *msg_l3l4_hdr;
-       struct sk_buff *ack_skb;
-       const struct i2400m_l3l4_hdr *ack_l3l4_hdr;
-       size_t ack_len;
-       int ack_timeout;
-       unsigned msg_type;
-       unsigned long flags;
-
-       d_fnstart(3, dev, "(i2400m %p buf %p len %zu)\n",
-                 i2400m, buf, buf_len);
-
-       rmb();          /* Make sure we see what i2400m_dev_reset_handle() */
-       if (i2400m->boot_mode)
-               return ERR_PTR(-EL3RST);
-
-       msg_l3l4_hdr = buf;
-       /* Check msg & payload consistency */
-       result = i2400m_msg_size_check(i2400m, msg_l3l4_hdr, buf_len);
-       if (result < 0)
-               goto error_bad_msg;
-       msg_type = le16_to_cpu(msg_l3l4_hdr->type);
-       d_printf(1, dev, "CMD/GET/SET 0x%04x %zu bytes\n",
-                msg_type, buf_len);
-       d_dump(2, dev, buf, buf_len);
-
-       /* Setup the completion, ack_skb ("we are waiting") and send
-        * the message to the device */
-       mutex_lock(&i2400m->msg_mutex);
-       spin_lock_irqsave(&i2400m->rx_lock, flags);
-       i2400m->ack_skb = ERR_PTR(-EINPROGRESS);
-       spin_unlock_irqrestore(&i2400m->rx_lock, flags);
-       init_completion(&i2400m->msg_completion);
-       result = i2400m_tx(i2400m, buf, buf_len, I2400M_PT_CTRL);
-       if (result < 0) {
-               dev_err(dev, "can't send message 0x%04x: %d\n",
-                       le16_to_cpu(msg_l3l4_hdr->type), result);
-               goto error_tx;
-       }
-
-       /* Some commands take longer to execute because of crypto ops,
-        * so we give them some more leeway on timeout */
-       switch (msg_type) {
-       case I2400M_MT_GET_TLS_OPERATION_RESULT:
-       case I2400M_MT_CMD_SEND_EAP_RESPONSE:
-               ack_timeout = 5 * HZ;
-               break;
-       default:
-               ack_timeout = HZ;
-       }
-
-       if (unlikely(i2400m->trace_msg_from_user))
-               wimax_msg(&i2400m->wimax_dev, "echo", buf, buf_len, GFP_KERNEL);
-       /* The RX path in rx.c will put any response for this message
-        * in i2400m->ack_skb and wake us up. If we cancel the wait,
-        * we need to change the value of i2400m->ack_skb to something
-        * not -EINPROGRESS so RX knows there is no one waiting. */
-       result = wait_for_completion_interruptible_timeout(
-               &i2400m->msg_completion, ack_timeout);
-       if (result == 0) {
-               dev_err(dev, "timeout waiting for reply to message 0x%04x\n",
-                       msg_type);
-               result = -ETIMEDOUT;
-               i2400m_msg_to_dev_cancel_wait(i2400m, result);
-               goto error_wait_for_completion;
-       } else if (result < 0) {
-               dev_err(dev, "error waiting for reply to message 0x%04x: %d\n",
-                       msg_type, result);
-               i2400m_msg_to_dev_cancel_wait(i2400m, result);
-               goto error_wait_for_completion;
-       }
-
-       /* Pull out the ack data from i2400m->ack_skb -- see if it is
-        * an error and act accordingly */
-       spin_lock_irqsave(&i2400m->rx_lock, flags);
-       ack_skb = i2400m->ack_skb;
-       if (IS_ERR(ack_skb))
-               result = PTR_ERR(ack_skb);
-       else
-               result = 0;
-       i2400m->ack_skb = NULL;
-       spin_unlock_irqrestore(&i2400m->rx_lock, flags);
-       if (result < 0)
-               goto error_ack_status;
-       ack_l3l4_hdr = wimax_msg_data_len(ack_skb, &ack_len);
-
-       /* Check the ack and deliver it if it is ok */
-       if (unlikely(i2400m->trace_msg_from_user))
-               wimax_msg(&i2400m->wimax_dev, "echo",
-                         ack_l3l4_hdr, ack_len, GFP_KERNEL);
-       result = i2400m_msg_size_check(i2400m, ack_l3l4_hdr, ack_len);
-       if (result < 0) {
-               dev_err(dev, "HW BUG? reply to message 0x%04x: %d\n",
-                       msg_type, result);
-               goto error_bad_ack_len;
-       }
-       if (msg_type != le16_to_cpu(ack_l3l4_hdr->type)) {
-               dev_err(dev, "HW BUG? bad reply 0x%04x to message 0x%04x\n",
-                       le16_to_cpu(ack_l3l4_hdr->type), msg_type);
-               result = -EIO;
-               goto error_bad_ack_type;
-       }
-       i2400m_msg_ack_hook(i2400m, ack_l3l4_hdr, ack_len);
-       mutex_unlock(&i2400m->msg_mutex);
-       d_fnend(3, dev, "(i2400m %p buf %p len %zu) = %p\n",
-               i2400m, buf, buf_len, ack_skb);
-       return ack_skb;
-
-error_bad_ack_type:
-error_bad_ack_len:
-       kfree_skb(ack_skb);
-error_ack_status:
-error_wait_for_completion:
-error_tx:
-       mutex_unlock(&i2400m->msg_mutex);
-error_bad_msg:
-       d_fnend(3, dev, "(i2400m %p buf %p len %zu) = %d\n",
-               i2400m, buf, buf_len, result);
-       return ERR_PTR(result);
-}
-
-
-/*
- * Definitions for the Enter Power Save command
- *
- * The Enter Power Save command requests the device to go into power
- * saving mode. The device will ack or nak the command depending on it
- * being ready for it. If it acks, we tell the USB subsystem to
- *
- * As well, the device might request to go into power saving mode by
- * sending a report (REPORT_POWERSAVE_READY), in which case, we issue
- * this command. The hookups in the RX coder allow
- */
-enum {
-       I2400M_WAKEUP_ENABLED  = 0x01,
-       I2400M_WAKEUP_DISABLED = 0x02,
-       I2400M_TLV_TYPE_WAKEUP_MODE = 144,
-};
-
-struct i2400m_cmd_enter_power_save {
-       struct i2400m_l3l4_hdr hdr;
-       struct i2400m_tlv_hdr tlv;
-       __le32 val;
-} __packed;
-
-
-/*
- * Request entering power save
- *
- * This command is (mainly) executed when the device indicates that it
- * is ready to go into powersave mode via a REPORT_POWERSAVE_READY.
- */
-int i2400m_cmd_enter_powersave(struct i2400m *i2400m)
-{
-       int result;
-       struct device *dev = i2400m_dev(i2400m);
-       struct sk_buff *ack_skb;
-       struct i2400m_cmd_enter_power_save *cmd;
-       char strerr[32];
-
-       result = -ENOMEM;
-       cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
-       if (cmd == NULL)
-               goto error_alloc;
-       cmd->hdr.type = cpu_to_le16(I2400M_MT_CMD_ENTER_POWERSAVE);
-       cmd->hdr.length = cpu_to_le16(sizeof(*cmd) - sizeof(cmd->hdr));
-       cmd->hdr.version = cpu_to_le16(I2400M_L3L4_VERSION);
-       cmd->tlv.type = cpu_to_le16(I2400M_TLV_TYPE_WAKEUP_MODE);
-       cmd->tlv.length = cpu_to_le16(sizeof(cmd->val));
-       cmd->val = cpu_to_le32(I2400M_WAKEUP_ENABLED);
-
-       ack_skb = i2400m_msg_to_dev(i2400m, cmd, sizeof(*cmd));
-       result = PTR_ERR(ack_skb);
-       if (IS_ERR(ack_skb)) {
-               dev_err(dev, "Failed to issue 'Enter power save' command: %d\n",
-                       result);
-               goto error_msg_to_dev;
-       }
-       result = i2400m_msg_check_status(wimax_msg_data(ack_skb),
-                                        strerr, sizeof(strerr));
-       if (result == -EACCES)
-               d_printf(1, dev, "Cannot enter power save mode\n");
-       else if (result < 0)
-               dev_err(dev, "'Enter power save' (0x%04x) command failed: "
-                       "%d - %s\n", I2400M_MT_CMD_ENTER_POWERSAVE,
-                       result, strerr);
-       else
-               d_printf(1, dev, "device ready to power save\n");
-       kfree_skb(ack_skb);
-error_msg_to_dev:
-       kfree(cmd);
-error_alloc:
-       return result;
-}
-EXPORT_SYMBOL_GPL(i2400m_cmd_enter_powersave);
-
-
-/*
- * Definitions for getting device information
- */
-enum {
-       I2400M_TLV_DETAILED_DEVICE_INFO = 140
-};
-
-/**
- * i2400m_get_device_info - Query the device for detailed device information
- *
- * @i2400m: device descriptor
- *
- * Returns: an skb whose skb->data points to a 'struct
- *    i2400m_tlv_detailed_device_info'. When done, kfree_skb() it. The
- *    skb is *guaranteed* to contain the whole TLV data structure.
- *
- *    On error, IS_ERR(skb) is true and ERR_PTR(skb) is the error
- *    code.
- */
-struct sk_buff *i2400m_get_device_info(struct i2400m *i2400m)
-{
-       int result;
-       struct device *dev = i2400m_dev(i2400m);
-       struct sk_buff *ack_skb;
-       struct i2400m_l3l4_hdr *cmd;
-       const struct i2400m_l3l4_hdr *ack;
-       size_t ack_len;
-       const struct i2400m_tlv_hdr *tlv;
-       const struct i2400m_tlv_detailed_device_info *ddi;
-       char strerr[32];
-
-       ack_skb = ERR_PTR(-ENOMEM);
-       cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
-       if (cmd == NULL)
-               goto error_alloc;
-       cmd->type = cpu_to_le16(I2400M_MT_GET_DEVICE_INFO);
-       cmd->length = 0;
-       cmd->version = cpu_to_le16(I2400M_L3L4_VERSION);
-
-       ack_skb = i2400m_msg_to_dev(i2400m, cmd, sizeof(*cmd));
-       if (IS_ERR(ack_skb)) {
-               dev_err(dev, "Failed to issue 'get device info' command: %ld\n",
-                       PTR_ERR(ack_skb));
-               goto error_msg_to_dev;
-       }
-       ack = wimax_msg_data_len(ack_skb, &ack_len);
-       result = i2400m_msg_check_status(ack, strerr, sizeof(strerr));
-       if (result < 0) {
-               dev_err(dev, "'get device info' (0x%04x) command failed: "
-                       "%d - %s\n", I2400M_MT_GET_DEVICE_INFO, result,
-                       strerr);
-               goto error_cmd_failed;
-       }
-       tlv = i2400m_tlv_find(i2400m, ack->pl, ack_len - sizeof(*ack),
-                             I2400M_TLV_DETAILED_DEVICE_INFO, sizeof(*ddi));
-       if (tlv == NULL) {
-               dev_err(dev, "GET DEVICE INFO: "
-                       "detailed device info TLV not found (0x%04x)\n",
-                       I2400M_TLV_DETAILED_DEVICE_INFO);
-               result = -EIO;
-               goto error_no_tlv;
-       }
-       skb_pull(ack_skb, (void *) tlv - (void *) ack_skb->data);
-error_msg_to_dev:
-       kfree(cmd);
-error_alloc:
-       return ack_skb;
-
-error_no_tlv:
-error_cmd_failed:
-       kfree_skb(ack_skb);
-       kfree(cmd);
-       return ERR_PTR(result);
-}
-
-
-/* Firmware interface versions we support */
-enum {
-       I2400M_HDIv_MAJOR = 9,
-       I2400M_HDIv_MINOR = 1,
-       I2400M_HDIv_MINOR_2 = 2,
-};
-
-
-/**
- * i2400m_firmware_check - check firmware versions are compatible with
- * the driver
- *
- * @i2400m: device descriptor
- *
- * Returns: 0 if ok, < 0 errno code an error and a message in the
- *    kernel log.
- *
- * Long function, but quite simple; first chunk launches the command
- * and double checks the reply for the right TLV. Then we process the
- * TLV (where the meat is).
- *
- * Once we process the TLV that gives us the firmware's interface
- * version, we encode it and save it in i2400m->fw_version for future
- * reference.
- */
-int i2400m_firmware_check(struct i2400m *i2400m)
-{
-       int result;
-       struct device *dev = i2400m_dev(i2400m);
-       struct sk_buff *ack_skb;
-       struct i2400m_l3l4_hdr *cmd;
-       const struct i2400m_l3l4_hdr *ack;
-       size_t ack_len;
-       const struct i2400m_tlv_hdr *tlv;
-       const struct i2400m_tlv_l4_message_versions *l4mv;
-       char strerr[32];
-       unsigned major, minor, branch;
-
-       result = -ENOMEM;
-       cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
-       if (cmd == NULL)
-               goto error_alloc;
-       cmd->type = cpu_to_le16(I2400M_MT_GET_LM_VERSION);
-       cmd->length = 0;
-       cmd->version = cpu_to_le16(I2400M_L3L4_VERSION);
-
-       ack_skb = i2400m_msg_to_dev(i2400m, cmd, sizeof(*cmd));
-       if (IS_ERR(ack_skb)) {
-               result = PTR_ERR(ack_skb);
-               dev_err(dev, "Failed to issue 'get lm version' command: %-d\n",
-                       result);
-               goto error_msg_to_dev;
-       }
-       ack = wimax_msg_data_len(ack_skb, &ack_len);
-       result = i2400m_msg_check_status(ack, strerr, sizeof(strerr));
-       if (result < 0) {
-               dev_err(dev, "'get lm version' (0x%04x) command failed: "
-                       "%d - %s\n", I2400M_MT_GET_LM_VERSION, result,
-                       strerr);
-               goto error_cmd_failed;
-       }
-       tlv = i2400m_tlv_find(i2400m, ack->pl, ack_len - sizeof(*ack),
-                             I2400M_TLV_L4_MESSAGE_VERSIONS, sizeof(*l4mv));
-       if (tlv == NULL) {
-               dev_err(dev, "get lm version: TLV not found (0x%04x)\n",
-                       I2400M_TLV_L4_MESSAGE_VERSIONS);
-               result = -EIO;
-               goto error_no_tlv;
-       }
-       l4mv = container_of(tlv, typeof(*l4mv), hdr);
-       major = le16_to_cpu(l4mv->major);
-       minor = le16_to_cpu(l4mv->minor);
-       branch = le16_to_cpu(l4mv->branch);
-       result = -EINVAL;
-       if (major != I2400M_HDIv_MAJOR) {
-               dev_err(dev, "unsupported major fw version "
-                       "%u.%u.%u\n", major, minor, branch);
-               goto error_bad_major;
-       }
-       result = 0;
-       if (minor > I2400M_HDIv_MINOR_2 || minor < I2400M_HDIv_MINOR)
-               dev_warn(dev, "untested minor fw version %u.%u.%u\n",
-                        major, minor, branch);
-       /* Yes, we ignore the branch -- we don't have to track it */
-       i2400m->fw_version = major << 16 | minor;
-       dev_info(dev, "firmware interface version %u.%u.%u\n",
-                major, minor, branch);
-error_bad_major:
-error_no_tlv:
-error_cmd_failed:
-       kfree_skb(ack_skb);
-error_msg_to_dev:
-       kfree(cmd);
-error_alloc:
-       return result;
-}
-
-
-/*
- * Send an DoExitIdle command to the device to ask it to go out of
- * basestation-idle mode.
- *
- * @i2400m: device descriptor
- *
- * This starts a renegotiation with the basestation that might involve
- * another crypto handshake with user space.
- *
- * Returns: 0 if ok, < 0 errno code on error.
- */
-int i2400m_cmd_exit_idle(struct i2400m *i2400m)
-{
-       int result;
-       struct device *dev = i2400m_dev(i2400m);
-       struct sk_buff *ack_skb;
-       struct i2400m_l3l4_hdr *cmd;
-       char strerr[32];
-
-       result = -ENOMEM;
-       cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
-       if (cmd == NULL)
-               goto error_alloc;
-       cmd->type = cpu_to_le16(I2400M_MT_CMD_EXIT_IDLE);
-       cmd->length = 0;
-       cmd->version = cpu_to_le16(I2400M_L3L4_VERSION);
-
-       ack_skb = i2400m_msg_to_dev(i2400m, cmd, sizeof(*cmd));
-       result = PTR_ERR(ack_skb);
-       if (IS_ERR(ack_skb)) {
-               dev_err(dev, "Failed to issue 'exit idle' command: %d\n",
-                       result);
-               goto error_msg_to_dev;
-       }
-       result = i2400m_msg_check_status(wimax_msg_data(ack_skb),
-                                        strerr, sizeof(strerr));
-       kfree_skb(ack_skb);
-error_msg_to_dev:
-       kfree(cmd);
-error_alloc:
-       return result;
-
-}
-
-
-/*
- * Query the device for its state, update the WiMAX stack's idea of it
- *
- * @i2400m: device descriptor
- *
- * Returns: 0 if ok, < 0 errno code on error.
- *
- * Executes a 'Get State' command and parses the returned
- * TLVs.
- *
- * Because this is almost identical to a 'Report State', we use
- * i2400m_report_state_hook() to parse the answer. This will set the
- * carrier state, as well as the RF Kill switches state.
- */
-static int i2400m_cmd_get_state(struct i2400m *i2400m)
-{
-       int result;
-       struct device *dev = i2400m_dev(i2400m);
-       struct sk_buff *ack_skb;
-       struct i2400m_l3l4_hdr *cmd;
-       const struct i2400m_l3l4_hdr *ack;
-       size_t ack_len;
-       char strerr[32];
-
-       result = -ENOMEM;
-       cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
-       if (cmd == NULL)
-               goto error_alloc;
-       cmd->type = cpu_to_le16(I2400M_MT_GET_STATE);
-       cmd->length = 0;
-       cmd->version = cpu_to_le16(I2400M_L3L4_VERSION);
-
-       ack_skb = i2400m_msg_to_dev(i2400m, cmd, sizeof(*cmd));
-       if (IS_ERR(ack_skb)) {
-               dev_err(dev, "Failed to issue 'get state' command: %ld\n",
-                       PTR_ERR(ack_skb));
-               result = PTR_ERR(ack_skb);
-               goto error_msg_to_dev;
-       }
-       ack = wimax_msg_data_len(ack_skb, &ack_len);
-       result = i2400m_msg_check_status(ack, strerr, sizeof(strerr));
-       if (result < 0) {
-               dev_err(dev, "'get state' (0x%04x) command failed: "
-                       "%d - %s\n", I2400M_MT_GET_STATE, result, strerr);
-               goto error_cmd_failed;
-       }
-       i2400m_report_state_hook(i2400m, ack, ack_len - sizeof(*ack),
-                                "GET STATE");
-       result = 0;
-       kfree_skb(ack_skb);
-error_cmd_failed:
-error_msg_to_dev:
-       kfree(cmd);
-error_alloc:
-       return result;
-}
-
-/**
- * Set basic configuration settings
- *
- * @i2400m: device descriptor
- * @arg: array of pointers to the TLV headers to send for
- *     configuration (each followed by its payload).
- *     TLV headers and payloads must be properly initialized, with the
- *     right endianess (LE).
- * @args: number of pointers in the @arg array
- */
-static int i2400m_set_init_config(struct i2400m *i2400m,
-                                 const struct i2400m_tlv_hdr **arg,
-                                 size_t args)
-{
-       int result;
-       struct device *dev = i2400m_dev(i2400m);
-       struct sk_buff *ack_skb;
-       struct i2400m_l3l4_hdr *cmd;
-       char strerr[32];
-       unsigned argc, argsize, tlv_size;
-       const struct i2400m_tlv_hdr *tlv_hdr;
-       void *buf, *itr;
-
-       d_fnstart(3, dev, "(i2400m %p arg %p args %zu)\n", i2400m, arg, args);
-       result = 0;
-       if (args == 0)
-               goto none;
-       /* Compute the size of all the TLVs, so we can alloc a
-        * contiguous command block to copy them. */
-       argsize = 0;
-       for (argc = 0; argc < args; argc++) {
-               tlv_hdr = arg[argc];
-               argsize += sizeof(*tlv_hdr) + le16_to_cpu(tlv_hdr->length);
-       }
-       WARN_ON(argc >= 9);     /* As per hw spec */
-
-       /* Alloc the space for the command and TLVs*/
-       result = -ENOMEM;
-       buf = kzalloc(sizeof(*cmd) + argsize, GFP_KERNEL);
-       if (buf == NULL)
-               goto error_alloc;
-       cmd = buf;
-       cmd->type = cpu_to_le16(I2400M_MT_SET_INIT_CONFIG);
-       cmd->length = cpu_to_le16(argsize);
-       cmd->version = cpu_to_le16(I2400M_L3L4_VERSION);
-
-       /* Copy the TLVs */
-       itr = buf + sizeof(*cmd);
-       for (argc = 0; argc < args; argc++) {
-               tlv_hdr = arg[argc];
-               tlv_size = sizeof(*tlv_hdr) + le16_to_cpu(tlv_hdr->length);
-               memcpy(itr, tlv_hdr, tlv_size);
-               itr += tlv_size;
-       }
-
-       /* Send the message! */
-       ack_skb = i2400m_msg_to_dev(i2400m, buf, sizeof(*cmd) + argsize);
-       result = PTR_ERR(ack_skb);
-       if (IS_ERR(ack_skb)) {
-               dev_err(dev, "Failed to issue 'init config' command: %d\n",
-                       result);
-
-               goto error_msg_to_dev;
-       }
-       result = i2400m_msg_check_status(wimax_msg_data(ack_skb),
-                                        strerr, sizeof(strerr));
-       if (result < 0)
-               dev_err(dev, "'init config' (0x%04x) command failed: %d - %s\n",
-                       I2400M_MT_SET_INIT_CONFIG, result, strerr);
-       kfree_skb(ack_skb);
-error_msg_to_dev:
-       kfree(buf);
-error_alloc:
-none:
-       d_fnend(3, dev, "(i2400m %p arg %p args %zu) = %d\n",
-               i2400m, arg, args, result);
-       return result;
-
-}
-
-/**
- * i2400m_set_idle_timeout - Set the device's idle mode timeout
- *
- * @i2400m: i2400m device descriptor
- *
- * @msecs: milliseconds for the timeout to enter idle mode. Between
- *     100 to 300000 (5m); 0 to disable. In increments of 100.
- *
- * After this @msecs of the link being idle (no data being sent or
- * received), the device will negotiate with the basestation entering
- * idle mode for saving power. The connection is maintained, but
- * getting out of it (done in tx.c) will require some negotiation,
- * possible crypto re-handshake and a possible DHCP re-lease.
- *
- * Only available if fw_version >= 0x00090002.
- *
- * Returns: 0 if ok, < 0 errno code on error.
- */
-int i2400m_set_idle_timeout(struct i2400m *i2400m, unsigned msecs)
-{
-       int result;
-       struct device *dev = i2400m_dev(i2400m);
-       struct sk_buff *ack_skb;
-       struct {
-               struct i2400m_l3l4_hdr hdr;
-               struct i2400m_tlv_config_idle_timeout cit;
-       } *cmd;
-       const struct i2400m_l3l4_hdr *ack;
-       size_t ack_len;
-       char strerr[32];
-
-       result = -ENOSYS;
-       if (i2400m_le_v1_3(i2400m))
-               goto error_alloc;
-       result = -ENOMEM;
-       cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
-       if (cmd == NULL)
-               goto error_alloc;
-       cmd->hdr.type = cpu_to_le16(I2400M_MT_GET_STATE);
-       cmd->hdr.length = cpu_to_le16(sizeof(*cmd) - sizeof(cmd->hdr));
-       cmd->hdr.version = cpu_to_le16(I2400M_L3L4_VERSION);
-
-       cmd->cit.hdr.type =
-               cpu_to_le16(I2400M_TLV_CONFIG_IDLE_TIMEOUT);
-       cmd->cit.hdr.length = cpu_to_le16(sizeof(cmd->cit.timeout));
-       cmd->cit.timeout = cpu_to_le32(msecs);
-
-       ack_skb = i2400m_msg_to_dev(i2400m, cmd, sizeof(*cmd));
-       if (IS_ERR(ack_skb)) {
-               dev_err(dev, "Failed to issue 'set idle timeout' command: "
-                       "%ld\n", PTR_ERR(ack_skb));
-               result = PTR_ERR(ack_skb);
-               goto error_msg_to_dev;
-       }
-       ack = wimax_msg_data_len(ack_skb, &ack_len);
-       result = i2400m_msg_check_status(ack, strerr, sizeof(strerr));
-       if (result < 0) {
-               dev_err(dev, "'set idle timeout' (0x%04x) command failed: "
-                       "%d - %s\n", I2400M_MT_GET_STATE, result, strerr);
-               goto error_cmd_failed;
-       }
-       result = 0;
-       kfree_skb(ack_skb);
-error_cmd_failed:
-error_msg_to_dev:
-       kfree(cmd);
-error_alloc:
-       return result;
-}
-
-
-/**
- * i2400m_dev_initialize - Initialize the device once communications are ready
- *
- * @i2400m: device descriptor
- *
- * Returns: 0 if ok, < 0 errno code on error.
- *
- * Configures the device to work the way we like it.
- *
- * At the point of this call, the device is registered with the WiMAX
- * and netdev stacks, firmware is uploaded and we can talk to the
- * device normally.
- */
-int i2400m_dev_initialize(struct i2400m *i2400m)
-{
-       int result;
-       struct device *dev = i2400m_dev(i2400m);
-       struct i2400m_tlv_config_idle_parameters idle_params;
-       struct i2400m_tlv_config_idle_timeout idle_timeout;
-       struct i2400m_tlv_config_d2h_data_format df;
-       struct i2400m_tlv_config_dl_host_reorder dlhr;
-       const struct i2400m_tlv_hdr *args[9];
-       unsigned argc = 0;
-
-       d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
-       if (i2400m_passive_mode)
-               goto out_passive;
-       /* Disable idle mode? (enabled by default) */
-       if (i2400m_idle_mode_disabled) {
-               if (i2400m_le_v1_3(i2400m)) {
-                       idle_params.hdr.type =
-                               cpu_to_le16(I2400M_TLV_CONFIG_IDLE_PARAMETERS);
-                       idle_params.hdr.length = cpu_to_le16(
-                               sizeof(idle_params) - sizeof(idle_params.hdr));
-                       idle_params.idle_timeout = 0;
-                       idle_params.idle_paging_interval = 0;
-                       args[argc++] = &idle_params.hdr;
-               } else {
-                       idle_timeout.hdr.type =
-                               cpu_to_le16(I2400M_TLV_CONFIG_IDLE_TIMEOUT);
-                       idle_timeout.hdr.length = cpu_to_le16(
-                               sizeof(idle_timeout) - sizeof(idle_timeout.hdr));
-                       idle_timeout.timeout = 0;
-                       args[argc++] = &idle_timeout.hdr;
-               }
-       }
-       if (i2400m_ge_v1_4(i2400m)) {
-               /* Enable extended RX data format? */
-               df.hdr.type =
-                       cpu_to_le16(I2400M_TLV_CONFIG_D2H_DATA_FORMAT);
-               df.hdr.length = cpu_to_le16(
-                       sizeof(df) - sizeof(df.hdr));
-               df.format = 1;
-               args[argc++] = &df.hdr;
-
-               /* Enable RX data reordering?
-                * (switch flipped in rx.c:i2400m_rx_setup() after fw upload) */
-               if (i2400m->rx_reorder) {
-                       dlhr.hdr.type =
-                               cpu_to_le16(I2400M_TLV_CONFIG_DL_HOST_REORDER);
-                       dlhr.hdr.length = cpu_to_le16(
-                               sizeof(dlhr) - sizeof(dlhr.hdr));
-                       dlhr.reorder = 1;
-                       args[argc++] = &dlhr.hdr;
-               }
-       }
-       result = i2400m_set_init_config(i2400m, args, argc);
-       if (result < 0)
-               goto error;
-out_passive:
-       /*
-        * Update state: Here it just calls a get state; parsing the
-        * result (System State TLV and RF Status TLV [done in the rx
-        * path hooks]) will set the hardware and software RF-Kill
-        * status.
-        */
-       result = i2400m_cmd_get_state(i2400m);
-error:
-       if (result < 0)
-               dev_err(dev, "failed to initialize the device: %d\n", result);
-       d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
-       return result;
-}
-
-
-/**
- * i2400m_dev_shutdown - Shutdown a running device
- *
- * @i2400m: device descriptor
- *
- * Release resources acquired during the running of the device; in
- * theory, should also tell the device to go to sleep, switch off the
- * radio, all that, but at this point, in most cases (driver
- * disconnection, reset handling) we can't even talk to the device.
- */
-void i2400m_dev_shutdown(struct i2400m *i2400m)
-{
-       struct device *dev = i2400m_dev(i2400m);
-
-       d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
-       d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
-}
diff --git a/drivers/staging/wimax/i2400m/debug-levels.h b/drivers/staging/wimax/i2400m/debug-levels.h
deleted file mode 100644 (file)
index a317e9f..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Intel Wireless WiMAX Connection 2400m
- * Debug levels control file for the i2400m module
- *
- * Copyright (C) 2007-2008 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- */
-#ifndef __debug_levels__h__
-#define __debug_levels__h__
-
-/* Maximum compile and run time debug level for all submodules */
-#define D_MODULENAME i2400m
-#define D_MASTER CONFIG_WIMAX_I2400M_DEBUG_LEVEL
-
-#include "../linux-wimax-debug.h"
-
-/* List of all the enabled modules */
-enum d_module {
-       D_SUBMODULE_DECLARE(control),
-       D_SUBMODULE_DECLARE(driver),
-       D_SUBMODULE_DECLARE(debugfs),
-       D_SUBMODULE_DECLARE(fw),
-       D_SUBMODULE_DECLARE(netdev),
-       D_SUBMODULE_DECLARE(rfkill),
-       D_SUBMODULE_DECLARE(rx),
-       D_SUBMODULE_DECLARE(sysfs),
-       D_SUBMODULE_DECLARE(tx),
-};
-
-
-#endif /* #ifndef __debug_levels__h__ */
diff --git a/drivers/staging/wimax/i2400m/debugfs.c b/drivers/staging/wimax/i2400m/debugfs.c
deleted file mode 100644 (file)
index 1c640b4..0000000
+++ /dev/null
@@ -1,253 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel Wireless WiMAX Connection 2400m
- * Debugfs interfaces to manipulate driver and device information
- *
- * Copyright (C) 2007 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- */
-
-#include <linux/debugfs.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/spinlock.h>
-#include <linux/device.h>
-#include <linux/export.h>
-#include "i2400m.h"
-
-
-#define D_SUBMODULE debugfs
-#include "debug-levels.h"
-
-static
-int debugfs_netdev_queue_stopped_get(void *data, u64 *val)
-{
-       struct i2400m *i2400m = data;
-       *val = netif_queue_stopped(i2400m->wimax_dev.net_dev);
-       return 0;
-}
-DEFINE_DEBUGFS_ATTRIBUTE(fops_netdev_queue_stopped,
-                       debugfs_netdev_queue_stopped_get,
-                       NULL, "%llu\n");
-
-/*
- * We don't allow partial reads of this file, as then the reader would
- * get weirdly confused data as it is updated.
- *
- * So or you read it all or nothing; if you try to read with an offset
- * != 0, we consider you are done reading.
- */
-static
-ssize_t i2400m_rx_stats_read(struct file *filp, char __user *buffer,
-                            size_t count, loff_t *ppos)
-{
-       struct i2400m *i2400m = filp->private_data;
-       char buf[128];
-       unsigned long flags;
-
-       if (*ppos != 0)
-               return 0;
-       if (count < sizeof(buf))
-               return -ENOSPC;
-       spin_lock_irqsave(&i2400m->rx_lock, flags);
-       snprintf(buf, sizeof(buf), "%u %u %u %u %u %u %u\n",
-                i2400m->rx_pl_num, i2400m->rx_pl_min,
-                i2400m->rx_pl_max, i2400m->rx_num,
-                i2400m->rx_size_acc,
-                i2400m->rx_size_min, i2400m->rx_size_max);
-       spin_unlock_irqrestore(&i2400m->rx_lock, flags);
-       return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
-}
-
-
-/* Any write clears the stats */
-static
-ssize_t i2400m_rx_stats_write(struct file *filp, const char __user *buffer,
-                             size_t count, loff_t *ppos)
-{
-       struct i2400m *i2400m = filp->private_data;
-       unsigned long flags;
-
-       spin_lock_irqsave(&i2400m->rx_lock, flags);
-       i2400m->rx_pl_num = 0;
-       i2400m->rx_pl_max = 0;
-       i2400m->rx_pl_min = UINT_MAX;
-       i2400m->rx_num = 0;
-       i2400m->rx_size_acc = 0;
-       i2400m->rx_size_min = UINT_MAX;
-       i2400m->rx_size_max = 0;
-       spin_unlock_irqrestore(&i2400m->rx_lock, flags);
-       return count;
-}
-
-static
-const struct file_operations i2400m_rx_stats_fops = {
-       .owner =        THIS_MODULE,
-       .open =         simple_open,
-       .read =         i2400m_rx_stats_read,
-       .write =        i2400m_rx_stats_write,
-       .llseek =       default_llseek,
-};
-
-
-/* See i2400m_rx_stats_read() */
-static
-ssize_t i2400m_tx_stats_read(struct file *filp, char __user *buffer,
-                            size_t count, loff_t *ppos)
-{
-       struct i2400m *i2400m = filp->private_data;
-       char buf[128];
-       unsigned long flags;
-
-       if (*ppos != 0)
-               return 0;
-       if (count < sizeof(buf))
-               return -ENOSPC;
-       spin_lock_irqsave(&i2400m->tx_lock, flags);
-       snprintf(buf, sizeof(buf), "%u %u %u %u %u %u %u\n",
-                i2400m->tx_pl_num, i2400m->tx_pl_min,
-                i2400m->tx_pl_max, i2400m->tx_num,
-                i2400m->tx_size_acc,
-                i2400m->tx_size_min, i2400m->tx_size_max);
-       spin_unlock_irqrestore(&i2400m->tx_lock, flags);
-       return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
-}
-
-/* Any write clears the stats */
-static
-ssize_t i2400m_tx_stats_write(struct file *filp, const char __user *buffer,
-                             size_t count, loff_t *ppos)
-{
-       struct i2400m *i2400m = filp->private_data;
-       unsigned long flags;
-
-       spin_lock_irqsave(&i2400m->tx_lock, flags);
-       i2400m->tx_pl_num = 0;
-       i2400m->tx_pl_max = 0;
-       i2400m->tx_pl_min = UINT_MAX;
-       i2400m->tx_num = 0;
-       i2400m->tx_size_acc = 0;
-       i2400m->tx_size_min = UINT_MAX;
-       i2400m->tx_size_max = 0;
-       spin_unlock_irqrestore(&i2400m->tx_lock, flags);
-       return count;
-}
-
-static
-const struct file_operations i2400m_tx_stats_fops = {
-       .owner =        THIS_MODULE,
-       .open =         simple_open,
-       .read =         i2400m_tx_stats_read,
-       .write =        i2400m_tx_stats_write,
-       .llseek =       default_llseek,
-};
-
-
-/* Write 1 to ask the device to go into suspend */
-static
-int debugfs_i2400m_suspend_set(void *data, u64 val)
-{
-       int result;
-       struct i2400m *i2400m = data;
-       result = i2400m_cmd_enter_powersave(i2400m);
-       if (result >= 0)
-               result = 0;
-       return result;
-}
-DEFINE_DEBUGFS_ATTRIBUTE(fops_i2400m_suspend,
-                       NULL, debugfs_i2400m_suspend_set,
-                       "%llu\n");
-
-/*
- * Reset the device
- *
- * Write 0 to ask the device to soft reset, 1 to cold reset, 2 to bus
- * reset (as defined by enum i2400m_reset_type).
- */
-static
-int debugfs_i2400m_reset_set(void *data, u64 val)
-{
-       int result;
-       struct i2400m *i2400m = data;
-       enum i2400m_reset_type rt = val;
-       switch(rt) {
-       case I2400M_RT_WARM:
-       case I2400M_RT_COLD:
-       case I2400M_RT_BUS:
-               result = i2400m_reset(i2400m, rt);
-               if (result >= 0)
-                       result = 0;
-               break;
-       default:
-               result = -EINVAL;
-       }
-       return result;
-}
-DEFINE_DEBUGFS_ATTRIBUTE(fops_i2400m_reset,
-                       NULL, debugfs_i2400m_reset_set,
-                       "%llu\n");
-
-void i2400m_debugfs_add(struct i2400m *i2400m)
-{
-       struct dentry *dentry = i2400m->wimax_dev.debugfs_dentry;
-
-       dentry = debugfs_create_dir("i2400m", dentry);
-       i2400m->debugfs_dentry = dentry;
-
-       d_level_register_debugfs("dl_", control, dentry);
-       d_level_register_debugfs("dl_", driver, dentry);
-       d_level_register_debugfs("dl_", debugfs, dentry);
-       d_level_register_debugfs("dl_", fw, dentry);
-       d_level_register_debugfs("dl_", netdev, dentry);
-       d_level_register_debugfs("dl_", rfkill, dentry);
-       d_level_register_debugfs("dl_", rx, dentry);
-       d_level_register_debugfs("dl_", tx, dentry);
-
-       debugfs_create_size_t("tx_in", 0400, dentry, &i2400m->tx_in);
-       debugfs_create_size_t("tx_out", 0400, dentry, &i2400m->tx_out);
-       debugfs_create_u32("state", 0600, dentry, &i2400m->state);
-
-       /*
-        * Trace received messages from user space
-        *
-        * In order to tap the bidirectional message stream in the
-        * 'msg' pipe, user space can read from the 'msg' pipe;
-        * however, due to limitations in libnl, we can't know what
-        * the different applications are sending down to the kernel.
-        *
-        * So we have this hack where the driver will echo any message
-        * received on the msg pipe from user space [through a call to
-        * wimax_dev->op_msg_from_user() into
-        * i2400m_op_msg_from_user()] into the 'trace' pipe that this
-        * driver creates.
-        *
-        * So then, reading from both the 'trace' and 'msg' pipes in
-        * user space will provide a full dump of the traffic.
-        *
-        * Write 1 to activate, 0 to clear.
-        *
-        * It is not really very atomic, but it is also not too
-        * critical.
-        */
-       debugfs_create_u8("trace_msg_from_user", 0600, dentry,
-                         &i2400m->trace_msg_from_user);
-
-       debugfs_create_file("netdev_queue_stopped", 0400, dentry, i2400m,
-                           &fops_netdev_queue_stopped);
-
-       debugfs_create_file("rx_stats", 0600, dentry, i2400m,
-                           &i2400m_rx_stats_fops);
-
-       debugfs_create_file("tx_stats", 0600, dentry, i2400m,
-                           &i2400m_tx_stats_fops);
-
-       debugfs_create_file("suspend", 0200, dentry, i2400m,
-                           &fops_i2400m_suspend);
-
-       debugfs_create_file("reset", 0200, dentry, i2400m, &fops_i2400m_reset);
-}
-
-void i2400m_debugfs_rm(struct i2400m *i2400m)
-{
-       debugfs_remove_recursive(i2400m->debugfs_dentry);
-}
diff --git a/drivers/staging/wimax/i2400m/driver.c b/drivers/staging/wimax/i2400m/driver.c
deleted file mode 100644 (file)
index f518645..0000000
+++ /dev/null
@@ -1,1003 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel Wireless WiMAX Connection 2400m
- * Generic probe/disconnect, reset and message passing
- *
- * Copyright (C) 2007-2008 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *
- * See i2400m.h for driver documentation. This contains helpers for
- * the driver model glue [_setup()/_release()], handling device resets
- * [_dev_reset_handle()], and the backends for the WiMAX stack ops
- * reset [_op_reset()] and message from user [_op_msg_from_user()].
- *
- * ROADMAP:
- *
- * i2400m_op_msg_from_user()
- *   i2400m_msg_to_dev()
- *   wimax_msg_to_user_send()
- *
- * i2400m_op_reset()
- *   i240m->bus_reset()
- *
- * i2400m_dev_reset_handle()
- *   __i2400m_dev_reset_handle()
- *     __i2400m_dev_stop()
- *     __i2400m_dev_start()
- *
- * i2400m_setup()
- *   i2400m->bus_setup()
- *   i2400m_bootrom_init()
- *   register_netdev()
- *   wimax_dev_add()
- *   i2400m_dev_start()
- *     __i2400m_dev_start()
- *       i2400m_dev_bootstrap()
- *       i2400m_tx_setup()
- *       i2400m->bus_dev_start()
- *       i2400m_firmware_check()
- *       i2400m_check_mac_addr()
- *
- * i2400m_release()
- *   i2400m_dev_stop()
- *     __i2400m_dev_stop()
- *       i2400m_dev_shutdown()
- *       i2400m->bus_dev_stop()
- *       i2400m_tx_release()
- *   i2400m->bus_release()
- *   wimax_dev_rm()
- *   unregister_netdev()
- */
-#include "i2400m.h"
-#include <linux/etherdevice.h>
-#include "linux-wimax-i2400m.h"
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/suspend.h>
-#include <linux/slab.h>
-
-#define D_SUBMODULE driver
-#include "debug-levels.h"
-
-
-static char i2400m_debug_params[128];
-module_param_string(debug, i2400m_debug_params, sizeof(i2400m_debug_params),
-                   0644);
-MODULE_PARM_DESC(debug,
-                "String of space-separated NAME:VALUE pairs, where NAMEs "
-                "are the different debug submodules and VALUE are the "
-                "initial debug value to set.");
-
-static char i2400m_barkers_params[128];
-module_param_string(barkers, i2400m_barkers_params,
-                   sizeof(i2400m_barkers_params), 0644);
-MODULE_PARM_DESC(barkers,
-                "String of comma-separated 32-bit values; each is "
-                "recognized as the value the device sends as a reboot "
-                "signal; values are appended to a list--setting one value "
-                "as zero cleans the existing list and starts a new one.");
-
-/*
- * WiMAX stack operation: relay a message from user space
- *
- * @wimax_dev: device descriptor
- * @pipe_name: named pipe the message is for
- * @msg_buf: pointer to the message bytes
- * @msg_len: length of the buffer
- * @genl_info: passed by the generic netlink layer
- *
- * The WiMAX stack will call this function when a message was received
- * from user space.
- *
- * For the i2400m, this is an L3L4 message, as specified in
- * include/linux/wimax/i2400m.h, and thus prefixed with a 'struct
- * i2400m_l3l4_hdr'. Driver (and device) expect the messages to be
- * coded in Little Endian.
- *
- * This function just verifies that the header declaration and the
- * payload are consistent and then deals with it, either forwarding it
- * to the device or procesing it locally.
- *
- * In the i2400m, messages are basically commands that will carry an
- * ack, so we use i2400m_msg_to_dev() and then deliver the ack back to
- * user space. The rx.c code might intercept the response and use it
- * to update the driver's state, but then it will pass it on so it can
- * be relayed back to user space.
- *
- * Note that asynchronous events from the device are processed and
- * sent to user space in rx.c.
- */
-static
-int i2400m_op_msg_from_user(struct wimax_dev *wimax_dev,
-                           const char *pipe_name,
-                           const void *msg_buf, size_t msg_len,
-                           const struct genl_info *genl_info)
-{
-       int result;
-       struct i2400m *i2400m = wimax_dev_to_i2400m(wimax_dev);
-       struct device *dev = i2400m_dev(i2400m);
-       struct sk_buff *ack_skb;
-
-       d_fnstart(4, dev, "(wimax_dev %p [i2400m %p] msg_buf %p "
-                 "msg_len %zu genl_info %p)\n", wimax_dev, i2400m,
-                 msg_buf, msg_len, genl_info);
-       ack_skb = i2400m_msg_to_dev(i2400m, msg_buf, msg_len);
-       result = PTR_ERR(ack_skb);
-       if (IS_ERR(ack_skb))
-               goto error_msg_to_dev;
-       result = wimax_msg_send(&i2400m->wimax_dev, ack_skb);
-error_msg_to_dev:
-       d_fnend(4, dev, "(wimax_dev %p [i2400m %p] msg_buf %p msg_len %zu "
-               "genl_info %p) = %d\n", wimax_dev, i2400m, msg_buf, msg_len,
-               genl_info, result);
-       return result;
-}
-
-
-/*
- * Context to wait for a reset to finalize
- */
-struct i2400m_reset_ctx {
-       struct completion completion;
-       int result;
-};
-
-
-/*
- * WiMAX stack operation: reset a device
- *
- * @wimax_dev: device descriptor
- *
- * See the documentation for wimax_reset() and wimax_dev->op_reset for
- * the requirements of this function. The WiMAX stack guarantees
- * serialization on calls to this function.
- *
- * Do a warm reset on the device; if it fails, resort to a cold reset
- * and return -ENODEV. On successful warm reset, we need to block
- * until it is complete.
- *
- * The bus-driver implementation of reset takes care of falling back
- * to cold reset if warm fails.
- */
-static
-int i2400m_op_reset(struct wimax_dev *wimax_dev)
-{
-       int result;
-       struct i2400m *i2400m = wimax_dev_to_i2400m(wimax_dev);
-       struct device *dev = i2400m_dev(i2400m);
-       struct i2400m_reset_ctx ctx = {
-               .completion = COMPLETION_INITIALIZER_ONSTACK(ctx.completion),
-               .result = 0,
-       };
-
-       d_fnstart(4, dev, "(wimax_dev %p)\n", wimax_dev);
-       mutex_lock(&i2400m->init_mutex);
-       i2400m->reset_ctx = &ctx;
-       mutex_unlock(&i2400m->init_mutex);
-       result = i2400m_reset(i2400m, I2400M_RT_WARM);
-       if (result < 0)
-               goto out;
-       result = wait_for_completion_timeout(&ctx.completion, 4*HZ);
-       if (result == 0)
-               result = -ETIMEDOUT;
-       else if (result > 0)
-               result = ctx.result;
-       /* if result < 0, pass it on */
-       mutex_lock(&i2400m->init_mutex);
-       i2400m->reset_ctx = NULL;
-       mutex_unlock(&i2400m->init_mutex);
-out:
-       d_fnend(4, dev, "(wimax_dev %p) = %d\n", wimax_dev, result);
-       return result;
-}
-
-
-/*
- * Check the MAC address we got from boot mode is ok
- *
- * @i2400m: device descriptor
- *
- * Returns: 0 if ok, < 0 errno code on error.
- */
-static
-int i2400m_check_mac_addr(struct i2400m *i2400m)
-{
-       int result;
-       struct device *dev = i2400m_dev(i2400m);
-       struct sk_buff *skb;
-       const struct i2400m_tlv_detailed_device_info *ddi;
-       struct net_device *net_dev = i2400m->wimax_dev.net_dev;
-
-       d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
-       skb = i2400m_get_device_info(i2400m);
-       if (IS_ERR(skb)) {
-               result = PTR_ERR(skb);
-               dev_err(dev, "Cannot verify MAC address, error reading: %d\n",
-                       result);
-               goto error;
-       }
-       /* Extract MAC address */
-       ddi = (void *) skb->data;
-       BUILD_BUG_ON(ETH_ALEN != sizeof(ddi->mac_address));
-       d_printf(2, dev, "GET DEVICE INFO: mac addr %pM\n",
-                ddi->mac_address);
-       if (!memcmp(net_dev->perm_addr, ddi->mac_address,
-                  sizeof(ddi->mac_address)))
-               goto ok;
-       dev_warn(dev, "warning: device reports a different MAC address "
-                "to that of boot mode's\n");
-       dev_warn(dev, "device reports     %pM\n", ddi->mac_address);
-       dev_warn(dev, "boot mode reported %pM\n", net_dev->perm_addr);
-       if (is_zero_ether_addr(ddi->mac_address))
-               dev_err(dev, "device reports an invalid MAC address, "
-                       "not updating\n");
-       else {
-               dev_warn(dev, "updating MAC address\n");
-               net_dev->addr_len = ETH_ALEN;
-               memcpy(net_dev->perm_addr, ddi->mac_address, ETH_ALEN);
-               memcpy(net_dev->dev_addr, ddi->mac_address, ETH_ALEN);
-       }
-ok:
-       result = 0;
-       kfree_skb(skb);
-error:
-       d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
-       return result;
-}
-
-
-/**
- * __i2400m_dev_start - Bring up driver communication with the device
- *
- * @i2400m: device descriptor
- * @flags: boot mode flags
- *
- * Returns: 0 if ok, < 0 errno code on error.
- *
- * Uploads firmware and brings up all the resources needed to be able
- * to communicate with the device.
- *
- * The workqueue has to be setup early, at least before RX handling
- * (it's only real user for now) so it can process reports as they
- * arrive. We also want to destroy it if we retry, to make sure it is
- * flushed...easier like this.
- *
- * TX needs to be setup before the bus-specific code (otherwise on
- * shutdown, the bus-tx code could try to access it).
- */
-static
-int __i2400m_dev_start(struct i2400m *i2400m, enum i2400m_bri flags)
-{
-       int result;
-       struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
-       struct net_device *net_dev = wimax_dev->net_dev;
-       struct device *dev = i2400m_dev(i2400m);
-       int times = i2400m->bus_bm_retries;
-
-       d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
-retry:
-       result = i2400m_dev_bootstrap(i2400m, flags);
-       if (result < 0) {
-               dev_err(dev, "cannot bootstrap device: %d\n", result);
-               goto error_bootstrap;
-       }
-       result = i2400m_tx_setup(i2400m);
-       if (result < 0)
-               goto error_tx_setup;
-       result = i2400m_rx_setup(i2400m);
-       if (result < 0)
-               goto error_rx_setup;
-       i2400m->work_queue = create_singlethread_workqueue(wimax_dev->name);
-       if (i2400m->work_queue == NULL) {
-               result = -ENOMEM;
-               dev_err(dev, "cannot create workqueue\n");
-               goto error_create_workqueue;
-       }
-       if (i2400m->bus_dev_start) {
-               result = i2400m->bus_dev_start(i2400m);
-               if (result < 0)
-                       goto error_bus_dev_start;
-       }
-       i2400m->ready = 1;
-       wmb();          /* see i2400m->ready's documentation  */
-       /* process pending reports from the device */
-       queue_work(i2400m->work_queue, &i2400m->rx_report_ws);
-       result = i2400m_firmware_check(i2400m); /* fw versions ok? */
-       if (result < 0)
-               goto error_fw_check;
-       /* At this point is ok to send commands to the device */
-       result = i2400m_check_mac_addr(i2400m);
-       if (result < 0)
-               goto error_check_mac_addr;
-       result = i2400m_dev_initialize(i2400m);
-       if (result < 0)
-               goto error_dev_initialize;
-
-       /* We don't want any additional unwanted error recovery triggered
-        * from any other context so if anything went wrong before we come
-        * here, let's keep i2400m->error_recovery untouched and leave it to
-        * dev_reset_handle(). See dev_reset_handle(). */
-
-       atomic_dec(&i2400m->error_recovery);
-       /* Every thing works so far, ok, now we are ready to
-        * take error recovery if it's required. */
-
-       /* At this point, reports will come for the device and set it
-        * to the right state if it is different than UNINITIALIZED */
-       d_fnend(3, dev, "(net_dev %p [i2400m %p]) = %d\n",
-               net_dev, i2400m, result);
-       return result;
-
-error_dev_initialize:
-error_check_mac_addr:
-error_fw_check:
-       i2400m->ready = 0;
-       wmb();          /* see i2400m->ready's documentation  */
-       flush_workqueue(i2400m->work_queue);
-       if (i2400m->bus_dev_stop)
-               i2400m->bus_dev_stop(i2400m);
-error_bus_dev_start:
-       destroy_workqueue(i2400m->work_queue);
-error_create_workqueue:
-       i2400m_rx_release(i2400m);
-error_rx_setup:
-       i2400m_tx_release(i2400m);
-error_tx_setup:
-error_bootstrap:
-       if (result == -EL3RST && times-- > 0) {
-               flags = I2400M_BRI_SOFT|I2400M_BRI_MAC_REINIT;
-               goto retry;
-       }
-       d_fnend(3, dev, "(net_dev %p [i2400m %p]) = %d\n",
-               net_dev, i2400m, result);
-       return result;
-}
-
-
-static
-int i2400m_dev_start(struct i2400m *i2400m, enum i2400m_bri bm_flags)
-{
-       int result = 0;
-       mutex_lock(&i2400m->init_mutex);        /* Well, start the device */
-       if (i2400m->updown == 0) {
-               result = __i2400m_dev_start(i2400m, bm_flags);
-               if (result >= 0) {
-                       i2400m->updown = 1;
-                       i2400m->alive = 1;
-                       wmb();/* see i2400m->updown and i2400m->alive's doc */
-               }
-       }
-       mutex_unlock(&i2400m->init_mutex);
-       return result;
-}
-
-
-/**
- * i2400m_dev_stop - Tear down driver communication with the device
- *
- * @i2400m: device descriptor
- *
- * Returns: 0 if ok, < 0 errno code on error.
- *
- * Releases all the resources allocated to communicate with the
- * device. Note we cannot destroy the workqueue earlier as until RX is
- * fully destroyed, it could still try to schedule jobs.
- */
-static
-void __i2400m_dev_stop(struct i2400m *i2400m)
-{
-       struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
-       struct device *dev = i2400m_dev(i2400m);
-
-       d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
-       wimax_state_change(wimax_dev, __WIMAX_ST_QUIESCING);
-       i2400m_msg_to_dev_cancel_wait(i2400m, -EL3RST);
-       complete(&i2400m->msg_completion);
-       i2400m_net_wake_stop(i2400m);
-       i2400m_dev_shutdown(i2400m);
-       /*
-        * Make sure no report hooks are running *before* we stop the
-        * communication infrastructure with the device.
-        */
-       i2400m->ready = 0;      /* nobody can queue work anymore */
-       wmb();          /* see i2400m->ready's documentation  */
-       flush_workqueue(i2400m->work_queue);
-
-       if (i2400m->bus_dev_stop)
-               i2400m->bus_dev_stop(i2400m);
-       destroy_workqueue(i2400m->work_queue);
-       i2400m_rx_release(i2400m);
-       i2400m_tx_release(i2400m);
-       wimax_state_change(wimax_dev, WIMAX_ST_DOWN);
-       d_fnend(3, dev, "(i2400m %p) = 0\n", i2400m);
-}
-
-
-/*
- * Watch out -- we only need to stop if there is a need for it. The
- * device could have reset itself and failed to come up again (see
- * _i2400m_dev_reset_handle()).
- */
-static
-void i2400m_dev_stop(struct i2400m *i2400m)
-{
-       mutex_lock(&i2400m->init_mutex);
-       if (i2400m->updown) {
-               __i2400m_dev_stop(i2400m);
-               i2400m->updown = 0;
-               i2400m->alive = 0;
-               wmb();  /* see i2400m->updown and i2400m->alive's doc */
-       }
-       mutex_unlock(&i2400m->init_mutex);
-}
-
-
-/*
- * Listen to PM events to cache the firmware before suspend/hibernation
- *
- * When the device comes out of suspend, it might go into reset and
- * firmware has to be uploaded again. At resume, most of the times, we
- * can't load firmware images from disk, so we need to cache it.
- *
- * i2400m_fw_cache() will allocate a kobject and attach the firmware
- * to it; that way we don't have to worry too much about the fw loader
- * hitting a race condition.
- *
- * Note: modus operandi stolen from the Orinoco driver; thx.
- */
-static
-int i2400m_pm_notifier(struct notifier_block *notifier,
-                      unsigned long pm_event,
-                      void *unused)
-{
-       struct i2400m *i2400m =
-               container_of(notifier, struct i2400m, pm_notifier);
-       struct device *dev = i2400m_dev(i2400m);
-
-       d_fnstart(3, dev, "(i2400m %p pm_event %lx)\n", i2400m, pm_event);
-       switch (pm_event) {
-       case PM_HIBERNATION_PREPARE:
-       case PM_SUSPEND_PREPARE:
-               i2400m_fw_cache(i2400m);
-               break;
-       case PM_POST_RESTORE:
-               /* Restore from hibernation failed. We need to clean
-                * up in exactly the same way, so fall through. */
-       case PM_POST_HIBERNATION:
-       case PM_POST_SUSPEND:
-               i2400m_fw_uncache(i2400m);
-               break;
-
-       case PM_RESTORE_PREPARE:
-       default:
-               break;
-       }
-       d_fnend(3, dev, "(i2400m %p pm_event %lx) = void\n", i2400m, pm_event);
-       return NOTIFY_DONE;
-}
-
-
-/*
- * pre-reset is called before a device is going on reset
- *
- * This has to be followed by a call to i2400m_post_reset(), otherwise
- * bad things might happen.
- */
-int i2400m_pre_reset(struct i2400m *i2400m)
-{
-       struct device *dev = i2400m_dev(i2400m);
-
-       d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
-       d_printf(1, dev, "pre-reset shut down\n");
-
-       mutex_lock(&i2400m->init_mutex);
-       if (i2400m->updown) {
-               netif_tx_disable(i2400m->wimax_dev.net_dev);
-               __i2400m_dev_stop(i2400m);
-               /* down't set updown to zero -- this way
-                * post_reset can restore properly */
-       }
-       mutex_unlock(&i2400m->init_mutex);
-       if (i2400m->bus_release)
-               i2400m->bus_release(i2400m);
-       d_fnend(3, dev, "(i2400m %p) = 0\n", i2400m);
-       return 0;
-}
-EXPORT_SYMBOL_GPL(i2400m_pre_reset);
-
-
-/*
- * Restore device state after a reset
- *
- * Do the work needed after a device reset to bring it up to the same
- * state as it was before the reset.
- *
- * NOTE: this requires i2400m->init_mutex taken
- */
-int i2400m_post_reset(struct i2400m *i2400m)
-{
-       int result = 0;
-       struct device *dev = i2400m_dev(i2400m);
-
-       d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
-       d_printf(1, dev, "post-reset start\n");
-       if (i2400m->bus_setup) {
-               result = i2400m->bus_setup(i2400m);
-               if (result < 0) {
-                       dev_err(dev, "bus-specific setup failed: %d\n",
-                               result);
-                       goto error_bus_setup;
-               }
-       }
-       mutex_lock(&i2400m->init_mutex);
-       if (i2400m->updown) {
-               result = __i2400m_dev_start(
-                       i2400m, I2400M_BRI_SOFT | I2400M_BRI_MAC_REINIT);
-               if (result < 0)
-                       goto error_dev_start;
-       }
-       mutex_unlock(&i2400m->init_mutex);
-       d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
-       return result;
-
-error_dev_start:
-       if (i2400m->bus_release)
-               i2400m->bus_release(i2400m);
-       /* even if the device was up, it could not be recovered, so we
-        * mark it as down. */
-       i2400m->updown = 0;
-       wmb();          /* see i2400m->updown's documentation  */
-       mutex_unlock(&i2400m->init_mutex);
-error_bus_setup:
-       d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
-       return result;
-}
-EXPORT_SYMBOL_GPL(i2400m_post_reset);
-
-
-/*
- * The device has rebooted; fix up the device and the driver
- *
- * Tear down the driver communication with the device, reload the
- * firmware and reinitialize the communication with the device.
- *
- * If someone calls a reset when the device's firmware is down, in
- * theory we won't see it because we are not listening. However, just
- * in case, leave the code to handle it.
- *
- * If there is a reset context, use it; this means someone is waiting
- * for us to tell him when the reset operation is complete and the
- * device is ready to rock again.
- *
- * NOTE: if we are in the process of bringing up or down the
- *       communication with the device [running i2400m_dev_start() or
- *       _stop()], don't do anything, let it fail and handle it.
- *
- * This function is ran always in a thread context
- *
- * This function gets passed, as payload to i2400m_work() a 'const
- * char *' ptr with a "reason" why the reset happened (for messages).
- */
-static
-void __i2400m_dev_reset_handle(struct work_struct *ws)
-{
-       struct i2400m *i2400m = container_of(ws, struct i2400m, reset_ws);
-       const char *reason = i2400m->reset_reason;
-       struct device *dev = i2400m_dev(i2400m);
-       struct i2400m_reset_ctx *ctx = i2400m->reset_ctx;
-       int result;
-
-       d_fnstart(3, dev, "(ws %p i2400m %p reason %s)\n", ws, i2400m, reason);
-
-       i2400m->boot_mode = 1;
-       wmb();          /* Make sure i2400m_msg_to_dev() sees boot_mode */
-
-       result = 0;
-       if (mutex_trylock(&i2400m->init_mutex) == 0) {
-               /* We are still in i2400m_dev_start() [let it fail] or
-                * i2400m_dev_stop() [we are shutting down anyway, so
-                * ignore it] or we are resetting somewhere else. */
-               dev_err(dev, "device rebooted somewhere else?\n");
-               i2400m_msg_to_dev_cancel_wait(i2400m, -EL3RST);
-               complete(&i2400m->msg_completion);
-               goto out;
-       }
-
-       dev_err(dev, "%s: reinitializing driver\n", reason);
-       rmb();
-       if (i2400m->updown) {
-               __i2400m_dev_stop(i2400m);
-               i2400m->updown = 0;
-               wmb();          /* see i2400m->updown's documentation  */
-       }
-
-       if (i2400m->alive) {
-               result = __i2400m_dev_start(i2400m,
-                                   I2400M_BRI_SOFT | I2400M_BRI_MAC_REINIT);
-               if (result < 0) {
-                       dev_err(dev, "%s: cannot start the device: %d\n",
-                               reason, result);
-                       result = -EUCLEAN;
-                       if (atomic_read(&i2400m->bus_reset_retries)
-                                       >= I2400M_BUS_RESET_RETRIES) {
-                               result = -ENODEV;
-                               dev_err(dev, "tried too many times to "
-                                       "reset the device, giving up\n");
-                       }
-               }
-       }
-
-       if (i2400m->reset_ctx) {
-               ctx->result = result;
-               complete(&ctx->completion);
-       }
-       mutex_unlock(&i2400m->init_mutex);
-       if (result == -EUCLEAN) {
-               /*
-                * We come here because the reset during operational mode
-                * wasn't successfully done and need to proceed to a bus
-                * reset. For the dev_reset_handle() to be able to handle
-                * the reset event later properly, we restore boot_mode back
-                * to the state before previous reset. ie: just like we are
-                * issuing the bus reset for the first time
-                */
-               i2400m->boot_mode = 0;
-               wmb();
-
-               atomic_inc(&i2400m->bus_reset_retries);
-               /* ops, need to clean up [w/ init_mutex not held] */
-               result = i2400m_reset(i2400m, I2400M_RT_BUS);
-               if (result >= 0)
-                       result = -ENODEV;
-       } else {
-               rmb();
-               if (i2400m->alive) {
-                       /* great, we expect the device state up and
-                        * dev_start() actually brings the device state up */
-                       i2400m->updown = 1;
-                       wmb();
-                       atomic_set(&i2400m->bus_reset_retries, 0);
-               }
-       }
-out:
-       d_fnend(3, dev, "(ws %p i2400m %p reason %s) = void\n",
-               ws, i2400m, reason);
-}
-
-
-/*
- * i2400m_dev_reset_handle - Handle a device's reset in a thread context
- *
- * Schedule a device reset handling out on a thread context, so it
- * is safe to call from atomic context. We can't use the i2400m's
- * queue as we are going to destroy it and reinitialize it as part of
- * the driver bringup/bringup process.
- *
- * See __i2400m_dev_reset_handle() for details; that takes care of
- * reinitializing the driver to handle the reset, calling into the
- * bus-specific functions ops as needed.
- */
-int i2400m_dev_reset_handle(struct i2400m *i2400m, const char *reason)
-{
-       i2400m->reset_reason = reason;
-       return schedule_work(&i2400m->reset_ws);
-}
-EXPORT_SYMBOL_GPL(i2400m_dev_reset_handle);
-
-
-/*
- * The actual work of error recovery.
- *
- * The current implementation of error recovery is to trigger a bus reset.
- */
-static
-void __i2400m_error_recovery(struct work_struct *ws)
-{
-       struct i2400m *i2400m = container_of(ws, struct i2400m, recovery_ws);
-
-       i2400m_reset(i2400m, I2400M_RT_BUS);
-}
-
-/*
- * Schedule a work struct for error recovery.
- *
- * The intention of error recovery is to bring back the device to some
- * known state whenever TX sees -110 (-ETIMEOUT) on copying the data to
- * the device. The TX failure could mean a device bus stuck, so the current
- * error recovery implementation is to trigger a bus reset to the device
- * and hopefully it can bring back the device.
- *
- * The actual work of error recovery has to be in a thread context because
- * it is kicked off in the TX thread (i2400ms->tx_workqueue) which is to be
- * destroyed by the error recovery mechanism (currently a bus reset).
- *
- * Also, there may be already a queue of TX works that all hit
- * the -ETIMEOUT error condition because the device is stuck already.
- * Since bus reset is used as the error recovery mechanism and we don't
- * want consecutive bus resets simply because the multiple TX works
- * in the queue all hit the same device erratum, the flag "error_recovery"
- * is introduced for preventing unwanted consecutive bus resets.
- *
- * Error recovery shall only be invoked again if previous one was completed.
- * The flag error_recovery is set when error recovery mechanism is scheduled,
- * and is checked when we need to schedule another error recovery. If it is
- * in place already, then we shouldn't schedule another one.
- */
-void i2400m_error_recovery(struct i2400m *i2400m)
-{
-       if (atomic_add_return(1, &i2400m->error_recovery) == 1)
-               schedule_work(&i2400m->recovery_ws);
-       else
-               atomic_dec(&i2400m->error_recovery);
-}
-EXPORT_SYMBOL_GPL(i2400m_error_recovery);
-
-/*
- * Alloc the command and ack buffers for boot mode
- *
- * Get the buffers needed to deal with boot mode messages.
- */
-static
-int i2400m_bm_buf_alloc(struct i2400m *i2400m)
-{
-       i2400m->bm_cmd_buf = kzalloc(I2400M_BM_CMD_BUF_SIZE, GFP_KERNEL);
-       if (i2400m->bm_cmd_buf == NULL)
-               goto error_bm_cmd_kzalloc;
-       i2400m->bm_ack_buf = kzalloc(I2400M_BM_ACK_BUF_SIZE, GFP_KERNEL);
-       if (i2400m->bm_ack_buf == NULL)
-               goto error_bm_ack_buf_kzalloc;
-       return 0;
-
-error_bm_ack_buf_kzalloc:
-       kfree(i2400m->bm_cmd_buf);
-error_bm_cmd_kzalloc:
-       return -ENOMEM;
-}
-
-
-/*
- * Free boot mode command and ack buffers.
- */
-static
-void i2400m_bm_buf_free(struct i2400m *i2400m)
-{
-       kfree(i2400m->bm_ack_buf);
-       kfree(i2400m->bm_cmd_buf);
-}
-
-
-/*
- * i2400m_init - Initialize a 'struct i2400m' from all zeroes
- *
- * This is a bus-generic API call.
- */
-void i2400m_init(struct i2400m *i2400m)
-{
-       wimax_dev_init(&i2400m->wimax_dev);
-
-       i2400m->boot_mode = 1;
-       i2400m->rx_reorder = 1;
-       init_waitqueue_head(&i2400m->state_wq);
-
-       spin_lock_init(&i2400m->tx_lock);
-       i2400m->tx_pl_min = UINT_MAX;
-       i2400m->tx_size_min = UINT_MAX;
-
-       spin_lock_init(&i2400m->rx_lock);
-       i2400m->rx_pl_min = UINT_MAX;
-       i2400m->rx_size_min = UINT_MAX;
-       INIT_LIST_HEAD(&i2400m->rx_reports);
-       INIT_WORK(&i2400m->rx_report_ws, i2400m_report_hook_work);
-
-       mutex_init(&i2400m->msg_mutex);
-       init_completion(&i2400m->msg_completion);
-
-       mutex_init(&i2400m->init_mutex);
-       /* wake_tx_ws is initialized in i2400m_tx_setup() */
-
-       INIT_WORK(&i2400m->reset_ws, __i2400m_dev_reset_handle);
-       INIT_WORK(&i2400m->recovery_ws, __i2400m_error_recovery);
-
-       atomic_set(&i2400m->bus_reset_retries, 0);
-
-       i2400m->alive = 0;
-
-       /* initialize error_recovery to 1 for denoting we
-        * are not yet ready to take any error recovery */
-       atomic_set(&i2400m->error_recovery, 1);
-}
-EXPORT_SYMBOL_GPL(i2400m_init);
-
-
-int i2400m_reset(struct i2400m *i2400m, enum i2400m_reset_type rt)
-{
-       struct net_device *net_dev = i2400m->wimax_dev.net_dev;
-
-       /*
-        * Make sure we stop TXs and down the carrier before
-        * resetting; this is needed to avoid things like
-        * i2400m_wake_tx() scheduling stuff in parallel.
-        */
-       if (net_dev->reg_state == NETREG_REGISTERED) {
-               netif_tx_disable(net_dev);
-               netif_carrier_off(net_dev);
-       }
-       return i2400m->bus_reset(i2400m, rt);
-}
-EXPORT_SYMBOL_GPL(i2400m_reset);
-
-
-/**
- * i2400m_setup - bus-generic setup function for the i2400m device
- *
- * @i2400m: device descriptor (bus-specific parts have been initialized)
- * @bm_flags: boot mode flags
- *
- * Returns: 0 if ok, < 0 errno code on error.
- *
- * Sets up basic device comunication infrastructure, boots the ROM to
- * read the MAC address, registers with the WiMAX and network stacks
- * and then brings up the device.
- */
-int i2400m_setup(struct i2400m *i2400m, enum i2400m_bri bm_flags)
-{
-       int result;
-       struct device *dev = i2400m_dev(i2400m);
-       struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
-       struct net_device *net_dev = i2400m->wimax_dev.net_dev;
-
-       d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
-
-       snprintf(wimax_dev->name, sizeof(wimax_dev->name),
-                "i2400m-%s:%s", dev->bus->name, dev_name(dev));
-
-       result = i2400m_bm_buf_alloc(i2400m);
-       if (result < 0) {
-               dev_err(dev, "cannot allocate bootmode scratch buffers\n");
-               goto error_bm_buf_alloc;
-       }
-
-       if (i2400m->bus_setup) {
-               result = i2400m->bus_setup(i2400m);
-               if (result < 0) {
-                       dev_err(dev, "bus-specific setup failed: %d\n",
-                               result);
-                       goto error_bus_setup;
-               }
-       }
-
-       result = i2400m_bootrom_init(i2400m, bm_flags);
-       if (result < 0) {
-               dev_err(dev, "read mac addr: bootrom init "
-                       "failed: %d\n", result);
-               goto error_bootrom_init;
-       }
-       result = i2400m_read_mac_addr(i2400m);
-       if (result < 0)
-               goto error_read_mac_addr;
-       eth_random_addr(i2400m->src_mac_addr);
-
-       i2400m->pm_notifier.notifier_call = i2400m_pm_notifier;
-       register_pm_notifier(&i2400m->pm_notifier);
-
-       result = register_netdev(net_dev);      /* Okey dokey, bring it up */
-       if (result < 0) {
-               dev_err(dev, "cannot register i2400m network device: %d\n",
-                       result);
-               goto error_register_netdev;
-       }
-       netif_carrier_off(net_dev);
-
-       i2400m->wimax_dev.op_msg_from_user = i2400m_op_msg_from_user;
-       i2400m->wimax_dev.op_rfkill_sw_toggle = i2400m_op_rfkill_sw_toggle;
-       i2400m->wimax_dev.op_reset = i2400m_op_reset;
-
-       result = wimax_dev_add(&i2400m->wimax_dev, net_dev);
-       if (result < 0)
-               goto error_wimax_dev_add;
-
-       /* Now setup all that requires a registered net and wimax device. */
-       result = sysfs_create_group(&net_dev->dev.kobj, &i2400m_dev_attr_group);
-       if (result < 0) {
-               dev_err(dev, "cannot setup i2400m's sysfs: %d\n", result);
-               goto error_sysfs_setup;
-       }
-
-       i2400m_debugfs_add(i2400m);
-
-       result = i2400m_dev_start(i2400m, bm_flags);
-       if (result < 0)
-               goto error_dev_start;
-       d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
-       return result;
-
-error_dev_start:
-       i2400m_debugfs_rm(i2400m);
-       sysfs_remove_group(&i2400m->wimax_dev.net_dev->dev.kobj,
-                          &i2400m_dev_attr_group);
-error_sysfs_setup:
-       wimax_dev_rm(&i2400m->wimax_dev);
-error_wimax_dev_add:
-       unregister_netdev(net_dev);
-error_register_netdev:
-       unregister_pm_notifier(&i2400m->pm_notifier);
-error_read_mac_addr:
-error_bootrom_init:
-       if (i2400m->bus_release)
-               i2400m->bus_release(i2400m);
-error_bus_setup:
-       i2400m_bm_buf_free(i2400m);
-error_bm_buf_alloc:
-       d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
-       return result;
-}
-EXPORT_SYMBOL_GPL(i2400m_setup);
-
-
-/*
- * i2400m_release - release the bus-generic driver resources
- *
- * Sends a disconnect message and undoes any setup done by i2400m_setup()
- */
-void i2400m_release(struct i2400m *i2400m)
-{
-       struct device *dev = i2400m_dev(i2400m);
-
-       d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
-       netif_stop_queue(i2400m->wimax_dev.net_dev);
-
-       i2400m_dev_stop(i2400m);
-
-       cancel_work_sync(&i2400m->reset_ws);
-       cancel_work_sync(&i2400m->recovery_ws);
-
-       i2400m_debugfs_rm(i2400m);
-       sysfs_remove_group(&i2400m->wimax_dev.net_dev->dev.kobj,
-                          &i2400m_dev_attr_group);
-       wimax_dev_rm(&i2400m->wimax_dev);
-       unregister_netdev(i2400m->wimax_dev.net_dev);
-       unregister_pm_notifier(&i2400m->pm_notifier);
-       if (i2400m->bus_release)
-               i2400m->bus_release(i2400m);
-       i2400m_bm_buf_free(i2400m);
-       d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
-}
-EXPORT_SYMBOL_GPL(i2400m_release);
-
-
-/*
- * Debug levels control; see debug.h
- */
-struct d_level D_LEVEL[] = {
-       D_SUBMODULE_DEFINE(control),
-       D_SUBMODULE_DEFINE(driver),
-       D_SUBMODULE_DEFINE(debugfs),
-       D_SUBMODULE_DEFINE(fw),
-       D_SUBMODULE_DEFINE(netdev),
-       D_SUBMODULE_DEFINE(rfkill),
-       D_SUBMODULE_DEFINE(rx),
-       D_SUBMODULE_DEFINE(sysfs),
-       D_SUBMODULE_DEFINE(tx),
-};
-size_t D_LEVEL_SIZE = ARRAY_SIZE(D_LEVEL);
-
-
-static
-int __init i2400m_driver_init(void)
-{
-       d_parse_params(D_LEVEL, D_LEVEL_SIZE, i2400m_debug_params,
-                      "i2400m.debug");
-       return i2400m_barker_db_init(i2400m_barkers_params);
-}
-module_init(i2400m_driver_init);
-
-static
-void __exit i2400m_driver_exit(void)
-{
-       i2400m_barker_db_exit();
-}
-module_exit(i2400m_driver_exit);
-
-MODULE_AUTHOR("Intel Corporation <linux-wimax@intel.com>");
-MODULE_DESCRIPTION("Intel 2400M WiMAX networking bus-generic driver");
-MODULE_LICENSE("GPL");
diff --git a/drivers/staging/wimax/i2400m/fw.c b/drivers/staging/wimax/i2400m/fw.c
deleted file mode 100644 (file)
index 75df071..0000000
+++ /dev/null
@@ -1,1666 +0,0 @@
-/*
- * Intel Wireless WiMAX Connection 2400m
- * Firmware uploader
- *
- *
- * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   * Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in
- *     the documentation and/or other materials provided with the
- *     distribution.
- *   * Neither the name of Intel Corporation nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *
- * Intel Corporation <linux-wimax@intel.com>
- * Yanir Lubetkin <yanirx.lubetkin@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *  - Initial implementation
- *
- *
- * THE PROCEDURE
- *
- * The 2400m and derived devices work in two modes: boot-mode or
- * normal mode. In boot mode we can execute only a handful of commands
- * targeted at uploading the firmware and launching it.
- *
- * The 2400m enters boot mode when it is first connected to the
- * system, when it crashes and when you ask it to reboot. There are
- * two submodes of the boot mode: signed and non-signed. Signed takes
- * firmwares signed with a certain private key, non-signed takes any
- * firmware. Normal hardware takes only signed firmware.
- *
- * On boot mode, in USB, we write to the device using the bulk out
- * endpoint and read from it in the notification endpoint.
- *
- * Upon entrance to boot mode, the device sends (preceded with a few
- * zero length packets (ZLPs) on the notification endpoint in USB) a
- * reboot barker (4 le32 words with the same value). We ack it by
- * sending the same barker to the device. The device acks with a
- * reboot ack barker (4 le32 words with value I2400M_ACK_BARKER) and
- * then is fully booted. At this point we can upload the firmware.
- *
- * Note that different iterations of the device and EEPROM
- * configurations will send different [re]boot barkers; these are
- * collected in i2400m_barker_db along with the firmware
- * characteristics they require.
- *
- * This process is accomplished by the i2400m_bootrom_init()
- * function. All the device interaction happens through the
- * i2400m_bm_cmd() [boot mode command]. Special return values will
- * indicate if the device did reset during the process.
- *
- * After this, we read the MAC address and then (if needed)
- * reinitialize the device. We need to read it ahead of time because
- * in the future, we might not upload the firmware until userspace
- * 'ifconfig up's the device.
- *
- * We can then upload the firmware file. The file is composed of a BCF
- * header (basic data, keys and signatures) and a list of write
- * commands and payloads. Optionally more BCF headers might follow the
- * main payload. We first upload the header [i2400m_dnload_init()] and
- * then pass the commands and payloads verbatim to the i2400m_bm_cmd()
- * function [i2400m_dnload_bcf()]. Then we tell the device to jump to
- * the new firmware [i2400m_dnload_finalize()].
- *
- * Once firmware is uploaded, we are good to go :)
- *
- * When we don't know in which mode we are, we first try by sending a
- * warm reset request that will take us to boot-mode. If we time out
- * waiting for a reboot barker, that means maybe we are already in
- * boot mode, so we send a reboot barker.
- *
- * COMMAND EXECUTION
- *
- * This code (and process) is single threaded; for executing commands,
- * we post a URB to the notification endpoint, post the command, wait
- * for data on the notification buffer. We don't need to worry about
- * others as we know we are the only ones in there.
- *
- * BACKEND IMPLEMENTATION
- *
- * This code is bus-generic; the bus-specific driver provides back end
- * implementations to send a boot mode command to the device and to
- * read an acknolwedgement from it (or an asynchronous notification)
- * from it.
- *
- * FIRMWARE LOADING
- *
- * Note that in some cases, we can't just load a firmware file (for
- * example, when resuming). For that, we might cache the firmware
- * file. Thus, when doing the bootstrap, if there is a cache firmware
- * file, it is used; if not, loading from disk is attempted.
- *
- * ROADMAP
- *
- * i2400m_barker_db_init              Called by i2400m_driver_init()
- *   i2400m_barker_db_add
- *
- * i2400m_barker_db_exit              Called by i2400m_driver_exit()
- *
- * i2400m_dev_bootstrap               Called by __i2400m_dev_start()
- *   request_firmware
- *   i2400m_fw_bootstrap
- *     i2400m_fw_check
- *       i2400m_fw_hdr_check
- *     i2400m_fw_dnload
- *   release_firmware
- *
- * i2400m_fw_dnload
- *   i2400m_bootrom_init
- *     i2400m_bm_cmd
- *     i2400m_reset
- *   i2400m_dnload_init
- *     i2400m_dnload_init_signed
- *     i2400m_dnload_init_nonsigned
- *       i2400m_download_chunk
- *         i2400m_bm_cmd
- *   i2400m_dnload_bcf
- *     i2400m_bm_cmd
- *   i2400m_dnload_finalize
- *     i2400m_bm_cmd
- *
- * i2400m_bm_cmd
- *   i2400m->bus_bm_cmd_send()
- *   i2400m->bus_bm_wait_for_ack
- *   __i2400m_bm_ack_verify
- *     i2400m_is_boot_barker
- *
- * i2400m_bm_cmd_prepare              Used by bus-drivers to prep
- *                                    commands before sending
- *
- * i2400m_pm_notifier                 Called on Power Management events
- *   i2400m_fw_cache
- *   i2400m_fw_uncache
- */
-#include <linux/firmware.h>
-#include <linux/sched.h>
-#include <linux/slab.h>
-#include <linux/usb.h>
-#include <linux/export.h>
-#include "i2400m.h"
-
-
-#define D_SUBMODULE fw
-#include "debug-levels.h"
-
-
-static const __le32 i2400m_ACK_BARKER[4] = {
-       cpu_to_le32(I2400M_ACK_BARKER),
-       cpu_to_le32(I2400M_ACK_BARKER),
-       cpu_to_le32(I2400M_ACK_BARKER),
-       cpu_to_le32(I2400M_ACK_BARKER)
-};
-
-
-/**
- * Prepare a boot-mode command for delivery
- *
- * @cmd: pointer to bootrom header to prepare
- *
- * Computes checksum if so needed. After calling this function, DO NOT
- * modify the command or header as the checksum won't work anymore.
- *
- * We do it from here because some times we cannot do it in the
- * original context the command was sent (it is a const), so when we
- * copy it to our staging buffer, we add the checksum there.
- */
-void i2400m_bm_cmd_prepare(struct i2400m_bootrom_header *cmd)
-{
-       if (i2400m_brh_get_use_checksum(cmd)) {
-               int i;
-               __le32 checksum = 0;
-               const u32 *checksum_ptr = (void *) cmd->payload;
-
-               for (i = 0; i < le32_to_cpu(cmd->data_size) / 4; i++)
-                       le32_add_cpu(&checksum, *checksum_ptr++);
-
-               le32_add_cpu(&checksum, le32_to_cpu(cmd->command));
-               le32_add_cpu(&checksum, le32_to_cpu(cmd->target_addr));
-               le32_add_cpu(&checksum, le32_to_cpu(cmd->data_size));
-
-               cmd->block_checksum = checksum;
-       }
-}
-EXPORT_SYMBOL_GPL(i2400m_bm_cmd_prepare);
-
-
-/*
- * Database of known barkers.
- *
- * A barker is what the device sends indicating he is ready to be
- * bootloaded. Different versions of the device will send different
- * barkers. Depending on the barker, it might mean the device wants
- * some kind of firmware or the other.
- */
-static struct i2400m_barker_db {
-       __le32 data[4];
-} *i2400m_barker_db;
-static size_t i2400m_barker_db_used, i2400m_barker_db_size;
-
-
-static
-int i2400m_zrealloc_2x(void **ptr, size_t *_count, size_t el_size,
-                      gfp_t gfp_flags)
-{
-       size_t old_count = *_count,
-               new_count = old_count ? 2 * old_count : 2,
-               old_size = el_size * old_count,
-               new_size = el_size * new_count;
-       void *nptr = krealloc(*ptr, new_size, gfp_flags);
-       if (nptr) {
-               /* zero the other half or the whole thing if old_count
-                * was zero */
-               if (old_size == 0)
-                       memset(nptr, 0, new_size);
-               else
-                       memset(nptr + old_size, 0, old_size);
-               *_count = new_count;
-               *ptr = nptr;
-               return 0;
-       } else
-               return -ENOMEM;
-}
-
-
-/*
- * Add a barker to the database
- *
- * This cannot used outside of this module and only at at module_init
- * time. This is to avoid the need to do locking.
- */
-static
-int i2400m_barker_db_add(u32 barker_id)
-{
-       int result;
-
-       struct i2400m_barker_db *barker;
-       if (i2400m_barker_db_used >= i2400m_barker_db_size) {
-               result = i2400m_zrealloc_2x(
-                       (void **) &i2400m_barker_db, &i2400m_barker_db_size,
-                       sizeof(i2400m_barker_db[0]), GFP_KERNEL);
-               if (result < 0)
-                       return result;
-       }
-       barker = i2400m_barker_db + i2400m_barker_db_used++;
-       barker->data[0] = cpu_to_le32(barker_id);
-       barker->data[1] = cpu_to_le32(barker_id);
-       barker->data[2] = cpu_to_le32(barker_id);
-       barker->data[3] = cpu_to_le32(barker_id);
-       return 0;
-}
-
-
-void i2400m_barker_db_exit(void)
-{
-       kfree(i2400m_barker_db);
-       i2400m_barker_db = NULL;
-       i2400m_barker_db_size = 0;
-       i2400m_barker_db_used = 0;
-}
-
-
-/*
- * Helper function to add all the known stable barkers to the barker
- * database.
- */
-static
-int i2400m_barker_db_known_barkers(void)
-{
-       int result;
-
-       result = i2400m_barker_db_add(I2400M_NBOOT_BARKER);
-       if (result < 0)
-               goto error_add;
-       result = i2400m_barker_db_add(I2400M_SBOOT_BARKER);
-       if (result < 0)
-               goto error_add;
-       result = i2400m_barker_db_add(I2400M_SBOOT_BARKER_6050);
-       if (result < 0)
-               goto error_add;
-error_add:
-       return result;
-}
-
-
-/*
- * Initialize the barker database
- *
- * This can only be used from the module_init function for this
- * module; this is to avoid the need to do locking.
- *
- * @options: command line argument with extra barkers to
- *     recognize. This is a comma-separated list of 32-bit hex
- *     numbers. They are appended to the existing list. Setting 0
- *     cleans the existing list and starts a new one.
- */
-int i2400m_barker_db_init(const char *_options)
-{
-       int result;
-       char *options = NULL, *options_orig, *token;
-
-       i2400m_barker_db = NULL;
-       i2400m_barker_db_size = 0;
-       i2400m_barker_db_used = 0;
-
-       result = i2400m_barker_db_known_barkers();
-       if (result < 0)
-               goto error_add;
-       /* parse command line options from i2400m.barkers */
-       if (_options != NULL) {
-               unsigned barker;
-
-               options_orig = kstrdup(_options, GFP_KERNEL);
-               if (options_orig == NULL) {
-                       result = -ENOMEM;
-                       goto error_parse;
-               }
-               options = options_orig;
-
-               while ((token = strsep(&options, ",")) != NULL) {
-                       if (*token == '\0')     /* eat joint commas */
-                               continue;
-                       if (sscanf(token, "%x", &barker) != 1
-                           || barker > 0xffffffff) {
-                               printk(KERN_ERR "%s: can't recognize "
-                                      "i2400m.barkers value '%s' as "
-                                      "a 32-bit number\n",
-                                      __func__, token);
-                               result = -EINVAL;
-                               goto error_parse;
-                       }
-                       if (barker == 0) {
-                               /* clean list and start new */
-                               i2400m_barker_db_exit();
-                               continue;
-                       }
-                       result = i2400m_barker_db_add(barker);
-                       if (result < 0)
-                               goto error_parse_add;
-               }
-               kfree(options_orig);
-       }
-       return 0;
-
-error_parse_add:
-error_parse:
-       kfree(options_orig);
-error_add:
-       kfree(i2400m_barker_db);
-       return result;
-}
-
-
-/*
- * Recognize a boot barker
- *
- * @buf: buffer where the boot barker.
- * @buf_size: size of the buffer (has to be 16 bytes). It is passed
- *     here so the function can check it for the caller.
- *
- * Note that as a side effect, upon identifying the obtained boot
- * barker, this function will set i2400m->barker to point to the right
- * barker database entry. Subsequent calls to the function will result
- * in verifying that the same type of boot barker is returned when the
- * device [re]boots (as long as the same device instance is used).
- *
- * Return: 0 if @buf matches a known boot barker. -ENOENT if the
- *     buffer in @buf doesn't match any boot barker in the database or
- *     -EILSEQ if the buffer doesn't have the right size.
- */
-int i2400m_is_boot_barker(struct i2400m *i2400m,
-                         const void *buf, size_t buf_size)
-{
-       int result;
-       struct device *dev = i2400m_dev(i2400m);
-       struct i2400m_barker_db *barker;
-       int i;
-
-       result = -ENOENT;
-       if (buf_size != sizeof(i2400m_barker_db[i].data))
-               return result;
-
-       /* Short circuit if we have already discovered the barker
-        * associated with the device. */
-       if (i2400m->barker &&
-           !memcmp(buf, i2400m->barker, sizeof(i2400m->barker->data)))
-               return 0;
-
-       for (i = 0; i < i2400m_barker_db_used; i++) {
-               barker = &i2400m_barker_db[i];
-               BUILD_BUG_ON(sizeof(barker->data) != 16);
-               if (memcmp(buf, barker->data, sizeof(barker->data)))
-                       continue;
-
-               if (i2400m->barker == NULL) {
-                       i2400m->barker = barker;
-                       d_printf(1, dev, "boot barker set to #%u/%08x\n",
-                                i, le32_to_cpu(barker->data[0]));
-                       if (barker->data[0] == le32_to_cpu(I2400M_NBOOT_BARKER))
-                               i2400m->sboot = 0;
-                       else
-                               i2400m->sboot = 1;
-               } else if (i2400m->barker != barker) {
-                       dev_err(dev, "HW inconsistency: device "
-                               "reports a different boot barker "
-                               "than set (from %08x to %08x)\n",
-                               le32_to_cpu(i2400m->barker->data[0]),
-                               le32_to_cpu(barker->data[0]));
-                       result = -EIO;
-               } else
-                       d_printf(2, dev, "boot barker confirmed #%u/%08x\n",
-                                i, le32_to_cpu(barker->data[0]));
-               result = 0;
-               break;
-       }
-       return result;
-}
-EXPORT_SYMBOL_GPL(i2400m_is_boot_barker);
-
-
-/*
- * Verify the ack data received
- *
- * Given a reply to a boot mode command, chew it and verify everything
- * is ok.
- *
- * @opcode: opcode which generated this ack. For error messages.
- * @ack: pointer to ack data we received
- * @ack_size: size of that data buffer
- * @flags: I2400M_BM_CMD_* flags we called the command with.
- *
- * Way too long function -- maybe it should be further split
- */
-static
-ssize_t __i2400m_bm_ack_verify(struct i2400m *i2400m, int opcode,
-                              struct i2400m_bootrom_header *ack,
-                              size_t ack_size, int flags)
-{
-       ssize_t result = -ENOMEM;
-       struct device *dev = i2400m_dev(i2400m);
-
-       d_fnstart(8, dev, "(i2400m %p opcode %d ack %p size %zu)\n",
-                 i2400m, opcode, ack, ack_size);
-       if (ack_size < sizeof(*ack)) {
-               result = -EIO;
-               dev_err(dev, "boot-mode cmd %d: HW BUG? notification didn't "
-                       "return enough data (%zu bytes vs %zu expected)\n",
-                       opcode, ack_size, sizeof(*ack));
-               goto error_ack_short;
-       }
-       result = i2400m_is_boot_barker(i2400m, ack, ack_size);
-       if (result >= 0) {
-               result = -ERESTARTSYS;
-               d_printf(6, dev, "boot-mode cmd %d: HW boot barker\n", opcode);
-               goto error_reboot;
-       }
-       if (ack_size == sizeof(i2400m_ACK_BARKER)
-                && memcmp(ack, i2400m_ACK_BARKER, sizeof(*ack)) == 0) {
-               result = -EISCONN;
-               d_printf(3, dev, "boot-mode cmd %d: HW reboot ack barker\n",
-                        opcode);
-               goto error_reboot_ack;
-       }
-       result = 0;
-       if (flags & I2400M_BM_CMD_RAW)
-               goto out_raw;
-       ack->data_size = le32_to_cpu(ack->data_size);
-       ack->target_addr = le32_to_cpu(ack->target_addr);
-       ack->block_checksum = le32_to_cpu(ack->block_checksum);
-       d_printf(5, dev, "boot-mode cmd %d: notification for opcode %u "
-                "response %u csum %u rr %u da %u\n",
-                opcode, i2400m_brh_get_opcode(ack),
-                i2400m_brh_get_response(ack),
-                i2400m_brh_get_use_checksum(ack),
-                i2400m_brh_get_response_required(ack),
-                i2400m_brh_get_direct_access(ack));
-       result = -EIO;
-       if (i2400m_brh_get_signature(ack) != 0xcbbc) {
-               dev_err(dev, "boot-mode cmd %d: HW BUG? wrong signature "
-                       "0x%04x\n", opcode, i2400m_brh_get_signature(ack));
-               goto error_ack_signature;
-       }
-       if (opcode != -1 && opcode != i2400m_brh_get_opcode(ack)) {
-               dev_err(dev, "boot-mode cmd %d: HW BUG? "
-                       "received response for opcode %u, expected %u\n",
-                       opcode, i2400m_brh_get_opcode(ack), opcode);
-               goto error_ack_opcode;
-       }
-       if (i2400m_brh_get_response(ack) != 0) {        /* failed? */
-               dev_err(dev, "boot-mode cmd %d: error; hw response %u\n",
-                       opcode, i2400m_brh_get_response(ack));
-               goto error_ack_failed;
-       }
-       if (ack_size < le32_to_cpu(ack->data_size) + sizeof(*ack)) {
-               dev_err(dev, "boot-mode cmd %d: SW BUG "
-                       "driver provided only %zu bytes for %zu bytes "
-                       "of data\n", opcode, ack_size,
-                       (size_t) le32_to_cpu(ack->data_size) + sizeof(*ack));
-               goto error_ack_short_buffer;
-       }
-       result = ack_size;
-       /* Don't you love this stack of empty targets? Well, I don't
-        * either, but it helps track exactly who comes in here and
-        * why :) */
-error_ack_short_buffer:
-error_ack_failed:
-error_ack_opcode:
-error_ack_signature:
-out_raw:
-error_reboot_ack:
-error_reboot:
-error_ack_short:
-       d_fnend(8, dev, "(i2400m %p opcode %d ack %p size %zu) = %d\n",
-               i2400m, opcode, ack, ack_size, (int) result);
-       return result;
-}
-
-
-/**
- * i2400m_bm_cmd - Execute a boot mode command
- *
- * @i2400m: device descriptor
- * @cmd: buffer containing the command data (pointing at the header).
- *     This data can be ANYWHERE (for USB, we will copy it to an
- *     specific buffer). Make sure everything is in proper little
- *     endian.
- *
- *     A raw buffer can be also sent, just cast it and set flags to
- *     I2400M_BM_CMD_RAW.
- *
- *     This function will generate a checksum for you if the
- *     checksum bit in the command is set (unless I2400M_BM_CMD_RAW
- *     is set).
- *
- *     You can use the i2400m->bm_cmd_buf to stage your commands and
- *     send them.
- *
- *     If NULL, no command is sent (we just wait for an ack).
- *
- * @cmd_size: size of the command. Will be auto padded to the
- *     bus-specific drivers padding requirements.
- *
- * @ack: buffer where to place the acknowledgement. If it is a regular
- *     command response, all fields will be returned with the right,
- *     native endianess.
- *
- *     You *cannot* use i2400m->bm_ack_buf for this buffer.
- *
- * @ack_size: size of @ack, 16 aligned; you need to provide at least
- *     sizeof(*ack) bytes and then enough to contain the return data
- *     from the command
- *
- * @flags: see I2400M_BM_CMD_* above.
- *
- * Returns: bytes received by the notification; if < 0, an errno code
- *     denoting an error or:
- *
- *     -ERESTARTSYS  The device has rebooted
- *
- * Executes a boot-mode command and waits for a response, doing basic
- * validation on it; if a zero length response is received, it retries
- * waiting for a response until a non-zero one is received (timing out
- * after %I2400M_BOOT_RETRIES retries).
- */
-static
-ssize_t i2400m_bm_cmd(struct i2400m *i2400m,
-                     const struct i2400m_bootrom_header *cmd, size_t cmd_size,
-                     struct i2400m_bootrom_header *ack, size_t ack_size,
-                     int flags)
-{
-       ssize_t result, rx_bytes;
-       struct device *dev = i2400m_dev(i2400m);
-       int opcode = cmd == NULL ? -1 : i2400m_brh_get_opcode(cmd);
-
-       d_fnstart(6, dev, "(i2400m %p cmd %p size %zu ack %p size %zu)\n",
-                 i2400m, cmd, cmd_size, ack, ack_size);
-       BUG_ON(ack_size < sizeof(*ack));
-       BUG_ON(i2400m->boot_mode == 0);
-
-       if (cmd != NULL) {              /* send the command */
-               result = i2400m->bus_bm_cmd_send(i2400m, cmd, cmd_size, flags);
-               if (result < 0)
-                       goto error_cmd_send;
-               if ((flags & I2400M_BM_CMD_RAW) == 0)
-                       d_printf(5, dev,
-                                "boot-mode cmd %d csum %u rr %u da %u: "
-                                "addr 0x%04x size %u block csum 0x%04x\n",
-                                opcode, i2400m_brh_get_use_checksum(cmd),
-                                i2400m_brh_get_response_required(cmd),
-                                i2400m_brh_get_direct_access(cmd),
-                                cmd->target_addr, cmd->data_size,
-                                cmd->block_checksum);
-       }
-       result = i2400m->bus_bm_wait_for_ack(i2400m, ack, ack_size);
-       if (result < 0) {
-               dev_err(dev, "boot-mode cmd %d: error waiting for an ack: %d\n",
-                       opcode, (int) result);  /* bah, %zd doesn't work */
-               goto error_wait_for_ack;
-       }
-       rx_bytes = result;
-       /* verify the ack and read more if necessary [result is the
-        * final amount of bytes we get in the ack]  */
-       result = __i2400m_bm_ack_verify(i2400m, opcode, ack, ack_size, flags);
-       if (result < 0)
-               goto error_bad_ack;
-       /* Don't you love this stack of empty targets? Well, I don't
-        * either, but it helps track exactly who comes in here and
-        * why :) */
-       result = rx_bytes;
-error_bad_ack:
-error_wait_for_ack:
-error_cmd_send:
-       d_fnend(6, dev, "(i2400m %p cmd %p size %zu ack %p size %zu) = %d\n",
-               i2400m, cmd, cmd_size, ack, ack_size, (int) result);
-       return result;
-}
-
-
-/**
- * i2400m_download_chunk - write a single chunk of data to the device's memory
- *
- * @i2400m: device descriptor
- * @chunk: the buffer to write
- * @__chunk_len: length of the buffer to write
- * @addr: address in the device memory space
- * @direct: bootrom write mode
- * @do_csum: should a checksum validation be performed
- */
-static int i2400m_download_chunk(struct i2400m *i2400m, const void *chunk,
-                                size_t __chunk_len, unsigned long addr,
-                                unsigned int direct, unsigned int do_csum)
-{
-       int ret;
-       size_t chunk_len = ALIGN(__chunk_len, I2400M_PL_ALIGN);
-       struct device *dev = i2400m_dev(i2400m);
-       struct {
-               struct i2400m_bootrom_header cmd;
-               u8 cmd_payload[];
-       } __packed *buf;
-       struct i2400m_bootrom_header ack;
-
-       d_fnstart(5, dev, "(i2400m %p chunk %p __chunk_len %zu addr 0x%08lx "
-                 "direct %u do_csum %u)\n", i2400m, chunk, __chunk_len,
-                 addr, direct, do_csum);
-       buf = i2400m->bm_cmd_buf;
-       memcpy(buf->cmd_payload, chunk, __chunk_len);
-       memset(buf->cmd_payload + __chunk_len, 0xad, chunk_len - __chunk_len);
-
-       buf->cmd.command = i2400m_brh_command(I2400M_BRH_WRITE,
-                                             __chunk_len & 0x3 ? 0 : do_csum,
-                                             __chunk_len & 0xf ? 0 : direct);
-       buf->cmd.target_addr = cpu_to_le32(addr);
-       buf->cmd.data_size = cpu_to_le32(__chunk_len);
-       ret = i2400m_bm_cmd(i2400m, &buf->cmd, sizeof(buf->cmd) + chunk_len,
-                           &ack, sizeof(ack), 0);
-       if (ret >= 0)
-               ret = 0;
-       d_fnend(5, dev, "(i2400m %p chunk %p __chunk_len %zu addr 0x%08lx "
-               "direct %u do_csum %u) = %d\n", i2400m, chunk, __chunk_len,
-               addr, direct, do_csum, ret);
-       return ret;
-}
-
-
-/*
- * Download a BCF file's sections to the device
- *
- * @i2400m: device descriptor
- * @bcf: pointer to firmware data (first header followed by the
- *     payloads). Assumed verified and consistent.
- * @bcf_len: length (in bytes) of the @bcf buffer.
- *
- * Returns: < 0 errno code on error or the offset to the jump instruction.
- *
- * Given a BCF file, downloads each section (a command and a payload)
- * to the device's address space. Actually, it just executes each
- * command i the BCF file.
- *
- * The section size has to be aligned to 4 bytes AND the padding has
- * to be taken from the firmware file, as the signature takes it into
- * account.
- */
-static
-ssize_t i2400m_dnload_bcf(struct i2400m *i2400m,
-                         const struct i2400m_bcf_hdr *bcf, size_t bcf_len)
-{
-       ssize_t ret;
-       struct device *dev = i2400m_dev(i2400m);
-       size_t offset,          /* iterator offset */
-               data_size,      /* Size of the data payload */
-               section_size,   /* Size of the whole section (cmd + payload) */
-               section = 1;
-       const struct i2400m_bootrom_header *bh;
-       struct i2400m_bootrom_header ack;
-
-       d_fnstart(3, dev, "(i2400m %p bcf %p bcf_len %zu)\n",
-                 i2400m, bcf, bcf_len);
-       /* Iterate over the command blocks in the BCF file that start
-        * after the header */
-       offset = le32_to_cpu(bcf->header_len) * sizeof(u32);
-       while (1) {     /* start sending the file */
-               bh = (void *) bcf + offset;
-               data_size = le32_to_cpu(bh->data_size);
-               section_size = ALIGN(sizeof(*bh) + data_size, 4);
-               d_printf(7, dev,
-                        "downloading section #%zu (@%zu %zu B) to 0x%08x\n",
-                        section, offset, sizeof(*bh) + data_size,
-                        le32_to_cpu(bh->target_addr));
-               /*
-                * We look for JUMP cmd from the bootmode header,
-                * either I2400M_BRH_SIGNED_JUMP for secure boot
-                * or I2400M_BRH_JUMP for unsecure boot, the last chunk
-                * should be the bootmode header with JUMP cmd.
-                */
-               if (i2400m_brh_get_opcode(bh) == I2400M_BRH_SIGNED_JUMP ||
-                       i2400m_brh_get_opcode(bh) == I2400M_BRH_JUMP) {
-                       d_printf(5, dev,  "jump found @%zu\n", offset);
-                       break;
-               }
-               if (offset + section_size > bcf_len) {
-                       dev_err(dev, "fw %s: bad section #%zu, "
-                               "end (@%zu) beyond EOF (@%zu)\n",
-                               i2400m->fw_name, section,
-                               offset + section_size,  bcf_len);
-                       ret = -EINVAL;
-                       goto error_section_beyond_eof;
-               }
-               __i2400m_msleep(20);
-               ret = i2400m_bm_cmd(i2400m, bh, section_size,
-                                   &ack, sizeof(ack), I2400M_BM_CMD_RAW);
-               if (ret < 0) {
-                       dev_err(dev, "fw %s: section #%zu (@%zu %zu B) "
-                               "failed %d\n", i2400m->fw_name, section,
-                               offset, sizeof(*bh) + data_size, (int) ret);
-                       goto error_send;
-               }
-               offset += section_size;
-               section++;
-       }
-       ret = offset;
-error_section_beyond_eof:
-error_send:
-       d_fnend(3, dev, "(i2400m %p bcf %p bcf_len %zu) = %d\n",
-               i2400m, bcf, bcf_len, (int) ret);
-       return ret;
-}
-
-
-/*
- * Indicate if the device emitted a reboot barker that indicates
- * "signed boot"
- */
-static
-unsigned i2400m_boot_is_signed(struct i2400m *i2400m)
-{
-       return likely(i2400m->sboot);
-}
-
-
-/*
- * Do the final steps of uploading firmware
- *
- * @bcf_hdr: BCF header we are actually using
- * @bcf: pointer to the firmware image (which matches the first header
- *     that is followed by the actual payloads).
- * @offset: [byte] offset into @bcf for the command we need to send.
- *
- * Depending on the boot mode (signed vs non-signed), different
- * actions need to be taken.
- */
-static
-int i2400m_dnload_finalize(struct i2400m *i2400m,
-                          const struct i2400m_bcf_hdr *bcf_hdr,
-                          const struct i2400m_bcf_hdr *bcf, size_t offset)
-{
-       int ret = 0;
-       struct device *dev = i2400m_dev(i2400m);
-       struct i2400m_bootrom_header *cmd, ack;
-       struct {
-               struct i2400m_bootrom_header cmd;
-               u8 cmd_pl[0];
-       } __packed *cmd_buf;
-       size_t signature_block_offset, signature_block_size;
-
-       d_fnstart(3, dev, "offset %zu\n", offset);
-       cmd = (void *) bcf + offset;
-       if (i2400m_boot_is_signed(i2400m) == 0) {
-               struct i2400m_bootrom_header jump_ack;
-               d_printf(1, dev, "unsecure boot, jumping to 0x%08x\n",
-                       le32_to_cpu(cmd->target_addr));
-               cmd_buf = i2400m->bm_cmd_buf;
-               memcpy(&cmd_buf->cmd, cmd, sizeof(*cmd));
-               cmd = &cmd_buf->cmd;
-               /* now cmd points to the actual bootrom_header in cmd_buf */
-               i2400m_brh_set_opcode(cmd, I2400M_BRH_JUMP);
-               cmd->data_size = 0;
-               ret = i2400m_bm_cmd(i2400m, cmd, sizeof(*cmd),
-                                   &jump_ack, sizeof(jump_ack), 0);
-       } else {
-               d_printf(1, dev, "secure boot, jumping to 0x%08x\n",
-                        le32_to_cpu(cmd->target_addr));
-               cmd_buf = i2400m->bm_cmd_buf;
-               memcpy(&cmd_buf->cmd, cmd, sizeof(*cmd));
-               signature_block_offset =
-                       sizeof(*bcf_hdr)
-                       + le32_to_cpu(bcf_hdr->key_size) * sizeof(u32)
-                       + le32_to_cpu(bcf_hdr->exponent_size) * sizeof(u32);
-               signature_block_size =
-                       le32_to_cpu(bcf_hdr->modulus_size) * sizeof(u32);
-               memcpy(cmd_buf->cmd_pl,
-                      (void *) bcf_hdr + signature_block_offset,
-                      signature_block_size);
-               ret = i2400m_bm_cmd(i2400m, &cmd_buf->cmd,
-                                   sizeof(cmd_buf->cmd) + signature_block_size,
-                                   &ack, sizeof(ack), I2400M_BM_CMD_RAW);
-       }
-       d_fnend(3, dev, "returning %d\n", ret);
-       return ret;
-}
-
-
-/**
- * i2400m_bootrom_init - Reboots a powered device into boot mode
- *
- * @i2400m: device descriptor
- * @flags:
- *      I2400M_BRI_SOFT: a reboot barker has been seen
- *          already, so don't wait for it.
- *
- *      I2400M_BRI_NO_REBOOT: Don't send a reboot command, but wait
- *          for a reboot barker notification. This is a one shot; if
- *          the state machine needs to send a reboot command it will.
- *
- * Returns:
- *
- *     < 0 errno code on error, 0 if ok.
- *
- * Description:
- *
- * Tries hard enough to put the device in boot-mode. There are two
- * main phases to this:
- *
- * a. (1) send a reboot command and (2) get a reboot barker
- *
- * b. (1) echo/ack the reboot sending the reboot barker back and (2)
- *        getting an ack barker in return
- *
- * We want to skip (a) in some cases [soft]. The state machine is
- * horrible, but it is basically: on each phase, send what has to be
- * sent (if any), wait for the answer and act on the answer. We might
- * have to backtrack and retry, so we keep a max tries counter for
- * that.
- *
- * It sucks because we don't know ahead of time which is going to be
- * the reboot barker (the device might send different ones depending
- * on its EEPROM config) and once the device reboots and waits for the
- * echo/ack reboot barker being sent back, it doesn't understand
- * anything else. So we can be left at the point where we don't know
- * what to send to it -- cold reset and bus reset seem to have little
- * effect. So the function iterates (in this case) through all the
- * known barkers and tries them all until an ACK is
- * received. Otherwise, it gives up.
- *
- * If we get a timeout after sending a warm reset, we do it again.
- */
-int i2400m_bootrom_init(struct i2400m *i2400m, enum i2400m_bri flags)
-{
-       int result;
-       struct device *dev = i2400m_dev(i2400m);
-       struct i2400m_bootrom_header *cmd;
-       struct i2400m_bootrom_header ack;
-       int count = i2400m->bus_bm_retries;
-       int ack_timeout_cnt = 1;
-       unsigned i;
-
-       BUILD_BUG_ON(sizeof(*cmd) != sizeof(i2400m_barker_db[0].data));
-       BUILD_BUG_ON(sizeof(ack) != sizeof(i2400m_ACK_BARKER));
-
-       d_fnstart(4, dev, "(i2400m %p flags 0x%08x)\n", i2400m, flags);
-       result = -ENOMEM;
-       cmd = i2400m->bm_cmd_buf;
-       if (flags & I2400M_BRI_SOFT)
-               goto do_reboot_ack;
-do_reboot:
-       ack_timeout_cnt = 1;
-       if (--count < 0)
-               goto error_timeout;
-       d_printf(4, dev, "device reboot: reboot command [%d # left]\n",
-                count);
-       if ((flags & I2400M_BRI_NO_REBOOT) == 0)
-               i2400m_reset(i2400m, I2400M_RT_WARM);
-       result = i2400m_bm_cmd(i2400m, NULL, 0, &ack, sizeof(ack),
-                              I2400M_BM_CMD_RAW);
-       flags &= ~I2400M_BRI_NO_REBOOT;
-       switch (result) {
-       case -ERESTARTSYS:
-               /*
-                * at this point, i2400m_bm_cmd(), through
-                * __i2400m_bm_ack_process(), has updated
-                * i2400m->barker and we are good to go.
-                */
-               d_printf(4, dev, "device reboot: got reboot barker\n");
-               break;
-       case -EISCONN:  /* we don't know how it got here...but we follow it */
-               d_printf(4, dev, "device reboot: got ack barker - whatever\n");
-               goto do_reboot;
-       case -ETIMEDOUT:
-               /*
-                * Device has timed out, we might be in boot mode
-                * already and expecting an ack; if we don't know what
-                * the barker is, we just send them all. Cold reset
-                * and bus reset don't work. Beats me.
-                */
-               if (i2400m->barker != NULL) {
-                       dev_err(dev, "device boot: reboot barker timed out, "
-                               "trying (set) %08x echo/ack\n",
-                               le32_to_cpu(i2400m->barker->data[0]));
-                       goto do_reboot_ack;
-               }
-               for (i = 0; i < i2400m_barker_db_used; i++) {
-                       struct i2400m_barker_db *barker = &i2400m_barker_db[i];
-                       memcpy(cmd, barker->data, sizeof(barker->data));
-                       result = i2400m_bm_cmd(i2400m, cmd, sizeof(*cmd),
-                                              &ack, sizeof(ack),
-                                              I2400M_BM_CMD_RAW);
-                       if (result == -EISCONN) {
-                               dev_warn(dev, "device boot: got ack barker "
-                                        "after sending echo/ack barker "
-                                        "#%d/%08x; rebooting j.i.c.\n",
-                                        i, le32_to_cpu(barker->data[0]));
-                               flags &= ~I2400M_BRI_NO_REBOOT;
-                               goto do_reboot;
-                       }
-               }
-               dev_err(dev, "device boot: tried all the echo/acks, could "
-                       "not get device to respond; giving up");
-               result = -ESHUTDOWN;
-       case -EPROTO:
-       case -ESHUTDOWN:        /* dev is gone */
-       case -EINTR:            /* user cancelled */
-               goto error_dev_gone;
-       default:
-               dev_err(dev, "device reboot: error %d while waiting "
-                       "for reboot barker - rebooting\n", result);
-               d_dump(1, dev, &ack, result);
-               goto do_reboot;
-       }
-       /* At this point we ack back with 4 REBOOT barkers and expect
-        * 4 ACK barkers. This is ugly, as we send a raw command --
-        * hence the cast. _bm_cmd() will catch the reboot ack
-        * notification and report it as -EISCONN. */
-do_reboot_ack:
-       d_printf(4, dev, "device reboot ack: sending ack [%d # left]\n", count);
-       memcpy(cmd, i2400m->barker->data, sizeof(i2400m->barker->data));
-       result = i2400m_bm_cmd(i2400m, cmd, sizeof(*cmd),
-                              &ack, sizeof(ack), I2400M_BM_CMD_RAW);
-       switch (result) {
-       case -ERESTARTSYS:
-               d_printf(4, dev, "reboot ack: got reboot barker - retrying\n");
-               if (--count < 0)
-                       goto error_timeout;
-               goto do_reboot_ack;
-       case -EISCONN:
-               d_printf(4, dev, "reboot ack: got ack barker - good\n");
-               break;
-       case -ETIMEDOUT:        /* no response, maybe it is the other type? */
-               if (ack_timeout_cnt-- < 0) {
-                       d_printf(4, dev, "reboot ack timedout: retrying\n");
-                       goto do_reboot_ack;
-               } else {
-                       dev_err(dev, "reboot ack timedout too long: "
-                               "trying reboot\n");
-                       goto do_reboot;
-               }
-               break;
-       case -EPROTO:
-       case -ESHUTDOWN:        /* dev is gone */
-               goto error_dev_gone;
-       default:
-               dev_err(dev, "device reboot ack: error %d while waiting for "
-                       "reboot ack barker - rebooting\n", result);
-               goto do_reboot;
-       }
-       d_printf(2, dev, "device reboot ack: got ack barker - boot done\n");
-       result = 0;
-exit_timeout:
-error_dev_gone:
-       d_fnend(4, dev, "(i2400m %p flags 0x%08x) = %d\n",
-               i2400m, flags, result);
-       return result;
-
-error_timeout:
-       dev_err(dev, "Timed out waiting for reboot ack\n");
-       result = -ETIMEDOUT;
-       goto exit_timeout;
-}
-
-
-/*
- * Read the MAC addr
- *
- * The position this function reads is fixed in device memory and
- * always available, even without firmware.
- *
- * Note we specify we want to read only six bytes, but provide space
- * for 16, as we always get it rounded up.
- */
-int i2400m_read_mac_addr(struct i2400m *i2400m)
-{
-       int result;
-       struct device *dev = i2400m_dev(i2400m);
-       struct net_device *net_dev = i2400m->wimax_dev.net_dev;
-       struct i2400m_bootrom_header *cmd;
-       struct {
-               struct i2400m_bootrom_header ack;
-               u8 ack_pl[16];
-       } __packed ack_buf;
-
-       d_fnstart(5, dev, "(i2400m %p)\n", i2400m);
-       cmd = i2400m->bm_cmd_buf;
-       cmd->command = i2400m_brh_command(I2400M_BRH_READ, 0, 1);
-       cmd->target_addr = cpu_to_le32(0x00203fe8);
-       cmd->data_size = cpu_to_le32(6);
-       result = i2400m_bm_cmd(i2400m, cmd, sizeof(*cmd),
-                              &ack_buf.ack, sizeof(ack_buf), 0);
-       if (result < 0) {
-               dev_err(dev, "BM: read mac addr failed: %d\n", result);
-               goto error_read_mac;
-       }
-       d_printf(2, dev, "mac addr is %pM\n", ack_buf.ack_pl);
-       if (i2400m->bus_bm_mac_addr_impaired == 1) {
-               ack_buf.ack_pl[0] = 0x00;
-               ack_buf.ack_pl[1] = 0x16;
-               ack_buf.ack_pl[2] = 0xd3;
-               get_random_bytes(&ack_buf.ack_pl[3], 3);
-               dev_err(dev, "BM is MAC addr impaired, faking MAC addr to "
-                       "mac addr is %pM\n", ack_buf.ack_pl);
-               result = 0;
-       }
-       net_dev->addr_len = ETH_ALEN;
-       memcpy(net_dev->dev_addr, ack_buf.ack_pl, ETH_ALEN);
-error_read_mac:
-       d_fnend(5, dev, "(i2400m %p) = %d\n", i2400m, result);
-       return result;
-}
-
-
-/*
- * Initialize a non signed boot
- *
- * This implies sending some magic values to the device's memory. Note
- * we convert the values to little endian in the same array
- * declaration.
- */
-static
-int i2400m_dnload_init_nonsigned(struct i2400m *i2400m)
-{
-       unsigned i = 0;
-       int ret = 0;
-       struct device *dev = i2400m_dev(i2400m);
-       d_fnstart(5, dev, "(i2400m %p)\n", i2400m);
-       if (i2400m->bus_bm_pokes_table) {
-               while (i2400m->bus_bm_pokes_table[i].address) {
-                       ret = i2400m_download_chunk(
-                               i2400m,
-                               &i2400m->bus_bm_pokes_table[i].data,
-                               sizeof(i2400m->bus_bm_pokes_table[i].data),
-                               i2400m->bus_bm_pokes_table[i].address, 1, 1);
-                       if (ret < 0)
-                               break;
-                       i++;
-               }
-       }
-       d_fnend(5, dev, "(i2400m %p) = %d\n", i2400m, ret);
-       return ret;
-}
-
-
-/*
- * Initialize the signed boot process
- *
- * @i2400m: device descriptor
- *
- * @bcf_hdr: pointer to the firmware header; assumes it is fully in
- *     memory (it has gone through basic validation).
- *
- * Returns: 0 if ok, < 0 errno code on error, -ERESTARTSYS if the hw
- *     rebooted.
- *
- * This writes the firmware BCF header to the device using the
- * HASH_PAYLOAD_ONLY command.
- */
-static
-int i2400m_dnload_init_signed(struct i2400m *i2400m,
-                             const struct i2400m_bcf_hdr *bcf_hdr)
-{
-       int ret;
-       struct device *dev = i2400m_dev(i2400m);
-       struct {
-               struct i2400m_bootrom_header cmd;
-               struct i2400m_bcf_hdr cmd_pl;
-       } __packed *cmd_buf;
-       struct i2400m_bootrom_header ack;
-
-       d_fnstart(5, dev, "(i2400m %p bcf_hdr %p)\n", i2400m, bcf_hdr);
-       cmd_buf = i2400m->bm_cmd_buf;
-       cmd_buf->cmd.command =
-               i2400m_brh_command(I2400M_BRH_HASH_PAYLOAD_ONLY, 0, 0);
-       cmd_buf->cmd.target_addr = 0;
-       cmd_buf->cmd.data_size = cpu_to_le32(sizeof(cmd_buf->cmd_pl));
-       memcpy(&cmd_buf->cmd_pl, bcf_hdr, sizeof(*bcf_hdr));
-       ret = i2400m_bm_cmd(i2400m, &cmd_buf->cmd, sizeof(*cmd_buf),
-                           &ack, sizeof(ack), 0);
-       if (ret >= 0)
-               ret = 0;
-       d_fnend(5, dev, "(i2400m %p bcf_hdr %p) = %d\n", i2400m, bcf_hdr, ret);
-       return ret;
-}
-
-
-/*
- * Initialize the firmware download at the device size
- *
- * Multiplex to the one that matters based on the device's mode
- * (signed or non-signed).
- */
-static
-int i2400m_dnload_init(struct i2400m *i2400m,
-                      const struct i2400m_bcf_hdr *bcf_hdr)
-{
-       int result;
-       struct device *dev = i2400m_dev(i2400m);
-
-       if (i2400m_boot_is_signed(i2400m)) {
-               d_printf(1, dev, "signed boot\n");
-               result = i2400m_dnload_init_signed(i2400m, bcf_hdr);
-               if (result == -ERESTARTSYS)
-                       return result;
-               if (result < 0)
-                       dev_err(dev, "firmware %s: signed boot download "
-                               "initialization failed: %d\n",
-                               i2400m->fw_name, result);
-       } else {
-               /* non-signed boot process without pokes */
-               d_printf(1, dev, "non-signed boot\n");
-               result = i2400m_dnload_init_nonsigned(i2400m);
-               if (result == -ERESTARTSYS)
-                       return result;
-               if (result < 0)
-                       dev_err(dev, "firmware %s: non-signed download "
-                               "initialization failed: %d\n",
-                               i2400m->fw_name, result);
-       }
-       return result;
-}
-
-
-/*
- * Run consistency tests on the firmware file and load up headers
- *
- * Check for the firmware being made for the i2400m device,
- * etc...These checks are mostly informative, as the device will make
- * them too; but the driver's response is more informative on what
- * went wrong.
- *
- * This will also look at all the headers present on the firmware
- * file, and update i2400m->fw_bcf_hdr to point to them.
- */
-static
-int i2400m_fw_hdr_check(struct i2400m *i2400m,
-                       const struct i2400m_bcf_hdr *bcf_hdr,
-                       size_t index, size_t offset)
-{
-       struct device *dev = i2400m_dev(i2400m);
-
-       unsigned module_type, header_len, major_version, minor_version,
-               module_id, module_vendor, date, size;
-
-       module_type = le32_to_cpu(bcf_hdr->module_type);
-       header_len = sizeof(u32) * le32_to_cpu(bcf_hdr->header_len);
-       major_version = (le32_to_cpu(bcf_hdr->header_version) & 0xffff0000)
-               >> 16;
-       minor_version = le32_to_cpu(bcf_hdr->header_version) & 0x0000ffff;
-       module_id = le32_to_cpu(bcf_hdr->module_id);
-       module_vendor = le32_to_cpu(bcf_hdr->module_vendor);
-       date = le32_to_cpu(bcf_hdr->date);
-       size = sizeof(u32) * le32_to_cpu(bcf_hdr->size);
-
-       d_printf(1, dev, "firmware %s #%zd@%08zx: BCF header "
-                "type:vendor:id 0x%x:%x:%x v%u.%u (%u/%u B) built %08x\n",
-                i2400m->fw_name, index, offset,
-                module_type, module_vendor, module_id,
-                major_version, minor_version, header_len, size, date);
-
-       /* Hard errors */
-       if (major_version != 1) {
-               dev_err(dev, "firmware %s #%zd@%08zx: major header version "
-                       "v%u.%u not supported\n",
-                       i2400m->fw_name, index, offset,
-                       major_version, minor_version);
-               return -EBADF;
-       }
-
-       if (module_type != 6) {         /* built for the right hardware? */
-               dev_err(dev, "firmware %s #%zd@%08zx: unexpected module "
-                       "type 0x%x; aborting\n",
-                       i2400m->fw_name, index, offset,
-                       module_type);
-               return -EBADF;
-       }
-
-       if (module_vendor != 0x8086) {
-               dev_err(dev, "firmware %s #%zd@%08zx: unexpected module "
-                       "vendor 0x%x; aborting\n",
-                       i2400m->fw_name, index, offset, module_vendor);
-               return -EBADF;
-       }
-
-       if (date < 0x20080300)
-               dev_warn(dev, "firmware %s #%zd@%08zx: build date %08x "
-                        "too old; unsupported\n",
-                        i2400m->fw_name, index, offset, date);
-       return 0;
-}
-
-
-/*
- * Run consistency tests on the firmware file and load up headers
- *
- * Check for the firmware being made for the i2400m device,
- * etc...These checks are mostly informative, as the device will make
- * them too; but the driver's response is more informative on what
- * went wrong.
- *
- * This will also look at all the headers present on the firmware
- * file, and update i2400m->fw_hdrs to point to them.
- */
-static
-int i2400m_fw_check(struct i2400m *i2400m, const void *bcf, size_t bcf_size)
-{
-       int result;
-       struct device *dev = i2400m_dev(i2400m);
-       size_t headers = 0;
-       const struct i2400m_bcf_hdr *bcf_hdr;
-       const void *itr, *next, *top;
-       size_t slots = 0, used_slots = 0;
-
-       for (itr = bcf, top = itr + bcf_size;
-            itr < top;
-            headers++, itr = next) {
-               size_t leftover, offset, header_len, size;
-
-               leftover = top - itr;
-               offset = itr - bcf;
-               if (leftover <= sizeof(*bcf_hdr)) {
-                       dev_err(dev, "firmware %s: %zu B left at @%zx, "
-                               "not enough for BCF header\n",
-                               i2400m->fw_name, leftover, offset);
-                       break;
-               }
-               bcf_hdr = itr;
-               /* Only the first header is supposed to be followed by
-                * payload */
-               header_len = sizeof(u32) * le32_to_cpu(bcf_hdr->header_len);
-               size = sizeof(u32) * le32_to_cpu(bcf_hdr->size);
-               if (headers == 0)
-                       next = itr + size;
-               else
-                       next = itr + header_len;
-
-               result = i2400m_fw_hdr_check(i2400m, bcf_hdr, headers, offset);
-               if (result < 0)
-                       continue;
-               if (used_slots + 1 >= slots) {
-                       /* +1 -> we need to account for the one we'll
-                        * occupy and at least an extra one for
-                        * always being NULL */
-                       result = i2400m_zrealloc_2x(
-                               (void **) &i2400m->fw_hdrs, &slots,
-                               sizeof(i2400m->fw_hdrs[0]),
-                               GFP_KERNEL);
-                       if (result < 0)
-                               goto error_zrealloc;
-               }
-               i2400m->fw_hdrs[used_slots] = bcf_hdr;
-               used_slots++;
-       }
-       if (headers == 0) {
-               dev_err(dev, "firmware %s: no usable headers found\n",
-                       i2400m->fw_name);
-               result = -EBADF;
-       } else
-               result = 0;
-error_zrealloc:
-       return result;
-}
-
-
-/*
- * Match a barker to a BCF header module ID
- *
- * The device sends a barker which tells the firmware loader which
- * header in the BCF file has to be used. This does the matching.
- */
-static
-unsigned i2400m_bcf_hdr_match(struct i2400m *i2400m,
-                             const struct i2400m_bcf_hdr *bcf_hdr)
-{
-       u32 barker = le32_to_cpu(i2400m->barker->data[0])
-               & 0x7fffffff;
-       u32 module_id = le32_to_cpu(bcf_hdr->module_id)
-               & 0x7fffffff;   /* high bit used for something else */
-
-       /* special case for 5x50 */
-       if (barker == I2400M_SBOOT_BARKER && module_id == 0)
-               return 1;
-       if (module_id == barker)
-               return 1;
-       return 0;
-}
-
-static
-const struct i2400m_bcf_hdr *i2400m_bcf_hdr_find(struct i2400m *i2400m)
-{
-       struct device *dev = i2400m_dev(i2400m);
-       const struct i2400m_bcf_hdr **bcf_itr, *bcf_hdr;
-       unsigned i = 0;
-       u32 barker = le32_to_cpu(i2400m->barker->data[0]);
-
-       d_printf(2, dev, "finding BCF header for barker %08x\n", barker);
-       if (barker == I2400M_NBOOT_BARKER) {
-               bcf_hdr = i2400m->fw_hdrs[0];
-               d_printf(1, dev, "using BCF header #%u/%08x for non-signed "
-                        "barker\n", 0, le32_to_cpu(bcf_hdr->module_id));
-               return bcf_hdr;
-       }
-       for (bcf_itr = i2400m->fw_hdrs; *bcf_itr != NULL; bcf_itr++, i++) {
-               bcf_hdr = *bcf_itr;
-               if (i2400m_bcf_hdr_match(i2400m, bcf_hdr)) {
-                       d_printf(1, dev, "hit on BCF hdr #%u/%08x\n",
-                                i, le32_to_cpu(bcf_hdr->module_id));
-                       return bcf_hdr;
-               } else
-                       d_printf(1, dev, "miss on BCF hdr #%u/%08x\n",
-                                i, le32_to_cpu(bcf_hdr->module_id));
-       }
-       dev_err(dev, "cannot find a matching BCF header for barker %08x\n",
-               barker);
-       return NULL;
-}
-
-
-/*
- * Download the firmware to the device
- *
- * @i2400m: device descriptor
- * @bcf: pointer to loaded (and minimally verified for consistency)
- *    firmware
- * @bcf_size: size of the @bcf buffer (header plus payloads)
- *
- * The process for doing this is described in this file's header.
- *
- * Note we only reinitialize boot-mode if the flags say so. Some hw
- * iterations need it, some don't. In any case, if we loop, we always
- * need to reinitialize the boot room, hence the flags modification.
- */
-static
-int i2400m_fw_dnload(struct i2400m *i2400m, const struct i2400m_bcf_hdr *bcf,
-                    size_t fw_size, enum i2400m_bri flags)
-{
-       int ret = 0;
-       struct device *dev = i2400m_dev(i2400m);
-       int count = i2400m->bus_bm_retries;
-       const struct i2400m_bcf_hdr *bcf_hdr;
-       size_t bcf_size;
-
-       d_fnstart(5, dev, "(i2400m %p bcf %p fw size %zu)\n",
-                 i2400m, bcf, fw_size);
-       i2400m->boot_mode = 1;
-       wmb();          /* Make sure other readers see it */
-hw_reboot:
-       if (count-- == 0) {
-               ret = -ERESTARTSYS;
-               dev_err(dev, "device rebooted too many times, aborting\n");
-               goto error_too_many_reboots;
-       }
-       if (flags & I2400M_BRI_MAC_REINIT) {
-               ret = i2400m_bootrom_init(i2400m, flags);
-               if (ret < 0) {
-                       dev_err(dev, "bootrom init failed: %d\n", ret);
-                       goto error_bootrom_init;
-               }
-       }
-       flags |= I2400M_BRI_MAC_REINIT;
-
-       /*
-        * Initialize the download, push the bytes to the device and
-        * then jump to the new firmware. Note @ret is passed with the
-        * offset of the jump instruction to _dnload_finalize()
-        *
-        * Note we need to use the BCF header in the firmware image
-        * that matches the barker that the device sent when it
-        * rebooted, so it has to be passed along.
-        */
-       ret = -EBADF;
-       bcf_hdr = i2400m_bcf_hdr_find(i2400m);
-       if (bcf_hdr == NULL)
-               goto error_bcf_hdr_find;
-
-       ret = i2400m_dnload_init(i2400m, bcf_hdr);
-       if (ret == -ERESTARTSYS)
-               goto error_dev_rebooted;
-       if (ret < 0)
-               goto error_dnload_init;
-
-       /*
-        * bcf_size refers to one header size plus the fw sections size
-        * indicated by the header,ie. if there are other extended headers
-        * at the tail, they are not counted
-        */
-       bcf_size = sizeof(u32) * le32_to_cpu(bcf_hdr->size);
-       ret = i2400m_dnload_bcf(i2400m, bcf, bcf_size);
-       if (ret == -ERESTARTSYS)
-               goto error_dev_rebooted;
-       if (ret < 0) {
-               dev_err(dev, "fw %s: download failed: %d\n",
-                       i2400m->fw_name, ret);
-               goto error_dnload_bcf;
-       }
-
-       ret = i2400m_dnload_finalize(i2400m, bcf_hdr, bcf, ret);
-       if (ret == -ERESTARTSYS)
-               goto error_dev_rebooted;
-       if (ret < 0) {
-               dev_err(dev, "fw %s: "
-                       "download finalization failed: %d\n",
-                       i2400m->fw_name, ret);
-               goto error_dnload_finalize;
-       }
-
-       d_printf(2, dev, "fw %s successfully uploaded\n",
-                i2400m->fw_name);
-       i2400m->boot_mode = 0;
-       wmb();          /* Make sure i2400m_msg_to_dev() sees boot_mode */
-error_dnload_finalize:
-error_dnload_bcf:
-error_dnload_init:
-error_bcf_hdr_find:
-error_bootrom_init:
-error_too_many_reboots:
-       d_fnend(5, dev, "(i2400m %p bcf %p size %zu) = %d\n",
-               i2400m, bcf, fw_size, ret);
-       return ret;
-
-error_dev_rebooted:
-       dev_err(dev, "device rebooted, %d tries left\n", count);
-       /* we got the notification already, no need to wait for it again */
-       flags |= I2400M_BRI_SOFT;
-       goto hw_reboot;
-}
-
-static
-int i2400m_fw_bootstrap(struct i2400m *i2400m, const struct firmware *fw,
-                       enum i2400m_bri flags)
-{
-       int ret;
-       struct device *dev = i2400m_dev(i2400m);
-       const struct i2400m_bcf_hdr *bcf;       /* Firmware data */
-
-       d_fnstart(5, dev, "(i2400m %p)\n", i2400m);
-       bcf = (void *) fw->data;
-       ret = i2400m_fw_check(i2400m, bcf, fw->size);
-       if (ret >= 0)
-               ret = i2400m_fw_dnload(i2400m, bcf, fw->size, flags);
-       if (ret < 0)
-               dev_err(dev, "%s: cannot use: %d, skipping\n",
-                       i2400m->fw_name, ret);
-       kfree(i2400m->fw_hdrs);
-       i2400m->fw_hdrs = NULL;
-       d_fnend(5, dev, "(i2400m %p) = %d\n", i2400m, ret);
-       return ret;
-}
-
-
-/* Refcounted container for firmware data */
-struct i2400m_fw {
-       struct kref kref;
-       const struct firmware *fw;
-};
-
-
-static
-void i2400m_fw_destroy(struct kref *kref)
-{
-       struct i2400m_fw *i2400m_fw =
-               container_of(kref, struct i2400m_fw, kref);
-       release_firmware(i2400m_fw->fw);
-       kfree(i2400m_fw);
-}
-
-
-static
-struct i2400m_fw *i2400m_fw_get(struct i2400m_fw *i2400m_fw)
-{
-       if (i2400m_fw != NULL && i2400m_fw != (void *) ~0)
-               kref_get(&i2400m_fw->kref);
-       return i2400m_fw;
-}
-
-
-static
-void i2400m_fw_put(struct i2400m_fw *i2400m_fw)
-{
-       kref_put(&i2400m_fw->kref, i2400m_fw_destroy);
-}
-
-
-/**
- * i2400m_dev_bootstrap - Bring the device to a known state and upload firmware
- *
- * @i2400m: device descriptor
- * @flags:
- *      I2400M_BRI_SOFT: a reboot barker has been seen
- *          already, so don't wait for it.
- *
- *      I2400M_BRI_NO_REBOOT: Don't send a reboot command, but wait
- *          for a reboot barker notification. This is a one shot; if
- *          the state machine needs to send a reboot command it will.
- *
- * Returns: >= 0 if ok, < 0 errno code on error.
- *
- * This sets up the firmware upload environment, loads the firmware
- * file from disk, verifies and then calls the firmware upload process
- * per se.
- *
- * Can be called either from probe, or after a warm reset.  Can not be
- * called from within an interrupt.  All the flow in this code is
- * single-threade; all I/Os are synchronous.
- */
-int i2400m_dev_bootstrap(struct i2400m *i2400m, enum i2400m_bri flags)
-{
-       int ret, itr;
-       struct device *dev = i2400m_dev(i2400m);
-       struct i2400m_fw *i2400m_fw;
-       const struct firmware *fw;
-       const char *fw_name;
-
-       d_fnstart(5, dev, "(i2400m %p)\n", i2400m);
-
-       ret = -ENODEV;
-       spin_lock(&i2400m->rx_lock);
-       i2400m_fw = i2400m_fw_get(i2400m->fw_cached);
-       spin_unlock(&i2400m->rx_lock);
-       if (i2400m_fw == (void *) ~0) {
-               dev_err(dev, "can't load firmware now!");
-               goto out;
-       } else if (i2400m_fw != NULL) {
-               dev_info(dev, "firmware %s: loading from cache\n",
-                        i2400m->fw_name);
-               ret = i2400m_fw_bootstrap(i2400m, i2400m_fw->fw, flags);
-               i2400m_fw_put(i2400m_fw);
-               goto out;
-       }
-
-       /* Load firmware files to memory. */
-       for (itr = 0, ret = -ENOENT; ; itr++) {
-               fw_name = i2400m->bus_fw_names[itr];
-               if (fw_name == NULL) {
-                       dev_err(dev, "Could not find a usable firmware image\n");
-                       break;
-               }
-               d_printf(1, dev, "trying firmware %s (%d)\n", fw_name, itr);
-               ret = request_firmware(&fw, fw_name, dev);
-               if (ret < 0) {
-                       dev_err(dev, "fw %s: cannot load file: %d\n",
-                               fw_name, ret);
-                       continue;
-               }
-               i2400m->fw_name = fw_name;
-               ret = i2400m_fw_bootstrap(i2400m, fw, flags);
-               release_firmware(fw);
-               if (ret >= 0)   /* firmware loaded successfully */
-                       break;
-               i2400m->fw_name = NULL;
-       }
-out:
-       d_fnend(5, dev, "(i2400m %p) = %d\n", i2400m, ret);
-       return ret;
-}
-EXPORT_SYMBOL_GPL(i2400m_dev_bootstrap);
-
-
-void i2400m_fw_cache(struct i2400m *i2400m)
-{
-       int result;
-       struct i2400m_fw *i2400m_fw;
-       struct device *dev = i2400m_dev(i2400m);
-
-       /* if there is anything there, free it -- now, this'd be weird */
-       spin_lock(&i2400m->rx_lock);
-       i2400m_fw = i2400m->fw_cached;
-       spin_unlock(&i2400m->rx_lock);
-       if (i2400m_fw != NULL && i2400m_fw != (void *) ~0) {
-               i2400m_fw_put(i2400m_fw);
-               WARN(1, "%s:%u: still cached fw still present?\n",
-                    __func__, __LINE__);
-       }
-
-       if (i2400m->fw_name == NULL) {
-               dev_err(dev, "firmware n/a: can't cache\n");
-               i2400m_fw = (void *) ~0;
-               goto out;
-       }
-
-       i2400m_fw = kzalloc(sizeof(*i2400m_fw), GFP_ATOMIC);
-       if (i2400m_fw == NULL)
-               goto out;
-       kref_init(&i2400m_fw->kref);
-       result = request_firmware(&i2400m_fw->fw, i2400m->fw_name, dev);
-       if (result < 0) {
-               dev_err(dev, "firmware %s: failed to cache: %d\n",
-                       i2400m->fw_name, result);
-               kfree(i2400m_fw);
-               i2400m_fw = (void *) ~0;
-       } else
-               dev_info(dev, "firmware %s: cached\n", i2400m->fw_name);
-out:
-       spin_lock(&i2400m->rx_lock);
-       i2400m->fw_cached = i2400m_fw;
-       spin_unlock(&i2400m->rx_lock);
-}
-
-
-void i2400m_fw_uncache(struct i2400m *i2400m)
-{
-       struct i2400m_fw *i2400m_fw;
-
-       spin_lock(&i2400m->rx_lock);
-       i2400m_fw = i2400m->fw_cached;
-       i2400m->fw_cached = NULL;
-       spin_unlock(&i2400m->rx_lock);
-
-       if (i2400m_fw != NULL && i2400m_fw != (void *) ~0)
-               i2400m_fw_put(i2400m_fw);
-}
-
diff --git a/drivers/staging/wimax/i2400m/i2400m-usb.h b/drivers/staging/wimax/i2400m/i2400m-usb.h
deleted file mode 100644 (file)
index eff4f46..0000000
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * Intel Wireless WiMAX Connection 2400m
- * USB-specific i2400m driver definitions
- *
- *
- * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   * Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in
- *     the documentation and/or other materials provided with the
- *     distribution.
- *   * Neither the name of Intel Corporation nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *
- * Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- * Yanir Lubetkin <yanirx.lubetkin@intel.com>
- *  - Initial implementation
- *
- *
- * This driver implements the bus-specific part of the i2400m for
- * USB. Check i2400m.h for a generic driver description.
- *
- * ARCHITECTURE
- *
- * This driver listens to notifications sent from the notification
- * endpoint (in usb-notif.c); when data is ready to read, the code in
- * there schedules a read from the device (usb-rx.c) and then passes
- * the data to the generic RX code (rx.c).
- *
- * When the generic driver needs to send data (network or control), it
- * queues up in the TX FIFO (tx.c) and that will notify the driver
- * through the i2400m->bus_tx_kick() callback
- * (usb-tx.c:i2400mu_bus_tx_kick) which will send the items in the
- * FIFO queue.
- *
- * This driver, as well, implements the USB-specific ops for the generic
- * driver to be able to setup/teardown communication with the device
- * [i2400m_bus_dev_start() and i2400m_bus_dev_stop()], reseting the
- * device [i2400m_bus_reset()] and performing firmware upload
- * [i2400m_bus_bm_cmd() and i2400_bus_bm_wait_for_ack()].
- */
-
-#ifndef __I2400M_USB_H__
-#define __I2400M_USB_H__
-
-#include "i2400m.h"
-#include <linux/kthread.h>
-
-
-/*
- * Error Density Count: cheapo error density (over time) counter
- *
- * Originally by Reinette Chatre <reinette.chatre@intel.com>
- *
- * Embed an 'struct edc' somewhere. Each time there is a soft or
- * retryable error, call edc_inc() and check if the error top
- * watermark has been reached.
- */
-enum {
-       EDC_MAX_ERRORS = 10,
-       EDC_ERROR_TIMEFRAME = HZ,
-};
-
-/* error density counter */
-struct edc {
-       unsigned long timestart;
-       u16 errorcount;
-};
-
-struct i2400m_endpoint_cfg {
-       unsigned char bulk_out;
-       unsigned char notification;
-       unsigned char reset_cold;
-       unsigned char bulk_in;
-};
-
-static inline void edc_init(struct edc *edc)
-{
-       edc->timestart = jiffies;
-}
-
-/**
- * edc_inc - report a soft error and check if we are over the watermark
- *
- * @edc: pointer to error density counter.
- * @max_err: maximum number of errors we can accept over the timeframe
- * @timeframe: length of the timeframe (in jiffies).
- *
- * Returns: !0 1 if maximum acceptable errors per timeframe has been
- *     exceeded. 0 otherwise.
- *
- * This is way to determine if the number of acceptable errors per time
- * period has been exceeded. It is not accurate as there are cases in which
- * this scheme will not work, for example if there are periodic occurrences
- * of errors that straddle updates to the start time. This scheme is
- * sufficient for our usage.
- *
- * To use, embed a 'struct edc' somewhere, initialize it with
- * edc_init() and when an error hits:
- *
- * if (do_something_fails_with_a_soft_error) {
- *        if (edc_inc(&my->edc, MAX_ERRORS, MAX_TIMEFRAME))
- *                Ops, hard error, do something about it
- *        else
- *                 Retry or ignore, depending on whatever
- * }
- */
-static inline int edc_inc(struct edc *edc, u16 max_err, u16 timeframe)
-{
-       unsigned long now;
-
-       now = jiffies;
-       if (time_after(now, edc->timestart + timeframe)) {
-               edc->errorcount = 1;
-               edc->timestart = now;
-       } else if (++edc->errorcount > max_err) {
-               edc->errorcount = 0;
-               edc->timestart = now;
-               return 1;
-       }
-       return 0;
-}
-
-/* Host-Device interface for USB */
-enum {
-       I2400M_USB_BOOT_RETRIES = 3,
-       I2400MU_MAX_NOTIFICATION_LEN = 256,
-       I2400MU_BLK_SIZE = 16,
-       I2400MU_PL_SIZE_MAX = 0x3EFF,
-
-       /* Device IDs */
-       USB_DEVICE_ID_I6050 = 0x0186,
-       USB_DEVICE_ID_I6050_2 = 0x0188,
-       USB_DEVICE_ID_I6150 = 0x07d6,
-       USB_DEVICE_ID_I6150_2 = 0x07d7,
-       USB_DEVICE_ID_I6150_3 = 0x07d9,
-       USB_DEVICE_ID_I6250 = 0x0187,
-};
-
-
-/**
- * struct i2400mu - descriptor for a USB connected i2400m
- *
- * @i2400m: bus-generic i2400m implementation; has to be first (see
- *     it's documentation in i2400m.h).
- *
- * @usb_dev: pointer to our USB device
- *
- * @usb_iface: pointer to our USB interface
- *
- * @urb_edc: error density counter; used to keep a density-on-time tab
- *     on how many soft (retryable or ignorable) errors we get. If we
- *     go over the threshold, we consider the bus transport is failing
- *     too much and reset.
- *
- * @notif_urb: URB for receiving notifications from the device.
- *
- * @tx_kthread: thread we use for data TX. We use a thread because in
- *     order to do deep power saving and put the device to sleep, we
- *     need to call usb_autopm_*() [blocking functions].
- *
- * @tx_wq: waitqueue for the TX kthread to sleep when there is no data
- *     to be sent; when more data is available, it is woken up by
- *     i2400mu_bus_tx_kick().
- *
- * @rx_kthread: thread we use for data RX. We use a thread because in
- *     order to do deep power saving and put the device to sleep, we
- *     need to call usb_autopm_*() [blocking functions].
- *
- * @rx_wq: waitqueue for the RX kthread to sleep when there is no data
- *     to receive. When data is available, it is woken up by
- *     usb-notif.c:i2400mu_notification_grok().
- *
- * @rx_pending_count: number of rx-data-ready notifications that were
- *     still not handled by the RX kthread.
- *
- * @rx_size: current RX buffer size that is being used.
- *
- * @rx_size_acc: accumulator of the sizes of the previous read
- *     transactions.
- *
- * @rx_size_cnt: number of read transactions accumulated in
- *     @rx_size_acc.
- *
- * @do_autopm: disable(0)/enable(>0) calling the
- *     usb_autopm_get/put_interface() barriers when executing
- *     commands. See doc in i2400mu_suspend() for more information.
- *
- * @rx_size_auto_shrink: if true, the rx_size is shrunk
- *     automatically based on the average size of the received
- *     transactions. This allows the receive code to allocate smaller
- *     chunks of memory and thus reduce pressure on the memory
- *     allocator by not wasting so much space. By default it is
- *     enabled.
- *
- * @debugfs_dentry: hookup for debugfs files.
- *     These have to be in a separate directory, a child of
- *     (wimax_dev->debugfs_dentry) so they can be removed when the
- *     module unloads, as we don't keep each dentry.
- */
-struct i2400mu {
-       struct i2400m i2400m;           /* FIRST! See doc */
-
-       struct usb_device *usb_dev;
-       struct usb_interface *usb_iface;
-       struct edc urb_edc;             /* Error density counter */
-       struct i2400m_endpoint_cfg endpoint_cfg;
-
-       struct urb *notif_urb;
-       struct task_struct *tx_kthread;
-       wait_queue_head_t tx_wq;
-
-       struct task_struct *rx_kthread;
-       wait_queue_head_t rx_wq;
-       atomic_t rx_pending_count;
-       size_t rx_size, rx_size_acc, rx_size_cnt;
-       atomic_t do_autopm;
-       u8 rx_size_auto_shrink;
-
-       struct dentry *debugfs_dentry;
-       unsigned i6050:1;       /* 1 if this is a 6050 based SKU */
-};
-
-
-static inline
-void i2400mu_init(struct i2400mu *i2400mu)
-{
-       i2400m_init(&i2400mu->i2400m);
-       edc_init(&i2400mu->urb_edc);
-       init_waitqueue_head(&i2400mu->tx_wq);
-       atomic_set(&i2400mu->rx_pending_count, 0);
-       init_waitqueue_head(&i2400mu->rx_wq);
-       i2400mu->rx_size = PAGE_SIZE - sizeof(struct skb_shared_info);
-       atomic_set(&i2400mu->do_autopm, 1);
-       i2400mu->rx_size_auto_shrink = 1;
-}
-
-int i2400mu_notification_setup(struct i2400mu *);
-void i2400mu_notification_release(struct i2400mu *);
-
-int i2400mu_rx_setup(struct i2400mu *);
-void i2400mu_rx_release(struct i2400mu *);
-void i2400mu_rx_kick(struct i2400mu *);
-
-int i2400mu_tx_setup(struct i2400mu *);
-void i2400mu_tx_release(struct i2400mu *);
-void i2400mu_bus_tx_kick(struct i2400m *);
-
-ssize_t i2400mu_bus_bm_cmd_send(struct i2400m *,
-                               const struct i2400m_bootrom_header *, size_t,
-                               int);
-ssize_t i2400mu_bus_bm_wait_for_ack(struct i2400m *,
-                                   struct i2400m_bootrom_header *, size_t);
-#endif /* #ifndef __I2400M_USB_H__ */
diff --git a/drivers/staging/wimax/i2400m/i2400m.h b/drivers/staging/wimax/i2400m/i2400m.h
deleted file mode 100644 (file)
index de22cc6..0000000
+++ /dev/null
@@ -1,970 +0,0 @@
-/*
- * Intel Wireless WiMAX Connection 2400m
- * Declarations for bus-generic internal APIs
- *
- *
- * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   * Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in
- *     the documentation and/or other materials provided with the
- *     distribution.
- *   * Neither the name of Intel Corporation nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *
- * Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- * Yanir Lubetkin <yanirx.lubetkin@intel.com>
- *  - Initial implementation
- *
- *
- * GENERAL DRIVER ARCHITECTURE
- *
- * The i2400m driver is split in the following two major parts:
- *
- *  - bus specific driver
- *  - bus generic driver (this part)
- *
- * The bus specific driver sets up stuff specific to the bus the
- * device is connected to (USB, PCI, tam-tam...non-authoritative
- * nor binding list) which is basically the device-model management
- * (probe/disconnect, etc), moving data from device to kernel and
- * back, doing the power saving details and reseting the device.
- *
- * For details on each bus-specific driver, see it's include file,
- * i2400m-BUSNAME.h
- *
- * The bus-generic functionality break up is:
- *
- *  - Firmware upload: fw.c - takes care of uploading firmware to the
- *        device. bus-specific driver just needs to provides a way to
- *        execute boot-mode commands and to reset the device.
- *
- *  - RX handling: rx.c - receives data from the bus-specific code and
- *        feeds it to the network or WiMAX stack or uses it to modify
- *        the driver state. bus-specific driver only has to receive
- *        frames and pass them to this module.
- *
- *  - TX handling: tx.c - manages the TX FIFO queue and provides means
- *        for the bus-specific TX code to pull data from the FIFO
- *        queue. bus-specific code just pulls frames from this module
- *        to sends them to the device.
- *
- *  - netdev glue: netdev.c - interface with Linux networking
- *        stack. Pass around data frames, and configure when the
- *        device is up and running or shutdown (through ifconfig up /
- *        down). Bus-generic only.
- *
- *  - control ops: control.c - implements various commands for
- *        controlling the device. bus-generic only.
- *
- *  - device model glue: driver.c - implements helpers for the
- *        device-model glue done by the bus-specific layer
- *        (setup/release the driver resources), turning the device on
- *        and off, handling the device reboots/resets and a few simple
- *        WiMAX stack ops.
- *
- * Code is also broken up in linux-glue / device-glue.
- *
- * Linux glue contains functions that deal mostly with gluing with the
- * rest of the Linux kernel.
- *
- * Device-glue are functions that deal mostly with the way the device
- * does things and talk the device's language.
- *
- * device-glue code is licensed BSD so other open source OSes can take
- * it to implement their drivers.
- *
- *
- * APIs AND HEADER FILES
- *
- * This bus generic code exports three APIs:
- *
- *  - HDI (host-device interface) definitions common to all busses
- *    (include/linux/wimax/i2400m.h); these can be also used by user
- *    space code.
- *  - internal API for the bus-generic code
- *  - external API for the bus-specific drivers
- *
- *
- * LIFE CYCLE:
- *
- * When the bus-specific driver probes, it allocates a network device
- * with enough space for it's data structue, that must contain a
- * &struct i2400m at the top.
- *
- * On probe, it needs to fill the i2400m members marked as [fill], as
- * well as i2400m->wimax_dev.net_dev and call i2400m_setup(). The
- * i2400m driver will only register with the WiMAX and network stacks;
- * the only access done to the device is to read the MAC address so we
- * can register a network device.
- *
- * The high-level call flow is:
- *
- * bus_probe()
- *   i2400m_setup()
- *     i2400m->bus_setup()
- *     boot rom initialization / read mac addr
- *     network / WiMAX stacks registration
- *     i2400m_dev_start()
- *       i2400m->bus_dev_start()
- *       i2400m_dev_initialize()
- *
- * The reverse applies for a disconnect() call:
- *
- * bus_disconnect()
- *   i2400m_release()
- *     i2400m_dev_stop()
- *       i2400m_dev_shutdown()
- *       i2400m->bus_dev_stop()
- *     network / WiMAX stack unregistration
- *     i2400m->bus_release()
- *
- * At this point, control and data communications are possible.
- *
- * While the device is up, it might reset. The bus-specific driver has
- * to catch that situation and call i2400m_dev_reset_handle() to deal
- * with it (reset the internal driver structures and go back to square
- * one).
- */
-
-#ifndef __I2400M_H__
-#define __I2400M_H__
-
-#include <linux/usb.h>
-#include <linux/netdevice.h>
-#include <linux/completion.h>
-#include <linux/rwsem.h>
-#include <linux/atomic.h>
-#include "../net-wimax.h"
-#include "linux-wimax-i2400m.h"
-#include <asm/byteorder.h>
-
-enum {
-/* netdev interface */
-       /*
-        * Out of NWG spec (R1_v1.2.2), 3.3.3 ASN Bearer Plane MTU Size
-        *
-        * The MTU is 1400 or less
-        */
-       I2400M_MAX_MTU = 1400,
-};
-
-/* Misc constants */
-enum {
-       /* Size of the Boot Mode Command buffer */
-       I2400M_BM_CMD_BUF_SIZE = 16 * 1024,
-       I2400M_BM_ACK_BUF_SIZE = 256,
-};
-
-enum {
-       /* Maximum number of bus reset can be retried */
-       I2400M_BUS_RESET_RETRIES = 3,
-};
-
-/**
- * struct i2400m_poke_table - Hardware poke table for the Intel 2400m
- *
- * This structure will be used to create a device specific poke table
- * to put the device in a consistent state at boot time.
- *
- * @address: The device address to poke
- *
- * @data: The data value to poke to the device address
- *
- */
-struct i2400m_poke_table{
-       __le32 address;
-       __le32 data;
-};
-
-#define I2400M_FW_POKE(a, d) {         \
-       .address = cpu_to_le32(a),      \
-       .data = cpu_to_le32(d)          \
-}
-
-
-/**
- * i2400m_reset_type - methods to reset a device
- *
- * @I2400M_RT_WARM: Reset without device disconnection, device handles
- *     are kept valid but state is back to power on, with firmware
- *     re-uploaded.
- * @I2400M_RT_COLD: Tell the device to disconnect itself from the bus
- *     and reconnect. Renders all device handles invalid.
- * @I2400M_RT_BUS: Tells the bus to reset the device; last measure
- *     used when both types above don't work.
- */
-enum i2400m_reset_type {
-       I2400M_RT_WARM, /* first measure */
-       I2400M_RT_COLD, /* second measure */
-       I2400M_RT_BUS,  /* call in artillery */
-};
-
-struct i2400m_reset_ctx;
-struct i2400m_roq;
-struct i2400m_barker_db;
-
-/**
- * struct i2400m - descriptor for an Intel 2400m
- *
- * Members marked with [fill] must be filled out/initialized before
- * calling i2400m_setup().
- *
- * Note the @bus_setup/@bus_release, @bus_dev_start/@bus_dev_release
- * call pairs are very much doing almost the same, and depending on
- * the underlying bus, some stuff has to be put in one or the
- * other. The idea of setup/release is that they setup the minimal
- * amount needed for loading firmware, where us dev_start/stop setup
- * the rest needed to do full data/control traffic.
- *
- * @bus_tx_block_size: [fill] USB imposes a 16 block size, but other
- *     busses will differ.  So we have a tx_blk_size variable that the
- *     bus layer sets to tell the engine how much of that we need.
- *
- * @bus_tx_room_min: [fill] Minimum room required while allocating
- *     TX queue's buffer space for message header. USB requires
- *     16 bytes. Refer to bus specific driver code for details.
- *
- * @bus_pl_size_max: [fill] Maximum payload size.
- *
- * @bus_setup: [optional fill] Function called by the bus-generic code
- *     [i2400m_setup()] to setup the basic bus-specific communications
- *     to the the device needed to load firmware. See LIFE CYCLE above.
- *
- *     NOTE: Doesn't need to upload the firmware, as that is taken
- *     care of by the bus-generic code.
- *
- * @bus_release: [optional fill] Function called by the bus-generic
- *     code [i2400m_release()] to shutdown the basic bus-specific
- *     communications to the the device needed to load firmware. See
- *     LIFE CYCLE above.
- *
- *     This function does not need to reset the device, just tear down
- *     all the host resources created to  handle communication with
- *     the device.
- *
- * @bus_dev_start: [optional fill] Function called by the bus-generic
- *     code [i2400m_dev_start()] to do things needed to start the
- *     device. See LIFE CYCLE above.
- *
- *     NOTE: Doesn't need to upload the firmware, as that is taken
- *     care of by the bus-generic code.
- *
- * @bus_dev_stop: [optional fill] Function called by the bus-generic
- *     code [i2400m_dev_stop()] to do things needed for stopping the
- *     device. See LIFE CYCLE above.
- *
- *     This function does not need to reset the device, just tear down
- *     all the host resources created to handle communication with
- *     the device.
- *
- * @bus_tx_kick: [fill] Function called by the bus-generic code to let
- *     the bus-specific code know that there is data available in the
- *     TX FIFO for transmission to the device.
- *
- *     This function cannot sleep.
- *
- * @bus_reset: [fill] Function called by the bus-generic code to reset
- *     the device in in various ways. Doesn't need to wait for the
- *     reset to finish.
- *
- *     If warm or cold reset fail, this function is expected to do a
- *     bus-specific reset (eg: USB reset) to get the device to a
- *     working state (even if it implies device disconecction).
- *
- *     Note the warm reset is used by the firmware uploader to
- *     reinitialize the device.
- *
- *     IMPORTANT: this is called very early in the device setup
- *     process, so it cannot rely on common infrastructure being laid
- *     out.
- *
- *     IMPORTANT: don't call reset on RT_BUS with i2400m->init_mutex
- *     held, as the .pre/.post reset handlers will deadlock.
- *
- * @bus_bm_retries: [fill] How many times shall a firmware upload /
- *     device initialization be retried? Different models of the same
- *     device might need different values, hence it is set by the
- *     bus-specific driver. Note this value is used in two places,
- *     i2400m_fw_dnload() and __i2400m_dev_start(); they won't become
- *     multiplicative (__i2400m_dev_start() calling N times
- *     i2400m_fw_dnload() and this trying N times to download the
- *     firmware), as if __i2400m_dev_start() only retries if the
- *     firmware crashed while initializing the device (not in a
- *     general case).
- *
- * @bus_bm_cmd_send: [fill] Function called to send a boot-mode
- *     command. Flags are defined in 'enum i2400m_bm_cmd_flags'. This
- *     is synchronous and has to return 0 if ok or < 0 errno code in
- *     any error condition.
- *
- * @bus_bm_wait_for_ack: [fill] Function called to wait for a
- *     boot-mode notification (that can be a response to a previously
- *     issued command or an asynchronous one). Will read until all the
- *     indicated size is read or timeout. Reading more or less data
- *     than asked for is an error condition. Return 0 if ok, < 0 errno
- *     code on error.
- *
- *     The caller to this function will check if the response is a
- *     barker that indicates the device going into reset mode.
- *
- * @bus_fw_names: [fill] a NULL-terminated array with the names of the
- *     firmware images to try loading. This is made a list so we can
- *     support backward compatibility of firmware releases (eg: if we
- *     can't find the default v1.4, we try v1.3). In general, the name
- *     should be i2400m-fw-X-VERSION.sbcf, where X is the bus name.
- *     The list is tried in order and the first one that loads is
- *     used. The fw loader will set i2400m->fw_name to point to the
- *     active firmware image.
- *
- * @bus_bm_mac_addr_impaired: [fill] Set to true if the device's MAC
- *     address provided in boot mode is kind of broken and needs to
- *     be re-read later on.
- *
- * @bus_bm_pokes_table: [fill/optional] A table of device addresses
- *     and values that will be poked at device init time to move the
- *     device to the correct state for the type of boot/firmware being
- *     used.  This table MUST be terminated with (0x000000,
- *     0x00000000) or bad things will happen.
- *
- *
- * @wimax_dev: WiMAX generic device for linkage into the kernel WiMAX
- *     stack. Due to the way a net_device is allocated, we need to
- *     force this to be the first field so that we can get from
- *     netdev_priv() the right pointer.
- *
- * @updown: the device is up and ready for transmitting control and
- *     data packets. This implies @ready (communication infrastructure
- *     with the device is ready) and the device's firmware has been
- *     loaded and the device initialized.
- *
- *     Write to it only inside a i2400m->init_mutex protected area
- *     followed with a wmb(); rmb() before accesing (unless locked
- *     inside i2400m->init_mutex). Read access can be loose like that
- *     [just using rmb()] because the paths that use this also do
- *     other error checks later on.
- *
- * @ready: Communication infrastructure with the device is ready, data
- *     frames can start to be passed around (this is lighter than
- *     using the WiMAX state for certain hot paths).
- *
- *     Write to it only inside a i2400m->init_mutex protected area
- *     followed with a wmb(); rmb() before accesing (unless locked
- *     inside i2400m->init_mutex). Read access can be loose like that
- *     [just using rmb()] because the paths that use this also do
- *     other error checks later on.
- *
- * @rx_reorder: 1 if RX reordering is enabled; this can only be
- *     set at probe time.
- *
- * @state: device's state (as reported by it)
- *
- * @state_wq: waitqueue that is woken up whenever the state changes
- *
- * @tx_lock: spinlock to protect TX members
- *
- * @tx_buf: FIFO buffer for TX; we queue data here
- *
- * @tx_in: FIFO index for incoming data. Note this doesn't wrap around
- *     and it is always greater than @tx_out.
- *
- * @tx_out: FIFO index for outgoing data
- *
- * @tx_msg: current TX message that is active in the FIFO for
- *     appending payloads.
- *
- * @tx_sequence: current sequence number for TX messages from the
- *     device to the host.
- *
- * @tx_msg_size: size of the current message being transmitted by the
- *     bus-specific code.
- *
- * @tx_pl_num: total number of payloads sent
- *
- * @tx_pl_max: maximum number of payloads sent in a TX message
- *
- * @tx_pl_min: minimum number of payloads sent in a TX message
- *
- * @tx_num: number of TX messages sent
- *
- * @tx_size_acc: number of bytes in all TX messages sent
- *     (this is different to net_dev's statistics as it also counts
- *     control messages).
- *
- * @tx_size_min: smallest TX message sent.
- *
- * @tx_size_max: biggest TX message sent.
- *
- * @rx_lock: spinlock to protect RX members and rx_roq_refcount.
- *
- * @rx_pl_num: total number of payloads received
- *
- * @rx_pl_max: maximum number of payloads received in a RX message
- *
- * @rx_pl_min: minimum number of payloads received in a RX message
- *
- * @rx_num: number of RX messages received
- *
- * @rx_size_acc: number of bytes in all RX messages received
- *     (this is different to net_dev's statistics as it also counts
- *     control messages).
- *
- * @rx_size_min: smallest RX message received.
- *
- * @rx_size_max: buggest RX message received.
- *
- * @rx_roq: RX ReOrder queues. (fw >= v1.4) When packets are received
- *     out of order, the device will ask the driver to hold certain
- *     packets until the ones that are received out of order can be
- *     delivered. Then the driver can release them to the host. See
- *     drivers/net/i2400m/rx.c for details.
- *
- * @rx_roq_refcount: refcount rx_roq. This refcounts any access to
- *     rx_roq thus preventing rx_roq being destroyed when rx_roq
- *     is being accessed. rx_roq_refcount is protected by rx_lock.
- *
- * @rx_reports: reports received from the device that couldn't be
- *     processed because the driver wasn't still ready; when ready,
- *     they are pulled from here and chewed.
- *
- * @rx_reports_ws: Work struct used to kick a scan of the RX reports
- *     list and to process each.
- *
- * @src_mac_addr: MAC address used to make ethernet packets be coming
- *     from. This is generated at i2400m_setup() time and used during
- *     the life cycle of the instance. See i2400m_fake_eth_header().
- *
- * @init_mutex: Mutex used for serializing the device bringup
- *     sequence; this way if the device reboots in the middle, we
- *     don't try to do a bringup again while we are tearing down the
- *     one that failed.
- *
- *     Can't reuse @msg_mutex because from within the bringup sequence
- *     we need to send messages to the device and thus use @msg_mutex.
- *
- * @msg_mutex: mutex used to send control commands to the device (we
- *     only allow one at a time, per host-device interface design).
- *
- * @msg_completion: used to wait for an ack to a control command sent
- *     to the device.
- *
- * @ack_skb: used to store the actual ack to a control command if the
- *     reception of the command was successful. Otherwise, a ERR_PTR()
- *     errno code that indicates what failed with the ack reception.
- *
- *     Only valid after @msg_completion is woken up. Only updateable
- *     if @msg_completion is armed. Only touched by
- *     i2400m_msg_to_dev().
- *
- *     Protected by @rx_lock. In theory the command execution flow is
- *     sequential, but in case the device sends an out-of-phase or
- *     very delayed response, we need to avoid it trampling current
- *     execution.
- *
- * @bm_cmd_buf: boot mode command buffer for composing firmware upload
- *     commands.
- *
- *     USB can't r/w to stack, vmalloc, etc...as well, we end up
- *     having to alloc/free a lot to compose commands, so we use these
- *     for stagging and not having to realloc all the time.
- *
- *     This assumes the code always runs serialized. Only one thread
- *     can call i2400m_bm_cmd() at the same time.
- *
- * @bm_ack_buf: boot mode acknoledge buffer for staging reception of
- *     responses to commands.
- *
- *     See @bm_cmd_buf.
- *
- * @work_queue: work queue for processing device reports. This
- *     workqueue cannot be used for processing TX or RX to the device,
- *     as from it we'll process device reports, which might require
- *     further communication with the device.
- *
- * @debugfs_dentry: hookup for debugfs files.
- *     These have to be in a separate directory, a child of
- *     (wimax_dev->debugfs_dentry) so they can be removed when the
- *     module unloads, as we don't keep each dentry.
- *
- * @fw_name: name of the firmware image that is currently being used.
- *
- * @fw_version: version of the firmware interface, Major.minor,
- *     encoded in the high word and low word (major << 16 | minor).
- *
- * @fw_hdrs: NULL terminated array of pointers to the firmware
- *     headers. This is only available during firmware load time.
- *
- * @fw_cached: Used to cache firmware when the system goes to
- *     suspend/standby/hibernation (as on resume we can't read it). If
- *     NULL, no firmware was cached, read it. If ~0, you can't read
- *     any firmware files (the system still didn't come out of suspend
- *     and failed to cache one), so abort; otherwise, a valid cached
- *     firmware to be used. Access to this variable is protected by
- *     the spinlock i2400m->rx_lock.
- *
- * @barker: barker type that the device uses; this is initialized by
- *     i2400m_is_boot_barker() the first time it is called. Then it
- *     won't change during the life cycle of the device and every time
- *     a boot barker is received, it is just verified for it being the
- *     same.
- *
- * @pm_notifier: used to register for PM events
- *
- * @bus_reset_retries: counter for the number of bus resets attempted for
- *     this boot. It's not for tracking the number of bus resets during
- *     the whole driver life cycle (from insmod to rmmod) but for the
- *     number of dev_start() executed until dev_start() returns a success
- *     (ie: a good boot means a dev_stop() followed by a successful
- *     dev_start()). dev_reset_handler() increments this counter whenever
- *     it is triggering a bus reset. It checks this counter to decide if a
- *     subsequent bus reset should be retried. dev_reset_handler() retries
- *     the bus reset until dev_start() succeeds or the counter reaches
- *     I2400M_BUS_RESET_RETRIES. The counter is cleared to 0 in
- *     dev_reset_handle() when dev_start() returns a success,
- *     ie: a successul boot is completed.
- *
- * @alive: flag to denote if the device *should* be alive. This flag is
- *     everything like @updown (see doc for @updown) except reflecting
- *     the device state *we expect* rather than the actual state as denoted
- *     by @updown. It is set 1 whenever @updown is set 1 in dev_start().
- *     Then the device is expected to be alive all the time
- *     (i2400m->alive remains 1) until the driver is removed. Therefore
- *     all the device reboot events detected can be still handled properly
- *     by either dev_reset_handle() or .pre_reset/.post_reset as long as
- *     the driver presents. It is set 0 along with @updown in dev_stop().
- *
- * @error_recovery: flag to denote if we are ready to take an error recovery.
- *     0 for ready to take an error recovery; 1 for not ready. It is
- *     initialized to 1 while probe() since we don't tend to take any error
- *     recovery during probe(). It is decremented by 1 whenever dev_start()
- *     succeeds to indicate we are ready to take error recovery from now on.
- *     It is checked every time we wanna schedule an error recovery. If an
- *     error recovery is already in place (error_recovery was set 1), we
- *     should not schedule another one until the last one is done.
- */
-struct i2400m {
-       struct wimax_dev wimax_dev;     /* FIRST! See doc */
-
-       unsigned updown:1;              /* Network device is up or down */
-       unsigned boot_mode:1;           /* is the device in boot mode? */
-       unsigned sboot:1;               /* signed or unsigned fw boot */
-       unsigned ready:1;               /* Device comm infrastructure ready */
-       unsigned rx_reorder:1;          /* RX reorder is enabled */
-       u8 trace_msg_from_user;         /* echo rx msgs to 'trace' pipe */
-                                       /* typed u8 so /sys/kernel/debug/u8 can tweak */
-       enum i2400m_system_state state;
-       wait_queue_head_t state_wq;     /* Woken up when on state updates */
-
-       size_t bus_tx_block_size;
-       size_t bus_tx_room_min;
-       size_t bus_pl_size_max;
-       unsigned bus_bm_retries;
-
-       int (*bus_setup)(struct i2400m *);
-       int (*bus_dev_start)(struct i2400m *);
-       void (*bus_dev_stop)(struct i2400m *);
-       void (*bus_release)(struct i2400m *);
-       void (*bus_tx_kick)(struct i2400m *);
-       int (*bus_reset)(struct i2400m *, enum i2400m_reset_type);
-       ssize_t (*bus_bm_cmd_send)(struct i2400m *,
-                                  const struct i2400m_bootrom_header *,
-                                  size_t, int flags);
-       ssize_t (*bus_bm_wait_for_ack)(struct i2400m *,
-                                      struct i2400m_bootrom_header *, size_t);
-       const char **bus_fw_names;
-       unsigned bus_bm_mac_addr_impaired:1;
-       const struct i2400m_poke_table *bus_bm_pokes_table;
-
-       spinlock_t tx_lock;             /* protect TX state */
-       void *tx_buf;
-       size_t tx_in, tx_out;
-       struct i2400m_msg_hdr *tx_msg;
-       size_t tx_sequence, tx_msg_size;
-       /* TX stats */
-       unsigned tx_pl_num, tx_pl_max, tx_pl_min,
-               tx_num, tx_size_acc, tx_size_min, tx_size_max;
-
-       /* RX stuff */
-       /* protect RX state and rx_roq_refcount */
-       spinlock_t rx_lock;
-       unsigned rx_pl_num, rx_pl_max, rx_pl_min,
-               rx_num, rx_size_acc, rx_size_min, rx_size_max;
-       struct i2400m_roq *rx_roq;      /* access is refcounted */
-       struct kref rx_roq_refcount;    /* refcount access to rx_roq */
-       u8 src_mac_addr[ETH_HLEN];
-       struct list_head rx_reports;    /* under rx_lock! */
-       struct work_struct rx_report_ws;
-
-       struct mutex msg_mutex;         /* serialize command execution */
-       struct completion msg_completion;
-       struct sk_buff *ack_skb;        /* protected by rx_lock */
-
-       void *bm_ack_buf;               /* for receiving acks over USB */
-       void *bm_cmd_buf;               /* for issuing commands over USB */
-
-       struct workqueue_struct *work_queue;
-
-       struct mutex init_mutex;        /* protect bringup seq */
-       struct i2400m_reset_ctx *reset_ctx;     /* protected by init_mutex */
-
-       struct work_struct wake_tx_ws;
-       struct sk_buff *wake_tx_skb;
-
-       struct work_struct reset_ws;
-       const char *reset_reason;
-
-       struct work_struct recovery_ws;
-
-       struct dentry *debugfs_dentry;
-       const char *fw_name;            /* name of the current firmware image */
-       unsigned long fw_version;       /* version of the firmware interface */
-       const struct i2400m_bcf_hdr **fw_hdrs;
-       struct i2400m_fw *fw_cached;    /* protected by rx_lock */
-       struct i2400m_barker_db *barker;
-
-       struct notifier_block pm_notifier;
-
-       /* counting bus reset retries in this boot */
-       atomic_t bus_reset_retries;
-
-       /* if the device is expected to be alive */
-       unsigned alive;
-
-       /* 0 if we are ready for error recovery; 1 if not ready  */
-       atomic_t error_recovery;
-
-};
-
-
-/*
- * Bus-generic internal APIs
- * -------------------------
- */
-
-static inline
-struct i2400m *wimax_dev_to_i2400m(struct wimax_dev *wimax_dev)
-{
-       return container_of(wimax_dev, struct i2400m, wimax_dev);
-}
-
-static inline
-struct i2400m *net_dev_to_i2400m(struct net_device *net_dev)
-{
-       return wimax_dev_to_i2400m(netdev_priv(net_dev));
-}
-
-/*
- * Boot mode support
- */
-
-/**
- * i2400m_bm_cmd_flags - flags to i2400m_bm_cmd()
- *
- * @I2400M_BM_CMD_RAW: send the command block as-is, without doing any
- *     extra processing for adding CRC.
- */
-enum i2400m_bm_cmd_flags {
-       I2400M_BM_CMD_RAW       = 1 << 2,
-};
-
-/**
- * i2400m_bri - Boot-ROM indicators
- *
- * Flags for i2400m_bootrom_init() and i2400m_dev_bootstrap() [which
- * are passed from things like i2400m_setup()]. Can be combined with
- * |.
- *
- * @I2400M_BRI_SOFT: The device rebooted already and a reboot
- *     barker received, proceed directly to ack the boot sequence.
- * @I2400M_BRI_NO_REBOOT: Do not reboot the device and proceed
- *     directly to wait for a reboot barker from the device.
- * @I2400M_BRI_MAC_REINIT: We need to reinitialize the boot
- *     rom after reading the MAC address. This is quite a dirty hack,
- *     if you ask me -- the device requires the bootrom to be
- *     initialized after reading the MAC address.
- */
-enum i2400m_bri {
-       I2400M_BRI_SOFT       = 1 << 1,
-       I2400M_BRI_NO_REBOOT  = 1 << 2,
-       I2400M_BRI_MAC_REINIT = 1 << 3,
-};
-
-void i2400m_bm_cmd_prepare(struct i2400m_bootrom_header *);
-int i2400m_dev_bootstrap(struct i2400m *, enum i2400m_bri);
-int i2400m_read_mac_addr(struct i2400m *);
-int i2400m_bootrom_init(struct i2400m *, enum i2400m_bri);
-int i2400m_is_boot_barker(struct i2400m *, const void *, size_t);
-static inline
-int i2400m_is_d2h_barker(const void *buf)
-{
-       const __le32 *barker = buf;
-       return le32_to_cpu(*barker) == I2400M_D2H_MSG_BARKER;
-}
-void i2400m_unknown_barker(struct i2400m *, const void *, size_t);
-
-/* Make/grok boot-rom header commands */
-
-static inline
-__le32 i2400m_brh_command(enum i2400m_brh_opcode opcode, unsigned use_checksum,
-                         unsigned direct_access)
-{
-       return cpu_to_le32(
-               I2400M_BRH_SIGNATURE
-               | (direct_access ? I2400M_BRH_DIRECT_ACCESS : 0)
-               | I2400M_BRH_RESPONSE_REQUIRED /* response always required */
-               | (use_checksum ? I2400M_BRH_USE_CHECKSUM : 0)
-               | (opcode & I2400M_BRH_OPCODE_MASK));
-}
-
-static inline
-void i2400m_brh_set_opcode(struct i2400m_bootrom_header *hdr,
-                          enum i2400m_brh_opcode opcode)
-{
-       hdr->command = cpu_to_le32(
-               (le32_to_cpu(hdr->command) & ~I2400M_BRH_OPCODE_MASK)
-               | (opcode & I2400M_BRH_OPCODE_MASK));
-}
-
-static inline
-unsigned i2400m_brh_get_opcode(const struct i2400m_bootrom_header *hdr)
-{
-       return le32_to_cpu(hdr->command) & I2400M_BRH_OPCODE_MASK;
-}
-
-static inline
-unsigned i2400m_brh_get_response(const struct i2400m_bootrom_header *hdr)
-{
-       return (le32_to_cpu(hdr->command) & I2400M_BRH_RESPONSE_MASK)
-               >> I2400M_BRH_RESPONSE_SHIFT;
-}
-
-static inline
-unsigned i2400m_brh_get_use_checksum(const struct i2400m_bootrom_header *hdr)
-{
-       return le32_to_cpu(hdr->command) & I2400M_BRH_USE_CHECKSUM;
-}
-
-static inline
-unsigned i2400m_brh_get_response_required(
-       const struct i2400m_bootrom_header *hdr)
-{
-       return le32_to_cpu(hdr->command) & I2400M_BRH_RESPONSE_REQUIRED;
-}
-
-static inline
-unsigned i2400m_brh_get_direct_access(const struct i2400m_bootrom_header *hdr)
-{
-       return le32_to_cpu(hdr->command) & I2400M_BRH_DIRECT_ACCESS;
-}
-
-static inline
-unsigned i2400m_brh_get_signature(const struct i2400m_bootrom_header *hdr)
-{
-       return (le32_to_cpu(hdr->command) & I2400M_BRH_SIGNATURE_MASK)
-               >> I2400M_BRH_SIGNATURE_SHIFT;
-}
-
-
-/*
- * Driver / device setup and internal functions
- */
-void i2400m_init(struct i2400m *);
-int i2400m_reset(struct i2400m *, enum i2400m_reset_type);
-void i2400m_netdev_setup(struct net_device *net_dev);
-int i2400m_sysfs_setup(struct device_driver *);
-void i2400m_sysfs_release(struct device_driver *);
-int i2400m_tx_setup(struct i2400m *);
-void i2400m_wake_tx_work(struct work_struct *);
-void i2400m_tx_release(struct i2400m *);
-
-int i2400m_rx_setup(struct i2400m *);
-void i2400m_rx_release(struct i2400m *);
-
-void i2400m_fw_cache(struct i2400m *);
-void i2400m_fw_uncache(struct i2400m *);
-
-void i2400m_net_rx(struct i2400m *, struct sk_buff *, unsigned, const void *,
-                  int);
-void i2400m_net_erx(struct i2400m *, struct sk_buff *, enum i2400m_cs);
-void i2400m_net_wake_stop(struct i2400m *);
-enum i2400m_pt;
-int i2400m_tx(struct i2400m *, const void *, size_t, enum i2400m_pt);
-
-#ifdef CONFIG_DEBUG_FS
-void i2400m_debugfs_add(struct i2400m *);
-void i2400m_debugfs_rm(struct i2400m *);
-#else
-static inline void i2400m_debugfs_add(struct i2400m *i2400m) {}
-static inline void i2400m_debugfs_rm(struct i2400m *i2400m) {}
-#endif
-
-/* Initialize/shutdown the device */
-int i2400m_dev_initialize(struct i2400m *);
-void i2400m_dev_shutdown(struct i2400m *);
-
-extern struct attribute_group i2400m_dev_attr_group;
-
-
-/* HDI message's payload description handling */
-
-static inline
-size_t i2400m_pld_size(const struct i2400m_pld *pld)
-{
-       return I2400M_PLD_SIZE_MASK & le32_to_cpu(pld->val);
-}
-
-static inline
-enum i2400m_pt i2400m_pld_type(const struct i2400m_pld *pld)
-{
-       return (I2400M_PLD_TYPE_MASK & le32_to_cpu(pld->val))
-               >> I2400M_PLD_TYPE_SHIFT;
-}
-
-static inline
-void i2400m_pld_set(struct i2400m_pld *pld, size_t size,
-                   enum i2400m_pt type)
-{
-       pld->val = cpu_to_le32(
-               ((type << I2400M_PLD_TYPE_SHIFT) & I2400M_PLD_TYPE_MASK)
-               |  (size & I2400M_PLD_SIZE_MASK));
-}
-
-
-/*
- * API for the bus-specific drivers
- * --------------------------------
- */
-
-static inline
-struct i2400m *i2400m_get(struct i2400m *i2400m)
-{
-       dev_hold(i2400m->wimax_dev.net_dev);
-       return i2400m;
-}
-
-static inline
-void i2400m_put(struct i2400m *i2400m)
-{
-       dev_put(i2400m->wimax_dev.net_dev);
-}
-
-int i2400m_dev_reset_handle(struct i2400m *, const char *);
-int i2400m_pre_reset(struct i2400m *);
-int i2400m_post_reset(struct i2400m *);
-void i2400m_error_recovery(struct i2400m *);
-
-/*
- * _setup()/_release() are called by the probe/disconnect functions of
- * the bus-specific drivers.
- */
-int i2400m_setup(struct i2400m *, enum i2400m_bri bm_flags);
-void i2400m_release(struct i2400m *);
-
-int i2400m_rx(struct i2400m *, struct sk_buff *);
-struct i2400m_msg_hdr *i2400m_tx_msg_get(struct i2400m *, size_t *);
-void i2400m_tx_msg_sent(struct i2400m *);
-
-
-/*
- * Utility functions
- */
-
-static inline
-struct device *i2400m_dev(struct i2400m *i2400m)
-{
-       return i2400m->wimax_dev.net_dev->dev.parent;
-}
-
-int i2400m_msg_check_status(const struct i2400m_l3l4_hdr *, char *, size_t);
-int i2400m_msg_size_check(struct i2400m *, const struct i2400m_l3l4_hdr *,
-                         size_t);
-struct sk_buff *i2400m_msg_to_dev(struct i2400m *, const void *, size_t);
-void i2400m_msg_to_dev_cancel_wait(struct i2400m *, int);
-void i2400m_report_hook(struct i2400m *, const struct i2400m_l3l4_hdr *,
-                       size_t);
-void i2400m_report_hook_work(struct work_struct *);
-int i2400m_cmd_enter_powersave(struct i2400m *);
-int i2400m_cmd_exit_idle(struct i2400m *);
-struct sk_buff *i2400m_get_device_info(struct i2400m *);
-int i2400m_firmware_check(struct i2400m *);
-int i2400m_set_idle_timeout(struct i2400m *, unsigned);
-
-static inline
-struct usb_endpoint_descriptor *usb_get_epd(struct usb_interface *iface, int ep)
-{
-       return &iface->cur_altsetting->endpoint[ep].desc;
-}
-
-int i2400m_op_rfkill_sw_toggle(struct wimax_dev *, enum wimax_rf_state);
-void i2400m_report_tlv_rf_switches_status(struct i2400m *,
-                                         const struct i2400m_tlv_rf_switches_status *);
-
-/*
- * Helpers for firmware backwards compatibility
- *
- * As we aim to support at least the firmware version that was
- * released with the previous kernel/driver release, some code will be
- * conditionally executed depending on the firmware version. On each
- * release, the code to support fw releases past the last two ones
- * will be purged.
- *
- * By making it depend on this macros, it is easier to keep it a tab
- * on what has to go and what not.
- */
-static inline
-unsigned i2400m_le_v1_3(struct i2400m *i2400m)
-{
-       /* running fw is lower or v1.3 */
-       return i2400m->fw_version <= 0x00090001;
-}
-
-static inline
-unsigned i2400m_ge_v1_4(struct i2400m *i2400m)
-{
-       /* running fw is higher or v1.4 */
-       return i2400m->fw_version >= 0x00090002;
-}
-
-
-/*
- * Do a millisecond-sleep for allowing wireshark to dump all the data
- * packets. Used only for debugging.
- */
-static inline
-void __i2400m_msleep(unsigned ms)
-{
-#if 1
-#else
-       msleep(ms);
-#endif
-}
-
-
-/* module initialization helpers */
-int i2400m_barker_db_init(const char *);
-void i2400m_barker_db_exit(void);
-
-
-
-#endif /* #ifndef __I2400M_H__ */
diff --git a/drivers/staging/wimax/i2400m/linux-wimax-i2400m.h b/drivers/staging/wimax/i2400m/linux-wimax-i2400m.h
deleted file mode 100644 (file)
index fd198bc..0000000
+++ /dev/null
@@ -1,572 +0,0 @@
-/*
- * Intel Wireless WiMax Connection 2400m
- * Host-Device protocol interface definitions
- *
- *
- * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   * Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in
- *     the documentation and/or other materials provided with the
- *     distribution.
- *   * Neither the name of Intel Corporation nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *
- * Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *  - Initial implementation
- *
- *
- * This header defines the data structures and constants used to
- * communicate with the device.
- *
- * BOOTMODE/BOOTROM/FIRMWARE UPLOAD PROTOCOL
- *
- * The firmware upload protocol is quite simple and only requires a
- * handful of commands. See drivers/net/wimax/i2400m/fw.c for more
- * details.
- *
- * The BCF data structure is for the firmware file header.
- *
- *
- * THE DATA / CONTROL PROTOCOL
- *
- * This is the normal protocol spoken with the device once the
- * firmware is uploaded. It transports data payloads and control
- * messages back and forth.
- *
- * It consists 'messages' that pack one or more payloads each. The
- * format is described in detail in drivers/net/wimax/i2400m/rx.c and
- * tx.c.
- *
- *
- * THE L3L4 PROTOCOL
- *
- * The term L3L4 refers to Layer 3 (the device), Layer 4 (the
- * driver/host software).
- *
- * This is the control protocol used by the host to control the i2400m
- * device (scan, connect, disconnect...). This is sent to / received
- * as control frames. These frames consist of a header and zero or
- * more TLVs with information. We call each control frame a "message".
- *
- * Each message is composed of:
- *
- * HEADER
- * [TLV0 + PAYLOAD0]
- * [TLV1 + PAYLOAD1]
- * [...]
- * [TLVN + PAYLOADN]
- *
- * The HEADER is defined by 'struct i2400m_l3l4_hdr'. The payloads are
- * defined by a TLV structure (Type Length Value) which is a 'header'
- * (struct i2400m_tlv_hdr) and then the payload.
- *
- * All integers are represented as Little Endian.
- *
- * - REQUESTS AND EVENTS
- *
- * The requests can be clasified as follows:
- *
- *   COMMAND:  implies a request from the host to the device requesting
- *             an action being performed. The device will reply with a
- *             message (with the same type as the command), status and
- *             no (TLV) payload. Execution of a command might cause
- *             events (of different type) to be sent later on as
- *             device's state changes.
- *
- *   GET/SET:  similar to COMMAND, but will not cause other
- *             EVENTs. The reply, in the case of GET, will contain
- *             TLVs with the requested information.
- *
- *   EVENT:    asynchronous messages sent from the device, maybe as a
- *             consequence of previous COMMANDs but disassociated from
- *             them.
- *
- * Only one request might be pending at the same time (ie: don't
- * parallelize nor post another GET request before the previous
- * COMMAND has been acknowledged with it's corresponding reply by the
- * device).
- *
- * The different requests and their formats are described below:
- *
- *  I2400M_MT_*   Message types
- *  I2400M_MS_*   Message status (for replies, events)
- *  i2400m_tlv_*  TLVs
- *
- * data types are named 'struct i2400m_msg_OPNAME', OPNAME matching the
- * operation.
- */
-
-#ifndef __LINUX__WIMAX__I2400M_H__
-#define __LINUX__WIMAX__I2400M_H__
-
-#include <linux/types.h>
-#include <linux/if_ether.h>
-
-/*
- * Host Device Interface (HDI) common to all busses
- */
-
-/* Boot-mode (firmware upload mode) commands */
-
-/* Header for the firmware file */
-struct i2400m_bcf_hdr {
-       __le32 module_type;
-       __le32 header_len;
-       __le32 header_version;
-       __le32 module_id;
-       __le32 module_vendor;
-       __le32 date;            /* BCD YYYMMDD */
-       __le32 size;            /* in dwords */
-       __le32 key_size;        /* in dwords */
-       __le32 modulus_size;    /* in dwords */
-       __le32 exponent_size;   /* in dwords */
-       __u8 reserved[88];
-} __attribute__ ((packed));
-
-/* Boot mode opcodes */
-enum i2400m_brh_opcode {
-       I2400M_BRH_READ = 1,
-       I2400M_BRH_WRITE = 2,
-       I2400M_BRH_JUMP = 3,
-       I2400M_BRH_SIGNED_JUMP = 8,
-       I2400M_BRH_HASH_PAYLOAD_ONLY = 9,
-};
-
-/* Boot mode command masks and stuff */
-enum i2400m_brh {
-       I2400M_BRH_SIGNATURE = 0xcbbc0000,
-       I2400M_BRH_SIGNATURE_MASK = 0xffff0000,
-       I2400M_BRH_SIGNATURE_SHIFT = 16,
-       I2400M_BRH_OPCODE_MASK = 0x0000000f,
-       I2400M_BRH_RESPONSE_MASK = 0x000000f0,
-       I2400M_BRH_RESPONSE_SHIFT = 4,
-       I2400M_BRH_DIRECT_ACCESS = 0x00000400,
-       I2400M_BRH_RESPONSE_REQUIRED = 0x00000200,
-       I2400M_BRH_USE_CHECKSUM = 0x00000100,
-};
-
-
-/**
- * i2400m_bootrom_header - Header for a boot-mode command
- *
- * @cmd: the above command descriptor
- * @target_addr: where on the device memory should the action be performed.
- * @data_size: for read/write, amount of data to be read/written
- * @block_checksum: checksum value (if applicable)
- * @payload: the beginning of data attached to this header
- */
-struct i2400m_bootrom_header {
-       __le32 command;         /* Compose with enum i2400_brh */
-       __le32 target_addr;
-       __le32 data_size;
-       __le32 block_checksum;
-       char payload[0];
-} __attribute__ ((packed));
-
-
-/*
- * Data / control protocol
- */
-
-/* Packet types for the host-device interface */
-enum i2400m_pt {
-       I2400M_PT_DATA = 0,
-       I2400M_PT_CTRL,
-       I2400M_PT_TRACE,        /* For device debug */
-       I2400M_PT_RESET_WARM,   /* device reset */
-       I2400M_PT_RESET_COLD,   /* USB[transport] reset, like reconnect */
-       I2400M_PT_EDATA,        /* Extended RX data */
-       I2400M_PT_ILLEGAL
-};
-
-
-/*
- * Payload for a data packet
- *
- * This is prefixed to each and every outgoing DATA type.
- */
-struct i2400m_pl_data_hdr {
-       __le32 reserved;
-} __attribute__((packed));
-
-
-/*
- * Payload for an extended data packet
- *
- * New in fw v1.4
- *
- * @reorder: if this payload has to be reorder or not (and how)
- * @cs: the type of data in the packet, as defined per (802.16e
- *     T11.13.19.1). Currently only 2 (IPv4 packet) supported.
- *
- * This is prefixed to each and every INCOMING DATA packet.
- */
-struct i2400m_pl_edata_hdr {
-       __le32 reorder;         /* bits defined in i2400m_ro */
-       __u8 cs;
-       __u8 reserved[11];
-} __attribute__((packed));
-
-enum i2400m_cs {
-       I2400M_CS_IPV4_0 = 0,
-       I2400M_CS_IPV4 = 2,
-};
-
-enum i2400m_ro {
-       I2400M_RO_NEEDED     = 0x01,
-       I2400M_RO_TYPE       = 0x03,
-       I2400M_RO_TYPE_SHIFT = 1,
-       I2400M_RO_CIN        = 0x0f,
-       I2400M_RO_CIN_SHIFT  = 4,
-       I2400M_RO_FBN        = 0x07ff,
-       I2400M_RO_FBN_SHIFT  = 8,
-       I2400M_RO_SN         = 0x07ff,
-       I2400M_RO_SN_SHIFT   = 21,
-};
-
-enum i2400m_ro_type {
-       I2400M_RO_TYPE_RESET = 0,
-       I2400M_RO_TYPE_PACKET,
-       I2400M_RO_TYPE_WS,
-       I2400M_RO_TYPE_PACKET_WS,
-};
-
-
-/* Misc constants */
-enum {
-       I2400M_PL_ALIGN = 16,   /* Payload data size alignment */
-       I2400M_PL_SIZE_MAX = 0x3EFF,
-       I2400M_MAX_PLS_IN_MSG = 60,
-       /* protocol barkers: sync sequences; for notifications they
-        * are sent in groups of four. */
-       I2400M_H2D_PREVIEW_BARKER = 0xcafe900d,
-       I2400M_COLD_RESET_BARKER = 0xc01dc01d,
-       I2400M_WARM_RESET_BARKER = 0x50f750f7,
-       I2400M_NBOOT_BARKER = 0xdeadbeef,
-       I2400M_SBOOT_BARKER = 0x0ff1c1a1,
-       I2400M_SBOOT_BARKER_6050 = 0x80000001,
-       I2400M_ACK_BARKER = 0xfeedbabe,
-       I2400M_D2H_MSG_BARKER = 0xbeefbabe,
-};
-
-
-/*
- * Hardware payload descriptor
- *
- * Bitfields encoded in a struct to enforce typing semantics.
- *
- * Look in rx.c and tx.c for a full description of the format.
- */
-struct i2400m_pld {
-       __le32 val;
-} __attribute__ ((packed));
-
-#define I2400M_PLD_SIZE_MASK 0x00003fff
-#define I2400M_PLD_TYPE_SHIFT 16
-#define I2400M_PLD_TYPE_MASK 0x000f0000
-
-/*
- * Header for a TX message or RX message
- *
- * @barker: preamble
- * @size: used for management of the FIFO queue buffer; before
- *     sending, this is converted to be a real preamble. This
- *     indicates the real size of the TX message that starts at this
- *     point. If the highest bit is set, then this message is to be
- *     skipped.
- * @sequence: sequence number of this message
- * @offset: offset where the message itself starts -- see the comments
- *     in the file header about message header and payload descriptor
- *     alignment.
- * @num_pls: number of payloads in this message
- * @padding: amount of padding bytes at the end of the message to make
- *           it be of block-size aligned
- *
- * Look in rx.c and tx.c for a full description of the format.
- */
-struct i2400m_msg_hdr {
-       union {
-               __le32 barker;
-               __u32 size;     /* same size type as barker!! */
-       };
-       union {
-               __le32 sequence;
-               __u32 offset;   /* same size type as barker!! */
-       };
-       __le16 num_pls;
-       __le16 rsv1;
-       __le16 padding;
-       __le16 rsv2;
-       struct i2400m_pld pld[0];
-} __attribute__ ((packed));
-
-
-
-/*
- * L3/L4 control protocol
- */
-
-enum {
-       /* Interface version */
-       I2400M_L3L4_VERSION             = 0x0100,
-};
-
-/* Message types */
-enum i2400m_mt {
-       I2400M_MT_RESERVED              = 0x0000,
-       I2400M_MT_INVALID               = 0xffff,
-       I2400M_MT_REPORT_MASK           = 0x8000,
-
-       I2400M_MT_GET_SCAN_RESULT       = 0x4202,
-       I2400M_MT_SET_SCAN_PARAM        = 0x4402,
-       I2400M_MT_CMD_RF_CONTROL        = 0x4602,
-       I2400M_MT_CMD_SCAN              = 0x4603,
-       I2400M_MT_CMD_CONNECT           = 0x4604,
-       I2400M_MT_CMD_DISCONNECT        = 0x4605,
-       I2400M_MT_CMD_EXIT_IDLE         = 0x4606,
-       I2400M_MT_GET_LM_VERSION        = 0x5201,
-       I2400M_MT_GET_DEVICE_INFO       = 0x5202,
-       I2400M_MT_GET_LINK_STATUS       = 0x5203,
-       I2400M_MT_GET_STATISTICS        = 0x5204,
-       I2400M_MT_GET_STATE             = 0x5205,
-       I2400M_MT_GET_MEDIA_STATUS      = 0x5206,
-       I2400M_MT_SET_INIT_CONFIG       = 0x5404,
-       I2400M_MT_CMD_INIT              = 0x5601,
-       I2400M_MT_CMD_TERMINATE         = 0x5602,
-       I2400M_MT_CMD_MODE_OF_OP        = 0x5603,
-       I2400M_MT_CMD_RESET_DEVICE      = 0x5604,
-       I2400M_MT_CMD_MONITOR_CONTROL   = 0x5605,
-       I2400M_MT_CMD_ENTER_POWERSAVE   = 0x5606,
-       I2400M_MT_GET_TLS_OPERATION_RESULT = 0x6201,
-       I2400M_MT_SET_EAP_SUCCESS       = 0x6402,
-       I2400M_MT_SET_EAP_FAIL          = 0x6403,
-       I2400M_MT_SET_EAP_KEY           = 0x6404,
-       I2400M_MT_CMD_SEND_EAP_RESPONSE = 0x6602,
-       I2400M_MT_REPORT_SCAN_RESULT    = 0xc002,
-       I2400M_MT_REPORT_STATE          = 0xd002,
-       I2400M_MT_REPORT_POWERSAVE_READY = 0xd005,
-       I2400M_MT_REPORT_EAP_REQUEST    = 0xe002,
-       I2400M_MT_REPORT_EAP_RESTART    = 0xe003,
-       I2400M_MT_REPORT_ALT_ACCEPT     = 0xe004,
-       I2400M_MT_REPORT_KEY_REQUEST    = 0xe005,
-};
-
-
-/*
- * Message Ack Status codes
- *
- * When a message is replied-to, this status is reported.
- */
-enum i2400m_ms {
-       I2400M_MS_DONE_OK                  = 0,
-       I2400M_MS_DONE_IN_PROGRESS         = 1,
-       I2400M_MS_INVALID_OP               = 2,
-       I2400M_MS_BAD_STATE                = 3,
-       I2400M_MS_ILLEGAL_VALUE            = 4,
-       I2400M_MS_MISSING_PARAMS           = 5,
-       I2400M_MS_VERSION_ERROR            = 6,
-       I2400M_MS_ACCESSIBILITY_ERROR      = 7,
-       I2400M_MS_BUSY                     = 8,
-       I2400M_MS_CORRUPTED_TLV            = 9,
-       I2400M_MS_UNINITIALIZED            = 10,
-       I2400M_MS_UNKNOWN_ERROR            = 11,
-       I2400M_MS_PRODUCTION_ERROR         = 12,
-       I2400M_MS_NO_RF                    = 13,
-       I2400M_MS_NOT_READY_FOR_POWERSAVE  = 14,
-       I2400M_MS_THERMAL_CRITICAL         = 15,
-       I2400M_MS_MAX
-};
-
-
-/**
- * i2400m_tlv - enumeration of the different types of TLVs
- *
- * TLVs stand for type-length-value and are the header for a payload
- * composed of almost anything. Each payload has a type assigned
- * and a length.
- */
-enum i2400m_tlv {
-       I2400M_TLV_L4_MESSAGE_VERSIONS = 129,
-       I2400M_TLV_SYSTEM_STATE = 141,
-       I2400M_TLV_MEDIA_STATUS = 161,
-       I2400M_TLV_RF_OPERATION = 162,
-       I2400M_TLV_RF_STATUS = 163,
-       I2400M_TLV_DEVICE_RESET_TYPE = 132,
-       I2400M_TLV_CONFIG_IDLE_PARAMETERS = 601,
-       I2400M_TLV_CONFIG_IDLE_TIMEOUT = 611,
-       I2400M_TLV_CONFIG_D2H_DATA_FORMAT = 614,
-       I2400M_TLV_CONFIG_DL_HOST_REORDER = 615,
-};
-
-
-struct i2400m_tlv_hdr {
-       __le16 type;
-       __le16 length;          /* payload's */
-       __u8   pl[0];
-} __attribute__((packed));
-
-
-struct i2400m_l3l4_hdr {
-       __le16 type;
-       __le16 length;          /* payload's */
-       __le16 version;
-       __le16 resv1;
-       __le16 status;
-       __le16 resv2;
-       struct i2400m_tlv_hdr pl[0];
-} __attribute__((packed));
-
-
-/**
- * i2400m_system_state - different states of the device
- */
-enum i2400m_system_state {
-       I2400M_SS_UNINITIALIZED = 1,
-       I2400M_SS_INIT,
-       I2400M_SS_READY,
-       I2400M_SS_SCAN,
-       I2400M_SS_STANDBY,
-       I2400M_SS_CONNECTING,
-       I2400M_SS_WIMAX_CONNECTED,
-       I2400M_SS_DATA_PATH_CONNECTED,
-       I2400M_SS_IDLE,
-       I2400M_SS_DISCONNECTING,
-       I2400M_SS_OUT_OF_ZONE,
-       I2400M_SS_SLEEPACTIVE,
-       I2400M_SS_PRODUCTION,
-       I2400M_SS_CONFIG,
-       I2400M_SS_RF_OFF,
-       I2400M_SS_RF_SHUTDOWN,
-       I2400M_SS_DEVICE_DISCONNECT,
-       I2400M_SS_MAX,
-};
-
-
-/**
- * i2400m_tlv_system_state - report on the state of the system
- *
- * @state: see enum i2400m_system_state
- */
-struct i2400m_tlv_system_state {
-       struct i2400m_tlv_hdr hdr;
-       __le32 state;
-} __attribute__((packed));
-
-
-struct i2400m_tlv_l4_message_versions {
-       struct i2400m_tlv_hdr hdr;
-       __le16 major;
-       __le16 minor;
-       __le16 branch;
-       __le16 reserved;
-} __attribute__((packed));
-
-
-struct i2400m_tlv_detailed_device_info {
-       struct i2400m_tlv_hdr hdr;
-       __u8 reserved1[400];
-       __u8 mac_address[ETH_ALEN];
-       __u8 reserved2[2];
-} __attribute__((packed));
-
-
-enum i2400m_rf_switch_status {
-       I2400M_RF_SWITCH_ON = 1,
-       I2400M_RF_SWITCH_OFF = 2,
-};
-
-struct i2400m_tlv_rf_switches_status {
-       struct i2400m_tlv_hdr hdr;
-       __u8 sw_rf_switch;      /* 1 ON, 2 OFF */
-       __u8 hw_rf_switch;      /* 1 ON, 2 OFF */
-       __u8 reserved[2];
-} __attribute__((packed));
-
-
-enum {
-       i2400m_rf_operation_on = 1,
-       i2400m_rf_operation_off = 2
-};
-
-struct i2400m_tlv_rf_operation {
-       struct i2400m_tlv_hdr hdr;
-       __le32 status;  /* 1 ON, 2 OFF */
-} __attribute__((packed));
-
-
-enum i2400m_tlv_reset_type {
-       I2400M_RESET_TYPE_COLD = 1,
-       I2400M_RESET_TYPE_WARM
-};
-
-struct i2400m_tlv_device_reset_type {
-       struct i2400m_tlv_hdr hdr;
-       __le32 reset_type;
-} __attribute__((packed));
-
-
-struct i2400m_tlv_config_idle_parameters {
-       struct i2400m_tlv_hdr hdr;
-       __le32 idle_timeout;    /* 100 to 300000 ms [5min], 100 increments
-                                * 0 disabled */
-       __le32 idle_paging_interval;    /* frames */
-} __attribute__((packed));
-
-
-enum i2400m_media_status {
-       I2400M_MEDIA_STATUS_LINK_UP = 1,
-       I2400M_MEDIA_STATUS_LINK_DOWN,
-       I2400M_MEDIA_STATUS_LINK_RENEW,
-};
-
-struct i2400m_tlv_media_status {
-       struct i2400m_tlv_hdr hdr;
-       __le32 media_status;
-} __attribute__((packed));
-
-
-/* New in v1.4 */
-struct i2400m_tlv_config_idle_timeout {
-       struct i2400m_tlv_hdr hdr;
-       __le32 timeout; /* 100 to 300000 ms [5min], 100 increments
-                        * 0 disabled */
-} __attribute__((packed));
-
-/* New in v1.4 -- for backward compat, will be removed */
-struct i2400m_tlv_config_d2h_data_format {
-       struct i2400m_tlv_hdr hdr;
-       __u8 format;            /* 0 old format, 1 enhanced */
-       __u8 reserved[3];
-} __attribute__((packed));
-
-/* New in v1.4 */
-struct i2400m_tlv_config_dl_host_reorder {
-       struct i2400m_tlv_hdr hdr;
-       __u8 reorder;           /* 0 disabled, 1 enabled */
-       __u8 reserved[3];
-} __attribute__((packed));
-
-
-#endif /* #ifndef __LINUX__WIMAX__I2400M_H__ */
diff --git a/drivers/staging/wimax/i2400m/netdev.c b/drivers/staging/wimax/i2400m/netdev.c
deleted file mode 100644 (file)
index 5b53e59..0000000
+++ /dev/null
@@ -1,603 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel Wireless WiMAX Connection 2400m
- * Glue with the networking stack
- *
- * Copyright (C) 2007 Intel Corporation <linux-wimax@intel.com>
- * Yanir Lubetkin <yanirx.lubetkin@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *
- * This implements an ethernet device for the i2400m.
- *
- * We fake being an ethernet device to simplify the support from user
- * space and from the other side. The world is (sadly) configured to
- * take in only Ethernet devices...
- *
- * Because of this, when using firmwares <= v1.3, there is an
- * copy-each-rxed-packet overhead on the RX path. Each IP packet has
- * to be reallocated to add an ethernet header (as there is no space
- * in what we get from the device). This is a known drawback and
- * firmwares >= 1.4 add header space that can be used to insert the
- * ethernet header without having to reallocate and copy.
- *
- * TX error handling is tricky; because we have to FIFO/queue the
- * buffers for transmission (as the hardware likes it aggregated), we
- * just give the skb to the TX subsystem and by the time it is
- * transmitted, we have long forgotten about it. So we just don't care
- * too much about it.
- *
- * Note that when the device is in idle mode with the basestation, we
- * need to negotiate coming back up online. That involves negotiation
- * and possible user space interaction. Thus, we defer to a workqueue
- * to do all that. By default, we only queue a single packet and drop
- * the rest, as potentially the time to go back from idle to normal is
- * long.
- *
- * ROADMAP
- *
- * i2400m_open         Called on ifconfig up
- * i2400m_stop         Called on ifconfig down
- *
- * i2400m_hard_start_xmit Called by the network stack to send a packet
- *   i2400m_net_wake_tx          Wake up device from basestation-IDLE & TX
- *     i2400m_wake_tx_work
- *       i2400m_cmd_exit_idle
- *       i2400m_tx
- *   i2400m_net_tx        TX a data frame
- *     i2400m_tx
- *
- * i2400m_change_mtu      Called on ifconfig mtu XXX
- *
- * i2400m_tx_timeout      Called when the device times out
- *
- * i2400m_net_rx          Called by the RX code when a data frame is
- *                        available (firmware <= 1.3)
- * i2400m_net_erx         Called by the RX code when a data frame is
- *                        available (firmware >= 1.4).
- * i2400m_netdev_setup    Called to setup all the netdev stuff from
- *                        alloc_netdev.
- */
-#include <linux/if_arp.h>
-#include <linux/slab.h>
-#include <linux/netdevice.h>
-#include <linux/ethtool.h>
-#include <linux/export.h>
-#include "i2400m.h"
-
-
-#define D_SUBMODULE netdev
-#include "debug-levels.h"
-
-enum {
-/* netdev interface */
-       /* 20 secs? yep, this is the maximum timeout that the device
-        * might take to get out of IDLE / negotiate it with the base
-        * station. We add 1sec for good measure. */
-       I2400M_TX_TIMEOUT = 21 * HZ,
-       /*
-        * Experimentation has determined that, 20 to be a good value
-        * for minimizing the jitter in the throughput.
-        */
-       I2400M_TX_QLEN = 20,
-};
-
-
-static
-int i2400m_open(struct net_device *net_dev)
-{
-       int result;
-       struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
-       struct device *dev = i2400m_dev(i2400m);
-
-       d_fnstart(3, dev, "(net_dev %p [i2400m %p])\n", net_dev, i2400m);
-       /* Make sure we wait until init is complete... */
-       mutex_lock(&i2400m->init_mutex);
-       if (i2400m->updown)
-               result = 0;
-       else
-               result = -EBUSY;
-       mutex_unlock(&i2400m->init_mutex);
-       d_fnend(3, dev, "(net_dev %p [i2400m %p]) = %d\n",
-               net_dev, i2400m, result);
-       return result;
-}
-
-
-static
-int i2400m_stop(struct net_device *net_dev)
-{
-       struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
-       struct device *dev = i2400m_dev(i2400m);
-
-       d_fnstart(3, dev, "(net_dev %p [i2400m %p])\n", net_dev, i2400m);
-       i2400m_net_wake_stop(i2400m);
-       d_fnend(3, dev, "(net_dev %p [i2400m %p]) = 0\n", net_dev, i2400m);
-       return 0;
-}
-
-
-/*
- * Wake up the device and transmit a held SKB, then restart the net queue
- *
- * When the device goes into basestation-idle mode, we need to tell it
- * to exit that mode; it will negotiate with the base station, user
- * space may have to intervene to rehandshake crypto and then tell us
- * when it is ready to transmit the packet we have "queued". Still we
- * need to give it sometime after it reports being ok.
- *
- * On error, there is not much we can do. If the error was on TX, we
- * still wake the queue up to see if the next packet will be luckier.
- *
- * If _cmd_exit_idle() fails...well, it could be many things; most
- * commonly it is that something else took the device out of IDLE mode
- * (for example, the base station). In that case we get an -EILSEQ and
- * we are just going to ignore that one. If the device is back to
- * connected, then fine -- if it is someother state, the packet will
- * be dropped anyway.
- */
-void i2400m_wake_tx_work(struct work_struct *ws)
-{
-       int result;
-       struct i2400m *i2400m = container_of(ws, struct i2400m, wake_tx_ws);
-       struct net_device *net_dev = i2400m->wimax_dev.net_dev;
-       struct device *dev = i2400m_dev(i2400m);
-       struct sk_buff *skb;
-       unsigned long flags;
-
-       spin_lock_irqsave(&i2400m->tx_lock, flags);
-       skb = i2400m->wake_tx_skb;
-       i2400m->wake_tx_skb = NULL;
-       spin_unlock_irqrestore(&i2400m->tx_lock, flags);
-
-       d_fnstart(3, dev, "(ws %p i2400m %p skb %p)\n", ws, i2400m, skb);
-       result = -EINVAL;
-       if (skb == NULL) {
-               dev_err(dev, "WAKE&TX: skb disappeared!\n");
-               goto out_put;
-       }
-       /* If we have, somehow, lost the connection after this was
-        * queued, don't do anything; this might be the device got
-        * reset or just disconnected. */
-       if (unlikely(!netif_carrier_ok(net_dev)))
-               goto out_kfree;
-       result = i2400m_cmd_exit_idle(i2400m);
-       if (result == -EILSEQ)
-               result = 0;
-       if (result < 0) {
-               dev_err(dev, "WAKE&TX: device didn't get out of idle: "
-                       "%d - resetting\n", result);
-               i2400m_reset(i2400m, I2400M_RT_BUS);
-               goto error;
-       }
-       result = wait_event_timeout(i2400m->state_wq,
-                                   i2400m->state != I2400M_SS_IDLE,
-                                   net_dev->watchdog_timeo - HZ/2);
-       if (result == 0)
-               result = -ETIMEDOUT;
-       if (result < 0) {
-               dev_err(dev, "WAKE&TX: error waiting for device to exit IDLE: "
-                       "%d - resetting\n", result);
-               i2400m_reset(i2400m, I2400M_RT_BUS);
-               goto error;
-       }
-       msleep(20);     /* device still needs some time or it drops it */
-       result = i2400m_tx(i2400m, skb->data, skb->len, I2400M_PT_DATA);
-error:
-       netif_wake_queue(net_dev);
-out_kfree:
-       kfree_skb(skb); /* refcount transferred by _hard_start_xmit() */
-out_put:
-       i2400m_put(i2400m);
-       d_fnend(3, dev, "(ws %p i2400m %p skb %p) = void [%d]\n",
-               ws, i2400m, skb, result);
-}
-
-
-/*
- * Prepare the data payload TX header
- *
- * The i2400m expects a 4 byte header in front of a data packet.
- *
- * Because we pretend to be an ethernet device, this packet comes with
- * an ethernet header. Pull it and push our header.
- */
-static
-void i2400m_tx_prep_header(struct sk_buff *skb)
-{
-       struct i2400m_pl_data_hdr *pl_hdr;
-       skb_pull(skb, ETH_HLEN);
-       pl_hdr = skb_push(skb, sizeof(*pl_hdr));
-       pl_hdr->reserved = 0;
-}
-
-
-
-/*
- * Cleanup resources acquired during i2400m_net_wake_tx()
- *
- * This is called by __i2400m_dev_stop and means we have to make sure
- * the workqueue is flushed from any pending work.
- */
-void i2400m_net_wake_stop(struct i2400m *i2400m)
-{
-       struct device *dev = i2400m_dev(i2400m);
-       struct sk_buff *wake_tx_skb;
-       unsigned long flags;
-
-       d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
-       /*
-        * See i2400m_hard_start_xmit(), references are taken there and
-        * here we release them if the packet was still pending.
-        */
-       cancel_work_sync(&i2400m->wake_tx_ws);
-
-       spin_lock_irqsave(&i2400m->tx_lock, flags);
-       wake_tx_skb = i2400m->wake_tx_skb;
-       i2400m->wake_tx_skb = NULL;
-       spin_unlock_irqrestore(&i2400m->tx_lock, flags);
-
-       if (wake_tx_skb) {
-               i2400m_put(i2400m);
-               kfree_skb(wake_tx_skb);
-       }
-
-       d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
-}
-
-
-/*
- * TX an skb to an idle device
- *
- * When the device is in basestation-idle mode, we need to wake it up
- * and then TX. So we queue a work_struct for doing so.
- *
- * We need to get an extra ref for the skb (so it is not dropped), as
- * well as be careful not to queue more than one request (won't help
- * at all). If more than one request comes or there are errors, we
- * just drop the packets (see i2400m_hard_start_xmit()).
- */
-static
-int i2400m_net_wake_tx(struct i2400m *i2400m, struct net_device *net_dev,
-                      struct sk_buff *skb)
-{
-       int result;
-       struct device *dev = i2400m_dev(i2400m);
-       unsigned long flags;
-
-       d_fnstart(3, dev, "(skb %p net_dev %p)\n", skb, net_dev);
-       if (net_ratelimit()) {
-               d_printf(3, dev, "WAKE&NETTX: "
-                        "skb %p sending %d bytes to radio\n",
-                        skb, skb->len);
-               d_dump(4, dev, skb->data, skb->len);
-       }
-       /* We hold a ref count for i2400m and skb, so when
-        * stopping() the device, we need to cancel that work
-        * and if pending, release those resources. */
-       result = 0;
-       spin_lock_irqsave(&i2400m->tx_lock, flags);
-       if (!i2400m->wake_tx_skb) {
-               netif_stop_queue(net_dev);
-               i2400m_get(i2400m);
-               i2400m->wake_tx_skb = skb_get(skb);     /* transfer ref count */
-               i2400m_tx_prep_header(skb);
-               result = schedule_work(&i2400m->wake_tx_ws);
-               WARN_ON(result == 0);
-       }
-       spin_unlock_irqrestore(&i2400m->tx_lock, flags);
-       if (result == 0) {
-               /* Yes, this happens even if we stopped the
-                * queue -- blame the queue disciplines that
-                * queue without looking -- I guess there is a reason
-                * for that. */
-               if (net_ratelimit())
-                       d_printf(1, dev, "NETTX: device exiting idle, "
-                                "dropping skb %p, queue running %d\n",
-                                skb, netif_queue_stopped(net_dev));
-               result = -EBUSY;
-       }
-       d_fnend(3, dev, "(skb %p net_dev %p) = %d\n", skb, net_dev, result);
-       return result;
-}
-
-
-/*
- * Transmit a packet to the base station on behalf of the network stack.
- *
- * Returns: 0 if ok, < 0 errno code on error.
- *
- * We need to pull the ethernet header and add the hardware header,
- * which is currently set to all zeroes and reserved.
- */
-static
-int i2400m_net_tx(struct i2400m *i2400m, struct net_device *net_dev,
-                 struct sk_buff *skb)
-{
-       int result;
-       struct device *dev = i2400m_dev(i2400m);
-
-       d_fnstart(3, dev, "(i2400m %p net_dev %p skb %p)\n",
-                 i2400m, net_dev, skb);
-       /* FIXME: check eth hdr, only IPv4 is routed by the device as of now */
-       netif_trans_update(net_dev);
-       i2400m_tx_prep_header(skb);
-       d_printf(3, dev, "NETTX: skb %p sending %d bytes to radio\n",
-                skb, skb->len);
-       d_dump(4, dev, skb->data, skb->len);
-       result = i2400m_tx(i2400m, skb->data, skb->len, I2400M_PT_DATA);
-       d_fnend(3, dev, "(i2400m %p net_dev %p skb %p) = %d\n",
-               i2400m, net_dev, skb, result);
-       return result;
-}
-
-
-/*
- * Transmit a packet to the base station on behalf of the network stack
- *
- *
- * Returns: NETDEV_TX_OK (always, even in case of error)
- *
- * In case of error, we just drop it. Reasons:
- *
- *  - we add a hw header to each skb, and if the network stack
- *    retries, we have no way to know if that skb has it or not.
- *
- *  - network protocols have their own drop-recovery mechanisms
- *
- *  - there is not much else we can do
- *
- * If the device is idle, we need to wake it up; that is an operation
- * that will sleep. See i2400m_net_wake_tx() for details.
- */
-static
-netdev_tx_t i2400m_hard_start_xmit(struct sk_buff *skb,
-                                        struct net_device *net_dev)
-{
-       struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
-       struct device *dev = i2400m_dev(i2400m);
-       int result = -1;
-
-       d_fnstart(3, dev, "(skb %p net_dev %p)\n", skb, net_dev);
-
-       if (skb_cow_head(skb, 0))
-               goto drop;
-
-       if (i2400m->state == I2400M_SS_IDLE)
-               result = i2400m_net_wake_tx(i2400m, net_dev, skb);
-       else
-               result = i2400m_net_tx(i2400m, net_dev, skb);
-       if (result <  0) {
-drop:
-               net_dev->stats.tx_dropped++;
-       } else {
-               net_dev->stats.tx_packets++;
-               net_dev->stats.tx_bytes += skb->len;
-       }
-       dev_kfree_skb(skb);
-       d_fnend(3, dev, "(skb %p net_dev %p) = %d\n", skb, net_dev, result);
-       return NETDEV_TX_OK;
-}
-
-
-static
-void i2400m_tx_timeout(struct net_device *net_dev, unsigned int txqueue)
-{
-       /*
-        * We might want to kick the device
-        *
-        * There is not much we can do though, as the device requires
-        * that we send the data aggregated. By the time we receive
-        * this, there might be data pending to be sent or not...
-        */
-       net_dev->stats.tx_errors++;
-}
-
-
-/*
- * Create a fake ethernet header
- *
- * For emulating an ethernet device, every received IP header has to
- * be prefixed with an ethernet header. Fake it with the given
- * protocol.
- */
-static
-void i2400m_rx_fake_eth_header(struct net_device *net_dev,
-                              void *_eth_hdr, __be16 protocol)
-{
-       struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
-       struct ethhdr *eth_hdr = _eth_hdr;
-
-       memcpy(eth_hdr->h_dest, net_dev->dev_addr, sizeof(eth_hdr->h_dest));
-       memcpy(eth_hdr->h_source, i2400m->src_mac_addr,
-              sizeof(eth_hdr->h_source));
-       eth_hdr->h_proto = protocol;
-}
-
-
-/*
- * i2400m_net_rx - pass a network packet to the stack
- *
- * @i2400m: device instance
- * @skb_rx: the skb where the buffer pointed to by @buf is
- * @i: 1 if payload is the only one
- * @buf: pointer to the buffer containing the data
- * @len: buffer's length
- *
- * This is only used now for the v1.3 firmware. It will be deprecated
- * in >= 2.6.31.
- *
- * Note that due to firmware limitations, we don't have space to add
- * an ethernet header, so we need to copy each packet. Firmware
- * versions >= v1.4 fix this [see i2400m_net_erx()].
- *
- * We just clone the skb and set it up so that it's skb->data pointer
- * points to "buf" and it's length.
- *
- * Note that if the payload is the last (or the only one) in a
- * multi-payload message, we don't clone the SKB but just reuse it.
- *
- * This function is normally run from a thread context. However, we
- * still use netif_rx() instead of netif_receive_skb() as was
- * recommended in the mailing list. Reason is in some stress tests
- * when sending/receiving a lot of data we seem to hit a softlock in
- * the kernel's TCP implementation [aroudn tcp_delay_timer()]. Using
- * netif_rx() took care of the issue.
- *
- * This is, of course, still open to do more research on why running
- * with netif_receive_skb() hits this softlock. FIXME.
- *
- * FIXME: currently we don't do any efforts at distinguishing if what
- * we got was an IPv4 or IPv6 header, to setup the protocol field
- * correctly.
- */
-void i2400m_net_rx(struct i2400m *i2400m, struct sk_buff *skb_rx,
-                  unsigned i, const void *buf, int buf_len)
-{
-       struct net_device *net_dev = i2400m->wimax_dev.net_dev;
-       struct device *dev = i2400m_dev(i2400m);
-       struct sk_buff *skb;
-
-       d_fnstart(2, dev, "(i2400m %p buf %p buf_len %d)\n",
-                 i2400m, buf, buf_len);
-       if (i) {
-               skb = skb_get(skb_rx);
-               d_printf(2, dev, "RX: reusing first payload skb %p\n", skb);
-               skb_pull(skb, buf - (void *) skb->data);
-               skb_trim(skb, (void *) skb_end_pointer(skb) - buf);
-       } else {
-               /* Yes, this is bad -- a lot of overhead -- see
-                * comments at the top of the file */
-               skb = __netdev_alloc_skb(net_dev, buf_len, GFP_KERNEL);
-               if (skb == NULL) {
-                       dev_err(dev, "NETRX: no memory to realloc skb\n");
-                       net_dev->stats.rx_dropped++;
-                       goto error_skb_realloc;
-               }
-               skb_put_data(skb, buf, buf_len);
-       }
-       i2400m_rx_fake_eth_header(i2400m->wimax_dev.net_dev,
-                                 skb->data - ETH_HLEN,
-                                 cpu_to_be16(ETH_P_IP));
-       skb_set_mac_header(skb, -ETH_HLEN);
-       skb->dev = i2400m->wimax_dev.net_dev;
-       skb->protocol = htons(ETH_P_IP);
-       net_dev->stats.rx_packets++;
-       net_dev->stats.rx_bytes += buf_len;
-       d_printf(3, dev, "NETRX: receiving %d bytes to network stack\n",
-               buf_len);
-       d_dump(4, dev, buf, buf_len);
-       netif_rx_ni(skb);       /* see notes in function header */
-error_skb_realloc:
-       d_fnend(2, dev, "(i2400m %p buf %p buf_len %d) = void\n",
-               i2400m, buf, buf_len);
-}
-
-
-/*
- * i2400m_net_erx - pass a network packet to the stack (extended version)
- *
- * @i2400m: device descriptor
- * @skb: the skb where the packet is - the skb should be set to point
- *     at the IP packet; this function will add ethernet headers if
- *     needed.
- * @cs: packet type
- *
- * This is only used now for firmware >= v1.4. Note it is quite
- * similar to i2400m_net_rx() (used only for v1.3 firmware).
- *
- * This function is normally run from a thread context. However, we
- * still use netif_rx() instead of netif_receive_skb() as was
- * recommended in the mailing list. Reason is in some stress tests
- * when sending/receiving a lot of data we seem to hit a softlock in
- * the kernel's TCP implementation [aroudn tcp_delay_timer()]. Using
- * netif_rx() took care of the issue.
- *
- * This is, of course, still open to do more research on why running
- * with netif_receive_skb() hits this softlock. FIXME.
- */
-void i2400m_net_erx(struct i2400m *i2400m, struct sk_buff *skb,
-                   enum i2400m_cs cs)
-{
-       struct net_device *net_dev = i2400m->wimax_dev.net_dev;
-       struct device *dev = i2400m_dev(i2400m);
-
-       d_fnstart(2, dev, "(i2400m %p skb %p [%u] cs %d)\n",
-                 i2400m, skb, skb->len, cs);
-       switch (cs) {
-       case I2400M_CS_IPV4_0:
-       case I2400M_CS_IPV4:
-               i2400m_rx_fake_eth_header(i2400m->wimax_dev.net_dev,
-                                         skb->data - ETH_HLEN,
-                                         cpu_to_be16(ETH_P_IP));
-               skb_set_mac_header(skb, -ETH_HLEN);
-               skb->dev = i2400m->wimax_dev.net_dev;
-               skb->protocol = htons(ETH_P_IP);
-               net_dev->stats.rx_packets++;
-               net_dev->stats.rx_bytes += skb->len;
-               break;
-       default:
-               dev_err(dev, "ERX: BUG? CS type %u unsupported\n", cs);
-               goto error;
-
-       }
-       d_printf(3, dev, "ERX: receiving %d bytes to the network stack\n",
-                skb->len);
-       d_dump(4, dev, skb->data, skb->len);
-       netif_rx_ni(skb);       /* see notes in function header */
-error:
-       d_fnend(2, dev, "(i2400m %p skb %p [%u] cs %d) = void\n",
-               i2400m, skb, skb->len, cs);
-}
-
-static const struct net_device_ops i2400m_netdev_ops = {
-       .ndo_open = i2400m_open,
-       .ndo_stop = i2400m_stop,
-       .ndo_start_xmit = i2400m_hard_start_xmit,
-       .ndo_tx_timeout = i2400m_tx_timeout,
-};
-
-static void i2400m_get_drvinfo(struct net_device *net_dev,
-                              struct ethtool_drvinfo *info)
-{
-       struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
-
-       strscpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
-       strscpy(info->fw_version, i2400m->fw_name ? : "",
-               sizeof(info->fw_version));
-       if (net_dev->dev.parent)
-               strscpy(info->bus_info, dev_name(net_dev->dev.parent),
-                       sizeof(info->bus_info));
-}
-
-static const struct ethtool_ops i2400m_ethtool_ops = {
-       .get_drvinfo = i2400m_get_drvinfo,
-       .get_link = ethtool_op_get_link,
-};
-
-/*
- * i2400m_netdev_setup - Setup setup @net_dev's i2400m private data
- *
- * Called by alloc_netdev()
- */
-void i2400m_netdev_setup(struct net_device *net_dev)
-{
-       d_fnstart(3, NULL, "(net_dev %p)\n", net_dev);
-       ether_setup(net_dev);
-       net_dev->mtu = I2400M_MAX_MTU;
-       net_dev->min_mtu = 0;
-       net_dev->max_mtu = I2400M_MAX_MTU;
-       net_dev->tx_queue_len = I2400M_TX_QLEN;
-       net_dev->features =
-                 NETIF_F_VLAN_CHALLENGED
-               | NETIF_F_HIGHDMA;
-       net_dev->flags =
-               IFF_NOARP               /* i2400m is apure IP device */
-               & (~IFF_BROADCAST       /* i2400m is P2P */
-                  & ~IFF_MULTICAST);
-       net_dev->watchdog_timeo = I2400M_TX_TIMEOUT;
-       net_dev->netdev_ops = &i2400m_netdev_ops;
-       net_dev->ethtool_ops = &i2400m_ethtool_ops;
-       d_fnend(3, NULL, "(net_dev %p) = void\n", net_dev);
-}
-EXPORT_SYMBOL_GPL(i2400m_netdev_setup);
-
diff --git a/drivers/staging/wimax/i2400m/op-rfkill.c b/drivers/staging/wimax/i2400m/op-rfkill.c
deleted file mode 100644 (file)
index 0f438ae..0000000
+++ /dev/null
@@ -1,196 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel Wireless WiMAX Connection 2400m
- * Implement backend for the WiMAX stack rfkill support
- *
- * Copyright (C) 2007-2008 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *
- * The WiMAX kernel stack integrates into RF-Kill and keeps the
- * switches's status. We just need to:
- *
- * - report changes in the HW RF Kill switch [with
- *   wimax_rfkill_{sw,hw}_report(), which happens when we detect those
- *   indications coming through hardware reports]. We also do it on
- *   initialization to let the stack know the initial HW state.
- *
- * - implement indications from the stack to change the SW RF Kill
- *   switch (coming from sysfs, the wimax stack or user space).
- */
-#include "i2400m.h"
-#include "linux-wimax-i2400m.h"
-#include <linux/slab.h>
-
-
-
-#define D_SUBMODULE rfkill
-#include "debug-levels.h"
-
-/*
- * Return true if the i2400m radio is in the requested wimax_rf_state state
- *
- */
-static
-int i2400m_radio_is(struct i2400m *i2400m, enum wimax_rf_state state)
-{
-       if (state == WIMAX_RF_OFF)
-               return i2400m->state == I2400M_SS_RF_OFF
-                       || i2400m->state == I2400M_SS_RF_SHUTDOWN;
-       else if (state == WIMAX_RF_ON)
-               /* state == WIMAX_RF_ON */
-               return i2400m->state != I2400M_SS_RF_OFF
-                       && i2400m->state != I2400M_SS_RF_SHUTDOWN;
-       else {
-               BUG();
-               return -EINVAL; /* shut gcc warnings on certain arches */
-       }
-}
-
-
-/*
- * WiMAX stack operation: implement SW RFKill toggling
- *
- * @wimax_dev: device descriptor
- * @skb: skb where the message has been received; skb->data is
- *       expected to point to the message payload.
- * @genl_info: passed by the generic netlink layer
- *
- * Generic Netlink will call this function when a message is sent from
- * userspace to change the software RF-Kill switch status.
- *
- * This function will set the device's software RF-Kill switch state to
- * match what is requested.
- *
- * NOTE: the i2400m has a strict state machine; we can only set the
- *       RF-Kill switch when it is on, the HW RF-Kill is on and the
- *       device is initialized. So we ignore errors steaming from not
- *       being in the right state (-EILSEQ).
- */
-int i2400m_op_rfkill_sw_toggle(struct wimax_dev *wimax_dev,
-                              enum wimax_rf_state state)
-{
-       int result;
-       struct i2400m *i2400m = wimax_dev_to_i2400m(wimax_dev);
-       struct device *dev = i2400m_dev(i2400m);
-       struct sk_buff *ack_skb;
-       struct {
-               struct i2400m_l3l4_hdr hdr;
-               struct i2400m_tlv_rf_operation sw_rf;
-       } __packed *cmd;
-       char strerr[32];
-
-       d_fnstart(4, dev, "(wimax_dev %p state %d)\n", wimax_dev, state);
-
-       result = -ENOMEM;
-       cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
-       if (cmd == NULL)
-               goto error_alloc;
-       cmd->hdr.type = cpu_to_le16(I2400M_MT_CMD_RF_CONTROL);
-       cmd->hdr.length = cpu_to_le16(sizeof(cmd->sw_rf));
-       cmd->hdr.version = cpu_to_le16(I2400M_L3L4_VERSION);
-       cmd->sw_rf.hdr.type = cpu_to_le16(I2400M_TLV_RF_OPERATION);
-       cmd->sw_rf.hdr.length = cpu_to_le16(sizeof(cmd->sw_rf.status));
-       switch (state) {
-       case WIMAX_RF_OFF:      /* RFKILL ON, radio OFF */
-               cmd->sw_rf.status = cpu_to_le32(2);
-               break;
-       case WIMAX_RF_ON:       /* RFKILL OFF, radio ON */
-               cmd->sw_rf.status = cpu_to_le32(1);
-               break;
-       default:
-               BUG();
-       }
-
-       ack_skb = i2400m_msg_to_dev(i2400m, cmd, sizeof(*cmd));
-       result = PTR_ERR(ack_skb);
-       if (IS_ERR(ack_skb)) {
-               dev_err(dev, "Failed to issue 'RF Control' command: %d\n",
-                       result);
-               goto error_msg_to_dev;
-       }
-       result = i2400m_msg_check_status(wimax_msg_data(ack_skb),
-                                        strerr, sizeof(strerr));
-       if (result < 0) {
-               dev_err(dev, "'RF Control' (0x%04x) command failed: %d - %s\n",
-                       I2400M_MT_CMD_RF_CONTROL, result, strerr);
-               goto error_cmd;
-       }
-
-       /* Now we wait for the state to change to RADIO_OFF or RADIO_ON */
-       result = wait_event_timeout(
-               i2400m->state_wq, i2400m_radio_is(i2400m, state),
-               5 * HZ);
-       if (result == 0)
-               result = -ETIMEDOUT;
-       if (result < 0)
-               dev_err(dev, "Error waiting for device to toggle RF state: "
-                       "%d\n", result);
-       result = 0;
-error_cmd:
-       kfree_skb(ack_skb);
-error_msg_to_dev:
-error_alloc:
-       d_fnend(4, dev, "(wimax_dev %p state %d) = %d\n",
-               wimax_dev, state, result);
-       kfree(cmd);
-       return result;
-}
-
-
-/*
- * Inform the WiMAX stack of changes in the RF Kill switches reported
- * by the device
- *
- * @i2400m: device descriptor
- * @rfss: TLV for RF Switches status; already validated
- *
- * NOTE: the reports on RF switch status cannot be trusted
- *       or used until the device is in a state of RADIO_OFF
- *       or greater.
- */
-void i2400m_report_tlv_rf_switches_status(
-       struct i2400m *i2400m,
-       const struct i2400m_tlv_rf_switches_status *rfss)
-{
-       struct device *dev = i2400m_dev(i2400m);
-       enum i2400m_rf_switch_status hw, sw;
-       enum wimax_st wimax_state;
-
-       sw = rfss->sw_rf_switch;
-       hw = rfss->hw_rf_switch;
-
-       d_fnstart(3, dev, "(i2400m %p rfss %p [hw %u sw %u])\n",
-                 i2400m, rfss, hw, sw);
-       /* We only process rw switch evens when the device has been
-        * fully initialized */
-       wimax_state = wimax_state_get(&i2400m->wimax_dev);
-       if (wimax_state < WIMAX_ST_RADIO_OFF) {
-               d_printf(3, dev, "ignoring RF switches report, state %u\n",
-                        wimax_state);
-               goto out;
-       }
-       switch (sw) {
-       case I2400M_RF_SWITCH_ON:       /* RF Kill disabled (radio on) */
-               wimax_report_rfkill_sw(&i2400m->wimax_dev, WIMAX_RF_ON);
-               break;
-       case I2400M_RF_SWITCH_OFF:      /* RF Kill enabled (radio off) */
-               wimax_report_rfkill_sw(&i2400m->wimax_dev, WIMAX_RF_OFF);
-               break;
-       default:
-               dev_err(dev, "HW BUG? Unknown RF SW state 0x%x\n", sw);
-       }
-
-       switch (hw) {
-       case I2400M_RF_SWITCH_ON:       /* RF Kill disabled (radio on) */
-               wimax_report_rfkill_hw(&i2400m->wimax_dev, WIMAX_RF_ON);
-               break;
-       case I2400M_RF_SWITCH_OFF:      /* RF Kill enabled (radio off) */
-               wimax_report_rfkill_hw(&i2400m->wimax_dev, WIMAX_RF_OFF);
-               break;
-       default:
-               dev_err(dev, "HW BUG? Unknown RF HW state 0x%x\n", hw);
-       }
-out:
-       d_fnend(3, dev, "(i2400m %p rfss %p [hw %u sw %u]) = void\n",
-               i2400m, rfss, hw, sw);
-}
diff --git a/drivers/staging/wimax/i2400m/rx.c b/drivers/staging/wimax/i2400m/rx.c
deleted file mode 100644 (file)
index 702a1e2..0000000
+++ /dev/null
@@ -1,1394 +0,0 @@
-/*
- * Intel Wireless WiMAX Connection 2400m
- * Handle incoming traffic and deliver it to the control or data planes
- *
- *
- * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   * Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in
- *     the documentation and/or other materials provided with the
- *     distribution.
- *   * Neither the name of Intel Corporation nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *
- * Intel Corporation <linux-wimax@intel.com>
- * Yanir Lubetkin <yanirx.lubetkin@intel.com>
- *  - Initial implementation
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *  - Use skb_clone(), break up processing in chunks
- *  - Split transport/device specific
- *  - Make buffer size dynamic to exert less memory pressure
- *  - RX reorder support
- *
- * This handles the RX path.
- *
- * We receive an RX message from the bus-specific driver, which
- * contains one or more payloads that have potentially different
- * destinataries (data or control paths).
- *
- * So we just take that payload from the transport specific code in
- * the form of an skb, break it up in chunks (a cloned skb each in the
- * case of network packets) and pass it to netdev or to the
- * command/ack handler (and from there to the WiMAX stack).
- *
- * PROTOCOL FORMAT
- *
- * The format of the buffer is:
- *
- * HEADER                      (struct i2400m_msg_hdr)
- * PAYLOAD DESCRIPTOR 0        (struct i2400m_pld)
- * PAYLOAD DESCRIPTOR 1
- * ...
- * PAYLOAD DESCRIPTOR N
- * PAYLOAD 0                   (raw bytes)
- * PAYLOAD 1
- * ...
- * PAYLOAD N
- *
- * See tx.c for a deeper description on alignment requirements and
- * other fun facts of it.
- *
- * DATA PACKETS
- *
- * In firmwares <= v1.3, data packets have no header for RX, but they
- * do for TX (currently unused).
- *
- * In firmware >= 1.4, RX packets have an extended header (16
- * bytes). This header conveys information for management of host
- * reordering of packets (the device offloads storage of the packets
- * for reordering to the host). Read below for more information.
- *
- * The header is used as dummy space to emulate an ethernet header and
- * thus be able to act as an ethernet device without having to reallocate.
- *
- * DATA RX REORDERING
- *
- * Starting in firmware v1.4, the device can deliver packets for
- * delivery with special reordering information; this allows it to
- * more effectively do packet management when some frames were lost in
- * the radio traffic.
- *
- * Thus, for RX packets that come out of order, the device gives the
- * driver enough information to queue them properly and then at some
- * point, the signal to deliver the whole (or part) of the queued
- * packets to the networking stack. There are 16 such queues.
- *
- * This only happens when a packet comes in with the "need reorder"
- * flag set in the RX header. When such bit is set, the following
- * operations might be indicated:
- *
- *  - reset queue: send all queued packets to the OS
- *
- *  - queue: queue a packet
- *
- *  - update ws: update the queue's window start and deliver queued
- *    packets that meet the criteria
- *
- *  - queue & update ws: queue a packet, update the window start and
- *    deliver queued packets that meet the criteria
- *
- * (delivery criteria: the packet's [normalized] sequence number is
- * lower than the new [normalized] window start).
- *
- * See the i2400m_roq_*() functions for details.
- *
- * ROADMAP
- *
- * i2400m_rx
- *   i2400m_rx_msg_hdr_check
- *   i2400m_rx_pl_descr_check
- *   i2400m_rx_payload
- *     i2400m_net_rx
- *     i2400m_rx_edata
- *       i2400m_net_erx
- *       i2400m_roq_reset
- *         i2400m_net_erx
- *       i2400m_roq_queue
- *         __i2400m_roq_queue
- *       i2400m_roq_update_ws
- *         __i2400m_roq_update_ws
- *           i2400m_net_erx
- *       i2400m_roq_queue_update_ws
- *         __i2400m_roq_queue
- *         __i2400m_roq_update_ws
- *           i2400m_net_erx
- *     i2400m_rx_ctl
- *       i2400m_msg_size_check
- *       i2400m_report_hook_work    [in a workqueue]
- *         i2400m_report_hook
- *       wimax_msg_to_user
- *       i2400m_rx_ctl_ack
- *         wimax_msg_to_user_alloc
- *     i2400m_rx_trace
- *       i2400m_msg_size_check
- *       wimax_msg
- */
-#include <linux/slab.h>
-#include <linux/kernel.h>
-#include <linux/if_arp.h>
-#include <linux/netdevice.h>
-#include <linux/workqueue.h>
-#include <linux/export.h>
-#include <linux/moduleparam.h>
-#include "i2400m.h"
-
-
-#define D_SUBMODULE rx
-#include "debug-levels.h"
-
-static int i2400m_rx_reorder_disabled; /* 0 (rx reorder enabled) by default */
-module_param_named(rx_reorder_disabled, i2400m_rx_reorder_disabled, int, 0644);
-MODULE_PARM_DESC(rx_reorder_disabled,
-                "If true, RX reordering will be disabled.");
-
-struct i2400m_report_hook_args {
-       struct sk_buff *skb_rx;
-       const struct i2400m_l3l4_hdr *l3l4_hdr;
-       size_t size;
-       struct list_head list_node;
-};
-
-
-/*
- * Execute i2400m_report_hook in a workqueue
- *
- * Goes over the list of queued reports in i2400m->rx_reports and
- * processes them.
- *
- * NOTE: refcounts on i2400m are not needed because we flush the
- *     workqueue this runs on (i2400m->work_queue) before destroying
- *     i2400m.
- */
-void i2400m_report_hook_work(struct work_struct *ws)
-{
-       struct i2400m *i2400m = container_of(ws, struct i2400m, rx_report_ws);
-       struct device *dev = i2400m_dev(i2400m);
-       struct i2400m_report_hook_args *args, *args_next;
-       LIST_HEAD(list);
-       unsigned long flags;
-
-       while (1) {
-               spin_lock_irqsave(&i2400m->rx_lock, flags);
-               list_splice_init(&i2400m->rx_reports, &list);
-               spin_unlock_irqrestore(&i2400m->rx_lock, flags);
-               if (list_empty(&list))
-                       break;
-               else
-                       d_printf(1, dev, "processing queued reports\n");
-               list_for_each_entry_safe(args, args_next, &list, list_node) {
-                       d_printf(2, dev, "processing queued report %p\n", args);
-                       i2400m_report_hook(i2400m, args->l3l4_hdr, args->size);
-                       kfree_skb(args->skb_rx);
-                       list_del(&args->list_node);
-                       kfree(args);
-               }
-       }
-}
-
-
-/*
- * Flush the list of queued reports
- */
-static
-void i2400m_report_hook_flush(struct i2400m *i2400m)
-{
-       struct device *dev = i2400m_dev(i2400m);
-       struct i2400m_report_hook_args *args, *args_next;
-       LIST_HEAD(list);
-       unsigned long flags;
-
-       d_printf(1, dev, "flushing queued reports\n");
-       spin_lock_irqsave(&i2400m->rx_lock, flags);
-       list_splice_init(&i2400m->rx_reports, &list);
-       spin_unlock_irqrestore(&i2400m->rx_lock, flags);
-       list_for_each_entry_safe(args, args_next, &list, list_node) {
-               d_printf(2, dev, "flushing queued report %p\n", args);
-               kfree_skb(args->skb_rx);
-               list_del(&args->list_node);
-               kfree(args);
-       }
-}
-
-
-/*
- * Queue a report for later processing
- *
- * @i2400m: device descriptor
- * @skb_rx: skb that contains the payload (for reference counting)
- * @l3l4_hdr: pointer to the control
- * @size: size of the message
- */
-static
-void i2400m_report_hook_queue(struct i2400m *i2400m, struct sk_buff *skb_rx,
-                             const void *l3l4_hdr, size_t size)
-{
-       struct device *dev = i2400m_dev(i2400m);
-       unsigned long flags;
-       struct i2400m_report_hook_args *args;
-
-       args = kzalloc(sizeof(*args), GFP_NOIO);
-       if (args) {
-               args->skb_rx = skb_get(skb_rx);
-               args->l3l4_hdr = l3l4_hdr;
-               args->size = size;
-               spin_lock_irqsave(&i2400m->rx_lock, flags);
-               list_add_tail(&args->list_node, &i2400m->rx_reports);
-               spin_unlock_irqrestore(&i2400m->rx_lock, flags);
-               d_printf(2, dev, "queued report %p\n", args);
-               rmb();          /* see i2400m->ready's documentation  */
-               if (likely(i2400m->ready))      /* only send if up */
-                       queue_work(i2400m->work_queue, &i2400m->rx_report_ws);
-       } else  {
-               if (printk_ratelimit())
-                       dev_err(dev, "%s:%u: Can't allocate %zu B\n",
-                               __func__, __LINE__, sizeof(*args));
-       }
-}
-
-
-/*
- * Process an ack to a command
- *
- * @i2400m: device descriptor
- * @payload: pointer to message
- * @size: size of the message
- *
- * Pass the acknodledgment (in an skb) to the thread that is waiting
- * for it in i2400m->msg_completion.
- *
- * We need to coordinate properly with the thread waiting for the
- * ack. Check if it is waiting or if it is gone. We loose the spinlock
- * to avoid allocating on atomic contexts (yeah, could use GFP_ATOMIC,
- * but this is not so speed critical).
- */
-static
-void i2400m_rx_ctl_ack(struct i2400m *i2400m,
-                      const void *payload, size_t size)
-{
-       struct device *dev = i2400m_dev(i2400m);
-       struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
-       unsigned long flags;
-       struct sk_buff *ack_skb;
-
-       /* Anyone waiting for an answer? */
-       spin_lock_irqsave(&i2400m->rx_lock, flags);
-       if (i2400m->ack_skb != ERR_PTR(-EINPROGRESS)) {
-               dev_err(dev, "Huh? reply to command with no waiters\n");
-               goto error_no_waiter;
-       }
-       spin_unlock_irqrestore(&i2400m->rx_lock, flags);
-
-       ack_skb = wimax_msg_alloc(wimax_dev, NULL, payload, size, GFP_KERNEL);
-
-       /* Check waiter didn't time out waiting for the answer... */
-       spin_lock_irqsave(&i2400m->rx_lock, flags);
-       if (i2400m->ack_skb != ERR_PTR(-EINPROGRESS)) {
-               d_printf(1, dev, "Huh? waiter for command reply cancelled\n");
-               goto error_waiter_cancelled;
-       }
-       if (IS_ERR(ack_skb))
-               dev_err(dev, "CMD/GET/SET ack: cannot allocate SKB\n");
-       i2400m->ack_skb = ack_skb;
-       spin_unlock_irqrestore(&i2400m->rx_lock, flags);
-       complete(&i2400m->msg_completion);
-       return;
-
-error_waiter_cancelled:
-       if (!IS_ERR(ack_skb))
-               kfree_skb(ack_skb);
-error_no_waiter:
-       spin_unlock_irqrestore(&i2400m->rx_lock, flags);
-}
-
-
-/*
- * Receive and process a control payload
- *
- * @i2400m: device descriptor
- * @skb_rx: skb that contains the payload (for reference counting)
- * @payload: pointer to message
- * @size: size of the message
- *
- * There are two types of control RX messages: reports (asynchronous,
- * like your every day interrupts) and 'acks' (reponses to a command,
- * get or set request).
- *
- * If it is a report, we run hooks on it (to extract information for
- * things we need to do in the driver) and then pass it over to the
- * WiMAX stack to send it to user space.
- *
- * NOTE: report processing is done in a workqueue specific to the
- *     generic driver, to avoid deadlocks in the system.
- *
- * If it is not a report, it is an ack to a previously executed
- * command, set or get, so wake up whoever is waiting for it from
- * i2400m_msg_to_dev(). i2400m_rx_ctl_ack() takes care of that.
- *
- * Note that the sizes we pass to other functions from here are the
- * sizes of the _l3l4_hdr + payload, not full buffer sizes, as we have
- * verified in _msg_size_check() that they are congruent.
- *
- * For reports: We can't clone the original skb where the data is
- * because we need to send this up via netlink; netlink has to add
- * headers and we can't overwrite what's preceding the payload...as
- * it is another message. So we just dup them.
- */
-static
-void i2400m_rx_ctl(struct i2400m *i2400m, struct sk_buff *skb_rx,
-                  const void *payload, size_t size)
-{
-       int result;
-       struct device *dev = i2400m_dev(i2400m);
-       const struct i2400m_l3l4_hdr *l3l4_hdr = payload;
-       unsigned msg_type;
-
-       result = i2400m_msg_size_check(i2400m, l3l4_hdr, size);
-       if (result < 0) {
-               dev_err(dev, "HW BUG? device sent a bad message: %d\n",
-                       result);
-               goto error_check;
-       }
-       msg_type = le16_to_cpu(l3l4_hdr->type);
-       d_printf(1, dev, "%s 0x%04x: %zu bytes\n",
-                msg_type & I2400M_MT_REPORT_MASK ? "REPORT" : "CMD/SET/GET",
-                msg_type, size);
-       d_dump(2, dev, l3l4_hdr, size);
-       if (msg_type & I2400M_MT_REPORT_MASK) {
-               /*
-                * Process each report
-                *
-                * - has to be ran serialized as well
-                *
-                * - the handling might force the execution of
-                *   commands. That might cause reentrancy issues with
-                *   bus-specific subdrivers and workqueues, so the we
-                *   run it in a separate workqueue.
-                *
-                * - when the driver is not yet ready to handle them,
-                *   they are queued and at some point the queue is
-                *   restarted [NOTE: we can't queue SKBs directly, as
-                *   this might be a piece of a SKB, not the whole
-                *   thing, and this is cheaper than cloning the
-                *   SKB].
-                *
-                * Note we don't do refcounting for the device
-                * structure; this is because before destroying
-                * 'i2400m', we make sure to flush the
-                * i2400m->work_queue, so there are no issues.
-                */
-               i2400m_report_hook_queue(i2400m, skb_rx, l3l4_hdr, size);
-               if (unlikely(i2400m->trace_msg_from_user))
-                       wimax_msg(&i2400m->wimax_dev, "echo",
-                                 l3l4_hdr, size, GFP_KERNEL);
-               result = wimax_msg(&i2400m->wimax_dev, NULL, l3l4_hdr, size,
-                                  GFP_KERNEL);
-               if (result < 0)
-                       dev_err(dev, "error sending report to userspace: %d\n",
-                               result);
-       } else          /* an ack to a CMD, GET or SET */
-               i2400m_rx_ctl_ack(i2400m, payload, size);
-error_check:
-       return;
-}
-
-
-/*
- * Receive and send up a trace
- *
- * @i2400m: device descriptor
- * @skb_rx: skb that contains the trace (for reference counting)
- * @payload: pointer to trace message inside the skb
- * @size: size of the message
- *
- * THe i2400m might produce trace information (diagnostics) and we
- * send them through a different kernel-to-user pipe (to avoid
- * clogging it).
- *
- * As in i2400m_rx_ctl(), we can't clone the original skb where the
- * data is because we need to send this up via netlink; netlink has to
- * add headers and we can't overwrite what's preceding the
- * payload...as it is another message. So we just dup them.
- */
-static
-void i2400m_rx_trace(struct i2400m *i2400m,
-                    const void *payload, size_t size)
-{
-       int result;
-       struct device *dev = i2400m_dev(i2400m);
-       struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
-       const struct i2400m_l3l4_hdr *l3l4_hdr = payload;
-       unsigned msg_type;
-
-       result = i2400m_msg_size_check(i2400m, l3l4_hdr, size);
-       if (result < 0) {
-               dev_err(dev, "HW BUG? device sent a bad trace message: %d\n",
-                       result);
-               goto error_check;
-       }
-       msg_type = le16_to_cpu(l3l4_hdr->type);
-       d_printf(1, dev, "Trace %s 0x%04x: %zu bytes\n",
-                msg_type & I2400M_MT_REPORT_MASK ? "REPORT" : "CMD/SET/GET",
-                msg_type, size);
-       d_dump(2, dev, l3l4_hdr, size);
-       result = wimax_msg(wimax_dev, "trace", l3l4_hdr, size, GFP_KERNEL);
-       if (result < 0)
-               dev_err(dev, "error sending trace to userspace: %d\n",
-                       result);
-error_check:
-       return;
-}
-
-
-/*
- * Reorder queue data stored on skb->cb while the skb is queued in the
- * reorder queues.
- */
-struct i2400m_roq_data {
-       unsigned sn;            /* Serial number for the skb */
-       enum i2400m_cs cs;      /* packet type for the skb */
-};
-
-
-/*
- * ReOrder Queue
- *
- * @ws: Window Start; sequence number where the current window start
- *     is for this queue
- * @queue: the skb queue itself
- * @log: circular ring buffer used to log information about the
- *     reorder process in this queue that can be displayed in case of
- *     error to help diagnose it.
- *
- * This is the head for a list of skbs. In the skb->cb member of the
- * skb when queued here contains a 'struct i2400m_roq_data' were we
- * store the sequence number (sn) and the cs (packet type) coming from
- * the RX payload header from the device.
- */
-struct i2400m_roq {
-       unsigned ws;
-       struct sk_buff_head queue;
-       struct i2400m_roq_log *log;
-};
-
-
-static
-void __i2400m_roq_init(struct i2400m_roq *roq)
-{
-       roq->ws = 0;
-       skb_queue_head_init(&roq->queue);
-}
-
-
-static
-unsigned __i2400m_roq_index(struct i2400m *i2400m, struct i2400m_roq *roq)
-{
-       return ((unsigned long) roq - (unsigned long) i2400m->rx_roq)
-               / sizeof(*roq);
-}
-
-
-/*
- * Normalize a sequence number based on the queue's window start
- *
- * nsn = (sn - ws) % 2048
- *
- * Note that if @sn < @roq->ws, we still need a positive number; %'s
- * sign is implementation specific, so we normalize it by adding 2048
- * to bring it to be positive.
- */
-static
-unsigned __i2400m_roq_nsn(struct i2400m_roq *roq, unsigned sn)
-{
-       int r;
-       r =  ((int) sn - (int) roq->ws) % 2048;
-       if (r < 0)
-               r += 2048;
-       return r;
-}
-
-
-/*
- * Circular buffer to keep the last N reorder operations
- *
- * In case something fails, dumb then to try to come up with what
- * happened.
- */
-enum {
-       I2400M_ROQ_LOG_LENGTH = 32,
-};
-
-struct i2400m_roq_log {
-       struct i2400m_roq_log_entry {
-               enum i2400m_ro_type type;
-               unsigned ws, count, sn, nsn, new_ws;
-       } entry[I2400M_ROQ_LOG_LENGTH];
-       unsigned in, out;
-};
-
-
-/* Print a log entry */
-static
-void i2400m_roq_log_entry_print(struct i2400m *i2400m, unsigned index,
-                               unsigned e_index,
-                               struct i2400m_roq_log_entry *e)
-{
-       struct device *dev = i2400m_dev(i2400m);
-
-       switch(e->type) {
-       case I2400M_RO_TYPE_RESET:
-               dev_err(dev, "q#%d reset           ws %u cnt %u sn %u/%u"
-                       " - new nws %u\n",
-                       index, e->ws, e->count, e->sn, e->nsn, e->new_ws);
-               break;
-       case I2400M_RO_TYPE_PACKET:
-               dev_err(dev, "q#%d queue           ws %u cnt %u sn %u/%u\n",
-                       index, e->ws, e->count, e->sn, e->nsn);
-               break;
-       case I2400M_RO_TYPE_WS:
-               dev_err(dev, "q#%d update_ws       ws %u cnt %u sn %u/%u"
-                       " - new nws %u\n",
-                       index, e->ws, e->count, e->sn, e->nsn, e->new_ws);
-               break;
-       case I2400M_RO_TYPE_PACKET_WS:
-               dev_err(dev, "q#%d queue_update_ws ws %u cnt %u sn %u/%u"
-                       " - new nws %u\n",
-                       index, e->ws, e->count, e->sn, e->nsn, e->new_ws);
-               break;
-       default:
-               dev_err(dev, "q#%d BUG? entry %u - unknown type %u\n",
-                       index, e_index, e->type);
-               break;
-       }
-}
-
-
-static
-void i2400m_roq_log_add(struct i2400m *i2400m,
-                       struct i2400m_roq *roq, enum i2400m_ro_type type,
-                       unsigned ws, unsigned count, unsigned sn,
-                       unsigned nsn, unsigned new_ws)
-{
-       struct i2400m_roq_log_entry *e;
-       unsigned cnt_idx;
-       int index = __i2400m_roq_index(i2400m, roq);
-
-       /* if we run out of space, we eat from the end */
-       if (roq->log->in - roq->log->out == I2400M_ROQ_LOG_LENGTH)
-               roq->log->out++;
-       cnt_idx = roq->log->in++ % I2400M_ROQ_LOG_LENGTH;
-       e = &roq->log->entry[cnt_idx];
-
-       e->type = type;
-       e->ws = ws;
-       e->count = count;
-       e->sn = sn;
-       e->nsn = nsn;
-       e->new_ws = new_ws;
-
-       if (d_test(1))
-               i2400m_roq_log_entry_print(i2400m, index, cnt_idx, e);
-}
-
-
-/* Dump all the entries in the FIFO and reinitialize it */
-static
-void i2400m_roq_log_dump(struct i2400m *i2400m, struct i2400m_roq *roq)
-{
-       unsigned cnt, cnt_idx;
-       struct i2400m_roq_log_entry *e;
-       int index = __i2400m_roq_index(i2400m, roq);
-
-       BUG_ON(roq->log->out > roq->log->in);
-       for (cnt = roq->log->out; cnt < roq->log->in; cnt++) {
-               cnt_idx = cnt % I2400M_ROQ_LOG_LENGTH;
-               e = &roq->log->entry[cnt_idx];
-               i2400m_roq_log_entry_print(i2400m, index, cnt_idx, e);
-               memset(e, 0, sizeof(*e));
-       }
-       roq->log->in = roq->log->out = 0;
-}
-
-
-/*
- * Backbone for the queuing of an skb (by normalized sequence number)
- *
- * @i2400m: device descriptor
- * @roq: reorder queue where to add
- * @skb: the skb to add
- * @sn: the sequence number of the skb
- * @nsn: the normalized sequence number of the skb (pre-computed by the
- *     caller from the @sn and @roq->ws).
- *
- * We try first a couple of quick cases:
- *
- *   - the queue is empty
- *   - the skb would be appended to the queue
- *
- * These will be the most common operations.
- *
- * If these fail, then we have to do a sorted insertion in the queue,
- * which is the slowest path.
- *
- * We don't have to acquire a reference count as we are going to own it.
- */
-static
-void __i2400m_roq_queue(struct i2400m *i2400m, struct i2400m_roq *roq,
-                       struct sk_buff *skb, unsigned sn, unsigned nsn)
-{
-       struct device *dev = i2400m_dev(i2400m);
-       struct sk_buff *skb_itr;
-       struct i2400m_roq_data *roq_data_itr, *roq_data;
-       unsigned nsn_itr;
-
-       d_fnstart(4, dev, "(i2400m %p roq %p skb %p sn %u nsn %u)\n",
-                 i2400m, roq, skb, sn, nsn);
-
-       roq_data = (struct i2400m_roq_data *) &skb->cb;
-       BUILD_BUG_ON(sizeof(*roq_data) > sizeof(skb->cb));
-       roq_data->sn = sn;
-       d_printf(3, dev, "ERX: roq %p [ws %u] nsn %d sn %u\n",
-                roq, roq->ws, nsn, roq_data->sn);
-
-       /* Queues will be empty on not-so-bad environments, so try
-        * that first */
-       if (skb_queue_empty(&roq->queue)) {
-               d_printf(2, dev, "ERX: roq %p - first one\n", roq);
-               __skb_queue_head(&roq->queue, skb);
-               goto out;
-       }
-       /* Now try append, as most of the operations will be that */
-       skb_itr = skb_peek_tail(&roq->queue);
-       roq_data_itr = (struct i2400m_roq_data *) &skb_itr->cb;
-       nsn_itr = __i2400m_roq_nsn(roq, roq_data_itr->sn);
-       /* NSN bounds assumed correct (checked when it was queued) */
-       if (nsn >= nsn_itr) {
-               d_printf(2, dev, "ERX: roq %p - appended after %p (nsn %d sn %u)\n",
-                        roq, skb_itr, nsn_itr, roq_data_itr->sn);
-               __skb_queue_tail(&roq->queue, skb);
-               goto out;
-       }
-       /* None of the fast paths option worked. Iterate to find the
-        * right spot where to insert the packet; we know the queue is
-        * not empty, so we are not the first ones; we also know we
-        * are not going to be the last ones. The list is sorted, so
-        * we have to insert before the the first guy with an nsn_itr
-        * greater that our nsn. */
-       skb_queue_walk(&roq->queue, skb_itr) {
-               roq_data_itr = (struct i2400m_roq_data *) &skb_itr->cb;
-               nsn_itr = __i2400m_roq_nsn(roq, roq_data_itr->sn);
-               /* NSN bounds assumed correct (checked when it was queued) */
-               if (nsn_itr > nsn) {
-                       d_printf(2, dev, "ERX: roq %p - queued before %p "
-                                "(nsn %d sn %u)\n", roq, skb_itr, nsn_itr,
-                                roq_data_itr->sn);
-                       __skb_queue_before(&roq->queue, skb_itr, skb);
-                       goto out;
-               }
-       }
-       /* If we get here, that is VERY bad -- print info to help
-        * diagnose and crash it */
-       dev_err(dev, "SW BUG? failed to insert packet\n");
-       dev_err(dev, "ERX: roq %p [ws %u] skb %p nsn %d sn %u\n",
-               roq, roq->ws, skb, nsn, roq_data->sn);
-       skb_queue_walk(&roq->queue, skb_itr) {
-               roq_data_itr = (struct i2400m_roq_data *) &skb_itr->cb;
-               nsn_itr = __i2400m_roq_nsn(roq, roq_data_itr->sn);
-               /* NSN bounds assumed correct (checked when it was queued) */
-               dev_err(dev, "ERX: roq %p skb_itr %p nsn %d sn %u\n",
-                       roq, skb_itr, nsn_itr, roq_data_itr->sn);
-       }
-       BUG();
-out:
-       d_fnend(4, dev, "(i2400m %p roq %p skb %p sn %u nsn %d) = void\n",
-               i2400m, roq, skb, sn, nsn);
-}
-
-
-/*
- * Backbone for the update window start operation
- *
- * @i2400m: device descriptor
- * @roq: Reorder queue
- * @sn: New sequence number
- *
- * Updates the window start of a queue; when doing so, it must deliver
- * to the networking stack all the queued skb's whose normalized
- * sequence number is lower than the new normalized window start.
- */
-static
-unsigned __i2400m_roq_update_ws(struct i2400m *i2400m, struct i2400m_roq *roq,
-                               unsigned sn)
-{
-       struct device *dev = i2400m_dev(i2400m);
-       struct sk_buff *skb_itr, *tmp_itr;
-       struct i2400m_roq_data *roq_data_itr;
-       unsigned new_nws, nsn_itr;
-
-       new_nws = __i2400m_roq_nsn(roq, sn);
-       /*
-        * For type 2(update_window_start) rx messages, there is no
-        * need to check if the normalized sequence number is greater 1023.
-        * Simply insert and deliver all packets to the host up to the
-        * window start.
-        */
-       skb_queue_walk_safe(&roq->queue, skb_itr, tmp_itr) {
-               roq_data_itr = (struct i2400m_roq_data *) &skb_itr->cb;
-               nsn_itr = __i2400m_roq_nsn(roq, roq_data_itr->sn);
-               /* NSN bounds assumed correct (checked when it was queued) */
-               if (nsn_itr < new_nws) {
-                       d_printf(2, dev, "ERX: roq %p - release skb %p "
-                                "(nsn %u/%u new nws %u)\n",
-                                roq, skb_itr, nsn_itr, roq_data_itr->sn,
-                                new_nws);
-                       __skb_unlink(skb_itr, &roq->queue);
-                       i2400m_net_erx(i2400m, skb_itr, roq_data_itr->cs);
-               }
-               else
-                       break;  /* rest of packets all nsn_itr > nws */
-       }
-       roq->ws = sn;
-       return new_nws;
-}
-
-
-/*
- * Reset a queue
- *
- * @i2400m: device descriptor
- * @cin: Queue Index
- *
- * Deliver all the packets and reset the window-start to zero. Name is
- * kind of misleading.
- */
-static
-void i2400m_roq_reset(struct i2400m *i2400m, struct i2400m_roq *roq)
-{
-       struct device *dev = i2400m_dev(i2400m);
-       struct sk_buff *skb_itr, *tmp_itr;
-       struct i2400m_roq_data *roq_data_itr;
-
-       d_fnstart(2, dev, "(i2400m %p roq %p)\n", i2400m, roq);
-       i2400m_roq_log_add(i2400m, roq, I2400M_RO_TYPE_RESET,
-                            roq->ws, skb_queue_len(&roq->queue),
-                            ~0, ~0, 0);
-       skb_queue_walk_safe(&roq->queue, skb_itr, tmp_itr) {
-               roq_data_itr = (struct i2400m_roq_data *) &skb_itr->cb;
-               d_printf(2, dev, "ERX: roq %p - release skb %p (sn %u)\n",
-                        roq, skb_itr, roq_data_itr->sn);
-               __skb_unlink(skb_itr, &roq->queue);
-               i2400m_net_erx(i2400m, skb_itr, roq_data_itr->cs);
-       }
-       roq->ws = 0;
-       d_fnend(2, dev, "(i2400m %p roq %p) = void\n", i2400m, roq);
-}
-
-
-/*
- * Queue a packet
- *
- * @i2400m: device descriptor
- * @cin: Queue Index
- * @skb: containing the packet data
- * @fbn: First block number of the packet in @skb
- * @lbn: Last block number of the packet in @skb
- *
- * The hardware is asking the driver to queue a packet for later
- * delivery to the networking stack.
- */
-static
-void i2400m_roq_queue(struct i2400m *i2400m, struct i2400m_roq *roq,
-                     struct sk_buff *skb, unsigned lbn)
-{
-       struct device *dev = i2400m_dev(i2400m);
-       unsigned nsn, len;
-
-       d_fnstart(2, dev, "(i2400m %p roq %p skb %p lbn %u) = void\n",
-                 i2400m, roq, skb, lbn);
-       len = skb_queue_len(&roq->queue);
-       nsn = __i2400m_roq_nsn(roq, lbn);
-       if (unlikely(nsn >= 1024)) {
-               dev_err(dev, "SW BUG? queue nsn %d (lbn %u ws %u)\n",
-                       nsn, lbn, roq->ws);
-               i2400m_roq_log_dump(i2400m, roq);
-               i2400m_reset(i2400m, I2400M_RT_WARM);
-       } else {
-               __i2400m_roq_queue(i2400m, roq, skb, lbn, nsn);
-               i2400m_roq_log_add(i2400m, roq, I2400M_RO_TYPE_PACKET,
-                                    roq->ws, len, lbn, nsn, ~0);
-       }
-       d_fnend(2, dev, "(i2400m %p roq %p skb %p lbn %u) = void\n",
-               i2400m, roq, skb, lbn);
-}
-
-
-/*
- * Update the window start in a reorder queue and deliver all skbs
- * with a lower window start
- *
- * @i2400m: device descriptor
- * @roq: Reorder queue
- * @sn: New sequence number
- */
-static
-void i2400m_roq_update_ws(struct i2400m *i2400m, struct i2400m_roq *roq,
-                         unsigned sn)
-{
-       struct device *dev = i2400m_dev(i2400m);
-       unsigned old_ws, nsn, len;
-
-       d_fnstart(2, dev, "(i2400m %p roq %p sn %u)\n", i2400m, roq, sn);
-       old_ws = roq->ws;
-       len = skb_queue_len(&roq->queue);
-       nsn = __i2400m_roq_update_ws(i2400m, roq, sn);
-       i2400m_roq_log_add(i2400m, roq, I2400M_RO_TYPE_WS,
-                            old_ws, len, sn, nsn, roq->ws);
-       d_fnstart(2, dev, "(i2400m %p roq %p sn %u) = void\n", i2400m, roq, sn);
-}
-
-
-/*
- * Queue a packet and update the window start
- *
- * @i2400m: device descriptor
- * @cin: Queue Index
- * @skb: containing the packet data
- * @fbn: First block number of the packet in @skb
- * @sn: Last block number of the packet in @skb
- *
- * Note that unlike i2400m_roq_update_ws(), which sets the new window
- * start to @sn, in here we'll set it to @sn + 1.
- */
-static
-void i2400m_roq_queue_update_ws(struct i2400m *i2400m, struct i2400m_roq *roq,
-                               struct sk_buff *skb, unsigned sn)
-{
-       struct device *dev = i2400m_dev(i2400m);
-       unsigned nsn, old_ws, len;
-
-       d_fnstart(2, dev, "(i2400m %p roq %p skb %p sn %u)\n",
-                 i2400m, roq, skb, sn);
-       len = skb_queue_len(&roq->queue);
-       nsn = __i2400m_roq_nsn(roq, sn);
-       /*
-        * For type 3(queue_update_window_start) rx messages, there is no
-        * need to check if the normalized sequence number is greater 1023.
-        * Simply insert and deliver all packets to the host up to the
-        * window start.
-        */
-       old_ws = roq->ws;
-       /* If the queue is empty, don't bother as we'd queue
-        * it and immediately unqueue it -- just deliver it.
-        */
-       if (len == 0) {
-               struct i2400m_roq_data *roq_data;
-               roq_data = (struct i2400m_roq_data *) &skb->cb;
-               i2400m_net_erx(i2400m, skb, roq_data->cs);
-       } else
-               __i2400m_roq_queue(i2400m, roq, skb, sn, nsn);
-
-       __i2400m_roq_update_ws(i2400m, roq, sn + 1);
-       i2400m_roq_log_add(i2400m, roq, I2400M_RO_TYPE_PACKET_WS,
-                          old_ws, len, sn, nsn, roq->ws);
-
-       d_fnend(2, dev, "(i2400m %p roq %p skb %p sn %u) = void\n",
-               i2400m, roq, skb, sn);
-}
-
-
-/*
- * This routine destroys the memory allocated for rx_roq, when no
- * other thread is accessing it. Access to rx_roq is refcounted by
- * rx_roq_refcount, hence memory allocated must be destroyed when
- * rx_roq_refcount becomes zero. This routine gets executed when
- * rx_roq_refcount becomes zero.
- */
-static void i2400m_rx_roq_destroy(struct kref *ref)
-{
-       unsigned itr;
-       struct i2400m *i2400m
-                       = container_of(ref, struct i2400m, rx_roq_refcount);
-       for (itr = 0; itr < I2400M_RO_CIN + 1; itr++)
-               __skb_queue_purge(&i2400m->rx_roq[itr].queue);
-       kfree(i2400m->rx_roq[0].log);
-       kfree(i2400m->rx_roq);
-       i2400m->rx_roq = NULL;
-}
-
-/*
- * Receive and send up an extended data packet
- *
- * @i2400m: device descriptor
- * @skb_rx: skb that contains the extended data packet
- * @single_last: 1 if the payload is the only one or the last one of
- *     the skb.
- * @payload: pointer to the packet's data inside the skb
- * @size: size of the payload
- *
- * Starting in v1.4 of the i2400m's firmware, the device can send data
- * packets to the host in an extended format that; this incudes a 16
- * byte header (struct i2400m_pl_edata_hdr). Using this header's space
- * we can fake ethernet headers for ethernet device emulation without
- * having to copy packets around.
- *
- * This function handles said path.
- *
- *
- * Receive and send up an extended data packet that requires no reordering
- *
- * @i2400m: device descriptor
- * @skb_rx: skb that contains the extended data packet
- * @single_last: 1 if the payload is the only one or the last one of
- *     the skb.
- * @payload: pointer to the packet's data (past the actual extended
- *     data payload header).
- * @size: size of the payload
- *
- * Pass over to the networking stack a data packet that might have
- * reordering requirements.
- *
- * This needs to the decide if the skb in which the packet is
- * contained can be reused or if it needs to be cloned. Then it has to
- * be trimmed in the edges so that the beginning is the space for eth
- * header and then pass it to i2400m_net_erx() for the stack
- *
- * Assumes the caller has verified the sanity of the payload (size,
- * etc) already.
- */
-static
-void i2400m_rx_edata(struct i2400m *i2400m, struct sk_buff *skb_rx,
-                    unsigned single_last, const void *payload, size_t size)
-{
-       struct device *dev = i2400m_dev(i2400m);
-       const struct i2400m_pl_edata_hdr *hdr = payload;
-       struct net_device *net_dev = i2400m->wimax_dev.net_dev;
-       struct sk_buff *skb;
-       enum i2400m_cs cs;
-       u32 reorder;
-       unsigned ro_needed, ro_type, ro_cin, ro_sn;
-       struct i2400m_roq *roq;
-       struct i2400m_roq_data *roq_data;
-       unsigned long flags;
-
-       BUILD_BUG_ON(ETH_HLEN > sizeof(*hdr));
-
-       d_fnstart(2, dev, "(i2400m %p skb_rx %p single %u payload %p "
-                 "size %zu)\n", i2400m, skb_rx, single_last, payload, size);
-       if (size < sizeof(*hdr)) {
-               dev_err(dev, "ERX: HW BUG? message with short header (%zu "
-                       "vs %zu bytes expected)\n", size, sizeof(*hdr));
-               goto error;
-       }
-
-       if (single_last) {
-               skb = skb_get(skb_rx);
-               d_printf(3, dev, "ERX: skb %p reusing\n", skb);
-       } else {
-               skb = skb_clone(skb_rx, GFP_KERNEL);
-               if (skb == NULL) {
-                       dev_err(dev, "ERX: no memory to clone skb\n");
-                       net_dev->stats.rx_dropped++;
-                       goto error_skb_clone;
-               }
-               d_printf(3, dev, "ERX: skb %p cloned from %p\n", skb, skb_rx);
-       }
-       /* now we have to pull and trim so that the skb points to the
-        * beginning of the IP packet; the netdev part will add the
-        * ethernet header as needed - we know there is enough space
-        * because we checked in i2400m_rx_edata(). */
-       skb_pull(skb, payload + sizeof(*hdr) - (void *) skb->data);
-       skb_trim(skb, (void *) skb_end_pointer(skb) - payload - sizeof(*hdr));
-
-       reorder = le32_to_cpu(hdr->reorder);
-       ro_needed = reorder & I2400M_RO_NEEDED;
-       cs = hdr->cs;
-       if (ro_needed) {
-               ro_type = (reorder >> I2400M_RO_TYPE_SHIFT) & I2400M_RO_TYPE;
-               ro_cin = (reorder >> I2400M_RO_CIN_SHIFT) & I2400M_RO_CIN;
-               ro_sn = (reorder >> I2400M_RO_SN_SHIFT) & I2400M_RO_SN;
-
-               spin_lock_irqsave(&i2400m->rx_lock, flags);
-               if (i2400m->rx_roq == NULL) {
-                       kfree_skb(skb); /* rx_roq is already destroyed */
-                       spin_unlock_irqrestore(&i2400m->rx_lock, flags);
-                       goto error;
-               }
-               roq = &i2400m->rx_roq[ro_cin];
-               kref_get(&i2400m->rx_roq_refcount);
-               spin_unlock_irqrestore(&i2400m->rx_lock, flags);
-
-               roq_data = (struct i2400m_roq_data *) &skb->cb;
-               roq_data->sn = ro_sn;
-               roq_data->cs = cs;
-               d_printf(2, dev, "ERX: reorder needed: "
-                        "type %u cin %u [ws %u] sn %u/%u len %zuB\n",
-                        ro_type, ro_cin, roq->ws, ro_sn,
-                        __i2400m_roq_nsn(roq, ro_sn), size);
-               d_dump(2, dev, payload, size);
-               switch(ro_type) {
-               case I2400M_RO_TYPE_RESET:
-                       i2400m_roq_reset(i2400m, roq);
-                       kfree_skb(skb); /* no data here */
-                       break;
-               case I2400M_RO_TYPE_PACKET:
-                       i2400m_roq_queue(i2400m, roq, skb, ro_sn);
-                       break;
-               case I2400M_RO_TYPE_WS:
-                       i2400m_roq_update_ws(i2400m, roq, ro_sn);
-                       kfree_skb(skb); /* no data here */
-                       break;
-               case I2400M_RO_TYPE_PACKET_WS:
-                       i2400m_roq_queue_update_ws(i2400m, roq, skb, ro_sn);
-                       break;
-               default:
-                       dev_err(dev, "HW BUG? unknown reorder type %u\n", ro_type);
-               }
-
-               spin_lock_irqsave(&i2400m->rx_lock, flags);
-               kref_put(&i2400m->rx_roq_refcount, i2400m_rx_roq_destroy);
-               spin_unlock_irqrestore(&i2400m->rx_lock, flags);
-       }
-       else
-               i2400m_net_erx(i2400m, skb, cs);
-error_skb_clone:
-error:
-       d_fnend(2, dev, "(i2400m %p skb_rx %p single %u payload %p "
-               "size %zu) = void\n", i2400m, skb_rx, single_last, payload, size);
-}
-
-
-/*
- * Act on a received payload
- *
- * @i2400m: device instance
- * @skb_rx: skb where the transaction was received
- * @single_last: 1 this is the only payload or the last one (so the
- *     skb can be reused instead of cloned).
- * @pld: payload descriptor
- * @payload: payload data
- *
- * Upon reception of a payload, look at its guts in the payload
- * descriptor and decide what to do with it. If it is a single payload
- * skb or if the last skb is a data packet, the skb will be referenced
- * and modified (so it doesn't have to be cloned).
- */
-static
-void i2400m_rx_payload(struct i2400m *i2400m, struct sk_buff *skb_rx,
-                      unsigned single_last, const struct i2400m_pld *pld,
-                      const void *payload)
-{
-       struct device *dev = i2400m_dev(i2400m);
-       size_t pl_size = i2400m_pld_size(pld);
-       enum i2400m_pt pl_type = i2400m_pld_type(pld);
-
-       d_printf(7, dev, "RX: received payload type %u, %zu bytes\n",
-                pl_type, pl_size);
-       d_dump(8, dev, payload, pl_size);
-
-       switch (pl_type) {
-       case I2400M_PT_DATA:
-               d_printf(3, dev, "RX: data payload %zu bytes\n", pl_size);
-               i2400m_net_rx(i2400m, skb_rx, single_last, payload, pl_size);
-               break;
-       case I2400M_PT_CTRL:
-               i2400m_rx_ctl(i2400m, skb_rx, payload, pl_size);
-               break;
-       case I2400M_PT_TRACE:
-               i2400m_rx_trace(i2400m, payload, pl_size);
-               break;
-       case I2400M_PT_EDATA:
-               d_printf(3, dev, "ERX: data payload %zu bytes\n", pl_size);
-               i2400m_rx_edata(i2400m, skb_rx, single_last, payload, pl_size);
-               break;
-       default:        /* Anything else shouldn't come to the host */
-               if (printk_ratelimit())
-                       dev_err(dev, "RX: HW BUG? unexpected payload type %u\n",
-                               pl_type);
-       }
-}
-
-
-/*
- * Check a received transaction's message header
- *
- * @i2400m: device descriptor
- * @msg_hdr: message header
- * @buf_size: size of the received buffer
- *
- * Check that the declarations done by a RX buffer message header are
- * sane and consistent with the amount of data that was received.
- */
-static
-int i2400m_rx_msg_hdr_check(struct i2400m *i2400m,
-                           const struct i2400m_msg_hdr *msg_hdr,
-                           size_t buf_size)
-{
-       int result = -EIO;
-       struct device *dev = i2400m_dev(i2400m);
-       if (buf_size < sizeof(*msg_hdr)) {
-               dev_err(dev, "RX: HW BUG? message with short header (%zu "
-                       "vs %zu bytes expected)\n", buf_size, sizeof(*msg_hdr));
-               goto error;
-       }
-       if (msg_hdr->barker != cpu_to_le32(I2400M_D2H_MSG_BARKER)) {
-               dev_err(dev, "RX: HW BUG? message received with unknown "
-                       "barker 0x%08x (buf_size %zu bytes)\n",
-                       le32_to_cpu(msg_hdr->barker), buf_size);
-               goto error;
-       }
-       if (msg_hdr->num_pls == 0) {
-               dev_err(dev, "RX: HW BUG? zero payload packets in message\n");
-               goto error;
-       }
-       if (le16_to_cpu(msg_hdr->num_pls) > I2400M_MAX_PLS_IN_MSG) {
-               dev_err(dev, "RX: HW BUG? message contains more payload "
-                       "than maximum; ignoring.\n");
-               goto error;
-       }
-       result = 0;
-error:
-       return result;
-}
-
-
-/*
- * Check a payload descriptor against the received data
- *
- * @i2400m: device descriptor
- * @pld: payload descriptor
- * @pl_itr: offset (in bytes) in the received buffer the payload is
- *          located
- * @buf_size: size of the received buffer
- *
- * Given a payload descriptor (part of a RX buffer), check it is sane
- * and that the data it declares fits in the buffer.
- */
-static
-int i2400m_rx_pl_descr_check(struct i2400m *i2400m,
-                             const struct i2400m_pld *pld,
-                             size_t pl_itr, size_t buf_size)
-{
-       int result = -EIO;
-       struct device *dev = i2400m_dev(i2400m);
-       size_t pl_size = i2400m_pld_size(pld);
-       enum i2400m_pt pl_type = i2400m_pld_type(pld);
-
-       if (pl_size > i2400m->bus_pl_size_max) {
-               dev_err(dev, "RX: HW BUG? payload @%zu: size %zu is "
-                       "bigger than maximum %zu; ignoring message\n",
-                       pl_itr, pl_size, i2400m->bus_pl_size_max);
-               goto error;
-       }
-       if (pl_itr + pl_size > buf_size) {      /* enough? */
-               dev_err(dev, "RX: HW BUG? payload @%zu: size %zu "
-                       "goes beyond the received buffer "
-                       "size (%zu bytes); ignoring message\n",
-                       pl_itr, pl_size, buf_size);
-               goto error;
-       }
-       if (pl_type >= I2400M_PT_ILLEGAL) {
-               dev_err(dev, "RX: HW BUG? illegal payload type %u; "
-                       "ignoring message\n", pl_type);
-               goto error;
-       }
-       result = 0;
-error:
-       return result;
-}
-
-
-/**
- * i2400m_rx - Receive a buffer of data from the device
- *
- * @i2400m: device descriptor
- * @skb: skbuff where the data has been received
- *
- * Parse in a buffer of data that contains an RX message sent from the
- * device. See the file header for the format. Run all checks on the
- * buffer header, then run over each payload's descriptors, verify
- * their consistency and act on each payload's contents.  If
- * everything is successful, update the device's statistics.
- *
- * Note: You need to set the skb to contain only the length of the
- * received buffer; for that, use skb_trim(skb, RECEIVED_SIZE).
- *
- * Returns:
- *
- * 0 if ok, < 0 errno on error
- *
- * If ok, this function owns now the skb and the caller DOESN'T have
- * to run kfree_skb() on it. However, on error, the caller still owns
- * the skb and it is responsible for releasing it.
- */
-int i2400m_rx(struct i2400m *i2400m, struct sk_buff *skb)
-{
-       int i, result;
-       struct device *dev = i2400m_dev(i2400m);
-       const struct i2400m_msg_hdr *msg_hdr;
-       size_t pl_itr, pl_size;
-       unsigned long flags;
-       unsigned num_pls, single_last, skb_len;
-
-       skb_len = skb->len;
-       d_fnstart(4, dev, "(i2400m %p skb %p [size %u])\n",
-                 i2400m, skb, skb_len);
-       msg_hdr = (void *) skb->data;
-       result = i2400m_rx_msg_hdr_check(i2400m, msg_hdr, skb_len);
-       if (result < 0)
-               goto error_msg_hdr_check;
-       result = -EIO;
-       num_pls = le16_to_cpu(msg_hdr->num_pls);
-       /* Check payload descriptor(s) */
-       pl_itr = struct_size(msg_hdr, pld, num_pls);
-       pl_itr = ALIGN(pl_itr, I2400M_PL_ALIGN);
-       if (pl_itr > skb_len) { /* got all the payload descriptors? */
-               dev_err(dev, "RX: HW BUG? message too short (%u bytes) for "
-                       "%u payload descriptors (%zu each, total %zu)\n",
-                       skb_len, num_pls, sizeof(msg_hdr->pld[0]), pl_itr);
-               goto error_pl_descr_short;
-       }
-       /* Walk each payload payload--check we really got it */
-       for (i = 0; i < num_pls; i++) {
-               /* work around old gcc warnings */
-               pl_size = i2400m_pld_size(&msg_hdr->pld[i]);
-               result = i2400m_rx_pl_descr_check(i2400m, &msg_hdr->pld[i],
-                                                 pl_itr, skb_len);
-               if (result < 0)
-                       goto error_pl_descr_check;
-               single_last = num_pls == 1 || i == num_pls - 1;
-               i2400m_rx_payload(i2400m, skb, single_last, &msg_hdr->pld[i],
-                                 skb->data + pl_itr);
-               pl_itr += ALIGN(pl_size, I2400M_PL_ALIGN);
-               cond_resched();         /* Don't monopolize */
-       }
-       kfree_skb(skb);
-       /* Update device statistics */
-       spin_lock_irqsave(&i2400m->rx_lock, flags);
-       i2400m->rx_pl_num += i;
-       if (i > i2400m->rx_pl_max)
-               i2400m->rx_pl_max = i;
-       if (i < i2400m->rx_pl_min)
-               i2400m->rx_pl_min = i;
-       i2400m->rx_num++;
-       i2400m->rx_size_acc += skb_len;
-       if (skb_len < i2400m->rx_size_min)
-               i2400m->rx_size_min = skb_len;
-       if (skb_len > i2400m->rx_size_max)
-               i2400m->rx_size_max = skb_len;
-       spin_unlock_irqrestore(&i2400m->rx_lock, flags);
-error_pl_descr_check:
-error_pl_descr_short:
-error_msg_hdr_check:
-       d_fnend(4, dev, "(i2400m %p skb %p [size %u]) = %d\n",
-               i2400m, skb, skb_len, result);
-       return result;
-}
-EXPORT_SYMBOL_GPL(i2400m_rx);
-
-
-void i2400m_unknown_barker(struct i2400m *i2400m,
-                          const void *buf, size_t size)
-{
-       struct device *dev = i2400m_dev(i2400m);
-       char prefix[64];
-       const __le32 *barker = buf;
-       dev_err(dev, "RX: HW BUG? unknown barker %08x, "
-               "dropping %zu bytes\n", le32_to_cpu(*barker), size);
-       snprintf(prefix, sizeof(prefix), "%s %s: ",
-                dev_driver_string(dev), dev_name(dev));
-       if (size > 64) {
-               print_hex_dump(KERN_ERR, prefix, DUMP_PREFIX_OFFSET,
-                              8, 4, buf, 64, 0);
-               printk(KERN_ERR "%s... (only first 64 bytes "
-                      "dumped)\n", prefix);
-       } else
-               print_hex_dump(KERN_ERR, prefix, DUMP_PREFIX_OFFSET,
-                              8, 4, buf, size, 0);
-}
-EXPORT_SYMBOL(i2400m_unknown_barker);
-
-
-/*
- * Initialize the RX queue and infrastructure
- *
- * This sets up all the RX reordering infrastructures, which will not
- * be used if reordering is not enabled or if the firmware does not
- * support it. The device is told to do reordering in
- * i2400m_dev_initialize(), where it also looks at the value of the
- * i2400m->rx_reorder switch before taking a decission.
- *
- * Note we allocate the roq queues in one chunk and the actual logging
- * support for it (logging) in another one and then we setup the
- * pointers from the first to the last.
- */
-int i2400m_rx_setup(struct i2400m *i2400m)
-{
-       int result = 0;
-
-       i2400m->rx_reorder = i2400m_rx_reorder_disabled? 0 : 1;
-       if (i2400m->rx_reorder) {
-               unsigned itr;
-               struct i2400m_roq_log *rd;
-
-               result = -ENOMEM;
-
-               i2400m->rx_roq = kcalloc(I2400M_RO_CIN + 1,
-                                        sizeof(i2400m->rx_roq[0]), GFP_KERNEL);
-               if (i2400m->rx_roq == NULL)
-                       goto error_roq_alloc;
-
-               rd = kcalloc(I2400M_RO_CIN + 1, sizeof(*i2400m->rx_roq[0].log),
-                            GFP_KERNEL);
-               if (rd == NULL) {
-                       result = -ENOMEM;
-                       goto error_roq_log_alloc;
-               }
-
-               for(itr = 0; itr < I2400M_RO_CIN + 1; itr++) {
-                       __i2400m_roq_init(&i2400m->rx_roq[itr]);
-                       i2400m->rx_roq[itr].log = &rd[itr];
-               }
-               kref_init(&i2400m->rx_roq_refcount);
-       }
-       return 0;
-
-error_roq_log_alloc:
-       kfree(i2400m->rx_roq);
-error_roq_alloc:
-       return result;
-}
-
-
-/* Tear down the RX queue and infrastructure */
-void i2400m_rx_release(struct i2400m *i2400m)
-{
-       unsigned long flags;
-
-       if (i2400m->rx_reorder) {
-               spin_lock_irqsave(&i2400m->rx_lock, flags);
-               kref_put(&i2400m->rx_roq_refcount, i2400m_rx_roq_destroy);
-               spin_unlock_irqrestore(&i2400m->rx_lock, flags);
-       }
-       /* at this point, nothing can be received... */
-       i2400m_report_hook_flush(i2400m);
-}
diff --git a/drivers/staging/wimax/i2400m/sysfs.c b/drivers/staging/wimax/i2400m/sysfs.c
deleted file mode 100644 (file)
index 895ee26..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel Wireless WiMAX Connection 2400m
- * Sysfs interfaces to show driver and device information
- *
- * Copyright (C) 2007 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- */
-
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/spinlock.h>
-#include <linux/device.h>
-#include "i2400m.h"
-
-
-#define D_SUBMODULE sysfs
-#include "debug-levels.h"
-
-
-/*
- * Set the idle timeout (msecs)
- *
- * FIXME: eventually this should be a common WiMAX stack method, but
- * would like to wait to see how other devices manage it.
- */
-static
-ssize_t i2400m_idle_timeout_store(struct device *dev,
-                                 struct device_attribute *attr,
-                                 const char *buf, size_t size)
-{
-       ssize_t result;
-       struct i2400m *i2400m = net_dev_to_i2400m(to_net_dev(dev));
-       unsigned val;
-
-       result = -EINVAL;
-       if (sscanf(buf, "%u\n", &val) != 1)
-               goto error_no_unsigned;
-       if (val != 0 && (val < 100 || val > 300000 || val % 100 != 0)) {
-               dev_err(dev, "idle_timeout: %u: invalid msecs specification; "
-                       "valid values are 0, 100-300000 in 100 increments\n",
-                       val);
-               goto error_bad_value;
-       }
-       result = i2400m_set_idle_timeout(i2400m, val);
-       if (result >= 0)
-               result = size;
-error_no_unsigned:
-error_bad_value:
-       return result;
-}
-
-static
-DEVICE_ATTR_WO(i2400m_idle_timeout);
-
-static
-struct attribute *i2400m_dev_attrs[] = {
-       &dev_attr_i2400m_idle_timeout.attr,
-       NULL,
-};
-
-struct attribute_group i2400m_dev_attr_group = {
-       .name = NULL,           /* we want them in the same directory */
-       .attrs = i2400m_dev_attrs,
-};
diff --git a/drivers/staging/wimax/i2400m/tx.c b/drivers/staging/wimax/i2400m/tx.c
deleted file mode 100644 (file)
index 8c01f42..0000000
+++ /dev/null
@@ -1,1015 +0,0 @@
-/*
- * Intel Wireless WiMAX Connection 2400m
- * Generic (non-bus specific) TX handling
- *
- *
- * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   * Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in
- *     the documentation and/or other materials provided with the
- *     distribution.
- *   * Neither the name of Intel Corporation nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *
- * Intel Corporation <linux-wimax@intel.com>
- * Yanir Lubetkin <yanirx.lubetkin@intel.com>
- *  - Initial implementation
- *
- * Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *  - Rewritten to use a single FIFO to lower the memory allocation
- *    pressure and optimize cache hits when copying to the queue, as
- *    well as splitting out bus-specific code.
- *
- *
- * Implements data transmission to the device; this is done through a
- * software FIFO, as data/control frames can be coalesced (while the
- * device is reading the previous tx transaction, others accumulate).
- *
- * A FIFO is used because at the end it is resource-cheaper that trying
- * to implement scatter/gather over USB. As well, most traffic is going
- * to be download (vs upload).
- *
- * The format for sending/receiving data to/from the i2400m is
- * described in detail in rx.c:PROTOCOL FORMAT. In here we implement
- * the transmission of that. This is split between a bus-independent
- * part that just prepares everything and a bus-specific part that
- * does the actual transmission over the bus to the device (in the
- * bus-specific driver).
- *
- *
- * The general format of a device-host transaction is MSG-HDR, PLD1,
- * PLD2...PLDN, PL1, PL2,...PLN, PADDING.
- *
- * Because we need the send payload descriptors and then payloads and
- * because it is kind of expensive to do scatterlists in USB (one URB
- * per node), it becomes cheaper to append all the data to a FIFO
- * (copying to a FIFO potentially in cache is cheaper).
- *
- * Then the bus-specific code takes the parts of that FIFO that are
- * written and passes them to the device.
- *
- * So the concepts to keep in mind there are:
- *
- * We use a FIFO to queue the data in a linear buffer. We first append
- * a MSG-HDR, space for I2400M_TX_PLD_MAX payload descriptors and then
- * go appending payloads until we run out of space or of payload
- * descriptors. Then we append padding to make the whole transaction a
- * multiple of i2400m->bus_tx_block_size (as defined by the bus layer).
- *
- * - A TX message: a combination of a message header, payload
- *   descriptors and payloads.
- *
- *     Open: it is marked as active (i2400m->tx_msg is valid) and we
- *       can keep adding payloads to it.
- *
- *     Closed: we are not appending more payloads to this TX message
- *       (exahusted space in the queue, too many payloads or
- *       whichever).  We have appended padding so the whole message
- *       length is aligned to i2400m->bus_tx_block_size (as set by the
- *       bus/transport layer).
- *
- * - Most of the time we keep a TX message open to which we append
- *   payloads.
- *
- * - If we are going to append and there is no more space (we are at
- *   the end of the FIFO), we close the message, mark the rest of the
- *   FIFO space unusable (skip_tail), create a new message at the
- *   beginning of the FIFO (if there is space) and append the message
- *   there.
- *
- *   This is because we need to give linear TX messages to the bus
- *   engine. So we don't write a message to the remaining FIFO space
- *   until the tail and continue at the head of it.
- *
- * - We overload one of the fields in the message header to use it as
- *   'size' of the TX message, so we can iterate over them. It also
- *   contains a flag that indicates if we have to skip it or not.
- *   When we send the buffer, we update that to its real on-the-wire
- *   value.
- *
- * - The MSG-HDR PLD1...PLD2 stuff has to be a size multiple of 16.
- *
- *   It follows that if MSG-HDR says we have N messages, the whole
- *   header + descriptors is 16 + 4*N; for those to be a multiple of
- *   16, it follows that N can be 4, 8, 12, ... (32, 48, 64, 80...
- *   bytes).
- *
- *   So if we have only 1 payload, we have to submit a header that in
- *   all truth has space for 4.
- *
- *   The implication is that we reserve space for 12 (64 bytes); but
- *   if we fill up only (eg) 2, our header becomes 32 bytes only. So
- *   the TX engine has to shift those 32 bytes of msg header and 2
- *   payloads and padding so that right after it the payloads start
- *   and the TX engine has to know about that.
- *
- *   It is cheaper to move the header up than the whole payloads down.
- *
- *   We do this in i2400m_tx_close(). See 'i2400m_msg_hdr->offset'.
- *
- * - Each payload has to be size-padded to 16 bytes; before appending
- *   it, we just do it.
- *
- * - The whole message has to be padded to i2400m->bus_tx_block_size;
- *   we do this at close time. Thus, when reserving space for the
- *   payload, we always make sure there is also free space for this
- *   padding that sooner or later will happen.
- *
- * When we append a message, we tell the bus specific code to kick in
- * TXs. It will TX (in parallel) until the buffer is exhausted--hence
- * the lockin we do. The TX code will only send a TX message at the
- * time (which remember, might contain more than one payload). Of
- * course, when the bus-specific driver attempts to TX a message that
- * is still open, it gets closed first.
- *
- * Gee, this is messy; well a picture. In the example below we have a
- * partially full FIFO, with a closed message ready to be delivered
- * (with a moved message header to make sure it is size-aligned to
- * 16), TAIL room that was unusable (and thus is marked with a message
- * header that says 'skip this') and at the head of the buffer, an
- * incomplete message with a couple of payloads.
- *
- * N   ___________________________________________________
- *    |                                                   |
- *    |     TAIL room                                     |
- *    |                                                   |
- *    |  msg_hdr to skip (size |= 0x80000)                |
- *    |---------------------------------------------------|-------
- *    |                                                   |  /|\
- *    |                                                   |   |
- *    |  TX message padding                               |   |
- *    |                                                   |   |
- *    |                                                   |   |
- *    |- - - - - - - - - - - - - - - - - - - - - - - - - -|   |
- *    |                                                   |   |
- *    |  payload 1                                        |   |
- *    |                                                   | N * tx_block_size
- *    |                                                   |   |
- *    |- - - - - - - - - - - - - - - - - - - - - - - - - -|   |
- *    |                                                   |   |
- *    |  payload 1                                        |   |
- *    |                                                   |   |
- *    |                                                   |   |
- *    |- - - - - - - - - - - - - - - - - - - - - - - - - -|- -|- - - -
- *    |  padding 3                  /|\                   |   |   /|\
- *    |  padding 2                   |                    |   |    |
- *    |  pld 1                32 bytes (2 * 16)           |   |    |
- *    |  pld 0                       |                    |   |    |
- *    |  moved msg_hdr              \|/                   |  \|/   |
- *    |- - - - - - - - - - - - - - - - - - - - - - - - - -|- - -   |
- *    |                                                   |    _PLD_SIZE
- *    |  unused                                           |        |
- *    |                                                   |        |
- *    |- - - - - - - - - - - - - - - - - - - - - - - - - -|        |
- *    |  msg_hdr (size X)       [this message is closed]  |       \|/
- *    |===================================================|========== <=== OUT
- *    |                                                   |
- *    |                                                   |
- *    |                                                   |
- *    |          Free rooom                               |
- *    |                                                   |
- *    |                                                   |
- *    |                                                   |
- *    |                                                   |
- *    |                                                   |
- *    |                                                   |
- *    |                                                   |
- *    |                                                   |
- *    |                                                   |
- *    |===================================================|========== <=== IN
- *    |                                                   |
- *    |                                                   |
- *    |                                                   |
- *    |                                                   |
- *    |  payload 1                                        |
- *    |                                                   |
- *    |                                                   |
- *    |- - - - - - - - - - - - - - - - - - - - - - - - - -|
- *    |                                                   |
- *    |  payload 0                                        |
- *    |                                                   |
- *    |                                                   |
- *    |- - - - - - - - - - - - - - - - - - - - - - - - - -|
- *    |  pld 11                     /|\                   |
- *    |  ...                         |                    |
- *    |  pld 1                64 bytes (2 * 16)           |
- *    |  pld 0                       |                    |
- *    |  msg_hdr (size X)           \|/ [message is open] |
- * 0   ---------------------------------------------------
- *
- *
- * ROADMAP
- *
- * i2400m_tx_setup()           Called by i2400m_setup
- * i2400m_tx_release()         Called by i2400m_release()
- *
- *  i2400m_tx()                 Called to send data or control frames
- *    i2400m_tx_fifo_push()     Allocates append-space in the FIFO
- *    i2400m_tx_new()           Opens a new message in the FIFO
- *    i2400m_tx_fits()          Checks if a new payload fits in the message
- *    i2400m_tx_close()         Closes an open message in the FIFO
- *    i2400m_tx_skip_tail()     Marks unusable FIFO tail space
- *    i2400m->bus_tx_kick()
- *
- * Now i2400m->bus_tx_kick() is the the bus-specific driver backend
- * implementation; that would do:
- *
- * i2400m->bus_tx_kick()
- *   i2400m_tx_msg_get()       Gets first message ready to go
- *   ...sends it...
- *   i2400m_tx_msg_sent()       Ack the message is sent; repeat from
- *                              _tx_msg_get() until it returns NULL
- *                               (FIFO empty).
- */
-#include <linux/netdevice.h>
-#include <linux/slab.h>
-#include <linux/export.h>
-#include "i2400m.h"
-
-
-#define D_SUBMODULE tx
-#include "debug-levels.h"
-
-enum {
-       /**
-        * TX Buffer size
-        *
-        * Doc says maximum transaction is 16KiB. If we had 16KiB en
-        * route and 16KiB being queued, it boils down to needing
-        * 32KiB.
-        * 32KiB is insufficient for 1400 MTU, hence increasing
-        * tx buffer size to 64KiB.
-        */
-       I2400M_TX_BUF_SIZE = 65536,
-       /**
-        * Message header and payload descriptors have to be 16
-        * aligned (16 + 4 * N = 16 * M). If we take that average sent
-        * packets are MTU size (~1400-~1500) it follows that we could
-        * fit at most 10-11 payloads in one transaction. To meet the
-        * alignment requirement, that means we need to leave space
-        * for 12 (64 bytes). To simplify, we leave space for that. If
-        * at the end there are less, we pad up to the nearest
-        * multiple of 16.
-        */
-       /*
-        * According to Intel Wimax i3200, i5x50 and i6x50 specification
-        * documents, the maximum number of payloads per message can be
-        * up to 60. Increasing the number of payloads to 60 per message
-        * helps to accommodate smaller payloads in a single transaction.
-        */
-       I2400M_TX_PLD_MAX = 60,
-       I2400M_TX_PLD_SIZE = sizeof(struct i2400m_msg_hdr)
-       + I2400M_TX_PLD_MAX * sizeof(struct i2400m_pld),
-       I2400M_TX_SKIP = 0x80000000,
-       /*
-        * According to Intel Wimax i3200, i5x50 and i6x50 specification
-        * documents, the maximum size of each message can be up to 16KiB.
-        */
-       I2400M_TX_MSG_SIZE = 16384,
-};
-
-#define TAIL_FULL ((void *)~(unsigned long)NULL)
-
-/*
- * Calculate how much tail room is available
- *
- * Note the trick here. This path is ONLY caleed for Case A (see
- * i2400m_tx_fifo_push() below), where we have:
- *
- *       Case A
- * N  ___________
- *   | tail room |
- *   |           |
- *   |<-  IN   ->|
- *   |           |
- *   |   data    |
- *   |           |
- *   |<-  OUT  ->|
- *   |           |
- *   | head room |
- * 0  -----------
- *
- * When calculating the tail_room, tx_in might get to be zero if
- * i2400m->tx_in is right at the end of the buffer (really full
- * buffer) if there is no head room. In this case, tail_room would be
- * I2400M_TX_BUF_SIZE, although it is actually zero. Hence the final
- * mod (%) operation. However, when doing this kind of optimization,
- * i2400m->tx_in being zero would fail, so we treat is an a special
- * case.
- */
-static inline
-size_t __i2400m_tx_tail_room(struct i2400m *i2400m)
-{
-       size_t tail_room;
-       size_t tx_in;
-
-       if (unlikely(i2400m->tx_in == 0))
-               return I2400M_TX_BUF_SIZE;
-       tx_in = i2400m->tx_in % I2400M_TX_BUF_SIZE;
-       tail_room = I2400M_TX_BUF_SIZE - tx_in;
-       tail_room %= I2400M_TX_BUF_SIZE;
-       return tail_room;
-}
-
-
-/*
- * Allocate @size bytes in the TX fifo, return a pointer to it
- *
- * @i2400m: device descriptor
- * @size: size of the buffer we need to allocate
- * @padding: ensure that there is at least this many bytes of free
- *     contiguous space in the fifo. This is needed because later on
- *     we might need to add padding.
- * @try_head: specify either to allocate head room or tail room space
- *     in the TX FIFO. This boolean is required to avoids a system hang
- *     due to an infinite loop caused by i2400m_tx_fifo_push().
- *     The caller must always try to allocate tail room space first by
- *     calling this routine with try_head = 0. In case if there
- *     is not enough tail room space but there is enough head room space,
- *     (i2400m_tx_fifo_push() returns TAIL_FULL) try to allocate head
- *     room space, by calling this routine again with try_head = 1.
- *
- * Returns:
- *
- *     Pointer to the allocated space. NULL if there is no
- *     space. TAIL_FULL if there is no space at the tail but there is at
- *     the head (Case B below).
- *
- * These are the two basic cases we need to keep an eye for -- it is
- * much better explained in linux/kernel/kfifo.c, but this code
- * basically does the same. No rocket science here.
- *
- *       Case A               Case B
- * N  ___________          ___________
- *   | tail room |        |   data    |
- *   |           |        |           |
- *   |<-  IN   ->|        |<-  OUT  ->|
- *   |           |        |           |
- *   |   data    |        |   room    |
- *   |           |        |           |
- *   |<-  OUT  ->|        |<-  IN   ->|
- *   |           |        |           |
- *   | head room |        |   data    |
- * 0  -----------          -----------
- *
- * We allocate only *contiguous* space.
- *
- * We can allocate only from 'room'. In Case B, it is simple; in case
- * A, we only try from the tail room; if it is not enough, we just
- * fail and return TAIL_FULL and let the caller figure out if we wants to
- * skip the tail room and try to allocate from the head.
- *
- * There is a corner case, wherein i2400m_tx_new() can get into
- * an infinite loop calling i2400m_tx_fifo_push().
- * In certain situations, tx_in would have reached on the top of TX FIFO
- * and i2400m_tx_tail_room() returns 0, as described below:
- *
- * N  ___________ tail room is zero
- *   |<-  IN   ->|
- *   |           |
- *   |           |
- *   |           |
- *   |   data    |
- *   |<-  OUT  ->|
- *   |           |
- *   |           |
- *   | head room |
- * 0  -----------
- * During such a time, where tail room is zero in the TX FIFO and if there
- * is a request to add a payload to TX FIFO, which calls:
- * i2400m_tx()
- *         ->calls i2400m_tx_close()
- *         ->calls i2400m_tx_skip_tail()
- *         goto try_new;
- *         ->calls i2400m_tx_new()
- *                    |----> [try_head:]
- *     infinite loop  |     ->calls i2400m_tx_fifo_push()
- *                    |                if (tail_room < needed)
- *                    |                   if (head_room => needed)
- *                    |                       return TAIL_FULL;
- *                    |<----  goto try_head;
- *
- * i2400m_tx() calls i2400m_tx_close() to close the message, since there
- * is no tail room to accommodate the payload and calls
- * i2400m_tx_skip_tail() to skip the tail space. Now i2400m_tx() calls
- * i2400m_tx_new() to allocate space for new message header calling
- * i2400m_tx_fifo_push() that returns TAIL_FULL, since there is no tail space
- * to accommodate the message header, but there is enough head space.
- * The i2400m_tx_new() keeps re-retrying by calling i2400m_tx_fifo_push()
- * ending up in a loop causing system freeze.
- *
- * This corner case is avoided by using a try_head boolean,
- * as an argument to i2400m_tx_fifo_push().
- *
- * Note:
- *
- *     Assumes i2400m->tx_lock is taken, and we use that as a barrier
- *
- *     The indexes keep increasing and we reset them to zero when we
- *     pop data off the queue
- */
-static
-void *i2400m_tx_fifo_push(struct i2400m *i2400m, size_t size,
-                         size_t padding, bool try_head)
-{
-       struct device *dev = i2400m_dev(i2400m);
-       size_t room, tail_room, needed_size;
-       void *ptr;
-
-       needed_size = size + padding;
-       room = I2400M_TX_BUF_SIZE - (i2400m->tx_in - i2400m->tx_out);
-       if (room < needed_size) { /* this takes care of Case B */
-               d_printf(2, dev, "fifo push %zu/%zu: no space\n",
-                        size, padding);
-               return NULL;
-       }
-       /* Is there space at the tail? */
-       tail_room = __i2400m_tx_tail_room(i2400m);
-       if (!try_head && tail_room < needed_size) {
-               /*
-                * If the tail room space is not enough to push the message
-                * in the TX FIFO, then there are two possibilities:
-                * 1. There is enough head room space to accommodate
-                * this message in the TX FIFO.
-                * 2. There is not enough space in the head room and
-                * in tail room of the TX FIFO to accommodate the message.
-                * In the case (1), return TAIL_FULL so that the caller
-                * can figure out, if the caller wants to push the message
-                * into the head room space.
-                * In the case (2), return NULL, indicating that the TX FIFO
-                * cannot accommodate the message.
-                */
-               if (room - tail_room >= needed_size) {
-                       d_printf(2, dev, "fifo push %zu/%zu: tail full\n",
-                                size, padding);
-                       return TAIL_FULL;       /* There might be head space */
-               } else {
-                       d_printf(2, dev, "fifo push %zu/%zu: no head space\n",
-                                size, padding);
-                       return NULL;    /* There is no space */
-               }
-       }
-       ptr = i2400m->tx_buf + i2400m->tx_in % I2400M_TX_BUF_SIZE;
-       d_printf(2, dev, "fifo push %zu/%zu: at @%zu\n", size, padding,
-                i2400m->tx_in % I2400M_TX_BUF_SIZE);
-       i2400m->tx_in += size;
-       return ptr;
-}
-
-
-/*
- * Mark the tail of the FIFO buffer as 'to-skip'
- *
- * We should never hit the BUG_ON() because all the sizes we push to
- * the FIFO are padded to be a multiple of 16 -- the size of *msg
- * (I2400M_PL_PAD for the payloads, I2400M_TX_PLD_SIZE for the
- * header).
- *
- * Tail room can get to be zero if a message was opened when there was
- * space only for a header. _tx_close() will mark it as to-skip (as it
- * will have no payloads) and there will be no more space to flush, so
- * nothing has to be done here. This is probably cheaper than ensuring
- * in _tx_new() that there is some space for payloads...as we could
- * always possibly hit the same problem if the payload wouldn't fit.
- *
- * Note:
- *
- *     Assumes i2400m->tx_lock is taken, and we use that as a barrier
- *
- *     This path is only taken for Case A FIFO situations [see
- *     i2400m_tx_fifo_push()]
- */
-static
-void i2400m_tx_skip_tail(struct i2400m *i2400m)
-{
-       struct device *dev = i2400m_dev(i2400m);
-       size_t tx_in = i2400m->tx_in % I2400M_TX_BUF_SIZE;
-       size_t tail_room = __i2400m_tx_tail_room(i2400m);
-       struct i2400m_msg_hdr *msg = i2400m->tx_buf + tx_in;
-       if (unlikely(tail_room == 0))
-               return;
-       BUG_ON(tail_room < sizeof(*msg));
-       msg->size = tail_room | I2400M_TX_SKIP;
-       d_printf(2, dev, "skip tail: skipping %zu bytes @%zu\n",
-                tail_room, tx_in);
-       i2400m->tx_in += tail_room;
-}
-
-
-/*
- * Check if a skb will fit in the TX queue's current active TX
- * message (if there are still descriptors left unused).
- *
- * Returns:
- *     0 if the message won't fit, 1 if it will.
- *
- * Note:
- *
- *     Assumes a TX message is active (i2400m->tx_msg).
- *
- *     Assumes i2400m->tx_lock is taken, and we use that as a barrier
- */
-static
-unsigned i2400m_tx_fits(struct i2400m *i2400m)
-{
-       struct i2400m_msg_hdr *msg_hdr = i2400m->tx_msg;
-       return le16_to_cpu(msg_hdr->num_pls) < I2400M_TX_PLD_MAX;
-
-}
-
-
-/*
- * Start a new TX message header in the queue.
- *
- * Reserve memory from the base FIFO engine and then just initialize
- * the message header.
- *
- * We allocate the biggest TX message header we might need (one that'd
- * fit I2400M_TX_PLD_MAX payloads) -- when it is closed it will be
- * 'ironed it out' and the unneeded parts removed.
- *
- * NOTE:
- *
- *     Assumes that the previous message is CLOSED (eg: either
- *     there was none or 'i2400m_tx_close()' was called on it).
- *
- *     Assumes i2400m->tx_lock is taken, and we use that as a barrier
- */
-static
-void i2400m_tx_new(struct i2400m *i2400m)
-{
-       struct device *dev = i2400m_dev(i2400m);
-       struct i2400m_msg_hdr *tx_msg;
-       bool try_head = false;
-       BUG_ON(i2400m->tx_msg != NULL);
-       /*
-        * In certain situations, TX queue might have enough space to
-        * accommodate the new message header I2400M_TX_PLD_SIZE, but
-        * might not have enough space to accommodate the payloads.
-        * Adding bus_tx_room_min padding while allocating a new TX message
-        * increases the possibilities of including at least one payload of the
-        * size <= bus_tx_room_min.
-        */
-try_head:
-       tx_msg = i2400m_tx_fifo_push(i2400m, I2400M_TX_PLD_SIZE,
-                                    i2400m->bus_tx_room_min, try_head);
-       if (tx_msg == NULL)
-               goto out;
-       else if (tx_msg == TAIL_FULL) {
-               i2400m_tx_skip_tail(i2400m);
-               d_printf(2, dev, "new TX message: tail full, trying head\n");
-               try_head = true;
-               goto try_head;
-       }
-       memset(tx_msg, 0, I2400M_TX_PLD_SIZE);
-       tx_msg->size = I2400M_TX_PLD_SIZE;
-out:
-       i2400m->tx_msg = tx_msg;
-       d_printf(2, dev, "new TX message: %p @%zu\n",
-                tx_msg, (void *) tx_msg - i2400m->tx_buf);
-}
-
-
-/*
- * Finalize the current TX message header
- *
- * Sets the message header to be at the proper location depending on
- * how many descriptors we have (check documentation at the file's
- * header for more info on that).
- *
- * Appends padding bytes to make sure the whole TX message (counting
- * from the 'relocated' message header) is aligned to
- * tx_block_size. We assume the _append() code has left enough space
- * in the FIFO for that. If there are no payloads, just pass, as it
- * won't be transferred.
- *
- * The amount of padding bytes depends on how many payloads are in the
- * TX message, as the "msg header and payload descriptors" will be
- * shifted up in the buffer.
- */
-static
-void i2400m_tx_close(struct i2400m *i2400m)
-{
-       struct device *dev = i2400m_dev(i2400m);
-       struct i2400m_msg_hdr *tx_msg = i2400m->tx_msg;
-       struct i2400m_msg_hdr *tx_msg_moved;
-       size_t aligned_size, padding, hdr_size;
-       void *pad_buf;
-       unsigned num_pls;
-
-       if (tx_msg->size & I2400M_TX_SKIP)      /* a skipper? nothing to do */
-               goto out;
-       num_pls = le16_to_cpu(tx_msg->num_pls);
-       /* We can get this situation when a new message was started
-        * and there was no space to add payloads before hitting the
-        tail (and taking padding into consideration). */
-       if (num_pls == 0) {
-               tx_msg->size |= I2400M_TX_SKIP;
-               goto out;
-       }
-       /* Relocate the message header
-        *
-        * Find the current header size, align it to 16 and if we need
-        * to move it so the tail is next to the payloads, move it and
-        * set the offset.
-        *
-        * If it moved, this header is good only for transmission; the
-        * original one (it is kept if we moved) is still used to
-        * figure out where the next TX message starts (and where the
-        * offset to the moved header is).
-        */
-       hdr_size = struct_size(tx_msg, pld, le16_to_cpu(tx_msg->num_pls));
-       hdr_size = ALIGN(hdr_size, I2400M_PL_ALIGN);
-       tx_msg->offset = I2400M_TX_PLD_SIZE - hdr_size;
-       tx_msg_moved = (void *) tx_msg + tx_msg->offset;
-       memmove(tx_msg_moved, tx_msg, hdr_size);
-       tx_msg_moved->size -= tx_msg->offset;
-       /*
-        * Now figure out how much we have to add to the (moved!)
-        * message so the size is a multiple of i2400m->bus_tx_block_size.
-        */
-       aligned_size = ALIGN(tx_msg_moved->size, i2400m->bus_tx_block_size);
-       padding = aligned_size - tx_msg_moved->size;
-       if (padding > 0) {
-               pad_buf = i2400m_tx_fifo_push(i2400m, padding, 0, 0);
-               if (WARN_ON(pad_buf == NULL || pad_buf == TAIL_FULL)) {
-                       /* This should not happen -- append should verify
-                        * there is always space left at least to append
-                        * tx_block_size */
-                       dev_err(dev,
-                               "SW BUG! Possible data leakage from memory the "
-                               "device should not read for padding - "
-                               "size %lu aligned_size %zu tx_buf %p in "
-                               "%zu out %zu\n",
-                               (unsigned long) tx_msg_moved->size,
-                               aligned_size, i2400m->tx_buf, i2400m->tx_in,
-                               i2400m->tx_out);
-               } else
-                       memset(pad_buf, 0xad, padding);
-       }
-       tx_msg_moved->padding = cpu_to_le16(padding);
-       tx_msg_moved->size += padding;
-       if (tx_msg != tx_msg_moved)
-               tx_msg->size += padding;
-out:
-       i2400m->tx_msg = NULL;
-}
-
-
-/**
- * i2400m_tx - send the data in a buffer to the device
- *
- * @i2400m: device descriptor
- *
- * @buf: pointer to the buffer to transmit
- *
- * @buf_len: buffer size
- *
- * @pl_type: type of the payload we are sending.
- *
- * Returns:
- *     0 if ok, < 0 errno code on error (-ENOSPC, if there is no more
- *     room for the message in the queue).
- *
- * Appends the buffer to the TX FIFO and notifies the bus-specific
- * part of the driver that there is new data ready to transmit.
- * Once this function returns, the buffer has been copied, so it can
- * be reused.
- *
- * The steps followed to append are explained in detail in the file
- * header.
- *
- * Whenever we write to a message, we increase msg->size, so it
- * reflects exactly how big the message is. This is needed so that if
- * we concatenate two messages before they can be sent, the code that
- * sends the messages can find the boundaries (and it will replace the
- * size with the real barker before sending).
- *
- * Note:
- *
- *     Cold and warm reset payloads need to be sent as a single
- *     payload, so we handle that.
- */
-int i2400m_tx(struct i2400m *i2400m, const void *buf, size_t buf_len,
-             enum i2400m_pt pl_type)
-{
-       int result = -ENOSPC;
-       struct device *dev = i2400m_dev(i2400m);
-       unsigned long flags;
-       size_t padded_len;
-       void *ptr;
-       bool try_head = false;
-       unsigned is_singleton = pl_type == I2400M_PT_RESET_WARM
-               || pl_type == I2400M_PT_RESET_COLD;
-
-       d_fnstart(3, dev, "(i2400m %p skb %p [%zu bytes] pt %u)\n",
-                 i2400m, buf, buf_len, pl_type);
-       padded_len = ALIGN(buf_len, I2400M_PL_ALIGN);
-       d_printf(5, dev, "padded_len %zd buf_len %zd\n", padded_len, buf_len);
-       /* If there is no current TX message, create one; if the
-        * current one is out of payload slots or we have a singleton,
-        * close it and start a new one */
-       spin_lock_irqsave(&i2400m->tx_lock, flags);
-       /* If tx_buf is NULL, device is shutdown */
-       if (i2400m->tx_buf == NULL) {
-               result = -ESHUTDOWN;
-               goto error_tx_new;
-       }
-try_new:
-       if (unlikely(i2400m->tx_msg == NULL))
-               i2400m_tx_new(i2400m);
-       else if (unlikely(!i2400m_tx_fits(i2400m)
-                         || (is_singleton && i2400m->tx_msg->num_pls != 0))) {
-               d_printf(2, dev, "closing TX message (fits %u singleton "
-                        "%u num_pls %u)\n", i2400m_tx_fits(i2400m),
-                        is_singleton, i2400m->tx_msg->num_pls);
-               i2400m_tx_close(i2400m);
-               i2400m_tx_new(i2400m);
-       }
-       if (i2400m->tx_msg == NULL)
-               goto error_tx_new;
-       /*
-        * Check if this skb will fit in the TX queue's current active
-        * TX message. The total message size must not exceed the maximum
-        * size of each message I2400M_TX_MSG_SIZE. If it exceeds,
-        * close the current message and push this skb into the new message.
-        */
-       if (i2400m->tx_msg->size + padded_len > I2400M_TX_MSG_SIZE) {
-               d_printf(2, dev, "TX: message too big, going new\n");
-               i2400m_tx_close(i2400m);
-               i2400m_tx_new(i2400m);
-       }
-       if (i2400m->tx_msg == NULL)
-               goto error_tx_new;
-       /* So we have a current message header; now append space for
-        * the message -- if there is not enough, try the head */
-       ptr = i2400m_tx_fifo_push(i2400m, padded_len,
-                                 i2400m->bus_tx_block_size, try_head);
-       if (ptr == TAIL_FULL) { /* Tail is full, try head */
-               d_printf(2, dev, "pl append: tail full\n");
-               i2400m_tx_close(i2400m);
-               i2400m_tx_skip_tail(i2400m);
-               try_head = true;
-               goto try_new;
-       } else if (ptr == NULL) {       /* All full */
-               result = -ENOSPC;
-               d_printf(2, dev, "pl append: all full\n");
-       } else {                        /* Got space, copy it, set padding */
-               struct i2400m_msg_hdr *tx_msg = i2400m->tx_msg;
-               unsigned num_pls = le16_to_cpu(tx_msg->num_pls);
-               memcpy(ptr, buf, buf_len);
-               memset(ptr + buf_len, 0xad, padded_len - buf_len);
-               i2400m_pld_set(&tx_msg->pld[num_pls], buf_len, pl_type);
-               d_printf(3, dev, "pld 0x%08x (type 0x%1x len 0x%04zx\n",
-                        le32_to_cpu(tx_msg->pld[num_pls].val),
-                        pl_type, buf_len);
-               tx_msg->num_pls = cpu_to_le16(num_pls + 1);
-               tx_msg->size += padded_len;
-               d_printf(2, dev, "TX: appended %zu b (up to %u b) pl #%u\n",
-                       padded_len, tx_msg->size, num_pls+1);
-               d_printf(2, dev,
-                        "TX: appended hdr @%zu %zu b pl #%u @%zu %zu/%zu b\n",
-                        (void *)tx_msg - i2400m->tx_buf, (size_t)tx_msg->size,
-                        num_pls+1, ptr - i2400m->tx_buf, buf_len, padded_len);
-               result = 0;
-               if (is_singleton)
-                       i2400m_tx_close(i2400m);
-       }
-error_tx_new:
-       spin_unlock_irqrestore(&i2400m->tx_lock, flags);
-       /* kick in most cases, except when the TX subsys is down, as
-        * it might free space */
-       if (likely(result != -ESHUTDOWN))
-               i2400m->bus_tx_kick(i2400m);
-       d_fnend(3, dev, "(i2400m %p skb %p [%zu bytes] pt %u) = %d\n",
-               i2400m, buf, buf_len, pl_type, result);
-       return result;
-}
-EXPORT_SYMBOL_GPL(i2400m_tx);
-
-
-/**
- * i2400m_tx_msg_get - Get the first TX message in the FIFO to start sending it
- *
- * @i2400m: device descriptors
- * @bus_size: where to place the size of the TX message
- *
- * Called by the bus-specific driver to get the first TX message at
- * the FIF that is ready for transmission.
- *
- * It sets the state in @i2400m to indicate the bus-specific driver is
- * transferring that message (i2400m->tx_msg_size).
- *
- * Once the transfer is completed, call i2400m_tx_msg_sent().
- *
- * Notes:
- *
- *     The size of the TX message to be transmitted might be smaller than
- *     that of the TX message in the FIFO (in case the header was
- *     shorter). Hence, we copy it in @bus_size, for the bus layer to
- *     use. We keep the message's size in i2400m->tx_msg_size so that
- *     when the bus later is done transferring we know how much to
- *     advance the fifo.
- *
- *     We collect statistics here as all the data is available and we
- *     assume it is going to work [see i2400m_tx_msg_sent()].
- */
-struct i2400m_msg_hdr *i2400m_tx_msg_get(struct i2400m *i2400m,
-                                        size_t *bus_size)
-{
-       struct device *dev = i2400m_dev(i2400m);
-       struct i2400m_msg_hdr *tx_msg, *tx_msg_moved;
-       unsigned long flags, pls;
-
-       d_fnstart(3, dev, "(i2400m %p bus_size %p)\n", i2400m, bus_size);
-       spin_lock_irqsave(&i2400m->tx_lock, flags);
-       tx_msg_moved = NULL;
-       if (i2400m->tx_buf == NULL)
-               goto out_unlock;
-skip:
-       tx_msg_moved = NULL;
-       if (i2400m->tx_in == i2400m->tx_out) {  /* Empty FIFO? */
-               i2400m->tx_in = 0;
-               i2400m->tx_out = 0;
-               d_printf(2, dev, "TX: FIFO empty: resetting\n");
-               goto out_unlock;
-       }
-       tx_msg = i2400m->tx_buf + i2400m->tx_out % I2400M_TX_BUF_SIZE;
-       if (tx_msg->size & I2400M_TX_SKIP) {    /* skip? */
-               d_printf(2, dev, "TX: skip: msg @%zu (%zu b)\n",
-                        i2400m->tx_out % I2400M_TX_BUF_SIZE,
-                        (size_t) tx_msg->size & ~I2400M_TX_SKIP);
-               i2400m->tx_out += tx_msg->size & ~I2400M_TX_SKIP;
-               goto skip;
-       }
-
-       if (tx_msg->num_pls == 0) {             /* No payloads? */
-               if (tx_msg == i2400m->tx_msg) { /* open, we are done */
-                       d_printf(2, dev,
-                                "TX: FIFO empty: open msg w/o payloads @%zu\n",
-                                (void *) tx_msg - i2400m->tx_buf);
-                       tx_msg = NULL;
-                       goto out_unlock;
-               } else {                        /* closed, skip it */
-                       d_printf(2, dev,
-                                "TX: skip msg w/o payloads @%zu (%zu b)\n",
-                                (void *) tx_msg - i2400m->tx_buf,
-                                (size_t) tx_msg->size);
-                       i2400m->tx_out += tx_msg->size & ~I2400M_TX_SKIP;
-                       goto skip;
-               }
-       }
-       if (tx_msg == i2400m->tx_msg)           /* open msg? */
-               i2400m_tx_close(i2400m);
-
-       /* Now we have a valid TX message (with payloads) to TX */
-       tx_msg_moved = (void *) tx_msg + tx_msg->offset;
-       i2400m->tx_msg_size = tx_msg->size;
-       *bus_size = tx_msg_moved->size;
-       d_printf(2, dev, "TX: pid %d msg hdr at @%zu offset +@%zu "
-                "size %zu bus_size %zu\n",
-                current->pid, (void *) tx_msg - i2400m->tx_buf,
-                (size_t) tx_msg->offset, (size_t) tx_msg->size,
-                (size_t) tx_msg_moved->size);
-       tx_msg_moved->barker = cpu_to_le32(I2400M_H2D_PREVIEW_BARKER);
-       tx_msg_moved->sequence = cpu_to_le32(i2400m->tx_sequence++);
-
-       pls = le16_to_cpu(tx_msg_moved->num_pls);
-       i2400m->tx_pl_num += pls;               /* Update stats */
-       if (pls > i2400m->tx_pl_max)
-               i2400m->tx_pl_max = pls;
-       if (pls < i2400m->tx_pl_min)
-               i2400m->tx_pl_min = pls;
-       i2400m->tx_num++;
-       i2400m->tx_size_acc += *bus_size;
-       if (*bus_size < i2400m->tx_size_min)
-               i2400m->tx_size_min = *bus_size;
-       if (*bus_size > i2400m->tx_size_max)
-               i2400m->tx_size_max = *bus_size;
-out_unlock:
-       spin_unlock_irqrestore(&i2400m->tx_lock, flags);
-       d_fnstart(3, dev, "(i2400m %p bus_size %p [%zu]) = %p\n",
-                 i2400m, bus_size, *bus_size, tx_msg_moved);
-       return tx_msg_moved;
-}
-EXPORT_SYMBOL_GPL(i2400m_tx_msg_get);
-
-
-/**
- * i2400m_tx_msg_sent - indicate the transmission of a TX message
- *
- * @i2400m: device descriptor
- *
- * Called by the bus-specific driver when a message has been sent;
- * this pops it from the FIFO; and as there is space, start the queue
- * in case it was stopped.
- *
- * Should be called even if the message send failed and we are
- * dropping this TX message.
- */
-void i2400m_tx_msg_sent(struct i2400m *i2400m)
-{
-       unsigned n;
-       unsigned long flags;
-       struct device *dev = i2400m_dev(i2400m);
-
-       d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
-       spin_lock_irqsave(&i2400m->tx_lock, flags);
-       if (i2400m->tx_buf == NULL)
-               goto out_unlock;
-       i2400m->tx_out += i2400m->tx_msg_size;
-       d_printf(2, dev, "TX: sent %zu b\n", (size_t) i2400m->tx_msg_size);
-       i2400m->tx_msg_size = 0;
-       BUG_ON(i2400m->tx_out > i2400m->tx_in);
-       /* level them FIFO markers off */
-       n = i2400m->tx_out / I2400M_TX_BUF_SIZE;
-       i2400m->tx_out %= I2400M_TX_BUF_SIZE;
-       i2400m->tx_in -= n * I2400M_TX_BUF_SIZE;
-out_unlock:
-       spin_unlock_irqrestore(&i2400m->tx_lock, flags);
-       d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
-}
-EXPORT_SYMBOL_GPL(i2400m_tx_msg_sent);
-
-
-/**
- * i2400m_tx_setup - Initialize the TX queue and infrastructure
- *
- * @i2400m: device descriptor
- *
- * Make sure we reset the TX sequence to zero, as when this function
- * is called, the firmware has been just restarted. Same rational
- * for tx_in, tx_out, tx_msg_size and tx_msg. We reset them since
- * the memory for TX queue is reallocated.
- */
-int i2400m_tx_setup(struct i2400m *i2400m)
-{
-       int result = 0;
-       void *tx_buf;
-       unsigned long flags;
-
-       /* Do this here only once -- can't do on
-        * i2400m_hard_start_xmit() as we'll cause race conditions if
-        * the WS was scheduled on another CPU */
-       INIT_WORK(&i2400m->wake_tx_ws, i2400m_wake_tx_work);
-
-       tx_buf = kmalloc(I2400M_TX_BUF_SIZE, GFP_ATOMIC);
-       if (tx_buf == NULL) {
-               result = -ENOMEM;
-               goto error_kmalloc;
-       }
-
-       /*
-        * Fail the build if we can't fit at least two maximum size messages
-        * on the TX FIFO [one being delivered while one is constructed].
-        */
-       BUILD_BUG_ON(2 * I2400M_TX_MSG_SIZE > I2400M_TX_BUF_SIZE);
-       spin_lock_irqsave(&i2400m->tx_lock, flags);
-       i2400m->tx_sequence = 0;
-       i2400m->tx_in = 0;
-       i2400m->tx_out = 0;
-       i2400m->tx_msg_size = 0;
-       i2400m->tx_msg = NULL;
-       i2400m->tx_buf = tx_buf;
-       spin_unlock_irqrestore(&i2400m->tx_lock, flags);
-       /* Huh? the bus layer has to define this... */
-       BUG_ON(i2400m->bus_tx_block_size == 0);
-error_kmalloc:
-       return result;
-
-}
-
-
-/*
- * i2400m_tx_release - Tear down the TX queue and infrastructure
- */
-void i2400m_tx_release(struct i2400m *i2400m)
-{
-       unsigned long flags;
-       spin_lock_irqsave(&i2400m->tx_lock, flags);
-       kfree(i2400m->tx_buf);
-       i2400m->tx_buf = NULL;
-       spin_unlock_irqrestore(&i2400m->tx_lock, flags);
-}
diff --git a/drivers/staging/wimax/i2400m/usb-debug-levels.h b/drivers/staging/wimax/i2400m/usb-debug-levels.h
deleted file mode 100644 (file)
index 8fd0111..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Intel Wireless WiMAX Connection 2400m
- * Debug levels control file for the i2400m-usb module
- *
- * Copyright (C) 2007-2008 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- */
-#ifndef __debug_levels__h__
-#define __debug_levels__h__
-
-/* Maximum compile and run time debug level for all submodules */
-#define D_MODULENAME i2400m_usb
-#define D_MASTER CONFIG_WIMAX_I2400M_DEBUG_LEVEL
-
-#include "../linux-wimax-debug.h"
-
-/* List of all the enabled modules */
-enum d_module {
-       D_SUBMODULE_DECLARE(usb),
-       D_SUBMODULE_DECLARE(fw),
-       D_SUBMODULE_DECLARE(notif),
-       D_SUBMODULE_DECLARE(rx),
-       D_SUBMODULE_DECLARE(tx),
-};
-
-
-#endif /* #ifndef __debug_levels__h__ */
diff --git a/drivers/staging/wimax/i2400m/usb-fw.c b/drivers/staging/wimax/i2400m/usb-fw.c
deleted file mode 100644 (file)
index 27ab233..0000000
+++ /dev/null
@@ -1,365 +0,0 @@
-/*
- * Intel Wireless WiMAX Connection 2400m
- * Firmware uploader's USB specifics
- *
- *
- * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   * Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in
- *     the documentation and/or other materials provided with the
- *     distribution.
- *   * Neither the name of Intel Corporation nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *
- * Intel Corporation <linux-wimax@intel.com>
- * Yanir Lubetkin <yanirx.lubetkin@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *  - Initial implementation
- *
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *  - bus generic/specific split
- *
- * THE PROCEDURE
- *
- * See fw.c for the generic description of this procedure.
- *
- * This file implements only the USB specifics. It boils down to how
- * to send a command and waiting for an acknowledgement from the
- * device.
- *
- * This code (and process) is single threaded. It assumes it is the
- * only thread poking around (guaranteed by fw.c).
- *
- * COMMAND EXECUTION
- *
- * A write URB is posted with the buffer to the bulk output endpoint.
- *
- * ACK RECEPTION
- *
- * We just post a URB to the notification endpoint and wait for
- * data. We repeat until we get all the data we expect (as indicated
- * by the call from the bus generic code).
- *
- * The data is not read from the bulk in endpoint for boot mode.
- *
- * ROADMAP
- *
- * i2400mu_bus_bm_cmd_send
- *   i2400m_bm_cmd_prepare...
- *   i2400mu_tx_bulk_out
- *
- * i2400mu_bus_bm_wait_for_ack
- *   i2400m_notif_submit
- */
-#include <linux/usb.h>
-#include <linux/gfp.h>
-#include "i2400m-usb.h"
-
-
-#define D_SUBMODULE fw
-#include "usb-debug-levels.h"
-
-
-/*
- * Synchronous write to the device
- *
- * Takes care of updating EDC counts and thus, handle device errors.
- */
-static
-ssize_t i2400mu_tx_bulk_out(struct i2400mu *i2400mu, void *buf, size_t buf_size)
-{
-       int result;
-       struct device *dev = &i2400mu->usb_iface->dev;
-       int len;
-       struct usb_endpoint_descriptor *epd;
-       int pipe, do_autopm = 1;
-
-       result = usb_autopm_get_interface(i2400mu->usb_iface);
-       if (result < 0) {
-               dev_err(dev, "BM-CMD: can't get autopm: %d\n", result);
-               do_autopm = 0;
-       }
-       epd = usb_get_epd(i2400mu->usb_iface, i2400mu->endpoint_cfg.bulk_out);
-       pipe = usb_sndbulkpipe(i2400mu->usb_dev, epd->bEndpointAddress);
-retry:
-       result = usb_bulk_msg(i2400mu->usb_dev, pipe, buf, buf_size, &len, 200);
-       switch (result) {
-       case 0:
-               if (len != buf_size) {
-                       dev_err(dev, "BM-CMD: short write (%u B vs %zu "
-                               "expected)\n", len, buf_size);
-                       result = -EIO;
-                       break;
-               }
-               result = len;
-               break;
-       case -EPIPE:
-               /*
-                * Stall -- maybe the device is choking with our
-                * requests. Clear it and give it some time. If they
-                * happen to often, it might be another symptom, so we
-                * reset.
-                *
-                * No error handling for usb_clear_halt(0; if it
-                * works, the retry works; if it fails, this switch
-                * does the error handling for us.
-                */
-               if (edc_inc(&i2400mu->urb_edc,
-                           10 * EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME)) {
-                       dev_err(dev, "BM-CMD: too many stalls in "
-                               "URB; resetting device\n");
-                       usb_queue_reset_device(i2400mu->usb_iface);
-               } else {
-                       usb_clear_halt(i2400mu->usb_dev, pipe);
-                       msleep(10);     /* give the device some time */
-                       goto retry;
-               }
-               fallthrough;
-       case -EINVAL:                   /* while removing driver */
-       case -ENODEV:                   /* dev disconnect ... */
-       case -ENOENT:                   /* just ignore it */
-       case -ESHUTDOWN:                /* and exit */
-       case -ECONNRESET:
-               result = -ESHUTDOWN;
-               break;
-       case -ETIMEDOUT:                        /* bah... */
-               break;
-       default:                                /* any other? */
-               if (edc_inc(&i2400mu->urb_edc,
-                           EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME)) {
-                               dev_err(dev, "BM-CMD: maximum errors in "
-                                       "URB exceeded; resetting device\n");
-                               usb_queue_reset_device(i2400mu->usb_iface);
-                               result = -ENODEV;
-                               break;
-               }
-               dev_err(dev, "BM-CMD: URB error %d, retrying\n",
-                       result);
-               goto retry;
-       }
-       if (do_autopm)
-               usb_autopm_put_interface(i2400mu->usb_iface);
-       return result;
-}
-
-
-/*
- * Send a boot-mode command over the bulk-out pipe
- *
- * Command can be a raw command, which requires no preparation (and
- * which might not even be following the command format). Checks that
- * the right amount of data was transferred.
- *
- * To satisfy USB requirements (no onstack, vmalloc or in data segment
- * buffers), we copy the command to i2400m->bm_cmd_buf and send it from
- * there.
- *
- * @flags: pass thru from i2400m_bm_cmd()
- * @return: cmd_size if ok, < 0 errno code on error.
- */
-ssize_t i2400mu_bus_bm_cmd_send(struct i2400m *i2400m,
-                               const struct i2400m_bootrom_header *_cmd,
-                               size_t cmd_size, int flags)
-{
-       ssize_t result;
-       struct device *dev = i2400m_dev(i2400m);
-       struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m);
-       int opcode = _cmd == NULL ? -1 : i2400m_brh_get_opcode(_cmd);
-       struct i2400m_bootrom_header *cmd;
-       size_t cmd_size_a = ALIGN(cmd_size, 16);        /* USB restriction */
-
-       d_fnstart(8, dev, "(i2400m %p cmd %p size %zu)\n",
-                 i2400m, _cmd, cmd_size);
-       result = -E2BIG;
-       if (cmd_size > I2400M_BM_CMD_BUF_SIZE)
-               goto error_too_big;
-       if (_cmd != i2400m->bm_cmd_buf)
-               memmove(i2400m->bm_cmd_buf, _cmd, cmd_size);
-       cmd = i2400m->bm_cmd_buf;
-       if (cmd_size_a > cmd_size)                      /* Zero pad space */
-               memset(i2400m->bm_cmd_buf + cmd_size, 0, cmd_size_a - cmd_size);
-       if ((flags & I2400M_BM_CMD_RAW) == 0) {
-               if (WARN_ON(i2400m_brh_get_response_required(cmd) == 0))
-                       dev_warn(dev, "SW BUG: response_required == 0\n");
-               i2400m_bm_cmd_prepare(cmd);
-       }
-       result = i2400mu_tx_bulk_out(i2400mu, i2400m->bm_cmd_buf, cmd_size);
-       if (result < 0) {
-               dev_err(dev, "boot-mode cmd %d: cannot send: %zd\n",
-                       opcode, result);
-               goto error_cmd_send;
-       }
-       if (result != cmd_size) {               /* all was transferred? */
-               dev_err(dev, "boot-mode cmd %d: incomplete transfer "
-                       "(%zd vs %zu submitted)\n",  opcode, result, cmd_size);
-               result = -EIO;
-               goto error_cmd_size;
-       }
-error_cmd_size:
-error_cmd_send:
-error_too_big:
-       d_fnend(8, dev, "(i2400m %p cmd %p size %zu) = %zd\n",
-               i2400m, _cmd, cmd_size, result);
-       return result;
-}
-
-
-static
-void __i2400mu_bm_notif_cb(struct urb *urb)
-{
-       complete(urb->context);
-}
-
-
-/*
- * submit a read to the notification endpoint
- *
- * @i2400m: device descriptor
- * @urb: urb to use
- * @completion: completion variable to complete when done
- *
- * Data is always read to i2400m->bm_ack_buf
- */
-static
-int i2400mu_notif_submit(struct i2400mu *i2400mu, struct urb *urb,
-                        struct completion *completion)
-{
-       struct i2400m *i2400m = &i2400mu->i2400m;
-       struct usb_endpoint_descriptor *epd;
-       int pipe;
-
-       epd = usb_get_epd(i2400mu->usb_iface,
-                         i2400mu->endpoint_cfg.notification);
-       pipe = usb_rcvintpipe(i2400mu->usb_dev, epd->bEndpointAddress);
-       usb_fill_int_urb(urb, i2400mu->usb_dev, pipe,
-                        i2400m->bm_ack_buf, I2400M_BM_ACK_BUF_SIZE,
-                        __i2400mu_bm_notif_cb, completion,
-                        epd->bInterval);
-       return usb_submit_urb(urb, GFP_KERNEL);
-}
-
-
-/*
- * Read an ack from  the notification endpoint
- *
- * @i2400m:
- * @_ack: pointer to where to store the read data
- * @ack_size: how many bytes we should read
- *
- * Returns: < 0 errno code on error; otherwise, amount of received bytes.
- *
- * Submits a notification read, appends the read data to the given ack
- * buffer and then repeats (until @ack_size bytes have been
- * received).
- */
-ssize_t i2400mu_bus_bm_wait_for_ack(struct i2400m *i2400m,
-                                   struct i2400m_bootrom_header *_ack,
-                                   size_t ack_size)
-{
-       ssize_t result = -ENOMEM;
-       struct device *dev = i2400m_dev(i2400m);
-       struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m);
-       struct urb notif_urb;
-       void *ack = _ack;
-       size_t offset, len;
-       long val;
-       int do_autopm = 1;
-       DECLARE_COMPLETION_ONSTACK(notif_completion);
-
-       d_fnstart(8, dev, "(i2400m %p ack %p size %zu)\n",
-                 i2400m, ack, ack_size);
-       BUG_ON(_ack == i2400m->bm_ack_buf);
-       result = usb_autopm_get_interface(i2400mu->usb_iface);
-       if (result < 0) {
-               dev_err(dev, "BM-ACK: can't get autopm: %d\n", (int) result);
-               do_autopm = 0;
-       }
-       usb_init_urb(&notif_urb);       /* ready notifications */
-       usb_get_urb(&notif_urb);
-       offset = 0;
-       while (offset < ack_size) {
-               init_completion(&notif_completion);
-               result = i2400mu_notif_submit(i2400mu, &notif_urb,
-                                             &notif_completion);
-               if (result < 0)
-                       goto error_notif_urb_submit;
-               val = wait_for_completion_interruptible_timeout(
-                       &notif_completion, HZ);
-               if (val == 0) {
-                       result = -ETIMEDOUT;
-                       usb_kill_urb(&notif_urb);       /* Timedout */
-                       goto error_notif_wait;
-               }
-               if (val == -ERESTARTSYS) {
-                       result = -EINTR;                /* Interrupted */
-                       usb_kill_urb(&notif_urb);
-                       goto error_notif_wait;
-               }
-               result = notif_urb.status;              /* How was the ack? */
-               switch (result) {
-               case 0:
-                       break;
-               case -EINVAL:                   /* while removing driver */
-               case -ENODEV:                   /* dev disconnect ... */
-               case -ENOENT:                   /* just ignore it */
-               case -ESHUTDOWN:                /* and exit */
-               case -ECONNRESET:
-                       result = -ESHUTDOWN;
-                       goto error_dev_gone;
-               default:                                /* any other? */
-                       usb_kill_urb(&notif_urb);       /* Timedout */
-                       if (edc_inc(&i2400mu->urb_edc,
-                                   EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME))
-                               goto error_exceeded;
-                       dev_err(dev, "BM-ACK: URB error %d, "
-                               "retrying\n", notif_urb.status);
-                       continue;       /* retry */
-               }
-               if (notif_urb.actual_length == 0) {
-                       d_printf(6, dev, "ZLP received, retrying\n");
-                       continue;
-               }
-               /* Got data, append it to the buffer */
-               len = min(ack_size - offset, (size_t) notif_urb.actual_length);
-               memcpy(ack + offset, i2400m->bm_ack_buf, len);
-               offset += len;
-       }
-       result = offset;
-error_notif_urb_submit:
-error_notif_wait:
-error_dev_gone:
-out:
-       if (do_autopm)
-               usb_autopm_put_interface(i2400mu->usb_iface);
-       d_fnend(8, dev, "(i2400m %p ack %p size %zu) = %ld\n",
-               i2400m, ack, ack_size, (long) result);
-       usb_put_urb(&notif_urb);
-       return result;
-
-error_exceeded:
-       dev_err(dev, "bm: maximum errors in notification URB exceeded; "
-               "resetting device\n");
-       usb_queue_reset_device(i2400mu->usb_iface);
-       goto out;
-}
diff --git a/drivers/staging/wimax/i2400m/usb-notif.c b/drivers/staging/wimax/i2400m/usb-notif.c
deleted file mode 100644 (file)
index 5d429f8..0000000
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * Intel Wireless WiMAX Connection 2400m over USB
- * Notification handling
- *
- *
- * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   * Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in
- *     the documentation and/or other materials provided with the
- *     distribution.
- *   * Neither the name of Intel Corporation nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *
- * Intel Corporation <linux-wimax@intel.com>
- * Yanir Lubetkin <yanirx.lubetkin@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *  - Initial implementation
- *
- *
- * The notification endpoint is active when the device is not in boot
- * mode; in here we just read and get notifications; based on those,
- * we act to either reinitialize the device after a reboot or to
- * submit a RX request.
- *
- * ROADMAP
- *
- * i2400mu_usb_notification_setup()
- *
- * i2400mu_usb_notification_release()
- *
- * i2400mu_usb_notification_cb()       Called when a URB is ready
- *   i2400mu_notif_grok()
- *     i2400m_is_boot_barker()
- *     i2400m_dev_reset_handle()
- *     i2400mu_rx_kick()
- */
-#include <linux/usb.h>
-#include <linux/slab.h>
-#include "i2400m-usb.h"
-
-
-#define D_SUBMODULE notif
-#include "usb-debug-levels.h"
-
-
-static const
-__le32 i2400m_ZERO_BARKER[4] = { 0, 0, 0, 0 };
-
-
-/*
- * Process a received notification
- *
- * In normal operation mode, we can only receive two types of payloads
- * on the notification endpoint:
- *
- *   - a reboot barker, we do a bootstrap (the device has reseted).
- *
- *   - a block of zeroes: there is pending data in the IN endpoint
- */
-static
-int i2400mu_notification_grok(struct i2400mu *i2400mu, const void *buf,
-                                size_t buf_len)
-{
-       int ret;
-       struct device *dev = &i2400mu->usb_iface->dev;
-       struct i2400m *i2400m = &i2400mu->i2400m;
-
-       d_fnstart(4, dev, "(i2400m %p buf %p buf_len %zu)\n",
-                 i2400mu, buf, buf_len);
-       ret = -EIO;
-       if (buf_len < sizeof(i2400m_ZERO_BARKER))
-               /* Not a bug, just ignore */
-               goto error_bad_size;
-       ret = 0;
-       if (!memcmp(i2400m_ZERO_BARKER, buf, sizeof(i2400m_ZERO_BARKER))) {
-               i2400mu_rx_kick(i2400mu);
-               goto out;
-       }
-       ret = i2400m_is_boot_barker(i2400m, buf, buf_len);
-       if (unlikely(ret >= 0))
-               ret = i2400m_dev_reset_handle(i2400m, "device rebooted");
-       else    /* Unknown or unexpected data in the notif message */
-               i2400m_unknown_barker(i2400m, buf, buf_len);
-error_bad_size:
-out:
-       d_fnend(4, dev, "(i2400m %p buf %p buf_len %zu) = %d\n",
-               i2400mu, buf, buf_len, ret);
-       return ret;
-}
-
-
-/*
- * URB callback for the notification endpoint
- *
- * @urb: the urb received from the notification endpoint
- *
- * This function will just process the USB side of the transaction,
- * checking everything is fine, pass the processing to
- * i2400m_notification_grok() and resubmit the URB.
- */
-static
-void i2400mu_notification_cb(struct urb *urb)
-{
-       int ret;
-       struct i2400mu *i2400mu = urb->context;
-       struct device *dev = &i2400mu->usb_iface->dev;
-
-       d_fnstart(4, dev, "(urb %p status %d actual_length %d)\n",
-                 urb, urb->status, urb->actual_length);
-       ret = urb->status;
-       switch (ret) {
-       case 0:
-               ret = i2400mu_notification_grok(i2400mu, urb->transfer_buffer,
-                                               urb->actual_length);
-               if (ret == -EIO && edc_inc(&i2400mu->urb_edc, EDC_MAX_ERRORS,
-                                          EDC_ERROR_TIMEFRAME))
-                       goto error_exceeded;
-               if (ret == -ENOMEM)     /* uff...power cycle? shutdown? */
-                       goto error_exceeded;
-               break;
-       case -EINVAL:                   /* while removing driver */
-       case -ENODEV:                   /* dev disconnect ... */
-       case -ENOENT:                   /* ditto */
-       case -ESHUTDOWN:                /* URB killed */
-       case -ECONNRESET:               /* disconnection */
-               goto out;               /* Notify around */
-       default:                        /* Some error? */
-               if (edc_inc(&i2400mu->urb_edc,
-                           EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME))
-                       goto error_exceeded;
-               dev_err(dev, "notification: URB error %d, retrying\n",
-                       urb->status);
-       }
-       usb_mark_last_busy(i2400mu->usb_dev);
-       ret = usb_submit_urb(i2400mu->notif_urb, GFP_ATOMIC);
-       switch (ret) {
-       case 0:
-       case -EINVAL:                   /* while removing driver */
-       case -ENODEV:                   /* dev disconnect ... */
-       case -ENOENT:                   /* ditto */
-       case -ESHUTDOWN:                /* URB killed */
-       case -ECONNRESET:               /* disconnection */
-               break;                  /* just ignore */
-       default:                        /* Some error? */
-               dev_err(dev, "notification: cannot submit URB: %d\n", ret);
-               goto error_submit;
-       }
-       d_fnend(4, dev, "(urb %p status %d actual_length %d) = void\n",
-               urb, urb->status, urb->actual_length);
-       return;
-
-error_exceeded:
-       dev_err(dev, "maximum errors in notification URB exceeded; "
-               "resetting device\n");
-error_submit:
-       usb_queue_reset_device(i2400mu->usb_iface);
-out:
-       d_fnend(4, dev, "(urb %p status %d actual_length %d) = void\n",
-               urb, urb->status, urb->actual_length);
-}
-
-
-/*
- * setup the notification endpoint
- *
- * @i2400m: device descriptor
- *
- * This procedure prepares the notification urb and handler for receiving
- * unsolicited barkers from the device.
- */
-int i2400mu_notification_setup(struct i2400mu *i2400mu)
-{
-       struct device *dev = &i2400mu->usb_iface->dev;
-       int usb_pipe, ret = 0;
-       struct usb_endpoint_descriptor *epd;
-       char *buf;
-
-       d_fnstart(4, dev, "(i2400m %p)\n", i2400mu);
-       buf = kmalloc(I2400MU_MAX_NOTIFICATION_LEN, GFP_KERNEL | GFP_DMA);
-       if (buf == NULL) {
-               ret = -ENOMEM;
-               goto error_buf_alloc;
-       }
-
-       i2400mu->notif_urb = usb_alloc_urb(0, GFP_KERNEL);
-       if (!i2400mu->notif_urb) {
-               ret = -ENOMEM;
-               goto error_alloc_urb;
-       }
-       epd = usb_get_epd(i2400mu->usb_iface,
-                         i2400mu->endpoint_cfg.notification);
-       usb_pipe = usb_rcvintpipe(i2400mu->usb_dev, epd->bEndpointAddress);
-       usb_fill_int_urb(i2400mu->notif_urb, i2400mu->usb_dev, usb_pipe,
-                        buf, I2400MU_MAX_NOTIFICATION_LEN,
-                        i2400mu_notification_cb, i2400mu, epd->bInterval);
-       ret = usb_submit_urb(i2400mu->notif_urb, GFP_KERNEL);
-       if (ret != 0) {
-               dev_err(dev, "notification: cannot submit URB: %d\n", ret);
-               goto error_submit;
-       }
-       d_fnend(4, dev, "(i2400m %p) = %d\n", i2400mu, ret);
-       return ret;
-
-error_submit:
-       usb_free_urb(i2400mu->notif_urb);
-error_alloc_urb:
-       kfree(buf);
-error_buf_alloc:
-       d_fnend(4, dev, "(i2400m %p) = %d\n", i2400mu, ret);
-       return ret;
-}
-
-
-/*
- * Tear down of the notification mechanism
- *
- * @i2400m: device descriptor
- *
- * Kill the interrupt endpoint urb, free any allocated resources.
- *
- * We need to check if we have done it before as for example,
- * _suspend() call this; if after a suspend() we get a _disconnect()
- * (as the case is when hibernating), nothing bad happens.
- */
-void i2400mu_notification_release(struct i2400mu *i2400mu)
-{
-       struct device *dev = &i2400mu->usb_iface->dev;
-
-       d_fnstart(4, dev, "(i2400mu %p)\n", i2400mu);
-       if (i2400mu->notif_urb != NULL) {
-               usb_kill_urb(i2400mu->notif_urb);
-               kfree(i2400mu->notif_urb->transfer_buffer);
-               usb_free_urb(i2400mu->notif_urb);
-               i2400mu->notif_urb = NULL;
-       }
-       d_fnend(4, dev, "(i2400mu %p)\n", i2400mu);
-}
diff --git a/drivers/staging/wimax/i2400m/usb-rx.c b/drivers/staging/wimax/i2400m/usb-rx.c
deleted file mode 100644 (file)
index 5b64bda..0000000
+++ /dev/null
@@ -1,462 +0,0 @@
-/*
- * Intel Wireless WiMAX Connection 2400m
- * USB RX handling
- *
- *
- * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   * Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in
- *     the documentation and/or other materials provided with the
- *     distribution.
- *   * Neither the name of Intel Corporation nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *
- * Intel Corporation <linux-wimax@intel.com>
- * Yanir Lubetkin <yanirx.lubetkin@intel.com>
- *  - Initial implementation
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *  - Use skb_clone(), break up processing in chunks
- *  - Split transport/device specific
- *  - Make buffer size dynamic to exert less memory pressure
- *
- *
- * This handles the RX path on USB.
- *
- * When a notification is received that says 'there is RX data ready',
- * we call i2400mu_rx_kick(); that wakes up the RX kthread, which
- * reads a buffer from USB and passes it to i2400m_rx() in the generic
- * handling code. The RX buffer has an specific format that is
- * described in rx.c.
- *
- * We use a kernel thread in a loop because:
- *
- *  - we want to be able to call the USB power management get/put
- *    functions (blocking) before each transaction.
- *
- *  - We might get a lot of notifications and we don't want to submit
- *    a zillion reads; by serializing, we are throttling.
- *
- *  - RX data processing can get heavy enough so that it is not
- *    appropriate for doing it in the USB callback; thus we run it in a
- *    process context.
- *
- * We provide a read buffer of an arbitrary size (short of a page); if
- * the callback reports -EOVERFLOW, it means it was too small, so we
- * just double the size and retry (being careful to append, as
- * sometimes the device provided some data). Every now and then we
- * check if the average packet size is smaller than the current packet
- * size and if so, we halve it. At the end, the size of the
- * preallocated buffer should be following the average received
- * transaction size, adapting dynamically to it.
- *
- * ROADMAP
- *
- * i2400mu_rx_kick()              Called from notif.c when we get a
- *                                'data ready' notification
- * i2400mu_rxd()                   Kernel RX daemon
- *   i2400mu_rx()                  Receive USB data
- *   i2400m_rx()                   Send data to generic i2400m RX handling
- *
- * i2400mu_rx_setup()              called from i2400mu_bus_dev_start()
- *
- * i2400mu_rx_release()            called from i2400mu_bus_dev_stop()
- */
-#include <linux/workqueue.h>
-#include <linux/slab.h>
-#include <linux/usb.h>
-#include "i2400m-usb.h"
-
-
-#define D_SUBMODULE rx
-#include "usb-debug-levels.h"
-
-/*
- * Dynamic RX size
- *
- * We can't let the rx_size be a multiple of 512 bytes (the RX
- * endpoint's max packet size). On some USB host controllers (we
- * haven't been able to fully characterize which), if the device is
- * about to send (for example) X bytes and we only post a buffer to
- * receive n*512, it will fail to mark that as babble (so that
- * i2400mu_rx() [case -EOVERFLOW] can resize the buffer and get the
- * rest).
- *
- * So on growing or shrinking, if it is a multiple of the
- * maxpacketsize, we remove some (instead of incresing some, so in a
- * buddy allocator we try to waste less space).
- *
- * Note we also need a hook for this on i2400mu_rx() -- when we do the
- * first read, we are sure we won't hit this spot because
- * i240mm->rx_size has been set properly. However, if we have to
- * double because of -EOVERFLOW, when we launch the read to get the
- * rest of the data, we *have* to make sure that also is not a
- * multiple of the max_pkt_size.
- */
-
-static
-size_t i2400mu_rx_size_grow(struct i2400mu *i2400mu)
-{
-       struct device *dev = &i2400mu->usb_iface->dev;
-       size_t rx_size;
-       const size_t max_pkt_size = 512;
-
-       rx_size = 2 * i2400mu->rx_size;
-       if (rx_size % max_pkt_size == 0) {
-               rx_size -= 8;
-               d_printf(1, dev,
-                        "RX: expected size grew to %zu [adjusted -8] "
-                        "from %zu\n",
-                        rx_size, i2400mu->rx_size);
-       } else
-               d_printf(1, dev,
-                        "RX: expected size grew to %zu from %zu\n",
-                        rx_size, i2400mu->rx_size);
-       return rx_size;
-}
-
-
-static
-void i2400mu_rx_size_maybe_shrink(struct i2400mu *i2400mu)
-{
-       const size_t max_pkt_size = 512;
-       struct device *dev = &i2400mu->usb_iface->dev;
-
-       if (unlikely(i2400mu->rx_size_cnt >= 100
-                    && i2400mu->rx_size_auto_shrink)) {
-               size_t avg_rx_size =
-                       i2400mu->rx_size_acc / i2400mu->rx_size_cnt;
-               size_t new_rx_size = i2400mu->rx_size / 2;
-               if (avg_rx_size < new_rx_size) {
-                       if (new_rx_size % max_pkt_size == 0) {
-                               new_rx_size -= 8;
-                               d_printf(1, dev,
-                                        "RX: expected size shrank to %zu "
-                                        "[adjusted -8] from %zu\n",
-                                        new_rx_size, i2400mu->rx_size);
-                       } else
-                               d_printf(1, dev,
-                                        "RX: expected size shrank to %zu "
-                                        "from %zu\n",
-                                        new_rx_size, i2400mu->rx_size);
-                       i2400mu->rx_size = new_rx_size;
-                       i2400mu->rx_size_cnt = 0;
-                       i2400mu->rx_size_acc = i2400mu->rx_size;
-               }
-       }
-}
-
-/*
- * Receive a message with payloads from the USB bus into an skb
- *
- * @i2400mu: USB device descriptor
- * @rx_skb: skb where to place the received message
- *
- * Deals with all the USB-specifics of receiving, dynamically
- * increasing the buffer size if so needed. Returns the payload in the
- * skb, ready to process. On a zero-length packet, we retry.
- *
- * On soft USB errors, we retry (until they become too frequent and
- * then are promoted to hard); on hard USB errors, we reset the
- * device. On other errors (skb realloacation, we just drop it and
- * hope for the next invocation to solve it).
- *
- * Returns: pointer to the skb if ok, ERR_PTR on error.
- *   NOTE: this function might realloc the skb (if it is too small),
- *   so always update with the one returned.
- *   ERR_PTR() is < 0 on error.
- *   Will return NULL if it cannot reallocate -- this can be
- *   considered a transient retryable error.
- */
-static
-struct sk_buff *i2400mu_rx(struct i2400mu *i2400mu, struct sk_buff *rx_skb)
-{
-       int result = 0;
-       struct device *dev = &i2400mu->usb_iface->dev;
-       int usb_pipe, read_size, rx_size, do_autopm;
-       struct usb_endpoint_descriptor *epd;
-       const size_t max_pkt_size = 512;
-
-       d_fnstart(4, dev, "(i2400mu %p)\n", i2400mu);
-       do_autopm = atomic_read(&i2400mu->do_autopm);
-       result = do_autopm ?
-               usb_autopm_get_interface(i2400mu->usb_iface) : 0;
-       if (result < 0) {
-               dev_err(dev, "RX: can't get autopm: %d\n", result);
-               do_autopm = 0;
-       }
-       epd = usb_get_epd(i2400mu->usb_iface, i2400mu->endpoint_cfg.bulk_in);
-       usb_pipe = usb_rcvbulkpipe(i2400mu->usb_dev, epd->bEndpointAddress);
-retry:
-       rx_size = skb_end_pointer(rx_skb) - rx_skb->data - rx_skb->len;
-       if (unlikely(rx_size % max_pkt_size == 0)) {
-               rx_size -= 8;
-               d_printf(1, dev, "RX: rx_size adapted to %d [-8]\n", rx_size);
-       }
-       result = usb_bulk_msg(
-               i2400mu->usb_dev, usb_pipe, rx_skb->data + rx_skb->len,
-               rx_size, &read_size, 200);
-       usb_mark_last_busy(i2400mu->usb_dev);
-       switch (result) {
-       case 0:
-               if (read_size == 0)
-                       goto retry;     /* ZLP, just resubmit */
-               skb_put(rx_skb, read_size);
-               break;
-       case -EPIPE:
-               /*
-                * Stall -- maybe the device is choking with our
-                * requests. Clear it and give it some time. If they
-                * happen to often, it might be another symptom, so we
-                * reset.
-                *
-                * No error handling for usb_clear_halt(0; if it
-                * works, the retry works; if it fails, this switch
-                * does the error handling for us.
-                */
-               if (edc_inc(&i2400mu->urb_edc,
-                           10 * EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME)) {
-                       dev_err(dev, "BM-CMD: too many stalls in "
-                               "URB; resetting device\n");
-                       goto do_reset;
-               }
-               usb_clear_halt(i2400mu->usb_dev, usb_pipe);
-               msleep(10);     /* give the device some time */
-               goto retry;
-       case -EINVAL:                   /* while removing driver */
-       case -ENODEV:                   /* dev disconnect ... */
-       case -ENOENT:                   /* just ignore it */
-       case -ESHUTDOWN:
-       case -ECONNRESET:
-               break;
-       case -EOVERFLOW: {              /* too small, reallocate */
-               struct sk_buff *new_skb;
-               rx_size = i2400mu_rx_size_grow(i2400mu);
-               if (rx_size <= (1 << 16))       /* cap it */
-                       i2400mu->rx_size = rx_size;
-               else if (printk_ratelimit()) {
-                       dev_err(dev, "BUG? rx_size up to %d\n", rx_size);
-                       result = -EINVAL;
-                       goto out;
-               }
-               skb_put(rx_skb, read_size);
-               new_skb = skb_copy_expand(rx_skb, 0, rx_size - rx_skb->len,
-                                         GFP_KERNEL);
-               if (new_skb == NULL) {
-                       kfree_skb(rx_skb);
-                       rx_skb = NULL;
-                       goto out;       /* drop it...*/
-               }
-               kfree_skb(rx_skb);
-               rx_skb = new_skb;
-               i2400mu->rx_size_cnt = 0;
-               i2400mu->rx_size_acc = i2400mu->rx_size;
-               d_printf(1, dev, "RX: size changed to %d, received %d, "
-                        "copied %d, capacity %ld\n",
-                        rx_size, read_size, rx_skb->len,
-                        (long) skb_end_offset(new_skb));
-               goto retry;
-       }
-               /* In most cases, it happens due to the hardware scheduling a
-                * read when there was no data - unfortunately, we have no way
-                * to tell this timeout from a USB timeout. So we just ignore
-                * it. */
-       case -ETIMEDOUT:
-               dev_err(dev, "RX: timeout: %d\n", result);
-               result = 0;
-               break;
-       default:                        /* Any error */
-               if (edc_inc(&i2400mu->urb_edc,
-                           EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME))
-                       goto error_reset;
-               dev_err(dev, "RX: error receiving URB: %d, retrying\n", result);
-               goto retry;
-       }
-out:
-       if (do_autopm)
-               usb_autopm_put_interface(i2400mu->usb_iface);
-       d_fnend(4, dev, "(i2400mu %p) = %p\n", i2400mu, rx_skb);
-       return rx_skb;
-
-error_reset:
-       dev_err(dev, "RX: maximum errors in URB exceeded; "
-               "resetting device\n");
-do_reset:
-       usb_queue_reset_device(i2400mu->usb_iface);
-       rx_skb = ERR_PTR(result);
-       goto out;
-}
-
-
-/*
- * Kernel thread for USB reception of data
- *
- * This thread waits for a kick; once kicked, it will allocate an skb
- * and receive a single message to it from USB (using
- * i2400mu_rx()). Once received, it is passed to the generic i2400m RX
- * code for processing.
- *
- * When done processing, it runs some dirty statistics to verify if
- * the last 100 messages received were smaller than half of the
- * current RX buffer size. In that case, the RX buffer size is
- * halved. This will helps lowering the pressure on the memory
- * allocator.
- *
- * Hard errors force the thread to exit.
- */
-static
-int i2400mu_rxd(void *_i2400mu)
-{
-       int result = 0;
-       struct i2400mu *i2400mu = _i2400mu;
-       struct i2400m *i2400m = &i2400mu->i2400m;
-       struct device *dev = &i2400mu->usb_iface->dev;
-       struct net_device *net_dev = i2400m->wimax_dev.net_dev;
-       size_t pending;
-       int rx_size;
-       struct sk_buff *rx_skb;
-       unsigned long flags;
-
-       d_fnstart(4, dev, "(i2400mu %p)\n", i2400mu);
-       spin_lock_irqsave(&i2400m->rx_lock, flags);
-       BUG_ON(i2400mu->rx_kthread != NULL);
-       i2400mu->rx_kthread = current;
-       spin_unlock_irqrestore(&i2400m->rx_lock, flags);
-       while (1) {
-               d_printf(2, dev, "RX: waiting for messages\n");
-               pending = 0;
-               wait_event_interruptible(
-                       i2400mu->rx_wq,
-                       (kthread_should_stop()  /* check this first! */
-                        || (pending = atomic_read(&i2400mu->rx_pending_count)))
-                       );
-               if (kthread_should_stop())
-                       break;
-               if (pending == 0)
-                       continue;
-               rx_size = i2400mu->rx_size;
-               d_printf(2, dev, "RX: reading up to %d bytes\n", rx_size);
-               rx_skb = __netdev_alloc_skb(net_dev, rx_size, GFP_KERNEL);
-               if (rx_skb == NULL) {
-                       dev_err(dev, "RX: can't allocate skb [%d bytes]\n",
-                               rx_size);
-                       msleep(50);     /* give it some time? */
-                       continue;
-               }
-
-               /* Receive the message with the payloads */
-               rx_skb = i2400mu_rx(i2400mu, rx_skb);
-               result = PTR_ERR(rx_skb);
-               if (IS_ERR(rx_skb))
-                       goto out;
-               atomic_dec(&i2400mu->rx_pending_count);
-               if (rx_skb == NULL || rx_skb->len == 0) {
-                       /* some "ignorable" condition */
-                       kfree_skb(rx_skb);
-                       continue;
-               }
-
-               /* Deliver the message to the generic i2400m code */
-               i2400mu->rx_size_cnt++;
-               i2400mu->rx_size_acc += rx_skb->len;
-               result = i2400m_rx(i2400m, rx_skb);
-               if (result == -EIO
-                   && edc_inc(&i2400mu->urb_edc,
-                              EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME)) {
-                       goto error_reset;
-               }
-
-               /* Maybe adjust RX buffer size */
-               i2400mu_rx_size_maybe_shrink(i2400mu);
-       }
-       result = 0;
-out:
-       spin_lock_irqsave(&i2400m->rx_lock, flags);
-       i2400mu->rx_kthread = NULL;
-       spin_unlock_irqrestore(&i2400m->rx_lock, flags);
-       d_fnend(4, dev, "(i2400mu %p) = %d\n", i2400mu, result);
-       return result;
-
-error_reset:
-       dev_err(dev, "RX: maximum errors in received buffer exceeded; "
-               "resetting device\n");
-       usb_queue_reset_device(i2400mu->usb_iface);
-       goto out;
-}
-
-
-/*
- * Start reading from the device
- *
- * @i2400m: device instance
- *
- * Notify the RX thread that there is data pending.
- */
-void i2400mu_rx_kick(struct i2400mu *i2400mu)
-{
-       struct i2400m *i2400m = &i2400mu->i2400m;
-       struct device *dev = &i2400mu->usb_iface->dev;
-
-       d_fnstart(3, dev, "(i2400mu %p)\n", i2400m);
-       atomic_inc(&i2400mu->rx_pending_count);
-       wake_up_all(&i2400mu->rx_wq);
-       d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
-}
-
-
-int i2400mu_rx_setup(struct i2400mu *i2400mu)
-{
-       int result = 0;
-       struct i2400m *i2400m = &i2400mu->i2400m;
-       struct device *dev = &i2400mu->usb_iface->dev;
-       struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
-       struct task_struct *kthread;
-
-       kthread = kthread_run(i2400mu_rxd, i2400mu, "%s-rx",
-                             wimax_dev->name);
-       /* the kthread function sets i2400mu->rx_thread */
-       if (IS_ERR(kthread)) {
-               result = PTR_ERR(kthread);
-               dev_err(dev, "RX: cannot start thread: %d\n", result);
-       }
-       return result;
-}
-
-
-void i2400mu_rx_release(struct i2400mu *i2400mu)
-{
-       unsigned long flags;
-       struct i2400m *i2400m = &i2400mu->i2400m;
-       struct device *dev = i2400m_dev(i2400m);
-       struct task_struct *kthread;
-
-       spin_lock_irqsave(&i2400m->rx_lock, flags);
-       kthread = i2400mu->rx_kthread;
-       i2400mu->rx_kthread = NULL;
-       spin_unlock_irqrestore(&i2400m->rx_lock, flags);
-       if (kthread)
-               kthread_stop(kthread);
-       else
-               d_printf(1, dev, "RX: kthread had already exited\n");
-}
-
diff --git a/drivers/staging/wimax/i2400m/usb-tx.c b/drivers/staging/wimax/i2400m/usb-tx.c
deleted file mode 100644 (file)
index 3ba9d70..0000000
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * Intel Wireless WiMAX Connection 2400m
- * USB specific TX handling
- *
- *
- * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   * Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in
- *     the documentation and/or other materials provided with the
- *     distribution.
- *   * Neither the name of Intel Corporation nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *
- * Intel Corporation <linux-wimax@intel.com>
- * Yanir Lubetkin <yanirx.lubetkin@intel.com>
- *  - Initial implementation
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *  - Split transport/device specific
- *
- *
- * Takes the TX messages in the i2400m's driver TX FIFO and sends them
- * to the device until there are no more.
- *
- * If we fail sending the message, we just drop it. There isn't much
- * we can do at this point. We could also retry, but the USB stack has
- * already retried and still failed, so there is not much of a
- * point. As well, most of the traffic is network, which has recovery
- * methods for dropped packets.
- *
- * For sending we just obtain a FIFO buffer to send, send it to the
- * USB bulk out, tell the TX FIFO code we have sent it; query for
- * another one, etc... until done.
- *
- * We use a thread so we can call usb_autopm_enable() and
- * usb_autopm_disable() for each transaction; this way when the device
- * goes idle, it will suspend. It also has less overhead than a
- * dedicated workqueue, as it is being used for a single task.
- *
- * ROADMAP
- *
- * i2400mu_tx_setup()
- * i2400mu_tx_release()
- *
- * i2400mu_bus_tx_kick()       - Called by the tx.c code when there
- *                                is new data in the FIFO.
- * i2400mu_txd()
- *   i2400m_tx_msg_get()
- *   i2400m_tx_msg_sent()
- */
-#include "i2400m-usb.h"
-
-
-#define D_SUBMODULE tx
-#include "usb-debug-levels.h"
-
-
-/*
- * Get the next TX message in the TX FIFO and send it to the device
- *
- * Note that any iteration consumes a message to be sent, no matter if
- * it succeeds or fails (we have no real way to retry or complain).
- *
- * Return: 0 if ok, < 0 errno code on hard error.
- */
-static
-int i2400mu_tx(struct i2400mu *i2400mu, struct i2400m_msg_hdr *tx_msg,
-              size_t tx_msg_size)
-{
-       int result = 0;
-       struct i2400m *i2400m = &i2400mu->i2400m;
-       struct device *dev = &i2400mu->usb_iface->dev;
-       int usb_pipe, sent_size, do_autopm;
-       struct usb_endpoint_descriptor *epd;
-
-       d_fnstart(4, dev, "(i2400mu %p)\n", i2400mu);
-       do_autopm = atomic_read(&i2400mu->do_autopm);
-       result = do_autopm ?
-               usb_autopm_get_interface(i2400mu->usb_iface) : 0;
-       if (result < 0) {
-               dev_err(dev, "TX: can't get autopm: %d\n", result);
-               do_autopm = 0;
-       }
-       epd = usb_get_epd(i2400mu->usb_iface, i2400mu->endpoint_cfg.bulk_out);
-       usb_pipe = usb_sndbulkpipe(i2400mu->usb_dev, epd->bEndpointAddress);
-retry:
-       result = usb_bulk_msg(i2400mu->usb_dev, usb_pipe,
-                             tx_msg, tx_msg_size, &sent_size, 200);
-       usb_mark_last_busy(i2400mu->usb_dev);
-       switch (result) {
-       case 0:
-               if (sent_size != tx_msg_size) { /* Too short? drop it */
-                       dev_err(dev, "TX: short write (%d B vs %zu "
-                               "expected)\n", sent_size, tx_msg_size);
-                       result = -EIO;
-               }
-               break;
-       case -EPIPE:
-               /*
-                * Stall -- maybe the device is choking with our
-                * requests. Clear it and give it some time. If they
-                * happen to often, it might be another symptom, so we
-                * reset.
-                *
-                * No error handling for usb_clear_halt(0; if it
-                * works, the retry works; if it fails, this switch
-                * does the error handling for us.
-                */
-               if (edc_inc(&i2400mu->urb_edc,
-                           10 * EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME)) {
-                       dev_err(dev, "BM-CMD: too many stalls in "
-                               "URB; resetting device\n");
-                       usb_queue_reset_device(i2400mu->usb_iface);
-               } else {
-                       usb_clear_halt(i2400mu->usb_dev, usb_pipe);
-                       msleep(10);     /* give the device some time */
-                       goto retry;
-               }
-               fallthrough;
-       case -EINVAL:                   /* while removing driver */
-       case -ENODEV:                   /* dev disconnect ... */
-       case -ENOENT:                   /* just ignore it */
-       case -ESHUTDOWN:                /* and exit */
-       case -ECONNRESET:
-               result = -ESHUTDOWN;
-               break;
-       default:                        /* Some error? */
-               if (edc_inc(&i2400mu->urb_edc,
-                           EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME)) {
-                       dev_err(dev, "TX: maximum errors in URB "
-                               "exceeded; resetting device\n");
-                       usb_queue_reset_device(i2400mu->usb_iface);
-               } else {
-                       dev_err(dev, "TX: cannot send URB; retrying. "
-                               "tx_msg @%zu %zu B [%d sent]: %d\n",
-                               (void *) tx_msg - i2400m->tx_buf,
-                               tx_msg_size, sent_size, result);
-                       goto retry;
-               }
-       }
-       if (do_autopm)
-               usb_autopm_put_interface(i2400mu->usb_iface);
-       d_fnend(4, dev, "(i2400mu %p) = result\n", i2400mu);
-       return result;
-}
-
-
-/*
- * Get the next TX message in the TX FIFO and send it to the device
- *
- * Note we exit the loop if i2400mu_tx() fails; that function only
- * fails on hard error (failing to tx a buffer not being one of them,
- * see its doc).
- *
- * Return: 0
- */
-static
-int i2400mu_txd(void *_i2400mu)
-{
-       struct i2400mu *i2400mu = _i2400mu;
-       struct i2400m *i2400m = &i2400mu->i2400m;
-       struct device *dev = &i2400mu->usb_iface->dev;
-       struct i2400m_msg_hdr *tx_msg;
-       size_t tx_msg_size;
-       unsigned long flags;
-
-       d_fnstart(4, dev, "(i2400mu %p)\n", i2400mu);
-
-       spin_lock_irqsave(&i2400m->tx_lock, flags);
-       BUG_ON(i2400mu->tx_kthread != NULL);
-       i2400mu->tx_kthread = current;
-       spin_unlock_irqrestore(&i2400m->tx_lock, flags);
-
-       while (1) {
-               d_printf(2, dev, "TX: waiting for messages\n");
-               tx_msg = NULL;
-               wait_event_interruptible(
-                       i2400mu->tx_wq,
-                       (kthread_should_stop()  /* check this first! */
-                        || (tx_msg = i2400m_tx_msg_get(i2400m, &tx_msg_size)))
-                       );
-               if (kthread_should_stop())
-                       break;
-               WARN_ON(tx_msg == NULL);        /* should not happen...*/
-               d_printf(2, dev, "TX: submitting %zu bytes\n", tx_msg_size);
-               d_dump(5, dev, tx_msg, tx_msg_size);
-               /* Yeah, we ignore errors ... not much we can do */
-               i2400mu_tx(i2400mu, tx_msg, tx_msg_size);
-               i2400m_tx_msg_sent(i2400m);     /* ack it, advance the FIFO */
-       }
-
-       spin_lock_irqsave(&i2400m->tx_lock, flags);
-       i2400mu->tx_kthread = NULL;
-       spin_unlock_irqrestore(&i2400m->tx_lock, flags);
-
-       d_fnend(4, dev, "(i2400mu %p)\n", i2400mu);
-       return 0;
-}
-
-
-/*
- * i2400m TX engine notifies us that there is data in the FIFO ready
- * for TX
- *
- * If there is a URB in flight, don't do anything; when it finishes,
- * it will see there is data in the FIFO and send it. Else, just
- * submit a write.
- */
-void i2400mu_bus_tx_kick(struct i2400m *i2400m)
-{
-       struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m);
-       struct device *dev = &i2400mu->usb_iface->dev;
-
-       d_fnstart(3, dev, "(i2400m %p) = void\n", i2400m);
-       wake_up_all(&i2400mu->tx_wq);
-       d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
-}
-
-
-int i2400mu_tx_setup(struct i2400mu *i2400mu)
-{
-       int result = 0;
-       struct i2400m *i2400m = &i2400mu->i2400m;
-       struct device *dev = &i2400mu->usb_iface->dev;
-       struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
-       struct task_struct *kthread;
-
-       kthread = kthread_run(i2400mu_txd, i2400mu, "%s-tx",
-                             wimax_dev->name);
-       /* the kthread function sets i2400mu->tx_thread */
-       if (IS_ERR(kthread)) {
-               result = PTR_ERR(kthread);
-               dev_err(dev, "TX: cannot start thread: %d\n", result);
-       }
-       return result;
-}
-
-void i2400mu_tx_release(struct i2400mu *i2400mu)
-{
-       unsigned long flags;
-       struct i2400m *i2400m = &i2400mu->i2400m;
-       struct device *dev = i2400m_dev(i2400m);
-       struct task_struct *kthread;
-
-       spin_lock_irqsave(&i2400m->tx_lock, flags);
-       kthread = i2400mu->tx_kthread;
-       i2400mu->tx_kthread = NULL;
-       spin_unlock_irqrestore(&i2400m->tx_lock, flags);
-       if (kthread)
-               kthread_stop(kthread);
-       else
-               d_printf(1, dev, "TX: kthread had already exited\n");
-}
diff --git a/drivers/staging/wimax/i2400m/usb.c b/drivers/staging/wimax/i2400m/usb.c
deleted file mode 100644 (file)
index 481b1cc..0000000
+++ /dev/null
@@ -1,765 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel Wireless WiMAX Connection 2400m
- * Linux driver model glue for USB device, reset & fw upload
- *
- * Copyright (C) 2007-2008 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- * Yanir Lubetkin <yanirx.lubetkin@intel.com>
- *
- * See i2400m-usb.h for a general description of this driver.
- *
- * This file implements driver model glue, and hook ups for the
- * generic driver to implement the bus-specific functions (device
- * communication setup/tear down, firmware upload and resetting).
- *
- * ROADMAP
- *
- * i2400mu_probe()
- *   alloc_netdev()...
- *     i2400mu_netdev_setup()
- *       i2400mu_init()
- *       i2400m_netdev_setup()
- *   i2400m_setup()...
- *
- * i2400mu_disconnect
- *   i2400m_release()
- *   free_netdev()
- *
- * i2400mu_suspend()
- *   i2400m_cmd_enter_powersave()
- *   i2400mu_notification_release()
- *
- * i2400mu_resume()
- *   i2400mu_notification_setup()
- *
- * i2400mu_bus_dev_start()        Called by i2400m_dev_start() [who is
- *   i2400mu_tx_setup()           called by i2400m_setup()]
- *   i2400mu_rx_setup()
- *   i2400mu_notification_setup()
- *
- * i2400mu_bus_dev_stop()         Called by i2400m_dev_stop() [who is
- *   i2400mu_notification_release()  called by i2400m_release()]
- *   i2400mu_rx_release()
- *   i2400mu_tx_release()
- *
- * i2400mu_bus_reset()            Called by i2400m_reset
- *   __i2400mu_reset()
- *     __i2400mu_send_barker()
- *   usb_reset_device()
- */
-#include "i2400m-usb.h"
-#include "linux-wimax-i2400m.h"
-#include <linux/debugfs.h>
-#include <linux/ethtool.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-
-
-#define D_SUBMODULE usb
-#include "usb-debug-levels.h"
-
-static char i2400mu_debug_params[128];
-module_param_string(debug, i2400mu_debug_params, sizeof(i2400mu_debug_params),
-                   0644);
-MODULE_PARM_DESC(debug,
-                "String of space-separated NAME:VALUE pairs, where NAMEs "
-                "are the different debug submodules and VALUE are the "
-                "initial debug value to set.");
-
-/* Our firmware file name */
-static const char *i2400mu_bus_fw_names_5x50[] = {
-#define I2400MU_FW_FILE_NAME_v1_5 "i2400m-fw-usb-1.5.sbcf"
-       I2400MU_FW_FILE_NAME_v1_5,
-#define I2400MU_FW_FILE_NAME_v1_4 "i2400m-fw-usb-1.4.sbcf"
-       I2400MU_FW_FILE_NAME_v1_4,
-       NULL,
-};
-
-
-static const char *i2400mu_bus_fw_names_6050[] = {
-#define I6050U_FW_FILE_NAME_v1_5 "i6050-fw-usb-1.5.sbcf"
-       I6050U_FW_FILE_NAME_v1_5,
-       NULL,
-};
-
-
-static
-int i2400mu_bus_dev_start(struct i2400m *i2400m)
-{
-       int result;
-       struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m);
-       struct device *dev = &i2400mu->usb_iface->dev;
-
-       d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
-       result = i2400mu_tx_setup(i2400mu);
-       if (result < 0)
-               goto error_usb_tx_setup;
-       result = i2400mu_rx_setup(i2400mu);
-       if (result < 0)
-               goto error_usb_rx_setup;
-       result = i2400mu_notification_setup(i2400mu);
-       if (result < 0)
-               goto error_notif_setup;
-       d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
-       return result;
-
-error_notif_setup:
-       i2400mu_rx_release(i2400mu);
-error_usb_rx_setup:
-       i2400mu_tx_release(i2400mu);
-error_usb_tx_setup:
-       d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
-       return result;
-}
-
-
-static
-void i2400mu_bus_dev_stop(struct i2400m *i2400m)
-{
-       struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m);
-       struct device *dev = &i2400mu->usb_iface->dev;
-
-       d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
-       i2400mu_notification_release(i2400mu);
-       i2400mu_rx_release(i2400mu);
-       i2400mu_tx_release(i2400mu);
-       d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
-}
-
-
-/*
- * Sends a barker buffer to the device
- *
- * This helper will allocate a kmalloced buffer and use it to transmit
- * (then free it). Reason for this is that other arches cannot use
- * stack/vmalloc/text areas for DMA transfers.
- *
- * Error recovery here is simpler: anything is considered a hard error
- * and will move the reset code to use a last-resort bus-based reset.
- */
-static
-int __i2400mu_send_barker(struct i2400mu *i2400mu,
-                         const __le32 *barker,
-                         size_t barker_size,
-                         unsigned endpoint)
-{
-       struct usb_endpoint_descriptor *epd = NULL;
-       int pipe, actual_len, ret;
-       struct device *dev = &i2400mu->usb_iface->dev;
-       void *buffer;
-       int do_autopm = 1;
-
-       ret = usb_autopm_get_interface(i2400mu->usb_iface);
-       if (ret < 0) {
-               dev_err(dev, "RESET: can't get autopm: %d\n", ret);
-               do_autopm = 0;
-       }
-       ret = -ENOMEM;
-       buffer = kmalloc(barker_size, GFP_KERNEL);
-       if (buffer == NULL)
-               goto error_kzalloc;
-       epd = usb_get_epd(i2400mu->usb_iface, endpoint);
-       pipe = usb_sndbulkpipe(i2400mu->usb_dev, epd->bEndpointAddress);
-       memcpy(buffer, barker, barker_size);
-retry:
-       ret = usb_bulk_msg(i2400mu->usb_dev, pipe, buffer, barker_size,
-                          &actual_len, 200);
-       switch (ret) {
-       case 0:
-               if (actual_len != barker_size) {        /* Too short? drop it */
-                       dev_err(dev, "E: %s: short write (%d B vs %zu "
-                               "expected)\n",
-                               __func__, actual_len, barker_size);
-                       ret = -EIO;
-               }
-               break;
-       case -EPIPE:
-               /*
-                * Stall -- maybe the device is choking with our
-                * requests. Clear it and give it some time. If they
-                * happen to often, it might be another symptom, so we
-                * reset.
-                *
-                * No error handling for usb_clear_halt(0; if it
-                * works, the retry works; if it fails, this switch
-                * does the error handling for us.
-                */
-               if (edc_inc(&i2400mu->urb_edc,
-                           10 * EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME)) {
-                       dev_err(dev, "E: %s: too many stalls in "
-                               "URB; resetting device\n", __func__);
-                       usb_queue_reset_device(i2400mu->usb_iface);
-                       /* fallthrough */
-               } else {
-                       usb_clear_halt(i2400mu->usb_dev, pipe);
-                       msleep(10);     /* give the device some time */
-                       goto retry;
-               }
-               fallthrough;
-       case -EINVAL:                   /* while removing driver */
-       case -ENODEV:                   /* dev disconnect ... */
-       case -ENOENT:                   /* just ignore it */
-       case -ESHUTDOWN:                /* and exit */
-       case -ECONNRESET:
-               ret = -ESHUTDOWN;
-               break;
-       default:                        /* Some error? */
-               if (edc_inc(&i2400mu->urb_edc,
-                           EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME)) {
-                       dev_err(dev, "E: %s: maximum errors in URB "
-                               "exceeded; resetting device\n",
-                               __func__);
-                       usb_queue_reset_device(i2400mu->usb_iface);
-               } else {
-                       dev_warn(dev, "W: %s: cannot send URB: %d\n",
-                                __func__, ret);
-                       goto retry;
-               }
-       }
-       kfree(buffer);
-error_kzalloc:
-       if (do_autopm)
-               usb_autopm_put_interface(i2400mu->usb_iface);
-       return ret;
-}
-
-
-/*
- * Reset a device at different levels (warm, cold or bus)
- *
- * @i2400m: device descriptor
- * @reset_type: soft, warm or bus reset (I2400M_RT_WARM/SOFT/BUS)
- *
- * Warm and cold resets get a USB reset if they fail.
- *
- * Warm reset:
- *
- * The device will be fully reset internally, but won't be
- * disconnected from the USB bus (so no reenumeration will
- * happen). Firmware upload will be necessary.
- *
- * The device will send a reboot barker in the notification endpoint
- * that will trigger the driver to reinitialize the state
- * automatically from notif.c:i2400m_notification_grok() into
- * i2400m_dev_bootstrap_delayed().
- *
- * Cold and bus (USB) reset:
- *
- * The device will be fully reset internally, disconnected from the
- * USB bus an a reenumeration will happen. Firmware upload will be
- * necessary. Thus, we don't do any locking or struct
- * reinitialization, as we are going to be fully disconnected and
- * reenumerated.
- *
- * Note we need to return -ENODEV if a warm reset was requested and we
- * had to resort to a bus reset. See i2400m_op_reset(), wimax_reset()
- * and wimax_dev->op_reset.
- *
- * WARNING: no driver state saved/fixed
- */
-static
-int i2400mu_bus_reset(struct i2400m *i2400m, enum i2400m_reset_type rt)
-{
-       int result;
-       struct i2400mu *i2400mu =
-               container_of(i2400m, struct i2400mu, i2400m);
-       struct device *dev = i2400m_dev(i2400m);
-       static const __le32 i2400m_WARM_BOOT_BARKER[4] = {
-               cpu_to_le32(I2400M_WARM_RESET_BARKER),
-               cpu_to_le32(I2400M_WARM_RESET_BARKER),
-               cpu_to_le32(I2400M_WARM_RESET_BARKER),
-               cpu_to_le32(I2400M_WARM_RESET_BARKER),
-       };
-       static const __le32 i2400m_COLD_BOOT_BARKER[4] = {
-               cpu_to_le32(I2400M_COLD_RESET_BARKER),
-               cpu_to_le32(I2400M_COLD_RESET_BARKER),
-               cpu_to_le32(I2400M_COLD_RESET_BARKER),
-               cpu_to_le32(I2400M_COLD_RESET_BARKER),
-       };
-
-       d_fnstart(3, dev, "(i2400m %p rt %u)\n", i2400m, rt);
-       if (rt == I2400M_RT_WARM)
-               result = __i2400mu_send_barker(
-                       i2400mu, i2400m_WARM_BOOT_BARKER,
-                       sizeof(i2400m_WARM_BOOT_BARKER),
-                       i2400mu->endpoint_cfg.bulk_out);
-       else if (rt == I2400M_RT_COLD)
-               result = __i2400mu_send_barker(
-                       i2400mu, i2400m_COLD_BOOT_BARKER,
-                       sizeof(i2400m_COLD_BOOT_BARKER),
-                       i2400mu->endpoint_cfg.reset_cold);
-       else if (rt == I2400M_RT_BUS) {
-               result = usb_reset_device(i2400mu->usb_dev);
-               switch (result) {
-               case 0:
-               case -EINVAL:   /* device is gone */
-               case -ENODEV:
-               case -ENOENT:
-               case -ESHUTDOWN:
-                       result = 0;
-                       break;  /* We assume the device is disconnected */
-               default:
-                       dev_err(dev, "USB reset failed (%d), giving up!\n",
-                               result);
-               }
-       } else {
-               result = -EINVAL;       /* shut gcc up in certain arches */
-               BUG();
-       }
-       if (result < 0
-           && result != -EINVAL        /* device is gone */
-           && rt != I2400M_RT_BUS) {
-               /*
-                * Things failed -- resort to lower level reset, that
-                * we queue in another context; the reason for this is
-                * that the pre and post reset functionality requires
-                * the i2400m->init_mutex; RT_WARM and RT_COLD can
-                * come from areas where i2400m->init_mutex is taken.
-                */
-               dev_err(dev, "%s reset failed (%d); trying USB reset\n",
-                       rt == I2400M_RT_WARM ? "warm" : "cold", result);
-               usb_queue_reset_device(i2400mu->usb_iface);
-               result = -ENODEV;
-       }
-       d_fnend(3, dev, "(i2400m %p rt %u) = %d\n", i2400m, rt, result);
-       return result;
-}
-
-static void i2400mu_get_drvinfo(struct net_device *net_dev,
-                                struct ethtool_drvinfo *info)
-{
-       struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
-       struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m);
-       struct usb_device *udev = i2400mu->usb_dev;
-
-       strscpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
-       strscpy(info->fw_version, i2400m->fw_name ? : "",
-               sizeof(info->fw_version));
-       usb_make_path(udev, info->bus_info, sizeof(info->bus_info));
-}
-
-static const struct ethtool_ops i2400mu_ethtool_ops = {
-       .get_drvinfo = i2400mu_get_drvinfo,
-       .get_link = ethtool_op_get_link,
-};
-
-static
-void i2400mu_netdev_setup(struct net_device *net_dev)
-{
-       struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
-       struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m);
-       i2400mu_init(i2400mu);
-       i2400m_netdev_setup(net_dev);
-       net_dev->ethtool_ops = &i2400mu_ethtool_ops;
-}
-
-
-/*
- * Debug levels control; see debug.h
- */
-struct d_level D_LEVEL[] = {
-       D_SUBMODULE_DEFINE(usb),
-       D_SUBMODULE_DEFINE(fw),
-       D_SUBMODULE_DEFINE(notif),
-       D_SUBMODULE_DEFINE(rx),
-       D_SUBMODULE_DEFINE(tx),
-};
-size_t D_LEVEL_SIZE = ARRAY_SIZE(D_LEVEL);
-
-static
-void i2400mu_debugfs_add(struct i2400mu *i2400mu)
-{
-       struct dentry *dentry = i2400mu->i2400m.wimax_dev.debugfs_dentry;
-
-       dentry = debugfs_create_dir("i2400m-usb", dentry);
-       i2400mu->debugfs_dentry = dentry;
-
-       d_level_register_debugfs("dl_", usb, dentry);
-       d_level_register_debugfs("dl_", fw, dentry);
-       d_level_register_debugfs("dl_", notif, dentry);
-       d_level_register_debugfs("dl_", rx, dentry);
-       d_level_register_debugfs("dl_", tx, dentry);
-
-       /* Don't touch these if you don't know what you are doing */
-       debugfs_create_u8("rx_size_auto_shrink", 0600, dentry,
-                         &i2400mu->rx_size_auto_shrink);
-
-       debugfs_create_size_t("rx_size", 0600, dentry, &i2400mu->rx_size);
-}
-
-
-static struct device_type i2400mu_type = {
-       .name   = "wimax",
-};
-
-/*
- * Probe a i2400m interface and register it
- *
- * @iface:   USB interface to link to
- * @id:      USB class/subclass/protocol id
- * @returns: 0 if ok, < 0 errno code on error.
- *
- * Alloc a net device, initialize the bus-specific details and then
- * calls the bus-generic initialization routine. That will register
- * the wimax and netdev devices, upload the firmware [using
- * _bus_bm_*()], call _bus_dev_start() to finalize the setup of the
- * communication with the device and then will start to talk to it to
- * finnish setting it up.
- */
-static
-int i2400mu_probe(struct usb_interface *iface,
-                 const struct usb_device_id *id)
-{
-       int result;
-       struct net_device *net_dev;
-       struct device *dev = &iface->dev;
-       struct i2400m *i2400m;
-       struct i2400mu *i2400mu;
-       struct usb_device *usb_dev = interface_to_usbdev(iface);
-
-       if (iface->cur_altsetting->desc.bNumEndpoints < 4)
-               return -ENODEV;
-
-       if (usb_dev->speed != USB_SPEED_HIGH)
-               dev_err(dev, "device not connected as high speed\n");
-
-       /* Allocate instance [calls i2400m_netdev_setup() on it]. */
-       result = -ENOMEM;
-       net_dev = alloc_netdev(sizeof(*i2400mu), "wmx%d", NET_NAME_UNKNOWN,
-                              i2400mu_netdev_setup);
-       if (net_dev == NULL) {
-               dev_err(dev, "no memory for network device instance\n");
-               goto error_alloc_netdev;
-       }
-       SET_NETDEV_DEV(net_dev, dev);
-       SET_NETDEV_DEVTYPE(net_dev, &i2400mu_type);
-       i2400m = net_dev_to_i2400m(net_dev);
-       i2400mu = container_of(i2400m, struct i2400mu, i2400m);
-       i2400m->wimax_dev.net_dev = net_dev;
-       i2400mu->usb_dev = usb_get_dev(usb_dev);
-       i2400mu->usb_iface = iface;
-       usb_set_intfdata(iface, i2400mu);
-
-       i2400m->bus_tx_block_size = I2400MU_BLK_SIZE;
-       /*
-        * Room required in the Tx queue for USB message to accommodate
-        * a smallest payload while allocating header space is 16 bytes.
-        * Adding this room  for the new tx message increases the
-        * possibilities of including any payload with size <= 16 bytes.
-        */
-       i2400m->bus_tx_room_min = I2400MU_BLK_SIZE;
-       i2400m->bus_pl_size_max = I2400MU_PL_SIZE_MAX;
-       i2400m->bus_setup = NULL;
-       i2400m->bus_dev_start = i2400mu_bus_dev_start;
-       i2400m->bus_dev_stop = i2400mu_bus_dev_stop;
-       i2400m->bus_release = NULL;
-       i2400m->bus_tx_kick = i2400mu_bus_tx_kick;
-       i2400m->bus_reset = i2400mu_bus_reset;
-       i2400m->bus_bm_retries = I2400M_USB_BOOT_RETRIES;
-       i2400m->bus_bm_cmd_send = i2400mu_bus_bm_cmd_send;
-       i2400m->bus_bm_wait_for_ack = i2400mu_bus_bm_wait_for_ack;
-       i2400m->bus_bm_mac_addr_impaired = 0;
-
-       switch (id->idProduct) {
-       case USB_DEVICE_ID_I6050:
-       case USB_DEVICE_ID_I6050_2:
-       case USB_DEVICE_ID_I6150:
-       case USB_DEVICE_ID_I6150_2:
-       case USB_DEVICE_ID_I6150_3:
-       case USB_DEVICE_ID_I6250:
-               i2400mu->i6050 = 1;
-               break;
-       default:
-               break;
-       }
-
-       if (i2400mu->i6050) {
-               i2400m->bus_fw_names = i2400mu_bus_fw_names_6050;
-               i2400mu->endpoint_cfg.bulk_out = 0;
-               i2400mu->endpoint_cfg.notification = 3;
-               i2400mu->endpoint_cfg.reset_cold = 2;
-               i2400mu->endpoint_cfg.bulk_in = 1;
-       } else {
-               i2400m->bus_fw_names = i2400mu_bus_fw_names_5x50;
-               i2400mu->endpoint_cfg.bulk_out = 0;
-               i2400mu->endpoint_cfg.notification = 1;
-               i2400mu->endpoint_cfg.reset_cold = 2;
-               i2400mu->endpoint_cfg.bulk_in = 3;
-       }
-#ifdef CONFIG_PM
-       iface->needs_remote_wakeup = 1;         /* autosuspend (15s delay) */
-       device_init_wakeup(dev, 1);
-       pm_runtime_set_autosuspend_delay(&usb_dev->dev, 15000);
-       usb_enable_autosuspend(usb_dev);
-#endif
-
-       result = i2400m_setup(i2400m, I2400M_BRI_MAC_REINIT);
-       if (result < 0) {
-               dev_err(dev, "cannot setup device: %d\n", result);
-               goto error_setup;
-       }
-       i2400mu_debugfs_add(i2400mu);
-       return 0;
-
-error_setup:
-       usb_set_intfdata(iface, NULL);
-       usb_put_dev(i2400mu->usb_dev);
-       free_netdev(net_dev);
-error_alloc_netdev:
-       return result;
-}
-
-
-/*
- * Disconnect a i2400m from the system.
- *
- * i2400m_stop() has been called before, so al the rx and tx contexts
- * have been taken down already. Make sure the queue is stopped,
- * unregister netdev and i2400m, free and kill.
- */
-static
-void i2400mu_disconnect(struct usb_interface *iface)
-{
-       struct i2400mu *i2400mu = usb_get_intfdata(iface);
-       struct i2400m *i2400m = &i2400mu->i2400m;
-       struct net_device *net_dev = i2400m->wimax_dev.net_dev;
-       struct device *dev = &iface->dev;
-
-       d_fnstart(3, dev, "(iface %p i2400m %p)\n", iface, i2400m);
-
-       debugfs_remove_recursive(i2400mu->debugfs_dentry);
-       i2400m_release(i2400m);
-       usb_set_intfdata(iface, NULL);
-       usb_put_dev(i2400mu->usb_dev);
-       free_netdev(net_dev);
-       d_fnend(3, dev, "(iface %p i2400m %p) = void\n", iface, i2400m);
-}
-
-
-/*
- * Get the device ready for USB port or system standby and hibernation
- *
- * USB port and system standby are handled the same.
- *
- * When the system hibernates, the USB device is powered down and then
- * up, so we don't really have to do much here, as it will be seen as
- * a reconnect. Still for simplicity we consider this case the same as
- * suspend, so that the device has a chance to do notify the base
- * station (if connected).
- *
- * So at the end, the three cases require common handling.
- *
- * If at the time of this call the device's firmware is not loaded,
- * nothing has to be done. Note we can be "loose" about not reading
- * i2400m->updown under i2400m->init_mutex. If it happens to change
- * inmediately, other parts of the call flow will fail and effectively
- * catch it.
- *
- * If the firmware is loaded, we need to:
- *
- *  - tell the device to go into host interface power save mode, wait
- *    for it to ack
- *
- *    This is quite more interesting than it is; we need to execute a
- *    command, but this time, we don't want the code in usb-{tx,rx}.c
- *    to call the usb_autopm_get/put_interface() barriers as it'd
- *    deadlock, so we need to decrement i2400mu->do_autopm, that acts
- *    as a poor man's semaphore. Ugly, but it works.
- *
- *    As well, the device might refuse going to sleep for whichever
- *    reason. In this case we just fail. For system suspend/hibernate,
- *    we *can't* fail. We check PMSG_IS_AUTO to see if the
- *    suspend call comes from the USB stack or from the system and act
- *    in consequence.
- *
- *  - stop the notification endpoint polling
- */
-static
-int i2400mu_suspend(struct usb_interface *iface, pm_message_t pm_msg)
-{
-       int result = 0;
-       struct device *dev = &iface->dev;
-       struct i2400mu *i2400mu = usb_get_intfdata(iface);
-       unsigned is_autosuspend = 0;
-       struct i2400m *i2400m = &i2400mu->i2400m;
-
-#ifdef CONFIG_PM
-       if (PMSG_IS_AUTO(pm_msg))
-               is_autosuspend = 1;
-#endif
-
-       d_fnstart(3, dev, "(iface %p pm_msg %u)\n", iface, pm_msg.event);
-       rmb();          /* see i2400m->updown's documentation  */
-       if (i2400m->updown == 0)
-               goto no_firmware;
-       if (i2400m->state == I2400M_SS_DATA_PATH_CONNECTED && is_autosuspend) {
-               /* ugh -- the device is connected and this suspend
-                * request is an autosuspend one (not a system standby
-                * / hibernate).
-                *
-                * The only way the device can go to standby is if the
-                * link with the base station is in IDLE mode; that
-                * were the case, we'd be in status
-                * I2400M_SS_CONNECTED_IDLE. But we are not.
-                *
-                * If we *tell* him to go power save now, it'll reset
-                * as a precautionary measure, so if this is an
-                * autosuspend thing, say no and it'll come back
-                * later, when the link is IDLE
-                */
-               result = -EBADF;
-               d_printf(1, dev, "fw up, link up, not-idle, autosuspend: "
-                        "not entering powersave\n");
-               goto error_not_now;
-       }
-       d_printf(1, dev, "fw up: entering powersave\n");
-       atomic_dec(&i2400mu->do_autopm);
-       result = i2400m_cmd_enter_powersave(i2400m);
-       atomic_inc(&i2400mu->do_autopm);
-       if (result < 0 && !is_autosuspend) {
-               /* System suspend, can't fail */
-               dev_err(dev, "failed to suspend, will reset on resume\n");
-               result = 0;
-       }
-       if (result < 0)
-               goto error_enter_powersave;
-       i2400mu_notification_release(i2400mu);
-       d_printf(1, dev, "powersave requested\n");
-error_enter_powersave:
-error_not_now:
-no_firmware:
-       d_fnend(3, dev, "(iface %p pm_msg %u) = %d\n",
-               iface, pm_msg.event, result);
-       return result;
-}
-
-
-static
-int i2400mu_resume(struct usb_interface *iface)
-{
-       int ret = 0;
-       struct device *dev = &iface->dev;
-       struct i2400mu *i2400mu = usb_get_intfdata(iface);
-       struct i2400m *i2400m = &i2400mu->i2400m;
-
-       d_fnstart(3, dev, "(iface %p)\n", iface);
-       rmb();          /* see i2400m->updown's documentation  */
-       if (i2400m->updown == 0) {
-               d_printf(1, dev, "fw was down, no resume needed\n");
-               goto out;
-       }
-       d_printf(1, dev, "fw was up, resuming\n");
-       i2400mu_notification_setup(i2400mu);
-       /* USB has flow control, so we don't need to give it time to
-        * come back; otherwise, we'd use something like a get-state
-        * command... */
-out:
-       d_fnend(3, dev, "(iface %p) = %d\n", iface, ret);
-       return ret;
-}
-
-
-static
-int i2400mu_reset_resume(struct usb_interface *iface)
-{
-       int result;
-       struct device *dev = &iface->dev;
-       struct i2400mu *i2400mu = usb_get_intfdata(iface);
-       struct i2400m *i2400m = &i2400mu->i2400m;
-
-       d_fnstart(3, dev, "(iface %p)\n", iface);
-       result = i2400m_dev_reset_handle(i2400m, "device reset on resume");
-       d_fnend(3, dev, "(iface %p) = %d\n", iface, result);
-       return result < 0 ? result : 0;
-}
-
-
-/*
- * Another driver or user space is triggering a reset on the device
- * which contains the interface passed as an argument. Cease IO and
- * save any device state you need to restore.
- *
- * If you need to allocate memory here, use GFP_NOIO or GFP_ATOMIC, if
- * you are in atomic context.
- */
-static
-int i2400mu_pre_reset(struct usb_interface *iface)
-{
-       struct i2400mu *i2400mu = usb_get_intfdata(iface);
-       return i2400m_pre_reset(&i2400mu->i2400m);
-}
-
-
-/*
- * The reset has completed.  Restore any saved device state and begin
- * using the device again.
- *
- * If you need to allocate memory here, use GFP_NOIO or GFP_ATOMIC, if
- * you are in atomic context.
- */
-static
-int i2400mu_post_reset(struct usb_interface *iface)
-{
-       struct i2400mu *i2400mu = usb_get_intfdata(iface);
-       return i2400m_post_reset(&i2400mu->i2400m);
-}
-
-
-static
-struct usb_device_id i2400mu_id_table[] = {
-       { USB_DEVICE(0x8086, USB_DEVICE_ID_I6050) },
-       { USB_DEVICE(0x8086, USB_DEVICE_ID_I6050_2) },
-       { USB_DEVICE(0x8087, USB_DEVICE_ID_I6150) },
-       { USB_DEVICE(0x8087, USB_DEVICE_ID_I6150_2) },
-       { USB_DEVICE(0x8087, USB_DEVICE_ID_I6150_3) },
-       { USB_DEVICE(0x8086, USB_DEVICE_ID_I6250) },
-       { USB_DEVICE(0x8086, 0x0181) },
-       { USB_DEVICE(0x8086, 0x1403) },
-       { USB_DEVICE(0x8086, 0x1405) },
-       { USB_DEVICE(0x8086, 0x0180) },
-       { USB_DEVICE(0x8086, 0x0182) },
-       { USB_DEVICE(0x8086, 0x1406) },
-       { USB_DEVICE(0x8086, 0x1403) },
-       { },
-};
-MODULE_DEVICE_TABLE(usb, i2400mu_id_table);
-
-
-static
-struct usb_driver i2400mu_driver = {
-       .name = KBUILD_MODNAME,
-       .suspend = i2400mu_suspend,
-       .resume = i2400mu_resume,
-       .reset_resume = i2400mu_reset_resume,
-       .probe = i2400mu_probe,
-       .disconnect = i2400mu_disconnect,
-       .pre_reset = i2400mu_pre_reset,
-       .post_reset = i2400mu_post_reset,
-       .id_table = i2400mu_id_table,
-       .supports_autosuspend = 1,
-};
-
-static
-int __init i2400mu_driver_init(void)
-{
-       d_parse_params(D_LEVEL, D_LEVEL_SIZE, i2400mu_debug_params,
-                      "i2400m_usb.debug");
-       return usb_register(&i2400mu_driver);
-}
-module_init(i2400mu_driver_init);
-
-
-static
-void __exit i2400mu_driver_exit(void)
-{
-       usb_deregister(&i2400mu_driver);
-}
-module_exit(i2400mu_driver_exit);
-
-MODULE_AUTHOR("Intel Corporation <linux-wimax@intel.com>");
-MODULE_DESCRIPTION("Driver for USB based Intel Wireless WiMAX Connection 2400M "
-                  "(5x50 & 6050)");
-MODULE_LICENSE("GPL");
-MODULE_FIRMWARE(I2400MU_FW_FILE_NAME_v1_5);
-MODULE_FIRMWARE(I6050U_FW_FILE_NAME_v1_5);
diff --git a/drivers/staging/wimax/id-table.c b/drivers/staging/wimax/id-table.c
deleted file mode 100644 (file)
index 0e6f4aa..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Linux WiMAX
- * Mappping of generic netlink family IDs to net devices
- *
- * Copyright (C) 2005-2006 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *
- * We assign a single generic netlink family ID to each device (to
- * simplify lookup).
- *
- * We need a way to map family ID to a wimax_dev pointer.
- *
- * The idea is to use a very simple lookup. Using a netlink attribute
- * with (for example) the interface name implies a heavier search over
- * all the network devices; seemed kind of a waste given that we know
- * we are looking for a WiMAX device and that most systems will have
- * just a single WiMAX adapter.
- *
- * We put all the WiMAX devices in the system in a linked list and
- * match the generic link family ID against the list.
- *
- * By using a linked list, the case of a single adapter in the system
- * becomes (almost) no overhead, while still working for many more. If
- * it ever goes beyond two, I'll be surprised.
- */
-#include <linux/device.h>
-#include <net/genetlink.h>
-#include <linux/netdevice.h>
-#include <linux/list.h>
-#include "linux-wimax.h"
-#include "wimax-internal.h"
-
-
-#define D_SUBMODULE id_table
-#include "debug-levels.h"
-
-
-static DEFINE_SPINLOCK(wimax_id_table_lock);
-static struct list_head wimax_id_table = LIST_HEAD_INIT(wimax_id_table);
-
-
-/*
- * wimax_id_table_add - add a gennetlink familiy ID / wimax_dev mapping
- *
- * @wimax_dev: WiMAX device descriptor to associate to the Generic
- *     Netlink family ID.
- *
- * Look for an empty spot in the ID table; if none found, double the
- * table's size and get the first spot.
- */
-void wimax_id_table_add(struct wimax_dev *wimax_dev)
-{
-       d_fnstart(3, NULL, "(wimax_dev %p)\n", wimax_dev);
-       spin_lock(&wimax_id_table_lock);
-       list_add(&wimax_dev->id_table_node, &wimax_id_table);
-       spin_unlock(&wimax_id_table_lock);
-       d_fnend(3, NULL, "(wimax_dev %p)\n", wimax_dev);
-}
-
-
-/*
- * wimax_get_netdev_by_info - lookup a wimax_dev from the gennetlink info
- *
- * The generic netlink family ID has been filled out in the
- * nlmsghdr->nlmsg_type field, so we pull it from there, look it up in
- * the mapping table and reference the wimax_dev.
- *
- * When done, the reference should be dropped with
- * 'dev_put(wimax_dev->net_dev)'.
- */
-struct wimax_dev *wimax_dev_get_by_genl_info(
-       struct genl_info *info, int ifindex)
-{
-       struct wimax_dev *wimax_dev = NULL;
-
-       d_fnstart(3, NULL, "(info %p ifindex %d)\n", info, ifindex);
-       spin_lock(&wimax_id_table_lock);
-       list_for_each_entry(wimax_dev, &wimax_id_table, id_table_node) {
-               if (wimax_dev->net_dev->ifindex == ifindex) {
-                       dev_hold(wimax_dev->net_dev);
-                       goto found;
-               }
-       }
-       wimax_dev = NULL;
-       d_printf(1, NULL, "wimax: no devices found with ifindex %d\n",
-                ifindex);
-found:
-       spin_unlock(&wimax_id_table_lock);
-       d_fnend(3, NULL, "(info %p ifindex %d) = %p\n",
-               info, ifindex, wimax_dev);
-       return wimax_dev;
-}
-
-
-/*
- * wimax_id_table_rm - Remove a gennetlink familiy ID / wimax_dev mapping
- *
- * @id: family ID to remove from the table
- */
-void wimax_id_table_rm(struct wimax_dev *wimax_dev)
-{
-       spin_lock(&wimax_id_table_lock);
-       list_del_init(&wimax_dev->id_table_node);
-       spin_unlock(&wimax_id_table_lock);
-}
-
-
-/*
- * Release the gennetlink family id / mapping table
- *
- * On debug, verify that the table is empty upon removal. We want the
- * code always compiled, to ensure it doesn't bit rot. It will be
- * compiled out if CONFIG_BUG is disabled.
- */
-void wimax_id_table_release(void)
-{
-       struct wimax_dev *wimax_dev;
-
-#ifndef CONFIG_BUG
-       return;
-#endif
-       spin_lock(&wimax_id_table_lock);
-       list_for_each_entry(wimax_dev, &wimax_id_table, id_table_node) {
-               pr_err("BUG: %s wimax_dev %p ifindex %d not cleared\n",
-                      __func__, wimax_dev, wimax_dev->net_dev->ifindex);
-               WARN_ON(1);
-       }
-       spin_unlock(&wimax_id_table_lock);
-}
diff --git a/drivers/staging/wimax/linux-wimax-debug.h b/drivers/staging/wimax/linux-wimax-debug.h
deleted file mode 100644 (file)
index 5b5ec40..0000000
+++ /dev/null
@@ -1,491 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Linux WiMAX
- * Collection of tools to manage debug operations.
- *
- * Copyright (C) 2005-2007 Intel Corporation
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *
- * Don't #include this file directly, read on!
- *
- * EXECUTING DEBUGGING ACTIONS OR NOT
- *
- * The main thing this framework provides is decission power to take a
- * debug action (like printing a message) if the current debug level
- * allows it.
- *
- * The decission power is at two levels: at compile-time (what does
- * not make it is compiled out) and at run-time. The run-time
- * selection is done per-submodule (as they are declared by the user
- * of the framework).
- *
- * A call to d_test(L) (L being the target debug level) returns true
- * if the action should be taken because the current debug levels
- * allow it (both compile and run time).
- *
- * It follows that a call to d_test() that can be determined to be
- * always false at compile time will get the code depending on it
- * compiled out by optimization.
- *
- * DEBUG LEVELS
- *
- * It is up to the caller to define how much a debugging level is.
- *
- * Convention sets 0 as "no debug" (so an action marked as debug level 0
- * will always be taken). The increasing debug levels are used for
- * increased verbosity.
- *
- * USAGE
- *
- * Group the code in modules and submodules inside each module [which
- * in most cases maps to Linux modules and .c files that compose
- * those].
- *
- * For each module, there is:
- *
- *  - a MODULENAME (single word, legal C identifier)
- *
- *  - a debug-levels.h header file that declares the list of
- *    submodules and that is included by all .c files that use
- *    the debugging tools. The file name can be anything.
- *
- *  - some (optional) .c code to manipulate the runtime debug levels
- *    through debugfs.
- *
- * The debug-levels.h file would look like:
- *
- *     #ifndef __debug_levels__h__
- *     #define __debug_levels__h__
- *
- *     #define D_MODULENAME modulename
- *     #define D_MASTER 10
- *
- *     #include "linux-wimax-debug.h"
- *
- *     enum d_module {
- *             D_SUBMODULE_DECLARE(submodule_1),
- *             D_SUBMODULE_DECLARE(submodule_2),
- *             ...
- *             D_SUBMODULE_DECLARE(submodule_N)
- *     };
- *
- *     #endif
- *
- * D_MASTER is the maximum compile-time debug level; any debug actions
- * above this will be out. D_MODULENAME is the module name (legal C
- * identifier), which has to be unique for each module (to avoid
- * namespace collisions during linkage). Note those #defines need to
- * be done before #including debug.h
- *
- * We declare N different submodules whose debug level can be
- * independently controlled during runtime.
- *
- * In a .c file of the module (and only in one of them), define the
- * following code:
- *
- *     struct d_level D_LEVEL[] = {
- *             D_SUBMODULE_DEFINE(submodule_1),
- *             D_SUBMODULE_DEFINE(submodule_2),
- *             ...
- *             D_SUBMODULE_DEFINE(submodule_N),
- *     };
- *     size_t D_LEVEL_SIZE = ARRAY_SIZE(D_LEVEL);
- *
- * Externs for d_level_MODULENAME and d_level_size_MODULENAME are used
- * and declared in this file using the D_LEVEL and D_LEVEL_SIZE macros
- * #defined also in this file.
- *
- * To manipulate from user space the levels, create a debugfs dentry
- * and then register each submodule with:
- *
- *     d_level_register_debugfs("PREFIX_", submodule_X, parent);
- *
- * Where PREFIX_ is a name of your chosing. This will create debugfs
- * file with a single numeric value that can be use to tweak it. To
- * remove the entires, just use debugfs_remove_recursive() on 'parent'.
- *
- * NOTE: remember that even if this will show attached to some
- *     particular instance of a device, the settings are *global*.
- *
- * On each submodule (for example, .c files), the debug infrastructure
- * should be included like this:
- *
- *     #define D_SUBMODULE submodule_x     // matches one in debug-levels.h
- *     #include "debug-levels.h"
- *
- * after #including all your include files.
- *
- * Now you can use the d_*() macros below [d_test(), d_fnstart(),
- * d_fnend(), d_printf(), d_dump()].
- *
- * If their debug level is greater than D_MASTER, they will be
- * compiled out.
- *
- * If their debug level is lower or equal than D_MASTER but greater
- * than the current debug level of their submodule, they'll be
- * ignored.
- *
- * Otherwise, the action will be performed.
- */
-#ifndef __debug__h__
-#define __debug__h__
-
-#include <linux/types.h>
-#include <linux/slab.h>
-
-struct device;
-
-/* Backend stuff */
-
-/*
- * Debug backend: generate a message header from a 'struct device'
- *
- * @head: buffer where to place the header
- * @head_size: length of @head
- * @dev: pointer to device used to generate a header from. If NULL,
- *     an empty ("") header is generated.
- */
-static inline
-void __d_head(char *head, size_t head_size,
-             struct device *dev)
-{
-       if (dev == NULL)
-               head[0] = 0;
-       else if ((unsigned long)dev < 4096) {
-               printk(KERN_ERR "E: Corrupt dev %p\n", dev);
-               WARN_ON(1);
-       } else
-               snprintf(head, head_size, "%s %s: ",
-                        dev_driver_string(dev), dev_name(dev));
-}
-
-
-/*
- * Debug backend: log some message if debugging is enabled
- *
- * @l: intended debug level
- * @tag: tag to prefix the message with
- * @dev: 'struct device' associated to this message
- * @f: printf-like format and arguments
- *
- * Note this is optimized out if it doesn't pass the compile-time
- * check; however, it is *always* compiled. This is useful to make
- * sure the printf-like formats and variables are always checked and
- * they don't get bit rot if you have all the debugging disabled.
- */
-#define _d_printf(l, tag, dev, f, a...)                                        \
-do {                                                                   \
-       char head[64];                                                  \
-       if (!d_test(l))                                                 \
-               break;                                                  \
-       __d_head(head, sizeof(head), dev);                              \
-       printk(KERN_ERR "%s%s%s: " f, head, __func__, tag, ##a);        \
-} while (0)
-
-
-/*
- * CPP syntactic sugar to generate A_B like symbol names when one of
- * the arguments is a preprocessor #define.
- */
-#define __D_PASTE__(varname, modulename) varname##_##modulename
-#define __D_PASTE(varname, modulename) (__D_PASTE__(varname, modulename))
-#define _D_SUBMODULE_INDEX(_name) (D_SUBMODULE_DECLARE(_name))
-
-
-/*
- * Store a submodule's runtime debug level and name
- */
-struct d_level {
-       u8 level;
-       const char *name;
-};
-
-
-/*
- * List of available submodules and their debug levels
- *
- * We call them d_level_MODULENAME and d_level_size_MODULENAME; the
- * macros D_LEVEL and D_LEVEL_SIZE contain the name already for
- * convenience.
- *
- * This array and the size are defined on some .c file that is part of
- * the current module.
- */
-#define D_LEVEL __D_PASTE(d_level, D_MODULENAME)
-#define D_LEVEL_SIZE __D_PASTE(d_level_size, D_MODULENAME)
-
-extern struct d_level D_LEVEL[];
-extern size_t D_LEVEL_SIZE;
-
-
-/*
- * Frontend stuff
- *
- *
- * Stuff you need to declare prior to using the actual "debug" actions
- * (defined below).
- */
-
-#ifndef D_MODULENAME
-#error D_MODULENAME is not defined in your debug-levels.h file
-/**
- * D_MODULE - Name of the current module
- *
- * #define in your module's debug-levels.h, making sure it is
- * unique. This has to be a legal C identifier.
- */
-#define D_MODULENAME undefined_modulename
-#endif
-
-
-#ifndef D_MASTER
-#warning D_MASTER not defined, but debug.h included! [see docs]
-/**
- * D_MASTER - Compile time maximum debug level
- *
- * #define in your debug-levels.h file to the maximum debug level the
- * runtime code will be allowed to have. This allows you to provide a
- * main knob.
- *
- * Anything above that level will be optimized out of the compile.
- *
- * Defaults to zero (no debug code compiled in).
- *
- * Maximum one definition per module (at the debug-levels.h file).
- */
-#define D_MASTER 0
-#endif
-
-#ifndef D_SUBMODULE
-#error D_SUBMODULE not defined, but debug.h included! [see docs]
-/**
- * D_SUBMODULE - Name of the current submodule
- *
- * #define in your submodule .c file before #including debug-levels.h
- * to the name of the current submodule as previously declared and
- * defined with D_SUBMODULE_DECLARE() (in your module's
- * debug-levels.h) and D_SUBMODULE_DEFINE().
- *
- * This is used to provide runtime-control over the debug levels.
- *
- * Maximum one per .c file! Can be shared among different .c files
- * (meaning they belong to the same submodule categorization).
- */
-#define D_SUBMODULE undefined_module
-#endif
-
-
-/**
- * D_SUBMODULE_DECLARE - Declare a submodule for runtime debug level control
- *
- * @_name: name of the submodule, restricted to the chars that make up a
- *     valid C identifier ([a-zA-Z0-9_]).
- *
- * Declare in the module's debug-levels.h header file as:
- *
- * enum d_module {
- *         D_SUBMODULE_DECLARE(submodule_1),
- *         D_SUBMODULE_DECLARE(submodule_2),
- *         D_SUBMODULE_DECLARE(submodule_3),
- * };
- *
- * Some corresponding .c file needs to have a matching
- * D_SUBMODULE_DEFINE().
- */
-#define D_SUBMODULE_DECLARE(_name) __D_SUBMODULE_##_name
-
-
-/**
- * D_SUBMODULE_DEFINE - Define a submodule for runtime debug level control
- *
- * @_name: name of the submodule, restricted to the chars that make up a
- *     valid C identifier ([a-zA-Z0-9_]).
- *
- * Use once per module (in some .c file) as:
- *
- * static
- * struct d_level d_level_SUBMODULENAME[] = {
- *         D_SUBMODULE_DEFINE(submodule_1),
- *         D_SUBMODULE_DEFINE(submodule_2),
- *         D_SUBMODULE_DEFINE(submodule_3),
- * };
- * size_t d_level_size_SUBDMODULENAME = ARRAY_SIZE(d_level_SUBDMODULENAME);
- *
- * Matching D_SUBMODULE_DECLARE()s have to be present in a
- * debug-levels.h header file.
- */
-#define D_SUBMODULE_DEFINE(_name)              \
-[__D_SUBMODULE_##_name] = {                    \
-       .level = 0,                             \
-       .name = #_name                          \
-}
-
-
-
-/* The actual "debug" operations */
-
-
-/**
- * d_test - Returns true if debugging should be enabled
- *
- * @l: intended debug level (unsigned)
- *
- * If the master debug switch is enabled and the current settings are
- * higher or equal to the requested level, then debugging
- * output/actions should be enabled.
- *
- * NOTE:
- *
- * This needs to be coded so that it can be evaluated in compile
- * time; this is why the ugly BUG_ON() is placed in there, so the
- * D_MASTER evaluation compiles all out if it is compile-time false.
- */
-#define d_test(l)                                                      \
-({                                                                     \
-       unsigned __l = l;       /* type enforcer */                     \
-       (D_MASTER) >= __l                                               \
-       && ({                                                           \
-               BUG_ON(_D_SUBMODULE_INDEX(D_SUBMODULE) >= D_LEVEL_SIZE);\
-               D_LEVEL[_D_SUBMODULE_INDEX(D_SUBMODULE)].level >= __l;  \
-       });                                                             \
-})
-
-
-/**
- * d_fnstart - log message at function start if debugging enabled
- *
- * @l: intended debug level
- * @_dev: 'struct device' pointer, NULL if none (for context)
- * @f: printf-like format and arguments
- */
-#define d_fnstart(l, _dev, f, a...) _d_printf(l, " FNSTART", _dev, f, ## a)
-
-
-/**
- * d_fnend - log message at function end if debugging enabled
- *
- * @l: intended debug level
- * @_dev: 'struct device' pointer, NULL if none (for context)
- * @f: printf-like format and arguments
- */
-#define d_fnend(l, _dev, f, a...) _d_printf(l, " FNEND", _dev, f, ## a)
-
-
-/**
- * d_printf - log message if debugging enabled
- *
- * @l: intended debug level
- * @_dev: 'struct device' pointer, NULL if none (for context)
- * @f: printf-like format and arguments
- */
-#define d_printf(l, _dev, f, a...) _d_printf(l, "", _dev, f, ## a)
-
-
-/**
- * d_dump - log buffer hex dump if debugging enabled
- *
- * @l: intended debug level
- * @_dev: 'struct device' pointer, NULL if none (for context)
- * @f: printf-like format and arguments
- */
-#define d_dump(l, dev, ptr, size)                      \
-do {                                                   \
-       char head[64];                                  \
-       if (!d_test(l))                                 \
-               break;                                  \
-       __d_head(head, sizeof(head), dev);              \
-       print_hex_dump(KERN_ERR, head, 0, 16, 1,        \
-                      ((void *) ptr), (size), 0);      \
-} while (0)
-
-
-/**
- * Export a submodule's debug level over debugfs as PREFIXSUBMODULE
- *
- * @prefix: string to prefix the name with
- * @submodule: name of submodule (not a string, just the name)
- * @dentry: debugfs parent dentry
- *
- * For removing, just use debugfs_remove_recursive() on the parent.
- */
-#define d_level_register_debugfs(prefix, name, parent)                 \
-({                                                                     \
-       debugfs_create_u8(                                              \
-               prefix #name, 0600, parent,                             \
-               &(D_LEVEL[__D_SUBMODULE_ ## name].level));              \
-})
-
-
-static inline
-void d_submodule_set(struct d_level *d_level, size_t d_level_size,
-                    const char *submodule, u8 level, const char *tag)
-{
-       struct d_level *itr, *top;
-       int index = -1;
-
-       for (itr = d_level, top = itr + d_level_size; itr < top; itr++) {
-               index++;
-               if (itr->name == NULL) {
-                       printk(KERN_ERR "%s: itr->name NULL?? (%p, #%d)\n",
-                              tag, itr, index);
-                       continue;
-               }
-               if (!strcmp(itr->name, submodule)) {
-                       itr->level = level;
-                       return;
-               }
-       }
-       printk(KERN_ERR "%s: unknown submodule %s\n", tag, submodule);
-}
-
-
-/**
- * d_parse_params - Parse a string with debug parameters from the
- * command line
- *
- * @d_level: level structure (D_LEVEL)
- * @d_level_size: number of items in the level structure
- *     (D_LEVEL_SIZE).
- * @_params: string with the parameters; this is a space (not tab!)
- *     separated list of NAME:VALUE, where value is the debug level
- *     and NAME is the name of the submodule.
- * @tag: string for error messages (example: MODULE.ARGNAME).
- */
-static inline
-void d_parse_params(struct d_level *d_level, size_t d_level_size,
-                   const char *_params, const char *tag)
-{
-       char submodule[130], *params, *params_orig, *token, *colon;
-       unsigned level, tokens;
-
-       if (_params == NULL)
-               return;
-       params_orig = kstrdup(_params, GFP_KERNEL);
-       params = params_orig;
-       while (1) {
-               token = strsep(&params, " ");
-               if (token == NULL)
-                       break;
-               if (*token == '\0')     /* eat joint spaces */
-                       continue;
-               /* kernel's sscanf %s eats until whitespace, so we
-                * replace : by \n so it doesn't get eaten later by
-                * strsep */
-               colon = strchr(token, ':');
-               if (colon != NULL)
-                       *colon = '\n';
-               tokens = sscanf(token, "%s\n%u", submodule, &level);
-               if (colon != NULL)
-                       *colon = ':';   /* set back, for error messages */
-               if (tokens == 2)
-                       d_submodule_set(d_level, d_level_size,
-                                       submodule, level, tag);
-               else
-                       printk(KERN_ERR "%s: can't parse '%s' as a "
-                              "SUBMODULE:LEVEL (%d tokens)\n",
-                              tag, token, tokens);
-       }
-       kfree(params_orig);
-}
-
-#endif /* #ifndef __debug__h__ */
diff --git a/drivers/staging/wimax/linux-wimax.h b/drivers/staging/wimax/linux-wimax.h
deleted file mode 100644 (file)
index 9f6b77a..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * Linux WiMax
- * API for user space
- *
- *
- * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   * Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in
- *     the documentation and/or other materials provided with the
- *     distribution.
- *   * Neither the name of Intel Corporation nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *
- * Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *  - Initial implementation
- *
- *
- * This file declares the user/kernel protocol that is spoken over
- * Generic Netlink, as well as any type declaration that is to be used
- * by kernel and user space.
- *
- * It is intended for user space to clone it verbatim to use it as a
- * primary reference for definitions.
- *
- * Stuff intended for kernel usage as well as full protocol and stack
- * documentation is rooted in include/net/wimax.h.
- */
-
-#ifndef __LINUX__WIMAX_H__
-#define __LINUX__WIMAX_H__
-
-#include <linux/types.h>
-
-enum {
-       /**
-        * Version of the interface (unsigned decimal, MMm, max 25.5)
-        * M - Major: change if removing or modifying an existing call.
-        * m - minor: change when adding a new call
-        */
-       WIMAX_GNL_VERSION = 01,
-       /* Generic NetLink attributes */
-       WIMAX_GNL_ATTR_INVALID = 0x00,
-       WIMAX_GNL_ATTR_MAX = 10,
-};
-
-
-/*
- * Generic NetLink operations
- *
- * Most of these map to an API call; _OP_ stands for operation, _RP_
- * for reply and _RE_ for report (aka: signal).
- */
-enum {
-       WIMAX_GNL_OP_MSG_FROM_USER,     /* User to kernel message */
-       WIMAX_GNL_OP_MSG_TO_USER,       /* Kernel to user message */
-       WIMAX_GNL_OP_RFKILL,    /* Run wimax_rfkill() */
-       WIMAX_GNL_OP_RESET,     /* Run wimax_rfkill() */
-       WIMAX_GNL_RE_STATE_CHANGE,      /* Report: status change */
-       WIMAX_GNL_OP_STATE_GET,         /* Request for current state */
-};
-
-
-/* Message from user / to user */
-enum {
-       WIMAX_GNL_MSG_IFIDX = 1,
-       WIMAX_GNL_MSG_PIPE_NAME,
-       WIMAX_GNL_MSG_DATA,
-};
-
-
-/*
- * wimax_rfkill()
- *
- * The state of the radio (ON/OFF) is mapped to the rfkill subsystem's
- * switch state (DISABLED/ENABLED).
- */
-enum wimax_rf_state {
-       WIMAX_RF_OFF = 0,       /* Radio is off, rfkill on/enabled */
-       WIMAX_RF_ON = 1,        /* Radio is on, rfkill off/disabled */
-       WIMAX_RF_QUERY = 2,
-};
-
-/* Attributes */
-enum {
-       WIMAX_GNL_RFKILL_IFIDX = 1,
-       WIMAX_GNL_RFKILL_STATE,
-};
-
-
-/* Attributes for wimax_reset() */
-enum {
-       WIMAX_GNL_RESET_IFIDX = 1,
-};
-
-/* Attributes for wimax_state_get() */
-enum {
-       WIMAX_GNL_STGET_IFIDX = 1,
-};
-
-/*
- * Attributes for the Report State Change
- *
- * For now we just have the old and new states; new attributes might
- * be added later on.
- */
-enum {
-       WIMAX_GNL_STCH_IFIDX = 1,
-       WIMAX_GNL_STCH_STATE_OLD,
-       WIMAX_GNL_STCH_STATE_NEW,
-};
-
-
-/**
- * enum wimax_st - The different states of a WiMAX device
- * @__WIMAX_ST_NULL: The device structure has been allocated and zeroed,
- *     but still wimax_dev_add() hasn't been called. There is no state.
- *
- * @WIMAX_ST_DOWN: The device has been registered with the WiMAX and
- *     networking stacks, but it is not initialized (normally that is
- *     done with 'ifconfig DEV up' [or equivalent], which can upload
- *     firmware and enable communications with the device).
- *     In this state, the device is powered down and using as less
- *     power as possible.
- *     This state is the default after a call to wimax_dev_add(). It
- *     is ok to have drivers move directly to %WIMAX_ST_UNINITIALIZED
- *     or %WIMAX_ST_RADIO_OFF in _probe() after the call to
- *     wimax_dev_add().
- *     It is recommended that the driver leaves this state when
- *     calling 'ifconfig DEV up' and enters it back on 'ifconfig DEV
- *     down'.
- *
- * @__WIMAX_ST_QUIESCING: The device is being torn down, so no API
- *     operations are allowed to proceed except the ones needed to
- *     complete the device clean up process.
- *
- * @WIMAX_ST_UNINITIALIZED: [optional] Communication with the device
- *     is setup, but the device still requires some configuration
- *     before being operational.
- *     Some WiMAX API calls might work.
- *
- * @WIMAX_ST_RADIO_OFF: The device is fully up; radio is off (wether
- *     by hardware or software switches).
- *     It is recommended to always leave the device in this state
- *     after initialization.
- *
- * @WIMAX_ST_READY: The device is fully up and radio is on.
- *
- * @WIMAX_ST_SCANNING: [optional] The device has been instructed to
- *     scan. In this state, the device cannot be actively connected to
- *     a network.
- *
- * @WIMAX_ST_CONNECTING: The device is connecting to a network. This
- *     state exists because in some devices, the connect process can
- *     include a number of negotiations between user space, kernel
- *     space and the device. User space needs to know what the device
- *     is doing. If the connect sequence in a device is atomic and
- *     fast, the device can transition directly to CONNECTED
- *
- * @WIMAX_ST_CONNECTED: The device is connected to a network.
- *
- * @__WIMAX_ST_INVALID: This is an invalid state used to mark the
- *     maximum numeric value of states.
- *
- * Description:
- *
- * Transitions from one state to another one are atomic and can only
- * be caused in kernel space with wimax_state_change(). To read the
- * state, use wimax_state_get().
- *
- * States starting with __ are internal and shall not be used or
- * referred to by drivers or userspace. They look ugly, but that's the
- * point -- if any use is made non-internal to the stack, it is easier
- * to catch on review.
- *
- * All API operations [with well defined exceptions] will take the
- * device mutex before starting and then check the state. If the state
- * is %__WIMAX_ST_NULL, %WIMAX_ST_DOWN, %WIMAX_ST_UNINITIALIZED or
- * %__WIMAX_ST_QUIESCING, it will drop the lock and quit with
- * -%EINVAL, -%ENOMEDIUM, -%ENOTCONN or -%ESHUTDOWN.
- *
- * The order of the definitions is important, so we can do numerical
- * comparisons (eg: < %WIMAX_ST_RADIO_OFF means the device is not ready
- * to operate).
- */
-/*
- * The allowed state transitions are described in the table below
- * (states in rows can go to states in columns where there is an X):
- *
- *                                  UNINI   RADIO READY SCAN CONNEC CONNEC
- *             NULL DOWN QUIESCING TIALIZED  OFF        NING  TING   TED
- * NULL         -    x
- * DOWN              -      x        x       x
- * QUIESCING         x      -
- * UNINITIALIZED            x        -       x
- * RADIO_OFF                x                -     x
- * READY                    x                x     -     x     x      x
- * SCANNING                 x                x     x     -     x      x
- * CONNECTING               x                x     x     x     -      x
- * CONNECTED                x                x     x                  -
- *
- * This table not available in kernel-doc because the formatting messes it up.
- */
- enum wimax_st {
-       __WIMAX_ST_NULL = 0,
-       WIMAX_ST_DOWN,
-       __WIMAX_ST_QUIESCING,
-       WIMAX_ST_UNINITIALIZED,
-       WIMAX_ST_RADIO_OFF,
-       WIMAX_ST_READY,
-       WIMAX_ST_SCANNING,
-       WIMAX_ST_CONNECTING,
-       WIMAX_ST_CONNECTED,
-       __WIMAX_ST_INVALID                      /* Always keep last */
-};
-
-
-#endif /* #ifndef __LINUX__WIMAX_H__ */
diff --git a/drivers/staging/wimax/net-wimax.h b/drivers/staging/wimax/net-wimax.h
deleted file mode 100644 (file)
index f578e34..0000000
+++ /dev/null
@@ -1,503 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Linux WiMAX
- * Kernel space API for accessing WiMAX devices
- *
- * Copyright (C) 2007-2008 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *
- * The WiMAX stack provides an API for controlling and managing the
- * system's WiMAX devices. This API affects the control plane; the
- * data plane is accessed via the network stack (netdev).
- *
- * Parts of the WiMAX stack API and notifications are exported to
- * user space via Generic Netlink. In user space, libwimax (part of
- * the wimax-tools package) provides a shim layer for accessing those
- * calls.
- *
- * The API is standarized for all WiMAX devices and different drivers
- * implement the backend support for it. However, device-specific
- * messaging pipes are provided that can be used to issue commands and
- * receive notifications in free form.
- *
- * Currently the messaging pipes are the only means of control as it
- * is not known (due to the lack of more devices in the market) what
- * will be a good abstraction layer. Expect this to change as more
- * devices show in the market. This API is designed to be growable in
- * order to address this problem.
- *
- * USAGE
- *
- * Embed a `struct wimax_dev` at the beginning of the device's
- * private structure, initialize and register it. For details, see
- * `struct wimax_dev`s documentation.
- *
- * Once this is done, wimax-tools's libwimaxll can be used to
- * communicate with the driver from user space. You user space
- * application does not have to forcibily use libwimaxll and can talk
- * the generic netlink protocol directly if desired.
- *
- * Remember this is a very low level API that will to provide all of
- * WiMAX features. Other daemons and services running in user space
- * are the expected clients of it. They offer a higher level API that
- * applications should use (an example of this is the Intel's WiMAX
- * Network Service for the i2400m).
- *
- * DESIGN
- *
- * Although not set on final stone, this very basic interface is
- * mostly completed. Remember this is meant to grow as new common
- * operations are decided upon. New operations will be added to the
- * interface, intent being on keeping backwards compatibility as much
- * as possible.
- *
- * This layer implements a set of calls to control a WiMAX device,
- * exposing a frontend to the rest of the kernel and user space (via
- * generic netlink) and a backend implementation in the driver through
- * function pointers.
- *
- * WiMAX devices have a state, and a kernel-only API allows the
- * drivers to manipulate that state. State transitions are atomic, and
- * only some of them are allowed (see `enum wimax_st`).
- *
- * Most API calls will set the state automatically; in most cases
- * drivers have to only report state changes due to external
- * conditions.
- *
- * All API operations are 'atomic', serialized through a mutex in the
- * `struct wimax_dev`.
- *
- * EXPORTING TO USER SPACE THROUGH GENERIC NETLINK
- *
- * The API is exported to user space using generic netlink (other
- * methods can be added as needed).
- *
- * There is a Generic Netlink Family named "WiMAX", where interfaces
- * supporting the WiMAX interface receive commands and broadcast their
- * signals over a multicast group named "msg".
- *
- * Mapping to the source/destination interface is done by an interface
- * index attribute.
- *
- * For user-to-kernel traffic (commands) we use a function call
- * marshalling mechanism, where a message X with attributes A, B, C
- * sent from user space to kernel space means executing the WiMAX API
- * call wimax_X(A, B, C), sending the results back as a message.
- *
- * Kernel-to-user (notifications or signals) communication is sent
- * over multicast groups. This allows to have multiple applications
- * monitoring them.
- *
- * Each command/signal gets assigned it's own attribute policy. This
- * way the validator will verify that all the attributes in there are
- * only the ones that should be for each command/signal. Thing of an
- * attribute mapping to a type+argumentname for each command/signal.
- *
- * If we had a single policy for *all* commands/signals, after running
- * the validator we'd have to check "does this attribute belong in
- * here"?  for each one. It can be done manually, but it's just easier
- * to have the validator do that job with multiple policies. As well,
- * it makes it easier to later expand each command/signal signature
- * without affecting others and keeping the namespace more or less
- * sane. Not that it is too complicated, but it makes it even easier.
- *
- * No state information is maintained in the kernel for each user
- * space connection (the connection is stateless).
- *
- * TESTING FOR THE INTERFACE AND VERSIONING
- *
- * If network interface X is a WiMAX device, there will be a Generic
- * Netlink family named "WiMAX X" and the device will present a
- * "wimax" directory in it's network sysfs directory
- * (/sys/class/net/DEVICE/wimax) [used by HAL].
- *
- * The inexistence of any of these means the device does not support
- * this WiMAX API.
- *
- * By querying the generic netlink controller, versioning information
- * and the multicast groups available can be found. Applications using
- * the interface can either rely on that or use the generic netlink
- * controller to figure out which generic netlink commands/signals are
- * supported.
- *
- * NOTE: this versioning is a last resort to avoid hard
- *    incompatibilities. It is the intention of the design of this
- *    stack not to introduce backward incompatible changes.
- *
- * The version code has to fit in one byte (restrictions imposed by
- * generic netlink); we use `version / 10` for the major version and
- * `version % 10` for the minor. This gives 9 minors for each major
- * and 25 majors.
- *
- * The version change protocol is as follow:
- *
- * - Major versions: needs to be increased if an existing message/API
- *   call is changed or removed. Doesn't need to be changed if a new
- *   message is added.
- *
- * - Minor version: needs to be increased if new messages/API calls are
- *   being added or some other consideration that doesn't impact the
- *   user-kernel interface too much (like some kind of bug fix) and
- *   that is kind of left up in the air to common sense.
- *
- * User space code should not try to work if the major version it was
- * compiled for differs from what the kernel offers. As well, if the
- * minor version of the kernel interface is lower than the one user
- * space is expecting (the one it was compiled for), the kernel
- * might be missing API calls; user space shall be ready to handle
- * said condition. Use the generic netlink controller operations to
- * find which ones are supported and which not.
- *
- * libwimaxll:wimaxll_open() takes care of checking versions.
- *
- * THE OPERATIONS:
- *
- * Each operation is defined in its on file (drivers/net/wimax/op-*.c)
- * for clarity. The parts needed for an operation are:
- *
- *  - a function pointer in `struct wimax_dev`: optional, as the
- *    operation might be implemented by the stack and not by the
- *    driver.
- *
- *    All function pointers are named wimax_dev->op_*(), and drivers
- *    must implement them except where noted otherwise.
- *
- *  - When exported to user space, a `struct nla_policy` to define the
- *    attributes of the generic netlink command and a `struct genl_ops`
- *    to define the operation.
- *
- * All the declarations for the operation codes (WIMAX_GNL_OP_<NAME>)
- * and generic netlink attributes (WIMAX_GNL_<NAME>_*) are declared in
- * include/linux/wimax.h; this file is intended to be cloned by user
- * space to gain access to those declarations.
- *
- * A few caveats to remember:
- *
- *  - Need to define attribute numbers starting in 1; otherwise it
- *    fails.
- *
- *  - the `struct genl_family` requires a maximum attribute id; when
- *    defining the `struct nla_policy` for each message, it has to have
- *    an array size of WIMAX_GNL_ATTR_MAX+1.
- *
- * The op_*() function pointers will not be called if the wimax_dev is
- * in a state <= %WIMAX_ST_UNINITIALIZED. The exception is:
- *
- * - op_reset: can be called at any time after wimax_dev_add() has
- *   been called.
- *
- * THE PIPE INTERFACE:
- *
- * This interface is kept intentionally simple. The driver can send
- * and receive free-form messages to/from user space through a
- * pipe. See drivers/net/wimax/op-msg.c for details.
- *
- * The kernel-to-user messages are sent with
- * wimax_msg(). user-to-kernel messages are delivered via
- * wimax_dev->op_msg_from_user().
- *
- * RFKILL:
- *
- * RFKILL support is built into the wimax_dev layer; the driver just
- * needs to call wimax_report_rfkill_{hw,sw}() to inform of changes in
- * the hardware or software RF kill switches. When the stack wants to
- * turn the radio off, it will call wimax_dev->op_rfkill_sw_toggle(),
- * which the driver implements.
- *
- * User space can set the software RF Kill switch by calling
- * wimax_rfkill().
- *
- * The code for now only supports devices that don't require polling;
- * If the device needs to be polled, create a self-rearming delayed
- * work struct for polling or look into adding polled support to the
- * WiMAX stack.
- *
- * When initializing the hardware (_probe), after calling
- * wimax_dev_add(), query the device for it's RF Kill switches status
- * and feed it back to the WiMAX stack using
- * wimax_report_rfkill_{hw,sw}(). If any switch is missing, always
- * report it as ON.
- *
- * NOTE: the wimax stack uses an inverted terminology to that of the
- * RFKILL subsystem:
- *
- *  - ON: radio is ON, RFKILL is DISABLED or OFF.
- *  - OFF: radio is OFF, RFKILL is ENABLED or ON.
- *
- * MISCELLANEOUS OPS:
- *
- * wimax_reset() can be used to reset the device to power on state; by
- * default it issues a warm reset that maintains the same device
- * node. If that is not possible, it falls back to a cold reset
- * (device reconnect). The driver implements the backend to this
- * through wimax_dev->op_reset().
- */
-
-#ifndef __NET__WIMAX_H__
-#define __NET__WIMAX_H__
-
-#include "linux-wimax.h"
-#include <net/genetlink.h>
-#include <linux/netdevice.h>
-
-struct net_device;
-struct genl_info;
-struct wimax_dev;
-
-/**
- * struct wimax_dev - Generic WiMAX device
- *
- * @net_dev: [fill] Pointer to the &struct net_device this WiMAX
- *     device implements.
- *
- * @op_msg_from_user: [fill] Driver-specific operation to
- *     handle a raw message from user space to the driver. The
- *     driver can send messages to user space using with
- *     wimax_msg_to_user().
- *
- * @op_rfkill_sw_toggle: [fill] Driver-specific operation to act on
- *     userspace (or any other agent) requesting the WiMAX device to
- *     change the RF Kill software switch (WIMAX_RF_ON or
- *     WIMAX_RF_OFF).
- *     If such hardware support is not present, it is assumed the
- *     radio cannot be switched off and it is always on (and the stack
- *     will error out when trying to switch it off). In such case,
- *     this function pointer can be left as NULL.
- *
- * @op_reset: [fill] Driver specific operation to reset the
- *     device.
- *     This operation should always attempt first a warm reset that
- *     does not disconnect the device from the bus and return 0.
- *     If that fails, it should resort to some sort of cold or bus
- *     reset (even if it implies a bus disconnection and device
- *     disappearance). In that case, -ENODEV should be returned to
- *     indicate the device is gone.
- *     This operation has to be synchronous, and return only when the
- *     reset is complete. In case of having had to resort to bus/cold
- *     reset implying a device disconnection, the call is allowed to
- *     return immediately.
- *     NOTE: wimax_dev->mutex is NOT locked when this op is being
- *     called; however, wimax_dev->mutex_reset IS locked to ensure
- *     serialization of calls to wimax_reset().
- *     See wimax_reset()'s documentation.
- *
- * @name: [fill] A way to identify this device. We need to register a
- *     name with many subsystems (rfkill, workqueue creation, etc).
- *     We can't use the network device name as that
- *     might change and in some instances we don't know it yet (until
- *     we don't call register_netdev()). So we generate an unique one
- *     using the driver name and device bus id, place it here and use
- *     it across the board. Recommended naming:
- *     DRIVERNAME-BUSNAME:BUSID (dev->bus->name, dev->bus_id).
- *
- * @id_table_node: [private] link to the list of wimax devices kept by
- *     id-table.c. Protected by it's own spinlock.
- *
- * @mutex: [private] Serializes all concurrent access and execution of
- *     operations.
- *
- * @mutex_reset: [private] Serializes reset operations. Needs to be a
- *     different mutex because as part of the reset operation, the
- *     driver has to call back into the stack to do things such as
- *     state change, that require wimax_dev->mutex.
- *
- * @state: [private] Current state of the WiMAX device.
- *
- * @rfkill: [private] integration into the RF-Kill infrastructure.
- *
- * @rf_sw: [private] State of the software radio switch (OFF/ON)
- *
- * @rf_hw: [private] State of the hardware radio switch (OFF/ON)
- *
- * @debugfs_dentry: [private] Used to hook up a debugfs entry. This
- *     shows up in the debugfs root as wimax\:DEVICENAME.
- *
- * Description:
- * This structure defines a common interface to access all WiMAX
- * devices from different vendors and provides a common API as well as
- * a free-form device-specific messaging channel.
- *
- * Usage:
- *  1. Embed a &struct wimax_dev at *the beginning* the network
- *     device structure so that netdev_priv() points to it.
- *
- *  2. memset() it to zero
- *
- *  3. Initialize with wimax_dev_init(). This will leave the WiMAX
- *     device in the %__WIMAX_ST_NULL state.
- *
- *  4. Fill all the fields marked with [fill]; once called
- *     wimax_dev_add(), those fields CANNOT be modified.
- *
- *  5. Call wimax_dev_add() *after* registering the network
- *     device. This will leave the WiMAX device in the %WIMAX_ST_DOWN
- *     state.
- *     Protect the driver's net_device->open() against succeeding if
- *     the wimax device state is lower than %WIMAX_ST_DOWN.
- *
- *  6. Select when the device is going to be turned on/initialized;
- *     for example, it could be initialized on 'ifconfig up' (when the
- *     netdev op 'open()' is called on the driver).
- *
- * When the device is initialized (at `ifconfig up` time, or right
- * after calling wimax_dev_add() from _probe(), make sure the
- * following steps are taken
- *
- *  a. Move the device to %WIMAX_ST_UNINITIALIZED. This is needed so
- *     some API calls that shouldn't work until the device is ready
- *     can be blocked.
- *
- *  b. Initialize the device. Make sure to turn the SW radio switch
- *     off and move the device to state %WIMAX_ST_RADIO_OFF when
- *     done. When just initialized, a device should be left in RADIO
- *     OFF state until user space devices to turn it on.
- *
- *  c. Query the device for the state of the hardware rfkill switch
- *     and call wimax_rfkill_report_hw() and wimax_rfkill_report_sw()
- *     as needed. See below.
- *
- * wimax_dev_rm() undoes before unregistering the network device. Once
- * wimax_dev_add() is called, the driver can get called on the
- * wimax_dev->op_* function pointers
- *
- * CONCURRENCY:
- *
- * The stack provides a mutex for each device that will disallow API
- * calls happening concurrently; thus, op calls into the driver
- * through the wimax_dev->op*() function pointers will always be
- * serialized and *never* concurrent.
- *
- * For locking, take wimax_dev->mutex is taken; (most) operations in
- * the API have to check for wimax_dev_is_ready() to return 0 before
- * continuing (this is done internally).
- *
- * REFERENCE COUNTING:
- *
- * The WiMAX device is reference counted by the associated network
- * device. The only operation that can be used to reference the device
- * is wimax_dev_get_by_genl_info(), and the reference it acquires has
- * to be released with dev_put(wimax_dev->net_dev).
- *
- * RFKILL:
- *
- * At startup, both HW and SW radio switchess are assumed to be off.
- *
- * At initialization time [after calling wimax_dev_add()], have the
- * driver query the device for the status of the software and hardware
- * RF kill switches and call wimax_report_rfkill_hw() and
- * wimax_rfkill_report_sw() to indicate their state. If any is
- * missing, just call it to indicate it is ON (radio always on).
- *
- * Whenever the driver detects a change in the state of the RF kill
- * switches, it should call wimax_report_rfkill_hw() or
- * wimax_report_rfkill_sw() to report it to the stack.
- */
-struct wimax_dev {
-       struct net_device *net_dev;
-       struct list_head id_table_node;
-       struct mutex mutex;             /* Protects all members and API calls */
-       struct mutex mutex_reset;
-       enum wimax_st state;
-
-       int (*op_msg_from_user)(struct wimax_dev *wimax_dev,
-                               const char *,
-                               const void *, size_t,
-                               const struct genl_info *info);
-       int (*op_rfkill_sw_toggle)(struct wimax_dev *wimax_dev,
-                                  enum wimax_rf_state);
-       int (*op_reset)(struct wimax_dev *wimax_dev);
-
-       struct rfkill *rfkill;
-       unsigned int rf_hw;
-       unsigned int rf_sw;
-       char name[32];
-
-       struct dentry *debugfs_dentry;
-};
-
-
-
-/*
- * WiMAX stack public API for device drivers
- * -----------------------------------------
- *
- * These functions are not exported to user space.
- */
-void wimax_dev_init(struct wimax_dev *);
-int wimax_dev_add(struct wimax_dev *, struct net_device *);
-void wimax_dev_rm(struct wimax_dev *);
-
-static inline
-struct wimax_dev *net_dev_to_wimax(struct net_device *net_dev)
-{
-       return netdev_priv(net_dev);
-}
-
-static inline
-struct device *wimax_dev_to_dev(struct wimax_dev *wimax_dev)
-{
-       return wimax_dev->net_dev->dev.parent;
-}
-
-void wimax_state_change(struct wimax_dev *, enum wimax_st);
-enum wimax_st wimax_state_get(struct wimax_dev *);
-
-/*
- * Radio Switch state reporting.
- *
- * enum wimax_rf_state is declared in linux/wimax.h so the exports
- * to user space can use it.
- */
-void wimax_report_rfkill_hw(struct wimax_dev *, enum wimax_rf_state);
-void wimax_report_rfkill_sw(struct wimax_dev *, enum wimax_rf_state);
-
-
-/*
- * Free-form messaging to/from user space
- *
- * Sending a message:
- *
- *   wimax_msg(wimax_dev, pipe_name, buf, buf_size, GFP_KERNEL);
- *
- * Broken up:
- *
- *   skb = wimax_msg_alloc(wimax_dev, pipe_name, buf_size, GFP_KERNEL);
- *   ...fill up skb...
- *   wimax_msg_send(wimax_dev, pipe_name, skb);
- *
- * Be sure not to modify skb->data in the middle (ie: don't use
- * skb_push()/skb_pull()/skb_reserve() on the skb).
- *
- * "pipe_name" is any string, that can be interpreted as the name of
- * the pipe or recipient; the interpretation of it is driver
- * specific, so the recipient can multiplex it as wished. It can be
- * NULL, it won't be used - an example is using a "diagnostics" tag to
- * send diagnostics information that a device-specific diagnostics
- * tool would be interested in.
- */
-struct sk_buff *wimax_msg_alloc(struct wimax_dev *, const char *, const void *,
-                               size_t, gfp_t);
-int wimax_msg_send(struct wimax_dev *, struct sk_buff *);
-int wimax_msg(struct wimax_dev *, const char *, const void *, size_t, gfp_t);
-
-const void *wimax_msg_data_len(struct sk_buff *, size_t *);
-const void *wimax_msg_data(struct sk_buff *);
-ssize_t wimax_msg_len(struct sk_buff *);
-
-
-/*
- * WiMAX stack user space API
- * --------------------------
- *
- * This API is what gets exported to user space for general
- * operations. As well, they can be called from within the kernel,
- * (with a properly referenced `struct wimax_dev`).
- *
- * Properly referenced means: the 'struct net_device' that embeds the
- * device's control structure and (as such) the 'struct wimax_dev' is
- * referenced by the caller.
- */
-int wimax_rfkill(struct wimax_dev *, enum wimax_rf_state);
-int wimax_reset(struct wimax_dev *);
-
-#endif /* #ifndef __NET__WIMAX_H__ */
diff --git a/drivers/staging/wimax/op-msg.c b/drivers/staging/wimax/op-msg.c
deleted file mode 100644 (file)
index e20ac7d..0000000
+++ /dev/null
@@ -1,391 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Linux WiMAX
- * Generic messaging interface between userspace and driver/device
- *
- * Copyright (C) 2007-2008 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *
- * This implements a direct communication channel between user space and
- * the driver/device, by which free form messages can be sent back and
- * forth.
- *
- * This is intended for device-specific features, vendor quirks, etc.
- *
- * See include/net/wimax.h
- *
- * GENERIC NETLINK ENCODING AND CAPACITY
- *
- * A destination "pipe name" is added to each message; it is up to the
- * drivers to assign or use those names (if using them at all).
- *
- * Messages are encoded as a binary netlink attribute using nla_put()
- * using type NLA_UNSPEC (as some versions of libnl still in
- * deployment don't yet understand NLA_BINARY).
- *
- * The maximum capacity of this transport is PAGESIZE per message (so
- * the actual payload will be bit smaller depending on the
- * netlink/generic netlink attributes and headers).
- *
- * RECEPTION OF MESSAGES
- *
- * When a message is received from user space, it is passed verbatim
- * to the driver calling wimax_dev->op_msg_from_user(). The return
- * value from this function is passed back to user space as an ack
- * over the generic netlink protocol.
- *
- * The stack doesn't do any processing or interpretation of these
- * messages.
- *
- * SENDING MESSAGES
- *
- * Messages can be sent with wimax_msg().
- *
- * If the message delivery needs to happen on a different context to
- * that of its creation, wimax_msg_alloc() can be used to get a
- * pointer to the message that can be delivered later on with
- * wimax_msg_send().
- *
- * ROADMAP
- *
- * wimax_gnl_doit_msg_from_user()    Process a message from user space
- *   wimax_dev_get_by_genl_info()
- *   wimax_dev->op_msg_from_user()   Delivery of message to the driver
- *
- * wimax_msg()                       Send a message to user space
- *   wimax_msg_alloc()
- *   wimax_msg_send()
- */
-#include <linux/device.h>
-#include <linux/slab.h>
-#include <net/genetlink.h>
-#include <linux/netdevice.h>
-#include "linux-wimax.h"
-#include <linux/security.h>
-#include <linux/export.h>
-#include "wimax-internal.h"
-
-
-#define D_SUBMODULE op_msg
-#include "debug-levels.h"
-
-
-/**
- * wimax_msg_alloc - Create a new skb for sending a message to userspace
- *
- * @wimax_dev: WiMAX device descriptor
- * @pipe_name: "named pipe" the message will be sent to
- * @msg: pointer to the message data to send
- * @size: size of the message to send (in bytes), including the header.
- * @gfp_flags: flags for memory allocation.
- *
- * Returns: %0 if ok, negative errno code on error
- *
- * Description:
- *
- * Allocates an skb that will contain the message to send to user
- * space over the messaging pipe and initializes it, copying the
- * payload.
- *
- * Once this call is done, you can deliver it with
- * wimax_msg_send().
- *
- * IMPORTANT:
- *
- * Don't use skb_push()/skb_pull()/skb_reserve() on the skb, as
- * wimax_msg_send() depends on skb->data being placed at the
- * beginning of the user message.
- *
- * Unlike other WiMAX stack calls, this call can be used way early,
- * even before wimax_dev_add() is called, as long as the
- * wimax_dev->net_dev pointer is set to point to a proper
- * net_dev. This is so that drivers can use it early in case they need
- * to send stuff around or communicate with user space.
- */
-struct sk_buff *wimax_msg_alloc(struct wimax_dev *wimax_dev,
-                               const char *pipe_name,
-                               const void *msg, size_t size,
-                               gfp_t gfp_flags)
-{
-       int result;
-       struct device *dev = wimax_dev_to_dev(wimax_dev);
-       size_t msg_size;
-       void *genl_msg;
-       struct sk_buff *skb;
-
-       msg_size = nla_total_size(size)
-               + nla_total_size(sizeof(u32))
-               + (pipe_name ? nla_total_size(strlen(pipe_name)) : 0);
-       result = -ENOMEM;
-       skb = genlmsg_new(msg_size, gfp_flags);
-       if (skb == NULL)
-               goto error_new;
-       genl_msg = genlmsg_put(skb, 0, 0, &wimax_gnl_family,
-                              0, WIMAX_GNL_OP_MSG_TO_USER);
-       if (genl_msg == NULL) {
-               dev_err(dev, "no memory to create generic netlink message\n");
-               goto error_genlmsg_put;
-       }
-       result = nla_put_u32(skb, WIMAX_GNL_MSG_IFIDX,
-                            wimax_dev->net_dev->ifindex);
-       if (result < 0) {
-               dev_err(dev, "no memory to add ifindex attribute\n");
-               goto error_nla_put;
-       }
-       if (pipe_name) {
-               result = nla_put_string(skb, WIMAX_GNL_MSG_PIPE_NAME,
-                                       pipe_name);
-               if (result < 0) {
-                       dev_err(dev, "no memory to add pipe_name attribute\n");
-                       goto error_nla_put;
-               }
-       }
-       result = nla_put(skb, WIMAX_GNL_MSG_DATA, size, msg);
-       if (result < 0) {
-               dev_err(dev, "no memory to add payload (msg %p size %zu) in "
-                       "attribute: %d\n", msg, size, result);
-               goto error_nla_put;
-       }
-       genlmsg_end(skb, genl_msg);
-       return skb;
-
-error_nla_put:
-error_genlmsg_put:
-error_new:
-       nlmsg_free(skb);
-       return ERR_PTR(result);
-}
-EXPORT_SYMBOL_GPL(wimax_msg_alloc);
-
-
-/**
- * wimax_msg_data_len - Return a pointer and size of a message's payload
- *
- * @msg: Pointer to a message created with wimax_msg_alloc()
- * @size: Pointer to where to store the message's size
- *
- * Returns the pointer to the message data.
- */
-const void *wimax_msg_data_len(struct sk_buff *msg, size_t *size)
-{
-       struct nlmsghdr *nlh = (void *) msg->head;
-       struct nlattr *nla;
-
-       nla = nlmsg_find_attr(nlh, sizeof(struct genlmsghdr),
-                             WIMAX_GNL_MSG_DATA);
-       if (nla == NULL) {
-               pr_err("Cannot find attribute WIMAX_GNL_MSG_DATA\n");
-               return NULL;
-       }
-       *size = nla_len(nla);
-       return nla_data(nla);
-}
-EXPORT_SYMBOL_GPL(wimax_msg_data_len);
-
-
-/**
- * wimax_msg_data - Return a pointer to a message's payload
- *
- * @msg: Pointer to a message created with wimax_msg_alloc()
- */
-const void *wimax_msg_data(struct sk_buff *msg)
-{
-       struct nlmsghdr *nlh = (void *) msg->head;
-       struct nlattr *nla;
-
-       nla = nlmsg_find_attr(nlh, sizeof(struct genlmsghdr),
-                             WIMAX_GNL_MSG_DATA);
-       if (nla == NULL) {
-               pr_err("Cannot find attribute WIMAX_GNL_MSG_DATA\n");
-               return NULL;
-       }
-       return nla_data(nla);
-}
-EXPORT_SYMBOL_GPL(wimax_msg_data);
-
-
-/**
- * wimax_msg_len - Return a message's payload length
- *
- * @msg: Pointer to a message created with wimax_msg_alloc()
- */
-ssize_t wimax_msg_len(struct sk_buff *msg)
-{
-       struct nlmsghdr *nlh = (void *) msg->head;
-       struct nlattr *nla;
-
-       nla = nlmsg_find_attr(nlh, sizeof(struct genlmsghdr),
-                             WIMAX_GNL_MSG_DATA);
-       if (nla == NULL) {
-               pr_err("Cannot find attribute WIMAX_GNL_MSG_DATA\n");
-               return -EINVAL;
-       }
-       return nla_len(nla);
-}
-EXPORT_SYMBOL_GPL(wimax_msg_len);
-
-
-/**
- * wimax_msg_send - Send a pre-allocated message to user space
- *
- * @wimax_dev: WiMAX device descriptor
- *
- * @skb: &struct sk_buff returned by wimax_msg_alloc(). Note the
- *     ownership of @skb is transferred to this function.
- *
- * Returns: 0 if ok, < 0 errno code on error
- *
- * Description:
- *
- * Sends a free-form message that was preallocated with
- * wimax_msg_alloc() and filled up.
- *
- * Assumes that once you pass an skb to this function for sending, it
- * owns it and will release it when done (on success).
- *
- * IMPORTANT:
- *
- * Don't use skb_push()/skb_pull()/skb_reserve() on the skb, as
- * wimax_msg_send() depends on skb->data being placed at the
- * beginning of the user message.
- *
- * Unlike other WiMAX stack calls, this call can be used way early,
- * even before wimax_dev_add() is called, as long as the
- * wimax_dev->net_dev pointer is set to point to a proper
- * net_dev. This is so that drivers can use it early in case they need
- * to send stuff around or communicate with user space.
- */
-int wimax_msg_send(struct wimax_dev *wimax_dev, struct sk_buff *skb)
-{
-       struct device *dev = wimax_dev_to_dev(wimax_dev);
-       void *msg = skb->data;
-       size_t size = skb->len;
-       might_sleep();
-
-       d_printf(1, dev, "CTX: wimax msg, %zu bytes\n", size);
-       d_dump(2, dev, msg, size);
-       genlmsg_multicast(&wimax_gnl_family, skb, 0, 0, GFP_KERNEL);
-       d_printf(1, dev, "CTX: genl multicast done\n");
-       return 0;
-}
-EXPORT_SYMBOL_GPL(wimax_msg_send);
-
-
-/**
- * wimax_msg - Send a message to user space
- *
- * @wimax_dev: WiMAX device descriptor (properly referenced)
- * @pipe_name: "named pipe" the message will be sent to
- * @buf: pointer to the message to send.
- * @size: size of the buffer pointed to by @buf (in bytes).
- * @gfp_flags: flags for memory allocation.
- *
- * Returns: %0 if ok, negative errno code on error.
- *
- * Description:
- *
- * Sends a free-form message to user space on the device @wimax_dev.
- *
- * NOTES:
- *
- * Once the @skb is given to this function, who will own it and will
- * release it when done (unless it returns error).
- */
-int wimax_msg(struct wimax_dev *wimax_dev, const char *pipe_name,
-             const void *buf, size_t size, gfp_t gfp_flags)
-{
-       int result = -ENOMEM;
-       struct sk_buff *skb;
-
-       skb = wimax_msg_alloc(wimax_dev, pipe_name, buf, size, gfp_flags);
-       if (IS_ERR(skb))
-               result = PTR_ERR(skb);
-       else
-               result = wimax_msg_send(wimax_dev, skb);
-       return result;
-}
-EXPORT_SYMBOL_GPL(wimax_msg);
-
-/*
- * Relays a message from user space to the driver
- *
- * The skb is passed to the driver-specific function with the netlink
- * and generic netlink headers already stripped.
- *
- * This call will block while handling/relaying the message.
- */
-int wimax_gnl_doit_msg_from_user(struct sk_buff *skb, struct genl_info *info)
-{
-       int result, ifindex;
-       struct wimax_dev *wimax_dev;
-       struct device *dev;
-       struct nlmsghdr *nlh = info->nlhdr;
-       char *pipe_name;
-       void *msg_buf;
-       size_t msg_len;
-
-       might_sleep();
-       d_fnstart(3, NULL, "(skb %p info %p)\n", skb, info);
-       result = -ENODEV;
-       if (info->attrs[WIMAX_GNL_MSG_IFIDX] == NULL) {
-               pr_err("WIMAX_GNL_MSG_FROM_USER: can't find IFIDX attribute\n");
-               goto error_no_wimax_dev;
-       }
-       ifindex = nla_get_u32(info->attrs[WIMAX_GNL_MSG_IFIDX]);
-       wimax_dev = wimax_dev_get_by_genl_info(info, ifindex);
-       if (wimax_dev == NULL)
-               goto error_no_wimax_dev;
-       dev = wimax_dev_to_dev(wimax_dev);
-
-       /* Unpack arguments */
-       result = -EINVAL;
-       if (info->attrs[WIMAX_GNL_MSG_DATA] == NULL) {
-               dev_err(dev, "WIMAX_GNL_MSG_FROM_USER: can't find MSG_DATA "
-                       "attribute\n");
-               goto error_no_data;
-       }
-       msg_buf = nla_data(info->attrs[WIMAX_GNL_MSG_DATA]);
-       msg_len = nla_len(info->attrs[WIMAX_GNL_MSG_DATA]);
-
-       if (info->attrs[WIMAX_GNL_MSG_PIPE_NAME] == NULL)
-               pipe_name = NULL;
-       else {
-               struct nlattr *attr = info->attrs[WIMAX_GNL_MSG_PIPE_NAME];
-               size_t attr_len = nla_len(attr);
-               /* libnl-1.1 does not yet support NLA_NUL_STRING */
-               result = -ENOMEM;
-               pipe_name = kstrndup(nla_data(attr), attr_len + 1, GFP_KERNEL);
-               if (pipe_name == NULL)
-                       goto error_alloc;
-               pipe_name[attr_len] = 0;
-       }
-       mutex_lock(&wimax_dev->mutex);
-       result = wimax_dev_is_ready(wimax_dev);
-       if (result == -ENOMEDIUM)
-               result = 0;
-       if (result < 0)
-               goto error_not_ready;
-       result = -ENOSYS;
-       if (wimax_dev->op_msg_from_user == NULL)
-               goto error_noop;
-
-       d_printf(1, dev,
-                "CRX: nlmsghdr len %u type %u flags 0x%04x seq 0x%x pid %u\n",
-                nlh->nlmsg_len, nlh->nlmsg_type, nlh->nlmsg_flags,
-                nlh->nlmsg_seq, nlh->nlmsg_pid);
-       d_printf(1, dev, "CRX: wimax message %zu bytes\n", msg_len);
-       d_dump(2, dev, msg_buf, msg_len);
-
-       result = wimax_dev->op_msg_from_user(wimax_dev, pipe_name,
-                                            msg_buf, msg_len, info);
-error_noop:
-error_not_ready:
-       mutex_unlock(&wimax_dev->mutex);
-error_alloc:
-       kfree(pipe_name);
-error_no_data:
-       dev_put(wimax_dev->net_dev);
-error_no_wimax_dev:
-       d_fnend(3, NULL, "(skb %p info %p) = %d\n", skb, info, result);
-       return result;
-}
diff --git a/drivers/staging/wimax/op-reset.c b/drivers/staging/wimax/op-reset.c
deleted file mode 100644 (file)
index b3f000c..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Linux WiMAX
- * Implement and export a method for resetting a WiMAX device
- *
- * Copyright (C) 2008 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *
- * This implements a simple synchronous call to reset a WiMAX device.
- *
- * Resets aim at being warm, keeping the device handles active;
- * however, when that fails, it falls back to a cold reset (that will
- * disconnect and reconnect the device).
- */
-
-#include "net-wimax.h"
-#include <net/genetlink.h>
-#include "linux-wimax.h"
-#include <linux/security.h>
-#include <linux/export.h>
-#include "wimax-internal.h"
-
-#define D_SUBMODULE op_reset
-#include "debug-levels.h"
-
-
-/**
- * wimax_reset - Reset a WiMAX device
- *
- * @wimax_dev: WiMAX device descriptor
- *
- * Returns:
- *
- * %0 if ok and a warm reset was done (the device still exists in
- * the system).
- *
- * -%ENODEV if a cold/bus reset had to be done (device has
- * disconnected and reconnected, so current handle is not valid
- * any more).
- *
- * -%EINVAL if the device is not even registered.
- *
- * Any other negative error code shall be considered as
- * non-recoverable.
- *
- * Description:
- *
- * Called when wanting to reset the device for any reason. Device is
- * taken back to power on status.
- *
- * This call blocks; on successful return, the device has completed the
- * reset process and is ready to operate.
- */
-int wimax_reset(struct wimax_dev *wimax_dev)
-{
-       int result = -EINVAL;
-       struct device *dev = wimax_dev_to_dev(wimax_dev);
-       enum wimax_st state;
-
-       might_sleep();
-       d_fnstart(3, dev, "(wimax_dev %p)\n", wimax_dev);
-       mutex_lock(&wimax_dev->mutex);
-       dev_hold(wimax_dev->net_dev);
-       state = wimax_dev->state;
-       mutex_unlock(&wimax_dev->mutex);
-
-       if (state >= WIMAX_ST_DOWN) {
-               mutex_lock(&wimax_dev->mutex_reset);
-               result = wimax_dev->op_reset(wimax_dev);
-               mutex_unlock(&wimax_dev->mutex_reset);
-       }
-       dev_put(wimax_dev->net_dev);
-
-       d_fnend(3, dev, "(wimax_dev %p) = %d\n", wimax_dev, result);
-       return result;
-}
-EXPORT_SYMBOL(wimax_reset);
-
-
-/*
- * Exporting to user space over generic netlink
- *
- * Parse the reset command from user space, return error code.
- *
- * No attributes.
- */
-int wimax_gnl_doit_reset(struct sk_buff *skb, struct genl_info *info)
-{
-       int result, ifindex;
-       struct wimax_dev *wimax_dev;
-
-       d_fnstart(3, NULL, "(skb %p info %p)\n", skb, info);
-       result = -ENODEV;
-       if (info->attrs[WIMAX_GNL_RESET_IFIDX] == NULL) {
-               pr_err("WIMAX_GNL_OP_RFKILL: can't find IFIDX attribute\n");
-               goto error_no_wimax_dev;
-       }
-       ifindex = nla_get_u32(info->attrs[WIMAX_GNL_RESET_IFIDX]);
-       wimax_dev = wimax_dev_get_by_genl_info(info, ifindex);
-       if (wimax_dev == NULL)
-               goto error_no_wimax_dev;
-       /* Execute the operation and send the result back to user space */
-       result = wimax_reset(wimax_dev);
-       dev_put(wimax_dev->net_dev);
-error_no_wimax_dev:
-       d_fnend(3, NULL, "(skb %p info %p) = %d\n", skb, info, result);
-       return result;
-}
diff --git a/drivers/staging/wimax/op-rfkill.c b/drivers/staging/wimax/op-rfkill.c
deleted file mode 100644 (file)
index 78b2944..0000000
+++ /dev/null
@@ -1,431 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Linux WiMAX
- * RF-kill framework integration
- *
- * Copyright (C) 2008 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *
- * This integrates into the Linux Kernel rfkill susbystem so that the
- * drivers just have to do the bare minimal work, which is providing a
- * method to set the software RF-Kill switch and to report changes in
- * the software and hardware switch status.
- *
- * A non-polled generic rfkill device is embedded into the WiMAX
- * subsystem's representation of a device.
- *
- * FIXME: Need polled support? Let drivers provide a poll routine
- *       and hand it to rfkill ops then?
- *
- * All device drivers have to do is after wimax_dev_init(), call
- * wimax_report_rfkill_hw() and wimax_report_rfkill_sw() to update
- * initial state and then every time it changes. See wimax.h:struct
- * wimax_dev for more information.
- *
- * ROADMAP
- *
- * wimax_gnl_doit_rfkill()      User space calling wimax_rfkill()
- *   wimax_rfkill()             Kernel calling wimax_rfkill()
- *     __wimax_rf_toggle_radio()
- *
- * wimax_rfkill_set_radio_block()  RF-Kill subsystem calling
- *   __wimax_rf_toggle_radio()
- *
- * __wimax_rf_toggle_radio()
- *   wimax_dev->op_rfkill_sw_toggle() Driver backend
- *   __wimax_state_change()
- *
- * wimax_report_rfkill_sw()     Driver reports state change
- *   __wimax_state_change()
- *
- * wimax_report_rfkill_hw()     Driver reports state change
- *   __wimax_state_change()
- *
- * wimax_rfkill_add()           Initialize/shutdown rfkill support
- * wimax_rfkill_rm()            [called by wimax_dev_add/rm()]
- */
-
-#include "net-wimax.h"
-#include <net/genetlink.h>
-#include "linux-wimax.h"
-#include <linux/security.h>
-#include <linux/rfkill.h>
-#include <linux/export.h>
-#include "wimax-internal.h"
-
-#define D_SUBMODULE op_rfkill
-#include "debug-levels.h"
-
-/**
- * wimax_report_rfkill_hw - Reports changes in the hardware RF switch
- *
- * @wimax_dev: WiMAX device descriptor
- *
- * @state: New state of the RF Kill switch. %WIMAX_RF_ON radio on,
- *     %WIMAX_RF_OFF radio off.
- *
- * When the device detects a change in the state of thehardware RF
- * switch, it must call this function to let the WiMAX kernel stack
- * know that the state has changed so it can be properly propagated.
- *
- * The WiMAX stack caches the state (the driver doesn't need to). As
- * well, as the change is propagated it will come back as a request to
- * change the software state to mirror the hardware state.
- *
- * If the device doesn't have a hardware kill switch, just report
- * it on initialization as always on (%WIMAX_RF_ON, radio on).
- */
-void wimax_report_rfkill_hw(struct wimax_dev *wimax_dev,
-                           enum wimax_rf_state state)
-{
-       int result;
-       struct device *dev = wimax_dev_to_dev(wimax_dev);
-       enum wimax_st wimax_state;
-
-       d_fnstart(3, dev, "(wimax_dev %p state %u)\n", wimax_dev, state);
-       BUG_ON(state == WIMAX_RF_QUERY);
-       BUG_ON(state != WIMAX_RF_ON && state != WIMAX_RF_OFF);
-
-       mutex_lock(&wimax_dev->mutex);
-       result = wimax_dev_is_ready(wimax_dev);
-       if (result < 0)
-               goto error_not_ready;
-
-       if (state != wimax_dev->rf_hw) {
-               wimax_dev->rf_hw = state;
-               if (wimax_dev->rf_hw == WIMAX_RF_ON &&
-                   wimax_dev->rf_sw == WIMAX_RF_ON)
-                       wimax_state = WIMAX_ST_READY;
-               else
-                       wimax_state = WIMAX_ST_RADIO_OFF;
-
-               result = rfkill_set_hw_state(wimax_dev->rfkill,
-                                            state == WIMAX_RF_OFF);
-
-               __wimax_state_change(wimax_dev, wimax_state);
-       }
-error_not_ready:
-       mutex_unlock(&wimax_dev->mutex);
-       d_fnend(3, dev, "(wimax_dev %p state %u) = void [%d]\n",
-               wimax_dev, state, result);
-}
-EXPORT_SYMBOL_GPL(wimax_report_rfkill_hw);
-
-
-/**
- * wimax_report_rfkill_sw - Reports changes in the software RF switch
- *
- * @wimax_dev: WiMAX device descriptor
- *
- * @state: New state of the RF kill switch. %WIMAX_RF_ON radio on,
- *     %WIMAX_RF_OFF radio off.
- *
- * Reports changes in the software RF switch state to the WiMAX stack.
- *
- * The main use is during initialization, so the driver can query the
- * device for its current software radio kill switch state and feed it
- * to the system.
- *
- * On the side, the device does not change the software state by
- * itself. In practice, this can happen, as the device might decide to
- * switch (in software) the radio off for different reasons.
- */
-void wimax_report_rfkill_sw(struct wimax_dev *wimax_dev,
-                           enum wimax_rf_state state)
-{
-       int result;
-       struct device *dev = wimax_dev_to_dev(wimax_dev);
-       enum wimax_st wimax_state;
-
-       d_fnstart(3, dev, "(wimax_dev %p state %u)\n", wimax_dev, state);
-       BUG_ON(state == WIMAX_RF_QUERY);
-       BUG_ON(state != WIMAX_RF_ON && state != WIMAX_RF_OFF);
-
-       mutex_lock(&wimax_dev->mutex);
-       result = wimax_dev_is_ready(wimax_dev);
-       if (result < 0)
-               goto error_not_ready;
-
-       if (state != wimax_dev->rf_sw) {
-               wimax_dev->rf_sw = state;
-               if (wimax_dev->rf_hw == WIMAX_RF_ON &&
-                   wimax_dev->rf_sw == WIMAX_RF_ON)
-                       wimax_state = WIMAX_ST_READY;
-               else
-                       wimax_state = WIMAX_ST_RADIO_OFF;
-               __wimax_state_change(wimax_dev, wimax_state);
-               rfkill_set_sw_state(wimax_dev->rfkill, state == WIMAX_RF_OFF);
-       }
-error_not_ready:
-       mutex_unlock(&wimax_dev->mutex);
-       d_fnend(3, dev, "(wimax_dev %p state %u) = void [%d]\n",
-               wimax_dev, state, result);
-}
-EXPORT_SYMBOL_GPL(wimax_report_rfkill_sw);
-
-
-/*
- * Callback for the RF Kill toggle operation
- *
- * This function is called by:
- *
- * - The rfkill subsystem when the RF-Kill key is pressed in the
- *   hardware and the driver notifies through
- *   wimax_report_rfkill_hw(). The rfkill subsystem ends up calling back
- *   here so the software RF Kill switch state is changed to reflect
- *   the hardware switch state.
- *
- * - When the user sets the state through sysfs' rfkill/state file
- *
- * - When the user calls wimax_rfkill().
- *
- * This call blocks!
- *
- * WARNING! When we call rfkill_unregister(), this will be called with
- * state 0!
- *
- * WARNING: wimax_dev must be locked
- */
-static
-int __wimax_rf_toggle_radio(struct wimax_dev *wimax_dev,
-                           enum wimax_rf_state state)
-{
-       int result = 0;
-       struct device *dev = wimax_dev_to_dev(wimax_dev);
-       enum wimax_st wimax_state;
-
-       might_sleep();
-       d_fnstart(3, dev, "(wimax_dev %p state %u)\n", wimax_dev, state);
-       if (wimax_dev->rf_sw == state)
-               goto out_no_change;
-       if (wimax_dev->op_rfkill_sw_toggle != NULL)
-               result = wimax_dev->op_rfkill_sw_toggle(wimax_dev, state);
-       else if (state == WIMAX_RF_OFF) /* No op? can't turn off */
-               result = -ENXIO;
-       else                            /* No op? can turn on */
-               result = 0;             /* should never happen tho */
-       if (result >= 0) {
-               result = 0;
-               wimax_dev->rf_sw = state;
-               wimax_state = state == WIMAX_RF_ON ?
-                       WIMAX_ST_READY : WIMAX_ST_RADIO_OFF;
-               __wimax_state_change(wimax_dev, wimax_state);
-       }
-out_no_change:
-       d_fnend(3, dev, "(wimax_dev %p state %u) = %d\n",
-               wimax_dev, state, result);
-       return result;
-}
-
-
-/*
- * Translate from rfkill state to wimax state
- *
- * NOTE: Special state handling rules here
- *
- *     Just pretend the call didn't happen if we are in a state where
- *     we know for sure it cannot be handled (WIMAX_ST_DOWN or
- *     __WIMAX_ST_QUIESCING). rfkill() needs it to register and
- *     unregister, as it will run this path.
- *
- * NOTE: This call will block until the operation is completed.
- */
-static int wimax_rfkill_set_radio_block(void *data, bool blocked)
-{
-       int result;
-       struct wimax_dev *wimax_dev = data;
-       struct device *dev = wimax_dev_to_dev(wimax_dev);
-       enum wimax_rf_state rf_state;
-
-       d_fnstart(3, dev, "(wimax_dev %p blocked %u)\n", wimax_dev, blocked);
-       rf_state = WIMAX_RF_ON;
-       if (blocked)
-               rf_state = WIMAX_RF_OFF;
-       mutex_lock(&wimax_dev->mutex);
-       if (wimax_dev->state <= __WIMAX_ST_QUIESCING)
-               result = 0;
-       else
-               result = __wimax_rf_toggle_radio(wimax_dev, rf_state);
-       mutex_unlock(&wimax_dev->mutex);
-       d_fnend(3, dev, "(wimax_dev %p blocked %u) = %d\n",
-               wimax_dev, blocked, result);
-       return result;
-}
-
-static const struct rfkill_ops wimax_rfkill_ops = {
-       .set_block = wimax_rfkill_set_radio_block,
-};
-
-/**
- * wimax_rfkill - Set the software RF switch state for a WiMAX device
- *
- * @wimax_dev: WiMAX device descriptor
- *
- * @state: New RF state.
- *
- * Returns:
- *
- * >= 0 toggle state if ok, < 0 errno code on error. The toggle state
- * is returned as a bitmap, bit 0 being the hardware RF state, bit 1
- * the software RF state.
- *
- * 0 means disabled (%WIMAX_RF_ON, radio on), 1 means enabled radio
- * off (%WIMAX_RF_OFF).
- *
- * Description:
- *
- * Called by the user when he wants to request the WiMAX radio to be
- * switched on (%WIMAX_RF_ON) or off (%WIMAX_RF_OFF). With
- * %WIMAX_RF_QUERY, just the current state is returned.
- *
- * NOTE:
- *
- * This call will block until the operation is complete.
- */
-int wimax_rfkill(struct wimax_dev *wimax_dev, enum wimax_rf_state state)
-{
-       int result;
-       struct device *dev = wimax_dev_to_dev(wimax_dev);
-
-       d_fnstart(3, dev, "(wimax_dev %p state %u)\n", wimax_dev, state);
-       mutex_lock(&wimax_dev->mutex);
-       result = wimax_dev_is_ready(wimax_dev);
-       if (result < 0) {
-               /* While initializing, < 1.4.3 wimax-tools versions use
-                * this call to check if the device is a valid WiMAX
-                * device; so we allow it to proceed always,
-                * considering the radios are all off. */
-               if (result == -ENOMEDIUM && state == WIMAX_RF_QUERY)
-                       result = WIMAX_RF_OFF << 1 | WIMAX_RF_OFF;
-               goto error_not_ready;
-       }
-       switch (state) {
-       case WIMAX_RF_ON:
-       case WIMAX_RF_OFF:
-               result = __wimax_rf_toggle_radio(wimax_dev, state);
-               if (result < 0)
-                       goto error;
-               rfkill_set_sw_state(wimax_dev->rfkill, state == WIMAX_RF_OFF);
-               break;
-       case WIMAX_RF_QUERY:
-               break;
-       default:
-               result = -EINVAL;
-               goto error;
-       }
-       result = wimax_dev->rf_sw << 1 | wimax_dev->rf_hw;
-error:
-error_not_ready:
-       mutex_unlock(&wimax_dev->mutex);
-       d_fnend(3, dev, "(wimax_dev %p state %u) = %d\n",
-               wimax_dev, state, result);
-       return result;
-}
-EXPORT_SYMBOL(wimax_rfkill);
-
-
-/*
- * Register a new WiMAX device's RF Kill support
- *
- * WARNING: wimax_dev->mutex must be unlocked
- */
-int wimax_rfkill_add(struct wimax_dev *wimax_dev)
-{
-       int result;
-       struct rfkill *rfkill;
-       struct device *dev = wimax_dev_to_dev(wimax_dev);
-
-       d_fnstart(3, dev, "(wimax_dev %p)\n", wimax_dev);
-       /* Initialize RF Kill */
-       result = -ENOMEM;
-       rfkill = rfkill_alloc(wimax_dev->name, dev, RFKILL_TYPE_WIMAX,
-                             &wimax_rfkill_ops, wimax_dev);
-       if (rfkill == NULL)
-               goto error_rfkill_allocate;
-
-       d_printf(1, dev, "rfkill %p\n", rfkill);
-
-       wimax_dev->rfkill = rfkill;
-
-       rfkill_init_sw_state(rfkill, 1);
-       result = rfkill_register(wimax_dev->rfkill);
-       if (result < 0)
-               goto error_rfkill_register;
-
-       /* If there is no SW toggle op, SW RFKill is always on */
-       if (wimax_dev->op_rfkill_sw_toggle == NULL)
-               wimax_dev->rf_sw = WIMAX_RF_ON;
-
-       d_fnend(3, dev, "(wimax_dev %p) = 0\n", wimax_dev);
-       return 0;
-
-error_rfkill_register:
-       rfkill_destroy(wimax_dev->rfkill);
-error_rfkill_allocate:
-       d_fnend(3, dev, "(wimax_dev %p) = %d\n", wimax_dev, result);
-       return result;
-}
-
-
-/*
- * Deregister a WiMAX device's RF Kill support
- *
- * Ick, we can't call rfkill_free() after rfkill_unregister()...oh
- * well.
- *
- * WARNING: wimax_dev->mutex must be unlocked
- */
-void wimax_rfkill_rm(struct wimax_dev *wimax_dev)
-{
-       struct device *dev = wimax_dev_to_dev(wimax_dev);
-       d_fnstart(3, dev, "(wimax_dev %p)\n", wimax_dev);
-       rfkill_unregister(wimax_dev->rfkill);
-       rfkill_destroy(wimax_dev->rfkill);
-       d_fnend(3, dev, "(wimax_dev %p)\n", wimax_dev);
-}
-
-
-/*
- * Exporting to user space over generic netlink
- *
- * Parse the rfkill command from user space, return a combination
- * value that describe the states of the different toggles.
- *
- * Only one attribute: the new state requested (on, off or no change,
- * just query).
- */
-
-int wimax_gnl_doit_rfkill(struct sk_buff *skb, struct genl_info *info)
-{
-       int result, ifindex;
-       struct wimax_dev *wimax_dev;
-       struct device *dev;
-       enum wimax_rf_state new_state;
-
-       d_fnstart(3, NULL, "(skb %p info %p)\n", skb, info);
-       result = -ENODEV;
-       if (info->attrs[WIMAX_GNL_RFKILL_IFIDX] == NULL) {
-               pr_err("WIMAX_GNL_OP_RFKILL: can't find IFIDX attribute\n");
-               goto error_no_wimax_dev;
-       }
-       ifindex = nla_get_u32(info->attrs[WIMAX_GNL_RFKILL_IFIDX]);
-       wimax_dev = wimax_dev_get_by_genl_info(info, ifindex);
-       if (wimax_dev == NULL)
-               goto error_no_wimax_dev;
-       dev = wimax_dev_to_dev(wimax_dev);
-       result = -EINVAL;
-       if (info->attrs[WIMAX_GNL_RFKILL_STATE] == NULL) {
-               dev_err(dev, "WIMAX_GNL_RFKILL: can't find RFKILL_STATE "
-                       "attribute\n");
-               goto error_no_pid;
-       }
-       new_state = nla_get_u32(info->attrs[WIMAX_GNL_RFKILL_STATE]);
-
-       /* Execute the operation and send the result back to user space */
-       result = wimax_rfkill(wimax_dev, new_state);
-error_no_pid:
-       dev_put(wimax_dev->net_dev);
-error_no_wimax_dev:
-       d_fnend(3, NULL, "(skb %p info %p) = %d\n", skb, info, result);
-       return result;
-}
diff --git a/drivers/staging/wimax/op-state-get.c b/drivers/staging/wimax/op-state-get.c
deleted file mode 100644 (file)
index c5bfbed..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Linux WiMAX
- * Implement and export a method for getting a WiMAX device current state
- *
- * Copyright (C) 2009 Paulius Zaleckas <paulius.zaleckas@teltonika.lt>
- *
- * Based on previous WiMAX core work by:
- *  Copyright (C) 2008 Intel Corporation <linux-wimax@intel.com>
- *  Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- */
-
-#include "net-wimax.h"
-#include <net/genetlink.h>
-#include "linux-wimax.h"
-#include <linux/security.h>
-#include "wimax-internal.h"
-
-#define D_SUBMODULE op_state_get
-#include "debug-levels.h"
-
-
-/*
- * Exporting to user space over generic netlink
- *
- * Parse the state get command from user space, return a combination
- * value that describe the current state.
- *
- * No attributes.
- */
-int wimax_gnl_doit_state_get(struct sk_buff *skb, struct genl_info *info)
-{
-       int result, ifindex;
-       struct wimax_dev *wimax_dev;
-
-       d_fnstart(3, NULL, "(skb %p info %p)\n", skb, info);
-       result = -ENODEV;
-       if (info->attrs[WIMAX_GNL_STGET_IFIDX] == NULL) {
-               pr_err("WIMAX_GNL_OP_STATE_GET: can't find IFIDX attribute\n");
-               goto error_no_wimax_dev;
-       }
-       ifindex = nla_get_u32(info->attrs[WIMAX_GNL_STGET_IFIDX]);
-       wimax_dev = wimax_dev_get_by_genl_info(info, ifindex);
-       if (wimax_dev == NULL)
-               goto error_no_wimax_dev;
-       /* Execute the operation and send the result back to user space */
-       result = wimax_state_get(wimax_dev);
-       dev_put(wimax_dev->net_dev);
-error_no_wimax_dev:
-       d_fnend(3, NULL, "(skb %p info %p) = %d\n", skb, info, result);
-       return result;
-}
diff --git a/drivers/staging/wimax/stack.c b/drivers/staging/wimax/stack.c
deleted file mode 100644 (file)
index 485c022..0000000
+++ /dev/null
@@ -1,604 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Linux WiMAX
- * Initialization, addition and removal of wimax devices
- *
- * Copyright (C) 2005-2006 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *
- * This implements:
- *
- *   - basic life cycle of 'struct wimax_dev' [wimax_dev_*()]; on
- *     addition/registration initialize all subfields and allocate
- *     generic netlink resources for user space communication. On
- *     removal/unregistration, undo all that.
- *
- *   - device state machine [wimax_state_change()] and support to send
- *     reports to user space when the state changes
- *     [wimax_gnl_re_state_change*()].
- *
- * See include/net/wimax.h for rationales and design.
- *
- * ROADMAP
- *
- * [__]wimax_state_change()     Called by drivers to update device's state
- *   wimax_gnl_re_state_change_alloc()
- *   wimax_gnl_re_state_change_send()
- *
- * wimax_dev_init()            Init a device
- * wimax_dev_add()              Register
- *   wimax_rfkill_add()
- *   wimax_gnl_add()            Register all the generic netlink resources.
- *   wimax_id_table_add()
- * wimax_dev_rm()               Unregister
- *   wimax_id_table_rm()
- *   wimax_gnl_rm()
- *   wimax_rfkill_rm()
- */
-#include <linux/device.h>
-#include <linux/gfp.h>
-#include <net/genetlink.h>
-#include <linux/netdevice.h>
-#include "linux-wimax.h"
-#include <linux/module.h>
-#include "wimax-internal.h"
-
-
-#define D_SUBMODULE stack
-#include "debug-levels.h"
-
-static char wimax_debug_params[128];
-module_param_string(debug, wimax_debug_params, sizeof(wimax_debug_params),
-                   0644);
-MODULE_PARM_DESC(debug,
-                "String of space-separated NAME:VALUE pairs, where NAMEs "
-                "are the different debug submodules and VALUE are the "
-                "initial debug value to set.");
-
-/*
- * Allocate a Report State Change message
- *
- * @header: save it, you need it for _send()
- *
- * Creates and fills a basic state change message; different code
- * paths can then add more attributes to the message as needed.
- *
- * Use wimax_gnl_re_state_change_send() to send the returned skb.
- *
- * Returns: skb with the genl message if ok, IS_ERR() ptr on error
- *     with an errno code.
- */
-static
-struct sk_buff *wimax_gnl_re_state_change_alloc(
-       struct wimax_dev *wimax_dev,
-       enum wimax_st new_state, enum wimax_st old_state,
-       void **header)
-{
-       int result;
-       struct device *dev = wimax_dev_to_dev(wimax_dev);
-       void *data;
-       struct sk_buff *report_skb;
-
-       d_fnstart(3, dev, "(wimax_dev %p new_state %u old_state %u)\n",
-                 wimax_dev, new_state, old_state);
-       result = -ENOMEM;
-       report_skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
-       if (report_skb == NULL) {
-               dev_err(dev, "RE_STCH: can't create message\n");
-               goto error_new;
-       }
-       /* FIXME: sending a group ID as the seq is wrong */
-       data = genlmsg_put(report_skb, 0, wimax_gnl_family.mcgrp_offset,
-                          &wimax_gnl_family, 0, WIMAX_GNL_RE_STATE_CHANGE);
-       if (data == NULL) {
-               dev_err(dev, "RE_STCH: can't put data into message\n");
-               goto error_put;
-       }
-       *header = data;
-
-       result = nla_put_u8(report_skb, WIMAX_GNL_STCH_STATE_OLD, old_state);
-       if (result < 0) {
-               dev_err(dev, "RE_STCH: Error adding OLD attr: %d\n", result);
-               goto error_put;
-       }
-       result = nla_put_u8(report_skb, WIMAX_GNL_STCH_STATE_NEW, new_state);
-       if (result < 0) {
-               dev_err(dev, "RE_STCH: Error adding NEW attr: %d\n", result);
-               goto error_put;
-       }
-       result = nla_put_u32(report_skb, WIMAX_GNL_STCH_IFIDX,
-                            wimax_dev->net_dev->ifindex);
-       if (result < 0) {
-               dev_err(dev, "RE_STCH: Error adding IFINDEX attribute\n");
-               goto error_put;
-       }
-       d_fnend(3, dev, "(wimax_dev %p new_state %u old_state %u) = %p\n",
-               wimax_dev, new_state, old_state, report_skb);
-       return report_skb;
-
-error_put:
-       nlmsg_free(report_skb);
-error_new:
-       d_fnend(3, dev, "(wimax_dev %p new_state %u old_state %u) = %d\n",
-               wimax_dev, new_state, old_state, result);
-       return ERR_PTR(result);
-}
-
-
-/*
- * Send a Report State Change message (as created with _alloc).
- *
- * @report_skb: as returned by wimax_gnl_re_state_change_alloc()
- * @header: as returned by wimax_gnl_re_state_change_alloc()
- *
- * Returns: 0 if ok, < 0 errno code on error.
- *
- * If the message is  NULL, pretend it didn't happen.
- */
-static
-int wimax_gnl_re_state_change_send(
-       struct wimax_dev *wimax_dev, struct sk_buff *report_skb,
-       void *header)
-{
-       int result = 0;
-       struct device *dev = wimax_dev_to_dev(wimax_dev);
-
-       d_fnstart(3, dev, "(wimax_dev %p report_skb %p)\n",
-                 wimax_dev, report_skb);
-       if (report_skb == NULL) {
-               result = -ENOMEM;
-               goto out;
-       }
-       genlmsg_end(report_skb, header);
-       genlmsg_multicast(&wimax_gnl_family, report_skb, 0, 0, GFP_KERNEL);
-out:
-       d_fnend(3, dev, "(wimax_dev %p report_skb %p) = %d\n",
-               wimax_dev, report_skb, result);
-       return result;
-}
-
-
-static
-void __check_new_state(enum wimax_st old_state, enum wimax_st new_state,
-                      unsigned int allowed_states_bm)
-{
-       if (WARN_ON(((1 << new_state) & allowed_states_bm) == 0)) {
-               pr_err("SW BUG! Forbidden state change %u -> %u\n",
-                      old_state, new_state);
-       }
-}
-
-
-/*
- * Set the current state of a WiMAX device [unlocking version of
- * wimax_state_change().
- */
-void __wimax_state_change(struct wimax_dev *wimax_dev, enum wimax_st new_state)
-{
-       struct device *dev = wimax_dev_to_dev(wimax_dev);
-       enum wimax_st old_state = wimax_dev->state;
-       struct sk_buff *stch_skb;
-       void *header;
-
-       d_fnstart(3, dev, "(wimax_dev %p new_state %u [old %u])\n",
-                 wimax_dev, new_state, old_state);
-
-       if (WARN_ON(new_state >= __WIMAX_ST_INVALID)) {
-               dev_err(dev, "SW BUG: requesting invalid state %u\n",
-                       new_state);
-               goto out;
-       }
-       if (old_state == new_state)
-               goto out;
-       header = NULL;  /* gcc complains? can't grok why */
-       stch_skb = wimax_gnl_re_state_change_alloc(
-               wimax_dev, new_state, old_state, &header);
-
-       /* Verify the state transition and do exit-from-state actions */
-       switch (old_state) {
-       case __WIMAX_ST_NULL:
-               __check_new_state(old_state, new_state,
-                                 1 << WIMAX_ST_DOWN);
-               break;
-       case WIMAX_ST_DOWN:
-               __check_new_state(old_state, new_state,
-                                 1 << __WIMAX_ST_QUIESCING
-                                 | 1 << WIMAX_ST_UNINITIALIZED
-                                 | 1 << WIMAX_ST_RADIO_OFF);
-               break;
-       case __WIMAX_ST_QUIESCING:
-               __check_new_state(old_state, new_state, 1 << WIMAX_ST_DOWN);
-               break;
-       case WIMAX_ST_UNINITIALIZED:
-               __check_new_state(old_state, new_state,
-                                 1 << __WIMAX_ST_QUIESCING
-                                 | 1 << WIMAX_ST_RADIO_OFF);
-               break;
-       case WIMAX_ST_RADIO_OFF:
-               __check_new_state(old_state, new_state,
-                                 1 << __WIMAX_ST_QUIESCING
-                                 | 1 << WIMAX_ST_READY);
-               break;
-       case WIMAX_ST_READY:
-               __check_new_state(old_state, new_state,
-                                 1 << __WIMAX_ST_QUIESCING
-                                 | 1 << WIMAX_ST_RADIO_OFF
-                                 | 1 << WIMAX_ST_SCANNING
-                                 | 1 << WIMAX_ST_CONNECTING
-                                 | 1 << WIMAX_ST_CONNECTED);
-               break;
-       case WIMAX_ST_SCANNING:
-               __check_new_state(old_state, new_state,
-                                 1 << __WIMAX_ST_QUIESCING
-                                 | 1 << WIMAX_ST_RADIO_OFF
-                                 | 1 << WIMAX_ST_READY
-                                 | 1 << WIMAX_ST_CONNECTING
-                                 | 1 << WIMAX_ST_CONNECTED);
-               break;
-       case WIMAX_ST_CONNECTING:
-               __check_new_state(old_state, new_state,
-                                 1 << __WIMAX_ST_QUIESCING
-                                 | 1 << WIMAX_ST_RADIO_OFF
-                                 | 1 << WIMAX_ST_READY
-                                 | 1 << WIMAX_ST_SCANNING
-                                 | 1 << WIMAX_ST_CONNECTED);
-               break;
-       case WIMAX_ST_CONNECTED:
-               __check_new_state(old_state, new_state,
-                                 1 << __WIMAX_ST_QUIESCING
-                                 | 1 << WIMAX_ST_RADIO_OFF
-                                 | 1 << WIMAX_ST_READY);
-               netif_tx_disable(wimax_dev->net_dev);
-               netif_carrier_off(wimax_dev->net_dev);
-               break;
-       case __WIMAX_ST_INVALID:
-       default:
-               dev_err(dev, "SW BUG: wimax_dev %p is in unknown state %u\n",
-                       wimax_dev, wimax_dev->state);
-               WARN_ON(1);
-               goto out;
-       }
-
-       /* Execute the actions of entry to the new state */
-       switch (new_state) {
-       case __WIMAX_ST_NULL:
-               dev_err(dev, "SW BUG: wimax_dev %p entering NULL state "
-                       "from %u\n", wimax_dev, wimax_dev->state);
-               WARN_ON(1);             /* Nobody can enter this state */
-               break;
-       case WIMAX_ST_DOWN:
-               break;
-       case __WIMAX_ST_QUIESCING:
-               break;
-       case WIMAX_ST_UNINITIALIZED:
-               break;
-       case WIMAX_ST_RADIO_OFF:
-               break;
-       case WIMAX_ST_READY:
-               break;
-       case WIMAX_ST_SCANNING:
-               break;
-       case WIMAX_ST_CONNECTING:
-               break;
-       case WIMAX_ST_CONNECTED:
-               netif_carrier_on(wimax_dev->net_dev);
-               netif_wake_queue(wimax_dev->net_dev);
-               break;
-       case __WIMAX_ST_INVALID:
-       default:
-               BUG();
-       }
-       __wimax_state_set(wimax_dev, new_state);
-       if (!IS_ERR(stch_skb))
-               wimax_gnl_re_state_change_send(wimax_dev, stch_skb, header);
-out:
-       d_fnend(3, dev, "(wimax_dev %p new_state %u [old %u]) = void\n",
-               wimax_dev, new_state, old_state);
-}
-
-
-/**
- * wimax_state_change - Set the current state of a WiMAX device
- *
- * @wimax_dev: WiMAX device descriptor (properly referenced)
- * @new_state: New state to switch to
- *
- * This implements the state changes for the wimax devices. It will
- *
- * - verify that the state transition is legal (for now it'll just
- *   print a warning if not) according to the table in
- *   linux/wimax.h's documentation for 'enum wimax_st'.
- *
- * - perform the actions needed for leaving the current state and
- *   whichever are needed for entering the new state.
- *
- * - issue a report to user space indicating the new state (and an
- *   optional payload with information about the new state).
- *
- * NOTE: @wimax_dev must be locked
- */
-void wimax_state_change(struct wimax_dev *wimax_dev, enum wimax_st new_state)
-{
-       /*
-        * A driver cannot take the wimax_dev out of the
-        * __WIMAX_ST_NULL state unless by calling wimax_dev_add(). If
-        * the wimax_dev's state is still NULL, we ignore any request
-        * to change its state because it means it hasn't been yet
-        * registered.
-        *
-        * There is no need to complain about it, as routines that
-        * call this might be shared from different code paths that
-        * are called before or after wimax_dev_add() has done its
-        * job.
-        */
-       mutex_lock(&wimax_dev->mutex);
-       if (wimax_dev->state > __WIMAX_ST_NULL)
-               __wimax_state_change(wimax_dev, new_state);
-       mutex_unlock(&wimax_dev->mutex);
-}
-EXPORT_SYMBOL_GPL(wimax_state_change);
-
-
-/**
- * wimax_state_get() - Return the current state of a WiMAX device
- *
- * @wimax_dev: WiMAX device descriptor
- *
- * Returns: Current state of the device according to its driver.
- */
-enum wimax_st wimax_state_get(struct wimax_dev *wimax_dev)
-{
-       enum wimax_st state;
-
-       mutex_lock(&wimax_dev->mutex);
-       state = wimax_dev->state;
-       mutex_unlock(&wimax_dev->mutex);
-       return state;
-}
-EXPORT_SYMBOL_GPL(wimax_state_get);
-
-
-/**
- * wimax_dev_init - initialize a newly allocated instance
- *
- * @wimax_dev: WiMAX device descriptor to initialize.
- *
- * Initializes fields of a freshly allocated @wimax_dev instance. This
- * function assumes that after allocation, the memory occupied by
- * @wimax_dev was zeroed.
- */
-void wimax_dev_init(struct wimax_dev *wimax_dev)
-{
-       INIT_LIST_HEAD(&wimax_dev->id_table_node);
-       __wimax_state_set(wimax_dev, __WIMAX_ST_NULL);
-       mutex_init(&wimax_dev->mutex);
-       mutex_init(&wimax_dev->mutex_reset);
-}
-EXPORT_SYMBOL_GPL(wimax_dev_init);
-
-/*
- * There are multiple enums reusing the same values, adding
- * others is only possible if they use a compatible policy.
- */
-static const struct nla_policy wimax_gnl_policy[WIMAX_GNL_ATTR_MAX + 1] = {
-       /*
-        * WIMAX_GNL_RESET_IFIDX, WIMAX_GNL_RFKILL_IFIDX,
-        * WIMAX_GNL_STGET_IFIDX, WIMAX_GNL_MSG_IFIDX
-        */
-       [1] = { .type = NLA_U32, },
-       /*
-        * WIMAX_GNL_RFKILL_STATE, WIMAX_GNL_MSG_PIPE_NAME
-        */
-       [2] = { .type = NLA_U32, }, /* enum wimax_rf_state */
-       /*
-        * WIMAX_GNL_MSG_DATA
-        */
-       [3] = { .type = NLA_UNSPEC, }, /* libnl doesn't grok BINARY yet */
-};
-
-static const struct genl_small_ops wimax_gnl_ops[] = {
-       {
-               .cmd = WIMAX_GNL_OP_MSG_FROM_USER,
-               .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-               .flags = GENL_ADMIN_PERM,
-               .doit = wimax_gnl_doit_msg_from_user,
-       },
-       {
-               .cmd = WIMAX_GNL_OP_RESET,
-               .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-               .flags = GENL_ADMIN_PERM,
-               .doit = wimax_gnl_doit_reset,
-       },
-       {
-               .cmd = WIMAX_GNL_OP_RFKILL,
-               .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-               .flags = GENL_ADMIN_PERM,
-               .doit = wimax_gnl_doit_rfkill,
-       },
-       {
-               .cmd = WIMAX_GNL_OP_STATE_GET,
-               .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-               .flags = GENL_ADMIN_PERM,
-               .doit = wimax_gnl_doit_state_get,
-       },
-};
-
-
-static
-size_t wimax_addr_scnprint(char *addr_str, size_t addr_str_size,
-                          unsigned char *addr, size_t addr_len)
-{
-       unsigned int cnt, total;
-
-       for (total = cnt = 0; cnt < addr_len; cnt++)
-               total += scnprintf(addr_str + total, addr_str_size - total,
-                                  "%02x%c", addr[cnt],
-                                  cnt == addr_len - 1 ? '\0' : ':');
-       return total;
-}
-
-
-/**
- * wimax_dev_add - Register a new WiMAX device
- *
- * @wimax_dev: WiMAX device descriptor (as embedded in your @net_dev's
- *     priv data). You must have called wimax_dev_init() on it before.
- *
- * @net_dev: net device the @wimax_dev is associated with. The
- *     function expects SET_NETDEV_DEV() and register_netdev() were
- *     already called on it.
- *
- * Registers the new WiMAX device, sets up the user-kernel control
- * interface (generic netlink) and common WiMAX infrastructure.
- *
- * Note that the parts that will allow interaction with user space are
- * setup at the very end, when the rest is in place, as once that
- * happens, the driver might get user space control requests via
- * netlink or from debugfs that might translate into calls into
- * wimax_dev->op_*().
- */
-int wimax_dev_add(struct wimax_dev *wimax_dev, struct net_device *net_dev)
-{
-       int result;
-       struct device *dev = net_dev->dev.parent;
-       char addr_str[32];
-
-       d_fnstart(3, dev, "(wimax_dev %p net_dev %p)\n", wimax_dev, net_dev);
-
-       /* Do the RFKILL setup before locking, as RFKILL will call
-        * into our functions.
-        */
-       wimax_dev->net_dev = net_dev;
-       result = wimax_rfkill_add(wimax_dev);
-       if (result < 0)
-               goto error_rfkill_add;
-
-       /* Set up user-space interaction */
-       mutex_lock(&wimax_dev->mutex);
-       wimax_id_table_add(wimax_dev);
-       wimax_debugfs_add(wimax_dev);
-
-       __wimax_state_set(wimax_dev, WIMAX_ST_DOWN);
-       mutex_unlock(&wimax_dev->mutex);
-
-       wimax_addr_scnprint(addr_str, sizeof(addr_str),
-                           net_dev->dev_addr, net_dev->addr_len);
-       dev_err(dev, "WiMAX interface %s (%s) ready\n",
-               net_dev->name, addr_str);
-       d_fnend(3, dev, "(wimax_dev %p net_dev %p) = 0\n", wimax_dev, net_dev);
-       return 0;
-
-error_rfkill_add:
-       d_fnend(3, dev, "(wimax_dev %p net_dev %p) = %d\n",
-               wimax_dev, net_dev, result);
-       return result;
-}
-EXPORT_SYMBOL_GPL(wimax_dev_add);
-
-
-/**
- * wimax_dev_rm - Unregister an existing WiMAX device
- *
- * @wimax_dev: WiMAX device descriptor
- *
- * Unregisters a WiMAX device previously registered for use with
- * wimax_add_rm().
- *
- * IMPORTANT! Must call before calling unregister_netdev().
- *
- * After this function returns, you will not get any more user space
- * control requests (via netlink or debugfs) and thus to wimax_dev->ops.
- *
- * Reentrancy control is ensured by setting the state to
- * %__WIMAX_ST_QUIESCING. rfkill operations coming through
- * wimax_*rfkill*() will be stopped by the quiescing state; ops coming
- * from the rfkill subsystem will be stopped by the support being
- * removed by wimax_rfkill_rm().
- */
-void wimax_dev_rm(struct wimax_dev *wimax_dev)
-{
-       d_fnstart(3, NULL, "(wimax_dev %p)\n", wimax_dev);
-
-       mutex_lock(&wimax_dev->mutex);
-       __wimax_state_change(wimax_dev, __WIMAX_ST_QUIESCING);
-       wimax_debugfs_rm(wimax_dev);
-       wimax_id_table_rm(wimax_dev);
-       __wimax_state_change(wimax_dev, WIMAX_ST_DOWN);
-       mutex_unlock(&wimax_dev->mutex);
-       wimax_rfkill_rm(wimax_dev);
-       d_fnend(3, NULL, "(wimax_dev %p) = void\n", wimax_dev);
-}
-EXPORT_SYMBOL_GPL(wimax_dev_rm);
-
-
-/* Debug framework control of debug levels */
-struct d_level D_LEVEL[] = {
-       D_SUBMODULE_DEFINE(debugfs),
-       D_SUBMODULE_DEFINE(id_table),
-       D_SUBMODULE_DEFINE(op_msg),
-       D_SUBMODULE_DEFINE(op_reset),
-       D_SUBMODULE_DEFINE(op_rfkill),
-       D_SUBMODULE_DEFINE(op_state_get),
-       D_SUBMODULE_DEFINE(stack),
-};
-size_t D_LEVEL_SIZE = ARRAY_SIZE(D_LEVEL);
-
-
-static const struct genl_multicast_group wimax_gnl_mcgrps[] = {
-       { .name = "msg", },
-};
-
-struct genl_family wimax_gnl_family __ro_after_init = {
-       .name = "WiMAX",
-       .version = WIMAX_GNL_VERSION,
-       .hdrsize = 0,
-       .maxattr = WIMAX_GNL_ATTR_MAX,
-       .policy = wimax_gnl_policy,
-       .module = THIS_MODULE,
-       .small_ops = wimax_gnl_ops,
-       .n_small_ops = ARRAY_SIZE(wimax_gnl_ops),
-       .mcgrps = wimax_gnl_mcgrps,
-       .n_mcgrps = ARRAY_SIZE(wimax_gnl_mcgrps),
-};
-
-
-
-/* Shutdown the wimax stack */
-static
-int __init wimax_subsys_init(void)
-{
-       int result;
-
-       d_fnstart(4, NULL, "()\n");
-       d_parse_params(D_LEVEL, D_LEVEL_SIZE, wimax_debug_params,
-                      "wimax.debug");
-
-       result = genl_register_family(&wimax_gnl_family);
-       if (unlikely(result < 0)) {
-               pr_err("cannot register generic netlink family: %d\n", result);
-               goto error_register_family;
-       }
-
-       d_fnend(4, NULL, "() = 0\n");
-       return 0;
-
-error_register_family:
-       d_fnend(4, NULL, "() = %d\n", result);
-       return result;
-
-}
-module_init(wimax_subsys_init);
-
-
-/* Shutdown the wimax stack */
-static
-void __exit wimax_subsys_exit(void)
-{
-       wimax_id_table_release();
-       genl_unregister_family(&wimax_gnl_family);
-}
-module_exit(wimax_subsys_exit);
-
-MODULE_AUTHOR("Intel Corporation <linux-wimax@intel.com>");
-MODULE_DESCRIPTION("Linux WiMAX stack");
-MODULE_LICENSE("GPL");
diff --git a/drivers/staging/wimax/wimax-internal.h b/drivers/staging/wimax/wimax-internal.h
deleted file mode 100644 (file)
index a6b6990..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Linux WiMAX
- * Internal API for kernel space WiMAX stack
- *
- * Copyright (C) 2007 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *
- * This header file is for declarations and definitions internal to
- * the WiMAX stack. For public APIs and documentation, see
- * include/net/wimax.h and include/linux/wimax.h.
- */
-
-#ifndef __WIMAX_INTERNAL_H__
-#define __WIMAX_INTERNAL_H__
-#ifdef __KERNEL__
-
-#ifdef pr_fmt
-#undef pr_fmt
-#endif
-
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include <linux/device.h>
-#include "net-wimax.h"
-
-
-/*
- * Decide if a (locked) device is ready for use
- *
- * Before using the device structure, it must be locked
- * (wimax_dev->mutex). As well, most operations need to call this
- * function to check if the state is the right one.
- *
- * An error value will be returned if the state is not the right
- * one. In that case, the caller should not attempt to use the device
- * and just unlock it.
- */
-static inline __must_check
-int wimax_dev_is_ready(struct wimax_dev *wimax_dev)
-{
-       if (wimax_dev->state == __WIMAX_ST_NULL)
-               return -EINVAL; /* Device is not even registered! */
-       if (wimax_dev->state == WIMAX_ST_DOWN)
-               return -ENOMEDIUM;
-       if (wimax_dev->state == __WIMAX_ST_QUIESCING)
-               return -ESHUTDOWN;
-       return 0;
-}
-
-
-static inline
-void __wimax_state_set(struct wimax_dev *wimax_dev, enum wimax_st state)
-{
-       wimax_dev->state = state;
-}
-void __wimax_state_change(struct wimax_dev *, enum wimax_st);
-
-#ifdef CONFIG_DEBUG_FS
-void wimax_debugfs_add(struct wimax_dev *);
-void wimax_debugfs_rm(struct wimax_dev *);
-#else
-static inline void wimax_debugfs_add(struct wimax_dev *wimax_dev) {}
-static inline void wimax_debugfs_rm(struct wimax_dev *wimax_dev) {}
-#endif
-
-void wimax_id_table_add(struct wimax_dev *);
-struct wimax_dev *wimax_dev_get_by_genl_info(struct genl_info *, int);
-void wimax_id_table_rm(struct wimax_dev *);
-void wimax_id_table_release(void);
-
-int wimax_rfkill_add(struct wimax_dev *);
-void wimax_rfkill_rm(struct wimax_dev *);
-
-/* generic netlink */
-extern struct genl_family wimax_gnl_family;
-
-/* ops */
-int wimax_gnl_doit_msg_from_user(struct sk_buff *skb, struct genl_info *info);
-int wimax_gnl_doit_reset(struct sk_buff *skb, struct genl_info *info);
-int wimax_gnl_doit_rfkill(struct sk_buff *skb, struct genl_info *info);
-int wimax_gnl_doit_state_get(struct sk_buff *skb, struct genl_info *info);
-
-#endif /* #ifdef __KERNEL__ */
-#endif /* #ifndef __WIMAX_INTERNAL_H__ */
index cf4718c6d35dacc946bee65ce7549ba7daf5a2db..319a1e701163b6c419e3e3ca6f14a69c0ee1c1c0 100644 (file)
@@ -747,7 +747,6 @@ module_platform_driver(optee_driver);
 
 MODULE_AUTHOR("Linaro");
 MODULE_DESCRIPTION("OP-TEE driver");
-MODULE_SUPPORTED_DEVICE("");
 MODULE_VERSION("1.0");
 MODULE_LICENSE("GPL v2");
 MODULE_ALIAS("platform:optee");
index 345917a58f2fd22e9b80481b0c16bb9b343d05b3..1c4aac8464a709d3fb01f667daab973a7cace8b2 100644 (file)
@@ -674,6 +674,9 @@ void thermal_cooling_device_stats_update(struct thermal_cooling_device *cdev,
 {
        struct cooling_dev_stats *stats = cdev->stats;
 
+       if (!stats)
+               return;
+
        spin_lock(&stats->lock);
 
        if (stats->state == new_state)
index b63fecca6c2a1fa9862c7aa77df41338ff89ffa5..2a95b4ce06c0b9c765e0d39475c5ba0b09991a70 100644 (file)
@@ -768,12 +768,6 @@ static int tb_init_port(struct tb_port *port)
 
        tb_dump_port(port->sw->tb, &port->config);
 
-       /* Control port does not need HopID allocation */
-       if (port->port) {
-               ida_init(&port->in_hopids);
-               ida_init(&port->out_hopids);
-       }
-
        INIT_LIST_HEAD(&port->list);
        return 0;
 
@@ -1842,10 +1836,8 @@ static void tb_switch_release(struct device *dev)
        dma_port_free(sw->dma_port);
 
        tb_switch_for_each_port(sw, port) {
-               if (!port->disabled) {
-                       ida_destroy(&port->in_hopids);
-                       ida_destroy(&port->out_hopids);
-               }
+               ida_destroy(&port->in_hopids);
+               ida_destroy(&port->out_hopids);
        }
 
        kfree(sw->uuid);
@@ -2025,6 +2017,12 @@ struct tb_switch *tb_switch_alloc(struct tb *tb, struct device *parent,
                /* minimum setup for tb_find_cap and tb_drom_read to work */
                sw->ports[i].sw = sw;
                sw->ports[i].port = i;
+
+               /* Control port does not need HopID allocation */
+               if (i) {
+                       ida_init(&sw->ports[i].in_hopids);
+                       ida_init(&sw->ports[i].out_hopids);
+               }
        }
 
        ret = tb_switch_find_vse_cap(sw, TB_VSE_CAP_PLUG_EVENTS);
index 1f000ac1728b9a15269ceef1de9223263432e65c..c348b1fc0efc3f84477f1a02921118e274cf300f 100644 (file)
@@ -138,6 +138,10 @@ static void tb_discover_tunnels(struct tb_switch *sw)
                                parent->boot = true;
                                parent = tb_switch_parent(parent);
                        }
+               } else if (tb_tunnel_is_dp(tunnel)) {
+                       /* Keep the domain from powering down */
+                       pm_runtime_get_sync(&tunnel->src_port->sw->dev);
+                       pm_runtime_get_sync(&tunnel->dst_port->sw->dev);
                }
 
                list_add_tail(&tunnel->list, &tcm->tunnel_list);
index c908489196442d9a1a7792a470c2469905e3a09d..9afa1dcef2c2f247fceb509a3153f59808078d5f 100644 (file)
@@ -317,7 +317,6 @@ static void hvcs_hangup(struct tty_struct * tty);
 
 static int hvcs_probe(struct vio_dev *dev,
                const struct vio_device_id *id);
-static int hvcs_remove(struct vio_dev *dev);
 static int __init hvcs_module_init(void);
 static void __exit hvcs_module_exit(void);
 static int hvcs_initialize(void);
@@ -819,7 +818,7 @@ static int hvcs_probe(
        return 0;
 }
 
-static int hvcs_remove(struct vio_dev *dev)
+static void hvcs_remove(struct vio_dev *dev)
 {
        struct hvcs_struct *hvcsd = dev_get_drvdata(&dev->dev);
        unsigned long flags;
@@ -849,7 +848,6 @@ static int hvcs_remove(struct vio_dev *dev)
 
        printk(KERN_INFO "HVCS: vty-server@%X removed from the"
                        " vio bus.\n", dev->unit_address);
-       return 0;
 };
 
 static struct vio_driver hvcs_vio_driver = {
index 8b2797b6ee4417e4fe85050b44747c46f4403004..5e2374580e271395151039b96fd3fbf1d177e884 100644 (file)
@@ -66,8 +66,7 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
        wake_up_interruptible(&tty->link->read_wait);
        wake_up_interruptible(&tty->link->write_wait);
        if (tty->driver->subtype == PTY_TYPE_MASTER) {
-               struct file *f;
-
+               set_bit(TTY_OTHER_CLOSED, &tty->flags);
 #ifdef CONFIG_UNIX98_PTYS
                if (tty->driver == ptm_driver) {
                        mutex_lock(&devpts_mutex);
@@ -76,17 +75,7 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
                        mutex_unlock(&devpts_mutex);
                }
 #endif
-
-               /*
-                * This hack is required because a program can open a
-                * pty and redirect a console to it, but if the pty is
-                * closed and the console is not released, then the
-                * slave side will never close.  So release the
-                * redirect when the master closes.
-                */
-               f = tty_release_redirect(tty->link);
-               if (f)
-                       fput(f);
+               tty_vhangup(tty->link);
        }
 }
 
index 9a872750581c93c90f8177e7b769049b5587f147..94af7a5ea4975c5a213fee40d3609c657420ca4d 100644 (file)
@@ -1639,8 +1639,6 @@ module_exit(icom_exit);
 
 MODULE_AUTHOR("Michael Anderson <mjanders@us.ibm.com>");
 MODULE_DESCRIPTION("IBM iSeries Serial IOA driver");
-MODULE_SUPPORTED_DEVICE
-    ("IBM iSeries 2745, 2771, 2772, 2742, 2793 and 2805 Communications adapters");
 MODULE_LICENSE("GPL");
 MODULE_FIRMWARE("icom_call_setup.bin");
 MODULE_FIRMWARE("icom_res_dce.bin");
index cd30da0ef08344a2bb0342f6c705c4e3f6438c3f..0ea799bf8dbb1c58161e617929dcbb785d9f29dc 100644 (file)
@@ -19,7 +19,6 @@
 MODULE_AUTHOR("Digi International, https://www.digi.com");
 MODULE_DESCRIPTION("Driver for the Digi International Neo and Classic PCI based product line");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("jsm");
 
 #define JSM_DRIVER_NAME "jsm"
 #define NR_PORTS       32
index 9795b2e8b0b2cc96ed2a1f5b2a5b6ca5f72da887..1b61d26bb7afe48ce862f884420d31a72f549c71 100644 (file)
@@ -1056,9 +1056,9 @@ static int max310x_startup(struct uart_port *port)
        max310x_port_update(port, MAX310X_MODE1_REG,
                            MAX310X_MODE1_TRNSCVCTRL_BIT, 0);
 
-       /* Reset FIFOs */
-       max310x_port_write(port, MAX310X_MODE2_REG,
-                          MAX310X_MODE2_FIFORST_BIT);
+       /* Configure MODE2 register & Reset FIFOs*/
+       val = MAX310X_MODE2_RXEMPTINV_BIT | MAX310X_MODE2_FIFORST_BIT;
+       max310x_port_write(port, MAX310X_MODE2_REG, val);
        max310x_port_update(port, MAX310X_MODE2_REG,
                            MAX310X_MODE2_FIFORST_BIT, 0);
 
@@ -1086,27 +1086,8 @@ static int max310x_startup(struct uart_port *port)
        /* Clear IRQ status register */
        max310x_port_read(port, MAX310X_IRQSTS_REG);
 
-       /*
-        * Let's ask for an interrupt after a timeout equivalent to
-        * the receiving time of 4 characters after the last character
-        * has been received.
-        */
-       max310x_port_write(port, MAX310X_RXTO_REG, 4);
-
-       /*
-        * Make sure we also get RX interrupts when the RX FIFO is
-        * filling up quickly, so get an interrupt when half of the RX
-        * FIFO has been filled in.
-        */
-       max310x_port_write(port, MAX310X_FIFOTRIGLVL_REG,
-                          MAX310X_FIFOTRIGLVL_RX(MAX310X_FIFO_SIZE / 2));
-
-       /* Enable RX timeout interrupt in LSR */
-       max310x_port_write(port, MAX310X_LSR_IRQEN_REG,
-                          MAX310X_LSR_RXTO_BIT);
-
-       /* Enable LSR, RX FIFO trigger, CTS change interrupts */
-       val = MAX310X_IRQ_LSR_BIT  | MAX310X_IRQ_RXFIFO_BIT | MAX310X_IRQ_TXEMPTY_BIT;
+       /* Enable RX, TX, CTS change interrupts */
+       val = MAX310X_IRQ_RXEMPTY_BIT | MAX310X_IRQ_TXEMPTY_BIT;
        max310x_port_write(port, MAX310X_IRQEN_REG, val | MAX310X_IRQ_CTS_BIT);
 
        return 0;
index 74733ec8f565367bbd9aa8d03d684a127aec11f0..391bada4cedb62f765af58a8e38c2440a02b9ff4 100644 (file)
@@ -544,9 +544,7 @@ EXPORT_SYMBOL_GPL(tty_wakeup);
  *     @tty: tty device
  *
  *     This is available to the pty code so if the master closes, if the
- *     slave is a redirect it can release the redirect.  It returns the
- *     filp for the redirect, which must be fput when the operations on
- *     the tty are completed.
+ *     slave is a redirect it can release the redirect.
  */
 struct file *tty_release_redirect(struct tty_struct *tty)
 {
@@ -561,6 +559,7 @@ struct file *tty_release_redirect(struct tty_struct *tty)
 
        return f;
 }
+EXPORT_SYMBOL_GPL(tty_release_redirect);
 
 /**
  *     __tty_hangup            -       actual handler for hangup events
index f9170d177a899baf9c5d638637f4164ea7507ac9..5f0513c96c04ec768a8ca3f29854d6cebf717535 100644 (file)
@@ -2197,7 +2197,10 @@ static int cdnsp_queue_isoc_tx(struct cdnsp_device *pdev,
         * inverted in the first TDs isoc TRB.
         */
        field = TRB_TYPE(TRB_ISOC) | TRB_TLBPC(last_burst_pkt) |
-               start_cycle ? 0 : 1 | TRB_SIA | TRB_TBC(burst_count);
+               TRB_SIA | TRB_TBC(burst_count);
+
+       if (!start_cycle)
+               field |= TRB_CYCLE;
 
        /* Fill the rest of the TRB fields, and remaining normal TRBs. */
        for (i = 0; i < trbs_per_td; i++) {
index 37f824b59daae8f96f7c2660adff672215956ef2..39ddb5585ded5059003106ce22eef1a3e5c01646 100644 (file)
@@ -1935,6 +1935,11 @@ static const struct usb_device_id acm_ids[] = {
        .driver_info = SEND_ZERO_PACKET,
        },
 
+       /* Exclude Goodix Fingerprint Reader */
+       { USB_DEVICE(0x27c6, 0x5395),
+       .driver_info = IGNORE_DEVICE,
+       },
+
        /* control interfaces without any protocol set */
        { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
                USB_CDC_PROTO_NONE) },
index c9f6e975828852f09206ca11ed84c0fb6582e21c..f27b4aecff3d497f0122de042a8b5d06881565be 100644 (file)
@@ -494,16 +494,24 @@ static int usblp_release(struct inode *inode, struct file *file)
 /* No kernel lock - fine */
 static __poll_t usblp_poll(struct file *file, struct poll_table_struct *wait)
 {
-       __poll_t ret;
+       struct usblp *usblp = file->private_data;
+       __poll_t ret = 0;
        unsigned long flags;
 
-       struct usblp *usblp = file->private_data;
        /* Should we check file->f_mode & FMODE_WRITE before poll_wait()? */
        poll_wait(file, &usblp->rwait, wait);
        poll_wait(file, &usblp->wwait, wait);
+
+       mutex_lock(&usblp->mut);
+       if (!usblp->present)
+               ret |= EPOLLHUP;
+       mutex_unlock(&usblp->mut);
+
        spin_lock_irqsave(&usblp->lock, flags);
-       ret = ((usblp->bidir && usblp->rcomplete) ? EPOLLIN  | EPOLLRDNORM : 0) |
-          ((usblp->no_paper || usblp->wcomplete) ? EPOLLOUT | EPOLLWRNORM : 0);
+       if (usblp->bidir && usblp->rcomplete)
+               ret |= EPOLLIN  | EPOLLRDNORM;
+       if (usblp->no_paper || usblp->wcomplete)
+               ret |= EPOLLOUT | EPOLLWRNORM;
        spin_unlock_irqrestore(&usblp->lock, flags);
        return ret;
 }
index 8f07b051610096d3957702c255d44b8183103ef2..a566bb494e246b852578130522539d577f06d256 100644 (file)
@@ -748,6 +748,38 @@ void usb_put_intf(struct usb_interface *intf)
 }
 EXPORT_SYMBOL_GPL(usb_put_intf);
 
+/**
+ * usb_intf_get_dma_device - acquire a reference on the usb interface's DMA endpoint
+ * @intf: the usb interface
+ *
+ * While a USB device cannot perform DMA operations by itself, many USB
+ * controllers can. A call to usb_intf_get_dma_device() returns the DMA endpoint
+ * for the given USB interface, if any. The returned device structure must be
+ * released with put_device().
+ *
+ * See also usb_get_dma_device().
+ *
+ * Returns: A reference to the usb interface's DMA endpoint; or NULL if none
+ *          exists.
+ */
+struct device *usb_intf_get_dma_device(struct usb_interface *intf)
+{
+       struct usb_device *udev = interface_to_usbdev(intf);
+       struct device *dmadev;
+
+       if (!udev->bus)
+               return NULL;
+
+       dmadev = get_device(udev->bus->sysdev);
+       if (!dmadev || !dmadev->dma_mask) {
+               put_device(dmadev);
+               return NULL;
+       }
+
+       return dmadev;
+}
+EXPORT_SYMBOL_GPL(usb_intf_get_dma_device);
+
 /*                     USB device locking
  *
  * USB devices and interfaces are locked using the semaphore in their
index 846a47be6df7f7bebde8b1b644cf49b6ba07acef..fcaf04483ad0248834ae14d5be121aa4e9b29c02 100644 (file)
@@ -358,8 +358,10 @@ static int dwc3_qcom_suspend(struct dwc3_qcom *qcom)
        if (ret)
                dev_warn(qcom->dev, "failed to disable interconnect: %d\n", ret);
 
+       if (device_may_wakeup(qcom->dev))
+               dwc3_qcom_enable_interrupts(qcom);
+
        qcom->is_suspended = true;
-       dwc3_qcom_enable_interrupts(qcom);
 
        return 0;
 }
@@ -372,7 +374,8 @@ static int dwc3_qcom_resume(struct dwc3_qcom *qcom)
        if (!qcom->is_suspended)
                return 0;
 
-       dwc3_qcom_disable_interrupts(qcom);
+       if (device_may_wakeup(qcom->dev))
+               dwc3_qcom_disable_interrupts(qcom);
 
        for (i = 0; i < qcom->num_clocks; i++) {
                ret = clk_prepare_enable(qcom->clks[i]);
@@ -650,16 +653,19 @@ static int dwc3_qcom_of_register_core(struct platform_device *pdev)
        ret = of_platform_populate(np, NULL, NULL, dev);
        if (ret) {
                dev_err(dev, "failed to register dwc3 core - %d\n", ret);
-               return ret;
+               goto node_put;
        }
 
        qcom->dwc3 = of_find_device_by_node(dwc3_np);
        if (!qcom->dwc3) {
+               ret = -ENODEV;
                dev_err(dev, "failed to get dwc3 platform device\n");
-               return -ENODEV;
        }
 
-       return 0;
+node_put:
+       of_node_put(dwc3_np);
+
+       return ret;
 }
 
 static struct platform_device *
@@ -938,6 +944,8 @@ static const struct dwc3_acpi_pdata sdm845_acpi_urs_pdata = {
 static const struct acpi_device_id dwc3_qcom_acpi_match[] = {
        { "QCOM2430", (unsigned long)&sdm845_acpi_pdata },
        { "QCOM0304", (unsigned long)&sdm845_acpi_urs_pdata },
+       { "QCOM0497", (unsigned long)&sdm845_acpi_urs_pdata },
+       { "QCOM04A6", (unsigned long)&sdm845_acpi_pdata },
        { },
 };
 MODULE_DEVICE_TABLE(acpi, dwc3_qcom_acpi_match);
index aebcf8ec071639da21f0b698807fa5813890a65e..4a337f3486510931aa655cf1b19e75eaeebf8f66 100644 (file)
@@ -783,8 +783,6 @@ static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep)
 
        trace_dwc3_gadget_ep_disable(dep);
 
-       dwc3_remove_requests(dwc, dep);
-
        /* make sure HW endpoint isn't stalled */
        if (dep->flags & DWC3_EP_STALL)
                __dwc3_gadget_ep_set_halt(dep, 0, false);
@@ -803,6 +801,8 @@ static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep)
                dep->endpoint.desc = NULL;
        }
 
+       dwc3_remove_requests(dwc, dep);
+
        return 0;
 }
 
@@ -1617,7 +1617,7 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req)
 {
        struct dwc3             *dwc = dep->dwc;
 
-       if (!dep->endpoint.desc || !dwc->pullups_connected) {
+       if (!dep->endpoint.desc || !dwc->pullups_connected || !dwc->connected) {
                dev_err(dwc->dev, "%s: can't queue to disabled endpoint\n",
                                dep->name);
                return -ESHUTDOWN;
@@ -2247,6 +2247,7 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
        if (!is_on) {
                u32 count;
 
+               dwc->connected = false;
                /*
                 * In the Synopsis DesignWare Cores USB3 Databook Rev. 3.30a
                 * Section 4.1.8 Table 4-7, it states that for a device-initiated
@@ -2271,7 +2272,6 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
                        dwc->ev_buf->lpos = (dwc->ev_buf->lpos + count) %
                                                dwc->ev_buf->length;
                }
-               dwc->connected = false;
        } else {
                __dwc3_gadget_start(dwc);
        }
@@ -3321,8 +3321,6 @@ static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc)
 {
        u32                     reg;
 
-       dwc->connected = true;
-
        /*
         * WORKAROUND: DWC3 revisions <1.88a have an issue which
         * would cause a missing Disconnect Event if there's a
@@ -3362,6 +3360,7 @@ static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc)
         * transfers."
         */
        dwc3_stop_active_transfers(dwc);
+       dwc->connected = true;
 
        reg = dwc3_readl(dwc->regs, DWC3_DCTL);
        reg &= ~DWC3_DCTL_TSTCTRL_MASK;
index 0d56f33d63c29e170828547c13fbb37e6fe5fae2..15a607ccef8a23896fbb3019a0341a9dc5d192e0 100644 (file)
@@ -97,6 +97,8 @@ struct gadget_config_name {
        struct list_head list;
 };
 
+#define USB_MAX_STRING_WITH_NULL_LEN   (USB_MAX_STRING_LEN+1)
+
 static int usb_string_copy(const char *s, char **s_copy)
 {
        int ret;
@@ -106,12 +108,16 @@ static int usb_string_copy(const char *s, char **s_copy)
        if (ret > USB_MAX_STRING_LEN)
                return -EOVERFLOW;
 
-       str = kstrdup(s, GFP_KERNEL);
-       if (!str)
-               return -ENOMEM;
+       if (copy) {
+               str = copy;
+       } else {
+               str = kmalloc(USB_MAX_STRING_WITH_NULL_LEN, GFP_KERNEL);
+               if (!str)
+                       return -ENOMEM;
+       }
+       strcpy(str, s);
        if (str[ret - 1] == '\n')
                str[ret - 1] = '\0';
-       kfree(copy);
        *s_copy = str;
        return 0;
 }
index 00d346965f7a553fa0120b599c12ad8db1776da9..560382e0a8f38d2b79502c9211b69a7cf1281a40 100644 (file)
@@ -499,6 +499,7 @@ static void f_audio_disable(struct usb_function *f)
        uac1->as_out_alt = 0;
        uac1->as_in_alt = 0;
 
+       u_audio_stop_playback(&uac1->g_audio);
        u_audio_stop_capture(&uac1->g_audio);
 }
 
index 5d960b6603b6f0f67e2590bb50aa0809edcd4481..6f03e944e0e31e8a7b6ac230daa9602046cd8923 100644 (file)
@@ -478,7 +478,7 @@ static int set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts,
        }
 
        max_size_bw = num_channels(chmask) * ssize *
-               DIV_ROUND_UP(srate, factor / (1 << (ep_desc->bInterval - 1)));
+               ((srate / (factor / (1 << (ep_desc->bInterval - 1)))) + 1);
        ep_desc->wMaxPacketSize = cpu_to_le16(min_t(u16, max_size_bw,
                                                    max_size_ep));
 
index 3dfb460908fae4f5722327aa44a534cdabfeae43..f558c3139ebe50d67b63a92cdc4bc0786998e23a 100644 (file)
@@ -182,12 +182,11 @@ out:                                                                      \
                                                size_t len)             \
        {                                                               \
                struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item);  \
-               int ret;                                                \
+               int ret = -EINVAL;                                      \
                u8 val;                                                 \
                                                                        \
                mutex_lock(&opts->lock);                                \
-               ret = sscanf(page, "%02hhx", &val);                     \
-               if (ret > 0) {                                          \
+               if (sscanf(page, "%02hhx", &val) > 0) {                 \
                        opts->_n_ = val;                                \
                        ret = len;                                      \
                }                                                       \
index f1ea51476add0ffcef423e618b48714852f2e46e..1d3ebb07ccd4d8cfb9173c66e200f428eacf30c0 100644 (file)
@@ -1773,8 +1773,8 @@ static int s3c2410_udc_probe(struct platform_device *pdev)
        udc_info = dev_get_platdata(&pdev->dev);
 
        base_addr = devm_platform_ioremap_resource(pdev, 0);
-       if (!base_addr) {
-               retval = -ENOMEM;
+       if (IS_ERR(base_addr)) {
+               retval = PTR_ERR(base_addr);
                goto err_mem;
        }
 
index 84da8406d5b42415d9adcf276bc24d49de860423..5bbccc9a0179fff56b1799d35935db1f332adf08 100644 (file)
@@ -66,6 +66,7 @@
 #define PCI_DEVICE_ID_ASMEDIA_1042A_XHCI               0x1142
 #define PCI_DEVICE_ID_ASMEDIA_1142_XHCI                        0x1242
 #define PCI_DEVICE_ID_ASMEDIA_2142_XHCI                        0x2142
+#define PCI_DEVICE_ID_ASMEDIA_3242_XHCI                        0x3242
 
 static const char hcd_name[] = "xhci_hcd";
 
@@ -276,11 +277,14 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
                pdev->device == PCI_DEVICE_ID_ASMEDIA_1042_XHCI)
                xhci->quirks |= XHCI_BROKEN_STREAMS;
        if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA &&
-               pdev->device == PCI_DEVICE_ID_ASMEDIA_1042A_XHCI)
+               pdev->device == PCI_DEVICE_ID_ASMEDIA_1042A_XHCI) {
                xhci->quirks |= XHCI_TRUST_TX_LENGTH;
+               xhci->quirks |= XHCI_NO_64BIT_SUPPORT;
+       }
        if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA &&
            (pdev->device == PCI_DEVICE_ID_ASMEDIA_1142_XHCI ||
-            pdev->device == PCI_DEVICE_ID_ASMEDIA_2142_XHCI))
+            pdev->device == PCI_DEVICE_ID_ASMEDIA_2142_XHCI ||
+            pdev->device == PCI_DEVICE_ID_ASMEDIA_3242_XHCI))
                xhci->quirks |= XHCI_NO_64BIT_SUPPORT;
 
        if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA &&
@@ -295,6 +299,11 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
             pdev->device == 0x9026)
                xhci->quirks |= XHCI_RESET_PLL_ON_DISCONNECT;
 
+       if (pdev->vendor == PCI_VENDOR_ID_AMD &&
+           (pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_2 ||
+            pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_4))
+               xhci->quirks |= XHCI_NO_SOFT_RETRY;
+
        if (xhci->quirks & XHCI_RESET_ON_RESUME)
                xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
                                "QUIRK: Resetting on resume");
index 5e548a1c93ab1a9cafc84d60566bab6f8894c1f1..ce38076901e25036a9b480b81e65fe0ec7466b62 100644 (file)
@@ -2484,7 +2484,8 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td,
                remaining       = 0;
                break;
        case COMP_USB_TRANSACTION_ERROR:
-               if ((ep_ring->err_count++ > MAX_SOFT_RETRY) ||
+               if (xhci->quirks & XHCI_NO_SOFT_RETRY ||
+                   (ep_ring->err_count++ > MAX_SOFT_RETRY) ||
                    le32_to_cpu(slot_ctx->tt_info) & TT_SLOT)
                        break;
 
index bd27bd670104ce48f89daf1c602d9f41d13acd0e..1975016f46bff6fc6a75419994726181d2baf7d3 100644 (file)
@@ -883,44 +883,42 @@ static void xhci_clear_command_ring(struct xhci_hcd *xhci)
        xhci_set_cmd_ring_deq(xhci);
 }
 
-static void xhci_disable_port_wake_on_bits(struct xhci_hcd *xhci)
+/*
+ * Disable port wake bits if do_wakeup is not set.
+ *
+ * Also clear a possible internal port wake state left hanging for ports that
+ * detected termination but never successfully enumerated (trained to 0U).
+ * Internal wake causes immediate xHCI wake after suspend. PORT_CSC write done
+ * at enumeration clears this wake, force one here as well for unconnected ports
+ */
+
+static void xhci_disable_hub_port_wake(struct xhci_hcd *xhci,
+                                      struct xhci_hub *rhub,
+                                      bool do_wakeup)
 {
-       struct xhci_port **ports;
-       int port_index;
        unsigned long flags;
        u32 t1, t2, portsc;
+       int i;
 
        spin_lock_irqsave(&xhci->lock, flags);
 
-       /* disable usb3 ports Wake bits */
-       port_index = xhci->usb3_rhub.num_ports;
-       ports = xhci->usb3_rhub.ports;
-       while (port_index--) {
-               t1 = readl(ports[port_index]->addr);
-               portsc = t1;
-               t1 = xhci_port_state_to_neutral(t1);
-               t2 = t1 & ~PORT_WAKE_BITS;
-               if (t1 != t2) {
-                       writel(t2, ports[port_index]->addr);
-                       xhci_dbg(xhci, "disable wake bits port %d-%d, portsc: 0x%x, write: 0x%x\n",
-                                xhci->usb3_rhub.hcd->self.busnum,
-                                port_index + 1, portsc, t2);
-               }
-       }
+       for (i = 0; i < rhub->num_ports; i++) {
+               portsc = readl(rhub->ports[i]->addr);
+               t1 = xhci_port_state_to_neutral(portsc);
+               t2 = t1;
+
+               /* clear wake bits if do_wake is not set */
+               if (!do_wakeup)
+                       t2 &= ~PORT_WAKE_BITS;
+
+               /* Don't touch csc bit if connected or connect change is set */
+               if (!(portsc & (PORT_CSC | PORT_CONNECT)))
+                       t2 |= PORT_CSC;
 
-       /* disable usb2 ports Wake bits */
-       port_index = xhci->usb2_rhub.num_ports;
-       ports = xhci->usb2_rhub.ports;
-       while (port_index--) {
-               t1 = readl(ports[port_index]->addr);
-               portsc = t1;
-               t1 = xhci_port_state_to_neutral(t1);
-               t2 = t1 & ~PORT_WAKE_BITS;
                if (t1 != t2) {
-                       writel(t2, ports[port_index]->addr);
-                       xhci_dbg(xhci, "disable wake bits port %d-%d, portsc: 0x%x, write: 0x%x\n",
-                                xhci->usb2_rhub.hcd->self.busnum,
-                                port_index + 1, portsc, t2);
+                       writel(t2, rhub->ports[i]->addr);
+                       xhci_dbg(xhci, "config port %d-%d wake bits, portsc: 0x%x, write: 0x%x\n",
+                                rhub->hcd->self.busnum, i + 1, portsc, t2);
                }
        }
        spin_unlock_irqrestore(&xhci->lock, flags);
@@ -983,8 +981,8 @@ int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup)
                return -EINVAL;
 
        /* Clear root port wake on bits if wakeup not allowed. */
-       if (!do_wakeup)
-               xhci_disable_port_wake_on_bits(xhci);
+       xhci_disable_hub_port_wake(xhci, &xhci->usb3_rhub, do_wakeup);
+       xhci_disable_hub_port_wake(xhci, &xhci->usb2_rhub, do_wakeup);
 
        if (!HCD_HW_ACCESSIBLE(hcd))
                return 0;
@@ -1088,6 +1086,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
        struct usb_hcd          *secondary_hcd;
        int                     retval = 0;
        bool                    comp_timer_running = false;
+       bool                    pending_portevent = false;
 
        if (!hcd->state)
                return 0;
@@ -1226,13 +1225,22 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
 
  done:
        if (retval == 0) {
-               /* Resume root hubs only when have pending events. */
-               if (xhci_pending_portevent(xhci)) {
+               /*
+                * Resume roothubs only if there are pending events.
+                * USB 3 devices resend U3 LFPS wake after a 100ms delay if
+                * the first wake signalling failed, give it that chance.
+                */
+               pending_portevent = xhci_pending_portevent(xhci);
+               if (!pending_portevent) {
+                       msleep(120);
+                       pending_portevent = xhci_pending_portevent(xhci);
+               }
+
+               if (pending_portevent) {
                        usb_hcd_resume_root_hub(xhci->shared_hcd);
                        usb_hcd_resume_root_hub(hcd);
                }
        }
-
        /*
         * If system is subject to the Quirk, Compliance Mode Timer needs to
         * be re-initialized Always after a system resume. Ports are subject
index d41de5dc0452ef816a56b8b3afa12a09c9a6e70f..ca822ad3b65b0f6383b11edd2aedfdf27f2768cd 100644 (file)
@@ -1891,6 +1891,7 @@ struct xhci_hcd {
 #define XHCI_SKIP_PHY_INIT     BIT_ULL(37)
 #define XHCI_DISABLE_SPARSE    BIT_ULL(38)
 #define XHCI_SG_TRB_CACHE_SIZE_QUIRK   BIT_ULL(39)
+#define XHCI_NO_SOFT_RETRY     BIT_ULL(40)
 
        unsigned int            num_active_eps;
        unsigned int            limit_active_eps;
index 670e4d91e9cae09e66e154dfa69e66f79b2f63a0..dcc88df72df426705e351fa511809451b821cc11 100644 (file)
@@ -117,7 +117,6 @@ MODULE_DEVICE_TABLE(usb, ld_usb_table);
 MODULE_AUTHOR("Michael Hund <mhund@ld-didactic.de>");
 MODULE_DESCRIPTION("LD USB Driver");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("LD USB Devices");
 
 /* All interrupt in transfers are collected in a ring buffer to
  * avoid racing conditions and get better performance of the driver.
index e7334b7fb3a62dd200b5541ae984a6e92a39ffdf..75fff2e4cbc65ff64211e95e1990e99d23063d9e 100644 (file)
@@ -746,6 +746,8 @@ struct usbhs_pipe *usbhs_pipe_malloc(struct usbhs_priv *priv,
 
 void usbhs_pipe_free(struct usbhs_pipe *pipe)
 {
+       usbhsp_pipe_select(pipe);
+       usbhsp_pipe_cfg_set(pipe, 0xFFFF, 0);
        usbhsp_put_pipe(pipe);
 }
 
index 8d997b71056f6560944e3f6d24c46093a32d75e6..2db917eab79952b3ae8e9d55a7a84c080c2e1881 100644 (file)
@@ -86,6 +86,7 @@ static const struct usb_device_id id_table[] = {
        { USB_DEVICE(0x1a86, 0x7522) },
        { USB_DEVICE(0x1a86, 0x7523) },
        { USB_DEVICE(0x4348, 0x5523) },
+       { USB_DEVICE(0x9986, 0x7523) },
        { },
 };
 MODULE_DEVICE_TABLE(usb, id_table);
index 9e1c609792fb0241370db38e58a647f6c26a5dce..a373cd63b3a44f7d5cb2f7646d3d51a6149b7137 100644 (file)
@@ -145,6 +145,7 @@ static const struct usb_device_id id_table[] = {
        { USB_DEVICE(0x10C4, 0x8857) }, /* CEL EM357 ZigBee USB Stick */
        { USB_DEVICE(0x10C4, 0x88A4) }, /* MMB Networks ZigBee USB Device */
        { USB_DEVICE(0x10C4, 0x88A5) }, /* Planet Innovation Ingeni ZigBee USB Device */
+       { USB_DEVICE(0x10C4, 0x88D8) }, /* Acuity Brands nLight Air Adapter */
        { USB_DEVICE(0x10C4, 0x88FB) }, /* CESINEL MEDCAL STII Network Analyzer */
        { USB_DEVICE(0x10C4, 0x8938) }, /* CESINEL MEDCAL S II Network Analyzer */
        { USB_DEVICE(0x10C4, 0x8946) }, /* Ketra N1 Wireless Interface */
@@ -201,6 +202,8 @@ static const struct usb_device_id id_table[] = {
        { USB_DEVICE(0x1901, 0x0194) }, /* GE Healthcare Remote Alarm Box */
        { USB_DEVICE(0x1901, 0x0195) }, /* GE B850/B650/B450 CP2104 DP UART interface */
        { USB_DEVICE(0x1901, 0x0196) }, /* GE B850 CP2105 DP UART interface */
+       { USB_DEVICE(0x1901, 0x0197) }, /* GE CS1000 Display serial interface */
+       { USB_DEVICE(0x1901, 0x0198) }, /* GE CS1000 M.2 Key E serial interface */
        { USB_DEVICE(0x199B, 0xBA30) }, /* LORD WSDA-200-USB */
        { USB_DEVICE(0x19CF, 0x3000) }, /* Parrot NMEA GPS Flight Recorder */
        { USB_DEVICE(0x1ADB, 0x0001) }, /* Schweitzer Engineering C662 Cable */
index a493670c06e61bec880ed1e00be2c32fa401de0f..68401adcffde590b8f9daefe343b9b688bb07c09 100644 (file)
@@ -3003,26 +3003,32 @@ static int edge_startup(struct usb_serial *serial)
                                response = -ENODEV;
                        }
 
-                       usb_free_urb(edge_serial->interrupt_read_urb);
-                       kfree(edge_serial->interrupt_in_buffer);
-
-                       usb_free_urb(edge_serial->read_urb);
-                       kfree(edge_serial->bulk_in_buffer);
-
-                       kfree(edge_serial);
-
-                       return response;
+                       goto error;
                }
 
                /* start interrupt read for this edgeport this interrupt will
                 * continue as long as the edgeport is connected */
                response = usb_submit_urb(edge_serial->interrupt_read_urb,
                                                                GFP_KERNEL);
-               if (response)
+               if (response) {
                        dev_err(ddev, "%s - Error %d submitting control urb\n",
                                __func__, response);
+
+                       goto error;
+               }
        }
        return response;
+
+error:
+       usb_free_urb(edge_serial->interrupt_read_urb);
+       kfree(edge_serial->interrupt_in_buffer);
+
+       usb_free_urb(edge_serial->read_urb);
+       kfree(edge_serial->bulk_in_buffer);
+
+       kfree(edge_serial);
+
+       return response;
 }
 
 
index 483d07dee19de546621c3b4381a6d577edd5e63d..0ca04906da4bf2b59f9bf0b2139f1402dfbd14e1 100644 (file)
@@ -545,37 +545,13 @@ static void xr_close(struct usb_serial_port *port)
 
 static int xr_probe(struct usb_serial *serial, const struct usb_device_id *id)
 {
-       struct usb_driver *driver = serial->type->usb_driver;
-       struct usb_interface *control_interface;
-       int ret;
-
        /* Don't bind to control interface */
        if (serial->interface->cur_altsetting->desc.bInterfaceNumber == 0)
                return -ENODEV;
 
-       /* But claim the control interface during data interface probe */
-       control_interface = usb_ifnum_to_if(serial->dev, 0);
-       if (!control_interface)
-               return -ENODEV;
-
-       ret = usb_driver_claim_interface(driver, control_interface, NULL);
-       if (ret) {
-               dev_err(&serial->interface->dev, "Failed to claim control interface\n");
-               return ret;
-       }
-
        return 0;
 }
 
-static void xr_disconnect(struct usb_serial *serial)
-{
-       struct usb_driver *driver = serial->type->usb_driver;
-       struct usb_interface *control_interface;
-
-       control_interface = usb_ifnum_to_if(serial->dev, 0);
-       usb_driver_release_interface(driver, control_interface);
-}
-
 static const struct usb_device_id id_table[] = {
        { USB_DEVICE(0x04e2, 0x1410) }, /* XR21V141X */
        { }
@@ -590,7 +566,6 @@ static struct usb_serial_driver xr_device = {
        .id_table               = id_table,
        .num_ports              = 1,
        .probe                  = xr_probe,
-       .disconnect             = xr_disconnect,
        .open                   = xr_open,
        .close                  = xr_close,
        .break_ctl              = xr_break_ctl,
index 5eb895b19c5584fe44f5befab26e1ae84efb56e3..f4304ce69350e38ff8053fcb728c51f4df608569 100644 (file)
@@ -656,6 +656,13 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
                need_auto_sense = 1;
        }
 
+       /* Some devices (Kindle) require another command after SYNC CACHE */
+       if ((us->fflags & US_FL_SENSE_AFTER_SYNC) &&
+                       srb->cmnd[0] == SYNCHRONIZE_CACHE) {
+               usb_stor_dbg(us, "-- sense after SYNC CACHE\n");
+               need_auto_sense = 1;
+       }
+
        /*
         * If we have a failure, we're going to do a REQUEST_SENSE 
         * automatically.  Note that we differentiate between a command
index 5732e9691f08f2f8a3c2661a3feaa46f6dcbbac6..efa972be2ee346fec9c00ec252a85e233f7decae 100644 (file)
@@ -2211,6 +2211,18 @@ UNUSUAL_DEV( 0x1908, 0x3335, 0x0200, 0x0200,
                USB_SC_DEVICE, USB_PR_DEVICE, NULL,
                US_FL_NO_READ_DISC_INFO ),
 
+/*
+ * Reported by Matthias Schwarzott <zzam@gentoo.org>
+ * The Amazon Kindle treats SYNCHRONIZE CACHE as an indication that
+ * the host may be finished with it, and automatically ejects its
+ * emulated media unless it receives another command within one second.
+ */
+UNUSUAL_DEV( 0x1949, 0x0004, 0x0000, 0x9999,
+               "Amazon",
+               "Kindle",
+               USB_SC_DEVICE, USB_PR_DEVICE, NULL,
+               US_FL_SENSE_AFTER_SYNC ),
+
 /*
  * Reported by Oliver Neukum <oneukum@suse.com>
  * This device morphes spontaneously into another device if the access
index be0b6469dd3dfb372109074e5c03459930c74bbc..ce7af398c7c1c1f29d7b98995375ee52dc8a3a72 100644 (file)
@@ -942,6 +942,7 @@ static int tcpm_set_current_limit(struct tcpm_port *port, u32 max_ma, u32 mv)
 
        port->supply_voltage = mv;
        port->current_limit = max_ma;
+       power_supply_changed(port->psy);
 
        if (port->tcpc->set_current_limit)
                ret = port->tcpc->set_current_limit(port->tcpc, max_ma, mv);
@@ -2928,6 +2929,7 @@ static int tcpm_pd_select_pdo(struct tcpm_port *port, int *sink_pdo,
 
        port->pps_data.supported = false;
        port->usb_type = POWER_SUPPLY_USB_TYPE_PD;
+       power_supply_changed(port->psy);
 
        /*
         * Select the source PDO providing the most power which has a
@@ -2952,6 +2954,7 @@ static int tcpm_pd_select_pdo(struct tcpm_port *port, int *sink_pdo,
                                port->pps_data.supported = true;
                                port->usb_type =
                                        POWER_SUPPLY_USB_TYPE_PD_PPS;
+                               power_supply_changed(port->psy);
                        }
                        continue;
                default:
@@ -3109,6 +3112,7 @@ static unsigned int tcpm_pd_select_pps_apdo(struct tcpm_port *port)
                                                  port->pps_data.out_volt));
                port->pps_data.op_curr = min(port->pps_data.max_curr,
                                             port->pps_data.op_curr);
+               power_supply_changed(port->psy);
        }
 
        return src_pdo;
@@ -3344,6 +3348,7 @@ static int tcpm_set_charge(struct tcpm_port *port, bool charge)
                        return ret;
        }
        port->vbus_charge = charge;
+       power_supply_changed(port->psy);
        return 0;
 }
 
@@ -3523,6 +3528,7 @@ static void tcpm_reset_port(struct tcpm_port *port)
        port->try_src_count = 0;
        port->try_snk_count = 0;
        port->usb_type = POWER_SUPPLY_USB_TYPE_C;
+       power_supply_changed(port->psy);
        port->nr_sink_caps = 0;
        port->sink_cap_done = false;
        if (port->tcpc->enable_frs)
@@ -5167,7 +5173,7 @@ static void tcpm_enable_frs_work(struct kthread_work *work)
                goto unlock;
 
        /* Send when the state machine is idle */
-       if (port->state != SNK_READY || port->vdm_state != VDM_STATE_DONE || port->send_discover)
+       if (port->state != SNK_READY || port->vdm_sm_running || port->send_discover)
                goto resched;
 
        port->upcoming_state = GET_SINK_CAP;
@@ -5905,7 +5911,7 @@ static int tcpm_psy_set_prop(struct power_supply *psy,
                ret = -EINVAL;
                break;
        }
-
+       power_supply_changed(port->psy);
        return ret;
 }
 
@@ -6058,6 +6064,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
        err = devm_tcpm_psy_register(port);
        if (err)
                goto out_role_sw_put;
+       power_supply_changed(port->psy);
 
        port->typec_port = typec_register_port(port->dev, &port->typec_caps);
        if (IS_ERR(port->typec_port)) {
index 6e6ef631752376ce7811a25040177fdad4621772..29bd1c5a283cd966bec7bebdd294fbc5a52f66e6 100644 (file)
@@ -64,7 +64,6 @@ enum {
 struct tps6598x_rx_identity_reg {
        u8 status;
        struct usb_pd_identity identity;
-       u32 vdo[3];
 } __packed;
 
 /* Standard Task return codes */
index 2305d425e6c9adbc8ebdbcf4db45770da3710c0d..8f1de1fbbeedfc870c1ce1ece01703b6462206c6 100644 (file)
@@ -46,6 +46,8 @@ static ssize_t usbip_sockfd_store(struct device *dev, struct device_attribute *a
        int sockfd = 0;
        struct socket *socket;
        int rv;
+       struct task_struct *tcp_rx = NULL;
+       struct task_struct *tcp_tx = NULL;
 
        if (!sdev) {
                dev_err(dev, "sdev is null\n");
@@ -69,23 +71,47 @@ static ssize_t usbip_sockfd_store(struct device *dev, struct device_attribute *a
                }
 
                socket = sockfd_lookup(sockfd, &err);
-               if (!socket)
+               if (!socket) {
+                       dev_err(dev, "failed to lookup sock");
                        goto err;
+               }
 
-               sdev->ud.tcp_socket = socket;
-               sdev->ud.sockfd = sockfd;
+               if (socket->type != SOCK_STREAM) {
+                       dev_err(dev, "Expecting SOCK_STREAM - found %d",
+                               socket->type);
+                       goto sock_err;
+               }
 
+               /* unlock and create threads and get tasks */
                spin_unlock_irq(&sdev->ud.lock);
+               tcp_rx = kthread_create(stub_rx_loop, &sdev->ud, "stub_rx");
+               if (IS_ERR(tcp_rx)) {
+                       sockfd_put(socket);
+                       return -EINVAL;
+               }
+               tcp_tx = kthread_create(stub_tx_loop, &sdev->ud, "stub_tx");
+               if (IS_ERR(tcp_tx)) {
+                       kthread_stop(tcp_rx);
+                       sockfd_put(socket);
+                       return -EINVAL;
+               }
 
-               sdev->ud.tcp_rx = kthread_get_run(stub_rx_loop, &sdev->ud,
-                                                 "stub_rx");
-               sdev->ud.tcp_tx = kthread_get_run(stub_tx_loop, &sdev->ud,
-                                                 "stub_tx");
+               /* get task structs now */
+               get_task_struct(tcp_rx);
+               get_task_struct(tcp_tx);
 
+               /* lock and update sdev->ud state */
                spin_lock_irq(&sdev->ud.lock);
+               sdev->ud.tcp_socket = socket;
+               sdev->ud.sockfd = sockfd;
+               sdev->ud.tcp_rx = tcp_rx;
+               sdev->ud.tcp_tx = tcp_tx;
                sdev->ud.status = SDEV_ST_USED;
                spin_unlock_irq(&sdev->ud.lock);
 
+               wake_up_process(sdev->ud.tcp_rx);
+               wake_up_process(sdev->ud.tcp_tx);
+
        } else {
                dev_info(dev, "stub down\n");
 
@@ -100,6 +126,8 @@ static ssize_t usbip_sockfd_store(struct device *dev, struct device_attribute *a
 
        return count;
 
+sock_err:
+       sockfd_put(socket);
 err:
        spin_unlock_irq(&sdev->ud.lock);
        return -EINVAL;
index 96e5371dc335aba3d9d5c169c5c9249e738250bb..c4b4256e5dad3b0f3d432dfa86e86133f9305b10 100644 (file)
@@ -312,6 +312,8 @@ static ssize_t attach_store(struct device *dev, struct device_attribute *attr,
        struct vhci *vhci;
        int err;
        unsigned long flags;
+       struct task_struct *tcp_rx = NULL;
+       struct task_struct *tcp_tx = NULL;
 
        /*
         * @rhport: port number of vhci_hcd
@@ -349,12 +351,35 @@ static ssize_t attach_store(struct device *dev, struct device_attribute *attr,
 
        /* Extract socket from fd. */
        socket = sockfd_lookup(sockfd, &err);
-       if (!socket)
+       if (!socket) {
+               dev_err(dev, "failed to lookup sock");
                return -EINVAL;
+       }
+       if (socket->type != SOCK_STREAM) {
+               dev_err(dev, "Expecting SOCK_STREAM - found %d",
+                       socket->type);
+               sockfd_put(socket);
+               return -EINVAL;
+       }
+
+       /* create threads before locking */
+       tcp_rx = kthread_create(vhci_rx_loop, &vdev->ud, "vhci_rx");
+       if (IS_ERR(tcp_rx)) {
+               sockfd_put(socket);
+               return -EINVAL;
+       }
+       tcp_tx = kthread_create(vhci_tx_loop, &vdev->ud, "vhci_tx");
+       if (IS_ERR(tcp_tx)) {
+               kthread_stop(tcp_rx);
+               sockfd_put(socket);
+               return -EINVAL;
+       }
 
-       /* now need lock until setting vdev status as used */
+       /* get task structs now */
+       get_task_struct(tcp_rx);
+       get_task_struct(tcp_tx);
 
-       /* begin a lock */
+       /* now begin lock until setting vdev status set */
        spin_lock_irqsave(&vhci->lock, flags);
        spin_lock(&vdev->ud.lock);
 
@@ -364,6 +389,8 @@ static ssize_t attach_store(struct device *dev, struct device_attribute *attr,
                spin_unlock_irqrestore(&vhci->lock, flags);
 
                sockfd_put(socket);
+               kthread_stop_put(tcp_rx);
+               kthread_stop_put(tcp_tx);
 
                dev_err(dev, "port %d already used\n", rhport);
                /*
@@ -382,6 +409,8 @@ static ssize_t attach_store(struct device *dev, struct device_attribute *attr,
        vdev->speed         = speed;
        vdev->ud.sockfd     = sockfd;
        vdev->ud.tcp_socket = socket;
+       vdev->ud.tcp_rx     = tcp_rx;
+       vdev->ud.tcp_tx     = tcp_tx;
        vdev->ud.status     = VDEV_ST_NOTASSIGNED;
        usbip_kcov_handle_init(&vdev->ud);
 
@@ -389,8 +418,8 @@ static ssize_t attach_store(struct device *dev, struct device_attribute *attr,
        spin_unlock_irqrestore(&vhci->lock, flags);
        /* end the lock */
 
-       vdev->ud.tcp_rx = kthread_get_run(vhci_rx_loop, &vdev->ud, "vhci_rx");
-       vdev->ud.tcp_tx = kthread_get_run(vhci_tx_loop, &vdev->ud, "vhci_tx");
+       wake_up_process(vdev->ud.tcp_rx);
+       wake_up_process(vdev->ud.tcp_tx);
 
        rh_port_connect(vdev, speed);
 
index 100f680c572ae149017d6ff26cd5950533dae8be..7383a543c6d121b814671fdb8ba89a501f98d773 100644 (file)
@@ -90,8 +90,9 @@ unlock:
 }
 static BIN_ATTR_RO(dev_desc, sizeof(struct usb_device_descriptor));
 
-static ssize_t usbip_sockfd_store(struct device *dev, struct device_attribute *attr,
-                    const char *in, size_t count)
+static ssize_t usbip_sockfd_store(struct device *dev,
+                                 struct device_attribute *attr,
+                                 const char *in, size_t count)
 {
        struct vudc *udc = (struct vudc *) dev_get_drvdata(dev);
        int rv;
@@ -100,6 +101,8 @@ static ssize_t usbip_sockfd_store(struct device *dev, struct device_attribute *a
        struct socket *socket;
        unsigned long flags;
        int ret;
+       struct task_struct *tcp_rx = NULL;
+       struct task_struct *tcp_tx = NULL;
 
        rv = kstrtoint(in, 0, &sockfd);
        if (rv != 0)
@@ -138,24 +141,54 @@ static ssize_t usbip_sockfd_store(struct device *dev, struct device_attribute *a
                        goto unlock_ud;
                }
 
-               udc->ud.tcp_socket = socket;
+               if (socket->type != SOCK_STREAM) {
+                       dev_err(dev, "Expecting SOCK_STREAM - found %d",
+                               socket->type);
+                       ret = -EINVAL;
+                       goto sock_err;
+               }
 
+               /* unlock and create threads and get tasks */
                spin_unlock_irq(&udc->ud.lock);
                spin_unlock_irqrestore(&udc->lock, flags);
 
-               udc->ud.tcp_rx = kthread_get_run(&v_rx_loop,
-                                                   &udc->ud, "vudc_rx");
-               udc->ud.tcp_tx = kthread_get_run(&v_tx_loop,
-                                                   &udc->ud, "vudc_tx");
+               tcp_rx = kthread_create(&v_rx_loop, &udc->ud, "vudc_rx");
+               if (IS_ERR(tcp_rx)) {
+                       sockfd_put(socket);
+                       return -EINVAL;
+               }
+               tcp_tx = kthread_create(&v_tx_loop, &udc->ud, "vudc_tx");
+               if (IS_ERR(tcp_tx)) {
+                       kthread_stop(tcp_rx);
+                       sockfd_put(socket);
+                       return -EINVAL;
+               }
+
+               /* get task structs now */
+               get_task_struct(tcp_rx);
+               get_task_struct(tcp_tx);
 
+               /* lock and update udc->ud state */
                spin_lock_irqsave(&udc->lock, flags);
                spin_lock_irq(&udc->ud.lock);
+
+               udc->ud.tcp_socket = socket;
+               udc->ud.tcp_rx = tcp_rx;
+               udc->ud.tcp_tx = tcp_tx;
                udc->ud.status = SDEV_ST_USED;
+
                spin_unlock_irq(&udc->ud.lock);
 
                ktime_get_ts64(&udc->start_time);
                v_start_timer(udc);
                udc->connected = 1;
+
+               spin_unlock_irqrestore(&udc->lock, flags);
+
+               wake_up_process(udc->ud.tcp_rx);
+               wake_up_process(udc->ud.tcp_tx);
+               return count;
+
        } else {
                if (!udc->connected) {
                        dev_err(dev, "Device not connected");
@@ -177,6 +210,8 @@ static ssize_t usbip_sockfd_store(struct device *dev, struct device_attribute *a
 
        return count;
 
+sock_err:
+       sockfd_put(socket);
 unlock_ud:
        spin_unlock_irq(&udc->ud.lock);
 unlock:
index 7c8bbfcf6c3ebe7e09cd923527a129c3b19e1c81..d555a6a5d1baf8b3241eb9dd54935a099230f2c6 100644 (file)
@@ -431,8 +431,7 @@ static int ifcvf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        }
 
        adapter = vdpa_alloc_device(struct ifcvf_adapter, vdpa,
-                                   dev, &ifc_vdpa_ops,
-                                   IFCVF_MAX_QUEUE_PAIRS * 2, NULL);
+                                   dev, &ifc_vdpa_ops, NULL);
        if (adapter == NULL) {
                IFCVF_ERR(pdev, "Failed to allocate vDPA structure");
                return -ENOMEM;
@@ -456,7 +455,7 @@ static int ifcvf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        for (i = 0; i < IFCVF_MAX_QUEUE_PAIRS * 2; i++)
                vf->vring[i].irq = -EINVAL;
 
-       ret = vdpa_register_device(&adapter->vdpa);
+       ret = vdpa_register_device(&adapter->vdpa, IFCVF_MAX_QUEUE_PAIRS * 2);
        if (ret) {
                IFCVF_ERR(pdev, "Failed to register ifcvf to vdpa bus");
                goto err;
index 10e9b09932eb8a46358c733b7b779267262302f4..71397fdafa6a4c013f680afefb51acf74108ad57 100644 (file)
@@ -1982,7 +1982,7 @@ static int mlx5v_probe(struct auxiliary_device *adev,
        max_vqs = min_t(u32, max_vqs, MLX5_MAX_SUPPORTED_VQS);
 
        ndev = vdpa_alloc_device(struct mlx5_vdpa_net, mvdev.vdev, mdev->device, &mlx5_vdpa_ops,
-                                2 * mlx5_vdpa_max_qps(max_vqs), NULL);
+                                NULL);
        if (IS_ERR(ndev))
                return PTR_ERR(ndev);
 
@@ -2009,7 +2009,7 @@ static int mlx5v_probe(struct auxiliary_device *adev,
        if (err)
                goto err_res;
 
-       err = vdpa_register_device(&mvdev->vdev);
+       err = vdpa_register_device(&mvdev->vdev, 2 * mlx5_vdpa_max_qps(max_vqs));
        if (err)
                goto err_reg;
 
index da67f07e24fd48b8c427a2b2492bc7658783c05e..5cffce67cab020d10b331cd04bbcceff31156899 100644 (file)
@@ -69,7 +69,6 @@ static void vdpa_release_dev(struct device *d)
  * initialized but before registered.
  * @parent: the parent device
  * @config: the bus operations that is supported by this device
- * @nvqs: number of virtqueues supported by this device
  * @size: size of the parent structure that contains private data
  * @name: name of the vdpa device; optional.
  *
@@ -81,7 +80,7 @@ static void vdpa_release_dev(struct device *d)
  */
 struct vdpa_device *__vdpa_alloc_device(struct device *parent,
                                        const struct vdpa_config_ops *config,
-                                       int nvqs, size_t size, const char *name)
+                                       size_t size, const char *name)
 {
        struct vdpa_device *vdev;
        int err = -EINVAL;
@@ -107,7 +106,6 @@ struct vdpa_device *__vdpa_alloc_device(struct device *parent,
        vdev->index = err;
        vdev->config = config;
        vdev->features_valid = false;
-       vdev->nvqs = nvqs;
 
        if (name)
                err = dev_set_name(&vdev->dev, "%s", name);
@@ -136,10 +134,12 @@ static int vdpa_name_match(struct device *dev, const void *data)
        return (strcmp(dev_name(&vdev->dev), data) == 0);
 }
 
-static int __vdpa_register_device(struct vdpa_device *vdev)
+static int __vdpa_register_device(struct vdpa_device *vdev, int nvqs)
 {
        struct device *dev;
 
+       vdev->nvqs = nvqs;
+
        lockdep_assert_held(&vdpa_dev_mutex);
        dev = bus_find_device(&vdpa_bus, NULL, dev_name(&vdev->dev), vdpa_name_match);
        if (dev) {
@@ -155,15 +155,16 @@ static int __vdpa_register_device(struct vdpa_device *vdev)
  * Caller must invoke this routine in the management device dev_add()
  * callback after setting up valid mgmtdev for this vdpa device.
  * @vdev: the vdpa device to be registered to vDPA bus
+ * @nvqs: number of virtqueues supported by this device
  *
  * Returns an error when fail to add device to vDPA bus
  */
-int _vdpa_register_device(struct vdpa_device *vdev)
+int _vdpa_register_device(struct vdpa_device *vdev, int nvqs)
 {
        if (!vdev->mdev)
                return -EINVAL;
 
-       return __vdpa_register_device(vdev);
+       return __vdpa_register_device(vdev, nvqs);
 }
 EXPORT_SYMBOL_GPL(_vdpa_register_device);
 
@@ -171,15 +172,16 @@ EXPORT_SYMBOL_GPL(_vdpa_register_device);
  * vdpa_register_device - register a vDPA device
  * Callers must have a succeed call of vdpa_alloc_device() before.
  * @vdev: the vdpa device to be registered to vDPA bus
+ * @nvqs: number of virtqueues supported by this device
  *
  * Returns an error when fail to add to vDPA bus
  */
-int vdpa_register_device(struct vdpa_device *vdev)
+int vdpa_register_device(struct vdpa_device *vdev, int nvqs)
 {
        int err;
 
        mutex_lock(&vdpa_dev_mutex);
-       err = __vdpa_register_device(vdev);
+       err = __vdpa_register_device(vdev, nvqs);
        mutex_unlock(&vdpa_dev_mutex);
        return err;
 }
index d5942842432d6b57d4e696771962787c5e6410d3..5b6b2f87d40c65748186c9b79efbabb1af595b26 100644 (file)
@@ -235,7 +235,7 @@ struct vdpasim *vdpasim_create(struct vdpasim_dev_attr *dev_attr)
                ops = &vdpasim_config_ops;
 
        vdpasim = vdpa_alloc_device(struct vdpasim, vdpa, NULL, ops,
-                                   dev_attr->nvqs, dev_attr->name);
+                                   dev_attr->name);
        if (!vdpasim)
                goto err_alloc;
 
index d344c5b7c9149c3da79f682db6ba8e041bca71eb..a1ab6163f7d13b89e74322887ead6d3b819bea3b 100644 (file)
@@ -110,8 +110,7 @@ out:
 
 static void vdpasim_net_get_config(struct vdpasim *vdpasim, void *config)
 {
-       struct virtio_net_config *net_config =
-               (struct virtio_net_config *)config;
+       struct virtio_net_config *net_config = config;
 
        net_config->mtu = cpu_to_vdpasim16(vdpasim, 1500);
        net_config->status = cpu_to_vdpasim16(vdpasim, VIRTIO_NET_S_LINK_UP);
@@ -147,7 +146,7 @@ static int vdpasim_net_dev_add(struct vdpa_mgmt_dev *mdev, const char *name)
        if (IS_ERR(simdev))
                return PTR_ERR(simdev);
 
-       ret = _vdpa_register_device(&simdev->vdpa);
+       ret = _vdpa_register_device(&simdev->vdpa, VDPASIM_NET_VQ_NUM);
        if (ret)
                goto reg_err;
 
index 5533df91b257d63da817c40b686e58906bf03959..67d0bf4efa16066c8437efafbcee323d71fedc41 100644 (file)
@@ -21,8 +21,8 @@ config VFIO_VIRQFD
 
 menuconfig VFIO
        tristate "VFIO Non-Privileged userspace driver framework"
-       depends on IOMMU_API
-       select VFIO_IOMMU_TYPE1 if (X86 || S390 || ARM || ARM64)
+       select IOMMU_API
+       select VFIO_IOMMU_TYPE1 if MMU && (X86 || S390 || ARM || ARM64)
        help
          VFIO provides a framework for secure userspace device drivers.
          See Documentation/driver-api/vfio.rst for more details.
index dc1a3c44f2c62bba26e75df8feefa0892d4afba2..ab341108a0be9497205752946f98f5ed85803fe9 100644 (file)
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 config VFIO_PLATFORM
        tristate "VFIO support for platform devices"
-       depends on VFIO && EVENTFD && (ARM || ARM64)
+       depends on VFIO && EVENTFD && (ARM || ARM64 || COMPILE_TEST)
        select VFIO_VIRQFD
        help
          Support for platform devices with VFIO. This is required to make
@@ -12,7 +12,7 @@ config VFIO_PLATFORM
 
 config VFIO_AMBA
        tristate "VFIO support for AMBA devices"
-       depends on VFIO_PLATFORM && ARM_AMBA
+       depends on VFIO_PLATFORM && (ARM_AMBA || COMPILE_TEST)
        help
          Support for ARM AMBA devices with VFIO. This is required to make
          use of ARM AMBA devices present on the system using the VFIO
index 4bb162c1d649b325eb1ef538e71ce15648989b49..be444407664af74e66d746a52a199513b501efb1 100644 (file)
@@ -189,7 +189,7 @@ static struct vfio_dma *vfio_find_dma(struct vfio_iommu *iommu,
 }
 
 static struct rb_node *vfio_find_dma_first_node(struct vfio_iommu *iommu,
-                                               dma_addr_t start, size_t size)
+                                               dma_addr_t start, u64 size)
 {
        struct rb_node *res = NULL;
        struct rb_node *node = iommu->dma_list.rb_node;
@@ -785,7 +785,12 @@ static int vfio_pin_page_external(struct vfio_dma *dma, unsigned long vaddr,
                return -ENODEV;
 
        ret = vaddr_get_pfns(mm, vaddr, 1, dma->prot, pfn_base, pages);
-       if (ret == 1 && do_accounting && !is_invalid_reserved_pfn(*pfn_base)) {
+       if (ret != 1)
+               goto out;
+
+       ret = 0;
+
+       if (do_accounting && !is_invalid_reserved_pfn(*pfn_base)) {
                ret = vfio_lock_acct(dma, 1, true);
                if (ret) {
                        put_pfn(*pfn_base, dma->prot);
@@ -797,6 +802,7 @@ static int vfio_pin_page_external(struct vfio_dma *dma, unsigned long vaddr,
                }
        }
 
+out:
        mmput(mm);
        return ret;
 }
@@ -1288,7 +1294,7 @@ static int vfio_dma_do_unmap(struct vfio_iommu *iommu,
        int ret = -EINVAL, retries = 0;
        unsigned long pgshift;
        dma_addr_t iova = unmap->iova;
-       unsigned long size = unmap->size;
+       u64 size = unmap->size;
        bool unmap_all = unmap->flags & VFIO_DMA_UNMAP_FLAG_ALL;
        bool invalidate_vaddr = unmap->flags & VFIO_DMA_UNMAP_FLAG_VADDR;
        struct rb_node *n, *first_n;
@@ -1304,14 +1310,12 @@ static int vfio_dma_do_unmap(struct vfio_iommu *iommu,
        if (unmap_all) {
                if (iova || size)
                        goto unlock;
-               size = SIZE_MAX;
-       } else if (!size || size & (pgsize - 1)) {
+               size = U64_MAX;
+       } else if (!size || size & (pgsize - 1) ||
+                  iova + size - 1 < iova || size > SIZE_MAX) {
                goto unlock;
        }
 
-       if (iova + size - 1 < iova || size > SIZE_MAX)
-               goto unlock;
-
        /* When dirty tracking is enabled, allow only min supported pgsize */
        if ((unmap->flags & VFIO_DMA_UNMAP_FLAG_GET_DIRTY_BITMAP) &&
            (!iommu->dirty_page_tracking || (bitmap->pgsize != pgsize))) {
index ef688c8c0e0e6f8048b342bb55cdb608fadb727a..e0a27e3362935651067c87f7afc1099d54978924 100644 (file)
@@ -308,8 +308,10 @@ static long vhost_vdpa_get_vring_num(struct vhost_vdpa *v, u16 __user *argp)
 
 static void vhost_vdpa_config_put(struct vhost_vdpa *v)
 {
-       if (v->config_ctx)
+       if (v->config_ctx) {
                eventfd_ctx_put(v->config_ctx);
+               v->config_ctx = NULL;
+       }
 }
 
 static long vhost_vdpa_set_config_call(struct vhost_vdpa *v, u32 __user *argp)
@@ -329,8 +331,12 @@ static long vhost_vdpa_set_config_call(struct vhost_vdpa *v, u32 __user *argp)
        if (!IS_ERR_OR_NULL(ctx))
                eventfd_ctx_put(ctx);
 
-       if (IS_ERR(v->config_ctx))
-               return PTR_ERR(v->config_ctx);
+       if (IS_ERR(v->config_ctx)) {
+               long ret = PTR_ERR(v->config_ctx);
+
+               v->config_ctx = NULL;
+               return ret;
+       }
 
        v->vdpa->config->set_config_cb(v->vdpa, &cb);
 
@@ -900,14 +906,10 @@ err:
 
 static void vhost_vdpa_clean_irq(struct vhost_vdpa *v)
 {
-       struct vhost_virtqueue *vq;
        int i;
 
-       for (i = 0; i < v->nvqs; i++) {
-               vq = &v->vqs[i];
-               if (vq->call_ctx.producer.irq)
-                       irq_bypass_unregister_producer(&vq->call_ctx.producer);
-       }
+       for (i = 0; i < v->nvqs; i++)
+               vhost_vdpa_unsetup_vq_irq(v, i);
 }
 
 static int vhost_vdpa_release(struct inode *inode, struct file *filep)
index a262e12c6dc26f76810ac28a833ea5deb1e70d74..5ccb0705beae172c4c8acef4a42b06286573aa92 100644 (file)
@@ -332,8 +332,8 @@ static void vhost_vq_reset(struct vhost_dev *dev,
        vq->error_ctx = NULL;
        vq->kick = NULL;
        vq->log_ctx = NULL;
-       vhost_reset_is_le(vq);
        vhost_disable_cross_endian(vq);
+       vhost_reset_is_le(vq);
        vq->busyloop_timeout = 0;
        vq->umem = NULL;
        vq->iotlb = NULL;
index 551372f9b9aa283f8c2abcb49375b32dac274a85..465f55beb97f94182594e74dd33237c6f458ebc7 100644 (file)
@@ -287,11 +287,8 @@ static inline void aty_st_8(int regindex, u8 val, const struct atyfb_par *par)
 #endif
 }
 
-#if defined(CONFIG_PMAC_BACKLIGHT) || defined (CONFIG_FB_ATY_GENERIC_LCD) || \
-defined (CONFIG_FB_ATY_BACKLIGHT)
 extern void aty_st_lcd(int index, u32 val, const struct atyfb_par *par);
 extern u32 aty_ld_lcd(int index, const struct atyfb_par *par);
-#endif
 
     /*
      *  DAC operations
index e946903a86c2d8ed042221534f8c916b93039291..1aef3d6ebd8809f5134381ab2d5b9878141a4c0d 100644 (file)
 #define PRINTKE(fmt, args...)  printk(KERN_ERR "atyfb: " fmt, ## args)
 
 #if defined(CONFIG_PMAC_BACKLIGHT) || defined(CONFIG_FB_ATY_GENERIC_LCD) || \
-defined(CONFIG_FB_ATY_BACKLIGHT)
+defined(CONFIG_FB_ATY_BACKLIGHT) || defined (CONFIG_PPC_PMAC)
 static const u32 lt_lcd_regs[] = {
        CNFG_PANEL_LG,
        LCD_GEN_CNTL_LG,
@@ -175,8 +175,8 @@ u32 aty_ld_lcd(int index, const struct atyfb_par *par)
                return aty_ld_le32(LCD_DATA, par);
        }
 }
-#else /* defined(CONFIG_PMAC_BACKLIGHT) || defined(CONFIG_FB_ATY_BACKLIGHT) \
-        defined(CONFIG_FB_ATY_GENERIC_LCD) */
+#else /* defined(CONFIG_PMAC_BACKLIGHT) || defined(CONFIG_FB_ATY_BACKLIGHT) ||
+        defined(CONFIG_FB_ATY_GENERIC_LCD) || defined(CONFIG_PPC_PMAC) */
 void aty_st_lcd(int index, u32 val, const struct atyfb_par *par)
 { }
 
@@ -184,7 +184,8 @@ u32 aty_ld_lcd(int index, const struct atyfb_par *par)
 {
        return 0;
 }
-#endif /* defined(CONFIG_PMAC_BACKLIGHT) || defined (CONFIG_FB_ATY_GENERIC_LCD) */
+#endif /* defined(CONFIG_PMAC_BACKLIGHT) || defined(CONFIG_FB_ATY_BACKLIGHT) ||
+         defined (CONFIG_FB_ATY_GENERIC_LCD) || defined(CONFIG_PPC_PMAC) */
 
 #ifdef CONFIG_FB_ATY_GENERIC_LCD
 /*
index 1f6b7c54a1a48a5f5f796de4508a399f4d93e382..130e12b8652a691e5bb58a63acee382f21c0b3d5 100644 (file)
@@ -333,7 +333,7 @@ static long acrn_dev_ioctl(struct file *filp, unsigned int cmd,
                acrn_ioreq_request_clear(vm);
                break;
        case ACRN_IOCTL_PM_GET_CPU_STATE:
-               if (copy_from_user(&cstate_cmd, (void *)ioctl_param,
+               if (copy_from_user(&cstate_cmd, (void __user *)ioctl_param,
                                   sizeof(cstate_cmd)))
                        return -EFAULT;
 
@@ -404,6 +404,14 @@ fail_remove:
 }
 static DEVICE_ATTR_WO(remove_cpu);
 
+static umode_t acrn_attr_visible(struct kobject *kobj, struct attribute *a, int n)
+{
+       if (a == &dev_attr_remove_cpu.attr)
+               return IS_ENABLED(CONFIG_HOTPLUG_CPU) ? a->mode : 0;
+
+       return a->mode;
+}
+
 static struct attribute *acrn_attrs[] = {
        &dev_attr_remove_cpu.attr,
        NULL
@@ -411,6 +419,7 @@ static struct attribute *acrn_attrs[] = {
 
 static struct attribute_group acrn_attr_group = {
        .attrs = acrn_attrs,
+       .is_visible = acrn_attr_visible,
 };
 
 static const struct attribute_group *acrn_attr_groups[] = {
index a8766d528e292cf4f58a006a52ca7db812e80189..df5184979b282549eaa123510880cf1e1e10477b 100644 (file)
@@ -112,7 +112,7 @@ static int acrn_irqfd_assign(struct acrn_vm *vm, struct acrn_irqfd *args)
 {
        struct eventfd_ctx *eventfd = NULL;
        struct hsm_irqfd *irqfd, *tmp;
-       unsigned int events;
+       __poll_t events;
        struct fd f;
        int ret = 0;
 
@@ -158,9 +158,9 @@ static int acrn_irqfd_assign(struct acrn_vm *vm, struct acrn_irqfd *args)
        mutex_unlock(&vm->irqfds_lock);
 
        /* Check the pending event in this stage */
-       events = f.file->f_op->poll(f.file, &irqfd->pt);
+       events = vfs_poll(f.file, &irqfd->pt);
 
-       if (events & POLLIN)
+       if (events & EPOLLIN)
                acrn_irqfd_inject(irqfd);
 
        fdput(f);
index 42e09cc1b8ac5a78d1d0619747d0fe2ac05a0c11..4b15c00c0a0afc5de99b1af79cd277553a9322e1 100644 (file)
@@ -141,15 +141,14 @@ void virtio_config_changed(struct virtio_device *dev)
 }
 EXPORT_SYMBOL_GPL(virtio_config_changed);
 
-void virtio_config_disable(struct virtio_device *dev)
+static void virtio_config_disable(struct virtio_device *dev)
 {
        spin_lock_irq(&dev->config_lock);
        dev->config_enabled = false;
        spin_unlock_irq(&dev->config_lock);
 }
-EXPORT_SYMBOL_GPL(virtio_config_disable);
 
-void virtio_config_enable(struct virtio_device *dev)
+static void virtio_config_enable(struct virtio_device *dev)
 {
        spin_lock_irq(&dev->config_lock);
        dev->config_enabled = true;
@@ -158,7 +157,6 @@ void virtio_config_enable(struct virtio_device *dev)
        dev->config_change_pending = false;
        spin_unlock_irq(&dev->config_lock);
 }
-EXPORT_SYMBOL_GPL(virtio_config_enable);
 
 void virtio_add_status(struct virtio_device *dev, unsigned int status)
 {
index a286d22b6551ccfc0f0be1ab63f4f9c445b2aa02..56128b9c46ebaabe1c1dcd872d11d664cd75d1dd 100644 (file)
@@ -548,8 +548,7 @@ static void virtio_mmio_release_dev(struct device *_d)
 {
        struct virtio_device *vdev =
                        container_of(_d, struct virtio_device, dev);
-       struct virtio_mmio_device *vm_dev =
-                       container_of(vdev, struct virtio_mmio_device, vdev);
+       struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
        struct platform_device *pdev = vm_dev->pdev;
 
        devm_kfree(&pdev->dev, vm_dev);
index 9867a3a936df2a6cd663e32fbef4552fcc015cd1..688b112e712badc63bc6e1a07049fa113c29546f 100644 (file)
@@ -273,7 +273,6 @@ module_exit(cpu5wdt_exit_module);
 
 MODULE_AUTHOR("Heiko Ronsdorf <hero@ihg.uni-duisburg.de>");
 MODULE_DESCRIPTION("sma cpu5 watchdog driver");
-MODULE_SUPPORTED_DEVICE("sma cpu5 watchdog");
 MODULE_LICENSE("GPL");
 
 module_param_hw(port, int, ioport, 0);
index 808eeb4779e4dbeb8f94985753d800ec32a15c0b..1eafe0b4d71cb5d235c1f0ead1d5b779bf3b41e5 100644 (file)
@@ -172,7 +172,6 @@ MODULE_PARM_DESC(wd2_timeout, "Default watchdog2 timeout in 1/10secs");
 MODULE_AUTHOR("Eric Brower <ebrower@usa.net>");
 MODULE_DESCRIPTION("Hardware watchdog driver for Sun Microsystems CP1400/1500");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("watchdog");
 
 static void cpwd_writew(u16 val, void __iomem *addr)
 {
index 7008596a575f942b355c9cf972662c64f454c6c2..747e346ed06c5a16a726e68d78d200cd22872b9e 100644 (file)
@@ -46,7 +46,6 @@
 
 MODULE_AUTHOR("David S. Miller <davem@davemloft.net>");
 MODULE_DESCRIPTION("Hardware watchdog driver for Sun RIO");
-MODULE_SUPPORTED_DEVICE("watchdog");
 MODULE_LICENSE("GPL");
 
 #define DRIVER_NAME    "riowd"
index da87f3a1e351b0bb2794b11aa900dc540d09351b..b8f2f971c2f0fc6ef6ef3b3e8ab88147b4dc39c3 100644 (file)
@@ -47,6 +47,11 @@ static unsigned evtchn_2l_max_channels(void)
        return EVTCHN_2L_NR_CHANNELS;
 }
 
+static void evtchn_2l_remove(evtchn_port_t evtchn, unsigned int cpu)
+{
+       clear_bit(evtchn, BM(per_cpu(cpu_evtchn_mask, cpu)));
+}
+
 static void evtchn_2l_bind_to_cpu(evtchn_port_t evtchn, unsigned int cpu,
                                  unsigned int old_cpu)
 {
@@ -72,12 +77,6 @@ static bool evtchn_2l_is_pending(evtchn_port_t port)
        return sync_test_bit(port, BM(&s->evtchn_pending[0]));
 }
 
-static bool evtchn_2l_test_and_set_mask(evtchn_port_t port)
-{
-       struct shared_info *s = HYPERVISOR_shared_info;
-       return sync_test_and_set_bit(port, BM(&s->evtchn_mask[0]));
-}
-
 static void evtchn_2l_mask(evtchn_port_t port)
 {
        struct shared_info *s = HYPERVISOR_shared_info;
@@ -355,18 +354,27 @@ static void evtchn_2l_resume(void)
                                EVTCHN_2L_NR_CHANNELS/BITS_PER_EVTCHN_WORD);
 }
 
+static int evtchn_2l_percpu_deinit(unsigned int cpu)
+{
+       memset(per_cpu(cpu_evtchn_mask, cpu), 0, sizeof(xen_ulong_t) *
+                       EVTCHN_2L_NR_CHANNELS/BITS_PER_EVTCHN_WORD);
+
+       return 0;
+}
+
 static const struct evtchn_ops evtchn_ops_2l = {
        .max_channels      = evtchn_2l_max_channels,
        .nr_channels       = evtchn_2l_max_channels,
+       .remove            = evtchn_2l_remove,
        .bind_to_cpu       = evtchn_2l_bind_to_cpu,
        .clear_pending     = evtchn_2l_clear_pending,
        .set_pending       = evtchn_2l_set_pending,
        .is_pending        = evtchn_2l_is_pending,
-       .test_and_set_mask = evtchn_2l_test_and_set_mask,
        .mask              = evtchn_2l_mask,
        .unmask            = evtchn_2l_unmask,
        .handle_events     = evtchn_2l_handle_events,
        .resume            = evtchn_2l_resume,
+       .percpu_deinit     = evtchn_2l_percpu_deinit,
 };
 
 void __init xen_evtchn_2l_init(void)
index adb7260e94b232d6ffe334cb2b5f6c023092c432..8236e2364eeb4e4415d2ab53348dc2306ce60126 100644 (file)
@@ -98,13 +98,19 @@ struct irq_info {
        short refcnt;
        u8 spurious_cnt;
        u8 is_accounted;
-       enum xen_irq_type type; /* type */
+       short type;             /* type: IRQT_* */
+       u8 mask_reason;         /* Why is event channel masked */
+#define EVT_MASK_REASON_EXPLICIT       0x01
+#define EVT_MASK_REASON_TEMPORARY      0x02
+#define EVT_MASK_REASON_EOI_PENDING    0x04
+       u8 is_active;           /* Is event just being handled? */
        unsigned irq;
        evtchn_port_t evtchn;   /* event channel */
        unsigned short cpu;     /* cpu bound */
        unsigned short eoi_cpu; /* EOI must happen on this cpu-1 */
        unsigned int irq_epoch; /* If eoi_cpu valid: irq_epoch of event */
        u64 eoi_time;           /* Time in jiffies when to EOI. */
+       spinlock_t lock;
 
        union {
                unsigned short virq;
@@ -154,6 +160,7 @@ static DEFINE_RWLOCK(evtchn_rwlock);
  *   evtchn_rwlock
  *     IRQ-desc lock
  *       percpu eoi_list_lock
+ *         irq_info->lock
  */
 
 static LIST_HEAD(xen_irq_list_head);
@@ -304,6 +311,8 @@ static int xen_irq_info_common_setup(struct irq_info *info,
        info->irq = irq;
        info->evtchn = evtchn;
        info->cpu = cpu;
+       info->mask_reason = EVT_MASK_REASON_EXPLICIT;
+       spin_lock_init(&info->lock);
 
        ret = set_evtchn_to_irq(evtchn, irq);
        if (ret < 0)
@@ -377,6 +386,7 @@ static int xen_irq_info_pirq_setup(unsigned irq,
 static void xen_irq_info_cleanup(struct irq_info *info)
 {
        set_evtchn_to_irq(info->evtchn, -1);
+       xen_evtchn_port_remove(info->evtchn, info->cpu);
        info->evtchn = 0;
        channels_on_cpu_dec(info);
 }
@@ -458,6 +468,34 @@ unsigned int cpu_from_evtchn(evtchn_port_t evtchn)
        return ret;
 }
 
+static void do_mask(struct irq_info *info, u8 reason)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&info->lock, flags);
+
+       if (!info->mask_reason)
+               mask_evtchn(info->evtchn);
+
+       info->mask_reason |= reason;
+
+       spin_unlock_irqrestore(&info->lock, flags);
+}
+
+static void do_unmask(struct irq_info *info, u8 reason)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&info->lock, flags);
+
+       info->mask_reason &= ~reason;
+
+       if (!info->mask_reason)
+               unmask_evtchn(info->evtchn);
+
+       spin_unlock_irqrestore(&info->lock, flags);
+}
+
 #ifdef CONFIG_X86
 static bool pirq_check_eoi_map(unsigned irq)
 {
@@ -604,7 +642,7 @@ static void xen_irq_lateeoi_locked(struct irq_info *info, bool spurious)
        }
 
        info->eoi_time = 0;
-       unmask_evtchn(evtchn);
+       do_unmask(info, EVT_MASK_REASON_EOI_PENDING);
 }
 
 static void xen_irq_lateeoi_worker(struct work_struct *work)
@@ -773,6 +811,12 @@ static void xen_evtchn_close(evtchn_port_t port)
                BUG();
 }
 
+static void event_handler_exit(struct irq_info *info)
+{
+       smp_store_release(&info->is_active, 0);
+       clear_evtchn(info->evtchn);
+}
+
 static void pirq_query_unmask(int irq)
 {
        struct physdev_irq_status_query irq_status;
@@ -791,14 +835,15 @@ static void pirq_query_unmask(int irq)
 
 static void eoi_pirq(struct irq_data *data)
 {
-       evtchn_port_t evtchn = evtchn_from_irq(data->irq);
+       struct irq_info *info = info_for_irq(data->irq);
+       evtchn_port_t evtchn = info ? info->evtchn : 0;
        struct physdev_eoi eoi = { .irq = pirq_from_irq(data->irq) };
        int rc = 0;
 
        if (!VALID_EVTCHN(evtchn))
                return;
 
-       clear_evtchn(evtchn);
+       event_handler_exit(info);
 
        if (pirq_needs_eoi(data->irq)) {
                rc = HYPERVISOR_physdev_op(PHYSDEVOP_eoi, &eoi);
@@ -849,7 +894,8 @@ static unsigned int __startup_pirq(unsigned int irq)
                goto err;
 
 out:
-       unmask_evtchn(evtchn);
+       do_unmask(info, EVT_MASK_REASON_EXPLICIT);
+
        eoi_pirq(irq_get_irq_data(irq));
 
        return 0;
@@ -876,7 +922,7 @@ static void shutdown_pirq(struct irq_data *data)
        if (!VALID_EVTCHN(evtchn))
                return;
 
-       mask_evtchn(evtchn);
+       do_mask(info, EVT_MASK_REASON_EXPLICIT);
        xen_evtchn_close(evtchn);
        xen_irq_info_cleanup(info);
 }
@@ -1628,6 +1674,8 @@ void handle_irq_for_port(evtchn_port_t port, struct evtchn_loop_ctrl *ctrl)
        }
 
        info = info_for_irq(irq);
+       if (xchg_acquire(&info->is_active, 1))
+               return;
 
        dev = (info->type == IRQT_EVTCHN) ? info->u.interdomain : NULL;
        if (dev)
@@ -1720,10 +1768,10 @@ void rebind_evtchn_irq(evtchn_port_t evtchn, int irq)
 }
 
 /* Rebind an evtchn so that it gets delivered to a specific cpu */
-static int xen_rebind_evtchn_to_cpu(evtchn_port_t evtchn, unsigned int tcpu)
+static int xen_rebind_evtchn_to_cpu(struct irq_info *info, unsigned int tcpu)
 {
        struct evtchn_bind_vcpu bind_vcpu;
-       int masked;
+       evtchn_port_t evtchn = info ? info->evtchn : 0;
 
        if (!VALID_EVTCHN(evtchn))
                return -1;
@@ -1739,7 +1787,7 @@ static int xen_rebind_evtchn_to_cpu(evtchn_port_t evtchn, unsigned int tcpu)
         * Mask the event while changing the VCPU binding to prevent
         * it being delivered on an unexpected VCPU.
         */
-       masked = test_and_set_mask(evtchn);
+       do_mask(info, EVT_MASK_REASON_TEMPORARY);
 
        /*
         * If this fails, it usually just indicates that we're dealing with a
@@ -1749,8 +1797,7 @@ static int xen_rebind_evtchn_to_cpu(evtchn_port_t evtchn, unsigned int tcpu)
        if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_vcpu, &bind_vcpu) >= 0)
                bind_evtchn_to_cpu(evtchn, tcpu, false);
 
-       if (!masked)
-               unmask_evtchn(evtchn);
+       do_unmask(info, EVT_MASK_REASON_TEMPORARY);
 
        return 0;
 }
@@ -1789,7 +1836,7 @@ static int set_affinity_irq(struct irq_data *data, const struct cpumask *dest,
        unsigned int tcpu = select_target_cpu(dest);
        int ret;
 
-       ret = xen_rebind_evtchn_to_cpu(evtchn_from_irq(data->irq), tcpu);
+       ret = xen_rebind_evtchn_to_cpu(info_for_irq(data->irq), tcpu);
        if (!ret)
                irq_data_update_effective_affinity(data, cpumask_of(tcpu));
 
@@ -1798,28 +1845,29 @@ static int set_affinity_irq(struct irq_data *data, const struct cpumask *dest,
 
 static void enable_dynirq(struct irq_data *data)
 {
-       evtchn_port_t evtchn = evtchn_from_irq(data->irq);
+       struct irq_info *info = info_for_irq(data->irq);
+       evtchn_port_t evtchn = info ? info->evtchn : 0;
 
        if (VALID_EVTCHN(evtchn))
-               unmask_evtchn(evtchn);
+               do_unmask(info, EVT_MASK_REASON_EXPLICIT);
 }
 
 static void disable_dynirq(struct irq_data *data)
 {
-       evtchn_port_t evtchn = evtchn_from_irq(data->irq);
+       struct irq_info *info = info_for_irq(data->irq);
+       evtchn_port_t evtchn = info ? info->evtchn : 0;
 
        if (VALID_EVTCHN(evtchn))
-               mask_evtchn(evtchn);
+               do_mask(info, EVT_MASK_REASON_EXPLICIT);
 }
 
 static void ack_dynirq(struct irq_data *data)
 {
-       evtchn_port_t evtchn = evtchn_from_irq(data->irq);
+       struct irq_info *info = info_for_irq(data->irq);
+       evtchn_port_t evtchn = info ? info->evtchn : 0;
 
-       if (!VALID_EVTCHN(evtchn))
-               return;
-
-       clear_evtchn(evtchn);
+       if (VALID_EVTCHN(evtchn))
+               event_handler_exit(info);
 }
 
 static void mask_ack_dynirq(struct irq_data *data)
@@ -1828,18 +1876,39 @@ static void mask_ack_dynirq(struct irq_data *data)
        ack_dynirq(data);
 }
 
+static void lateeoi_ack_dynirq(struct irq_data *data)
+{
+       struct irq_info *info = info_for_irq(data->irq);
+       evtchn_port_t evtchn = info ? info->evtchn : 0;
+
+       if (VALID_EVTCHN(evtchn)) {
+               do_mask(info, EVT_MASK_REASON_EOI_PENDING);
+               event_handler_exit(info);
+       }
+}
+
+static void lateeoi_mask_ack_dynirq(struct irq_data *data)
+{
+       struct irq_info *info = info_for_irq(data->irq);
+       evtchn_port_t evtchn = info ? info->evtchn : 0;
+
+       if (VALID_EVTCHN(evtchn)) {
+               do_mask(info, EVT_MASK_REASON_EXPLICIT);
+               event_handler_exit(info);
+       }
+}
+
 static int retrigger_dynirq(struct irq_data *data)
 {
-       evtchn_port_t evtchn = evtchn_from_irq(data->irq);
-       int masked;
+       struct irq_info *info = info_for_irq(data->irq);
+       evtchn_port_t evtchn = info ? info->evtchn : 0;
 
        if (!VALID_EVTCHN(evtchn))
                return 0;
 
-       masked = test_and_set_mask(evtchn);
+       do_mask(info, EVT_MASK_REASON_TEMPORARY);
        set_evtchn(evtchn);
-       if (!masked)
-               unmask_evtchn(evtchn);
+       do_unmask(info, EVT_MASK_REASON_TEMPORARY);
 
        return 1;
 }
@@ -1938,10 +2007,11 @@ static void restore_cpu_ipis(unsigned int cpu)
 /* Clear an irq's pending state, in preparation for polling on it */
 void xen_clear_irq_pending(int irq)
 {
-       evtchn_port_t evtchn = evtchn_from_irq(irq);
+       struct irq_info *info = info_for_irq(irq);
+       evtchn_port_t evtchn = info ? info->evtchn : 0;
 
        if (VALID_EVTCHN(evtchn))
-               clear_evtchn(evtchn);
+               event_handler_exit(info);
 }
 EXPORT_SYMBOL(xen_clear_irq_pending);
 void xen_set_irq_pending(int irq)
@@ -2053,8 +2123,8 @@ static struct irq_chip xen_lateeoi_chip __read_mostly = {
        .irq_mask               = disable_dynirq,
        .irq_unmask             = enable_dynirq,
 
-       .irq_ack                = mask_ack_dynirq,
-       .irq_mask_ack           = mask_ack_dynirq,
+       .irq_ack                = lateeoi_ack_dynirq,
+       .irq_mask_ack           = lateeoi_mask_ack_dynirq,
 
        .irq_set_affinity       = set_affinity_irq,
        .irq_retrigger          = retrigger_dynirq,
index b234f1766810c61db949c4a17b3cf19cdf4d3306..ad9fe51d3fb33275ec711a81b1f09d50ee46e963 100644 (file)
@@ -209,12 +209,6 @@ static bool evtchn_fifo_is_pending(evtchn_port_t port)
        return sync_test_bit(EVTCHN_FIFO_BIT(PENDING, word), BM(word));
 }
 
-static bool evtchn_fifo_test_and_set_mask(evtchn_port_t port)
-{
-       event_word_t *word = event_word_from_port(port);
-       return sync_test_and_set_bit(EVTCHN_FIFO_BIT(MASKED, word), BM(word));
-}
-
 static void evtchn_fifo_mask(evtchn_port_t port)
 {
        event_word_t *word = event_word_from_port(port);
@@ -423,7 +417,6 @@ static const struct evtchn_ops evtchn_ops_fifo = {
        .clear_pending     = evtchn_fifo_clear_pending,
        .set_pending       = evtchn_fifo_set_pending,
        .is_pending        = evtchn_fifo_is_pending,
-       .test_and_set_mask = evtchn_fifo_test_and_set_mask,
        .mask              = evtchn_fifo_mask,
        .unmask            = evtchn_fifo_unmask,
        .handle_events     = evtchn_fifo_handle_events,
index 0a97c0549db761fdf3f4ffdec0ff22401df427be..4d3398eff9cdf1567a5f64dcb63561680dda405e 100644 (file)
@@ -14,13 +14,13 @@ struct evtchn_ops {
        unsigned (*nr_channels)(void);
 
        int (*setup)(evtchn_port_t port);
+       void (*remove)(evtchn_port_t port, unsigned int cpu);
        void (*bind_to_cpu)(evtchn_port_t evtchn, unsigned int cpu,
                            unsigned int old_cpu);
 
        void (*clear_pending)(evtchn_port_t port);
        void (*set_pending)(evtchn_port_t port);
        bool (*is_pending)(evtchn_port_t port);
-       bool (*test_and_set_mask)(evtchn_port_t port);
        void (*mask)(evtchn_port_t port);
        void (*unmask)(evtchn_port_t port);
 
@@ -54,6 +54,13 @@ static inline int xen_evtchn_port_setup(evtchn_port_t evtchn)
        return 0;
 }
 
+static inline void xen_evtchn_port_remove(evtchn_port_t evtchn,
+                                         unsigned int cpu)
+{
+       if (evtchn_ops->remove)
+               evtchn_ops->remove(evtchn, cpu);
+}
+
 static inline void xen_evtchn_port_bind_to_cpu(evtchn_port_t evtchn,
                                               unsigned int cpu,
                                               unsigned int old_cpu)
@@ -76,11 +83,6 @@ static inline bool test_evtchn(evtchn_port_t port)
        return evtchn_ops->is_pending(port);
 }
 
-static inline bool test_and_set_mask(evtchn_port_t port)
-{
-       return evtchn_ops->test_and_set_mask(port);
-}
-
 static inline void mask_evtchn(evtchn_port_t port)
 {
        return evtchn_ops->mask(port);
index 5447c5156b2e62ea50f8190609a85db42904b4ed..f01d58c7a042ed747ce2c9227af0c5429a78546e 100644 (file)
@@ -133,20 +133,26 @@ struct gntdev_grant_map *gntdev_alloc_map(struct gntdev_priv *priv, int count,
        if (NULL == add)
                return NULL;
 
-       add->grants    = kvcalloc(count, sizeof(add->grants[0]), GFP_KERNEL);
-       add->map_ops   = kvcalloc(count, sizeof(add->map_ops[0]), GFP_KERNEL);
-       add->unmap_ops = kvcalloc(count, sizeof(add->unmap_ops[0]), GFP_KERNEL);
-       add->kmap_ops  = kvcalloc(count, sizeof(add->kmap_ops[0]), GFP_KERNEL);
-       add->kunmap_ops = kvcalloc(count,
-                                  sizeof(add->kunmap_ops[0]), GFP_KERNEL);
+       add->grants    = kvmalloc_array(count, sizeof(add->grants[0]),
+                                       GFP_KERNEL);
+       add->map_ops   = kvmalloc_array(count, sizeof(add->map_ops[0]),
+                                       GFP_KERNEL);
+       add->unmap_ops = kvmalloc_array(count, sizeof(add->unmap_ops[0]),
+                                       GFP_KERNEL);
        add->pages     = kvcalloc(count, sizeof(add->pages[0]), GFP_KERNEL);
        if (NULL == add->grants    ||
            NULL == add->map_ops   ||
            NULL == add->unmap_ops ||
-           NULL == add->kmap_ops  ||
-           NULL == add->kunmap_ops ||
            NULL == add->pages)
                goto err;
+       if (use_ptemod) {
+               add->kmap_ops   = kvmalloc_array(count, sizeof(add->kmap_ops[0]),
+                                                GFP_KERNEL);
+               add->kunmap_ops = kvmalloc_array(count, sizeof(add->kunmap_ops[0]),
+                                                GFP_KERNEL);
+               if (NULL == add->kmap_ops || NULL == add->kunmap_ops)
+                       goto err;
+       }
 
 #ifdef CONFIG_XEN_GRANT_DMA_ALLOC
        add->dma_flags = dma_flags;
@@ -183,10 +189,14 @@ struct gntdev_grant_map *gntdev_alloc_map(struct gntdev_priv *priv, int count,
                goto err;
 
        for (i = 0; i < count; i++) {
-               add->map_ops[i].handle = -1;
-               add->unmap_ops[i].handle = -1;
-               add->kmap_ops[i].handle = -1;
-               add->kunmap_ops[i].handle = -1;
+               add->grants[i].domid = DOMID_INVALID;
+               add->grants[i].ref = INVALID_GRANT_REF;
+               add->map_ops[i].handle = INVALID_GRANT_HANDLE;
+               add->unmap_ops[i].handle = INVALID_GRANT_HANDLE;
+               if (use_ptemod) {
+                       add->kmap_ops[i].handle = INVALID_GRANT_HANDLE;
+                       add->kunmap_ops[i].handle = INVALID_GRANT_HANDLE;
+               }
        }
 
        add->index = 0;
@@ -274,7 +284,7 @@ static int find_grant_ptes(pte_t *pte, unsigned long addr, void *data)
                          map->grants[pgnr].ref,
                          map->grants[pgnr].domid);
        gnttab_set_unmap_op(&map->unmap_ops[pgnr], pte_maddr, flags,
-                           -1 /* handle */);
+                           INVALID_GRANT_HANDLE);
        return 0;
 }
 
@@ -292,7 +302,7 @@ int gntdev_map_grant_pages(struct gntdev_grant_map *map)
 
        if (!use_ptemod) {
                /* Note: it could already be mapped */
-               if (map->map_ops[0].handle != -1)
+               if (map->map_ops[0].handle != INVALID_GRANT_HANDLE)
                        return 0;
                for (i = 0; i < map->count; i++) {
                        unsigned long addr = (unsigned long)
@@ -301,7 +311,7 @@ int gntdev_map_grant_pages(struct gntdev_grant_map *map)
                                map->grants[i].ref,
                                map->grants[i].domid);
                        gnttab_set_unmap_op(&map->unmap_ops[i], addr,
-                               map->flags, -1 /* handle */);
+                               map->flags, INVALID_GRANT_HANDLE);
                }
        } else {
                /*
@@ -327,13 +337,13 @@ int gntdev_map_grant_pages(struct gntdev_grant_map *map)
                                map->grants[i].ref,
                                map->grants[i].domid);
                        gnttab_set_unmap_op(&map->kunmap_ops[i], address,
-                               flags, -1);
+                               flags, INVALID_GRANT_HANDLE);
                }
        }
 
        pr_debug("map %d+%d\n", map->index, map->count);
-       err = gnttab_map_refs(map->map_ops, use_ptemod ? map->kmap_ops : NULL,
-                       map->pages, map->count);
+       err = gnttab_map_refs(map->map_ops, map->kmap_ops, map->pages,
+                       map->count);
 
        for (i = 0; i < map->count; i++) {
                if (map->map_ops[i].status == GNTST_okay)
@@ -385,7 +395,7 @@ static int __unmap_grant_pages(struct gntdev_grant_map *map, int offset,
                pr_debug("unmap handle=%d st=%d\n",
                        map->unmap_ops[offset+i].handle,
                        map->unmap_ops[offset+i].status);
-               map->unmap_ops[offset+i].handle = -1;
+               map->unmap_ops[offset+i].handle = INVALID_GRANT_HANDLE;
        }
        return err;
 }
@@ -401,13 +411,15 @@ static int unmap_grant_pages(struct gntdev_grant_map *map, int offset,
         * already unmapped some of the grants. Only unmap valid ranges.
         */
        while (pages && !err) {
-               while (pages && map->unmap_ops[offset].handle == -1) {
+               while (pages &&
+                      map->unmap_ops[offset].handle == INVALID_GRANT_HANDLE) {
                        offset++;
                        pages--;
                }
                range = 0;
                while (range < pages) {
-                       if (map->unmap_ops[offset+range].handle == -1)
+                       if (map->unmap_ops[offset + range].handle ==
+                           INVALID_GRANT_HANDLE)
                                break;
                        range++;
                }
index 462253ae483a34af11456e347cf0fb94e2da10ad..a55bda4233bbea9edd12555f03dac8289ea16232 100644 (file)
@@ -203,7 +203,7 @@ config TMPFS_XATTR
 
 config TMPFS_INODE64
        bool "Use 64-bit ino_t by default in tmpfs"
-       depends on TMPFS && 64BIT && !(S390 || ALPHA)
+       depends on TMPFS && 64BIT
        default n
        help
          tmpfs has historically used only inode numbers as wide as an unsigned
index 714fcca9af99090ac36cbd975185d1afdc3f031b..17548c1faf02999c7c631dd559fcaf2c430af607 100644 (file)
@@ -70,7 +70,6 @@ const struct inode_operations afs_dir_inode_operations = {
        .permission     = afs_permission,
        .getattr        = afs_getattr,
        .setattr        = afs_setattr,
-       .listxattr      = afs_listxattr,
 };
 
 const struct address_space_operations afs_dir_aops = {
index 85f5adf21aa08a50f372a9db3b5215d3822c3940..960b64268623e4cf03f84f6f2587bfe24479ab87 100644 (file)
@@ -43,7 +43,6 @@ const struct inode_operations afs_file_inode_operations = {
        .getattr        = afs_getattr,
        .setattr        = afs_setattr,
        .permission     = afs_permission,
-       .listxattr      = afs_listxattr,
 };
 
 const struct address_space_operations afs_fs_aops = {
index 97cab12b0a6c252380e3f317eac3aaba4878e894..71c58723763d23bf116353c405b5fcd78c8039cd 100644 (file)
@@ -181,10 +181,13 @@ void afs_wait_for_operation(struct afs_operation *op)
                if (test_bit(AFS_SERVER_FL_IS_YFS, &op->server->flags) &&
                    op->ops->issue_yfs_rpc)
                        op->ops->issue_yfs_rpc(op);
-               else
+               else if (op->ops->issue_afs_rpc)
                        op->ops->issue_afs_rpc(op);
+               else
+                       op->ac.error = -ENOTSUPP;
 
-               op->error = afs_wait_for_call_to_complete(op->call, &op->ac);
+               if (op->call)
+                       op->error = afs_wait_for_call_to_complete(op->call, &op->ac);
        }
 
        switch (op->error) {
index 1156b2df28d36afe27917af02a95b423aab53e66..12be88716e4c9bde3b12d92744f421d01e7e766a 100644 (file)
@@ -27,7 +27,6 @@
 
 static const struct inode_operations afs_symlink_inode_operations = {
        .get_link       = page_get_link,
-       .listxattr      = afs_listxattr,
 };
 
 static noinline void dump_vnode(struct afs_vnode *vnode, struct afs_vnode *parent_vnode)
index b626e38e9ab5d89f4e0fb0fac12131b1abb00e81..1627b1872812570da753f85c5fad8059245ad984 100644 (file)
@@ -1509,7 +1509,6 @@ extern int afs_launder_page(struct page *);
  * xattr.c
  */
 extern const struct xattr_handler *afs_xattr_handlers[];
-extern ssize_t afs_listxattr(struct dentry *, char *, size_t);
 
 /*
  * yfsclient.c
index 052dab2f5c03a872e8c2ac112944fe043fd9c32e..bbb2c210d139d9033e83e39f0c4778de83afc694 100644 (file)
@@ -32,7 +32,6 @@ const struct inode_operations afs_mntpt_inode_operations = {
        .lookup         = afs_mntpt_lookup,
        .readlink       = page_readlink,
        .getattr        = afs_getattr,
-       .listxattr      = afs_listxattr,
 };
 
 const struct inode_operations afs_autocell_inode_operations = {
index c629caae500286776bd04a800aabe11ed3c3f3ed..7751b0b3f81d486070f699548cdeba7fe9fd5dc9 100644 (file)
 #include <linux/xattr.h>
 #include "internal.h"
 
-static const char afs_xattr_list[] =
-       "afs.acl\0"
-       "afs.cell\0"
-       "afs.fid\0"
-       "afs.volume\0"
-       "afs.yfs.acl\0"
-       "afs.yfs.acl_inherited\0"
-       "afs.yfs.acl_num_cleaned\0"
-       "afs.yfs.vol_acl";
-
-/*
- * Retrieve a list of the supported xattrs.
- */
-ssize_t afs_listxattr(struct dentry *dentry, char *buffer, size_t size)
-{
-       if (size == 0)
-               return sizeof(afs_xattr_list);
-       if (size < sizeof(afs_xattr_list))
-               return -ERANGE;
-       memcpy(buffer, afs_xattr_list, sizeof(afs_xattr_list));
-       return sizeof(afs_xattr_list);
-}
-
 /*
  * Deal with the result of a successful fetch ACL operation.
  */
@@ -231,6 +208,8 @@ static int afs_xattr_get_yfs(const struct xattr_handler *handler,
                        else
                                ret = -ERANGE;
                }
+       } else if (ret == -ENOTSUPP) {
+               ret = -ENODATA;
        }
 
 error_yacl:
@@ -256,6 +235,7 @@ static int afs_xattr_set_yfs(const struct xattr_handler *handler,
 {
        struct afs_operation *op;
        struct afs_vnode *vnode = AFS_FS_I(inode);
+       int ret;
 
        if (flags == XATTR_CREATE ||
            strcmp(name, "acl") != 0)
@@ -270,7 +250,10 @@ static int afs_xattr_set_yfs(const struct xattr_handler *handler,
                return afs_put_operation(op);
 
        op->ops = &yfs_store_opaque_acl2_operation;
-       return afs_do_sync_operation(op);
+       ret = afs_do_sync_operation(op);
+       if (ret == -ENOTSUPP)
+               ret = -ENODATA;
+       return ret;
 }
 
 static const struct xattr_handler afs_xattr_yfs_handler = {
index c457334de43f8709cc5ee162d2382ebb3fb4f199..e1eae7ea823aeb2d5d0b245511658fcdb3a3ed09 100644 (file)
@@ -649,12 +649,24 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer,
        struct super_block *sb = file_inode(file)->i_sb;
        struct dentry *root = sb->s_root, *dentry;
        int err = 0;
+       struct file *f = NULL;
 
        e = create_entry(buffer, count);
 
        if (IS_ERR(e))
                return PTR_ERR(e);
 
+       if (e->flags & MISC_FMT_OPEN_FILE) {
+               f = open_exec(e->interpreter);
+               if (IS_ERR(f)) {
+                       pr_notice("register: failed to install interpreter file %s\n",
+                                e->interpreter);
+                       kfree(e);
+                       return PTR_ERR(f);
+               }
+               e->interp_file = f;
+       }
+
        inode_lock(d_inode(root));
        dentry = lookup_one_len(e->name, root, strlen(e->name));
        err = PTR_ERR(dentry);
@@ -678,21 +690,6 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer,
                goto out2;
        }
 
-       if (e->flags & MISC_FMT_OPEN_FILE) {
-               struct file *f;
-
-               f = open_exec(e->interpreter);
-               if (IS_ERR(f)) {
-                       err = PTR_ERR(f);
-                       pr_notice("register: failed to install interpreter file %s\n", e->interpreter);
-                       simple_release_fs(&bm_mnt, &entry_count);
-                       iput(inode);
-                       inode = NULL;
-                       goto out2;
-               }
-               e->interp_file = f;
-       }
-
        e->dentry = dget(dentry);
        inode->i_private = e;
        inode->i_fop = &bm_entry_operations;
@@ -709,6 +706,8 @@ out:
        inode_unlock(d_inode(root));
 
        if (err) {
+               if (f)
+                       filp_close(f, NULL);
                kfree(e);
                return err;
        }
index 4aa1f88d5bf8b390db16fab9d8999f0c9200b588..92ed7d5df67744c90012d7c829b9beaf0fc037f7 100644 (file)
@@ -118,13 +118,22 @@ int truncate_bdev_range(struct block_device *bdev, fmode_t mode,
        if (!(mode & FMODE_EXCL)) {
                int err = bd_prepare_to_claim(bdev, truncate_bdev_range);
                if (err)
-                       return err;
+                       goto invalidate;
        }
 
        truncate_inode_pages_range(bdev->bd_inode->i_mapping, lstart, lend);
        if (!(mode & FMODE_EXCL))
                bd_abort_claiming(bdev, truncate_bdev_range);
        return 0;
+
+invalidate:
+       /*
+        * Someone else has handle exclusively open. Try invalidating instead.
+        * The 'end' argument is inclusive so the rounding is safe.
+        */
+       return invalidate_inode_pages2_range(bdev->bd_inode->i_mapping,
+                                            lstart >> PAGE_SHIFT,
+                                            lend >> PAGE_SHIFT);
 }
 
 static void set_init_blocksize(struct block_device *bdev)
@@ -423,7 +432,7 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
                dio->size += bio->bi_iter.bi_size;
                pos += bio->bi_iter.bi_size;
 
-               nr_pages = bio_iov_vecs_to_alloc(iter, BIO_MAX_PAGES);
+               nr_pages = bio_iov_vecs_to_alloc(iter, BIO_MAX_VECS);
                if (!nr_pages) {
                        bool polled = false;
 
@@ -491,8 +500,8 @@ blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
        if (!iov_iter_count(iter))
                return 0;
 
-       nr_pages = bio_iov_vecs_to_alloc(iter, BIO_MAX_PAGES + 1);
-       if (is_sync_kiocb(iocb) && nr_pages <= BIO_MAX_PAGES)
+       nr_pages = bio_iov_vecs_to_alloc(iter, BIO_MAX_VECS + 1);
+       if (is_sync_kiocb(iocb) && nr_pages <= BIO_MAX_VECS)
                return __blkdev_direct_IO_simple(iocb, iter, nr_pages);
 
        return __blkdev_direct_IO(iocb, iter, bio_max_segs(nr_pages));
index d56730a6788537ac01cb6848442b80b101187c5f..34b929bd5c1af5a57a258d69e1142fdf46fc9ee6 100644 (file)
@@ -1365,7 +1365,9 @@ get_old_root(struct btrfs_root *root, u64 time_seq)
                                   "failed to read tree block %llu from get_old_root",
                                   logical);
                } else {
+                       btrfs_tree_read_lock(old);
                        eb = btrfs_clone_extent_buffer(old);
+                       btrfs_tree_read_unlock(old);
                        free_extent_buffer(old);
                }
        } else if (old_root) {
index 78ad31a59e59e0755f678e181c9ffe3c5d3319f2..36a3c973fda1029529f8cdaebca0e0be99539020 100644 (file)
@@ -3323,6 +3323,7 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans,
 
        if (last_ref && btrfs_header_generation(buf) == trans->transid) {
                struct btrfs_block_group *cache;
+               bool must_pin = false;
 
                if (root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID) {
                        ret = check_ref_cleanup(trans, buf->start);
@@ -3340,7 +3341,27 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans,
                        goto out;
                }
 
-               if (btrfs_is_zoned(fs_info)) {
+               /*
+                * If this is a leaf and there are tree mod log users, we may
+                * have recorded mod log operations that point to this leaf.
+                * So we must make sure no one reuses this leaf's extent before
+                * mod log operations are applied to a node, otherwise after
+                * rewinding a node using the mod log operations we get an
+                * inconsistent btree, as the leaf's extent may now be used as
+                * a node or leaf for another different btree.
+                * We are safe from races here because at this point no other
+                * node or root points to this extent buffer, so if after this
+                * check a new tree mod log user joins, it will not be able to
+                * find a node pointing to this leaf and record operations that
+                * point to this leaf.
+                */
+               if (btrfs_header_level(buf) == 0) {
+                       read_lock(&fs_info->tree_mod_log_lock);
+                       must_pin = !list_empty(&fs_info->tree_mod_seq_list);
+                       read_unlock(&fs_info->tree_mod_log_lock);
+               }
+
+               if (must_pin || btrfs_is_zoned(fs_info)) {
                        btrfs_redirty_list_add(trans->transaction, buf);
                        pin_down_extent(trans, cache, buf->start, buf->len, 1);
                        btrfs_put_block_group(cache);
index 4671c99d468ddd24e6563594581637923c5b06ff..910769d5fcdb4998ca5ba004087cf7537bfff132 100644 (file)
@@ -2885,6 +2885,35 @@ static void end_page_read(struct page *page, bool uptodate, u64 start, u32 len)
                btrfs_subpage_end_reader(fs_info, page, start, len);
 }
 
+/*
+ * Find extent buffer for a givne bytenr.
+ *
+ * This is for end_bio_extent_readpage(), thus we can't do any unsafe locking
+ * in endio context.
+ */
+static struct extent_buffer *find_extent_buffer_readpage(
+               struct btrfs_fs_info *fs_info, struct page *page, u64 bytenr)
+{
+       struct extent_buffer *eb;
+
+       /*
+        * For regular sectorsize, we can use page->private to grab extent
+        * buffer
+        */
+       if (fs_info->sectorsize == PAGE_SIZE) {
+               ASSERT(PagePrivate(page) && page->private);
+               return (struct extent_buffer *)page->private;
+       }
+
+       /* For subpage case, we need to lookup buffer radix tree */
+       rcu_read_lock();
+       eb = radix_tree_lookup(&fs_info->buffer_radix,
+                              bytenr >> fs_info->sectorsize_bits);
+       rcu_read_unlock();
+       ASSERT(eb);
+       return eb;
+}
+
 /*
  * after a readpage IO is done, we need to:
  * clear the uptodate bits on error
@@ -2996,7 +3025,7 @@ static void end_bio_extent_readpage(struct bio *bio)
                } else {
                        struct extent_buffer *eb;
 
-                       eb = (struct extent_buffer *)page->private;
+                       eb = find_extent_buffer_readpage(fs_info, page, start);
                        set_bit(EXTENT_BUFFER_READ_ERR, &eb->bflags);
                        eb->read_mirror = mirror;
                        atomic_dec(&eb->io_pages);
@@ -3020,7 +3049,7 @@ readpage_ok:
                         */
                        if (page->index == end_index && i_size <= end) {
                                u32 zero_start = max(offset_in_page(i_size),
-                                                    offset_in_page(end));
+                                                    offset_in_page(start));
 
                                zero_user_segment(page, zero_start,
                                                  offset_in_page(end) + 1);
@@ -3059,7 +3088,7 @@ struct bio *btrfs_bio_alloc(u64 first_byte)
 {
        struct bio *bio;
 
-       bio = bio_alloc_bioset(GFP_NOFS, BIO_MAX_PAGES, &btrfs_bioset);
+       bio = bio_alloc_bioset(GFP_NOFS, BIO_MAX_VECS, &btrfs_bioset);
        bio->bi_iter.bi_sector = first_byte >> 9;
        btrfs_io_bio_init(btrfs_io_bio(bio));
        return bio;
index 35bfa0533f233e0f9c20259ff64d6d6d6215f9b7..7cdf65be3707cd4c1602de86698488b84e97bf3f 100644 (file)
@@ -9008,7 +9008,7 @@ int __init btrfs_init_cachep(void)
 
        btrfs_free_space_bitmap_cachep = kmem_cache_create("btrfs_free_space_bitmap",
                                                        PAGE_SIZE, PAGE_SIZE,
-                                                       SLAB_RED_ZONE, NULL);
+                                                       SLAB_MEM_SPREAD, NULL);
        if (!btrfs_free_space_bitmap_cachep)
                goto fail;
 
@@ -9877,6 +9877,7 @@ static struct btrfs_trans_handle *insert_prealloc_file_extent(
        struct btrfs_path *path;
        u64 start = ins->objectid;
        u64 len = ins->offset;
+       int qgroup_released;
        int ret;
 
        memset(&stack_fi, 0, sizeof(stack_fi));
@@ -9889,16 +9890,16 @@ static struct btrfs_trans_handle *insert_prealloc_file_extent(
        btrfs_set_stack_file_extent_compression(&stack_fi, BTRFS_COMPRESS_NONE);
        /* Encryption and other encoding is reserved and all 0 */
 
-       ret = btrfs_qgroup_release_data(inode, file_offset, len);
-       if (ret < 0)
-               return ERR_PTR(ret);
+       qgroup_released = btrfs_qgroup_release_data(inode, file_offset, len);
+       if (qgroup_released < 0)
+               return ERR_PTR(qgroup_released);
 
        if (trans) {
                ret = insert_reserved_file_extent(trans, inode,
                                                  file_offset, &stack_fi,
-                                                 true, ret);
+                                                 true, qgroup_released);
                if (ret)
-                       return ERR_PTR(ret);
+                       goto free_qgroup;
                return trans;
        }
 
@@ -9909,21 +9910,35 @@ static struct btrfs_trans_handle *insert_prealloc_file_extent(
        extent_info.file_offset = file_offset;
        extent_info.extent_buf = (char *)&stack_fi;
        extent_info.is_new_extent = true;
-       extent_info.qgroup_reserved = ret;
+       extent_info.qgroup_reserved = qgroup_released;
        extent_info.insertions = 0;
 
        path = btrfs_alloc_path();
-       if (!path)
-               return ERR_PTR(-ENOMEM);
+       if (!path) {
+               ret = -ENOMEM;
+               goto free_qgroup;
+       }
 
        ret = btrfs_replace_file_extents(&inode->vfs_inode, path, file_offset,
                                     file_offset + len - 1, &extent_info,
                                     &trans);
        btrfs_free_path(path);
        if (ret)
-               return ERR_PTR(ret);
-
+               goto free_qgroup;
        return trans;
+
+free_qgroup:
+       /*
+        * We have released qgroup data range at the beginning of the function,
+        * and normally qgroup_released bytes will be freed when committing
+        * transaction.
+        * But if we error out early, we have to free what we have released
+        * or we leak qgroup data reservation.
+        */
+       btrfs_qgroup_free_refroot(inode->root->fs_info,
+                       inode->root->root_key.objectid, qgroup_released,
+                       BTRFS_QGROUP_RSV_DATA);
+       return ERR_PTR(ret);
 }
 
 static int __btrfs_prealloc_file_range(struct inode *inode, int mode,
index 20fd4aa48a8ce0df75ea9525e2f1ebbb35912a9a..06713a8fe26b4a3c618a1c7112e5a1b4ac50f24f 100644 (file)
@@ -209,7 +209,7 @@ int btree_readahead_hook(struct extent_buffer *eb, int err)
        /* find extent */
        spin_lock(&fs_info->reada_lock);
        re = radix_tree_lookup(&fs_info->reada_tree,
-                              eb->start >> PAGE_SHIFT);
+                              eb->start >> fs_info->sectorsize_bits);
        if (re)
                re->refcnt++;
        spin_unlock(&fs_info->reada_lock);
@@ -240,7 +240,7 @@ static struct reada_zone *reada_find_zone(struct btrfs_device *dev, u64 logical,
        zone = NULL;
        spin_lock(&fs_info->reada_lock);
        ret = radix_tree_gang_lookup(&dev->reada_zones, (void **)&zone,
-                                    logical >> PAGE_SHIFT, 1);
+                                    logical >> fs_info->sectorsize_bits, 1);
        if (ret == 1 && logical >= zone->start && logical <= zone->end) {
                kref_get(&zone->refcnt);
                spin_unlock(&fs_info->reada_lock);
@@ -283,13 +283,13 @@ static struct reada_zone *reada_find_zone(struct btrfs_device *dev, u64 logical,
 
        spin_lock(&fs_info->reada_lock);
        ret = radix_tree_insert(&dev->reada_zones,
-                               (unsigned long)(zone->end >> PAGE_SHIFT),
-                               zone);
+                       (unsigned long)(zone->end >> fs_info->sectorsize_bits),
+                       zone);
 
        if (ret == -EEXIST) {
                kfree(zone);
                ret = radix_tree_gang_lookup(&dev->reada_zones, (void **)&zone,
-                                            logical >> PAGE_SHIFT, 1);
+                                       logical >> fs_info->sectorsize_bits, 1);
                if (ret == 1 && logical >= zone->start && logical <= zone->end)
                        kref_get(&zone->refcnt);
                else
@@ -315,7 +315,7 @@ static struct reada_extent *reada_find_extent(struct btrfs_fs_info *fs_info,
        u64 length;
        int real_stripes;
        int nzones = 0;
-       unsigned long index = logical >> PAGE_SHIFT;
+       unsigned long index = logical >> fs_info->sectorsize_bits;
        int dev_replace_is_ongoing;
        int have_zone = 0;
 
@@ -497,7 +497,7 @@ static void reada_extent_put(struct btrfs_fs_info *fs_info,
                             struct reada_extent *re)
 {
        int i;
-       unsigned long index = re->logical >> PAGE_SHIFT;
+       unsigned long index = re->logical >> fs_info->sectorsize_bits;
 
        spin_lock(&fs_info->reada_lock);
        if (--re->refcnt) {
@@ -538,11 +538,12 @@ static void reada_extent_put(struct btrfs_fs_info *fs_info,
 static void reada_zone_release(struct kref *kref)
 {
        struct reada_zone *zone = container_of(kref, struct reada_zone, refcnt);
+       struct btrfs_fs_info *fs_info = zone->device->fs_info;
 
-       lockdep_assert_held(&zone->device->fs_info->reada_lock);
+       lockdep_assert_held(&fs_info->reada_lock);
 
        radix_tree_delete(&zone->device->reada_zones,
-                         zone->end >> PAGE_SHIFT);
+                         zone->end >> fs_info->sectorsize_bits);
 
        kfree(zone);
 }
@@ -593,7 +594,7 @@ static int reada_add_block(struct reada_control *rc, u64 logical,
 static void reada_peer_zones_set_lock(struct reada_zone *zone, int lock)
 {
        int i;
-       unsigned long index = zone->end >> PAGE_SHIFT;
+       unsigned long index = zone->end >> zone->device->fs_info->sectorsize_bits;
 
        for (i = 0; i < zone->ndevs; ++i) {
                struct reada_zone *peer;
@@ -628,7 +629,7 @@ static int reada_pick_zone(struct btrfs_device *dev)
                                             (void **)&zone, index, 1);
                if (ret == 0)
                        break;
-               index = (zone->end >> PAGE_SHIFT) + 1;
+               index = (zone->end >> dev->fs_info->sectorsize_bits) + 1;
                if (zone->locked) {
                        if (zone->elems > top_locked_elems) {
                                top_locked_elems = zone->elems;
@@ -709,7 +710,7 @@ static int reada_start_machine_dev(struct btrfs_device *dev)
         * plugging to speed things up
         */
        ret = radix_tree_gang_lookup(&dev->reada_extents, (void **)&re,
-                                    dev->reada_next >> PAGE_SHIFT, 1);
+                               dev->reada_next >> fs_info->sectorsize_bits, 1);
        if (ret == 0 || re->logical > dev->reada_curr_zone->end) {
                ret = reada_pick_zone(dev);
                if (!ret) {
@@ -718,7 +719,7 @@ static int reada_start_machine_dev(struct btrfs_device *dev)
                }
                re = NULL;
                ret = radix_tree_gang_lookup(&dev->reada_extents, (void **)&re,
-                                       dev->reada_next >> PAGE_SHIFT, 1);
+                               dev->reada_next >> fs_info->sectorsize_bits, 1);
        }
        if (ret == 0) {
                spin_unlock(&fs_info->reada_lock);
@@ -885,7 +886,7 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all)
                                pr_cont(" curr off %llu",
                                        device->reada_next - zone->start);
                        pr_cont("\n");
-                       index = (zone->end >> PAGE_SHIFT) + 1;
+                       index = (zone->end >> fs_info->sectorsize_bits) + 1;
                }
                cnt = 0;
                index = 0;
@@ -910,7 +911,7 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all)
                                }
                        }
                        pr_cont("\n");
-                       index = (re->logical >> PAGE_SHIFT) + 1;
+                       index = (re->logical >> fs_info->sectorsize_bits) + 1;
                        if (++cnt > 15)
                                break;
                }
@@ -926,7 +927,7 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all)
                if (ret == 0)
                        break;
                if (!re->scheduled) {
-                       index = (re->logical >> PAGE_SHIFT) + 1;
+                       index = (re->logical >> fs_info->sectorsize_bits) + 1;
                        continue;
                }
                pr_debug("re: logical %llu size %u list empty %d scheduled %d",
@@ -942,7 +943,7 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all)
                        }
                }
                pr_cont("\n");
-               index = (re->logical >> PAGE_SHIFT) + 1;
+               index = (re->logical >> fs_info->sectorsize_bits) + 1;
        }
        spin_unlock(&fs_info->reada_lock);
 }
index c2900ebf767a232e6141b2de7c1cd0f7fb1cc995..3d9088eab2fca3492762ae9f370e13d25baa9f3b 100644 (file)
@@ -1428,7 +1428,7 @@ static void scrub_recheck_block_on_raid56(struct btrfs_fs_info *fs_info,
        if (!first_page->dev->bdev)
                goto out;
 
-       bio = btrfs_io_bio_alloc(BIO_MAX_PAGES);
+       bio = btrfs_io_bio_alloc(BIO_MAX_VECS);
        bio_set_dev(bio, first_page->dev->bdev);
 
        for (page_num = 0; page_num < sblock->page_count; page_num++) {
index 2f1acc9aea9ea058093c861ef379f6039117a558..92a3686277918a67e22cdda63575344138830f30 100644 (file)
@@ -3169,10 +3169,6 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
 
        mutex_lock(&log_root_tree->log_mutex);
 
-       index2 = log_root_tree->log_transid % 2;
-       list_add_tail(&root_log_ctx.list, &log_root_tree->log_ctxs[index2]);
-       root_log_ctx.log_transid = log_root_tree->log_transid;
-
        if (btrfs_is_zoned(fs_info)) {
                if (!log_root_tree->node) {
                        ret = btrfs_alloc_log_tree_node(trans, log_root_tree);
@@ -3183,6 +3179,10 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
                }
        }
 
+       index2 = log_root_tree->log_transid % 2;
+       list_add_tail(&root_log_ctx.list, &log_root_tree->log_ctxs[index2]);
+       root_log_ctx.log_transid = log_root_tree->log_transid;
+
        /*
         * Now we are safe to update the log_root_tree because we're under the
         * log_mutex, and we're a current writer so we're holding the commit
index 3aedc484e4401e7234cec63726c14c84c4afa59f..88a7958170ee0f7612e94f576f7da965e3c235ba 100644 (file)
@@ -207,7 +207,7 @@ static int cifs_debug_files_proc_show(struct seq_file *m, void *v)
                                                from_kuid(&init_user_ns, cfile->uid),
                                                cfile->dentry);
 #ifdef CONFIG_CIFS_DEBUG2
-                                       seq_printf(m, " 0x%llx\n", cfile->fid.mid);
+                                       seq_printf(m, " %llu\n", cfile->fid.mid);
 #else
                                        seq_printf(m, "\n");
 #endif /* CIFS_DEBUG2 */
index f2d730fffccb3181f70a452640bc8ca2eb0744cb..d829b8bf833e3fc837d15ee279d099aa5423d2f2 100644 (file)
@@ -248,7 +248,7 @@ nlmsg_fail:
 
 /*
  * Try to find a matching registration for the tcon's server name and share name.
- * Calls to this funciton must be protected by cifs_swnreg_idr_mutex.
+ * Calls to this function must be protected by cifs_swnreg_idr_mutex.
  * TODO Try to avoid memory allocations
  */
 static struct cifs_swn_reg *cifs_find_swn_reg(struct cifs_tcon *tcon)
index 9d29eb9660c28141058cb48b7761ec0e916e1ac2..2be22a5c690f88f7ff975071e99944988540fe13 100644 (file)
@@ -1118,7 +1118,6 @@ static int set_chmod_dacl(struct cifs_acl *pdacl, struct cifs_acl *pndacl,
        /* Retain old ACEs which we can retain */
        for (i = 0; i < src_num_aces; ++i) {
                pntace = (struct cifs_ace *) (acl_base + size);
-               pnntace = (struct cifs_ace *) (nacl_base + nsize);
 
                if (!new_aces_set && (pntace->flags & INHERITED_ACE)) {
                        /* Place the new ACEs in between existing explicit and inherited */
@@ -1131,14 +1130,18 @@ static int set_chmod_dacl(struct cifs_acl *pdacl, struct cifs_acl *pndacl,
                }
 
                /* If it's any one of the ACE we're replacing, skip! */
-               if ((compare_sids(&pntace->sid, &sid_unix_NFS_mode) == 0) ||
+               if (!mode_from_sid &&
+                               ((compare_sids(&pntace->sid, &sid_unix_NFS_mode) == 0) ||
                                (compare_sids(&pntace->sid, pownersid) == 0) ||
                                (compare_sids(&pntace->sid, pgrpsid) == 0) ||
                                (compare_sids(&pntace->sid, &sid_everyone) == 0) ||
-                               (compare_sids(&pntace->sid, &sid_authusers) == 0)) {
+                               (compare_sids(&pntace->sid, &sid_authusers) == 0))) {
                        goto next_ace;
                }
 
+               /* update the pointer to the next ACE to populate*/
+               pnntace = (struct cifs_ace *) (nacl_base + nsize);
+
                nsize += cifs_copy_ace(pnntace, pntace, NULL);
                num_aces++;
 
index d43e935d2df4365371200276509d4c72bab13289..099ad9f3660bb28db1b6a9aea9538282b41c6455 100644 (file)
@@ -290,7 +290,7 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
                rc = server->ops->queryfs(xid, tcon, cifs_sb, buf);
 
        free_xid(xid);
-       return 0;
+       return rc;
 }
 
 static long cifs_fallocate(struct file *file, int mode, loff_t off, loff_t len)
index 3de3c5908a72d7f88b59ef566b30e4c8ffa9617c..31fc8695abd6d76c76b15fb67c772677946049e5 100644 (file)
@@ -257,7 +257,7 @@ struct smb_version_operations {
        /* verify the message */
        int (*check_message)(char *, unsigned int, struct TCP_Server_Info *);
        bool (*is_oplock_break)(char *, struct TCP_Server_Info *);
-       int (*handle_cancelled_mid)(char *, struct TCP_Server_Info *);
+       int (*handle_cancelled_mid)(struct mid_q_entry *, struct TCP_Server_Info *);
        void (*downgrade_oplock)(struct TCP_Server_Info *server,
                                 struct cifsInodeInfo *cinode, __u32 oplock,
                                 unsigned int epoch, bool *purge_cache);
@@ -1705,16 +1705,17 @@ static inline bool is_retryable_error(int error)
 #define   CIFS_NO_RSP_BUF   0x040    /* no response buffer required */
 
 /* Type of request operation */
-#define   CIFS_ECHO_OP      0x080    /* echo request */
-#define   CIFS_OBREAK_OP   0x0100    /* oplock break request */
-#define   CIFS_NEG_OP      0x0200    /* negotiate request */
+#define   CIFS_ECHO_OP            0x080  /* echo request */
+#define   CIFS_OBREAK_OP          0x0100 /* oplock break request */
+#define   CIFS_NEG_OP             0x0200 /* negotiate request */
+#define   CIFS_CP_CREATE_CLOSE_OP 0x0400 /* compound create+close request */
 /* Lower bitmask values are reserved by others below. */
-#define   CIFS_SESS_OP     0x2000    /* session setup request */
-#define   CIFS_OP_MASK     0x2380    /* mask request type */
+#define   CIFS_SESS_OP            0x2000 /* session setup request */
+#define   CIFS_OP_MASK            0x2780 /* mask request type */
 
-#define   CIFS_HAS_CREDITS 0x0400    /* already has credits */
-#define   CIFS_TRANSFORM_REQ 0x0800    /* transform request before sending */
-#define   CIFS_NO_SRV_RSP    0x1000    /* there is no server response */
+#define   CIFS_HAS_CREDITS        0x0400 /* already has credits */
+#define   CIFS_TRANSFORM_REQ      0x0800 /* transform request before sending */
+#define   CIFS_NO_SRV_RSP         0x1000 /* there is no server response */
 
 /* Security Flags: indicate type of session setup needed */
 #define   CIFSSEC_MAY_SIGN     0x00001
index 112692300fb60a15a374c8729050cd87d6330146..eec8a2052da226bdda1cd4e61a68b367d0201d7a 100644 (file)
@@ -741,7 +741,7 @@ static void clean_demultiplex_info(struct TCP_Server_Info *server)
                spin_lock(&GlobalMid_Lock);
                list_for_each_safe(tmp, tmp2, &server->pending_mid_q) {
                        mid_entry = list_entry(tmp, struct mid_q_entry, qhead);
-                       cifs_dbg(FYI, "Clearing mid 0x%llx\n", mid_entry->mid);
+                       cifs_dbg(FYI, "Clearing mid %llu\n", mid_entry->mid);
                        kref_get(&mid_entry->refcount);
                        mid_entry->mid_state = MID_SHUTDOWN;
                        list_move(&mid_entry->qhead, &dispose_list);
@@ -752,7 +752,7 @@ static void clean_demultiplex_info(struct TCP_Server_Info *server)
                /* now walk dispose list and issue callbacks */
                list_for_each_safe(tmp, tmp2, &dispose_list) {
                        mid_entry = list_entry(tmp, struct mid_q_entry, qhead);
-                       cifs_dbg(FYI, "Callback mid 0x%llx\n", mid_entry->mid);
+                       cifs_dbg(FYI, "Callback mid %llu\n", mid_entry->mid);
                        list_del_init(&mid_entry->qhead);
                        mid_entry->callback(mid_entry);
                        cifs_mid_q_entry_release(mid_entry);
@@ -1429,6 +1429,11 @@ smbd_connected:
        tcp_ses->min_offload = ctx->min_offload;
        tcp_ses->tcpStatus = CifsNeedNegotiate;
 
+       if ((ctx->max_credits < 20) || (ctx->max_credits > 60000))
+               tcp_ses->max_credits = SMB2_MAX_CREDITS_AVAILABLE;
+       else
+               tcp_ses->max_credits = ctx->max_credits;
+
        tcp_ses->nr_targets = 1;
        tcp_ses->ignore_signature = ctx->ignore_signature;
        /* thread spawned, put it on the list */
@@ -2832,11 +2837,6 @@ static int mount_get_conns(struct smb3_fs_context *ctx, struct cifs_sb_info *cif
 
        *nserver = server;
 
-       if ((ctx->max_credits < 20) || (ctx->max_credits > 60000))
-               server->max_credits = SMB2_MAX_CREDITS_AVAILABLE;
-       else
-               server->max_credits = ctx->max_credits;
-
        /* get a reference to a SMB session */
        ses = cifs_get_smb_ses(server, ctx);
        if (IS_ERR(ses)) {
index 892f51a21278beed2e6cfd590b234c65134254a1..78889024a7ed04cabf5eb7b99e52b5b17fb9e931 100644 (file)
@@ -1196,9 +1196,11 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
                pr_warn_once("Witness protocol support is experimental\n");
                break;
        case Opt_rootfs:
-#ifdef CONFIG_CIFS_ROOT
-               ctx->rootfs = true;
+#ifndef CONFIG_CIFS_ROOT
+               cifs_dbg(VFS, "rootfs support requires CONFIG_CIFS_ROOT config option\n");
+               goto cifs_parse_mount_err;
 #endif
+               ctx->rootfs = true;
                break;
        case Opt_posixpaths:
                if (result.negated)
index 7c61bc9573c02b5b4edf6d859360656bd06f4da9..f2df4422e54ae0c8262860165a93a8d96df229e2 100644 (file)
@@ -2395,7 +2395,7 @@ int cifs_getattr(struct user_namespace *mnt_userns, const struct path *path,
         * We need to be sure that all dirty pages are written and the server
         * has actual ctime, mtime and file length.
         */
-       if ((request_mask & (STATX_CTIME | STATX_MTIME | STATX_SIZE)) &&
+       if ((request_mask & (STATX_CTIME | STATX_MTIME | STATX_SIZE | STATX_BLOCKS)) &&
            !CIFS_CACHE_READ(CIFS_I(inode)) &&
            inode->i_mapping && inode->i_mapping->nrpages != 0) {
                rc = filemap_fdatawait(inode->i_mapping);
@@ -2585,6 +2585,14 @@ set_size_out:
        if (rc == 0) {
                cifsInode->server_eof = attrs->ia_size;
                cifs_setsize(inode, attrs->ia_size);
+               /*
+                * i_blocks is not related to (i_size / i_blksize), but instead
+                * 512 byte (2**9) size is required for calculating num blocks.
+                * Until we can query the server for actual allocation size,
+                * this is best estimate we have for blocks allocated for a file
+                * Number of blocks must be rounded up so size 1 is not 0 blocks
+                */
+               inode->i_blocks = (512 - 1 + attrs->ia_size) >> 9;
 
                /*
                 * The man page of truncate says if the size changed,
index 183a3a868d7b90946a9cc9f9b1a2fcac05ae3d45..63d517b9f2ffefddcc5cb01cf07f1c2b2df68826 100644 (file)
@@ -230,6 +230,7 @@ cifs_ses_add_channel(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses,
        ctx.noautotune = ses->server->noautotune;
        ctx.sockopt_tcp_nodelay = ses->server->tcp_nodelay;
        ctx.echo_interval = ses->server->echo_interval / HZ;
+       ctx.max_credits = ses->server->max_credits;
 
        /*
         * This will be used for encoding/decoding user/domain/pw
index 1f900b81c34ae62516c26fd48e6e2d17629f3be3..a718dc77e604edfe0c91933a435c18a7cd816316 100644 (file)
@@ -358,6 +358,7 @@ smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
        if (cfile)
                goto after_close;
        /* Close */
+       flags |= CIFS_CP_CREATE_CLOSE_OP;
        rqst[num_rqst].rq_iov = &vars->close_iov[0];
        rqst[num_rqst].rq_nvec = 1;
        rc = SMB2_close_init(tcon, server,
index 60d4bd1eae2b3aaff52ddb9a783ad97e22284914..b50164e2c88dc65df34cfca7e5b2411fdf3d818e 100644 (file)
@@ -767,7 +767,7 @@ smb2_cancelled_close_fid(struct work_struct *work)
        int rc;
 
        if (cancelled->mid)
-               cifs_tcon_dbg(VFS, "Close unmatched open for MID:%llx\n",
+               cifs_tcon_dbg(VFS, "Close unmatched open for MID:%llu\n",
                              cancelled->mid);
        else
                cifs_tcon_dbg(VFS, "Close interrupted close\n");
@@ -844,14 +844,14 @@ smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid,
 }
 
 int
-smb2_handle_cancelled_mid(char *buffer, struct TCP_Server_Info *server)
+smb2_handle_cancelled_mid(struct mid_q_entry *mid, struct TCP_Server_Info *server)
 {
-       struct smb2_sync_hdr *sync_hdr = (struct smb2_sync_hdr *)buffer;
-       struct smb2_create_rsp *rsp = (struct smb2_create_rsp *)buffer;
+       struct smb2_sync_hdr *sync_hdr = mid->resp_buf;
+       struct smb2_create_rsp *rsp = mid->resp_buf;
        struct cifs_tcon *tcon;
        int rc;
 
-       if (sync_hdr->Command != SMB2_CREATE ||
+       if ((mid->optype & CIFS_CP_CREATE_CLOSE_OP) || sync_hdr->Command != SMB2_CREATE ||
            sync_hdr->Status != STATUS_SUCCESS)
                return 0;
 
index f5087295424c65dfa1c9444f02890f8fcec8fc41..9bae7e8deb09e07bc28332f8c41767a239858ccd 100644 (file)
@@ -1195,7 +1195,7 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon,
        struct TCP_Server_Info *server = cifs_pick_channel(ses);
        __le16 *utf16_path = NULL;
        int ea_name_len = strlen(ea_name);
-       int flags = 0;
+       int flags = CIFS_CP_CREATE_CLOSE_OP;
        int len;
        struct smb_rqst rqst[3];
        int resp_buftype[3];
@@ -1573,7 +1573,7 @@ smb2_ioctl_query_info(const unsigned int xid,
        struct smb_query_info qi;
        struct smb_query_info __user *pqi;
        int rc = 0;
-       int flags = 0;
+       int flags = CIFS_CP_CREATE_CLOSE_OP;
        struct smb2_query_info_rsp *qi_rsp = NULL;
        struct smb2_ioctl_rsp *io_rsp = NULL;
        void *buffer = NULL;
@@ -2577,7 +2577,7 @@ smb2_query_info_compound(const unsigned int xid, struct cifs_tcon *tcon,
 {
        struct cifs_ses *ses = tcon->ses;
        struct TCP_Server_Info *server = cifs_pick_channel(ses);
-       int flags = 0;
+       int flags = CIFS_CP_CREATE_CLOSE_OP;
        struct smb_rqst rqst[3];
        int resp_buftype[3];
        struct kvec rsp_iov[3];
@@ -2975,7 +2975,7 @@ smb2_query_symlink(const unsigned int xid, struct cifs_tcon *tcon,
        unsigned int sub_offset;
        unsigned int print_len;
        unsigned int print_offset;
-       int flags = 0;
+       int flags = CIFS_CP_CREATE_CLOSE_OP;
        struct smb_rqst rqst[3];
        int resp_buftype[3];
        struct kvec rsp_iov[3];
@@ -3157,7 +3157,7 @@ smb2_query_reparse_tag(const unsigned int xid, struct cifs_tcon *tcon,
        struct cifs_open_parms oparms;
        struct cifs_fid fid;
        struct TCP_Server_Info *server = cifs_pick_channel(tcon->ses);
-       int flags = 0;
+       int flags = CIFS_CP_CREATE_CLOSE_OP;
        struct smb_rqst rqst[3];
        int resp_buftype[3];
        struct kvec rsp_iov[3];
index 4bbb6126b14d6e9a3703129a5616dff47611e11f..2199a9bfae8f79b60b35f53e9ea3dc696beb4665 100644 (file)
@@ -4041,8 +4041,7 @@ smb2_async_readv(struct cifs_readdata *rdata)
        if (rdata->credits.value > 0) {
                shdr->CreditCharge = cpu_to_le16(DIV_ROUND_UP(rdata->bytes,
                                                SMB2_MAX_BUFFER_SIZE));
-               shdr->CreditRequest =
-                       cpu_to_le16(le16_to_cpu(shdr->CreditCharge) + 1);
+               shdr->CreditRequest = cpu_to_le16(le16_to_cpu(shdr->CreditCharge) + 8);
 
                rc = adjust_credits(server, &rdata->credits, rdata->bytes);
                if (rc)
@@ -4348,8 +4347,7 @@ smb2_async_writev(struct cifs_writedata *wdata,
        if (wdata->credits.value > 0) {
                shdr->CreditCharge = cpu_to_le16(DIV_ROUND_UP(wdata->bytes,
                                                    SMB2_MAX_BUFFER_SIZE));
-               shdr->CreditRequest =
-                       cpu_to_le16(le16_to_cpu(shdr->CreditCharge) + 1);
+               shdr->CreditRequest = cpu_to_le16(le16_to_cpu(shdr->CreditCharge) + 8);
 
                rc = adjust_credits(server, &wdata->credits, wdata->bytes);
                if (rc)
index 9565e27681a541447c74ee0d5a2f745277f935f5..a2eb34a8d9c910b2aa616ba3cc6c5d145cb54566 100644 (file)
@@ -246,8 +246,7 @@ extern int SMB2_oplock_break(const unsigned int xid, struct cifs_tcon *tcon,
 extern int smb2_handle_cancelled_close(struct cifs_tcon *tcon,
                                       __u64 persistent_fid,
                                       __u64 volatile_fid);
-extern int smb2_handle_cancelled_mid(char *buffer,
-                                       struct TCP_Server_Info *server);
+extern int smb2_handle_cancelled_mid(struct mid_q_entry *mid, struct TCP_Server_Info *server);
 void smb2_cancelled_close_fid(struct work_struct *work);
 extern int SMB2_QFS_info(const unsigned int xid, struct cifs_tcon *tcon,
                         u64 persistent_file_id, u64 volatile_file_id,
index e90a1d1380b0697f2cf1aea53c50265ca068c42e..c1725b55f36488fd2532bef47176342aacad66b4 100644 (file)
@@ -101,7 +101,7 @@ static void _cifs_mid_q_entry_release(struct kref *refcount)
        if (midEntry->resp_buf && (midEntry->mid_flags & MID_WAIT_CANCELLED) &&
            midEntry->mid_state == MID_RESPONSE_RECEIVED &&
            server->ops->handle_cancelled_mid)
-               server->ops->handle_cancelled_mid(midEntry->resp_buf, server);
+               server->ops->handle_cancelled_mid(midEntry, server);
 
        midEntry->mid_state = MID_FREE;
        atomic_dec(&midCount);
@@ -1196,9 +1196,12 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
        /*
         * Compounding is never used during session establish.
         */
-       if ((ses->status == CifsNew) || (optype & CIFS_NEG_OP) || (optype & CIFS_SESS_OP))
+       if ((ses->status == CifsNew) || (optype & CIFS_NEG_OP) || (optype & CIFS_SESS_OP)) {
+               mutex_lock(&server->srv_mutex);
                smb311_update_preauth_hash(ses, rqst[0].rq_iov,
                                           rqst[0].rq_nvec);
+               mutex_unlock(&server->srv_mutex);
+       }
 
        for (i = 0; i < num_rqst; i++) {
                rc = wait_for_response(server, midQ[i]);
@@ -1207,7 +1210,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
        }
        if (rc != 0) {
                for (; i < num_rqst; i++) {
-                       cifs_server_dbg(VFS, "Cancelling wait for mid %llu cmd: %d\n",
+                       cifs_server_dbg(FYI, "Cancelling wait for mid %llu cmd: %d\n",
                                 midQ[i]->mid, le16_to_cpu(midQ[i]->command));
                        send_cancel(server, &rqst[i], midQ[i]);
                        spin_lock(&GlobalMid_Lock);
@@ -1266,7 +1269,9 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
                        .iov_base = resp_iov[0].iov_base,
                        .iov_len = resp_iov[0].iov_len
                };
+               mutex_lock(&server->srv_mutex);
                smb311_update_preauth_hash(ses, &iov, 1);
+               mutex_unlock(&server->srv_mutex);
        }
 
 out:
index 1f0270229d7b7e099765e1658bab5a0c6bc596a1..da8351d1e455209150954bf6cc002e5643d97870 100644 (file)
@@ -378,7 +378,7 @@ static int __configfs_open_file(struct inode *inode, struct file *file, int type
 
        attr = to_attr(dentry);
        if (!attr)
-               goto out_put_item;
+               goto out_free_buffer;
 
        if (type & CONFIGFS_ITEM_BIN_ATTR) {
                buffer->bin_attr = to_bin_attr(dentry);
@@ -391,7 +391,7 @@ static int __configfs_open_file(struct inode *inode, struct file *file, int type
        /* Grab the module reference for this attribute if we have one */
        error = -ENODEV;
        if (!try_module_get(buffer->owner))
-               goto out_put_item;
+               goto out_free_buffer;
 
        error = -EACCES;
        if (!buffer->item->ci_type)
@@ -435,8 +435,6 @@ static int __configfs_open_file(struct inode *inode, struct file *file, int type
 
 out_put_module:
        module_put(buffer->owner);
-out_put_item:
-       config_item_put(buffer->item);
 out_free_buffer:
        up_read(&frag->frag_sem);
        kfree(buffer);
index b048a0e3851629081eba466cbe85e2d5eb73abb6..68a2de6b5a9b13e76b0a32c7b724716d669a7dab 100644 (file)
@@ -52,7 +52,7 @@ static int fscrypt_zeroout_range_inline_crypt(const struct inode *inode,
        int num_pages = 0;
 
        /* This always succeeds since __GFP_DIRECT_RECLAIM is set. */
-       bio = bio_alloc(GFP_NOFS, BIO_MAX_PAGES);
+       bio = bio_alloc(GFP_NOFS, BIO_MAX_VECS);
 
        while (len) {
                unsigned int blocks_this_page = min(len, blocks_per_page);
@@ -74,7 +74,7 @@ static int fscrypt_zeroout_range_inline_crypt(const struct inode *inode,
                len -= blocks_this_page;
                lblk += blocks_this_page;
                pblk += blocks_this_page;
-               if (num_pages == BIO_MAX_PAGES || !len ||
+               if (num_pages == BIO_MAX_VECS || !len ||
                    !fscrypt_mergeable_bio(bio, inode, lblk)) {
                        err = submit_bio_wait(bio);
                        if (err)
@@ -126,7 +126,7 @@ int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk,
                return fscrypt_zeroout_range_inline_crypt(inode, lblk, pblk,
                                                          len);
 
-       BUILD_BUG_ON(ARRAY_SIZE(pages) > BIO_MAX_PAGES);
+       BUILD_BUG_ON(ARRAY_SIZE(pages) > BIO_MAX_VECS);
        nr_pages = min_t(unsigned int, ARRAY_SIZE(pages),
                         (len + blocks_per_page - 1) >> blocks_per_page_bits);
 
index f88851c5c250b5608a4f40fc221ddee9fa8e2108..1249e74b3bf04267cf2f67dfd5af4596e0e9bdcf 100644 (file)
@@ -129,6 +129,7 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio,
                                              struct page *page,
                                              erofs_off_t *last_block,
                                              unsigned int nblocks,
+                                             unsigned int *eblks,
                                              bool ra)
 {
        struct inode *const inode = mapping->host;
@@ -145,8 +146,7 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio,
 
        /* note that for readpage case, bio also equals to NULL */
        if (bio &&
-           /* not continuous */
-           *last_block + 1 != current_block) {
+           (*last_block + 1 != current_block || !*eblks)) {
 submit_bio_retry:
                submit_bio(bio);
                bio = NULL;
@@ -216,7 +216,8 @@ submit_bio_retry:
                if (nblocks > DIV_ROUND_UP(map.m_plen, PAGE_SIZE))
                        nblocks = DIV_ROUND_UP(map.m_plen, PAGE_SIZE);
 
-               bio = bio_alloc(GFP_NOIO, bio_max_segs(nblocks));
+               *eblks = bio_max_segs(nblocks);
+               bio = bio_alloc(GFP_NOIO, *eblks);
 
                bio->bi_end_io = erofs_readendio;
                bio_set_dev(bio, sb->s_bdev);
@@ -229,16 +230,8 @@ submit_bio_retry:
        /* out of the extent or bio is full */
        if (err < PAGE_SIZE)
                goto submit_bio_retry;
-
+       --*eblks;
        *last_block = current_block;
-
-       /* shift in advance in case of it followed by too many gaps */
-       if (bio->bi_iter.bi_size >= bio->bi_max_vecs * PAGE_SIZE) {
-               /* err should reassign to 0 after submitting */
-               err = 0;
-               goto submit_bio_out;
-       }
-
        return bio;
 
 err_out:
@@ -252,7 +245,6 @@ has_updated:
 
        /* if updated manually, continuous pages has a gap */
        if (bio)
-submit_bio_out:
                submit_bio(bio);
        return err ? ERR_PTR(err) : NULL;
 }
@@ -264,23 +256,26 @@ submit_bio_out:
 static int erofs_raw_access_readpage(struct file *file, struct page *page)
 {
        erofs_off_t last_block;
+       unsigned int eblks;
        struct bio *bio;
 
        trace_erofs_readpage(page, true);
 
        bio = erofs_read_raw_page(NULL, page->mapping,
-                                 page, &last_block, 1, false);
+                                 page, &last_block, 1, &eblks, false);
 
        if (IS_ERR(bio))
                return PTR_ERR(bio);
 
-       DBG_BUGON(bio); /* since we have only one bio -- must be NULL */
+       if (bio)
+               submit_bio(bio);
        return 0;
 }
 
 static void erofs_raw_access_readahead(struct readahead_control *rac)
 {
        erofs_off_t last_block;
+       unsigned int eblks;
        struct bio *bio = NULL;
        struct page *page;
 
@@ -291,7 +286,7 @@ static void erofs_raw_access_readahead(struct readahead_control *rac)
                prefetchw(&page->flags);
 
                bio = erofs_read_raw_page(bio, rac->mapping, page, &last_block,
-                               readahead_count(rac), true);
+                               readahead_count(rac), &eblks, true);
 
                /* all the page errors are ignored when readahead */
                if (IS_ERR(bio)) {
@@ -305,7 +300,6 @@ static void erofs_raw_access_readahead(struct readahead_control *rac)
                put_page(page);
        }
 
-       /* the rare case (end in gaps) */
        if (bio)
                submit_bio(bio);
 }
index 6cb356c4217b26d32c47fda6080b8a47770d3aa5..3851e1a64f730d115d57682699d7ab5f77674e60 100644 (file)
@@ -1235,7 +1235,7 @@ submit_bio_retry:
                        }
 
                        if (!bio) {
-                               bio = bio_alloc(GFP_NOIO, BIO_MAX_PAGES);
+                               bio = bio_alloc(GFP_NOIO, BIO_MAX_VECS);
 
                                bio->bi_end_io = z_erofs_decompressqueue_endio;
                                bio_set_dev(bio, sb->s_bdev);
index f45f9feebe59385469a12c040086ca976e83cc59..74a5172c2d838ab6336e222c5ead100097356ce2 100644 (file)
@@ -626,27 +626,41 @@ int ext4_claim_free_clusters(struct ext4_sb_info *sbi,
 
 /**
  * ext4_should_retry_alloc() - check if a block allocation should be retried
- * @sb:                        super block
- * @retries:           number of attemps has been made
+ * @sb:                        superblock
+ * @retries:           number of retry attempts made so far
  *
- * ext4_should_retry_alloc() is called when ENOSPC is returned, and if
- * it is profitable to retry the operation, this function will wait
- * for the current or committing transaction to complete, and then
- * return TRUE.  We will only retry once.
+ * ext4_should_retry_alloc() is called when ENOSPC is returned while
+ * attempting to allocate blocks.  If there's an indication that a pending
+ * journal transaction might free some space and allow another attempt to
+ * succeed, this function will wait for the current or committing transaction
+ * to complete and then return TRUE.
  */
 int ext4_should_retry_alloc(struct super_block *sb, int *retries)
 {
-       if (!ext4_has_free_clusters(EXT4_SB(sb), 1, 0) ||
-           (*retries)++ > 1 ||
-           !EXT4_SB(sb)->s_journal)
+       struct ext4_sb_info *sbi = EXT4_SB(sb);
+
+       if (!sbi->s_journal)
                return 0;
 
-       smp_mb();
-       if (EXT4_SB(sb)->s_mb_free_pending == 0)
+       if (++(*retries) > 3) {
+               percpu_counter_inc(&sbi->s_sra_exceeded_retry_limit);
                return 0;
+       }
 
+       /*
+        * if there's no indication that blocks are about to be freed it's
+        * possible we just missed a transaction commit that did so
+        */
+       smp_mb();
+       if (sbi->s_mb_free_pending == 0)
+               return ext4_has_free_clusters(sbi, 1, 0);
+
+       /*
+        * it's possible we've just missed a transaction commit here,
+        * so ignore the returned status
+        */
        jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);
-       jbd2_journal_force_commit_nested(EXT4_SB(sb)->s_journal);
+       (void) jbd2_journal_force_commit_nested(sbi->s_journal);
        return 1;
 }
 
index 644fd69185d369cb5da9baa9df73f76a69746e59..826a56e3bbd285671bd4ca6a827e767bcad21c33 100644 (file)
@@ -1484,6 +1484,7 @@ struct ext4_sb_info {
        struct percpu_counter s_freeinodes_counter;
        struct percpu_counter s_dirs_counter;
        struct percpu_counter s_dirtyclusters_counter;
+       struct percpu_counter s_sra_exceeded_retry_limit;
        struct blockgroup_lock *s_blockgroup_lock;
        struct proc_dir_entry *s_proc;
        struct kobject s_kobj;
@@ -2793,6 +2794,8 @@ void __ext4_fc_track_link(handle_t *handle, struct inode *inode,
        struct dentry *dentry);
 void ext4_fc_track_unlink(handle_t *handle, struct dentry *dentry);
 void ext4_fc_track_link(handle_t *handle, struct dentry *dentry);
+void __ext4_fc_track_create(handle_t *handle, struct inode *inode,
+                           struct dentry *dentry);
 void ext4_fc_track_create(handle_t *handle, struct dentry *dentry);
 void ext4_fc_track_inode(handle_t *handle, struct inode *inode);
 void ext4_fc_mark_ineligible(struct super_block *sb, int reason);
index 77c7c8a54da7371adc67e66287e6ddf68745fe2d..77c84d6f1af6b2489aa196e845f3b0b1a6060e83 100644 (file)
@@ -4382,7 +4382,7 @@ static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset,
 {
        struct inode *inode = file_inode(file);
        handle_t *handle;
-       int ret, ret2 = 0, ret3 = 0;
+       int ret = 0, ret2 = 0, ret3 = 0;
        int retries = 0;
        int depth = 0;
        struct ext4_map_blocks map;
index 6c4f19b0a55630b52ba5041aadf2c189ff11b81e..7541d0b5d7069a169600f5ba26e41de125bc6528 100644 (file)
@@ -513,10 +513,10 @@ void ext4_fc_track_link(handle_t *handle, struct dentry *dentry)
        __ext4_fc_track_link(handle, d_inode(dentry), dentry);
 }
 
-void ext4_fc_track_create(handle_t *handle, struct dentry *dentry)
+void __ext4_fc_track_create(handle_t *handle, struct inode *inode,
+                         struct dentry *dentry)
 {
        struct __track_dentry_update_args args;
-       struct inode *inode = d_inode(dentry);
        int ret;
 
        args.dentry = dentry;
@@ -527,6 +527,11 @@ void ext4_fc_track_create(handle_t *handle, struct dentry *dentry)
        trace_ext4_fc_track_create(inode, dentry, ret);
 }
 
+void ext4_fc_track_create(handle_t *handle, struct dentry *dentry)
+{
+       __ext4_fc_track_create(handle, d_inode(dentry), dentry);
+}
+
 /* __track_fn for inode tracking */
 static int __track_inode(struct inode *inode, void *arg, bool update)
 {
index 650c5acd2f2d99765622b5490b6e915e1c7aabbf..0948a43f1b3df379a55edc0694d34605aeb3ba76 100644 (file)
@@ -1938,13 +1938,13 @@ static int __ext4_journalled_writepage(struct page *page,
        if (!ret)
                ret = err;
 
-       if (!ext4_has_inline_data(inode))
-               ext4_walk_page_buffers(NULL, page_bufs, 0, len,
-                                      NULL, bput_one);
        ext4_set_inode_state(inode, EXT4_STATE_JDATA);
 out:
        unlock_page(page);
 out_no_pagelock:
+       if (!inline_data && page_bufs)
+               ext4_walk_page_buffers(NULL, page_bufs, 0, len,
+                                      NULL, bput_one);
        brelse(inode_bh);
        return ret;
 }
@@ -5026,7 +5026,7 @@ static int ext4_do_update_inode(handle_t *handle,
        struct ext4_inode_info *ei = EXT4_I(inode);
        struct buffer_head *bh = iloc->bh;
        struct super_block *sb = inode->i_sb;
-       int err = 0, rc, block;
+       int err = 0, block;
        int need_datasync = 0, set_large_file = 0;
        uid_t i_uid;
        gid_t i_gid;
@@ -5138,9 +5138,9 @@ static int ext4_do_update_inode(handle_t *handle,
                                              bh->b_data);
 
        BUFFER_TRACE(bh, "call ext4_handle_dirty_metadata");
-       rc = ext4_handle_dirty_metadata(handle, NULL, bh);
-       if (!err)
-               err = rc;
+       err = ext4_handle_dirty_metadata(handle, NULL, bh);
+       if (err)
+               goto out_brelse;
        ext4_clear_inode_state(inode, EXT4_STATE_NEW);
        if (set_large_file) {
                BUFFER_TRACE(EXT4_SB(sb)->s_sbh, "get write access");
@@ -5387,8 +5387,10 @@ int ext4_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
                        inode->i_gid = attr->ia_gid;
                error = ext4_mark_inode_dirty(handle, inode);
                ext4_journal_stop(handle);
-               if (unlikely(error))
+               if (unlikely(error)) {
+                       ext4_fc_stop_update(inode);
                        return error;
+               }
        }
 
        if (attr->ia_valid & ATTR_SIZE) {
index 99bf091fee10eeb0f6dbc250389e664ba8d07633..a02fadf4fc84e21e0b4b94182d66e07b2a52ae1c 100644 (file)
@@ -2709,8 +2709,15 @@ static int ext4_mb_init_backend(struct super_block *sb)
        }
 
        if (ext4_has_feature_flex_bg(sb)) {
-               /* a single flex group is supposed to be read by a single IO */
-               sbi->s_mb_prefetch = min(1 << sbi->s_es->s_log_groups_per_flex,
+               /* a single flex group is supposed to be read by a single IO.
+                * 2 ^ s_log_groups_per_flex != UINT_MAX as s_mb_prefetch is
+                * unsigned integer, so the maximum shift is 32.
+                */
+               if (sbi->s_es->s_log_groups_per_flex >= 32) {
+                       ext4_msg(sb, KERN_ERR, "too many log groups per flexible block group");
+                       goto err_freesgi;
+               }
+               sbi->s_mb_prefetch = min_t(uint, 1 << sbi->s_es->s_log_groups_per_flex,
                        BLK_MAX_SEGMENT_SIZE >> (sb->s_blocksize_bits - 9));
                sbi->s_mb_prefetch *= 8; /* 8 prefetch IOs in flight at most */
        } else {
index 686bf982c84e9e59764914f5cf9fd9e0a7229c6e..883e2a7cd4ab5e277c1bf22e5cd9b89473ff7170 100644 (file)
@@ -3613,6 +3613,31 @@ static int ext4_setent(handle_t *handle, struct ext4_renament *ent,
        return retval;
 }
 
+static void ext4_resetent(handle_t *handle, struct ext4_renament *ent,
+                         unsigned ino, unsigned file_type)
+{
+       struct ext4_renament old = *ent;
+       int retval = 0;
+
+       /*
+        * old->de could have moved from under us during make indexed dir,
+        * so the old->de may no longer valid and need to find it again
+        * before reset old inode info.
+        */
+       old.bh = ext4_find_entry(old.dir, &old.dentry->d_name, &old.de, NULL);
+       if (IS_ERR(old.bh))
+               retval = PTR_ERR(old.bh);
+       if (!old.bh)
+               retval = -ENOENT;
+       if (retval) {
+               ext4_std_error(old.dir->i_sb, retval);
+               return;
+       }
+
+       ext4_setent(handle, &old, ino, file_type);
+       brelse(old.bh);
+}
+
 static int ext4_find_delete_entry(handle_t *handle, struct inode *dir,
                                  const struct qstr *d_name)
 {
@@ -3774,14 +3799,14 @@ static int ext4_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
         */
        retval = -ENOENT;
        if (!old.bh || le32_to_cpu(old.de->inode) != old.inode->i_ino)
-               goto end_rename;
+               goto release_bh;
 
        new.bh = ext4_find_entry(new.dir, &new.dentry->d_name,
                                 &new.de, &new.inlined);
        if (IS_ERR(new.bh)) {
                retval = PTR_ERR(new.bh);
                new.bh = NULL;
-               goto end_rename;
+               goto release_bh;
        }
        if (new.bh) {
                if (!new.inode) {
@@ -3798,15 +3823,13 @@ static int ext4_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
                handle = ext4_journal_start(old.dir, EXT4_HT_DIR, credits);
                if (IS_ERR(handle)) {
                        retval = PTR_ERR(handle);
-                       handle = NULL;
-                       goto end_rename;
+                       goto release_bh;
                }
        } else {
                whiteout = ext4_whiteout_for_rename(mnt_userns, &old, credits, &handle);
                if (IS_ERR(whiteout)) {
                        retval = PTR_ERR(whiteout);
-                       whiteout = NULL;
-                       goto end_rename;
+                       goto release_bh;
                }
        }
 
@@ -3850,6 +3873,7 @@ static int ext4_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
                retval = ext4_mark_inode_dirty(handle, whiteout);
                if (unlikely(retval))
                        goto end_rename;
+
        }
        if (!new.bh) {
                retval = ext4_add_entry(handle, new.dentry, old.inode);
@@ -3923,6 +3947,8 @@ static int ext4_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
                        ext4_fc_track_unlink(handle, new.dentry);
                __ext4_fc_track_link(handle, old.inode, new.dentry);
                __ext4_fc_track_unlink(handle, old.inode, old.dentry);
+               if (whiteout)
+                       __ext4_fc_track_create(handle, whiteout, old.dentry);
        }
 
        if (new.inode) {
@@ -3937,19 +3963,21 @@ static int ext4_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
 end_rename:
        if (whiteout) {
                if (retval) {
-                       ext4_setent(handle, &old,
-                               old.inode->i_ino, old_file_type);
+                       ext4_resetent(handle, &old,
+                                     old.inode->i_ino, old_file_type);
                        drop_nlink(whiteout);
+                       ext4_orphan_add(handle, whiteout);
                }
                unlock_new_inode(whiteout);
+               ext4_journal_stop(handle);
                iput(whiteout);
-
+       } else {
+               ext4_journal_stop(handle);
        }
+release_bh:
        brelse(old.dir_bh);
        brelse(old.bh);
        brelse(new.bh);
-       if (handle)
-               ext4_journal_stop(handle);
        return retval;
 }
 
index 03a44a0de86addd1d0ed643053ab5ff84a9df9d1..f038d578d8d8ff3ab21f260a5fa011cc9150e60b 100644 (file)
@@ -398,7 +398,7 @@ static void io_submit_init_bio(struct ext4_io_submit *io,
         * bio_alloc will _always_ be able to allocate a bio if
         * __GFP_DIRECT_RECLAIM is set, see comments for bio_alloc_bioset().
         */
-       bio = bio_alloc(GFP_NOIO, BIO_MAX_PAGES);
+       bio = bio_alloc(GFP_NOIO, BIO_MAX_VECS);
        fscrypt_set_bio_crypt_ctx_bh(bio, bh, GFP_NOIO);
        bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >> 9);
        bio_set_dev(bio, bh->b_bdev);
index ad34a37278cd5d5190ecca6b3816a8e4c5ac0445..b9693680463aad4dbf5c22a0b69f6352ef5f5709 100644 (file)
@@ -1210,6 +1210,7 @@ static void ext4_put_super(struct super_block *sb)
        percpu_counter_destroy(&sbi->s_freeinodes_counter);
        percpu_counter_destroy(&sbi->s_dirs_counter);
        percpu_counter_destroy(&sbi->s_dirtyclusters_counter);
+       percpu_counter_destroy(&sbi->s_sra_exceeded_retry_limit);
        percpu_free_rwsem(&sbi->s_writepages_rwsem);
 #ifdef CONFIG_QUOTA
        for (i = 0; i < EXT4_MAXQUOTAS; i++)
@@ -5011,6 +5012,9 @@ no_journal:
        if (!err)
                err = percpu_counter_init(&sbi->s_dirtyclusters_counter, 0,
                                          GFP_KERNEL);
+       if (!err)
+               err = percpu_counter_init(&sbi->s_sra_exceeded_retry_limit, 0,
+                                         GFP_KERNEL);
        if (!err)
                err = percpu_init_rwsem(&sbi->s_writepages_rwsem);
 
@@ -5124,6 +5128,7 @@ failed_mount6:
        percpu_counter_destroy(&sbi->s_freeinodes_counter);
        percpu_counter_destroy(&sbi->s_dirs_counter);
        percpu_counter_destroy(&sbi->s_dirtyclusters_counter);
+       percpu_counter_destroy(&sbi->s_sra_exceeded_retry_limit);
        percpu_free_rwsem(&sbi->s_writepages_rwsem);
 failed_mount5:
        ext4_ext_release(sb);
@@ -5149,8 +5154,8 @@ failed_mount_wq:
 failed_mount3a:
        ext4_es_unregister_shrinker(sbi);
 failed_mount3:
-       del_timer_sync(&sbi->s_err_report);
        flush_work(&sbi->s_error_work);
+       del_timer_sync(&sbi->s_err_report);
        if (sbi->s_mmp_tsk)
                kthread_stop(sbi->s_mmp_tsk);
 failed_mount2:
index 075aa3a19ff5f1b731fba4ad8a266a39beb8a07a..a3d08276d441ecfdb912c75af9ebb644f2b2a99c 100644 (file)
@@ -24,6 +24,7 @@ typedef enum {
        attr_session_write_kbytes,
        attr_lifetime_write_kbytes,
        attr_reserved_clusters,
+       attr_sra_exceeded_retry_limit,
        attr_inode_readahead,
        attr_trigger_test_error,
        attr_first_error_time,
@@ -202,6 +203,7 @@ EXT4_ATTR_FUNC(delayed_allocation_blocks, 0444);
 EXT4_ATTR_FUNC(session_write_kbytes, 0444);
 EXT4_ATTR_FUNC(lifetime_write_kbytes, 0444);
 EXT4_ATTR_FUNC(reserved_clusters, 0644);
+EXT4_ATTR_FUNC(sra_exceeded_retry_limit, 0444);
 
 EXT4_ATTR_OFFSET(inode_readahead_blks, 0644, inode_readahead,
                 ext4_sb_info, s_inode_readahead_blks);
@@ -251,6 +253,7 @@ static struct attribute *ext4_attrs[] = {
        ATTR_LIST(session_write_kbytes),
        ATTR_LIST(lifetime_write_kbytes),
        ATTR_LIST(reserved_clusters),
+       ATTR_LIST(sra_exceeded_retry_limit),
        ATTR_LIST(inode_readahead_blks),
        ATTR_LIST(inode_goal),
        ATTR_LIST(mb_stats),
@@ -374,6 +377,10 @@ static ssize_t ext4_attr_show(struct kobject *kobj,
                return snprintf(buf, PAGE_SIZE, "%llu\n",
                                (unsigned long long)
                                atomic64_read(&sbi->s_resv_clusters));
+       case attr_sra_exceeded_retry_limit:
+               return snprintf(buf, PAGE_SIZE, "%llu\n",
+                               (unsigned long long)
+                       percpu_counter_sum(&sbi->s_sra_exceeded_retry_limit));
        case attr_inode_readahead:
        case attr_pointer_ui:
                if (!ptr)
index 5b7ba8f7115389cb8928279ac9943b06bf7b3658..00e3cbde472e45135f95c12d6615e4356caf67c3 100644 (file)
@@ -201,55 +201,76 @@ static int ext4_end_enable_verity(struct file *filp, const void *desc,
        struct inode *inode = file_inode(filp);
        const int credits = 2; /* superblock and inode for ext4_orphan_del() */
        handle_t *handle;
+       struct ext4_iloc iloc;
        int err = 0;
-       int err2;
 
-       if (desc != NULL) {
-               /* Succeeded; write the verity descriptor. */
-               err = ext4_write_verity_descriptor(inode, desc, desc_size,
-                                                  merkle_tree_size);
-
-               /* Write all pages before clearing VERITY_IN_PROGRESS. */
-               if (!err)
-                       err = filemap_write_and_wait(inode->i_mapping);
-       }
+       /*
+        * If an error already occurred (which fs/verity/ signals by passing
+        * desc == NULL), then only clean-up is needed.
+        */
+       if (desc == NULL)
+               goto cleanup;
 
-       /* If we failed, truncate anything we wrote past i_size. */
-       if (desc == NULL || err)
-               ext4_truncate(inode);
+       /* Append the verity descriptor. */
+       err = ext4_write_verity_descriptor(inode, desc, desc_size,
+                                          merkle_tree_size);
+       if (err)
+               goto cleanup;
 
        /*
-        * We must always clean up by clearing EXT4_STATE_VERITY_IN_PROGRESS and
-        * deleting the inode from the orphan list, even if something failed.
-        * If everything succeeded, we'll also set the verity bit in the same
-        * transaction.
+        * Write all pages (both data and verity metadata).  Note that this must
+        * happen before clearing EXT4_STATE_VERITY_IN_PROGRESS; otherwise pages
+        * beyond i_size won't be written properly.  For crash consistency, this
+        * also must happen before the verity inode flag gets persisted.
         */
+       err = filemap_write_and_wait(inode->i_mapping);
+       if (err)
+               goto cleanup;
 
-       ext4_clear_inode_state(inode, EXT4_STATE_VERITY_IN_PROGRESS);
+       /*
+        * Finally, set the verity inode flag and remove the inode from the
+        * orphan list (in a single transaction).
+        */
 
        handle = ext4_journal_start(inode, EXT4_HT_INODE, credits);
        if (IS_ERR(handle)) {
-               ext4_orphan_del(NULL, inode);
-               return PTR_ERR(handle);
+               err = PTR_ERR(handle);
+               goto cleanup;
        }
 
-       err2 = ext4_orphan_del(handle, inode);
-       if (err2)
-               goto out_stop;
+       err = ext4_orphan_del(handle, inode);
+       if (err)
+               goto stop_and_cleanup;
 
-       if (desc != NULL && !err) {
-               struct ext4_iloc iloc;
+       err = ext4_reserve_inode_write(handle, inode, &iloc);
+       if (err)
+               goto stop_and_cleanup;
 
-               err = ext4_reserve_inode_write(handle, inode, &iloc);
-               if (err)
-                       goto out_stop;
-               ext4_set_inode_flag(inode, EXT4_INODE_VERITY);
-               ext4_set_inode_flags(inode, false);
-               err = ext4_mark_iloc_dirty(handle, inode, &iloc);
-       }
-out_stop:
+       ext4_set_inode_flag(inode, EXT4_INODE_VERITY);
+       ext4_set_inode_flags(inode, false);
+       err = ext4_mark_iloc_dirty(handle, inode, &iloc);
+       if (err)
+               goto stop_and_cleanup;
+
+       ext4_journal_stop(handle);
+
+       ext4_clear_inode_state(inode, EXT4_STATE_VERITY_IN_PROGRESS);
+       return 0;
+
+stop_and_cleanup:
        ext4_journal_stop(handle);
-       return err ?: err2;
+cleanup:
+       /*
+        * Verity failed to be enabled, so clean up by truncating any verity
+        * metadata that was written beyond i_size (both from cache and from
+        * disk), removing the inode from the orphan list (if it wasn't done
+        * already), and clearing EXT4_STATE_VERITY_IN_PROGRESS.
+        */
+       truncate_inode_pages(inode->i_mapping, inode->i_size);
+       ext4_truncate(inode);
+       ext4_orphan_del(NULL, inode);
+       ext4_clear_inode_state(inode, EXT4_STATE_VERITY_IN_PROGRESS);
+       return err;
 }
 
 static int ext4_get_verity_descriptor_location(struct inode *inode,
index 372208500f4e766f0167ce4597f777dafc6891f2..6c1018223c54af36ddec9c885e7b4b278d5a3c96 100644 (file)
@@ -1462,6 +1462,9 @@ ext4_xattr_inode_cache_find(struct inode *inode, const void *value,
        if (!ce)
                return NULL;
 
+       WARN_ON_ONCE(ext4_handle_valid(journal_current_handle()) &&
+                    !(current->flags & PF_MEMALLOC_NOFS));
+
        ea_data = kvmalloc(value_len, GFP_KERNEL);
        if (!ea_data) {
                mb_cache_entry_put(ea_inode_cache, ce);
@@ -2327,6 +2330,7 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
                        error = -ENOSPC;
                        goto cleanup;
                }
+               WARN_ON_ONCE(!(current->flags & PF_MEMALLOC_NOFS));
        }
 
        error = ext4_reserve_inode_write(handle, inode, &is.iloc);
@@ -2400,7 +2404,7 @@ retry_inode:
                                 * external inode if possible.
                                 */
                                if (ext4_has_feature_ea_inode(inode->i_sb) &&
-                                   !i.in_inode) {
+                                   i.value_len && !i.in_inode) {
                                        i.in_inode = 1;
                                        goto retry_inode;
                                }
index 174a0819ad967ec6eb7d43b45d844e93fff626d8..be5415a0dbbc6d639d886b37a5b63b5d1cc20284 100644 (file)
@@ -292,7 +292,7 @@ void f2fs_ra_meta_pages_cond(struct f2fs_sb_info *sbi, pgoff_t index)
        f2fs_put_page(page, 0);
 
        if (readahead)
-               f2fs_ra_meta_pages(sbi, index, BIO_MAX_PAGES, META_POR, true);
+               f2fs_ra_meta_pages(sbi, index, BIO_MAX_VECS, META_POR, true);
 }
 
 static int __f2fs_write_meta_page(struct page *page,
index 7c95818639a630e1bdcb59af77a38bc4b5d14346..4e5257c763d014dc7490cf89cee10c1ce1bb536a 100644 (file)
@@ -857,7 +857,7 @@ int f2fs_merge_page_bio(struct f2fs_io_info *fio)
                f2fs_submit_merged_ipu_write(fio->sbi, &bio, NULL);
 alloc_new:
        if (!bio) {
-               bio = __bio_alloc(fio, BIO_MAX_PAGES);
+               bio = __bio_alloc(fio, BIO_MAX_VECS);
                __attach_io_flag(fio);
                f2fs_set_bio_crypt_ctx(bio, fio->page->mapping->host,
                                       fio->page->index, fio, GFP_NOIO);
@@ -932,7 +932,7 @@ alloc_new:
                        fio->retry = true;
                        goto skip;
                }
-               io->bio = __bio_alloc(fio, BIO_MAX_PAGES);
+               io->bio = __bio_alloc(fio, BIO_MAX_VECS);
                f2fs_set_bio_crypt_ctx(io->bio, fio->page->mapping->host,
                                       bio_page->index, fio, GFP_NOIO);
                io->fio = *fio;
index 993004f06a772ef7d640d235915a59e0f55daeca..c2866561263e96cd76d7ca39f4719791d6efcacb 100644 (file)
@@ -4381,7 +4381,7 @@ static int build_sit_entries(struct f2fs_sb_info *sbi)
        block_t total_node_blocks = 0;
 
        do {
-               readed = f2fs_ra_meta_pages(sbi, start_blk, BIO_MAX_PAGES,
+               readed = f2fs_ra_meta_pages(sbi, start_blk, BIO_MAX_VECS,
                                                        META_SIT, true);
 
                start = start_blk * sit_i->sents_per_block;
index 229814b4f4a6cce77cdce2f4be5898817b8ab3fc..e9a7a637d688773b448d990e08e78711ea2892d1 100644 (file)
@@ -851,7 +851,7 @@ static inline int nr_pages_to_skip(struct f2fs_sb_info *sbi, int type)
        else if (type == NODE)
                return 8 * sbi->blocks_per_seg;
        else if (type == META)
-               return 8 * BIO_MAX_PAGES;
+               return 8 * BIO_MAX_VECS;
        else
                return 0;
 }
@@ -868,7 +868,7 @@ static inline long nr_pages_to_write(struct f2fs_sb_info *sbi, int type,
                return 0;
 
        nr_to_write = wbc->nr_to_write;
-       desired = BIO_MAX_PAGES;
+       desired = BIO_MAX_VECS;
        if (type == NODE)
                desired <<= 1;
 
index 7069793752f1143611b8b8cde1d0deee958e720b..82592b19b4e025ce6f48db1caf771b6e4b12db55 100644 (file)
@@ -753,9 +753,9 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)
                case Opt_io_size_bits:
                        if (args->from && match_int(args, &arg))
                                return -EINVAL;
-                       if (arg <= 0 || arg > __ilog2_u32(BIO_MAX_PAGES)) {
+                       if (arg <= 0 || arg > __ilog2_u32(BIO_MAX_VECS)) {
                                f2fs_warn(sbi, "Not support %d, larger than %d",
-                                         1 << arg, BIO_MAX_PAGES);
+                                         1 << arg, BIO_MAX_VECS);
                                return -EINVAL;
                        }
                        F2FS_OPTION(sbi).write_io_size_bits = arg;
index c6636b4c4ccf25c83e041f528fb8745415db1542..c0fee830a34eda74e37abbbb4a99f0edd26693da 100644 (file)
@@ -2229,19 +2229,21 @@ static int fuse_device_clone(struct fuse_conn *fc, struct file *new)
 static long fuse_dev_ioctl(struct file *file, unsigned int cmd,
                           unsigned long arg)
 {
-       int err = -ENOTTY;
+       int res;
+       int oldfd;
+       struct fuse_dev *fud = NULL;
 
-       if (cmd == FUSE_DEV_IOC_CLONE) {
-               int oldfd;
+       if (_IOC_TYPE(cmd) != FUSE_DEV_IOC_MAGIC)
+               return -ENOTTY;
 
-               err = -EFAULT;
-               if (!get_user(oldfd, (__u32 __user *) arg)) {
+       switch (_IOC_NR(cmd)) {
+       case _IOC_NR(FUSE_DEV_IOC_CLONE):
+               res = -EFAULT;
+               if (!get_user(oldfd, (__u32 __user *)arg)) {
                        struct file *old = fget(oldfd);
 
-                       err = -EINVAL;
+                       res = -EINVAL;
                        if (old) {
-                               struct fuse_dev *fud = NULL;
-
                                /*
                                 * Check against file->f_op because CUSE
                                 * uses the same ioctl handler.
@@ -2252,14 +2254,18 @@ static long fuse_dev_ioctl(struct file *file, unsigned int cmd,
 
                                if (fud) {
                                        mutex_lock(&fuse_mutex);
-                                       err = fuse_device_clone(fud->fc, file);
+                                       res = fuse_device_clone(fud->fc, file);
                                        mutex_unlock(&fuse_mutex);
                                }
                                fput(old);
                        }
                }
+               break;
+       default:
+               res = -ENOTTY;
+               break;
        }
-       return err;
+       return res;
 }
 
 const struct file_operations fuse_dev_operations = {
index 68cca8d4db6ed5db79efddffb48d788db9f2dd0c..63d97a15ffde97916eedcee8e0d3b58b2d1584e2 100644 (file)
@@ -863,6 +863,7 @@ static inline u64 fuse_get_attr_version(struct fuse_conn *fc)
 
 static inline void fuse_make_bad(struct inode *inode)
 {
+       remove_inode_hash(inode);
        set_bit(FUSE_I_BAD, &get_fuse_inode(inode)->state);
 }
 
index 8868ac31a3c0a1c111ece76fc92958f1d4631a6b..4ee6f734ba8380f05ad8ee6411c3f828a68d2b72 100644 (file)
@@ -1324,8 +1324,15 @@ static int virtio_fs_fill_super(struct super_block *sb, struct fs_context *fsc)
 
        /* virtiofs allocates and installs its own fuse devices */
        ctx->fudptr = NULL;
-       if (ctx->dax)
+       if (ctx->dax) {
+               if (!fs->dax_dev) {
+                       err = -EINVAL;
+                       pr_err("virtio-fs: dax can't be enabled as filesystem"
+                              " device does not support it.\n");
+                       goto err_free_fuse_devs;
+               }
                ctx->dax_dev = fs->dax_dev;
+       }
        err = fuse_fill_super_common(sb, ctx);
        if (err < 0)
                goto err_free_fuse_devs;
index 16937ebb2a3e3463cdf176f90c877982abf93f5e..6410281546f924942dd6a3f734a357e8eadd300a 100644 (file)
@@ -998,12 +998,16 @@ static void trans_drain(struct gfs2_trans *tr)
        while (!list_empty(head)) {
                bd = list_first_entry(head, struct gfs2_bufdata, bd_list);
                list_del_init(&bd->bd_list);
+               if (!list_empty(&bd->bd_ail_st_list))
+                       gfs2_remove_from_ail(bd);
                kmem_cache_free(gfs2_bufdata_cachep, bd);
        }
        head = &tr->tr_databuf;
        while (!list_empty(head)) {
                bd = list_first_entry(head, struct gfs2_bufdata, bd_list);
                list_del_init(&bd->bd_list);
+               if (!list_empty(&bd->bd_ail_st_list))
+                       gfs2_remove_from_ail(bd);
                kmem_cache_free(gfs2_bufdata_cachep, bd);
        }
 }
@@ -1032,7 +1036,7 @@ repeat:
         * Do this check while holding the log_flush_lock to prevent new
         * buffers from being added to the ail via gfs2_pin()
         */
-       if (gfs2_withdrawn(sdp))
+       if (gfs2_withdrawn(sdp) || !test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags))
                goto out;
 
        /* Log might have been flushed while we waited for the flush lock */
index dc1b93a877c6d3c0bff2ad468e0294e9e17f2cca..a82f4747aa8d5eaa05038e9ae324eabad53b48c3 100644 (file)
@@ -267,7 +267,7 @@ static struct bio *gfs2_log_alloc_bio(struct gfs2_sbd *sdp, u64 blkno,
                                      bio_end_io_t *end_io)
 {
        struct super_block *sb = sdp->sd_vfs;
-       struct bio *bio = bio_alloc(GFP_NOIO, BIO_MAX_PAGES);
+       struct bio *bio = bio_alloc(GFP_NOIO, BIO_MAX_VECS);
 
        bio->bi_iter.bi_sector = blkno << sdp->sd_fsb2bb_shift;
        bio_set_dev(bio, sb->s_bdev);
index 74c7d01723b95667a5e42fb659d37e7de944d479..aa4136055a83c220c02cdab111f779141dc93d7b 100644 (file)
@@ -1539,9 +1539,7 @@ static int gfs2_reconfigure(struct fs_context *fc)
                        return -EINVAL;
 
                if (fc->sb_flags & SB_RDONLY) {
-                       error = gfs2_make_fs_ro(sdp);
-                       if (error)
-                               errorfc(fc, "unable to remount read-only");
+                       gfs2_make_fs_ro(sdp);
                } else {
                        error = gfs2_make_fs_rw(sdp);
                        if (error)
index 861ed5fe02a59dc786d781265183bc3ec9cf2051..97076d3f562f90dfec3a40f06abb5fdb165a2fee 100644 (file)
@@ -587,9 +587,8 @@ out:
  * Returns: errno
  */
 
-int gfs2_make_fs_ro(struct gfs2_sbd *sdp)
+void gfs2_make_fs_ro(struct gfs2_sbd *sdp)
 {
-       int error = 0;
        int log_write_allowed = test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags);
 
        gfs2_flush_delete_work(sdp);
@@ -624,8 +623,6 @@ int gfs2_make_fs_ro(struct gfs2_sbd *sdp)
 
        if (!log_write_allowed)
                sdp->sd_vfs->s_flags |= SB_RDONLY;
-
-       return error;
 }
 
 /**
@@ -637,7 +634,6 @@ int gfs2_make_fs_ro(struct gfs2_sbd *sdp)
 static void gfs2_put_super(struct super_block *sb)
 {
        struct gfs2_sbd *sdp = sb->s_fs_info;
-       int error;
        struct gfs2_jdesc *jd;
 
        /* No more recovery requests */
@@ -658,9 +654,7 @@ restart:
        spin_unlock(&sdp->sd_jindex_spin);
 
        if (!sb_rdonly(sb)) {
-               error = gfs2_make_fs_ro(sdp);
-               if (error)
-                       gfs2_io_error(sdp);
+               gfs2_make_fs_ro(sdp);
        }
        WARN_ON(gfs2_withdrawing(sdp));
 
index 08e502dec7ecb01ca2587f475e58ab077c483ee1..ec4affb33ed53f84c7fc622cd669da3bb80b2d66 100644 (file)
@@ -34,7 +34,7 @@ extern int gfs2_lookup_in_master_dir(struct gfs2_sbd *sdp, char *filename,
                                     struct gfs2_inode **ipp);
 
 extern int gfs2_make_fs_rw(struct gfs2_sbd *sdp);
-extern int gfs2_make_fs_ro(struct gfs2_sbd *sdp);
+extern void gfs2_make_fs_ro(struct gfs2_sbd *sdp);
 extern void gfs2_online_uevent(struct gfs2_sbd *sdp);
 extern int gfs2_statfs_init(struct gfs2_sbd *sdp);
 extern void gfs2_statfs_change(struct gfs2_sbd *sdp, s64 total, s64 free,
index ab96cf0bf26bea1c9b10136e54a207baafaaa0d3..63fec11ef2ce3fe8c37ff0f76a923444ee0df7d6 100644 (file)
@@ -169,6 +169,8 @@ static struct gfs2_bufdata *gfs2_alloc_bufdata(struct gfs2_glock *gl,
        bd->bd_bh = bh;
        bd->bd_gl = gl;
        INIT_LIST_HEAD(&bd->bd_list);
+       INIT_LIST_HEAD(&bd->bd_ail_st_list);
+       INIT_LIST_HEAD(&bd->bd_ail_gl_list);
        bh->b_private = bd;
        return bd;
 }
index 8d3c670c990fd99580a1c39eb13929eed2de1375..4f034b87b427609103357b4694d831a08b18e3bc 100644 (file)
@@ -119,17 +119,22 @@ void gfs2_freeze_unlock(struct gfs2_holder *freeze_gh)
 static void signal_our_withdraw(struct gfs2_sbd *sdp)
 {
        struct gfs2_glock *live_gl = sdp->sd_live_gh.gh_gl;
-       struct inode *inode = sdp->sd_jdesc->jd_inode;
-       struct gfs2_inode *ip = GFS2_I(inode);
-       struct gfs2_glock *i_gl = ip->i_gl;
-       u64 no_formal_ino = ip->i_no_formal_ino;
+       struct inode *inode;
+       struct gfs2_inode *ip;
+       struct gfs2_glock *i_gl;
+       u64 no_formal_ino;
        int log_write_allowed = test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags);
        int ret = 0;
        int tries;
 
-       if (test_bit(SDF_NORECOVERY, &sdp->sd_flags))
+       if (test_bit(SDF_NORECOVERY, &sdp->sd_flags) || !sdp->sd_jdesc)
                return;
 
+       inode = sdp->sd_jdesc->jd_inode;
+       ip = GFS2_I(inode);
+       i_gl = ip->i_gl;
+       no_formal_ino = ip->i_no_formal_ino;
+
        /* Prevent any glock dq until withdraw recovery is complete */
        set_bit(SDF_WITHDRAW_RECOVERY, &sdp->sd_flags);
        /*
@@ -156,7 +161,7 @@ static void signal_our_withdraw(struct gfs2_sbd *sdp)
                                ret = 0;
                }
                if (!ret)
-                       ret = gfs2_make_fs_ro(sdp);
+                       gfs2_make_fs_ro(sdp);
                gfs2_freeze_unlock(&freeze_gh);
        }
 
index 28868eb4cd099e91bc65eb77f6915863104f128e..3dc10bfd8c3baa4a7130ab9caf6cdbf90cf5bd84 100644 (file)
@@ -110,7 +110,6 @@ struct io_wq {
        io_wq_work_fn *do_work;
 
        struct task_struct *manager;
-       struct user_struct *user;
 
        struct io_wq_hash *hash;
 
@@ -387,13 +386,16 @@ static struct io_wq_work *io_get_next_work(struct io_wqe *wqe)
        return NULL;
 }
 
-static void io_flush_signals(void)
+static bool io_flush_signals(void)
 {
        if (unlikely(test_tsk_thread_flag(current, TIF_NOTIFY_SIGNAL))) {
+               __set_current_state(TASK_RUNNING);
                if (current->task_works)
                        task_work_run();
                clear_tsk_thread_flag(current, TIF_NOTIFY_SIGNAL);
+               return true;
        }
+       return false;
 }
 
 static void io_assign_current_work(struct io_worker *worker,
@@ -489,6 +491,8 @@ static int io_wqe_worker(void *data)
        set_task_comm(current, buf);
 
        while (!test_bit(IO_WQ_BIT_EXIT, &wq->state)) {
+               long ret;
+
                set_current_state(TASK_INTERRUPTIBLE);
 loop:
                raw_spin_lock_irq(&wqe->lock);
@@ -498,8 +502,10 @@ loop:
                }
                __io_worker_idle(wqe, worker);
                raw_spin_unlock_irq(&wqe->lock);
-               io_flush_signals();
-               if (schedule_timeout(WORKER_IDLE_TIMEOUT))
+               if (io_flush_signals())
+                       continue;
+               ret = schedule_timeout(WORKER_IDLE_TIMEOUT);
+               if (try_to_freeze() || ret)
                        continue;
                if (fatal_signal_pending(current))
                        break;
@@ -592,7 +598,7 @@ static bool create_io_worker(struct io_wq *wq, struct io_wqe *wqe, int index)
        tsk->pf_io_worker = worker;
        worker->task = tsk;
        set_cpus_allowed_ptr(tsk, cpumask_of_node(wqe->node));
-       tsk->flags |= PF_NOFREEZE | PF_NO_SETAFFINITY;
+       tsk->flags |= PF_NO_SETAFFINITY;
 
        raw_spin_lock_irq(&wqe->lock);
        hlist_nulls_add_head_rcu(&worker->nulls_node, &wqe->free_list);
@@ -722,9 +728,9 @@ static int io_wq_manager(void *data)
                io_wq_for_each_worker(wq->wqes[node], io_wq_worker_wake, NULL);
        rcu_read_unlock();
 
-       /* we might not ever have created any workers */
-       if (atomic_read(&wq->worker_refs))
-               wait_for_completion(&wq->worker_done);
+       if (atomic_dec_and_test(&wq->worker_refs))
+               complete(&wq->worker_done);
+       wait_for_completion(&wq->worker_done);
 
        spin_lock_irq(&wq->hash->wait.lock);
        for_each_node(node)
@@ -774,7 +780,10 @@ static int io_wq_fork_manager(struct io_wq *wq)
        if (wq->manager)
                return 0;
 
-       reinit_completion(&wq->worker_done);
+       WARN_ON_ONCE(test_bit(IO_WQ_BIT_EXIT, &wq->state));
+
+       init_completion(&wq->worker_done);
+       atomic_set(&wq->worker_refs, 1);
        tsk = create_io_thread(io_wq_manager, wq, NUMA_NO_NODE);
        if (!IS_ERR(tsk)) {
                wq->manager = get_task_struct(tsk);
@@ -782,6 +791,9 @@ static int io_wq_fork_manager(struct io_wq *wq)
                return 0;
        }
 
+       if (atomic_dec_and_test(&wq->worker_refs))
+               complete(&wq->worker_done);
+
        return PTR_ERR(tsk);
 }
 
@@ -794,8 +806,7 @@ static void io_wqe_enqueue(struct io_wqe *wqe, struct io_wq_work *work)
        /* Can only happen if manager creation fails after exec */
        if (io_wq_fork_manager(wqe->wq) ||
            test_bit(IO_WQ_BIT_EXIT, &wqe->wq->state)) {
-               work->flags |= IO_WQ_WORK_CANCEL;
-               wqe->wq->do_work(work);
+               io_run_cancel(work, wqe);
                return;
        }
 
@@ -1018,13 +1029,9 @@ struct io_wq *io_wq_create(unsigned bounded, struct io_wq_data *data)
        init_completion(&wq->exited);
        refcount_set(&wq->refs, 1);
 
-       init_completion(&wq->worker_done);
-       atomic_set(&wq->worker_refs, 0);
-
        ret = io_wq_fork_manager(wq);
        if (!ret)
                return wq;
-
 err:
        io_wq_put_hash(data->hash);
        cpuhp_state_remove_instance_nocalls(io_wq_online, &wq->cpuhp_node);
index 5fbf7997149ee1d422dfb14a9407929c2d406c4b..80d590564ff93e00f1a457fffd7bcee97f73e837 100644 (file)
@@ -2,7 +2,6 @@
 #define INTERNAL_IO_WQ_H
 
 #include <linux/refcount.h>
-#include <linux/io_uring.h>
 
 struct io_wq;
 
@@ -21,6 +20,15 @@ enum io_wq_cancel {
        IO_WQ_CANCEL_NOTFOUND,  /* work not found */
 };
 
+struct io_wq_work_node {
+       struct io_wq_work_node *next;
+};
+
+struct io_wq_work_list {
+       struct io_wq_work_node *first;
+       struct io_wq_work_node *last;
+};
+
 static inline void wq_list_add_after(struct io_wq_work_node *node,
                                     struct io_wq_work_node *pos,
                                     struct io_wq_work_list *list)
@@ -79,8 +87,8 @@ static inline void wq_list_del(struct io_wq_work_list *list,
 
 struct io_wq_work {
        struct io_wq_work_node list;
+       const struct cred *creds;
        unsigned flags;
-       unsigned short personality;
 };
 
 static inline struct io_wq_work *wq_next_work(struct io_wq_work *work)
index 92c25b5f13497fb6acf5857f0bca6aa57f22fc5f..543551d70327fa95f58e3d95718f3d917c50ff65 100644 (file)
@@ -258,12 +258,11 @@ enum {
 
 struct io_sq_data {
        refcount_t              refs;
+       atomic_t                park_pending;
        struct mutex            lock;
 
        /* ctx's that are using this sqd */
        struct list_head        ctx_list;
-       struct list_head        ctx_new_list;
-       struct mutex            ctx_lock;
 
        struct task_struct      *thread;
        struct wait_queue_head  wait;
@@ -271,11 +270,11 @@ struct io_sq_data {
        unsigned                sq_thread_idle;
        int                     sq_cpu;
        pid_t                   task_pid;
+       pid_t                   task_tgid;
 
        unsigned long           state;
-       struct completion       startup;
-       struct completion       parked;
        struct completion       exited;
+       struct callback_head    *park_task_work;
 };
 
 #define IO_IOPOLL_BATCH                        8
@@ -336,7 +335,6 @@ struct io_ring_ctx {
                unsigned int            drain_next: 1;
                unsigned int            eventfd_async: 1;
                unsigned int            restricted: 1;
-               unsigned int            sqo_exec: 1;
 
                /*
                 * Ring buffer of indices into array of io_uring_sqe, which is
@@ -380,6 +378,7 @@ struct io_ring_ctx {
        /* Only used for accounting purposes */
        struct mm_struct        *mm_account;
 
+       const struct cred       *sq_creds;      /* cred used for __io_sq_thread() */
        struct io_sq_data       *sq_data;       /* if using sq thread polling */
 
        struct wait_queue_head  sqo_sq_wait;
@@ -400,15 +399,15 @@ struct io_ring_ctx {
        struct user_struct      *user;
 
        struct completion       ref_comp;
-       struct completion       sq_thread_comp;
 
 #if defined(CONFIG_UNIX)
        struct socket           *ring_sock;
 #endif
 
-       struct idr              io_buffer_idr;
+       struct xarray           io_buffers;
 
-       struct idr              personality_idr;
+       struct xarray           personalities;
+       u32                     pers_next;
 
        struct {
                unsigned                cached_cq_tail;
@@ -454,6 +453,23 @@ struct io_ring_ctx {
 
        /* Keep this last, we don't need it for the fast path */
        struct work_struct              exit_work;
+       struct list_head                tctx_list;
+};
+
+struct io_uring_task {
+       /* submission side */
+       struct xarray           xa;
+       struct wait_queue_head  wait;
+       const struct io_ring_ctx *last;
+       struct io_wq            *io_wq;
+       struct percpu_counter   inflight;
+       atomic_t                in_idle;
+       bool                    sqpoll;
+
+       spinlock_t              task_lock;
+       struct io_wq_work_list  task_list;
+       unsigned long           task_state;
+       struct callback_head    task_work;
 };
 
 /*
@@ -805,6 +821,12 @@ struct io_kiocb {
        struct io_wq_work               work;
 };
 
+struct io_tctx_node {
+       struct list_head        ctx_node;
+       struct task_struct      *task;
+       struct io_ring_ctx      *ctx;
+};
+
 struct io_defer_entry {
        struct list_head        list;
        struct io_kiocb         *req;
@@ -979,6 +1001,8 @@ static const struct io_op_def io_op_defs[] = {
        [IORING_OP_UNLINKAT] = {},
 };
 
+static bool io_disarm_next(struct io_kiocb *req);
+static void io_uring_del_task_file(unsigned long index);
 static void io_uring_try_cancel_requests(struct io_ring_ctx *ctx,
                                         struct task_struct *task,
                                         struct files_struct *files);
@@ -1129,9 +1153,8 @@ static struct io_ring_ctx *io_ring_ctx_alloc(struct io_uring_params *p)
        init_waitqueue_head(&ctx->cq_wait);
        INIT_LIST_HEAD(&ctx->cq_overflow_list);
        init_completion(&ctx->ref_comp);
-       init_completion(&ctx->sq_thread_comp);
-       idr_init(&ctx->io_buffer_idr);
-       idr_init(&ctx->personality_idr);
+       xa_init_flags(&ctx->io_buffers, XA_FLAGS_ALLOC1);
+       xa_init_flags(&ctx->personalities, XA_FLAGS_ALLOC1);
        mutex_init(&ctx->uring_lock);
        init_waitqueue_head(&ctx->wait);
        spin_lock_init(&ctx->completion_lock);
@@ -1144,6 +1167,7 @@ static struct io_ring_ctx *io_ring_ctx_alloc(struct io_uring_params *p)
        INIT_LIST_HEAD(&ctx->rsrc_ref_list);
        INIT_DELAYED_WORK(&ctx->rsrc_put_work, io_rsrc_put_work);
        init_llist_head(&ctx->rsrc_put_llist);
+       INIT_LIST_HEAD(&ctx->tctx_list);
        INIT_LIST_HEAD(&ctx->submit_state.comp.free_list);
        INIT_LIST_HEAD(&ctx->submit_state.comp.locked_free_list);
        return ctx;
@@ -1183,6 +1207,9 @@ static void io_prep_async_work(struct io_kiocb *req)
        const struct io_op_def *def = &io_op_defs[req->opcode];
        struct io_ring_ctx *ctx = req->ctx;
 
+       if (!req->work.creds)
+               req->work.creds = get_current_cred();
+
        if (req->flags & REQ_F_FORCE_ASYNC)
                req->work.flags |= IO_WQ_WORK_CONCURRENT;
 
@@ -1514,15 +1541,14 @@ static void io_cqring_fill_event(struct io_kiocb *req, long res)
        __io_cqring_fill_event(req, res, 0);
 }
 
-static inline void io_req_complete_post(struct io_kiocb *req, long res,
-                                       unsigned int cflags)
+static void io_req_complete_post(struct io_kiocb *req, long res,
+                                unsigned int cflags)
 {
        struct io_ring_ctx *ctx = req->ctx;
        unsigned long flags;
 
        spin_lock_irqsave(&ctx->completion_lock, flags);
        __io_cqring_fill_event(req, res, cflags);
-       io_commit_cqring(ctx);
        /*
         * If we're the last reference to this request, add to our locked
         * free_list cache.
@@ -1530,17 +1556,27 @@ static inline void io_req_complete_post(struct io_kiocb *req, long res,
        if (refcount_dec_and_test(&req->refs)) {
                struct io_comp_state *cs = &ctx->submit_state.comp;
 
+               if (req->flags & (REQ_F_LINK | REQ_F_HARDLINK)) {
+                       if (req->flags & (REQ_F_LINK_TIMEOUT | REQ_F_FAIL_LINK))
+                               io_disarm_next(req);
+                       if (req->link) {
+                               io_req_task_queue(req->link);
+                               req->link = NULL;
+                       }
+               }
                io_dismantle_req(req);
                io_put_task(req->task, 1);
                list_add(&req->compl.list, &cs->locked_free_list);
                cs->locked_free_nr++;
-       } else
-               req = NULL;
+       } else {
+               if (!percpu_ref_tryget(&ctx->refs))
+                       req = NULL;
+       }
+       io_commit_cqring(ctx);
        spin_unlock_irqrestore(&ctx->completion_lock, flags);
 
-       io_cqring_ev_posted(ctx);
        if (req) {
-               io_queue_next(req);
+               io_cqring_ev_posted(ctx);
                percpu_ref_put(&ctx->refs);
        }
 }
@@ -1648,6 +1684,10 @@ static void io_dismantle_req(struct io_kiocb *req)
                io_put_file(req, req->file, (req->flags & REQ_F_FIXED_FILE));
        if (req->fixed_rsrc_refs)
                percpu_ref_put(req->fixed_rsrc_refs);
+       if (req->work.creds) {
+               put_cred(req->work.creds);
+               req->work.creds = NULL;
+       }
 
        if (req->flags & REQ_F_INFLIGHT) {
                struct io_ring_ctx *ctx = req->ctx;
@@ -1690,15 +1730,11 @@ static inline void io_remove_next_linked(struct io_kiocb *req)
        nxt->link = NULL;
 }
 
-static void io_kill_linked_timeout(struct io_kiocb *req)
+static bool io_kill_linked_timeout(struct io_kiocb *req)
+       __must_hold(&req->ctx->completion_lock)
 {
-       struct io_ring_ctx *ctx = req->ctx;
-       struct io_kiocb *link;
+       struct io_kiocb *link = req->link;
        bool cancelled = false;
-       unsigned long flags;
-
-       spin_lock_irqsave(&ctx->completion_lock, flags);
-       link = req->link;
 
        /*
         * Can happen if a linked timeout fired and link had been like
@@ -1713,50 +1749,48 @@ static void io_kill_linked_timeout(struct io_kiocb *req)
                ret = hrtimer_try_to_cancel(&io->timer);
                if (ret != -1) {
                        io_cqring_fill_event(link, -ECANCELED);
-                       io_commit_cqring(ctx);
+                       io_put_req_deferred(link, 1);
                        cancelled = true;
                }
        }
        req->flags &= ~REQ_F_LINK_TIMEOUT;
-       spin_unlock_irqrestore(&ctx->completion_lock, flags);
-
-       if (cancelled) {
-               io_cqring_ev_posted(ctx);
-               io_put_req(link);
-       }
+       return cancelled;
 }
 
-
 static void io_fail_links(struct io_kiocb *req)
+       __must_hold(&req->ctx->completion_lock)
 {
-       struct io_kiocb *link, *nxt;
-       struct io_ring_ctx *ctx = req->ctx;
-       unsigned long flags;
+       struct io_kiocb *nxt, *link = req->link;
 
-       spin_lock_irqsave(&ctx->completion_lock, flags);
-       link = req->link;
        req->link = NULL;
-
        while (link) {
                nxt = link->link;
                link->link = NULL;
 
                trace_io_uring_fail_link(req, link);
                io_cqring_fill_event(link, -ECANCELED);
-
                io_put_req_deferred(link, 2);
                link = nxt;
        }
-       io_commit_cqring(ctx);
-       spin_unlock_irqrestore(&ctx->completion_lock, flags);
+}
 
-       io_cqring_ev_posted(ctx);
+static bool io_disarm_next(struct io_kiocb *req)
+       __must_hold(&req->ctx->completion_lock)
+{
+       bool posted = false;
+
+       if (likely(req->flags & REQ_F_LINK_TIMEOUT))
+               posted = io_kill_linked_timeout(req);
+       if (unlikely(req->flags & REQ_F_FAIL_LINK)) {
+               posted |= (req->link != NULL);
+               io_fail_links(req);
+       }
+       return posted;
 }
 
 static struct io_kiocb *__io_req_find_next(struct io_kiocb *req)
 {
-       if (req->flags & REQ_F_LINK_TIMEOUT)
-               io_kill_linked_timeout(req);
+       struct io_kiocb *nxt;
 
        /*
         * If LINK is set, we have dependent requests in this chain. If we
@@ -1764,14 +1798,22 @@ static struct io_kiocb *__io_req_find_next(struct io_kiocb *req)
         * dependencies to the next request. In case of failure, fail the rest
         * of the chain.
         */
-       if (likely(!(req->flags & REQ_F_FAIL_LINK))) {
-               struct io_kiocb *nxt = req->link;
+       if (req->flags & (REQ_F_LINK_TIMEOUT | REQ_F_FAIL_LINK)) {
+               struct io_ring_ctx *ctx = req->ctx;
+               unsigned long flags;
+               bool posted;
 
-               req->link = NULL;
-               return nxt;
+               spin_lock_irqsave(&ctx->completion_lock, flags);
+               posted = io_disarm_next(req);
+               if (posted)
+                       io_commit_cqring(req->ctx);
+               spin_unlock_irqrestore(&ctx->completion_lock, flags);
+               if (posted)
+                       io_cqring_ev_posted(ctx);
        }
-       io_fail_links(req);
-       return NULL;
+       nxt = req->link;
+       req->link = NULL;
+       return nxt;
 }
 
 static inline struct io_kiocb *io_req_find_next(struct io_kiocb *req)
@@ -1904,17 +1946,44 @@ static int io_req_task_work_add(struct io_kiocb *req)
        return ret;
 }
 
-static void io_req_task_work_add_fallback(struct io_kiocb *req,
-                                         task_work_func_t cb)
+static bool io_run_task_work_head(struct callback_head **work_head)
+{
+       struct callback_head *work, *next;
+       bool executed = false;
+
+       do {
+               work = xchg(work_head, NULL);
+               if (!work)
+                       break;
+
+               do {
+                       next = work->next;
+                       work->func(work);
+                       work = next;
+                       cond_resched();
+               } while (work);
+               executed = true;
+       } while (1);
+
+       return executed;
+}
+
+static void io_task_work_add_head(struct callback_head **work_head,
+                                 struct callback_head *task_work)
 {
-       struct io_ring_ctx *ctx = req->ctx;
        struct callback_head *head;
 
-       init_task_work(&req->task_work, cb);
        do {
-               head = READ_ONCE(ctx->exit_task_work);
-               req->task_work.next = head;
-       } while (cmpxchg(&ctx->exit_task_work, head, &req->task_work) != head);
+               head = READ_ONCE(*work_head);
+               task_work->next = head;
+       } while (cmpxchg(work_head, head, task_work) != head);
+}
+
+static void io_req_task_work_add_fallback(struct io_kiocb *req,
+                                         task_work_func_t cb)
+{
+       init_task_work(&req->task_work, cb);
+       io_task_work_add_head(&req->ctx->exit_task_work, &req->task_work);
 }
 
 static void __io_req_task_cancel(struct io_kiocb *req, int error)
@@ -2822,7 +2891,7 @@ static struct io_buffer *io_buffer_select(struct io_kiocb *req, size_t *len,
 
        lockdep_assert_held(&req->ctx->uring_lock);
 
-       head = idr_find(&req->ctx->io_buffer_idr, bgid);
+       head = xa_load(&req->ctx->io_buffers, bgid);
        if (head) {
                if (!list_empty(&head->list)) {
                        kbuf = list_last_entry(&head->list, struct io_buffer,
@@ -2830,7 +2899,7 @@ static struct io_buffer *io_buffer_select(struct io_kiocb *req, size_t *len,
                        list_del(&kbuf->list);
                } else {
                        kbuf = head;
-                       idr_remove(&req->ctx->io_buffer_idr, bgid);
+                       xa_erase(&req->ctx->io_buffers, bgid);
                }
                if (*len > kbuf->len)
                        *len = kbuf->len;
@@ -3871,7 +3940,7 @@ static int __io_remove_buffers(struct io_ring_ctx *ctx, struct io_buffer *buf,
        }
        i++;
        kfree(buf);
-       idr_remove(&ctx->io_buffer_idr, bgid);
+       xa_erase(&ctx->io_buffers, bgid);
 
        return i;
 }
@@ -3889,7 +3958,7 @@ static int io_remove_buffers(struct io_kiocb *req, unsigned int issue_flags)
        lockdep_assert_held(&ctx->uring_lock);
 
        ret = -ENOENT;
-       head = idr_find(&ctx->io_buffer_idr, p->bgid);
+       head = xa_load(&ctx->io_buffers, p->bgid);
        if (head)
                ret = __io_remove_buffers(ctx, head, p->bgid, p->nbufs);
        if (ret < 0)
@@ -3972,21 +4041,14 @@ static int io_provide_buffers(struct io_kiocb *req, unsigned int issue_flags)
 
        lockdep_assert_held(&ctx->uring_lock);
 
-       list = head = idr_find(&ctx->io_buffer_idr, p->bgid);
+       list = head = xa_load(&ctx->io_buffers, p->bgid);
 
        ret = io_add_buffers(p, &head);
-       if (ret < 0)
-               goto out;
-
-       if (!list) {
-               ret = idr_alloc(&ctx->io_buffer_idr, head, p->bgid, p->bgid + 1,
-                                       GFP_KERNEL);
-               if (ret < 0) {
+       if (ret >= 0 && !list) {
+               ret = xa_insert(&ctx->io_buffers, p->bgid, head, GFP_KERNEL);
+               if (ret < 0)
                        __io_remove_buffers(ctx, head, p->bgid, -1U);
-                       goto out;
-               }
        }
-out:
        if (ret < 0)
                req_set_fail_links(req);
 
@@ -4324,6 +4386,7 @@ static int io_sendmsg(struct io_kiocb *req, unsigned int issue_flags)
        struct io_async_msghdr iomsg, *kmsg;
        struct socket *sock;
        unsigned flags;
+       int min_ret = 0;
        int ret;
 
        sock = sock_from_file(req->file);
@@ -4338,12 +4401,15 @@ static int io_sendmsg(struct io_kiocb *req, unsigned int issue_flags)
                kmsg = &iomsg;
        }
 
-       flags = req->sr_msg.msg_flags;
+       flags = req->sr_msg.msg_flags | MSG_NOSIGNAL;
        if (flags & MSG_DONTWAIT)
                req->flags |= REQ_F_NOWAIT;
        else if (issue_flags & IO_URING_F_NONBLOCK)
                flags |= MSG_DONTWAIT;
 
+       if (flags & MSG_WAITALL)
+               min_ret = iov_iter_count(&kmsg->msg.msg_iter);
+
        ret = __sys_sendmsg_sock(sock, &kmsg->msg, flags);
        if ((issue_flags & IO_URING_F_NONBLOCK) && ret == -EAGAIN)
                return io_setup_async_msg(req, kmsg);
@@ -4354,7 +4420,7 @@ static int io_sendmsg(struct io_kiocb *req, unsigned int issue_flags)
        if (kmsg->free_iov)
                kfree(kmsg->free_iov);
        req->flags &= ~REQ_F_NEED_CLEANUP;
-       if (ret < 0)
+       if (ret < min_ret)
                req_set_fail_links(req);
        __io_req_complete(req, issue_flags, ret, 0);
        return 0;
@@ -4367,6 +4433,7 @@ static int io_send(struct io_kiocb *req, unsigned int issue_flags)
        struct iovec iov;
        struct socket *sock;
        unsigned flags;
+       int min_ret = 0;
        int ret;
 
        sock = sock_from_file(req->file);
@@ -4382,12 +4449,15 @@ static int io_send(struct io_kiocb *req, unsigned int issue_flags)
        msg.msg_controllen = 0;
        msg.msg_namelen = 0;
 
-       flags = req->sr_msg.msg_flags;
+       flags = req->sr_msg.msg_flags | MSG_NOSIGNAL;
        if (flags & MSG_DONTWAIT)
                req->flags |= REQ_F_NOWAIT;
        else if (issue_flags & IO_URING_F_NONBLOCK)
                flags |= MSG_DONTWAIT;
 
+       if (flags & MSG_WAITALL)
+               min_ret = iov_iter_count(&msg.msg_iter);
+
        msg.msg_flags = flags;
        ret = sock_sendmsg(sock, &msg);
        if ((issue_flags & IO_URING_F_NONBLOCK) && ret == -EAGAIN)
@@ -4395,7 +4465,7 @@ static int io_send(struct io_kiocb *req, unsigned int issue_flags)
        if (ret == -ERESTARTSYS)
                ret = -EINTR;
 
-       if (ret < 0)
+       if (ret < min_ret)
                req_set_fail_links(req);
        __io_req_complete(req, issue_flags, ret, 0);
        return 0;
@@ -4547,6 +4617,7 @@ static int io_recvmsg(struct io_kiocb *req, unsigned int issue_flags)
        struct socket *sock;
        struct io_buffer *kbuf;
        unsigned flags;
+       int min_ret = 0;
        int ret, cflags = 0;
        bool force_nonblock = issue_flags & IO_URING_F_NONBLOCK;
 
@@ -4572,12 +4643,15 @@ static int io_recvmsg(struct io_kiocb *req, unsigned int issue_flags)
                                1, req->sr_msg.len);
        }
 
-       flags = req->sr_msg.msg_flags;
+       flags = req->sr_msg.msg_flags | MSG_NOSIGNAL;
        if (flags & MSG_DONTWAIT)
                req->flags |= REQ_F_NOWAIT;
        else if (force_nonblock)
                flags |= MSG_DONTWAIT;
 
+       if (flags & MSG_WAITALL)
+               min_ret = iov_iter_count(&kmsg->msg.msg_iter);
+
        ret = __sys_recvmsg_sock(sock, &kmsg->msg, req->sr_msg.umsg,
                                        kmsg->uaddr, flags);
        if (force_nonblock && ret == -EAGAIN)
@@ -4591,7 +4665,7 @@ static int io_recvmsg(struct io_kiocb *req, unsigned int issue_flags)
        if (kmsg->free_iov)
                kfree(kmsg->free_iov);
        req->flags &= ~REQ_F_NEED_CLEANUP;
-       if (ret < 0)
+       if (ret < min_ret || ((flags & MSG_WAITALL) && (kmsg->msg.msg_flags & (MSG_TRUNC | MSG_CTRUNC))))
                req_set_fail_links(req);
        __io_req_complete(req, issue_flags, ret, cflags);
        return 0;
@@ -4606,6 +4680,7 @@ static int io_recv(struct io_kiocb *req, unsigned int issue_flags)
        struct socket *sock;
        struct iovec iov;
        unsigned flags;
+       int min_ret = 0;
        int ret, cflags = 0;
        bool force_nonblock = issue_flags & IO_URING_F_NONBLOCK;
 
@@ -4631,12 +4706,15 @@ static int io_recv(struct io_kiocb *req, unsigned int issue_flags)
        msg.msg_iocb = NULL;
        msg.msg_flags = 0;
 
-       flags = req->sr_msg.msg_flags;
+       flags = req->sr_msg.msg_flags | MSG_NOSIGNAL;
        if (flags & MSG_DONTWAIT)
                req->flags |= REQ_F_NOWAIT;
        else if (force_nonblock)
                flags |= MSG_DONTWAIT;
 
+       if (flags & MSG_WAITALL)
+               min_ret = iov_iter_count(&msg.msg_iter);
+
        ret = sock_recvmsg(sock, &msg, flags);
        if (force_nonblock && ret == -EAGAIN)
                return -EAGAIN;
@@ -4645,7 +4723,7 @@ static int io_recv(struct io_kiocb *req, unsigned int issue_flags)
 out_free:
        if (req->flags & REQ_F_BUFFER_SELECTED)
                cflags = io_put_recv_kbuf(req);
-       if (ret < 0)
+       if (ret < min_ret || ((flags & MSG_WAITALL) && (msg.msg_flags & (MSG_TRUNC | MSG_CTRUNC))))
                req_set_fail_links(req);
        __io_req_complete(req, issue_flags, ret, cflags);
        return 0;
@@ -5559,22 +5637,30 @@ add:
        return 0;
 }
 
+struct io_cancel_data {
+       struct io_ring_ctx *ctx;
+       u64 user_data;
+};
+
 static bool io_cancel_cb(struct io_wq_work *work, void *data)
 {
        struct io_kiocb *req = container_of(work, struct io_kiocb, work);
+       struct io_cancel_data *cd = data;
 
-       return req->user_data == (unsigned long) data;
+       return req->ctx == cd->ctx && req->user_data == cd->user_data;
 }
 
-static int io_async_cancel_one(struct io_uring_task *tctx, void *sqe_addr)
+static int io_async_cancel_one(struct io_uring_task *tctx, u64 user_data,
+                              struct io_ring_ctx *ctx)
 {
+       struct io_cancel_data data = { .ctx = ctx, .user_data = user_data, };
        enum io_wq_cancel cancel_ret;
        int ret = 0;
 
-       if (!tctx->io_wq)
+       if (!tctx || !tctx->io_wq)
                return -ENOENT;
 
-       cancel_ret = io_wq_cancel_cb(tctx->io_wq, io_cancel_cb, sqe_addr, false);
+       cancel_ret = io_wq_cancel_cb(tctx->io_wq, io_cancel_cb, &data, false);
        switch (cancel_ret) {
        case IO_WQ_CANCEL_OK:
                ret = 0;
@@ -5597,8 +5683,7 @@ static void io_async_find_and_cancel(struct io_ring_ctx *ctx,
        unsigned long flags;
        int ret;
 
-       ret = io_async_cancel_one(req->task->io_uring,
-                                       (void *) (unsigned long) sqe_addr);
+       ret = io_async_cancel_one(req->task->io_uring, sqe_addr, ctx);
        if (ret != -ENOENT) {
                spin_lock_irqsave(&ctx->completion_lock, flags);
                goto done;
@@ -5639,8 +5724,47 @@ static int io_async_cancel_prep(struct io_kiocb *req,
 static int io_async_cancel(struct io_kiocb *req, unsigned int issue_flags)
 {
        struct io_ring_ctx *ctx = req->ctx;
+       u64 sqe_addr = req->cancel.addr;
+       struct io_tctx_node *node;
+       int ret;
 
-       io_async_find_and_cancel(ctx, req, req->cancel.addr, 0);
+       /* tasks should wait for their io-wq threads, so safe w/o sync */
+       ret = io_async_cancel_one(req->task->io_uring, sqe_addr, ctx);
+       spin_lock_irq(&ctx->completion_lock);
+       if (ret != -ENOENT)
+               goto done;
+       ret = io_timeout_cancel(ctx, sqe_addr);
+       if (ret != -ENOENT)
+               goto done;
+       ret = io_poll_cancel(ctx, sqe_addr);
+       if (ret != -ENOENT)
+               goto done;
+       spin_unlock_irq(&ctx->completion_lock);
+
+       /* slow path, try all io-wq's */
+       io_ring_submit_lock(ctx, !(issue_flags & IO_URING_F_NONBLOCK));
+       ret = -ENOENT;
+       list_for_each_entry(node, &ctx->tctx_list, ctx_node) {
+               struct io_uring_task *tctx = node->task->io_uring;
+
+               if (!tctx || !tctx->io_wq)
+                       continue;
+               ret = io_async_cancel_one(tctx, req->cancel.addr, ctx);
+               if (ret != -ENOENT)
+                       break;
+       }
+       io_ring_submit_unlock(ctx, !(issue_flags & IO_URING_F_NONBLOCK));
+
+       spin_lock_irq(&ctx->completion_lock);
+done:
+       io_cqring_fill_event(req, ret);
+       io_commit_cqring(ctx);
+       spin_unlock_irq(&ctx->completion_lock);
+       io_cqring_ev_posted(ctx);
+
+       if (ret < 0)
+               req_set_fail_links(req);
+       io_put_req(req);
        return 0;
 }
 
@@ -5916,18 +6040,8 @@ static int io_issue_sqe(struct io_kiocb *req, unsigned int issue_flags)
        const struct cred *creds = NULL;
        int ret;
 
-       if (req->work.personality) {
-               const struct cred *new_creds;
-
-               if (!(issue_flags & IO_URING_F_NONBLOCK))
-                       mutex_lock(&ctx->uring_lock);
-               new_creds = idr_find(&ctx->personality_idr, req->work.personality);
-               if (!(issue_flags & IO_URING_F_NONBLOCK))
-                       mutex_unlock(&ctx->uring_lock);
-               if (!new_creds)
-                       return -EINVAL;
-               creds = override_creds(new_creds);
-       }
+       if (req->work.creds && req->work.creds != current_cred())
+               creds = override_creds(req->work.creds);
 
        switch (req->opcode) {
        case IORING_OP_NOP:
@@ -6147,7 +6261,6 @@ static enum hrtimer_restart io_link_timeout_fn(struct hrtimer *timer)
        spin_unlock_irqrestore(&ctx->completion_lock, flags);
 
        if (prev) {
-               req_set_fail_links(prev);
                io_async_find_and_cancel(ctx, req, prev->user_data, -ETIME);
                io_put_req_deferred(prev, 1);
        } else {
@@ -6291,7 +6404,7 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req,
 {
        struct io_submit_state *state;
        unsigned int sqe_flags;
-       int ret = 0;
+       int personality, ret = 0;
 
        req->opcode = READ_ONCE(sqe->opcode);
        /* same numerical values with corresponding REQ_F_*, safe to copy */
@@ -6306,6 +6419,9 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req,
        refcount_set(&req->refs, 2);
        req->task = current;
        req->result = 0;
+       req->work.list.next = NULL;
+       req->work.creds = NULL;
+       req->work.flags = 0;
 
        /* enforce forwards compatibility on users */
        if (unlikely(sqe_flags & ~SQE_VALID_FLAGS)) {
@@ -6323,9 +6439,13 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req,
            !io_op_defs[req->opcode].buffer_select)
                return -EOPNOTSUPP;
 
-       req->work.list.next = NULL;
-       req->work.flags = 0;
-       req->work.personality = READ_ONCE(sqe->personality);
+       personality = READ_ONCE(sqe->personality);
+       if (personality) {
+               req->work.creds = xa_load(&ctx->personalities, personality);
+               if (!req->work.creds)
+                       return -EINVAL;
+               get_cred(req->work.creds);
+       }
        state = &ctx->submit_state;
 
        /*
@@ -6587,7 +6707,8 @@ static int __io_sq_thread(struct io_ring_ctx *ctx, bool cap_entries)
                if (!list_empty(&ctx->iopoll_list))
                        io_do_iopoll(ctx, &nr_events, 0);
 
-               if (to_submit && likely(!percpu_ref_is_dying(&ctx->refs)))
+               if (to_submit && likely(!percpu_ref_is_dying(&ctx->refs)) &&
+                   !(ctx->flags & IORING_SETUP_R_DISABLED))
                        ret = io_submit_sqes(ctx, to_submit);
                mutex_unlock(&ctx->uring_lock);
        }
@@ -6611,58 +6732,6 @@ static void io_sqd_update_thread_idle(struct io_sq_data *sqd)
        sqd->sq_thread_idle = sq_thread_idle;
 }
 
-static void io_sqd_init_new(struct io_sq_data *sqd)
-{
-       struct io_ring_ctx *ctx;
-
-       while (!list_empty(&sqd->ctx_new_list)) {
-               ctx = list_first_entry(&sqd->ctx_new_list, struct io_ring_ctx, sqd_list);
-               list_move_tail(&ctx->sqd_list, &sqd->ctx_list);
-               complete(&ctx->sq_thread_comp);
-       }
-
-       io_sqd_update_thread_idle(sqd);
-}
-
-static bool io_sq_thread_should_stop(struct io_sq_data *sqd)
-{
-       return test_bit(IO_SQ_THREAD_SHOULD_STOP, &sqd->state);
-}
-
-static bool io_sq_thread_should_park(struct io_sq_data *sqd)
-{
-       return test_bit(IO_SQ_THREAD_SHOULD_PARK, &sqd->state);
-}
-
-static void io_sq_thread_parkme(struct io_sq_data *sqd)
-{
-       for (;;) {
-               /*
-                * TASK_PARKED is a special state; we must serialize against
-                * possible pending wakeups to avoid store-store collisions on
-                * task->state.
-                *
-                * Such a collision might possibly result in the task state
-                * changin from TASK_PARKED and us failing the
-                * wait_task_inactive() in kthread_park().
-                */
-               set_special_state(TASK_PARKED);
-               if (!test_bit(IO_SQ_THREAD_SHOULD_PARK, &sqd->state))
-                       break;
-
-               /*
-                * Thread is going to call schedule(), do not preempt it,
-                * or the caller of kthread_park() may spend more time in
-                * wait_task_inactive().
-                */
-               preempt_disable();
-               complete(&sqd->parked);
-               schedule_preempt_disabled();
-               preempt_enable();
-       }
-       __set_current_state(TASK_RUNNING);
-}
-
 static int io_sq_thread(void *data)
 {
        struct io_sq_data *sqd = data;
@@ -6681,31 +6750,32 @@ static int io_sq_thread(void *data)
                set_cpus_allowed_ptr(current, cpu_online_mask);
        current->flags |= PF_NO_SETAFFINITY;
 
-       wait_for_completion(&sqd->startup);
-
-       while (!io_sq_thread_should_stop(sqd)) {
+       mutex_lock(&sqd->lock);
+       while (!test_bit(IO_SQ_THREAD_SHOULD_STOP, &sqd->state)) {
                int ret;
                bool cap_entries, sqt_spin, needs_sched;
 
-               /*
-                * Any changes to the sqd lists are synchronized through the
-                * thread parking. This synchronizes the thread vs users,
-                * the users are synchronized on the sqd->ctx_lock.
-                */
-               if (io_sq_thread_should_park(sqd)) {
-                       io_sq_thread_parkme(sqd);
-                       continue;
-               }
-               if (unlikely(!list_empty(&sqd->ctx_new_list))) {
-                       io_sqd_init_new(sqd);
+               if (test_bit(IO_SQ_THREAD_SHOULD_PARK, &sqd->state)) {
+                       mutex_unlock(&sqd->lock);
+                       cond_resched();
+                       mutex_lock(&sqd->lock);
+                       io_run_task_work();
+                       io_run_task_work_head(&sqd->park_task_work);
                        timeout = jiffies + sqd->sq_thread_idle;
+                       continue;
                }
                if (fatal_signal_pending(current))
                        break;
                sqt_spin = false;
                cap_entries = !list_is_singular(&sqd->ctx_list);
                list_for_each_entry(ctx, &sqd->ctx_list, sqd_list) {
+                       const struct cred *creds = NULL;
+
+                       if (ctx->sq_creds != current_cred())
+                               creds = override_creds(ctx->sq_creds);
                        ret = __io_sq_thread(ctx, cap_entries);
+                       if (creds)
+                               revert_creds(creds);
                        if (!sqt_spin && (ret > 0 || !list_empty(&ctx->iopoll_list)))
                                sqt_spin = true;
                }
@@ -6732,45 +6802,33 @@ static int io_sq_thread(void *data)
                        }
                }
 
-               if (needs_sched && !io_sq_thread_should_park(sqd)) {
+               if (needs_sched && !test_bit(IO_SQ_THREAD_SHOULD_PARK, &sqd->state)) {
                        list_for_each_entry(ctx, &sqd->ctx_list, sqd_list)
                                io_ring_set_wakeup_flag(ctx);
 
+                       mutex_unlock(&sqd->lock);
                        schedule();
                        try_to_freeze();
+                       mutex_lock(&sqd->lock);
                        list_for_each_entry(ctx, &sqd->ctx_list, sqd_list)
                                io_ring_clear_wakeup_flag(ctx);
                }
 
                finish_wait(&sqd->wait, &wait);
+               io_run_task_work_head(&sqd->park_task_work);
                timeout = jiffies + sqd->sq_thread_idle;
        }
 
        list_for_each_entry(ctx, &sqd->ctx_list, sqd_list)
                io_uring_cancel_sqpoll(ctx);
-
-       io_run_task_work();
-
-       /*
-        * Ensure that we park properly if racing with someone trying to park
-        * while we're exiting. If we fail to grab the lock, check park and
-        * park if necessary. The ordering with the park bit and the lock
-        * ensures that we catch this reliably.
-        */
-       if (!mutex_trylock(&sqd->lock)) {
-               if (io_sq_thread_should_park(sqd))
-                       io_sq_thread_parkme(sqd);
-               mutex_lock(&sqd->lock);
-       }
-
        sqd->thread = NULL;
-       list_for_each_entry(ctx, &sqd->ctx_list, sqd_list) {
-               ctx->sqo_exec = 1;
+       list_for_each_entry(ctx, &sqd->ctx_list, sqd_list)
                io_ring_set_wakeup_flag(ctx);
-       }
+       mutex_unlock(&sqd->lock);
 
+       io_run_task_work();
+       io_run_task_work_head(&sqd->park_task_work);
        complete(&sqd->exited);
-       mutex_unlock(&sqd->lock);
        do_exit(0);
 }
 
@@ -7071,47 +7129,47 @@ static int io_sqe_files_unregister(struct io_ring_ctx *ctx)
 static void io_sq_thread_unpark(struct io_sq_data *sqd)
        __releases(&sqd->lock)
 {
-       if (sqd->thread == current)
-               return;
+       WARN_ON_ONCE(sqd->thread == current);
+
+       /*
+        * Do the dance but not conditional clear_bit() because it'd race with
+        * other threads incrementing park_pending and setting the bit.
+        */
        clear_bit(IO_SQ_THREAD_SHOULD_PARK, &sqd->state);
-       if (sqd->thread)
-               wake_up_state(sqd->thread, TASK_PARKED);
+       if (atomic_dec_return(&sqd->park_pending))
+               set_bit(IO_SQ_THREAD_SHOULD_PARK, &sqd->state);
        mutex_unlock(&sqd->lock);
 }
 
 static void io_sq_thread_park(struct io_sq_data *sqd)
        __acquires(&sqd->lock)
 {
-       if (sqd->thread == current)
-               return;
+       WARN_ON_ONCE(sqd->thread == current);
+
+       atomic_inc(&sqd->park_pending);
        set_bit(IO_SQ_THREAD_SHOULD_PARK, &sqd->state);
        mutex_lock(&sqd->lock);
-       if (sqd->thread) {
+       if (sqd->thread)
                wake_up_process(sqd->thread);
-               wait_for_completion(&sqd->parked);
-       }
 }
 
 static void io_sq_thread_stop(struct io_sq_data *sqd)
 {
-       if (test_bit(IO_SQ_THREAD_SHOULD_STOP, &sqd->state))
-               return;
+       WARN_ON_ONCE(sqd->thread == current);
+
        mutex_lock(&sqd->lock);
-       if (sqd->thread) {
-               set_bit(IO_SQ_THREAD_SHOULD_STOP, &sqd->state);
-               WARN_ON_ONCE(test_bit(IO_SQ_THREAD_SHOULD_PARK, &sqd->state));
+       set_bit(IO_SQ_THREAD_SHOULD_STOP, &sqd->state);
+       if (sqd->thread)
                wake_up_process(sqd->thread);
-               mutex_unlock(&sqd->lock);
-               wait_for_completion(&sqd->exited);
-               WARN_ON_ONCE(sqd->thread);
-       } else {
-               mutex_unlock(&sqd->lock);
-       }
+       mutex_unlock(&sqd->lock);
+       wait_for_completion(&sqd->exited);
 }
 
 static void io_put_sq_data(struct io_sq_data *sqd)
 {
        if (refcount_dec_and_test(&sqd->refs)) {
+               WARN_ON_ONCE(atomic_read(&sqd->park_pending));
+
                io_sq_thread_stop(sqd);
                kfree(sqd);
        }
@@ -7122,22 +7180,15 @@ static void io_sq_thread_finish(struct io_ring_ctx *ctx)
        struct io_sq_data *sqd = ctx->sq_data;
 
        if (sqd) {
-               complete(&sqd->startup);
-               if (sqd->thread) {
-                       wait_for_completion(&ctx->sq_thread_comp);
-                       io_sq_thread_park(sqd);
-               }
-
-               mutex_lock(&sqd->ctx_lock);
-               list_del(&ctx->sqd_list);
+               io_sq_thread_park(sqd);
+               list_del_init(&ctx->sqd_list);
                io_sqd_update_thread_idle(sqd);
-               mutex_unlock(&sqd->ctx_lock);
-
-               if (sqd->thread)
-                       io_sq_thread_unpark(sqd);
+               io_sq_thread_unpark(sqd);
 
                io_put_sq_data(sqd);
                ctx->sq_data = NULL;
+               if (ctx->sq_creds)
+                       put_cred(ctx->sq_creds);
        }
 }
 
@@ -7161,31 +7212,42 @@ static struct io_sq_data *io_attach_sq_data(struct io_uring_params *p)
                fdput(f);
                return ERR_PTR(-EINVAL);
        }
+       if (sqd->task_tgid != current->tgid) {
+               fdput(f);
+               return ERR_PTR(-EPERM);
+       }
 
        refcount_inc(&sqd->refs);
        fdput(f);
        return sqd;
 }
 
-static struct io_sq_data *io_get_sq_data(struct io_uring_params *p)
+static struct io_sq_data *io_get_sq_data(struct io_uring_params *p,
+                                        bool *attached)
 {
        struct io_sq_data *sqd;
 
-       if (p->flags & IORING_SETUP_ATTACH_WQ)
-               return io_attach_sq_data(p);
+       *attached = false;
+       if (p->flags & IORING_SETUP_ATTACH_WQ) {
+               sqd = io_attach_sq_data(p);
+               if (!IS_ERR(sqd)) {
+                       *attached = true;
+                       return sqd;
+               }
+               /* fall through for EPERM case, setup new sqd/task */
+               if (PTR_ERR(sqd) != -EPERM)
+                       return sqd;
+       }
 
        sqd = kzalloc(sizeof(*sqd), GFP_KERNEL);
        if (!sqd)
                return ERR_PTR(-ENOMEM);
 
+       atomic_set(&sqd->park_pending, 0);
        refcount_set(&sqd->refs, 1);
        INIT_LIST_HEAD(&sqd->ctx_list);
-       INIT_LIST_HEAD(&sqd->ctx_new_list);
-       mutex_init(&sqd->ctx_lock);
        mutex_init(&sqd->lock);
        init_waitqueue_head(&sqd->wait);
-       init_completion(&sqd->startup);
-       init_completion(&sqd->parked);
        init_completion(&sqd->exited);
        return sqd;
 }
@@ -7802,7 +7864,6 @@ static int io_uring_alloc_task_context(struct task_struct *task,
        init_waitqueue_head(&tctx->wait);
        tctx->last = NULL;
        atomic_set(&tctx->in_idle, 0);
-       tctx->sqpoll = false;
        task->io_uring = tctx;
        spin_lock_init(&tctx->task_lock);
        INIT_WQ_LIST(&tctx->task_list);
@@ -7823,26 +7884,6 @@ void __io_uring_free(struct task_struct *tsk)
        tsk->io_uring = NULL;
 }
 
-static int io_sq_thread_fork(struct io_sq_data *sqd, struct io_ring_ctx *ctx)
-{
-       struct task_struct *tsk;
-       int ret;
-
-       clear_bit(IO_SQ_THREAD_SHOULD_STOP, &sqd->state);
-       reinit_completion(&sqd->parked);
-       ctx->sqo_exec = 0;
-       sqd->task_pid = current->pid;
-       tsk = create_io_thread(io_sq_thread, sqd, NUMA_NO_NODE);
-       if (IS_ERR(tsk))
-               return PTR_ERR(tsk);
-       ret = io_uring_alloc_task_context(tsk, ctx);
-       if (ret)
-               set_bit(IO_SQ_THREAD_SHOULD_STOP, &sqd->state);
-       sqd->thread = tsk;
-       wake_up_new_task(tsk);
-       return ret;
-}
-
 static int io_sq_offload_create(struct io_ring_ctx *ctx,
                                struct io_uring_params *p)
 {
@@ -7865,29 +7906,36 @@ static int io_sq_offload_create(struct io_ring_ctx *ctx,
        if (ctx->flags & IORING_SETUP_SQPOLL) {
                struct task_struct *tsk;
                struct io_sq_data *sqd;
+               bool attached;
 
                ret = -EPERM;
                if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_NICE))
                        goto err;
 
-               sqd = io_get_sq_data(p);
+               sqd = io_get_sq_data(p, &attached);
                if (IS_ERR(sqd)) {
                        ret = PTR_ERR(sqd);
                        goto err;
                }
 
+               ctx->sq_creds = get_current_cred();
                ctx->sq_data = sqd;
-               io_sq_thread_park(sqd);
-               mutex_lock(&sqd->ctx_lock);
-               list_add(&ctx->sqd_list, &sqd->ctx_new_list);
-               mutex_unlock(&sqd->ctx_lock);
-               io_sq_thread_unpark(sqd);
-
                ctx->sq_thread_idle = msecs_to_jiffies(p->sq_thread_idle);
                if (!ctx->sq_thread_idle)
                        ctx->sq_thread_idle = HZ;
 
-               if (sqd->thread)
+               ret = 0;
+               io_sq_thread_park(sqd);
+               list_add(&ctx->sqd_list, &sqd->ctx_list);
+               io_sqd_update_thread_idle(sqd);
+               /* don't attach to a dying SQPOLL thread, would be racy */
+               if (attached && !sqd->thread)
+                       ret = -ENXIO;
+               io_sq_thread_unpark(sqd);
+
+               if (ret < 0)
+                       goto err;
+               if (attached)
                        return 0;
 
                if (p->flags & IORING_SETUP_SQ_AFF) {
@@ -7895,9 +7943,9 @@ static int io_sq_offload_create(struct io_ring_ctx *ctx,
 
                        ret = -EINVAL;
                        if (cpu >= nr_cpu_ids)
-                               goto err;
+                               goto err_sqpoll;
                        if (!cpu_online(cpu))
-                               goto err;
+                               goto err_sqpoll;
 
                        sqd->sq_cpu = cpu;
                } else {
@@ -7905,15 +7953,15 @@ static int io_sq_offload_create(struct io_ring_ctx *ctx,
                }
 
                sqd->task_pid = current->pid;
+               sqd->task_tgid = current->tgid;
                tsk = create_io_thread(io_sq_thread, sqd, NUMA_NO_NODE);
                if (IS_ERR(tsk)) {
                        ret = PTR_ERR(tsk);
-                       goto err;
+                       goto err_sqpoll;
                }
-               ret = io_uring_alloc_task_context(tsk, ctx);
-               if (ret)
-                       set_bit(IO_SQ_THREAD_SHOULD_STOP, &sqd->state);
+
                sqd->thread = tsk;
+               ret = io_uring_alloc_task_context(tsk, ctx);
                wake_up_new_task(tsk);
                if (ret)
                        goto err;
@@ -7927,15 +7975,9 @@ static int io_sq_offload_create(struct io_ring_ctx *ctx,
 err:
        io_sq_thread_finish(ctx);
        return ret;
-}
-
-static void io_sq_offload_start(struct io_ring_ctx *ctx)
-{
-       struct io_sq_data *sqd = ctx->sq_data;
-
-       ctx->flags &= ~IORING_SETUP_R_DISABLED;
-       if (ctx->flags & IORING_SETUP_SQPOLL)
-               complete(&sqd->startup);
+err_sqpoll:
+       complete(&ctx->sq_data->exited);
+       goto err;
 }
 
 static inline void __io_unaccount_mem(struct user_struct *user,
@@ -8345,19 +8387,13 @@ static int io_eventfd_unregister(struct io_ring_ctx *ctx)
        return -ENXIO;
 }
 
-static int __io_destroy_buffers(int id, void *p, void *data)
-{
-       struct io_ring_ctx *ctx = data;
-       struct io_buffer *buf = p;
-
-       __io_remove_buffers(ctx, buf, id, -1U);
-       return 0;
-}
-
 static void io_destroy_buffers(struct io_ring_ctx *ctx)
 {
-       idr_for_each(&ctx->io_buffer_idr, __io_destroy_buffers, ctx);
-       idr_destroy(&ctx->io_buffer_idr);
+       struct io_buffer *buf;
+       unsigned long index;
+
+       xa_for_each(&ctx->io_buffers, index, buf)
+               __io_remove_buffers(ctx, buf, index, -1U);
 }
 
 static void io_req_cache_free(struct list_head *list, struct task_struct *tsk)
@@ -8399,11 +8435,13 @@ static void io_ring_ctx_free(struct io_ring_ctx *ctx)
 {
        /*
         * Some may use context even when all refs and requests have been put,
-        * and they are free to do so while still holding uring_lock, see
-        * __io_req_task_submit(). Wait for them to finish.
+        * and they are free to do so while still holding uring_lock or
+        * completion_lock, see __io_req_task_submit(). Wait for them to finish.
         */
        mutex_lock(&ctx->uring_lock);
        mutex_unlock(&ctx->uring_lock);
+       spin_lock_irq(&ctx->completion_lock);
+       spin_unlock_irq(&ctx->completion_lock);
 
        io_sq_thread_finish(ctx);
        io_sqe_buffers_unregister(ctx);
@@ -8418,7 +8456,6 @@ static void io_ring_ctx_free(struct io_ring_ctx *ctx)
        mutex_unlock(&ctx->uring_lock);
        io_eventfd_unregister(ctx);
        io_destroy_buffers(ctx);
-       idr_destroy(&ctx->personality_idr);
 
 #if defined(CONFIG_UNIX)
        if (ctx->ring_sock) {
@@ -8483,7 +8520,7 @@ static int io_unregister_personality(struct io_ring_ctx *ctx, unsigned id)
 {
        const struct cred *creds;
 
-       creds = idr_remove(&ctx->personality_idr, id);
+       creds = xa_erase(&ctx->personalities, id);
        if (creds) {
                put_cred(creds);
                return 0;
@@ -8492,40 +8529,39 @@ static int io_unregister_personality(struct io_ring_ctx *ctx, unsigned id)
        return -EINVAL;
 }
 
-static int io_remove_personalities(int id, void *p, void *data)
+static inline bool io_run_ctx_fallback(struct io_ring_ctx *ctx)
 {
-       struct io_ring_ctx *ctx = data;
-
-       io_unregister_personality(ctx, id);
-       return 0;
+       return io_run_task_work_head(&ctx->exit_task_work);
 }
 
-static bool io_run_ctx_fallback(struct io_ring_ctx *ctx)
-{
-       struct callback_head *work, *next;
-       bool executed = false;
-
-       do {
-               work = xchg(&ctx->exit_task_work, NULL);
-               if (!work)
-                       break;
+struct io_tctx_exit {
+       struct callback_head            task_work;
+       struct completion               completion;
+       struct io_ring_ctx              *ctx;
+};
 
-               do {
-                       next = work->next;
-                       work->func(work);
-                       work = next;
-                       cond_resched();
-               } while (work);
-               executed = true;
-       } while (1);
+static void io_tctx_exit_cb(struct callback_head *cb)
+{
+       struct io_uring_task *tctx = current->io_uring;
+       struct io_tctx_exit *work;
 
-       return executed;
+       work = container_of(cb, struct io_tctx_exit, task_work);
+       /*
+        * When @in_idle, we're in cancellation and it's racy to remove the
+        * node. It'll be removed by the end of cancellation, just ignore it.
+        */
+       if (!atomic_read(&tctx->in_idle))
+               io_uring_del_task_file((unsigned long)work->ctx);
+       complete(&work->completion);
 }
 
 static void io_ring_exit_work(struct work_struct *work)
 {
-       struct io_ring_ctx *ctx = container_of(work, struct io_ring_ctx,
-                                              exit_work);
+       struct io_ring_ctx *ctx = container_of(work, struct io_ring_ctx, exit_work);
+       unsigned long timeout = jiffies + HZ * 60 * 5;
+       struct io_tctx_exit exit;
+       struct io_tctx_node *node;
+       int ret;
 
        /*
         * If we're doing polled IO and end up having requests being
@@ -8535,21 +8571,57 @@ static void io_ring_exit_work(struct work_struct *work)
         */
        do {
                io_uring_try_cancel_requests(ctx, NULL, NULL);
+
+               WARN_ON_ONCE(time_after(jiffies, timeout));
        } while (!wait_for_completion_timeout(&ctx->ref_comp, HZ/20));
+
+       mutex_lock(&ctx->uring_lock);
+       while (!list_empty(&ctx->tctx_list)) {
+               WARN_ON_ONCE(time_after(jiffies, timeout));
+
+               node = list_first_entry(&ctx->tctx_list, struct io_tctx_node,
+                                       ctx_node);
+               exit.ctx = ctx;
+               init_completion(&exit.completion);
+               init_task_work(&exit.task_work, io_tctx_exit_cb);
+               ret = task_work_add(node->task, &exit.task_work, TWA_SIGNAL);
+               if (WARN_ON_ONCE(ret))
+                       continue;
+               wake_up_process(node->task);
+
+               mutex_unlock(&ctx->uring_lock);
+               wait_for_completion(&exit.completion);
+               cond_resched();
+               mutex_lock(&ctx->uring_lock);
+       }
+       mutex_unlock(&ctx->uring_lock);
+
        io_ring_ctx_free(ctx);
 }
 
 static void io_ring_ctx_wait_and_kill(struct io_ring_ctx *ctx)
 {
+       unsigned long index;
+       struct creds *creds;
+
        mutex_lock(&ctx->uring_lock);
        percpu_ref_kill(&ctx->refs);
        /* if force is set, the ring is going away. always drop after that */
        ctx->cq_overflow_flushed = 1;
        if (ctx->rings)
                __io_cqring_overflow_flush(ctx, true, NULL, NULL);
-       idr_for_each(&ctx->personality_idr, io_remove_personalities, ctx);
+       xa_for_each(&ctx->personalities, index, creds)
+               io_unregister_personality(ctx, index);
        mutex_unlock(&ctx->uring_lock);
 
+       /* prevent SQPOLL from submitting new requests */
+       if (ctx->sq_data) {
+               io_sq_thread_park(ctx->sq_data);
+               list_del_init(&ctx->sqd_list);
+               io_sqd_update_thread_idle(ctx->sq_data);
+               io_sq_thread_unpark(ctx->sq_data);
+       }
+
        io_kill_timeouts(ctx, NULL, NULL);
        io_poll_remove_all(ctx, NULL, NULL);
 
@@ -8600,11 +8672,11 @@ static bool io_cancel_task_cb(struct io_wq_work *work, void *data)
        return ret;
 }
 
-static void io_cancel_defer_files(struct io_ring_ctx *ctx,
+static bool io_cancel_defer_files(struct io_ring_ctx *ctx,
                                  struct task_struct *task,
                                  struct files_struct *files)
 {
-       struct io_defer_entry *de = NULL;
+       struct io_defer_entry *de;
        LIST_HEAD(list);
 
        spin_lock_irq(&ctx->completion_lock);
@@ -8615,6 +8687,8 @@ static void io_cancel_defer_files(struct io_ring_ctx *ctx,
                }
        }
        spin_unlock_irq(&ctx->completion_lock);
+       if (list_empty(&list))
+               return false;
 
        while (!list_empty(&list)) {
                de = list_first_entry(&list, struct io_defer_entry, list);
@@ -8624,6 +8698,38 @@ static void io_cancel_defer_files(struct io_ring_ctx *ctx,
                io_req_complete(de->req, -ECANCELED);
                kfree(de);
        }
+       return true;
+}
+
+static bool io_cancel_ctx_cb(struct io_wq_work *work, void *data)
+{
+       struct io_kiocb *req = container_of(work, struct io_kiocb, work);
+
+       return req->ctx == data;
+}
+
+static bool io_uring_try_cancel_iowq(struct io_ring_ctx *ctx)
+{
+       struct io_tctx_node *node;
+       enum io_wq_cancel cret;
+       bool ret = false;
+
+       mutex_lock(&ctx->uring_lock);
+       list_for_each_entry(node, &ctx->tctx_list, ctx_node) {
+               struct io_uring_task *tctx = node->task->io_uring;
+
+               /*
+                * io_wq will stay alive while we hold uring_lock, because it's
+                * killed after ctx nodes, which requires to take the lock.
+                */
+               if (!tctx || !tctx->io_wq)
+                       continue;
+               cret = io_wq_cancel_cb(tctx->io_wq, io_cancel_ctx_cb, ctx, true);
+               ret |= (cret != IO_WQ_CANCEL_NOTFOUND);
+       }
+       mutex_unlock(&ctx->uring_lock);
+
+       return ret;
 }
 
 static void io_uring_try_cancel_requests(struct io_ring_ctx *ctx,
@@ -8631,27 +8737,34 @@ static void io_uring_try_cancel_requests(struct io_ring_ctx *ctx,
                                         struct files_struct *files)
 {
        struct io_task_cancel cancel = { .task = task, .files = files, };
-       struct task_struct *tctx_task = task ?: current;
-       struct io_uring_task *tctx = tctx_task->io_uring;
+       struct io_uring_task *tctx = task ? task->io_uring : NULL;
 
        while (1) {
                enum io_wq_cancel cret;
                bool ret = false;
 
-               if (tctx && tctx->io_wq) {
+               if (!task) {
+                       ret |= io_uring_try_cancel_iowq(ctx);
+               } else if (tctx && tctx->io_wq) {
+                       /*
+                        * Cancels requests of all rings, not only @ctx, but
+                        * it's fine as the task is in exit/exec.
+                        */
                        cret = io_wq_cancel_cb(tctx->io_wq, io_cancel_task_cb,
                                               &cancel, true);
                        ret |= (cret != IO_WQ_CANCEL_NOTFOUND);
                }
 
                /* SQPOLL thread does its own polling */
-               if (!(ctx->flags & IORING_SETUP_SQPOLL) && !files) {
+               if ((!(ctx->flags & IORING_SETUP_SQPOLL) && !files) ||
+                   (ctx->sq_data && ctx->sq_data->thread == current)) {
                        while (!list_empty_careful(&ctx->iopoll_list)) {
                                io_iopoll_try_reap_events(ctx);
                                ret = true;
                        }
                }
 
+               ret |= io_cancel_defer_files(ctx, task, files);
                ret |= io_poll_remove_all(ctx, task, files);
                ret |= io_kill_timeouts(ctx, task, files);
                ret |= io_run_task_work();
@@ -8691,58 +8804,21 @@ static void io_uring_cancel_files(struct io_ring_ctx *ctx,
 
                io_uring_try_cancel_requests(ctx, task, files);
 
-               if (ctx->sq_data)
-                       io_sq_thread_unpark(ctx->sq_data);
                prepare_to_wait(&task->io_uring->wait, &wait,
                                TASK_UNINTERRUPTIBLE);
                if (inflight == io_uring_count_inflight(ctx, task, files))
                        schedule();
                finish_wait(&task->io_uring->wait, &wait);
-               if (ctx->sq_data)
-                       io_sq_thread_park(ctx->sq_data);
-       }
-}
-
-/*
- * We need to iteratively cancel requests, in case a request has dependent
- * hard links. These persist even for failure of cancelations, hence keep
- * looping until none are found.
- */
-static void io_uring_cancel_task_requests(struct io_ring_ctx *ctx,
-                                         struct files_struct *files)
-{
-       struct task_struct *task = current;
-
-       if ((ctx->flags & IORING_SETUP_SQPOLL) && ctx->sq_data) {
-               /* never started, nothing to cancel */
-               if (ctx->flags & IORING_SETUP_R_DISABLED) {
-                       io_sq_offload_start(ctx);
-                       return;
-               }
-               io_sq_thread_park(ctx->sq_data);
-               task = ctx->sq_data->thread;
-               if (task)
-                       atomic_inc(&task->io_uring->in_idle);
        }
-
-       io_cancel_defer_files(ctx, task, files);
-
-       io_uring_cancel_files(ctx, task, files);
-       if (!files)
-               io_uring_try_cancel_requests(ctx, task, NULL);
-
-       if (task)
-               atomic_dec(&task->io_uring->in_idle);
-       if (ctx->sq_data)
-               io_sq_thread_unpark(ctx->sq_data);
 }
 
 /*
  * Note that this task has used io_uring. We use it for cancelation purposes.
  */
-static int io_uring_add_task_file(struct io_ring_ctx *ctx, struct file *file)
+static int io_uring_add_task_file(struct io_ring_ctx *ctx)
 {
        struct io_uring_task *tctx = current->io_uring;
+       struct io_tctx_node *node;
        int ret;
 
        if (unlikely(!tctx)) {
@@ -8751,102 +8827,151 @@ static int io_uring_add_task_file(struct io_ring_ctx *ctx, struct file *file)
                        return ret;
                tctx = current->io_uring;
        }
-       if (tctx->last != file) {
-               void *old = xa_load(&tctx->xa, (unsigned long)file);
+       if (tctx->last != ctx) {
+               void *old = xa_load(&tctx->xa, (unsigned long)ctx);
 
                if (!old) {
-                       get_file(file);
-                       ret = xa_err(xa_store(&tctx->xa, (unsigned long)file,
-                                               file, GFP_KERNEL));
+                       node = kmalloc(sizeof(*node), GFP_KERNEL);
+                       if (!node)
+                               return -ENOMEM;
+                       node->ctx = ctx;
+                       node->task = current;
+
+                       ret = xa_err(xa_store(&tctx->xa, (unsigned long)ctx,
+                                               node, GFP_KERNEL));
                        if (ret) {
-                               fput(file);
+                               kfree(node);
                                return ret;
                        }
+
+                       mutex_lock(&ctx->uring_lock);
+                       list_add(&node->ctx_node, &ctx->tctx_list);
+                       mutex_unlock(&ctx->uring_lock);
                }
-               tctx->last = file;
+               tctx->last = ctx;
        }
-
-       /*
-        * This is race safe in that the task itself is doing this, hence it
-        * cannot be going through the exit/cancel paths at the same time.
-        * This cannot be modified while exit/cancel is running.
-        */
-       if (!tctx->sqpoll && (ctx->flags & IORING_SETUP_SQPOLL))
-               tctx->sqpoll = true;
-
        return 0;
 }
 
 /*
  * Remove this io_uring_file -> task mapping.
  */
-static void io_uring_del_task_file(struct file *file)
+static void io_uring_del_task_file(unsigned long index)
 {
        struct io_uring_task *tctx = current->io_uring;
+       struct io_tctx_node *node;
+
+       if (!tctx)
+               return;
+       node = xa_erase(&tctx->xa, index);
+       if (!node)
+               return;
+
+       WARN_ON_ONCE(current != node->task);
+       WARN_ON_ONCE(list_empty(&node->ctx_node));
+
+       mutex_lock(&node->ctx->uring_lock);
+       list_del(&node->ctx_node);
+       mutex_unlock(&node->ctx->uring_lock);
 
-       if (tctx->last == file)
+       if (tctx->last == node->ctx)
                tctx->last = NULL;
-       file = xa_erase(&tctx->xa, (unsigned long)file);
-       if (file)
-               fput(file);
+       kfree(node);
 }
 
 static void io_uring_clean_tctx(struct io_uring_task *tctx)
 {
-       struct file *file;
+       struct io_tctx_node *node;
        unsigned long index;
 
-       xa_for_each(&tctx->xa, index, file)
-               io_uring_del_task_file(file);
+       xa_for_each(&tctx->xa, index, node)
+               io_uring_del_task_file(index);
        if (tctx->io_wq) {
                io_wq_put_and_exit(tctx->io_wq);
                tctx->io_wq = NULL;
        }
 }
 
+static s64 tctx_inflight(struct io_uring_task *tctx)
+{
+       return percpu_counter_sum(&tctx->inflight);
+}
+
+static void io_sqpoll_cancel_cb(struct callback_head *cb)
+{
+       struct io_tctx_exit *work = container_of(cb, struct io_tctx_exit, task_work);
+       struct io_ring_ctx *ctx = work->ctx;
+       struct io_sq_data *sqd = ctx->sq_data;
+
+       if (sqd->thread)
+               io_uring_cancel_sqpoll(ctx);
+       complete(&work->completion);
+}
+
+static void io_sqpoll_cancel_sync(struct io_ring_ctx *ctx)
+{
+       struct io_sq_data *sqd = ctx->sq_data;
+       struct io_tctx_exit work = { .ctx = ctx, };
+       struct task_struct *task;
+
+       io_sq_thread_park(sqd);
+       list_del_init(&ctx->sqd_list);
+       io_sqd_update_thread_idle(sqd);
+       task = sqd->thread;
+       if (task) {
+               init_completion(&work.completion);
+               init_task_work(&work.task_work, io_sqpoll_cancel_cb);
+               io_task_work_add_head(&sqd->park_task_work, &work.task_work);
+               wake_up_process(task);
+       }
+       io_sq_thread_unpark(sqd);
+
+       if (task)
+               wait_for_completion(&work.completion);
+}
+
 void __io_uring_files_cancel(struct files_struct *files)
 {
        struct io_uring_task *tctx = current->io_uring;
-       struct file *file;
+       struct io_tctx_node *node;
        unsigned long index;
 
        /* make sure overflow events are dropped */
        atomic_inc(&tctx->in_idle);
-       xa_for_each(&tctx->xa, index, file)
-               io_uring_cancel_task_requests(file->private_data, files);
+       xa_for_each(&tctx->xa, index, node) {
+               struct io_ring_ctx *ctx = node->ctx;
+
+               if (ctx->sq_data) {
+                       io_sqpoll_cancel_sync(ctx);
+                       continue;
+               }
+               io_uring_cancel_files(ctx, current, files);
+               if (!files)
+                       io_uring_try_cancel_requests(ctx, current, NULL);
+       }
        atomic_dec(&tctx->in_idle);
 
        if (files)
                io_uring_clean_tctx(tctx);
 }
 
-static s64 tctx_inflight(struct io_uring_task *tctx)
-{
-       return percpu_counter_sum(&tctx->inflight);
-}
-
+/* should only be called by SQPOLL task */
 static void io_uring_cancel_sqpoll(struct io_ring_ctx *ctx)
 {
        struct io_sq_data *sqd = ctx->sq_data;
-       struct io_uring_task *tctx;
+       struct io_uring_task *tctx = current->io_uring;
        s64 inflight;
        DEFINE_WAIT(wait);
 
-       if (!sqd)
-               return;
-       io_sq_thread_park(sqd);
-       if (!sqd->thread || !sqd->thread->io_uring) {
-               io_sq_thread_unpark(sqd);
-               return;
-       }
-       tctx = ctx->sq_data->thread->io_uring;
+       WARN_ON_ONCE(!sqd || ctx->sq_data->thread != current);
+
        atomic_inc(&tctx->in_idle);
        do {
                /* read completions before cancelations */
                inflight = tctx_inflight(tctx);
                if (!inflight)
                        break;
-               io_uring_cancel_task_requests(ctx, NULL);
+               io_uring_try_cancel_requests(ctx, current, NULL);
 
                prepare_to_wait(&tctx->wait, &wait, TASK_UNINTERRUPTIBLE);
                /*
@@ -8859,7 +8984,6 @@ static void io_uring_cancel_sqpoll(struct io_ring_ctx *ctx)
                finish_wait(&tctx->wait, &wait);
        } while (1);
        atomic_dec(&tctx->in_idle);
-       io_sq_thread_unpark(sqd);
 }
 
 /*
@@ -8874,15 +8998,6 @@ void __io_uring_task_cancel(void)
 
        /* make sure overflow events are dropped */
        atomic_inc(&tctx->in_idle);
-
-       if (tctx->sqpoll) {
-               struct file *file;
-               unsigned long index;
-
-               xa_for_each(&tctx->xa, index, file)
-                       io_uring_cancel_sqpoll(file->private_data);
-       }
-
        do {
                /* read completions before cancelations */
                inflight = tctx_inflight(tctx);
@@ -8981,7 +9096,6 @@ static unsigned long io_uring_nommu_get_unmapped_area(struct file *file,
 
 static int io_sqpoll_wait_sq(struct io_ring_ctx *ctx)
 {
-       int ret = 0;
        DEFINE_WAIT(wait);
 
        do {
@@ -8995,7 +9109,7 @@ static int io_sqpoll_wait_sq(struct io_ring_ctx *ctx)
        } while (!signal_pending(current));
 
        finish_wait(&ctx->sqo_sq_wait, &wait);
-       return ret;
+       return 0;
 }
 
 static int io_get_ext_arg(unsigned flags, const void __user *argp, size_t *argsz,
@@ -9069,13 +9183,10 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, to_submit,
        if (ctx->flags & IORING_SETUP_SQPOLL) {
                io_cqring_overflow_flush(ctx, false, NULL, NULL);
 
-               if (unlikely(ctx->sqo_exec)) {
-                       ret = io_sq_thread_fork(ctx->sq_data, ctx);
-                       if (ret)
-                               goto out;
-                       ctx->sqo_exec = 0;
-               }
                ret = -EOWNERDEAD;
+               if (unlikely(ctx->sq_data->thread == NULL)) {
+                       goto out;
+               }
                if (flags & IORING_ENTER_SQ_WAKEUP)
                        wake_up(&ctx->sq_data->wait);
                if (flags & IORING_ENTER_SQ_WAIT) {
@@ -9085,7 +9196,7 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, to_submit,
                }
                submitted = to_submit;
        } else if (to_submit) {
-               ret = io_uring_add_task_file(ctx, f.file);
+               ret = io_uring_add_task_file(ctx);
                if (unlikely(ret))
                        goto out;
                mutex_lock(&ctx->uring_lock);
@@ -9127,10 +9238,9 @@ out_fput:
 }
 
 #ifdef CONFIG_PROC_FS
-static int io_uring_show_cred(int id, void *p, void *data)
+static int io_uring_show_cred(struct seq_file *m, unsigned int id,
+               const struct cred *cred)
 {
-       const struct cred *cred = p;
-       struct seq_file *m = data;
        struct user_namespace *uns = seq_user_ns(m);
        struct group_info *gi;
        kernel_cap_t cap;
@@ -9198,9 +9308,13 @@ static void __io_uring_show_fdinfo(struct io_ring_ctx *ctx, struct seq_file *m)
                seq_printf(m, "%5u: 0x%llx/%u\n", i, buf->ubuf,
                                                (unsigned int) buf->len);
        }
-       if (has_lock && !idr_is_empty(&ctx->personality_idr)) {
+       if (has_lock && !xa_empty(&ctx->personalities)) {
+               unsigned long index;
+               const struct cred *cred;
+
                seq_printf(m, "Personalities:\n");
-               idr_for_each(&ctx->personality_idr, io_uring_show_cred, m);
+               xa_for_each(&ctx->personalities, index, cred)
+                       io_uring_show_cred(m, index, cred);
        }
        seq_printf(m, "PollList:\n");
        spin_lock_irq(&ctx->completion_lock);
@@ -9294,7 +9408,7 @@ static int io_uring_install_fd(struct io_ring_ctx *ctx, struct file *file)
        if (fd < 0)
                return fd;
 
-       ret = io_uring_add_task_file(ctx, file);
+       ret = io_uring_add_task_file(ctx);
        if (ret) {
                put_unused_fd(fd);
                return ret;
@@ -9402,9 +9516,6 @@ static int io_uring_create(unsigned entries, struct io_uring_params *p,
        if (ret)
                goto err;
 
-       if (!(p->flags & IORING_SETUP_R_DISABLED))
-               io_sq_offload_start(ctx);
-
        memset(&p->sq_off, 0, sizeof(p->sq_off));
        p->sq_off.head = offsetof(struct io_rings, sq.head);
        p->sq_off.tail = offsetof(struct io_rings, sq.tail);
@@ -9532,14 +9643,16 @@ out:
 static int io_register_personality(struct io_ring_ctx *ctx)
 {
        const struct cred *creds;
+       u32 id;
        int ret;
 
        creds = get_current_cred();
 
-       ret = idr_alloc_cyclic(&ctx->personality_idr, (void *) creds, 1,
-                               USHRT_MAX, GFP_KERNEL);
-       if (ret < 0)
-               put_cred(creds);
+       ret = xa_alloc_cyclic(&ctx->personalities, &id, (void *)creds,
+                       XA_LIMIT(0, USHRT_MAX), &ctx->pers_next, GFP_KERNEL);
+       if (!ret)
+               return id;
+       put_cred(creds);
        return ret;
 }
 
@@ -9621,7 +9734,9 @@ static int io_register_enable_rings(struct io_ring_ctx *ctx)
        if (ctx->restrictions.registered)
                ctx->restricted = 1;
 
-       io_sq_offload_start(ctx);
+       ctx->flags &= ~IORING_SETUP_R_DISABLED;
+       if (ctx->sq_data && wq_has_sleeper(&ctx->sq_data->wait))
+               wake_up(&ctx->sq_data->wait);
        return 0;
 }
 
index 7ffcd7ef33d4f500f9f8e0de2a86aca8e1943aeb..414769a6ad113af77a363e12518d8cfc711a164e 100644 (file)
@@ -1221,7 +1221,7 @@ iomap_alloc_ioend(struct inode *inode, struct iomap_writepage_ctx *wpc,
        struct iomap_ioend *ioend;
        struct bio *bio;
 
-       bio = bio_alloc_bioset(GFP_NOFS, BIO_MAX_PAGES, &iomap_ioend_bioset);
+       bio = bio_alloc_bioset(GFP_NOFS, BIO_MAX_VECS, &iomap_ioend_bioset);
        bio_set_dev(bio, wpc->iomap.bdev);
        bio->bi_iter.bi_sector = sector;
        bio->bi_opf = REQ_OP_WRITE | wbc_to_write_flags(wbc);
@@ -1252,7 +1252,7 @@ iomap_chain_bio(struct bio *prev)
 {
        struct bio *new;
 
-       new = bio_alloc(GFP_NOFS, BIO_MAX_PAGES);
+       new = bio_alloc(GFP_NOFS, BIO_MAX_VECS);
        bio_copy_dev(new, prev);/* also copies over blkcg information */
        new->bi_iter.bi_sector = bio_end_sector(prev);
        new->bi_opf = prev->bi_opf;
index e2c4991833b8f91e085c885c54a34aa8681789fb..bdd0d89bbf0a3419b8e7906602126a30a26d98f2 100644 (file)
@@ -296,7 +296,7 @@ iomap_dio_bio_actor(struct inode *inode, loff_t pos, loff_t length,
         */
        bio_opf = iomap_dio_bio_opflags(dio, iomap, use_fua);
 
-       nr_pages = bio_iov_vecs_to_alloc(dio->submit.iter, BIO_MAX_PAGES);
+       nr_pages = bio_iov_vecs_to_alloc(dio->submit.iter, BIO_MAX_VECS);
        do {
                size_t n;
                if (dio->error) {
@@ -338,7 +338,7 @@ iomap_dio_bio_actor(struct inode *inode, loff_t pos, loff_t length,
                copied += n;
 
                nr_pages = bio_iov_vecs_to_alloc(dio->submit.iter,
-                                                BIO_MAX_PAGES);
+                                                BIO_MAX_VECS);
                iomap_dio_submit_bio(dio, iomap, bio, pos);
                pos += n;
        } while (nr_pages);
index a648dbf6991e4e5307574b7bb207269d7f650321..a5e478de141744cd7fef9276b26e5dc0b55638f0 100644 (file)
@@ -170,6 +170,16 @@ int iomap_swapfile_activate(struct swap_info_struct *sis,
                        return ret;
        }
 
+       /*
+        * If this swapfile doesn't contain even a single page-aligned
+        * contiguous range of blocks, reject this useless swapfile to
+        * prevent confusion later on.
+        */
+       if (isi.nr_pages == 0) {
+               pr_warn("swapon: Cannot find a single usable page in file.\n");
+               return -EINVAL;
+       }
+
        *pagespan = 1 + isi.highest_ppage - isi.lowest_ppage;
        sis->max = isi.nr_pages;
        sis->pages = isi.nr_pages - 1;
index 99ca97e81b7a95afc6bb65151161a3814f70e82b..6125d2de39b8b8bd18ef8678d9228fdf61eada16 100644 (file)
@@ -1808,9 +1808,6 @@ check_conflicting_open(struct file *filp, const long arg, int flags)
 
        if (flags & FL_LAYOUT)
                return 0;
-       if (flags & FL_DELEG)
-               /* We leave these checks to the caller. */
-               return 0;
 
        if (arg == F_RDLCK)
                return inode_is_open_for_write(inode) ? -EAGAIN : 0;
index 961234d687792a9b432341e2a7c0eed819f876d1..334e7d09aa65275727d9f3db6df845bccb4b762b 100644 (file)
@@ -616,7 +616,7 @@ alloc_new:
                                goto out;
                }
                bio = mpage_alloc(bdev, blocks[0] << (blkbits - 9),
-                               BIO_MAX_PAGES, GFP_NOFS|__GFP_HIGH);
+                               BIO_MAX_VECS, GFP_NOFS|__GFP_HIGH);
                if (bio == NULL)
                        goto confused;
 
index e2a488d403a619f871a6c77c7c357b231cf3f722..14a72224b6571b9617d586f766e39dcb5f1772eb 100644 (file)
@@ -127,7 +127,7 @@ config PNFS_BLOCK
 config PNFS_FLEXFILE_LAYOUT
        tristate
        depends on NFS_V4_1 && NFS_V3
-       default m
+       default NFS_V4
 
 config NFS_V4_1_IMPLEMENTATION_ID_DOMAIN
        string "NFSv4.1 Implementation ID Domain"
index 19a9f434442ff2d420ea65a3044f6590d11fa316..fc4f490f2d785d3581bc7286dcc38ccb2437b8df 100644 (file)
@@ -81,8 +81,9 @@ static struct nfs_open_dir_context *alloc_nfs_open_dir_context(struct inode *dir
                spin_lock(&dir->i_lock);
                if (list_empty(&nfsi->open_files) &&
                    (nfsi->cache_validity & NFS_INO_DATA_INVAL_DEFER))
-                       nfsi->cache_validity |= NFS_INO_INVALID_DATA |
-                               NFS_INO_REVAL_FORCED;
+                       nfs_set_cache_invalid(dir,
+                                             NFS_INO_INVALID_DATA |
+                                                     NFS_INO_REVAL_FORCED);
                list_add(&ctx->list, &nfsi->open_files);
                spin_unlock(&dir->i_lock);
                return ctx;
@@ -1401,6 +1402,13 @@ out_force:
        goto out;
 }
 
+static void nfs_mark_dir_for_revalidate(struct inode *inode)
+{
+       spin_lock(&inode->i_lock);
+       nfs_set_cache_invalid(inode, NFS_INO_REVAL_PAGECACHE);
+       spin_unlock(&inode->i_lock);
+}
+
 /*
  * We judge how long we want to trust negative
  * dentries by looking at the parent inode mtime.
@@ -1435,19 +1443,14 @@ nfs_lookup_revalidate_done(struct inode *dir, struct dentry *dentry,
                        __func__, dentry);
                return 1;
        case 0:
-               nfs_mark_for_revalidate(dir);
-               if (inode && S_ISDIR(inode->i_mode)) {
-                       /* Purge readdir caches. */
-                       nfs_zap_caches(inode);
-                       /*
-                        * We can't d_drop the root of a disconnected tree:
-                        * its d_hash is on the s_anon list and d_drop() would hide
-                        * it from shrink_dcache_for_unmount(), leading to busy
-                        * inodes on unmount and further oopses.
-                        */
-                       if (IS_ROOT(dentry))
-                               return 1;
-               }
+               /*
+                * We can't d_drop the root of a disconnected tree:
+                * its d_hash is on the s_anon list and d_drop() would hide
+                * it from shrink_dcache_for_unmount(), leading to busy
+                * inodes on unmount and further oopses.
+                */
+               if (inode && IS_ROOT(dentry))
+                       return 1;
                dfprintk(LOOKUPCACHE, "NFS: %s(%pd2) is invalid\n",
                                __func__, dentry);
                return 0;
@@ -1525,6 +1528,13 @@ out:
        nfs_free_fattr(fattr);
        nfs_free_fhandle(fhandle);
        nfs4_label_free(label);
+
+       /*
+        * If the lookup failed despite the dentry change attribute being
+        * a match, then we should revalidate the directory cache.
+        */
+       if (!ret && nfs_verify_change_attribute(dir, dentry->d_time))
+               nfs_mark_dir_for_revalidate(dir);
        return nfs_lookup_revalidate_done(dir, dentry, inode, ret);
 }
 
@@ -1567,7 +1577,7 @@ nfs_do_lookup_revalidate(struct inode *dir, struct dentry *dentry,
                error = nfs_lookup_verify_inode(inode, flags);
                if (error) {
                        if (error == -ESTALE)
-                               nfs_zap_caches(dir);
+                               nfs_mark_dir_for_revalidate(dir);
                        goto out_bad;
                }
                nfs_advise_use_readdirplus(dir);
@@ -1691,10 +1701,9 @@ static void nfs_drop_nlink(struct inode *inode)
        if (inode->i_nlink > 0)
                drop_nlink(inode);
        NFS_I(inode)->attr_gencount = nfs_inc_attr_generation_counter();
-       NFS_I(inode)->cache_validity |= NFS_INO_INVALID_CHANGE
-               | NFS_INO_INVALID_CTIME
-               | NFS_INO_INVALID_OTHER
-               | NFS_INO_REVAL_FORCED;
+       nfs_set_cache_invalid(
+               inode, NFS_INO_INVALID_CHANGE | NFS_INO_INVALID_CTIME |
+                              NFS_INO_INVALID_OTHER | NFS_INO_REVAL_FORCED);
        spin_unlock(&inode->i_lock);
 }
 
@@ -1706,7 +1715,7 @@ static void nfs_dentry_iput(struct dentry *dentry, struct inode *inode)
 {
        if (S_ISDIR(inode->i_mode))
                /* drop any readdir cache as it could easily be old */
-               NFS_I(inode)->cache_validity |= NFS_INO_INVALID_DATA;
+               nfs_set_cache_invalid(inode, NFS_INO_INVALID_DATA);
 
        if (dentry->d_flags & DCACHE_NFSFS_RENAMED) {
                nfs_complete_unlink(dentry, inode);
@@ -2064,7 +2073,6 @@ out:
        dput(parent);
        return d;
 out_error:
-       nfs_mark_for_revalidate(dir);
        d = ERR_PTR(error);
        goto out;
 }
@@ -2473,9 +2481,9 @@ int nfs_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
        if (error == 0) {
                spin_lock(&old_inode->i_lock);
                NFS_I(old_inode)->attr_gencount = nfs_inc_attr_generation_counter();
-               NFS_I(old_inode)->cache_validity |= NFS_INO_INVALID_CHANGE
-                       | NFS_INO_INVALID_CTIME
-                       | NFS_INO_REVAL_FORCED;
+               nfs_set_cache_invalid(old_inode, NFS_INO_INVALID_CHANGE |
+                                                        NFS_INO_INVALID_CTIME |
+                                                        NFS_INO_REVAL_FORCED);
                spin_unlock(&old_inode->i_lock);
        }
 out:
index 749bbea14d99a00c6cd62654aa61dead6b9351fd..a7fb076a5f44bcb8311e7bbb76c8ae778e158823 100644 (file)
@@ -207,7 +207,7 @@ static bool nfs_has_xattr_cache(const struct nfs_inode *nfsi)
 }
 #endif
 
-static void nfs_set_cache_invalid(struct inode *inode, unsigned long flags)
+void nfs_set_cache_invalid(struct inode *inode, unsigned long flags)
 {
        struct nfs_inode *nfsi = NFS_I(inode);
        bool have_delegation = NFS_PROTO(inode)->have_delegation(inode, FMODE_READ);
@@ -229,6 +229,7 @@ static void nfs_set_cache_invalid(struct inode *inode, unsigned long flags)
        if (flags & NFS_INO_INVALID_DATA)
                nfs_fscache_invalidate(inode);
 }
+EXPORT_SYMBOL_GPL(nfs_set_cache_invalid);
 
 /*
  * Invalidate the local caches
@@ -1067,8 +1068,8 @@ void nfs_inode_attach_open_context(struct nfs_open_context *ctx)
        spin_lock(&inode->i_lock);
        if (list_empty(&nfsi->open_files) &&
            (nfsi->cache_validity & NFS_INO_DATA_INVAL_DEFER))
-               nfsi->cache_validity |= NFS_INO_INVALID_DATA |
-                       NFS_INO_REVAL_FORCED;
+               nfs_set_cache_invalid(inode, NFS_INO_INVALID_DATA |
+                                                    NFS_INO_REVAL_FORCED);
        list_add_tail_rcu(&ctx->list, &nfsi->open_files);
        spin_unlock(&inode->i_lock);
 }
index 25fb43b69e5a45df09334d6cbf206c2f21687552..7b644d6c09e4b27d8e0e5a25d75f91202ea72049 100644 (file)
@@ -411,7 +411,8 @@ extern int nfs_write_inode(struct inode *, struct writeback_control *);
 extern int nfs_drop_inode(struct inode *);
 extern void nfs_clear_inode(struct inode *);
 extern void nfs_evict_inode(struct inode *);
-void nfs_zap_acl_cache(struct inode *inode);
+extern void nfs_zap_acl_cache(struct inode *inode);
+extern void nfs_set_cache_invalid(struct inode *inode, unsigned long flags);
 extern bool nfs_check_cache_invalid(struct inode *, unsigned long);
 extern int nfs_wait_bit_killable(struct wait_bit_key *key, int mode);
 extern int nfs_wait_atomic_killable(atomic_t *p, unsigned int mode);
index ca10072644ff26bb6a7bbd2a95d5594c8ab4228e..ed1c83738c30d1c17472d55b1e887027c02876fc 100644 (file)
@@ -36,6 +36,7 @@
 #define NFS3_pagepad_sz                (1) /* Page padding */
 #define NFS3_fhandle_sz                (1+16)
 #define NFS3_fh_sz             (NFS3_fhandle_sz)       /* shorthand */
+#define NFS3_post_op_fh_sz     (1+NFS3_fh_sz)
 #define NFS3_sattr_sz          (15)
 #define NFS3_filename_sz       (1+(NFS3_MAXNAMLEN>>2))
 #define NFS3_path_sz           (1+(NFS3_MAXPATHLEN>>2))
@@ -73,7 +74,7 @@
 #define NFS3_readlinkres_sz    (1+NFS3_post_op_attr_sz+1+NFS3_pagepad_sz)
 #define NFS3_readres_sz                (1+NFS3_post_op_attr_sz+3+NFS3_pagepad_sz)
 #define NFS3_writeres_sz       (1+NFS3_wcc_data_sz+4)
-#define NFS3_createres_sz      (1+NFS3_fh_sz+NFS3_post_op_attr_sz+NFS3_wcc_data_sz)
+#define NFS3_createres_sz      (1+NFS3_post_op_fh_sz+NFS3_post_op_attr_sz+NFS3_wcc_data_sz)
 #define NFS3_renameres_sz      (1+(2 * NFS3_wcc_data_sz))
 #define NFS3_linkres_sz                (1+NFS3_post_op_attr_sz+NFS3_wcc_data_sz)
 #define NFS3_readdirres_sz     (1+NFS3_post_op_attr_sz+2+NFS3_pagepad_sz)
index f3fd935620fcb33e34fe3e1c63402746886b595e..094024b0aca19cc59d8759c22cb69f96de5459f8 100644 (file)
@@ -357,13 +357,15 @@ static ssize_t _nfs42_proc_copy(struct file *src,
        truncate_pagecache_range(dst_inode, pos_dst,
                                 pos_dst + res->write_res.count);
        spin_lock(&dst_inode->i_lock);
-       NFS_I(dst_inode)->cache_validity |= (NFS_INO_REVAL_PAGECACHE |
-                       NFS_INO_REVAL_FORCED | NFS_INO_INVALID_SIZE |
-                       NFS_INO_INVALID_ATTR | NFS_INO_INVALID_DATA);
+       nfs_set_cache_invalid(
+               dst_inode, NFS_INO_REVAL_PAGECACHE | NFS_INO_REVAL_FORCED |
+                                  NFS_INO_INVALID_SIZE | NFS_INO_INVALID_ATTR |
+                                  NFS_INO_INVALID_DATA);
        spin_unlock(&dst_inode->i_lock);
        spin_lock(&src_inode->i_lock);
-       NFS_I(src_inode)->cache_validity |= (NFS_INO_REVAL_PAGECACHE |
-                       NFS_INO_REVAL_FORCED | NFS_INO_INVALID_ATIME);
+       nfs_set_cache_invalid(src_inode, NFS_INO_REVAL_PAGECACHE |
+                                                NFS_INO_REVAL_FORCED |
+                                                NFS_INO_INVALID_ATIME);
        spin_unlock(&src_inode->i_lock);
        status = res->write_res.count;
 out:
index 74bc5120013d29820c1cadfb55ea4971f5516072..c65c4b41e2c191dc05e875c070630ab588de63cd 100644 (file)
@@ -1169,14 +1169,14 @@ int nfs4_call_sync(struct rpc_clnt *clnt,
 static void
 nfs4_inc_nlink_locked(struct inode *inode)
 {
-       NFS_I(inode)->cache_validity |= NFS_INO_INVALID_OTHER;
+       nfs_set_cache_invalid(inode, NFS_INO_INVALID_OTHER);
        inc_nlink(inode);
 }
 
 static void
 nfs4_dec_nlink_locked(struct inode *inode)
 {
-       NFS_I(inode)->cache_validity |= NFS_INO_INVALID_OTHER;
+       nfs_set_cache_invalid(inode, NFS_INO_INVALID_OTHER);
        drop_nlink(inode);
 }
 
@@ -1187,35 +1187,31 @@ nfs4_update_changeattr_locked(struct inode *inode,
 {
        struct nfs_inode *nfsi = NFS_I(inode);
 
-       nfsi->cache_validity |= NFS_INO_INVALID_CTIME
-               | NFS_INO_INVALID_MTIME
-               | cache_validity;
+       cache_validity |= NFS_INO_INVALID_CTIME | NFS_INO_INVALID_MTIME;
 
        if (cinfo->atomic && cinfo->before == inode_peek_iversion_raw(inode)) {
                nfsi->cache_validity &= ~NFS_INO_REVAL_PAGECACHE;
                nfsi->attrtimeo_timestamp = jiffies;
        } else {
                if (S_ISDIR(inode->i_mode)) {
-                       nfsi->cache_validity |= NFS_INO_INVALID_DATA;
+                       cache_validity |= NFS_INO_INVALID_DATA;
                        nfs_force_lookup_revalidate(inode);
                } else {
                        if (!NFS_PROTO(inode)->have_delegation(inode,
                                                               FMODE_READ))
-                               nfsi->cache_validity |= NFS_INO_REVAL_PAGECACHE;
+                               cache_validity |= NFS_INO_REVAL_PAGECACHE;
                }
 
                if (cinfo->before != inode_peek_iversion_raw(inode))
-                       nfsi->cache_validity |= NFS_INO_INVALID_ACCESS |
-                                               NFS_INO_INVALID_ACL |
-                                               NFS_INO_INVALID_XATTR;
+                       cache_validity |= NFS_INO_INVALID_ACCESS |
+                                         NFS_INO_INVALID_ACL |
+                                         NFS_INO_INVALID_XATTR;
        }
        inode_set_iversion_raw(inode, cinfo->after);
        nfsi->read_cache_jiffies = timestamp;
        nfsi->attr_gencount = nfs_inc_attr_generation_counter();
+       nfs_set_cache_invalid(inode, cache_validity);
        nfsi->cache_validity &= ~NFS_INO_INVALID_CHANGE;
-
-       if (nfsi->cache_validity & NFS_INO_INVALID_DATA)
-               nfs_fscache_invalidate(inode);
 }
 
 void
@@ -5893,6 +5889,9 @@ static int __nfs4_proc_set_acl(struct inode *inode, const void *buf, size_t bufl
        unsigned int npages = DIV_ROUND_UP(buflen, PAGE_SIZE);
        int ret, i;
 
+       /* You can't remove system.nfs4_acl: */
+       if (buflen == 0)
+               return -EINVAL;
        if (!nfs4_server_supports_acls(server))
                return -EOPNOTSUPP;
        if (npages > ARRAY_SIZE(pages))
@@ -5915,9 +5914,9 @@ static int __nfs4_proc_set_acl(struct inode *inode, const void *buf, size_t bufl
         * so mark the attribute cache invalid.
         */
        spin_lock(&inode->i_lock);
-       NFS_I(inode)->cache_validity |= NFS_INO_INVALID_CHANGE
-               | NFS_INO_INVALID_CTIME
-               | NFS_INO_REVAL_FORCED;
+       nfs_set_cache_invalid(inode, NFS_INO_INVALID_CHANGE |
+                                            NFS_INO_INVALID_CTIME |
+                                            NFS_INO_REVAL_FORCED);
        spin_unlock(&inode->i_lock);
        nfs_access_zap_cache(inode);
        nfs_zap_acl_cache(inode);
@@ -5969,7 +5968,7 @@ static int _nfs4_get_security_label(struct inode *inode, void *buf,
                return ret;
        if (!(fattr.valid & NFS_ATTR_FATTR_V4_SECURITY_LABEL))
                return -ENOENT;
-       return 0;
+       return label.len;
 }
 
 static int nfs4_get_security_label(struct inode *inode, void *buf,
index b27ebdccef70353fc878e57ce2ee2bc82a83459b..5fa11e1aca4c2759358aa37c7c36691c1bc4bcd4 100644 (file)
@@ -500,9 +500,9 @@ nfs_sillyrename(struct inode *dir, struct dentry *dentry)
                nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
                spin_lock(&inode->i_lock);
                NFS_I(inode)->attr_gencount = nfs_inc_attr_generation_counter();
-               NFS_I(inode)->cache_validity |= NFS_INO_INVALID_CHANGE
-                       | NFS_INO_INVALID_CTIME
-                       | NFS_INO_REVAL_FORCED;
+               nfs_set_cache_invalid(inode, NFS_INO_INVALID_CHANGE |
+                                                    NFS_INO_INVALID_CTIME |
+                                                    NFS_INO_REVAL_FORCED);
                spin_unlock(&inode->i_lock);
                d_move(dentry, sdentry);
                break;
index 82bdcb982186ff5f26317189f10d55036d6cdae0..f05a90338a76fe2d86d37d10b47b127c703a8c93 100644 (file)
@@ -303,9 +303,9 @@ static void nfs_set_pageerror(struct address_space *mapping)
        nfs_zap_mapping(mapping->host, mapping);
        /* Force file size revalidation */
        spin_lock(&inode->i_lock);
-       NFS_I(inode)->cache_validity |= NFS_INO_REVAL_FORCED |
-                                       NFS_INO_REVAL_PAGECACHE |
-                                       NFS_INO_INVALID_SIZE;
+       nfs_set_cache_invalid(inode, NFS_INO_REVAL_FORCED |
+                                            NFS_INO_REVAL_PAGECACHE |
+                                            NFS_INO_INVALID_SIZE);
        spin_unlock(&inode->i_lock);
 }
 
@@ -1604,7 +1604,7 @@ static int nfs_writeback_done(struct rpc_task *task,
        /* Deal with the suid/sgid bit corner case */
        if (nfs_should_remove_suid(inode)) {
                spin_lock(&inode->i_lock);
-               NFS_I(inode)->cache_validity |= NFS_INO_INVALID_OTHER;
+               nfs_set_cache_invalid(inode, NFS_INO_INVALID_OTHER);
                spin_unlock(&inode->i_lock);
        }
        return 0;
index 821e5913faee49ac7686bec4d7bec4c96d23f358..d6cff5fbe705b4f64e215507d504a5081ab5b002 100644 (file)
@@ -73,6 +73,7 @@ config NFSD_V4
        select NFSD_V3
        select FS_POSIX_ACL
        select SUNRPC_GSS
+       select CRYPTO
        select CRYPTO_MD5
        select CRYPTO_SHA256
        select GRACE_PERIOD
index 53fcbf79bdca3ac7ea7c43e9222a1b79700f818b..7629248fdd532885d35423968c396dbbe9d56a6a 100644 (file)
@@ -898,6 +898,8 @@ nfsd_file_find_locked(struct inode *inode, unsigned int may_flags,
                        continue;
                if (!nfsd_match_cred(nf->nf_cred, current_cred()))
                        continue;
+               if (!test_bit(NFSD_FILE_HASHED, &nf->nf_flags))
+                       continue;
                if (nfsd_file_get(nf) != NULL)
                        return nf;
        }
index 052be5bf9ef50ca21c920f457aa29ed1e1cd6ff9..7325592b456e5186b8bf3c5ac7f39544e78bf30d 100644 (file)
@@ -1189,6 +1189,7 @@ static void nfsd4_cb_done(struct rpc_task *task, void *calldata)
                switch (task->tk_status) {
                case -EIO:
                case -ETIMEDOUT:
+               case -EACCES:
                        nfsd4_mark_cb_down(clp, task->tk_status);
                }
                break;
index acdb3cd806a1537da45f975b5f4ee528830b97e3..dd9f38d072dd6ecd04fe7aa92e24290e45dab1db 100644 (file)
@@ -1302,7 +1302,7 @@ nfsd4_cleanup_inter_ssc(struct vfsmount *ss_mnt, struct nfsd_file *src,
                        struct nfsd_file *dst)
 {
        nfs42_ssc_close(src->nf_file);
-       /* 'src' is freed by nfsd4_do_async_copy */
+       fput(src->nf_file);
        nfsd_file_put(dst);
        mntput(ss_mnt);
 }
index 423fd6683f3ae2612310df33df5a5b7ef46f5bcf..97447a64bad0bf6d423403774f48ccf84dcd12fc 100644 (file)
@@ -4940,31 +4940,6 @@ static struct file_lock *nfs4_alloc_init_lease(struct nfs4_delegation *dp,
        return fl;
 }
 
-static int nfsd4_check_conflicting_opens(struct nfs4_client *clp,
-                                               struct nfs4_file *fp)
-{
-       struct nfs4_clnt_odstate *co;
-       struct file *f = fp->fi_deleg_file->nf_file;
-       struct inode *ino = locks_inode(f);
-       int writes = atomic_read(&ino->i_writecount);
-
-       if (fp->fi_fds[O_WRONLY])
-               writes--;
-       if (fp->fi_fds[O_RDWR])
-               writes--;
-       if (writes > 0)
-               return -EAGAIN;
-       spin_lock(&fp->fi_lock);
-       list_for_each_entry(co, &fp->fi_clnt_odstate, co_perfile) {
-               if (co->co_client != clp) {
-                       spin_unlock(&fp->fi_lock);
-                       return -EAGAIN;
-               }
-       }
-       spin_unlock(&fp->fi_lock);
-       return 0;
-}
-
 static struct nfs4_delegation *
 nfs4_set_delegation(struct nfs4_client *clp, struct svc_fh *fh,
                    struct nfs4_file *fp, struct nfs4_clnt_odstate *odstate)
@@ -4984,12 +4959,9 @@ nfs4_set_delegation(struct nfs4_client *clp, struct svc_fh *fh,
 
        nf = find_readable_file(fp);
        if (!nf) {
-               /*
-                * We probably could attempt another open and get a read
-                * delegation, but for now, don't bother until the
-                * client actually sends us one.
-                */
-               return ERR_PTR(-EAGAIN);
+               /* We should always have a readable file here */
+               WARN_ON_ONCE(1);
+               return ERR_PTR(-EBADF);
        }
        spin_lock(&state_lock);
        spin_lock(&fp->fi_lock);
@@ -5019,19 +4991,11 @@ nfs4_set_delegation(struct nfs4_client *clp, struct svc_fh *fh,
        if (!fl)
                goto out_clnt_odstate;
 
-       status = nfsd4_check_conflicting_opens(clp, fp);
-       if (status) {
-               locks_free_lock(fl);
-               goto out_clnt_odstate;
-       }
        status = vfs_setlease(fp->fi_deleg_file->nf_file, fl->fl_type, &fl, NULL);
        if (fl)
                locks_free_lock(fl);
        if (status)
                goto out_clnt_odstate;
-       status = nfsd4_check_conflicting_opens(clp, fp);
-       if (status)
-               goto out_clnt_odstate;
 
        spin_lock(&state_lock);
        spin_lock(&fp->fi_lock);
@@ -5113,6 +5077,17 @@ nfs4_open_delegation(struct svc_fh *fh, struct nfsd4_open *open,
                                goto out_no_deleg;
                        if (!cb_up || !(oo->oo_flags & NFS4_OO_CONFIRMED))
                                goto out_no_deleg;
+                       /*
+                        * Also, if the file was opened for write or
+                        * create, there's a good chance the client's
+                        * about to write to it, resulting in an
+                        * immediate recall (since we don't support
+                        * write delegations):
+                        */
+                       if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE)
+                               goto out_no_deleg;
+                       if (open->op_create == NFS4_OPEN_CREATE)
+                               goto out_no_deleg;
                        break;
                default:
                        goto out_no_deleg;
@@ -5389,7 +5364,7 @@ nfs4_laundromat(struct nfsd_net *nn)
        idr_for_each_entry(&nn->s2s_cp_stateids, cps_t, i) {
                cps = container_of(cps_t, struct nfs4_cpntf_state, cp_stateid);
                if (cps->cp_stateid.sc_type == NFS4_COPYNOTIFY_STID &&
-                               cps->cpntf_time > cutoff)
+                               cps->cpntf_time < cutoff)
                        _free_cpntf_state_locked(nn, cps);
        }
        spin_unlock(&nn->s2s_cp_lock);
index 1e75417bfe6e5283f740e72716b86dc8702ac59e..56872e93823da0eee42a08cabd2dcf54ad20f288 100644 (file)
@@ -399,7 +399,7 @@ static void nilfs_segbuf_prepare_write(struct nilfs_segment_buffer *segbuf,
 {
        wi->bio = NULL;
        wi->rest_blocks = segbuf->sb_sum.nblocks;
-       wi->max_pages = BIO_MAX_PAGES;
+       wi->max_pages = BIO_MAX_VECS;
        wi->nr_vecs = min(wi->max_pages, wi->rest_blocks);
        wi->start = wi->end = 0;
        wi->blocknr = segbuf->sb_pseg_start;
index 26f74e092bd98123b0bd45175491d81b80bb35c5..988f1aa9b02aeaac191f6743ac88b5b6f2877ac7 100644 (file)
@@ -12,7 +12,7 @@
 
 #define IS_MNT_SHARED(m) ((m)->mnt.mnt_flags & MNT_SHARED)
 #define IS_MNT_SLAVE(m) ((m)->mnt_master)
-#define IS_MNT_NEW(m)  (!(m)->mnt_ns)
+#define IS_MNT_NEW(m)  (!(m)->mnt_ns || is_anon_ns((m)->mnt_ns))
 #define CLEAR_MNT_SHARED(m) ((m)->mnt.mnt_flags &= ~MNT_SHARED)
 #define IS_MNT_UNBINDABLE(m) ((m)->mnt.mnt_flags & MNT_UNBINDABLE)
 #define IS_MNT_MARKED(m) ((m)->mnt.mnt_flags & MNT_MARKED)
index 3cec6fbef725ed3e3122cf8dffbbd057be5c47b8..e862cab6958387623a287d536b7e3c6b41774e5a 100644 (file)
@@ -1036,8 +1036,6 @@ struct clear_refs_private {
 
 #ifdef CONFIG_MEM_SOFT_DIRTY
 
-#define is_cow_mapping(flags) (((flags) & (VM_SHARED | VM_MAYWRITE)) == VM_MAYWRITE)
-
 static inline bool pte_is_pinned(struct vm_area_struct *vma, unsigned long addr, pte_t pte)
 {
        struct page *page;
index 37aaa8317f3ae1a6a9aa9153f336eefa6c2b1aa4..945896d0ac9e7624db36d48169ebc757d4f18adb 100644 (file)
@@ -1055,10 +1055,9 @@ static long do_restart_poll(struct restart_block *restart_block)
 
        ret = do_sys_poll(ufds, nfds, to);
 
-       if (ret == -ERESTARTNOHAND) {
-               restart_block->fn = do_restart_poll;
-               ret = -ERESTART_RESTARTBLOCK;
-       }
+       if (ret == -ERESTARTNOHAND)
+               ret = set_restart_fn(restart_block, do_restart_poll);
+
        return ret;
 }
 
@@ -1080,7 +1079,6 @@ SYSCALL_DEFINE3(poll, struct pollfd __user *, ufds, unsigned int, nfds,
                struct restart_block *restart_block;
 
                restart_block = &current->restart_block;
-               restart_block->fn = do_restart_poll;
                restart_block->poll.ufds = ufds;
                restart_block->poll.nfds = nfds;
 
@@ -1091,7 +1089,7 @@ SYSCALL_DEFINE3(poll, struct pollfd __user *, ufds, unsigned int, nfds,
                } else
                        restart_block->poll.has_timeout = 0;
 
-               ret = -ERESTART_RESTARTBLOCK;
+               ret = set_restart_fn(restart_block, do_restart_poll);
        }
        return ret;
 }
index 45f44425d85601f14b09c49c8bdbc36294d9449b..b9e87ebb1060eefc8691f7a8e36374b35954ad6c 100644 (file)
@@ -87,7 +87,7 @@ static int squashfs_bio_read(struct super_block *sb, u64 index, int length,
        int error, i;
        struct bio *bio;
 
-       if (page_count <= BIO_MAX_PAGES)
+       if (page_count <= BIO_MAX_VECS)
                bio = bio_alloc(GFP_NOIO, page_count);
        else
                bio = bio_kmalloc(GFP_NOIO, page_count);
index 46a861d55e487b606b6e3951d69255e782eedee5..f93370bd7b1e387f35fc16b32bf058cc83002e5d 100644 (file)
@@ -1007,9 +1007,10 @@ xfs_create(
        /*
         * Make sure that we have allocated dquot(s) on disk.
         */
-       error = xfs_qm_vop_dqalloc(dp, current_fsuid(), current_fsgid(), prid,
-                                       XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT,
-                                       &udqp, &gdqp, &pdqp);
+       error = xfs_qm_vop_dqalloc(dp, fsuid_into_mnt(mnt_userns),
+                       fsgid_into_mnt(mnt_userns), prid,
+                       XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT,
+                       &udqp, &gdqp, &pdqp);
        if (error)
                return error;
 
@@ -1157,9 +1158,10 @@ xfs_create_tmpfile(
        /*
         * Make sure that we have allocated dquot(s) on disk.
         */
-       error = xfs_qm_vop_dqalloc(dp, current_fsuid(), current_fsgid(), prid,
-                               XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT,
-                               &udqp, &gdqp, &pdqp);
+       error = xfs_qm_vop_dqalloc(dp, fsuid_into_mnt(mnt_userns),
+                       fsgid_into_mnt(mnt_userns), prid,
+                       XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT,
+                       &udqp, &gdqp, &pdqp);
        if (error)
                return error;
 
index ca310a125d1e14d412b0d60790bfff8615e5b856..3498b97fb06d31710fb0f353d59d40c96232b769 100644 (file)
@@ -168,6 +168,12 @@ xfs_bulkstat_one(
        };
        int                     error;
 
+       if (breq->mnt_userns != &init_user_ns) {
+               xfs_warn_ratelimited(breq->mp,
+                       "bulkstat not supported inside of idmapped mounts.");
+               return -EINVAL;
+       }
+
        ASSERT(breq->icount == 1);
 
        bc.buf = kmem_zalloc(sizeof(struct xfs_bulkstat),
index 52370d0a3f4343a25795d571e4a17bd12118bd9c..1c97b155a8ee716cdd06f3e6c7b206d97d7b42d7 100644 (file)
@@ -634,6 +634,47 @@ xfs_check_summary_counts(
        return xfs_initialize_perag_data(mp, mp->m_sb.sb_agcount);
 }
 
+/*
+ * Flush and reclaim dirty inodes in preparation for unmount. Inodes and
+ * internal inode structures can be sitting in the CIL and AIL at this point,
+ * so we need to unpin them, write them back and/or reclaim them before unmount
+ * can proceed.
+ *
+ * An inode cluster that has been freed can have its buffer still pinned in
+ * memory because the transaction is still sitting in a iclog. The stale inodes
+ * on that buffer will be pinned to the buffer until the transaction hits the
+ * disk and the callbacks run. Pushing the AIL will skip the stale inodes and
+ * may never see the pinned buffer, so nothing will push out the iclog and
+ * unpin the buffer.
+ *
+ * Hence we need to force the log to unpin everything first. However, log
+ * forces don't wait for the discards they issue to complete, so we have to
+ * explicitly wait for them to complete here as well.
+ *
+ * Then we can tell the world we are unmounting so that error handling knows
+ * that the filesystem is going away and we should error out anything that we
+ * have been retrying in the background.  This will prevent never-ending
+ * retries in AIL pushing from hanging the unmount.
+ *
+ * Finally, we can push the AIL to clean all the remaining dirty objects, then
+ * reclaim the remaining inodes that are still in memory at this point in time.
+ */
+static void
+xfs_unmount_flush_inodes(
+       struct xfs_mount        *mp)
+{
+       xfs_log_force(mp, XFS_LOG_SYNC);
+       xfs_extent_busy_wait_all(mp);
+       flush_workqueue(xfs_discard_wq);
+
+       mp->m_flags |= XFS_MOUNT_UNMOUNTING;
+
+       xfs_ail_push_all_sync(mp->m_ail);
+       cancel_delayed_work_sync(&mp->m_reclaim_work);
+       xfs_reclaim_inodes(mp);
+       xfs_health_unmount(mp);
+}
+
 /*
  * This function does the following on an initial mount of a file system:
  *     - reads the superblock from disk and init the mount struct
@@ -1008,7 +1049,7 @@ xfs_mountfs(
        /* Clean out dquots that might be in memory after quotacheck. */
        xfs_qm_unmount(mp);
        /*
-        * Cancel all delayed reclaim work and reclaim the inodes directly.
+        * Flush all inode reclamation work and flush the log.
         * We have to do this /after/ rtunmount and qm_unmount because those
         * two will have scheduled delayed reclaim for the rt/quota inodes.
         *
@@ -1018,11 +1059,8 @@ xfs_mountfs(
         * qm_unmount_quotas and therefore rely on qm_unmount to release the
         * quota inodes.
         */
-       cancel_delayed_work_sync(&mp->m_reclaim_work);
-       xfs_reclaim_inodes(mp);
-       xfs_health_unmount(mp);
+       xfs_unmount_flush_inodes(mp);
  out_log_dealloc:
-       mp->m_flags |= XFS_MOUNT_UNMOUNTING;
        xfs_log_mount_cancel(mp);
  out_fail_wait:
        if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp)
@@ -1063,47 +1101,7 @@ xfs_unmountfs(
        xfs_rtunmount_inodes(mp);
        xfs_irele(mp->m_rootip);
 
-       /*
-        * We can potentially deadlock here if we have an inode cluster
-        * that has been freed has its buffer still pinned in memory because
-        * the transaction is still sitting in a iclog. The stale inodes
-        * on that buffer will be pinned to the buffer until the
-        * transaction hits the disk and the callbacks run. Pushing the AIL will
-        * skip the stale inodes and may never see the pinned buffer, so
-        * nothing will push out the iclog and unpin the buffer. Hence we
-        * need to force the log here to ensure all items are flushed into the
-        * AIL before we go any further.
-        */
-       xfs_log_force(mp, XFS_LOG_SYNC);
-
-       /*
-        * Wait for all busy extents to be freed, including completion of
-        * any discard operation.
-        */
-       xfs_extent_busy_wait_all(mp);
-       flush_workqueue(xfs_discard_wq);
-
-       /*
-        * We now need to tell the world we are unmounting. This will allow
-        * us to detect that the filesystem is going away and we should error
-        * out anything that we have been retrying in the background. This will
-        * prevent neverending retries in AIL pushing from hanging the unmount.
-        */
-       mp->m_flags |= XFS_MOUNT_UNMOUNTING;
-
-       /*
-        * Flush all pending changes from the AIL.
-        */
-       xfs_ail_push_all_sync(mp->m_ail);
-
-       /*
-        * Reclaim all inodes. At this point there should be no dirty inodes and
-        * none should be pinned or locked. Stop background inode reclaim here
-        * if it is still running.
-        */
-       cancel_delayed_work_sync(&mp->m_reclaim_work);
-       xfs_reclaim_inodes(mp);
-       xfs_health_unmount(mp);
+       xfs_unmount_flush_inodes(mp);
 
        xfs_qm_unmount(mp);
 
index 1379013d74b8877eb0784a7f8900aaecd4552d3f..7f368b10ded1bf1673167c5fefa7be03be983b22 100644 (file)
@@ -182,7 +182,8 @@ xfs_symlink(
        /*
         * Make sure that we have allocated dquot(s) on disk.
         */
-       error = xfs_qm_vop_dqalloc(dp, current_fsuid(), current_fsgid(), prid,
+       error = xfs_qm_vop_dqalloc(dp, fsuid_into_mnt(mnt_userns),
+                       fsgid_into_mnt(mnt_userns), prid,
                        XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT,
                        &udqp, &gdqp, &pdqp);
        if (error)
index b6ff4a21abacc68d476e91e828a5688e5d3992d1..049e36c69ed70b806035ec3f1ced2e874a49eaaf 100644 (file)
@@ -165,6 +165,21 @@ static int zonefs_writepages(struct address_space *mapping,
        return iomap_writepages(mapping, wbc, &wpc, &zonefs_writeback_ops);
 }
 
+static int zonefs_swap_activate(struct swap_info_struct *sis,
+                               struct file *swap_file, sector_t *span)
+{
+       struct inode *inode = file_inode(swap_file);
+       struct zonefs_inode_info *zi = ZONEFS_I(inode);
+
+       if (zi->i_ztype != ZONEFS_ZTYPE_CNV) {
+               zonefs_err(inode->i_sb,
+                          "swap file: not a conventional zone file\n");
+               return -EINVAL;
+       }
+
+       return iomap_swapfile_activate(sis, swap_file, span, &zonefs_iomap_ops);
+}
+
 static const struct address_space_operations zonefs_file_aops = {
        .readpage               = zonefs_readpage,
        .readahead              = zonefs_readahead,
@@ -177,6 +192,7 @@ static const struct address_space_operations zonefs_file_aops = {
        .is_partially_uptodate  = iomap_is_partially_uptodate,
        .error_remove_page      = generic_error_remove_page,
        .direct_IO              = noop_direct_IO,
+       .swap_activate          = zonefs_swap_activate,
 };
 
 static void zonefs_update_stats(struct inode *inode, loff_t new_isize)
@@ -684,7 +700,7 @@ static ssize_t zonefs_file_dio_append(struct kiocb *iocb, struct iov_iter *from)
        max = ALIGN_DOWN(max << SECTOR_SHIFT, inode->i_sb->s_blocksize);
        iov_iter_truncate(from, max);
 
-       nr_pages = iov_iter_npages(from, BIO_MAX_PAGES);
+       nr_pages = iov_iter_npages(from, BIO_MAX_VECS);
        if (!nr_pages)
                return 0;
 
@@ -727,6 +743,68 @@ out_release:
        return ret;
 }
 
+/*
+ * Do not exceed the LFS limits nor the file zone size. If pos is under the
+ * limit it becomes a short access. If it exceeds the limit, return -EFBIG.
+ */
+static loff_t zonefs_write_check_limits(struct file *file, loff_t pos,
+                                       loff_t count)
+{
+       struct inode *inode = file_inode(file);
+       struct zonefs_inode_info *zi = ZONEFS_I(inode);
+       loff_t limit = rlimit(RLIMIT_FSIZE);
+       loff_t max_size = zi->i_max_size;
+
+       if (limit != RLIM_INFINITY) {
+               if (pos >= limit) {
+                       send_sig(SIGXFSZ, current, 0);
+                       return -EFBIG;
+               }
+               count = min(count, limit - pos);
+       }
+
+       if (!(file->f_flags & O_LARGEFILE))
+               max_size = min_t(loff_t, MAX_NON_LFS, max_size);
+
+       if (unlikely(pos >= max_size))
+               return -EFBIG;
+
+       return min(count, max_size - pos);
+}
+
+static ssize_t zonefs_write_checks(struct kiocb *iocb, struct iov_iter *from)
+{
+       struct file *file = iocb->ki_filp;
+       struct inode *inode = file_inode(file);
+       struct zonefs_inode_info *zi = ZONEFS_I(inode);
+       loff_t count;
+
+       if (IS_SWAPFILE(inode))
+               return -ETXTBSY;
+
+       if (!iov_iter_count(from))
+               return 0;
+
+       if ((iocb->ki_flags & IOCB_NOWAIT) && !(iocb->ki_flags & IOCB_DIRECT))
+               return -EINVAL;
+
+       if (iocb->ki_flags & IOCB_APPEND) {
+               if (zi->i_ztype != ZONEFS_ZTYPE_SEQ)
+                       return -EINVAL;
+               mutex_lock(&zi->i_truncate_mutex);
+               iocb->ki_pos = zi->i_wpoffset;
+               mutex_unlock(&zi->i_truncate_mutex);
+       }
+
+       count = zonefs_write_check_limits(file, iocb->ki_pos,
+                                         iov_iter_count(from));
+       if (count < 0)
+               return count;
+
+       iov_iter_truncate(from, count);
+       return iov_iter_count(from);
+}
+
 /*
  * Handle direct writes. For sequential zone files, this is the only possible
  * write path. For these files, check that the user is issuing writes
@@ -744,8 +822,7 @@ static ssize_t zonefs_file_dio_write(struct kiocb *iocb, struct iov_iter *from)
        struct super_block *sb = inode->i_sb;
        bool sync = is_sync_kiocb(iocb);
        bool append = false;
-       size_t count;
-       ssize_t ret;
+       ssize_t ret, count;
 
        /*
         * For async direct IOs to sequential zone files, refuse IOCB_NOWAIT
@@ -763,12 +840,11 @@ static ssize_t zonefs_file_dio_write(struct kiocb *iocb, struct iov_iter *from)
                inode_lock(inode);
        }
 
-       ret = generic_write_checks(iocb, from);
-       if (ret <= 0)
+       count = zonefs_write_checks(iocb, from);
+       if (count <= 0) {
+               ret = count;
                goto inode_unlock;
-
-       iov_iter_truncate(from, zi->i_max_size - iocb->ki_pos);
-       count = iov_iter_count(from);
+       }
 
        if ((iocb->ki_pos | count) & (sb->s_blocksize - 1)) {
                ret = -EINVAL;
@@ -828,12 +904,10 @@ static ssize_t zonefs_file_buffered_write(struct kiocb *iocb,
                inode_lock(inode);
        }
 
-       ret = generic_write_checks(iocb, from);
+       ret = zonefs_write_checks(iocb, from);
        if (ret <= 0)
                goto inode_unlock;
 
-       iov_iter_truncate(from, zi->i_max_size - iocb->ki_pos);
-
        ret = iomap_file_buffered_write(iocb, from, &zonefs_iomap_ops);
        if (ret > 0)
                iocb->ki_pos += ret;
@@ -966,9 +1040,7 @@ static int zonefs_open_zone(struct inode *inode)
 
        mutex_lock(&zi->i_truncate_mutex);
 
-       zi->i_wr_refcnt++;
-       if (zi->i_wr_refcnt == 1) {
-
+       if (!zi->i_wr_refcnt) {
                if (atomic_inc_return(&sbi->s_open_zones) > sbi->s_max_open_zones) {
                        atomic_dec(&sbi->s_open_zones);
                        ret = -EBUSY;
@@ -978,7 +1050,6 @@ static int zonefs_open_zone(struct inode *inode)
                if (i_size_read(inode) < zi->i_max_size) {
                        ret = zonefs_zone_mgmt(inode, REQ_OP_ZONE_OPEN);
                        if (ret) {
-                               zi->i_wr_refcnt--;
                                atomic_dec(&sbi->s_open_zones);
                                goto unlock;
                        }
@@ -986,6 +1057,8 @@ static int zonefs_open_zone(struct inode *inode)
                }
        }
 
+       zi->i_wr_refcnt++;
+
 unlock:
        mutex_unlock(&zi->i_truncate_mutex);
 
index e17be324d95f5d47aa00af1242192febdbc63dff..b8ca13664fa20e6cfb57576a1689cd866691bd4d 100644 (file)
@@ -612,9 +612,11 @@ static inline void ttm_bo_pin(struct ttm_buffer_object *bo)
 static inline void ttm_bo_unpin(struct ttm_buffer_object *bo)
 {
        dma_resv_assert_held(bo->base.resv);
-       WARN_ON_ONCE(!bo->pin_count);
        WARN_ON_ONCE(!kref_read(&bo->kref));
-       --bo->pin_count;
+       if (bo->pin_count)
+               --bo->pin_count;
+       else
+               WARN_ON_ONCE(true);
 }
 
 int ttm_mem_evict_first(struct ttm_bo_device *bdev,
index 8dcb3e1477bc98faa7d62171ba5ec8166a41bc69..6fd3cda608e4a6a065b222ada62aba30eeff9a1c 100644 (file)
 #define ARMV8_PMU_CYCLE_IDX            (ARMV8_PMU_MAX_COUNTERS - 1)
 #define ARMV8_PMU_MAX_COUNTER_PAIRS    ((ARMV8_PMU_MAX_COUNTERS + 1) >> 1)
 
+DECLARE_STATIC_KEY_FALSE(kvm_arm_pmu_available);
+
+static __always_inline bool kvm_arm_support_pmu_v3(void)
+{
+       return static_branch_likely(&kvm_arm_pmu_available);
+}
+
 #ifdef CONFIG_HW_PERF_EVENTS
 
 struct kvm_pmc {
@@ -47,7 +54,6 @@ void kvm_pmu_software_increment(struct kvm_vcpu *vcpu, u64 val);
 void kvm_pmu_handle_pmcr(struct kvm_vcpu *vcpu, u64 val);
 void kvm_pmu_set_counter_event_type(struct kvm_vcpu *vcpu, u64 data,
                                    u64 select_idx);
-bool kvm_arm_support_pmu_v3(void);
 int kvm_arm_pmu_v3_set_attr(struct kvm_vcpu *vcpu,
                            struct kvm_device_attr *attr);
 int kvm_arm_pmu_v3_get_attr(struct kvm_vcpu *vcpu,
@@ -87,7 +93,6 @@ static inline void kvm_pmu_software_increment(struct kvm_vcpu *vcpu, u64 val) {}
 static inline void kvm_pmu_handle_pmcr(struct kvm_vcpu *vcpu, u64 val) {}
 static inline void kvm_pmu_set_counter_event_type(struct kvm_vcpu *vcpu,
                                                  u64 data, u64 select_idx) {}
-static inline bool kvm_arm_support_pmu_v3(void) { return false; }
 static inline int kvm_arm_pmu_v3_set_attr(struct kvm_vcpu *vcpu,
                                          struct kvm_device_attr *attr)
 {
index 9f432411e9883296c880f345323a344e26ea654d..fcdaab72391672f077de07d3ad49d1f3dc7d6eeb 100644 (file)
@@ -1079,19 +1079,25 @@ void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const c
 #if defined(CONFIG_ACPI) && defined(CONFIG_GPIOLIB)
 bool acpi_gpio_get_irq_resource(struct acpi_resource *ares,
                                struct acpi_resource_gpio **agpio);
-int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index);
+int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, int index);
 #else
 static inline bool acpi_gpio_get_irq_resource(struct acpi_resource *ares,
                                              struct acpi_resource_gpio **agpio)
 {
        return false;
 }
-static inline int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
+static inline int acpi_dev_gpio_irq_get_by(struct acpi_device *adev,
+                                          const char *name, int index)
 {
        return -ENXIO;
 }
 #endif
 
+static inline int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
+{
+       return acpi_dev_gpio_irq_get_by(adev, NULL, index);
+}
+
 /* Device properties */
 
 #ifdef CONFIG_ACPI
index 6cc93ab5b8096d1def9ebd9256e45c08fa86d161..c68d87b8728362ad6bc3114381dea574cd8a39eb 100644 (file)
@@ -105,8 +105,19 @@ extern struct bus_type amba_bustype;
 #define amba_get_drvdata(d)    dev_get_drvdata(&d->dev)
 #define amba_set_drvdata(d,p)  dev_set_drvdata(&d->dev, p)
 
+#ifdef CONFIG_ARM_AMBA
 int amba_driver_register(struct amba_driver *);
 void amba_driver_unregister(struct amba_driver *);
+#else
+static inline int amba_driver_register(struct amba_driver *drv)
+{
+       return -EINVAL;
+}
+static inline void amba_driver_unregister(struct amba_driver *drv)
+{
+}
+#endif
+
 struct amba_device *amba_device_alloc(const char *, resource_size_t, size_t);
 void amba_device_put(struct amba_device *);
 int amba_device_add(struct amba_device *, struct resource *);
index 60cd25c0461b873c959c49523b5563e2685d3205..9b02961d65ee6666bea094095d5efe9e35ba735f 100644 (file)
@@ -151,7 +151,7 @@ struct atm_dev {
        const char      *type;          /* device type name */
        int             number;         /* device index */
        void            *dev_data;      /* per-device data */
-       void            *phy_data;      /* private PHY date */
+       void            *phy_data;      /* private PHY data */
        unsigned long   flags;          /* device flags (ATM_DF_*) */
        struct list_head local;         /* local ATM addresses */
        struct list_head lecs;          /* LECS ATM addresses learned via ILMI */
index 983ed2fe7c850479040d42a569191a75206e2fb3..d0246c92a6e865efa9d7afab751aa3f74f3be540 100644 (file)
 #define BIO_BUG_ON
 #endif
 
-#define BIO_MAX_PAGES          256U
+#define BIO_MAX_VECS           256U
 
 static inline unsigned int bio_max_segs(unsigned int nr_segs)
 {
-       return min(nr_segs, BIO_MAX_PAGES);
+       return min(nr_segs, BIO_MAX_VECS);
 }
 
 #define bio_prio(bio)                  (bio)->bi_ioprio
index 685f34cfba20741d372d340fe7df1084767b2850..d438eb058069b1c420473cb2cedee5d0b78eed4a 100644 (file)
@@ -65,8 +65,12 @@ static inline void can_skb_reserve(struct sk_buff *skb)
 
 static inline void can_skb_set_owner(struct sk_buff *skb, struct sock *sk)
 {
-       if (sk) {
-               sock_hold(sk);
+       /* If the socket has already been closed by user space, the
+        * refcount may already be 0 (and the socket will be freed
+        * after the last TX skb has been freed). So only increase
+        * socket refcount if the refcount is > 0.
+        */
+       if (sk && refcount_inc_not_zero(&sk->sk_refcnt)) {
                skb->destructor = sock_efree;
                skb->sk = sk;
        }
index 04c0a5a717f7eb638dd3413d26cd244aadba1116..d217c382b02deff6cace8b80cc938d65cfed6d0d 100644 (file)
 #define __no_sanitize_thread
 #endif
 
+#if defined(CONFIG_ARCH_USE_BUILTIN_BSWAP)
+#define __HAVE_BUILTIN_BSWAP32__
+#define __HAVE_BUILTIN_BSWAP64__
+#define __HAVE_BUILTIN_BSWAP16__
+#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */
+
 #if __has_feature(undefined_behavior_sanitizer)
 /* GCC does not have __SANITIZE_UNDEFINED__ */
 #define __no_sanitize_undefined \
diff --git a/include/linux/compiler-version.h b/include/linux/compiler-version.h
new file mode 100644 (file)
index 0000000..2b2972c
--- /dev/null
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifdef  __LINUX_COMPILER_VERSION_H
+#error "Please do not include <linux/compiler-version.h>. This is done by the build system."
+#endif
+#define __LINUX_COMPILER_VERSION_H
+
+/*
+ * This header exists to force full rebuild when the compiler is upgraded.
+ *
+ * When fixdep scans this, it will find this string "CONFIG_CC_VERSION_TEXT"
+ * and add dependency on include/config/cc/version/text.h, which is touched
+ * by Kconfig when the version string from the compiler changes.
+ */
index 3aaa0687e8df6403a4b1faa68a5514bc7d31bd3b..94a578a96202222b5807e812a62d3dd156b7fc26 100644 (file)
@@ -108,6 +108,8 @@ static inline void cpu_maps_update_done(void)
 {
 }
 
+static inline int add_cpu(unsigned int cpu) { return 0;}
+
 #endif /* CONFIG_SMP */
 extern struct bus_type cpu_subsys;
 
@@ -137,6 +139,7 @@ static inline int  cpus_read_trylock(void) { return true; }
 static inline void lockdep_assert_cpus_held(void) { }
 static inline void cpu_hotplug_disable(void) { }
 static inline void cpu_hotplug_enable(void) { }
+static inline int remove_cpu(unsigned int cpu) { return -EPERM; }
 static inline void smp_shutdown_nonboot_cpus(unsigned int primary_cpu) { }
 #endif /* !CONFIG_HOTPLUG_CPU */
 
index 8710f5710c1d1a5d2973455fc1c97da4eaba5e41..6b5d36babfcc44c445dd847f84c1ae0b752cac81 100644 (file)
@@ -72,8 +72,10 @@ typedef void *efi_handle_t;
  */
 typedef guid_t efi_guid_t __aligned(__alignof__(u32));
 
-#define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \
-       GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)
+#define EFI_GUID(a, b, c, d...) (efi_guid_t){ {                                        \
+       (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff,  \
+       (b) & 0xff, ((b) >> 8) & 0xff,                                          \
+       (c) & 0xff, ((c) >> 8) & 0xff, d } }
 
 /*
  * Generic EFI table header
index ef49307611d219881c8ce9da694807a3a2b4d227..c73b25bc92134bee2fb9b19822ef42ac293ae4cd 100644 (file)
@@ -674,6 +674,8 @@ struct acpi_gpio_mapping {
  * get GpioIo type explicitly, this quirk may be used.
  */
 #define ACPI_GPIO_QUIRK_ONLY_GPIOIO            BIT(1)
+/* Use given pin as an absolute GPIO number in the system */
+#define ACPI_GPIO_QUIRK_ABSOLUTE_NUMBER                BIT(2)
 
        unsigned int quirks;
 };
index 7cb7bd0e334c33c690726fc28e24112216c230af..79cde9906be0486c702dc09a464c193ddf22f6b8 100644 (file)
@@ -5,31 +5,6 @@
 #include <linux/sched.h>
 #include <linux/xarray.h>
 
-struct io_wq_work_node {
-       struct io_wq_work_node *next;
-};
-
-struct io_wq_work_list {
-       struct io_wq_work_node *first;
-       struct io_wq_work_node *last;
-};
-
-struct io_uring_task {
-       /* submission side */
-       struct xarray           xa;
-       struct wait_queue_head  wait;
-       struct file             *last;
-       void                    *io_wq;
-       struct percpu_counter   inflight;
-       atomic_t                in_idle;
-       bool                    sqpoll;
-
-       spinlock_t              task_lock;
-       struct io_wq_work_list  task_list;
-       unsigned long           task_state;
-       struct callback_head    task_work;
-};
-
 #if defined(CONFIG_IO_URING)
 struct sock *io_uring_get_socket(struct file *file);
 void __io_uring_task_cancel(void);
index 42d196805f587e8adafe294ec93612e9f3c09cf9..33cacc8af26dab4f582d986054c4164d02d73d6c 100644 (file)
@@ -150,7 +150,6 @@ struct irq_domain_chip_generic;
  *      setting up one or more generic chips for interrupt controllers
  *      drivers using the generic chip library which uses this pointer.
  * @parent: Pointer to parent irq_domain to support hierarchy irq_domains
- * @debugfs_file: dentry for the domain debugfs file
  *
  * Revmap data, used internally by irq_domain
  * @revmap_direct_max_irq: The largest hwirq that can be set for controllers that
@@ -174,9 +173,6 @@ struct irq_domain {
 #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
        struct irq_domain *parent;
 #endif
-#ifdef CONFIG_GENERIC_IRQ_DEBUGFS
-       struct dentry           *debugfs_file;
-#endif
 
        /* reverse map data. The linear map gets appended to the irq_domain */
        irq_hw_number_t hwirq_max;
index e78e17a76dc95e14d3a5d90cc025a82bd83e1a9b..24a59cb0696359c45c46489fd7d791ea1c37b7e5 100644 (file)
@@ -2,8 +2,6 @@
 #ifndef __LINUX_KCONFIG_H
 #define __LINUX_KCONFIG_H
 
-/* CONFIG_CC_VERSION_TEXT (Do not delete this comment. See help in Kconfig) */
-
 #include <generated/autoconf.h>
 
 #ifdef CONFIG_CPU_BIG_ENDIAN
index c88bc24e31aa5214c08d8c3d0e5c427c5531d4e4..d13e3cd938b4660583dba1edd3e07c2fa5c44c2b 100644 (file)
@@ -460,7 +460,7 @@ static inline void memblock_free_late(phys_addr_t base, phys_addr_t size)
 /*
  * Set the allocation direction to bottom-up or top-down.
  */
-static inline void memblock_set_bottom_up(bool enable)
+static inline __init void memblock_set_bottom_up(bool enable)
 {
        memblock.bottom_up = enable;
 }
@@ -470,7 +470,7 @@ static inline void memblock_set_bottom_up(bool enable)
  * if this is true, that said, memblock will allocate memory
  * in bottom-up direction.
  */
-static inline bool memblock_bottom_up(void)
+static inline __init bool memblock_bottom_up(void)
 {
        return memblock.bottom_up;
 }
index e6dc793d587dea9798026a12423d506c3a97a7b7..0c04d39a7967659ff74babf8e57743fdead8712e 100644 (file)
@@ -1061,9 +1061,7 @@ static inline void memcg_memory_event_mm(struct mm_struct *mm,
        rcu_read_unlock();
 }
 
-#ifdef CONFIG_TRANSPARENT_HUGEPAGE
-void mem_cgroup_split_huge_fixup(struct page *head);
-#endif
+void split_page_memcg(struct page *head, unsigned int nr);
 
 #else /* CONFIG_MEMCG */
 
@@ -1400,7 +1398,7 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order,
        return 0;
 }
 
-static inline void mem_cgroup_split_huge_fixup(struct page *head)
+static inline void split_page_memcg(struct page *head, unsigned int nr)
 {
 }
 
index 77e64e3eac80bd756021c8d8a158b4faae694dcf..64a71bf2053674c32322555b5ad32821acdbc6ca 100644 (file)
@@ -1300,6 +1300,27 @@ static inline bool page_maybe_dma_pinned(struct page *page)
                GUP_PIN_COUNTING_BIAS;
 }
 
+static inline bool is_cow_mapping(vm_flags_t flags)
+{
+       return (flags & (VM_SHARED | VM_MAYWRITE)) == VM_MAYWRITE;
+}
+
+/*
+ * This should most likely only be called during fork() to see whether we
+ * should break the cow immediately for a page on the src mm.
+ */
+static inline bool page_needs_cow_for_dma(struct vm_area_struct *vma,
+                                         struct page *page)
+{
+       if (!is_cow_mapping(vma->vm_flags))
+               return false;
+
+       if (!atomic_read(&vma->vm_mm->has_pinned))
+               return false;
+
+       return page_maybe_dma_pinned(page);
+}
+
 #if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP)
 #define SECTION_IN_PAGE_FLAGS
 #endif
index 0974ad501a47ce5d5a8c6913287a1c31c4e44222..6613b26a88946c41afb469b894d3b66fc4712010 100644 (file)
@@ -23,6 +23,7 @@
 #endif
 #define AT_VECTOR_SIZE (2*(AT_VECTOR_SIZE_ARCH + AT_VECTOR_SIZE_BASE + 1))
 
+#define INIT_PASID     0
 
 struct address_space;
 struct mem_cgroup;
index 59f094fa6f744126617db8b4974b27b0faa95eaa..da4b6fbe8ebe9c055d6614dcc20d2ff7cbbf3d60 100644 (file)
@@ -30,9 +30,6 @@
 #include <linux/percpu.h>
 #include <asm/module.h>
 
-/* Not Yet Implemented */
-#define MODULE_SUPPORTED_DEVICE(name)
-
 #define MODULE_NAME_LEN MAX_PARAM_PREFIX_LEN
 
 struct modversion_info {
index f06fbee8638e84d42a4b8cb98bd2f2dcc33a0374..5b67ea89d5f26d72257ba03a1d669999cb570f92 100644 (file)
@@ -3959,8 +3959,6 @@ int dev_change_xdp_fd(struct net_device *dev, struct netlink_ext_ack *extack,
 int bpf_xdp_link_attach(const union bpf_attr *attr, struct bpf_prog *prog);
 u32 dev_xdp_prog_id(struct net_device *dev, enum bpf_xdp_mode mode);
 
-int xdp_umem_query(struct net_device *dev, u16 queue_id);
-
 int __dev_forward_skb(struct net_device *dev, struct sk_buff *skb);
 int dev_forward_skb(struct net_device *dev, struct sk_buff *skb);
 int dev_forward_skb_nomtu(struct net_device *dev, struct sk_buff *skb);
index fab42cfbd350251d4cdd63a41f00a0619995dfe5..3f7f89ea5e512b1240b8ebeb81b6b7cb8bb7944e 100644 (file)
@@ -606,6 +606,7 @@ struct swevent_hlist {
 #define PERF_ATTACH_TASK       0x04
 #define PERF_ATTACH_TASK_DATA  0x08
 #define PERF_ATTACH_ITRACE     0x10
+#define PERF_ATTACH_SCHED_CB   0x20
 
 struct perf_cgroup;
 struct perf_buffer;
@@ -872,6 +873,7 @@ struct perf_cpu_context {
        struct list_head                cgrp_cpuctx_entry;
 #endif
 
+       struct list_head                sched_cb_entry;
        int                             sched_cb_usage;
 
        int                             online;
index cdfc4e9f253e4e7004b08b5f275387dedb408d7d..5e772392a379560d2cc7dffc02227fcc0c604559 100644 (file)
@@ -904,6 +904,10 @@ static inline void ptep_modify_prot_commit(struct vm_area_struct *vma,
 #define pgprot_device pgprot_noncached
 #endif
 
+#ifndef pgprot_mhp
+#define pgprot_mhp(prot)       (prot)
+#endif
+
 #ifdef CONFIG_MMU
 #ifndef pgprot_modify
 #define pgprot_modify pgprot_modify
index dafccfce02624d6d8a47bf45410064d07bb8e015..dd4687b562393120ebd029ecc2fb977c9535f0c3 100644 (file)
@@ -488,7 +488,7 @@ fwnode_create_software_node(const struct property_entry *properties,
                            const struct fwnode_handle *parent);
 void fwnode_remove_software_node(struct fwnode_handle *fwnode);
 
-int device_add_software_node(struct device *dev, const struct software_node *swnode);
+int device_add_software_node(struct device *dev, const struct software_node *node);
 void device_remove_software_node(struct device *dev);
 
 int device_create_managed_software_node(struct device *dev,
index ccdb5320a2406a400a3c111c4a3cd5557c6b5fce..71902f41c91999d21cc037e9c9d1731a71844f0f 100644 (file)
@@ -147,6 +147,9 @@ enum {
 #define BUCK6_FPWM                     0x04
 #define BUCK6_ENMODE_MASK              0x03
 
+/* PCA9450_REG_BUCK123_PRESET_EN bit */
+#define BUCK123_PRESET_EN              0x80
+
 /* PCA9450_BUCK1OUT_DVS0 bits */
 #define BUCK1OUT_DVS0_MASK             0x7F
 #define BUCK1OUT_DVS0_DEFAULT          0x14
index bba2920e9c0539dd48c7c5da46a54d17db543754..980a65594412d95b56ed871b26fc5bbd06e11a69 100644 (file)
@@ -23,6 +23,7 @@ enum timespec_type {
  * System call restart block.
  */
 struct restart_block {
+       unsigned long arch_data;
        long (*fn)(struct restart_block *);
        union {
                /* For futex_wait and futex_wait_requeue_pi */
index 1ae08b8462a41762fd48e299f304e0ba5152f7c0..90b2a0bce11cab5737990cbcfc9bc52f5376fcde 100644 (file)
@@ -140,7 +140,8 @@ static inline bool in_vfork(struct task_struct *tsk)
         * another oom-unkillable task does this it should blame itself.
         */
        rcu_read_lock();
-       ret = tsk->vfork_done && tsk->real_parent->mm == tsk->mm;
+       ret = tsk->vfork_done &&
+                       rcu_dereference(tsk->real_parent)->mm == tsk->mm;
        rcu_read_unlock();
 
        return ret;
index 2f7bb92b4c9eefcab01054659e9d1c3fd5b86cef..f61e34fbaaea4f9f9af9195335eae17608e56b52 100644 (file)
@@ -664,10 +664,7 @@ typedef struct {
  * seqcount_latch_init() - runtime initializer for seqcount_latch_t
  * @s: Pointer to the seqcount_latch_t instance
  */
-static inline void seqcount_latch_init(seqcount_latch_t *s)
-{
-       seqcount_init(&s->seqcount);
-}
+#define seqcount_latch_init(s) seqcount_init(&(s)->seqcount)
 
 /**
  * raw_read_seqcount_latch() - pick even/odd latch data copy
index 30577c3aecf81109bff66e15a043c181b5cda613..46fb3ebdd16e44c61de04ec7349fb193bcb525f0 100644 (file)
@@ -128,7 +128,7 @@ int stop_machine_from_inactive_cpu(cpu_stop_fn_t fn, void *data,
                                   const struct cpumask *cpus);
 #else  /* CONFIG_SMP || CONFIG_HOTPLUG_CPU */
 
-static inline int stop_machine_cpuslocked(cpu_stop_fn_t fn, void *data,
+static __always_inline int stop_machine_cpuslocked(cpu_stop_fn_t fn, void *data,
                                          const struct cpumask *cpus)
 {
        unsigned long flags;
@@ -139,14 +139,15 @@ static inline int stop_machine_cpuslocked(cpu_stop_fn_t fn, void *data,
        return ret;
 }
 
-static inline int stop_machine(cpu_stop_fn_t fn, void *data,
-                              const struct cpumask *cpus)
+static __always_inline int
+stop_machine(cpu_stop_fn_t fn, void *data, const struct cpumask *cpus)
 {
        return stop_machine_cpuslocked(fn, data, cpus);
 }
 
-static inline int stop_machine_from_inactive_cpu(cpu_stop_fn_t fn, void *data,
-                                                const struct cpumask *cpus)
+static __always_inline int
+stop_machine_from_inactive_cpu(cpu_stop_fn_t fn, void *data,
+                              const struct cpumask *cpus)
 {
        return stop_machine(fn, data, cpus);
 }
index 7c693b31965e245aaf84a1beee58fcc1cdc3b5cb..1e76ed68804475283ca87ea7a86ac6f4e7610745 100644 (file)
@@ -104,7 +104,6 @@ struct svcxprt_rdma {
 
        wait_queue_head_t    sc_send_wait;      /* SQ exhaustion waitlist */
        unsigned long        sc_flags;
-       u32                  sc_pending_recvs;
        struct list_head     sc_read_complete_q;
        struct work_struct   sc_work;
 
index 13770cfe33ad8f7a5d084c1774ac170f6c7a8229..6673e4d4ac2e1b1348f6e94ad070f63921cc4cff 100644 (file)
@@ -23,7 +23,7 @@ struct ts_config;
 struct ts_state
 {
        unsigned int            offset;
-       char                    cb[40];
+       char                    cb[48];
 };
 
 /**
index 9b2158c69275e1069430beae14f2b4dfdb590825..157762db9d4bf011f3ba9fa8319911f325e192d0 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/types.h>
 #include <linux/bug.h>
 #include <linux/restart_block.h>
+#include <linux/errno.h>
 
 #ifdef CONFIG_THREAD_INFO_IN_TASK
 /*
@@ -59,6 +60,18 @@ enum syscall_work_bit {
 
 #ifdef __KERNEL__
 
+#ifndef arch_set_restart_data
+#define arch_set_restart_data(restart) do { } while (0)
+#endif
+
+static inline long set_restart_fn(struct restart_block *restart,
+                                       long (*fn)(struct restart_block *))
+{
+       restart->fn = fn;
+       arch_set_restart_data(restart);
+       return -ERESTART_RESTARTBLOCK;
+}
+
 #ifndef THREAD_ALIGN
 #define THREAD_ALIGN   THREAD_SIZE
 #endif
index c6abb79501b33c7afbd00196dd3a5f644ae4da83..e81856c0ba134fd07401f3e0e562828f0c8f1333 100644 (file)
@@ -115,12 +115,13 @@ static inline void u64_stats_inc(u64_stats_t *p)
 }
 #endif
 
+#if BITS_PER_LONG == 32 && defined(CONFIG_SMP)
+#define u64_stats_init(syncp)  seqcount_init(&(syncp)->seq)
+#else
 static inline void u64_stats_init(struct u64_stats_sync *syncp)
 {
-#if BITS_PER_LONG == 32 && defined(CONFIG_SMP)
-       seqcount_init(&syncp->seq);
-#endif
 }
+#endif
 
 static inline void u64_stats_update_begin(struct u64_stats_sync *syncp)
 {
index 7d72c4e0713c1068d11a01256de7a37bc44b809b..d6a41841b93e4f92647e938d0bff02712b795f12 100644 (file)
@@ -746,6 +746,8 @@ extern int usb_lock_device_for_reset(struct usb_device *udev,
 extern int usb_reset_device(struct usb_device *dev);
 extern void usb_queue_reset_device(struct usb_interface *dev);
 
+extern struct device *usb_intf_get_dma_device(struct usb_interface *intf);
+
 #ifdef CONFIG_ACPI
 extern int usb_acpi_set_power_state(struct usb_device *hdev, int index,
        bool enable);
index 6b03fdd69d2745967921b6ae2444cfea057e81f2..712363c7a2e8ec6cac6025c35d6bbe1e8f60568a 100644 (file)
@@ -86,6 +86,8 @@
                /* lies about caching, so always sync */        \
        US_FLAG(NO_SAME, 0x40000000)                            \
                /* Cannot handle WRITE_SAME */                  \
+       US_FLAG(SENSE_AFTER_SYNC, 0x80000000)                   \
+               /* Do REQUEST_SENSE after SYNCHRONIZE_CACHE */  \
 
 #define US_FLAG(name, value)   US_FL_##name = value ,
 enum { US_DO_ALL_FLAGS };
index 4ab5494503a830db9aa22ea64440bd4e92d48f2f..15fa085fab05732dcb678fcb8c298283a047b598 100644 (file)
@@ -250,20 +250,20 @@ struct vdpa_config_ops {
 
 struct vdpa_device *__vdpa_alloc_device(struct device *parent,
                                        const struct vdpa_config_ops *config,
-                                       int nvqs, size_t size, const char *name);
+                                       size_t size, const char *name);
 
-#define vdpa_alloc_device(dev_struct, member, parent, config, nvqs, name)   \
+#define vdpa_alloc_device(dev_struct, member, parent, config, name)   \
                          container_of(__vdpa_alloc_device( \
-                                      parent, config, nvqs, \
+                                      parent, config, \
                                       sizeof(dev_struct) + \
                                       BUILD_BUG_ON_ZERO(offsetof( \
                                       dev_struct, member)), name), \
                                       dev_struct, member)
 
-int vdpa_register_device(struct vdpa_device *vdev);
+int vdpa_register_device(struct vdpa_device *vdev, int nvqs);
 void vdpa_unregister_device(struct vdpa_device *vdev);
 
-int _vdpa_register_device(struct vdpa_device *vdev);
+int _vdpa_register_device(struct vdpa_device *vdev, int nvqs);
 void _vdpa_unregister_device(struct vdpa_device *vdev);
 
 /**
index 55ea329fe72a42c234a3078e779ebda8d729fd1f..b1894e0323fae45163eb2b10091d96fbc9f78401 100644 (file)
@@ -132,8 +132,6 @@ bool is_virtio_device(struct device *dev);
 void virtio_break_device(struct virtio_device *dev);
 
 void virtio_config_changed(struct virtio_device *dev);
-void virtio_config_disable(struct virtio_device *dev);
-void virtio_config_enable(struct virtio_device *dev);
 int virtio_finalize_features(struct virtio_device *dev);
 #ifdef CONFIG_PM_SLEEP
 int virtio_device_freeze(struct virtio_device *dev);
index e8a924eeea3d01c86c40766445c5661c395bce6c..6b5fcfa1e5553576b0e853ae31a2df655c04204b 100644 (file)
@@ -79,8 +79,13 @@ static inline int virtio_net_hdr_to_skb(struct sk_buff *skb,
                if (gso_type && skb->network_header) {
                        struct flow_keys_basic keys;
 
-                       if (!skb->protocol)
+                       if (!skb->protocol) {
+                               __be16 protocol = dev_parse_header_protocol(skb);
+
                                virtio_net_hdr_set_proto(skb, hdr);
+                               if (protocol && protocol != skb->protocol)
+                                       return -EINVAL;
+                       }
 retry:
                        if (!skb_flow_dissect_flow_keys_basic(NULL, skb, &keys,
                                                              NULL, 0, 0, 0,
index 850424e5d03061ea22c33b215ef3192119d652dc..6ecf2a0220dbe6c21ec8a3176c39b48823b0aaa7 100644 (file)
@@ -173,9 +173,10 @@ static inline void ww_acquire_done(struct ww_acquire_ctx *ctx)
  */
 static inline void ww_acquire_fini(struct ww_acquire_ctx *ctx)
 {
-#ifdef CONFIG_DEBUG_MUTEXES
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
        mutex_release(&ctx->dep_map, _THIS_IP_);
-
+#endif
+#ifdef CONFIG_DEBUG_MUTEXES
        DEBUG_LOCKS_WARN_ON(ctx->acquired);
        if (!IS_ENABLED(CONFIG_PROVE_LOCKING))
                /*
index 999b750bc6b88163a85e64f323ebfe6c0e33d9f1..30f138ebab6f0fdbc067708c9a12274ee846da79 100644 (file)
@@ -175,6 +175,13 @@ struct rc_map_list {
        struct rc_map map;
 };
 
+#ifdef CONFIG_MEDIA_CEC_RC
+/*
+ * rc_map_list from rc-cec.c
+ */
+extern struct rc_map_list cec_map;
+#endif
+
 /* Routines from rc-map.c */
 
 /**
index 970cc2ea285002ea2473449321343a63f8cd513d..6154a2e72bce6dbf59962b669ac381c6a29c9324 100644 (file)
@@ -30,7 +30,7 @@ TRACE_EVENT(workqueue_queue_work,
        TP_STRUCT__entry(
                __field( void *,        work    )
                __field( void *,        function)
-               __field( const char *,  workqueue)
+               __string( workqueue,    pwq->wq->name)
                __field( unsigned int,  req_cpu )
                __field( unsigned int,  cpu     )
        ),
@@ -38,13 +38,13 @@ TRACE_EVENT(workqueue_queue_work,
        TP_fast_assign(
                __entry->work           = work;
                __entry->function       = work->func;
-               __entry->workqueue      = pwq->wq->name;
+               __assign_str(workqueue, pwq->wq->name);
                __entry->req_cpu        = req_cpu;
                __entry->cpu            = pwq->pool->cpu;
        ),
 
        TP_printk("work struct=%p function=%ps workqueue=%s req_cpu=%u cpu=%u",
-                 __entry->work, __entry->function, __entry->workqueue,
+                 __entry->work, __entry->function, __get_str(workqueue),
                  __entry->req_cpu, __entry->cpu)
 );
 
index 4c24daa43bacc601cd3fc5ca8eeda3614bb45344..79c893310492b33689352b9dff5f53a42dd9d72b 100644 (file)
@@ -3850,7 +3850,6 @@ union bpf_attr {
  *
  * long bpf_check_mtu(void *ctx, u32 ifindex, u32 *mtu_len, s32 len_diff, u64 flags)
  *     Description
-
  *             Check ctx packet size against exceeding MTU of net device (based
  *             on *ifindex*).  This helper will likely be used in combination
  *             with helpers that adjust/change the packet size.
index 98ca64d1beb6fb1d540475fe20ec67a73b81b846..54442612c48bd7cbd5808f1145ff46c6c517fe28 100644 (file)
@@ -903,7 +903,8 @@ struct fuse_notify_retrieve_in {
 };
 
 /* Device ioctls: */
-#define FUSE_DEV_IOC_CLONE     _IOR(229, 0, uint32_t)
+#define FUSE_DEV_IOC_MAGIC             229
+#define FUSE_DEV_IOC_CLONE             _IOR(FUSE_DEV_IOC_MAGIC, 0, uint32_t)
 
 struct fuse_lseek_in {
        uint64_t        fh;
index 30c80d5ba4bfcba26a2bdd14045cfe0b936fdbfb..bab8c9708611139357eb888c9ad367935f380844 100644 (file)
@@ -145,6 +145,7 @@ enum {
        L2TP_ATTR_RX_ERRORS,            /* u64 */
        L2TP_ATTR_STATS_PAD,
        L2TP_ATTR_RX_COOKIE_DISCARDS,   /* u64 */
+       L2TP_ATTR_RX_INVALID,           /* u64 */
        __L2TP_ATTR_STATS_MAX,
 };
 
index a13137afc42994b75b9730e843d3e3ec59967fbc..70af02092d16efb30d3dac74a1fd3f2b35d618e5 100644 (file)
@@ -5,7 +5,7 @@
 #define NFCT_HELPER_STATUS_DISABLED    0
 #define NFCT_HELPER_STATUS_ENABLED     1
 
-enum nfnl_acct_msg_types {
+enum nfnl_cthelper_msg_types {
        NFNL_MSG_CTHELPER_NEW,
        NFNL_MSG_CTHELPER_GET,
        NFNL_MSG_CTHELPER_DEL,
index 0b1182a3cf4128b4502b7e3db59adeb8522daea5..cb854df031ce0715b9158fa71c7f02ad2c2dc732 100644 (file)
 #include <linux/page-flags.h>
 #include <linux/kernel.h>
 
+/*
+ * Technically there's no reliably invalid grant reference or grant handle,
+ * so pick the value that is the most unlikely one to be observed valid.
+ */
+#define INVALID_GRANT_REF          ((grant_ref_t)-1)
+#define INVALID_GRANT_HANDLE       ((grant_handle_t)-1)
+
 #define GNTTAB_RESERVED_XENSTORE 1
 
 /* NR_GRANT_FRAMES must be less than or equal to that configured in Xen */
index 0b1386073d49bf48d40909954d6043e15a27638d..b94074c827721b8ebdee18a5199ba3657cfcccfd 100644 (file)
@@ -51,7 +51,6 @@
 
 #define XENBUS_MAX_RING_GRANT_ORDER 4
 #define XENBUS_MAX_RING_GRANTS      (1U << XENBUS_MAX_RING_GRANT_ORDER)
-#define INVALID_GRANT_HANDLE       (~0U)
 
 /* Register callback to watch this node. */
 struct xenbus_watch
index 22946fe5ded982b37a9cd49c9b9b24a2f3667891..5f5c776ef192116166d3bd448f66777f5fe2253b 100644 (file)
@@ -20,10 +20,10 @@ config CC_VERSION_TEXT
            When the compiler is updated, Kconfig will be invoked.
 
          - Ensure full rebuild when the compiler is updated
-           include/linux/kconfig.h contains this option in the comment line so
-           fixdep adds include/config/cc/version/text.h into the auto-generated
-           dependency. When the compiler is updated, syncconfig will touch it
-           and then every file will be rebuilt.
+           include/linux/compiler-version.h contains this option in the comment
+           line so fixdep adds include/config/cc/version/text.h into the
+           auto-generated dependency. When the compiler is updated, syncconfig
+           will touch it and then every file will be rebuilt.
 
 config CC_IS_GCC
        def_bool $(success,test "$(cc-name)" = GCC)
@@ -119,8 +119,7 @@ config INIT_ENV_ARG_LIMIT
 
 config COMPILE_TEST
        bool "Compile also drivers which will not load"
-       depends on !UML && !S390
-       default n
+       depends on HAS_IOMEM
        help
          Some drivers can be compiled on a different platform than they are
          intended to be run on. Despite they cannot be loaded there (or even
index 2efeb5f4b3433a35570544600e72e08f4855db3e..b1a76fe046cbafed9f36ae3d76950ce05fd9200a 100644 (file)
@@ -4321,8 +4321,6 @@ btf_get_prog_ctx_type(struct bpf_verifier_log *log, struct btf *btf,
                 * is not supported yet.
                 * BPF_PROG_TYPE_RAW_TRACEPOINT is fine.
                 */
-               if (log->level & BPF_LOG_LEVEL)
-                       bpf_log(log, "arg#%d type is not a struct\n", arg);
                return NULL;
        }
        tname = btf_name_by_offset(btf, t->name_off);
index 0ae015ad1e05672c4baf60e81f68fd39e043b1f5..3a283bf97f2f674927d17da17efec2f5906c6580 100644 (file)
@@ -1118,6 +1118,8 @@ static void bpf_prog_clone_free(struct bpf_prog *fp)
         * clone is guaranteed to not be locked.
         */
        fp->aux = NULL;
+       fp->stats = NULL;
+       fp->active = NULL;
        __bpf_prog_free(fp);
 }
 
@@ -2342,6 +2344,10 @@ bool __weak bpf_helper_changes_pkt_data(void *func)
 /* Return TRUE if the JIT backend wants verifier to enable sub-register usage
  * analysis code and wants explicit zero extension inserted by verifier.
  * Otherwise, return FALSE.
+ *
+ * The verifier inserts an explicit zero extension after BPF_CMPXCHGs even if
+ * you don't override this. JITs that don't want these extra insns can detect
+ * them using insn_is_zext.
  */
 bool __weak bpf_jit_needs_zext(void)
 {
index 1dda9d81f12c5e8ef3bbc7327ebe51f305b6e67a..c56e3fcb5f1a07d2e0df00d82f01c4e6a1b12ff9 100644 (file)
@@ -504,6 +504,13 @@ static bool is_ptr_cast_function(enum bpf_func_id func_id)
                func_id == BPF_FUNC_skc_to_tcp_request_sock;
 }
 
+static bool is_cmpxchg_insn(const struct bpf_insn *insn)
+{
+       return BPF_CLASS(insn->code) == BPF_STX &&
+              BPF_MODE(insn->code) == BPF_ATOMIC &&
+              insn->imm == BPF_CMPXCHG;
+}
+
 /* string representation of 'enum bpf_reg_type' */
 static const char * const reg_type_str[] = {
        [NOT_INIT]              = "?",
@@ -1120,7 +1127,7 @@ static void mark_ptr_not_null_reg(struct bpf_reg_state *reg)
                reg->type = PTR_TO_RDWR_BUF;
                break;
        default:
-               WARN_ON("unknown nullable register type");
+               WARN_ONCE(1, "unknown nullable register type");
        }
 }
 
@@ -1703,7 +1710,11 @@ static bool is_reg64(struct bpf_verifier_env *env, struct bpf_insn *insn,
        }
 
        if (class == BPF_STX) {
-               if (reg->type != SCALAR_VALUE)
+               /* BPF_STX (including atomic variants) has multiple source
+                * operands, one of which is a ptr. Check whether the caller is
+                * asking about it.
+                */
+               if (t == SRC_OP && reg->type != SCALAR_VALUE)
                        return true;
                return BPF_SIZE(code) == BPF_DW;
        }
@@ -1735,22 +1746,38 @@ static bool is_reg64(struct bpf_verifier_env *env, struct bpf_insn *insn,
        return true;
 }
 
-/* Return TRUE if INSN doesn't have explicit value define. */
-static bool insn_no_def(struct bpf_insn *insn)
+/* Return the regno defined by the insn, or -1. */
+static int insn_def_regno(const struct bpf_insn *insn)
 {
-       u8 class = BPF_CLASS(insn->code);
-
-       return (class == BPF_JMP || class == BPF_JMP32 ||
-               class == BPF_STX || class == BPF_ST);
+       switch (BPF_CLASS(insn->code)) {
+       case BPF_JMP:
+       case BPF_JMP32:
+       case BPF_ST:
+               return -1;
+       case BPF_STX:
+               if (BPF_MODE(insn->code) == BPF_ATOMIC &&
+                   (insn->imm & BPF_FETCH)) {
+                       if (insn->imm == BPF_CMPXCHG)
+                               return BPF_REG_0;
+                       else
+                               return insn->src_reg;
+               } else {
+                       return -1;
+               }
+       default:
+               return insn->dst_reg;
+       }
 }
 
 /* Return TRUE if INSN has defined any 32-bit value explicitly. */
 static bool insn_has_def32(struct bpf_verifier_env *env, struct bpf_insn *insn)
 {
-       if (insn_no_def(insn))
+       int dst_reg = insn_def_regno(insn);
+
+       if (dst_reg == -1)
                return false;
 
-       return !is_reg64(env, insn, insn->dst_reg, NULL, DST_OP);
+       return !is_reg64(env, insn, dst_reg, NULL, DST_OP);
 }
 
 static void mark_insn_zext(struct bpf_verifier_env *env,
@@ -11006,9 +11033,10 @@ static int opt_subreg_zext_lo32_rnd_hi32(struct bpf_verifier_env *env,
        for (i = 0; i < len; i++) {
                int adj_idx = i + delta;
                struct bpf_insn insn;
-               u8 load_reg;
+               int load_reg;
 
                insn = insns[adj_idx];
+               load_reg = insn_def_regno(&insn);
                if (!aux[adj_idx].zext_dst) {
                        u8 code, class;
                        u32 imm_rnd;
@@ -11018,14 +11046,14 @@ static int opt_subreg_zext_lo32_rnd_hi32(struct bpf_verifier_env *env,
 
                        code = insn.code;
                        class = BPF_CLASS(code);
-                       if (insn_no_def(&insn))
+                       if (load_reg == -1)
                                continue;
 
                        /* NOTE: arg "reg" (the fourth one) is only used for
-                        *       BPF_STX which has been ruled out in above
-                        *       check, it is safe to pass NULL here.
+                        *       BPF_STX + SRC_OP, so it is safe to pass NULL
+                        *       here.
                         */
-                       if (is_reg64(env, &insn, insn.dst_reg, NULL, DST_OP)) {
+                       if (is_reg64(env, &insn, load_reg, NULL, DST_OP)) {
                                if (class == BPF_LD &&
                                    BPF_MODE(code) == BPF_IMM)
                                        i++;
@@ -11040,31 +11068,28 @@ static int opt_subreg_zext_lo32_rnd_hi32(struct bpf_verifier_env *env,
                        imm_rnd = get_random_int();
                        rnd_hi32_patch[0] = insn;
                        rnd_hi32_patch[1].imm = imm_rnd;
-                       rnd_hi32_patch[3].dst_reg = insn.dst_reg;
+                       rnd_hi32_patch[3].dst_reg = load_reg;
                        patch = rnd_hi32_patch;
                        patch_len = 4;
                        goto apply_patch_buffer;
                }
 
-               if (!bpf_jit_needs_zext())
+               /* Add in an zero-extend instruction if a) the JIT has requested
+                * it or b) it's a CMPXCHG.
+                *
+                * The latter is because: BPF_CMPXCHG always loads a value into
+                * R0, therefore always zero-extends. However some archs'
+                * equivalent instruction only does this load when the
+                * comparison is successful. This detail of CMPXCHG is
+                * orthogonal to the general zero-extension behaviour of the
+                * CPU, so it's treated independently of bpf_jit_needs_zext.
+                */
+               if (!bpf_jit_needs_zext() && !is_cmpxchg_insn(&insn))
                        continue;
 
-               /* zext_dst means that we want to zero-extend whatever register
-                * the insn defines, which is dst_reg most of the time, with
-                * the notable exception of BPF_STX + BPF_ATOMIC + BPF_FETCH.
-                */
-               if (BPF_CLASS(insn.code) == BPF_STX &&
-                   BPF_MODE(insn.code) == BPF_ATOMIC) {
-                       /* BPF_STX + BPF_ATOMIC insns without BPF_FETCH do not
-                        * define any registers, therefore zext_dst cannot be
-                        * set.
-                        */
-                       if (WARN_ON(!(insn.imm & BPF_FETCH)))
-                               return -EINVAL;
-                       load_reg = insn.imm == BPF_CMPXCHG ? BPF_REG_0
-                                                          : insn.src_reg;
-               } else {
-                       load_reg = insn.dst_reg;
+               if (WARN_ON(load_reg == -1)) {
+                       verbose(env, "verifier bug. zext_dst is set, but no reg is defined\n");
+                       return -EFAULT;
                }
 
                zext_patch[0] = insn;
index 0aeca5f3c0acceab9df9bb87ae01481fdb913f05..03db40f6cba904d8d99943b406c4b24031a63c92 100644 (file)
@@ -386,6 +386,7 @@ static DEFINE_MUTEX(perf_sched_mutex);
 static atomic_t perf_sched_count;
 
 static DEFINE_PER_CPU(atomic_t, perf_cgroup_events);
+static DEFINE_PER_CPU(int, perf_sched_cb_usages);
 static DEFINE_PER_CPU(struct pmu_event_list, pmu_sb_events);
 
 static atomic_t nr_mmap_events __read_mostly;
@@ -3461,11 +3462,16 @@ unlock:
        }
 }
 
+static DEFINE_PER_CPU(struct list_head, sched_cb_list);
+
 void perf_sched_cb_dec(struct pmu *pmu)
 {
        struct perf_cpu_context *cpuctx = this_cpu_ptr(pmu->pmu_cpu_context);
 
-       --cpuctx->sched_cb_usage;
+       this_cpu_dec(perf_sched_cb_usages);
+
+       if (!--cpuctx->sched_cb_usage)
+               list_del(&cpuctx->sched_cb_entry);
 }
 
 
@@ -3473,7 +3479,10 @@ void perf_sched_cb_inc(struct pmu *pmu)
 {
        struct perf_cpu_context *cpuctx = this_cpu_ptr(pmu->pmu_cpu_context);
 
-       cpuctx->sched_cb_usage++;
+       if (!cpuctx->sched_cb_usage++)
+               list_add(&cpuctx->sched_cb_entry, this_cpu_ptr(&sched_cb_list));
+
+       this_cpu_inc(perf_sched_cb_usages);
 }
 
 /*
@@ -3502,6 +3511,24 @@ static void __perf_pmu_sched_task(struct perf_cpu_context *cpuctx, bool sched_in
        perf_ctx_unlock(cpuctx, cpuctx->task_ctx);
 }
 
+static void perf_pmu_sched_task(struct task_struct *prev,
+                               struct task_struct *next,
+                               bool sched_in)
+{
+       struct perf_cpu_context *cpuctx;
+
+       if (prev == next)
+               return;
+
+       list_for_each_entry(cpuctx, this_cpu_ptr(&sched_cb_list), sched_cb_entry) {
+               /* will be handled in perf_event_context_sched_in/out */
+               if (cpuctx->task_ctx)
+                       continue;
+
+               __perf_pmu_sched_task(cpuctx, sched_in);
+       }
+}
+
 static void perf_event_switch(struct task_struct *task,
                              struct task_struct *next_prev, bool sched_in);
 
@@ -3524,6 +3551,9 @@ void __perf_event_task_sched_out(struct task_struct *task,
 {
        int ctxn;
 
+       if (__this_cpu_read(perf_sched_cb_usages))
+               perf_pmu_sched_task(task, next, false);
+
        if (atomic_read(&nr_switch_events))
                perf_event_switch(task, next, false);
 
@@ -3832,6 +3862,9 @@ void __perf_event_task_sched_in(struct task_struct *prev,
 
        if (atomic_read(&nr_switch_events))
                perf_event_switch(task, prev, true);
+
+       if (__this_cpu_read(perf_sched_cb_usages))
+               perf_pmu_sched_task(prev, task, true);
 }
 
 static u64 perf_calculate_period(struct perf_event *event, u64 nsec, u64 count)
@@ -4656,7 +4689,7 @@ static void unaccount_event(struct perf_event *event)
        if (event->parent)
                return;
 
-       if (event->attach_state & PERF_ATTACH_TASK)
+       if (event->attach_state & (PERF_ATTACH_TASK | PERF_ATTACH_SCHED_CB))
                dec = true;
        if (event->attr.mmap || event->attr.mmap_data)
                atomic_dec(&nr_mmap_events);
@@ -11175,7 +11208,7 @@ static void account_event(struct perf_event *event)
        if (event->parent)
                return;
 
-       if (event->attach_state & PERF_ATTACH_TASK)
+       if (event->attach_state & (PERF_ATTACH_TASK | PERF_ATTACH_SCHED_CB))
                inc = true;
        if (event->attr.mmap || event->attr.mmap_data)
                atomic_inc(&nr_mmap_events);
@@ -12972,6 +13005,7 @@ static void __init perf_event_init_all_cpus(void)
 #ifdef CONFIG_CGROUP_PERF
                INIT_LIST_HEAD(&per_cpu(cgrp_cpuctx_list, cpu));
 #endif
+               INIT_LIST_HEAD(&per_cpu(sched_cb_list, cpu));
        }
 }
 
index d3171e8e88e5d4af93ab1fa21a2dfe4c41b67292..54cc905e5fe095d0081ec943ac2a16e487f2235b 100644 (file)
@@ -994,6 +994,13 @@ static void mm_init_owner(struct mm_struct *mm, struct task_struct *p)
 #endif
 }
 
+static void mm_init_pasid(struct mm_struct *mm)
+{
+#ifdef CONFIG_IOMMU_SUPPORT
+       mm->pasid = INIT_PASID;
+#endif
+}
+
 static void mm_init_uprobes_state(struct mm_struct *mm)
 {
 #ifdef CONFIG_UPROBES
@@ -1024,6 +1031,7 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p,
        mm_init_cpumask(mm);
        mm_init_aio(mm);
        mm_init_owner(mm, p);
+       mm_init_pasid(mm);
        RCU_INIT_POINTER(mm->exe_file, NULL);
        mmu_notifier_subscriptions_init(mm);
        init_tlb_flush_pending(mm);
index dc520f01f99ddc053366ab5fdbaffd126f519c24..1a2d57d1327cd6d467d8ce86117bc2174652068e 100644 (file)
@@ -134,7 +134,7 @@ bool freeze_task(struct task_struct *p)
                return false;
        }
 
-       if (!(p->flags & PF_KTHREAD))
+       if (!(p->flags & (PF_KTHREAD | PF_IO_WORKER)))
                fake_signal_wake_up(p);
        else
                wake_up_state(p, TASK_INTERRUPTIBLE);
index e68db774503929bf519b19051908992fce336e50..00febd6dea9cc83d4fe21bd29609ee5b5db462c1 100644 (file)
@@ -2728,14 +2728,13 @@ retry:
                goto out;
 
        restart = &current->restart_block;
-       restart->fn = futex_wait_restart;
        restart->futex.uaddr = uaddr;
        restart->futex.val = val;
        restart->futex.time = *abs_time;
        restart->futex.bitset = bitset;
        restart->futex.flags = flags | FLAGS_HAS_TIMEOUT;
 
-       ret = -ERESTART_RESTARTBLOCK;
+       ret = set_restart_fn(restart, futex_wait_restart);
 
 out:
        if (to) {
index 48006608baf0c1d367975d985a434a83da41181a..40880c350b95d484c9c30bf3d3b72f1a56667721 100644 (file)
@@ -159,7 +159,7 @@ static const struct irq_domain_ops irq_sim_domain_ops = {
  * irq_domain_create_sim - Create a new interrupt simulator irq_domain and
  *                         allocate a range of dummy interrupts.
  *
- * @fnode:      struct fwnode_handle to be associated with this domain.
+ * @fwnode:     struct fwnode_handle to be associated with this domain.
  * @num_irqs:   Number of interrupts to allocate.
  *
  * On success: return a new irq_domain object.
@@ -228,7 +228,7 @@ static void devm_irq_domain_release_sim(struct device *dev, void *res)
  *                              a managed device.
  *
  * @dev:        Device to initialize the simulator object for.
- * @fnode:      struct fwnode_handle to be associated with this domain.
+ * @fwnode:     struct fwnode_handle to be associated with this domain.
  * @num_irqs:   Number of interrupts to allocate
  *
  * On success: return a new irq_domain object.
index 288151393a0653978d38facd20b30e7b28632372..d10ab1d689d58c39c72b8e615b0e64807f082d7c 100644 (file)
@@ -1898,16 +1898,15 @@ DEFINE_SHOW_ATTRIBUTE(irq_domain_debug);
 
 static void debugfs_add_domain_dir(struct irq_domain *d)
 {
-       if (!d->name || !domain_dir || d->debugfs_file)
+       if (!d->name || !domain_dir)
                return;
-       d->debugfs_file = debugfs_create_file(d->name, 0444, domain_dir, d,
-                                             &irq_domain_debug_fops);
+       debugfs_create_file(d->name, 0444, domain_dir, d,
+                           &irq_domain_debug_fops);
 }
 
 static void debugfs_remove_domain_dir(struct irq_domain *d)
 {
-       debugfs_remove(d->debugfs_file);
-       d->debugfs_file = NULL;
+       debugfs_remove(debugfs_lookup(d->name, domain_dir));
 }
 
 void __init irq_domain_debugfs_init(struct dentry *root)
index dec3f73e8db92e87e7cf2647d75ad5f7afaf2c62..21ea370fccda704050b2c8abddbb65adf0c7ed8b 100644 (file)
@@ -1142,11 +1142,15 @@ irq_forced_thread_fn(struct irq_desc *desc, struct irqaction *action)
        irqreturn_t ret;
 
        local_bh_disable();
+       if (!IS_ENABLED(CONFIG_PREEMPT_RT))
+               local_irq_disable();
        ret = action->thread_fn(action->irq, action->dev_id);
        if (ret == IRQ_HANDLED)
                atomic_inc(&desc->threads_handled);
 
        irq_finalize_oneshot(desc, action);
+       if (!IS_ENABLED(CONFIG_PREEMPT_RT))
+               local_irq_enable();
        local_bh_enable();
        return ret;
 }
index c6a39d662935e494decf97a6f09b3f5ebda4975b..ba39fbb1f8e7382c4b0bd7ffd785618574a8e270 100644 (file)
@@ -407,6 +407,14 @@ static bool jump_label_can_update(struct jump_entry *entry, bool init)
                return false;
 
        if (!kernel_text_address(jump_entry_code(entry))) {
+               /*
+                * This skips patching built-in __exit, which
+                * is part of init_section_contains() but is
+                * not part of kernel_text_address().
+                *
+                * Skipping built-in __exit is fine since it
+                * will never be executed.
+                */
                WARN_ONCE(!jump_entry_is_init(entry),
                          "can't patch jump_label at %pS",
                          (void *)jump_entry_code(entry));
index adb93509076886d55c9353228cda48dc46a9506d..622ebdfcd083b2712ce04b550cd0c4e02e2ddbfa 100644 (file)
@@ -626,7 +626,7 @@ static inline int mutex_can_spin_on_owner(struct mutex *lock)
  */
 static __always_inline bool
 mutex_optimistic_spin(struct mutex *lock, struct ww_acquire_ctx *ww_ctx,
-                     const bool use_ww_ctx, struct mutex_waiter *waiter)
+                     struct mutex_waiter *waiter)
 {
        if (!waiter) {
                /*
@@ -702,7 +702,7 @@ fail:
 #else
 static __always_inline bool
 mutex_optimistic_spin(struct mutex *lock, struct ww_acquire_ctx *ww_ctx,
-                     const bool use_ww_ctx, struct mutex_waiter *waiter)
+                     struct mutex_waiter *waiter)
 {
        return false;
 }
@@ -922,6 +922,9 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
        struct ww_mutex *ww;
        int ret;
 
+       if (!use_ww_ctx)
+               ww_ctx = NULL;
+
        might_sleep();
 
 #ifdef CONFIG_DEBUG_MUTEXES
@@ -929,7 +932,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
 #endif
 
        ww = container_of(lock, struct ww_mutex, base);
-       if (use_ww_ctx && ww_ctx) {
+       if (ww_ctx) {
                if (unlikely(ww_ctx == READ_ONCE(ww->ctx)))
                        return -EALREADY;
 
@@ -946,10 +949,10 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
        mutex_acquire_nest(&lock->dep_map, subclass, 0, nest_lock, ip);
 
        if (__mutex_trylock(lock) ||
-           mutex_optimistic_spin(lock, ww_ctx, use_ww_ctx, NULL)) {
+           mutex_optimistic_spin(lock, ww_ctx, NULL)) {
                /* got the lock, yay! */
                lock_acquired(&lock->dep_map, ip);
-               if (use_ww_ctx && ww_ctx)
+               if (ww_ctx)
                        ww_mutex_set_context_fastpath(ww, ww_ctx);
                preempt_enable();
                return 0;
@@ -960,7 +963,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
         * After waiting to acquire the wait_lock, try again.
         */
        if (__mutex_trylock(lock)) {
-               if (use_ww_ctx && ww_ctx)
+               if (ww_ctx)
                        __ww_mutex_check_waiters(lock, ww_ctx);
 
                goto skip_wait;
@@ -1013,7 +1016,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
                        goto err;
                }
 
-               if (use_ww_ctx && ww_ctx) {
+               if (ww_ctx) {
                        ret = __ww_mutex_check_kill(lock, &waiter, ww_ctx);
                        if (ret)
                                goto err;
@@ -1026,7 +1029,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
                 * ww_mutex needs to always recheck its position since its waiter
                 * list is not FIFO ordered.
                 */
-               if ((use_ww_ctx && ww_ctx) || !first) {
+               if (ww_ctx || !first) {
                        first = __mutex_waiter_is_first(lock, &waiter);
                        if (first)
                                __mutex_set_flag(lock, MUTEX_FLAG_HANDOFF);
@@ -1039,7 +1042,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
                 * or we must see its unlock and acquire.
                 */
                if (__mutex_trylock(lock) ||
-                   (first && mutex_optimistic_spin(lock, ww_ctx, use_ww_ctx, &waiter)))
+                   (first && mutex_optimistic_spin(lock, ww_ctx, &waiter)))
                        break;
 
                spin_lock(&lock->wait_lock);
@@ -1048,7 +1051,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
 acquired:
        __set_current_state(TASK_RUNNING);
 
-       if (use_ww_ctx && ww_ctx) {
+       if (ww_ctx) {
                /*
                 * Wound-Wait; we stole the lock (!first_waiter), check the
                 * waiters as anyone might want to wound us.
@@ -1068,7 +1071,7 @@ skip_wait:
        /* got the lock - cleanup and rejoice! */
        lock_acquired(&lock->dep_map, ip);
 
-       if (use_ww_ctx && ww_ctx)
+       if (ww_ctx)
                ww_mutex_lock_acquired(ww, ww_ctx);
 
        spin_unlock(&lock->wait_lock);
index eb1b158507616f9c738b3bc52c2eb93c15fdfb19..a6ad5eb2fa733fe2fd43e959c9a9fccd6c7dbb4a 100644 (file)
@@ -244,8 +244,6 @@ void migrate_to_reboot_cpu(void)
 void kernel_restart(char *cmd)
 {
        kernel_restart_prepare(cmd);
-       if (pm_power_off_prepare)
-               pm_power_off_prepare();
        migrate_to_reboot_cpu();
        syscore_shutdown();
        if (!cmd)
index ca2bb629595f63068292a75ce5e4678778444c88..98191218d891d8986f28fcc51c6724640bac7796 100644 (file)
@@ -1862,8 +1862,13 @@ struct migration_arg {
        struct set_affinity_pending     *pending;
 };
 
+/*
+ * @refs: number of wait_for_completion()
+ * @stop_pending: is @stop_work in use
+ */
 struct set_affinity_pending {
        refcount_t              refs;
+       unsigned int            stop_pending;
        struct completion       done;
        struct cpu_stop_work    stop_work;
        struct migration_arg    arg;
@@ -1898,8 +1903,8 @@ static struct rq *__migrate_task(struct rq *rq, struct rq_flags *rf,
  */
 static int migration_cpu_stop(void *data)
 {
-       struct set_affinity_pending *pending;
        struct migration_arg *arg = data;
+       struct set_affinity_pending *pending = arg->pending;
        struct task_struct *p = arg->task;
        int dest_cpu = arg->dest_cpu;
        struct rq *rq = this_rq();
@@ -1921,7 +1926,6 @@ static int migration_cpu_stop(void *data)
        raw_spin_lock(&p->pi_lock);
        rq_lock(rq, &rf);
 
-       pending = p->migration_pending;
        /*
         * If task_rq(p) != rq, it cannot be migrated here, because we're
         * holding rq->lock, if p->on_rq == 0 it cannot get enqueued because
@@ -1932,21 +1936,14 @@ static int migration_cpu_stop(void *data)
                        goto out;
 
                if (pending) {
-                       p->migration_pending = NULL;
+                       if (p->migration_pending == pending)
+                               p->migration_pending = NULL;
                        complete = true;
                }
 
-               /* migrate_enable() --  we must not race against SCA */
                if (dest_cpu < 0) {
-                       /*
-                        * When this was migrate_enable() but we no longer
-                        * have a @pending, a concurrent SCA 'fixed' things
-                        * and we should be valid again. Nothing to do.
-                        */
-                       if (!pending) {
-                               WARN_ON_ONCE(!cpumask_test_cpu(task_cpu(p), &p->cpus_mask));
+                       if (cpumask_test_cpu(task_cpu(p), &p->cpus_mask))
                                goto out;
-                       }
 
                        dest_cpu = cpumask_any_distribute(&p->cpus_mask);
                }
@@ -1956,7 +1953,14 @@ static int migration_cpu_stop(void *data)
                else
                        p->wake_cpu = dest_cpu;
 
-       } else if (dest_cpu < 0 || pending) {
+               /*
+                * XXX __migrate_task() can fail, at which point we might end
+                * up running on a dodgy CPU, AFAICT this can only happen
+                * during CPU hotplug, at which point we'll get pushed out
+                * anyway, so it's probably not a big deal.
+                */
+
+       } else if (pending) {
                /*
                 * This happens when we get migrated between migrate_enable()'s
                 * preempt_enable() and scheduling the stopper task. At that
@@ -1971,43 +1975,32 @@ static int migration_cpu_stop(void *data)
                 * ->pi_lock, so the allowed mask is stable - if it got
                 * somewhere allowed, we're done.
                 */
-               if (pending && cpumask_test_cpu(task_cpu(p), p->cpus_ptr)) {
-                       p->migration_pending = NULL;
+               if (cpumask_test_cpu(task_cpu(p), p->cpus_ptr)) {
+                       if (p->migration_pending == pending)
+                               p->migration_pending = NULL;
                        complete = true;
                        goto out;
                }
 
-               /*
-                * When this was migrate_enable() but we no longer have an
-                * @pending, a concurrent SCA 'fixed' things and we should be
-                * valid again. Nothing to do.
-                */
-               if (!pending) {
-                       WARN_ON_ONCE(!cpumask_test_cpu(task_cpu(p), &p->cpus_mask));
-                       goto out;
-               }
-
                /*
                 * When migrate_enable() hits a rq mis-match we can't reliably
                 * determine is_migration_disabled() and so have to chase after
                 * it.
                 */
+               WARN_ON_ONCE(!pending->stop_pending);
                task_rq_unlock(rq, p, &rf);
                stop_one_cpu_nowait(task_cpu(p), migration_cpu_stop,
                                    &pending->arg, &pending->stop_work);
                return 0;
        }
 out:
+       if (pending)
+               pending->stop_pending = false;
        task_rq_unlock(rq, p, &rf);
 
        if (complete)
                complete_all(&pending->done);
 
-       /* For pending->{arg,stop_work} */
-       pending = arg->pending;
-       if (pending && refcount_dec_and_test(&pending->refs))
-               wake_up_var(&pending->refs);
-
        return 0;
 }
 
@@ -2194,11 +2187,7 @@ static int affine_move_task(struct rq *rq, struct task_struct *p, struct rq_flag
                            int dest_cpu, unsigned int flags)
 {
        struct set_affinity_pending my_pending = { }, *pending = NULL;
-       struct migration_arg arg = {
-               .task = p,
-               .dest_cpu = dest_cpu,
-       };
-       bool complete = false;
+       bool stop_pending, complete = false;
 
        /* Can the task run on the task's current CPU? If so, we're done */
        if (cpumask_test_cpu(task_cpu(p), &p->cpus_mask)) {
@@ -2210,12 +2199,16 @@ static int affine_move_task(struct rq *rq, struct task_struct *p, struct rq_flag
                        push_task = get_task_struct(p);
                }
 
+               /*
+                * If there are pending waiters, but no pending stop_work,
+                * then complete now.
+                */
                pending = p->migration_pending;
-               if (pending) {
-                       refcount_inc(&pending->refs);
+               if (pending && !pending->stop_pending) {
                        p->migration_pending = NULL;
                        complete = true;
                }
+
                task_rq_unlock(rq, p, rf);
 
                if (push_task) {
@@ -2224,7 +2217,7 @@ static int affine_move_task(struct rq *rq, struct task_struct *p, struct rq_flag
                }
 
                if (complete)
-                       goto do_complete;
+                       complete_all(&pending->done);
 
                return 0;
        }
@@ -2235,6 +2228,12 @@ static int affine_move_task(struct rq *rq, struct task_struct *p, struct rq_flag
                        /* Install the request */
                        refcount_set(&my_pending.refs, 1);
                        init_completion(&my_pending.done);
+                       my_pending.arg = (struct migration_arg) {
+                               .task = p,
+                               .dest_cpu = -1,         /* any */
+                               .pending = &my_pending,
+                       };
+
                        p->migration_pending = &my_pending;
                } else {
                        pending = p->migration_pending;
@@ -2259,45 +2258,41 @@ static int affine_move_task(struct rq *rq, struct task_struct *p, struct rq_flag
                return -EINVAL;
        }
 
-       if (flags & SCA_MIGRATE_ENABLE) {
-
-               refcount_inc(&pending->refs); /* pending->{arg,stop_work} */
-               p->migration_flags &= ~MDF_PUSH;
-               task_rq_unlock(rq, p, rf);
-
-               pending->arg = (struct migration_arg) {
-                       .task = p,
-                       .dest_cpu = -1,
-                       .pending = pending,
-               };
-
-               stop_one_cpu_nowait(cpu_of(rq), migration_cpu_stop,
-                                   &pending->arg, &pending->stop_work);
-
-               return 0;
-       }
-
        if (task_running(rq, p) || p->state == TASK_WAKING) {
                /*
-                * Lessen races (and headaches) by delegating
-                * is_migration_disabled(p) checks to the stopper, which will
-                * run on the same CPU as said p.
+                * MIGRATE_ENABLE gets here because 'p == current', but for
+                * anything else we cannot do is_migration_disabled(), punt
+                * and have the stopper function handle it all race-free.
                 */
+               stop_pending = pending->stop_pending;
+               if (!stop_pending)
+                       pending->stop_pending = true;
+
+               if (flags & SCA_MIGRATE_ENABLE)
+                       p->migration_flags &= ~MDF_PUSH;
+
                task_rq_unlock(rq, p, rf);
-               stop_one_cpu(cpu_of(rq), migration_cpu_stop, &arg);
 
+               if (!stop_pending) {
+                       stop_one_cpu_nowait(cpu_of(rq), migration_cpu_stop,
+                                           &pending->arg, &pending->stop_work);
+               }
+
+               if (flags & SCA_MIGRATE_ENABLE)
+                       return 0;
        } else {
 
                if (!is_migration_disabled(p)) {
                        if (task_on_rq_queued(p))
                                rq = move_queued_task(rq, rf, p, dest_cpu);
 
-                       p->migration_pending = NULL;
-                       complete = true;
+                       if (!pending->stop_pending) {
+                               p->migration_pending = NULL;
+                               complete = true;
+                       }
                }
                task_rq_unlock(rq, p, rf);
 
-do_complete:
                if (complete)
                        complete_all(&pending->done);
        }
@@ -2305,7 +2300,7 @@ do_complete:
        wait_for_completion(&pending->done);
 
        if (refcount_dec_and_test(&pending->refs))
-               wake_up_var(&pending->refs);
+               wake_up_var(&pending->refs); /* No UaF, just an address */
 
        /*
         * Block the original owner of &pending until all subsequent callers
@@ -2313,6 +2308,9 @@ do_complete:
         */
        wait_var_event(&my_pending.refs, !refcount_read(&my_pending.refs));
 
+       /* ARGH */
+       WARN_ON_ONCE(my_pending.stop_pending);
+
        return 0;
 }
 
index acdae625c6364b61cefaddddef27d520514f49c8..b5add64d9698c60813f6640d0c6a3e944f21aba1 100644 (file)
@@ -471,9 +471,7 @@ static int sync_runqueues_membarrier_state(struct mm_struct *mm)
        }
        rcu_read_unlock();
 
-       preempt_disable();
-       smp_call_function_many(tmpmask, ipi_sync_rq_state, mm, 1);
-       preempt_enable();
+       on_each_cpu_mask(tmpmask, ipi_sync_rq_state, mm, true);
 
        free_cpumask_var(tmpmask);
        cpus_read_unlock();
index ba4d1ef39a9ead9847985954c8edb3629114eb6d..f2a1b898da29fcb5adc6cc5732f53150b25d51b3 100644 (file)
@@ -288,7 +288,8 @@ bool task_set_jobctl_pending(struct task_struct *task, unsigned long mask)
                        JOBCTL_STOP_SIGMASK | JOBCTL_TRAPPING));
        BUG_ON((mask & JOBCTL_TRAPPING) && !(mask & JOBCTL_PENDING_MASK));
 
-       if (unlikely(fatal_signal_pending(task) || (task->flags & PF_EXITING)))
+       if (unlikely(fatal_signal_pending(task) ||
+                    (task->flags & (PF_EXITING | PF_IO_WORKER))))
                return false;
 
        if (mask & JOBCTL_STOP_SIGMASK)
@@ -833,6 +834,9 @@ static int check_kill_permission(int sig, struct kernel_siginfo *info,
 
        if (!valid_signal(sig))
                return -EINVAL;
+       /* PF_IO_WORKER threads don't take any signals */
+       if (t->flags & PF_IO_WORKER)
+               return -ESRCH;
 
        if (!si_fromuser(info))
                return 0;
index 6906c6ec4c97d99772f286fa58836c2119896b97..2c5950b0b90ef16dee7e27e93dfa8d8a230df75a 100644 (file)
@@ -35,27 +35,30 @@ static inline void *static_call_addr(struct static_call_site *site)
        return (void *)((long)site->addr + (long)&site->addr);
 }
 
+static inline unsigned long __static_call_key(const struct static_call_site *site)
+{
+       return (long)site->key + (long)&site->key;
+}
 
 static inline struct static_call_key *static_call_key(const struct static_call_site *site)
 {
-       return (struct static_call_key *)
-               (((long)site->key + (long)&site->key) & ~STATIC_CALL_SITE_FLAGS);
+       return (void *)(__static_call_key(site) & ~STATIC_CALL_SITE_FLAGS);
 }
 
 /* These assume the key is word-aligned. */
 static inline bool static_call_is_init(struct static_call_site *site)
 {
-       return ((long)site->key + (long)&site->key) & STATIC_CALL_SITE_INIT;
+       return __static_call_key(site) & STATIC_CALL_SITE_INIT;
 }
 
 static inline bool static_call_is_tail(struct static_call_site *site)
 {
-       return ((long)site->key + (long)&site->key) & STATIC_CALL_SITE_TAIL;
+       return __static_call_key(site) & STATIC_CALL_SITE_TAIL;
 }
 
 static inline void static_call_set_init(struct static_call_site *site)
 {
-       site->key = ((long)static_call_key(site) | STATIC_CALL_SITE_INIT) -
+       site->key = (__static_call_key(site) | STATIC_CALL_SITE_INIT) -
                    (long)&site->key;
 }
 
@@ -146,6 +149,7 @@ void __static_call_update(struct static_call_key *key, void *tramp, void *func)
        };
 
        for (site_mod = &first; site_mod; site_mod = site_mod->next) {
+               bool init = system_state < SYSTEM_RUNNING;
                struct module *mod = site_mod->mod;
 
                if (!site_mod->sites) {
@@ -165,6 +169,7 @@ void __static_call_update(struct static_call_key *key, void *tramp, void *func)
                if (mod) {
                        stop = mod->static_call_sites +
                               mod->num_static_call_sites;
+                       init = mod->state == MODULE_STATE_COMING;
                }
 #endif
 
@@ -172,25 +177,26 @@ void __static_call_update(struct static_call_key *key, void *tramp, void *func)
                     site < stop && static_call_key(site) == key; site++) {
                        void *site_addr = static_call_addr(site);
 
-                       if (static_call_is_init(site)) {
-                               /*
-                                * Don't write to call sites which were in
-                                * initmem and have since been freed.
-                                */
-                               if (!mod && system_state >= SYSTEM_RUNNING)
-                                       continue;
-                               if (mod && !within_module_init((unsigned long)site_addr, mod))
-                                       continue;
-                       }
+                       if (!init && static_call_is_init(site))
+                               continue;
 
                        if (!kernel_text_address((unsigned long)site_addr)) {
-                               WARN_ONCE(1, "can't patch static call site at %pS",
+                               /*
+                                * This skips patching built-in __exit, which
+                                * is part of init_section_contains() but is
+                                * not part of kernel_text_address().
+                                *
+                                * Skipping built-in __exit is fine since it
+                                * will never be executed.
+                                */
+                               WARN_ONCE(!static_call_is_init(site),
+                                         "can't patch static call site at %pS",
                                          site_addr);
                                continue;
                        }
 
                        arch_static_call_transform(site_addr, NULL, func,
-                               static_call_is_tail(site));
+                                                  static_call_is_tail(site));
                }
        }
 
@@ -349,7 +355,8 @@ static int static_call_add_module(struct module *mod)
        struct static_call_site *site;
 
        for (site = start; site != stop; site++) {
-               unsigned long addr = (unsigned long)static_call_key(site);
+               unsigned long s_key = __static_call_key(site);
+               unsigned long addr = s_key & ~STATIC_CALL_SITE_FLAGS;
                unsigned long key;
 
                /*
@@ -373,8 +380,8 @@ static int static_call_add_module(struct module *mod)
                        return -EINVAL;
                }
 
-               site->key = (key - (long)&site->key) |
-                           (site->key & STATIC_CALL_SITE_FLAGS);
+               key |= s_key & STATIC_CALL_SITE_FLAGS;
+               site->key = key - (long)&site->key;
        }
 
        return __static_call_init(mod, start, stop);
index b09fe21e88ff578007bcecc81d1ae012fabdf130..2e2e3f378d97f61625c6a936b38e6c86c7037e0d 100644 (file)
@@ -2079,7 +2079,7 @@ static int prctl_set_auxv(struct mm_struct *mm, unsigned long addr,
         * up to the caller to provide sane values here, otherwise userspace
         * tools which use this vector might be unhappy.
         */
-       unsigned long user_auxv[AT_VECTOR_SIZE];
+       unsigned long user_auxv[AT_VECTOR_SIZE] = {};
 
        if (len > sizeof(user_auxv))
                return -EINVAL;
index 98d7a15e8cf691c6726347b37542b866fe07c471..4d94e2b5499d894346cac8a772b7cb25141f0988 100644 (file)
@@ -854,9 +854,9 @@ static int alarm_timer_nsleep(const clockid_t which_clock, int flags,
        if (flags == TIMER_ABSTIME)
                return -ERESTARTNOHAND;
 
-       restart->fn = alarm_timer_nsleep_restart;
        restart->nanosleep.clockid = type;
        restart->nanosleep.expires = exp;
+       set_restart_fn(restart, alarm_timer_nsleep_restart);
        return ret;
 }
 
index 743c852e10f232a1d2fab81aa309193a5a8078f6..5c9d968187ae850e7a1151adffb986bf0543bddb 100644 (file)
@@ -546,8 +546,11 @@ static ktime_t __hrtimer_next_event_base(struct hrtimer_cpu_base *cpu_base,
 }
 
 /*
- * Recomputes cpu_base::*next_timer and returns the earliest expires_next but
- * does not set cpu_base::*expires_next, that is done by hrtimer_reprogram.
+ * Recomputes cpu_base::*next_timer and returns the earliest expires_next
+ * but does not set cpu_base::*expires_next, that is done by
+ * hrtimer[_force]_reprogram and hrtimer_interrupt only. When updating
+ * cpu_base::*expires_next right away, reprogramming logic would no longer
+ * work.
  *
  * When a softirq is pending, we can ignore the HRTIMER_ACTIVE_SOFT bases,
  * those timers will get run whenever the softirq gets handled, at the end of
@@ -588,6 +591,37 @@ __hrtimer_get_next_event(struct hrtimer_cpu_base *cpu_base, unsigned int active_
        return expires_next;
 }
 
+static ktime_t hrtimer_update_next_event(struct hrtimer_cpu_base *cpu_base)
+{
+       ktime_t expires_next, soft = KTIME_MAX;
+
+       /*
+        * If the soft interrupt has already been activated, ignore the
+        * soft bases. They will be handled in the already raised soft
+        * interrupt.
+        */
+       if (!cpu_base->softirq_activated) {
+               soft = __hrtimer_get_next_event(cpu_base, HRTIMER_ACTIVE_SOFT);
+               /*
+                * Update the soft expiry time. clock_settime() might have
+                * affected it.
+                */
+               cpu_base->softirq_expires_next = soft;
+       }
+
+       expires_next = __hrtimer_get_next_event(cpu_base, HRTIMER_ACTIVE_HARD);
+       /*
+        * If a softirq timer is expiring first, update cpu_base->next_timer
+        * and program the hardware with the soft expiry time.
+        */
+       if (expires_next > soft) {
+               cpu_base->next_timer = cpu_base->softirq_next_timer;
+               expires_next = soft;
+       }
+
+       return expires_next;
+}
+
 static inline ktime_t hrtimer_update_base(struct hrtimer_cpu_base *base)
 {
        ktime_t *offs_real = &base->clock_base[HRTIMER_BASE_REALTIME].offset;
@@ -628,23 +662,7 @@ hrtimer_force_reprogram(struct hrtimer_cpu_base *cpu_base, int skip_equal)
 {
        ktime_t expires_next;
 
-       /*
-        * Find the current next expiration time.
-        */
-       expires_next = __hrtimer_get_next_event(cpu_base, HRTIMER_ACTIVE_ALL);
-
-       if (cpu_base->next_timer && cpu_base->next_timer->is_soft) {
-               /*
-                * When the softirq is activated, hrtimer has to be
-                * programmed with the first hard hrtimer because soft
-                * timer interrupt could occur too late.
-                */
-               if (cpu_base->softirq_activated)
-                       expires_next = __hrtimer_get_next_event(cpu_base,
-                                                               HRTIMER_ACTIVE_HARD);
-               else
-                       cpu_base->softirq_expires_next = expires_next;
-       }
+       expires_next = hrtimer_update_next_event(cpu_base);
 
        if (skip_equal && expires_next == cpu_base->expires_next)
                return;
@@ -1644,8 +1662,8 @@ retry:
 
        __hrtimer_run_queues(cpu_base, now, flags, HRTIMER_ACTIVE_HARD);
 
-       /* Reevaluate the clock bases for the next expiry */
-       expires_next = __hrtimer_get_next_event(cpu_base, HRTIMER_ACTIVE_ALL);
+       /* Reevaluate the clock bases for the [soft] next expiry */
+       expires_next = hrtimer_update_next_event(cpu_base);
        /*
         * Store the new expiry value so the migration code can verify
         * against it.
@@ -1939,9 +1957,9 @@ long hrtimer_nanosleep(ktime_t rqtp, const enum hrtimer_mode mode,
        }
 
        restart = &current->restart_block;
-       restart->fn = hrtimer_nanosleep_restart;
        restart->nanosleep.clockid = t.timer.base->clockid;
        restart->nanosleep.expires = hrtimer_get_expires_tv64(&t.timer);
+       set_restart_fn(restart, hrtimer_nanosleep_restart);
 out:
        destroy_hrtimer_on_stack(&t.timer);
        return ret;
index a71758e34e4564ad8db4d9081e0078287adab71d..9abe15255bc4ef4a3a01ff548fb119b338651e4a 100644 (file)
@@ -1480,8 +1480,8 @@ static int posix_cpu_nsleep(const clockid_t which_clock, int flags,
                if (flags & TIMER_ABSTIME)
                        return -ERESTARTNOHAND;
 
-               restart_block->fn = posix_cpu_nsleep_restart;
                restart_block->nanosleep.clockid = which_clock;
+               set_restart_fn(restart_block, posix_cpu_nsleep_restart);
        }
        return error;
 }
index 624ae1df7984c1bc75d39b5ff3becafb2f98310e..fba9909e31b717606b46263ff8f7c2e50220ea2f 100644 (file)
@@ -156,6 +156,7 @@ config KASAN_STACK_ENABLE
 
 config KASAN_STACK
        int
+       depends on KASAN_GENERIC || KASAN_SW_TAGS
        default 1 if KASAN_STACK_ENABLE || CC_IS_GCC
        default 0
 
index c3e59caf7ffa1004c2bbd1d3d04fefc17eece90e..9c9f40bd2b3d9b04e5ecc76825cdc1004f2dbc2a 100644 (file)
@@ -21,7 +21,6 @@ static inline unsigned long ex_to_insn(const struct exception_table_entry *x)
 }
 #endif
 
-#ifndef ARCH_HAS_SORT_EXTABLE
 #ifndef ARCH_HAS_RELATIVE_EXTABLE
 #define swap_ex                NULL
 #else
@@ -88,9 +87,6 @@ void trim_init_extable(struct module *m)
                m->num_exentries--;
 }
 #endif /* CONFIG_MODULES */
-#endif /* !ARCH_HAS_SORT_EXTABLE */
-
-#ifndef ARCH_HAS_SEARCH_EXTABLE
 
 static int cmp_ex_search(const void *key, const void *elt)
 {
@@ -120,4 +116,3 @@ search_extable(const struct exception_table_entry *base,
        return bsearch(&value, base, num,
                       sizeof(struct exception_table_entry), cmp_ex_search);
 }
-#endif
index 874b732b120ce2c81945c8582971f645fba5a9f8..86f2b9495f9cfd3f30127e8a452f6c1e182511d9 100644 (file)
@@ -368,20 +368,24 @@ void zero_user_segments(struct page *page, unsigned start1, unsigned end1,
 
        BUG_ON(end1 > page_size(page) || end2 > page_size(page));
 
+       if (start1 >= end1)
+               start1 = end1 = 0;
+       if (start2 >= end2)
+               start2 = end2 = 0;
+
        for (i = 0; i < compound_nr(page); i++) {
                void *kaddr = NULL;
 
-               if (start1 < PAGE_SIZE || start2 < PAGE_SIZE)
-                       kaddr = kmap_atomic(page + i);
-
                if (start1 >= PAGE_SIZE) {
                        start1 -= PAGE_SIZE;
                        end1 -= PAGE_SIZE;
                } else {
                        unsigned this_end = min_t(unsigned, end1, PAGE_SIZE);
 
-                       if (end1 > start1)
+                       if (end1 > start1) {
+                               kaddr = kmap_atomic(page + i);
                                memset(kaddr + start1, 0, this_end - start1);
+                       }
                        end1 -= this_end;
                        start1 = 0;
                }
@@ -392,8 +396,11 @@ void zero_user_segments(struct page *page, unsigned start1, unsigned end1,
                } else {
                        unsigned this_end = min_t(unsigned, end2, PAGE_SIZE);
 
-                       if (end2 > start2)
+                       if (end2 > start2) {
+                               if (!kaddr)
+                                       kaddr = kmap_atomic(page + i);
                                memset(kaddr + start2, 0, this_end - start2);
+                       }
                        end2 -= this_end;
                        start2 = 0;
                }
index 395c75111d335eafa310057ddf92a272850c2bfa..ae907a9c20506acbe8287e57f8ac67e644c5bfed 100644 (file)
@@ -1100,9 +1100,7 @@ int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm,
         * best effort that the pinned pages won't be replaced by another
         * random page during the coming copy-on-write.
         */
-       if (unlikely(is_cow_mapping(vma->vm_flags) &&
-                    atomic_read(&src_mm->has_pinned) &&
-                    page_maybe_dma_pinned(src_page))) {
+       if (unlikely(page_needs_cow_for_dma(vma, src_page))) {
                pte_free(dst_mm, pgtable);
                spin_unlock(src_ptl);
                spin_unlock(dst_ptl);
@@ -1214,9 +1212,7 @@ int copy_huge_pud(struct mm_struct *dst_mm, struct mm_struct *src_mm,
        }
 
        /* Please refer to comments in copy_huge_pmd() */
-       if (unlikely(is_cow_mapping(vma->vm_flags) &&
-                    atomic_read(&src_mm->has_pinned) &&
-                    page_maybe_dma_pinned(pud_page(pud)))) {
+       if (unlikely(page_needs_cow_for_dma(vma, pud_page(pud)))) {
                spin_unlock(src_ptl);
                spin_unlock(dst_ptl);
                __split_huge_pud(vma, src_pud, addr);
@@ -2471,7 +2467,7 @@ static void __split_huge_page(struct page *page, struct list_head *list,
        int i;
 
        /* complete memcg works before add pages to LRU */
-       mem_cgroup_split_huge_fixup(head);
+       split_page_memcg(head, nr);
 
        if (PageAnon(head) && PageSwapCache(head)) {
                swp_entry_t entry = { .val = page_private(head) };
index 8fb42c6dd74bf2bbb9a07f35d5c025bf633e2baf..5b1ab1f427c57cd1a66c29d9fca147d02bf229d4 100644 (file)
@@ -331,6 +331,24 @@ static void coalesce_file_region(struct resv_map *resv, struct file_region *rg)
        }
 }
 
+static inline long
+hugetlb_resv_map_add(struct resv_map *map, struct file_region *rg, long from,
+                    long to, struct hstate *h, struct hugetlb_cgroup *cg,
+                    long *regions_needed)
+{
+       struct file_region *nrg;
+
+       if (!regions_needed) {
+               nrg = get_file_region_entry_from_cache(map, from, to);
+               record_hugetlb_cgroup_uncharge_info(cg, h, map, nrg);
+               list_add(&nrg->link, rg->link.prev);
+               coalesce_file_region(map, nrg);
+       } else
+               *regions_needed += 1;
+
+       return to - from;
+}
+
 /*
  * Must be called with resv->lock held.
  *
@@ -346,7 +364,7 @@ static long add_reservation_in_range(struct resv_map *resv, long f, long t,
        long add = 0;
        struct list_head *head = &resv->regions;
        long last_accounted_offset = f;
-       struct file_region *rg = NULL, *trg = NULL, *nrg = NULL;
+       struct file_region *rg = NULL, *trg = NULL;
 
        if (regions_needed)
                *regions_needed = 0;
@@ -369,24 +387,17 @@ static long add_reservation_in_range(struct resv_map *resv, long f, long t,
                /* When we find a region that starts beyond our range, we've
                 * finished.
                 */
-               if (rg->from > t)
+               if (rg->from >= t)
                        break;
 
                /* Add an entry for last_accounted_offset -> rg->from, and
                 * update last_accounted_offset.
                 */
-               if (rg->from > last_accounted_offset) {
-                       add += rg->from - last_accounted_offset;
-                       if (!regions_needed) {
-                               nrg = get_file_region_entry_from_cache(
-                                       resv, last_accounted_offset, rg->from);
-                               record_hugetlb_cgroup_uncharge_info(h_cg, h,
-                                                                   resv, nrg);
-                               list_add(&nrg->link, rg->link.prev);
-                               coalesce_file_region(resv, nrg);
-                       } else
-                               *regions_needed += 1;
-               }
+               if (rg->from > last_accounted_offset)
+                       add += hugetlb_resv_map_add(resv, rg,
+                                                   last_accounted_offset,
+                                                   rg->from, h, h_cg,
+                                                   regions_needed);
 
                last_accounted_offset = rg->to;
        }
@@ -394,17 +405,9 @@ static long add_reservation_in_range(struct resv_map *resv, long f, long t,
        /* Handle the case where our range extends beyond
         * last_accounted_offset.
         */
-       if (last_accounted_offset < t) {
-               add += t - last_accounted_offset;
-               if (!regions_needed) {
-                       nrg = get_file_region_entry_from_cache(
-                               resv, last_accounted_offset, t);
-                       record_hugetlb_cgroup_uncharge_info(h_cg, h, resv, nrg);
-                       list_add(&nrg->link, rg->link.prev);
-                       coalesce_file_region(resv, nrg);
-               } else
-                       *regions_needed += 1;
-       }
+       if (last_accounted_offset < t)
+               add += hugetlb_resv_map_add(resv, rg, last_accounted_offset,
+                                           t, h, h_cg, regions_needed);
 
        VM_BUG_ON(add < 0);
        return add;
@@ -3725,21 +3728,32 @@ static bool is_hugetlb_entry_hwpoisoned(pte_t pte)
                return false;
 }
 
+static void
+hugetlb_install_page(struct vm_area_struct *vma, pte_t *ptep, unsigned long addr,
+                    struct page *new_page)
+{
+       __SetPageUptodate(new_page);
+       set_huge_pte_at(vma->vm_mm, addr, ptep, make_huge_pte(vma, new_page, 1));
+       hugepage_add_new_anon_rmap(new_page, vma, addr);
+       hugetlb_count_add(pages_per_huge_page(hstate_vma(vma)), vma->vm_mm);
+       ClearHPageRestoreReserve(new_page);
+       SetHPageMigratable(new_page);
+}
+
 int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
                            struct vm_area_struct *vma)
 {
        pte_t *src_pte, *dst_pte, entry, dst_entry;
        struct page *ptepage;
        unsigned long addr;
-       int cow;
+       bool cow = is_cow_mapping(vma->vm_flags);
        struct hstate *h = hstate_vma(vma);
        unsigned long sz = huge_page_size(h);
+       unsigned long npages = pages_per_huge_page(h);
        struct address_space *mapping = vma->vm_file->f_mapping;
        struct mmu_notifier_range range;
        int ret = 0;
 
-       cow = (vma->vm_flags & (VM_SHARED | VM_MAYWRITE)) == VM_MAYWRITE;
-
        if (cow) {
                mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, 0, vma, src,
                                        vma->vm_start,
@@ -3784,6 +3798,7 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
                spin_lock_nested(src_ptl, SINGLE_DEPTH_NESTING);
                entry = huge_ptep_get(src_pte);
                dst_entry = huge_ptep_get(dst_pte);
+again:
                if (huge_pte_none(entry) || !huge_pte_none(dst_entry)) {
                        /*
                         * Skip if src entry none.  Also, skip in the
@@ -3807,6 +3822,52 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
                        }
                        set_huge_swap_pte_at(dst, addr, dst_pte, entry, sz);
                } else {
+                       entry = huge_ptep_get(src_pte);
+                       ptepage = pte_page(entry);
+                       get_page(ptepage);
+
+                       /*
+                        * This is a rare case where we see pinned hugetlb
+                        * pages while they're prone to COW.  We need to do the
+                        * COW earlier during fork.
+                        *
+                        * When pre-allocating the page or copying data, we
+                        * need to be without the pgtable locks since we could
+                        * sleep during the process.
+                        */
+                       if (unlikely(page_needs_cow_for_dma(vma, ptepage))) {
+                               pte_t src_pte_old = entry;
+                               struct page *new;
+
+                               spin_unlock(src_ptl);
+                               spin_unlock(dst_ptl);
+                               /* Do not use reserve as it's private owned */
+                               new = alloc_huge_page(vma, addr, 1);
+                               if (IS_ERR(new)) {
+                                       put_page(ptepage);
+                                       ret = PTR_ERR(new);
+                                       break;
+                               }
+                               copy_user_huge_page(new, ptepage, addr, vma,
+                                                   npages);
+                               put_page(ptepage);
+
+                               /* Install the new huge page if src pte stable */
+                               dst_ptl = huge_pte_lock(h, dst, dst_pte);
+                               src_ptl = huge_pte_lockptr(h, src, src_pte);
+                               spin_lock_nested(src_ptl, SINGLE_DEPTH_NESTING);
+                               entry = huge_ptep_get(src_pte);
+                               if (!pte_same(src_pte_old, entry)) {
+                                       put_page(new);
+                                       /* dst_entry won't change as in child */
+                                       goto again;
+                               }
+                               hugetlb_install_page(vma, dst_pte, addr, new);
+                               spin_unlock(src_ptl);
+                               spin_unlock(dst_ptl);
+                               continue;
+                       }
+
                        if (cow) {
                                /*
                                 * No need to notify as we are downgrading page
@@ -3817,12 +3878,10 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
                                 */
                                huge_ptep_set_wrprotect(src, addr, src_pte);
                        }
-                       entry = huge_ptep_get(src_pte);
-                       ptepage = pte_page(entry);
-                       get_page(ptepage);
+
                        page_dup_rmap(ptepage, true);
                        set_huge_pte_at(dst, addr, dst_pte, entry);
-                       hugetlb_count_add(pages_per_huge_page(h), dst);
+                       hugetlb_count_add(npages, dst);
                }
                spin_unlock(src_ptl);
                spin_unlock(dst_ptl);
index 9902648f2206f0cd977986509f5cd8a7ba1771bc..1432feec62df09038a04f7b4348041f5c169ae42 100644 (file)
@@ -296,11 +296,6 @@ static inline unsigned int buddy_order(struct page *page)
  */
 #define buddy_order_unsafe(page)       READ_ONCE(page_private(page))
 
-static inline bool is_cow_mapping(vm_flags_t flags)
-{
-       return (flags & (VM_SHARED | VM_MAYWRITE)) == VM_MAYWRITE;
-}
-
 /*
  * These three helpers classifies VMAs for virtual memory accounting.
  */
index ab83d5a59bb124f1a0e3bccad8a55e0b5660aaba..e3f71451ad9e27485eed09e4049fa5dbac6bc02d 100644 (file)
 
 #include "kfence.h"
 
+/* May be overridden by <asm/kfence.h>. */
+#ifndef ARCH_FUNC_PREFIX
+#define ARCH_FUNC_PREFIX ""
+#endif
+
 extern bool no_hash_pointers;
 
 /* Helper function to either print to a seq_file or to console. */
@@ -67,8 +72,9 @@ static int get_stack_skipnr(const unsigned long stack_entries[], int num_entries
        for (skipnr = 0; skipnr < num_entries; skipnr++) {
                int len = scnprintf(buf, sizeof(buf), "%ps", (void *)stack_entries[skipnr]);
 
-               if (str_has_prefix(buf, "kfence_") || str_has_prefix(buf, "__kfence_") ||
-                   !strncmp(buf, "__slab_free", len)) {
+               if (str_has_prefix(buf, ARCH_FUNC_PREFIX "kfence_") ||
+                   str_has_prefix(buf, ARCH_FUNC_PREFIX "__kfence_") ||
+                   !strncmp(buf, ARCH_FUNC_PREFIX "__slab_free", len)) {
                        /*
                         * In case of tail calls from any of the below
                         * to any of the above.
@@ -77,10 +83,10 @@ static int get_stack_skipnr(const unsigned long stack_entries[], int num_entries
                }
 
                /* Also the *_bulk() variants by only checking prefixes. */
-               if (str_has_prefix(buf, "kfree") ||
-                   str_has_prefix(buf, "kmem_cache_free") ||
-                   str_has_prefix(buf, "__kmalloc") ||
-                   str_has_prefix(buf, "kmem_cache_alloc"))
+               if (str_has_prefix(buf, ARCH_FUNC_PREFIX "kfree") ||
+                   str_has_prefix(buf, ARCH_FUNC_PREFIX "kmem_cache_free") ||
+                   str_has_prefix(buf, ARCH_FUNC_PREFIX "__kmalloc") ||
+                   str_has_prefix(buf, ARCH_FUNC_PREFIX "kmem_cache_alloc"))
                        goto found;
        }
        if (fallback < num_entries)
@@ -116,12 +122,12 @@ void kfence_print_object(struct seq_file *seq, const struct kfence_metadata *met
        lockdep_assert_held(&meta->lock);
 
        if (meta->state == KFENCE_OBJECT_UNUSED) {
-               seq_con_printf(seq, "kfence-#%zd unused\n", meta - kfence_metadata);
+               seq_con_printf(seq, "kfence-#%td unused\n", meta - kfence_metadata);
                return;
        }
 
        seq_con_printf(seq,
-                      "kfence-#%zd [0x%p-0x%p"
+                      "kfence-#%td [0x%p-0x%p"
                       ", size=%d, cache=%s] allocated by task %d:\n",
                       meta - kfence_metadata, (void *)start, (void *)(start + size - 1), size,
                       (cache && cache->name) ? cache->name : "<destroyed>", meta->alloc_track.pid);
@@ -204,7 +210,7 @@ void kfence_report_error(unsigned long address, bool is_write, struct pt_regs *r
 
                pr_err("BUG: KFENCE: out-of-bounds %s in %pS\n\n", get_access_type(is_write),
                       (void *)stack_entries[skipnr]);
-               pr_err("Out-of-bounds %s at 0x%p (%luB %s of kfence-#%zd):\n",
+               pr_err("Out-of-bounds %s at 0x%p (%luB %s of kfence-#%td):\n",
                       get_access_type(is_write), (void *)address,
                       left_of_object ? meta->addr - address : address - meta->addr,
                       left_of_object ? "left" : "right", object_index);
@@ -213,14 +219,14 @@ void kfence_report_error(unsigned long address, bool is_write, struct pt_regs *r
        case KFENCE_ERROR_UAF:
                pr_err("BUG: KFENCE: use-after-free %s in %pS\n\n", get_access_type(is_write),
                       (void *)stack_entries[skipnr]);
-               pr_err("Use-after-free %s at 0x%p (in kfence-#%zd):\n",
+               pr_err("Use-after-free %s at 0x%p (in kfence-#%td):\n",
                       get_access_type(is_write), (void *)address, object_index);
                break;
        case KFENCE_ERROR_CORRUPTION:
                pr_err("BUG: KFENCE: memory corruption in %pS\n\n", (void *)stack_entries[skipnr]);
                pr_err("Corrupted memory at 0x%p ", (void *)address);
                print_diff_canary(address, 16, meta);
-               pr_cont(" (in kfence-#%zd):\n", object_index);
+               pr_cont(" (in kfence-#%td):\n", object_index);
                break;
        case KFENCE_ERROR_INVALID:
                pr_err("BUG: KFENCE: invalid %s in %pS\n\n", get_access_type(is_write),
@@ -230,7 +236,7 @@ void kfence_report_error(unsigned long address, bool is_write, struct pt_regs *r
                break;
        case KFENCE_ERROR_INVALID_FREE:
                pr_err("BUG: KFENCE: invalid free in %pS\n\n", (void *)stack_entries[skipnr]);
-               pr_err("Invalid free of 0x%p (in kfence-#%zd):\n", (void *)address,
+               pr_err("Invalid free of 0x%p (in kfence-#%td):\n", (void *)address,
                       object_index);
                break;
        }
index df692d2e35d4ae3a9b38caaa574fc14451d2504e..01fef79ac761bd73de0e0a28c82f001bba0d9a50 100644 (file)
@@ -1198,12 +1198,22 @@ SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec __user *, vec,
                goto release_task;
        }
 
-       mm = mm_access(task, PTRACE_MODE_ATTACH_FSCREDS);
+       /* Require PTRACE_MODE_READ to avoid leaking ASLR metadata. */
+       mm = mm_access(task, PTRACE_MODE_READ_FSCREDS);
        if (IS_ERR_OR_NULL(mm)) {
                ret = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
                goto release_task;
        }
 
+       /*
+        * Require CAP_SYS_NICE for influencing process performance. Note that
+        * only non-destructive hints are currently supported.
+        */
+       if (!capable(CAP_SYS_NICE)) {
+               ret = -EPERM;
+               goto release_mm;
+       }
+
        total_len = iov_iter_count(&iter);
 
        while (iov_iter_count(&iter)) {
@@ -1218,6 +1228,7 @@ SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec __user *, vec,
        if (ret == 0)
                ret = total_len - iov_iter_count(&iter);
 
+release_mm:
        mmput(mm);
 release_task:
        put_task_struct(task);
index 845eec01ef9d0dbe1392ee71ad0ec1e758fe85eb..e064ac0d850ac1cc968c8a11306e2b233c2ae706 100644 (file)
@@ -3287,24 +3287,21 @@ void obj_cgroup_uncharge(struct obj_cgroup *objcg, size_t size)
 
 #endif /* CONFIG_MEMCG_KMEM */
 
-#ifdef CONFIG_TRANSPARENT_HUGEPAGE
 /*
- * Because page_memcg(head) is not set on compound tails, set it now.
+ * Because page_memcg(head) is not set on tails, set it now.
  */
-void mem_cgroup_split_huge_fixup(struct page *head)
+void split_page_memcg(struct page *head, unsigned int nr)
 {
        struct mem_cgroup *memcg = page_memcg(head);
        int i;
 
-       if (mem_cgroup_disabled())
+       if (mem_cgroup_disabled() || !memcg)
                return;
 
-       for (i = 1; i < HPAGE_PMD_NR; i++) {
-               css_get(&memcg->css);
-               head[i].memcg_data = (unsigned long)memcg;
-       }
+       for (i = 1; i < nr; i++)
+               head[i].memcg_data = head->memcg_data;
+       css_get_many(&memcg->css, nr - 1);
 }
-#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
 
 #ifdef CONFIG_MEMCG_SWAP
 /**
index c8e357627318619a9aa7614354f60758b2b9e303..5efa07fb6cdc18c9189fc94a995716744218454a 100644 (file)
@@ -809,12 +809,8 @@ copy_present_page(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma
                  pte_t *dst_pte, pte_t *src_pte, unsigned long addr, int *rss,
                  struct page **prealloc, pte_t pte, struct page *page)
 {
-       struct mm_struct *src_mm = src_vma->vm_mm;
        struct page *new_page;
 
-       if (!is_cow_mapping(src_vma->vm_flags))
-               return 1;
-
        /*
         * What we want to do is to check whether this page may
         * have been pinned by the parent process.  If so,
@@ -828,9 +824,7 @@ copy_present_page(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma
         * the page count. That might give false positives for
         * for pinning, but it will work correctly.
         */
-       if (likely(!atomic_read(&src_mm->has_pinned)))
-               return 1;
-       if (likely(!page_maybe_dma_pinned(page)))
+       if (likely(!page_needs_cow_for_dma(src_vma, page)))
                return 1;
 
        new_page = *prealloc;
@@ -3103,6 +3097,14 @@ static vm_fault_t do_wp_page(struct vm_fault *vmf)
                return handle_userfault(vmf, VM_UFFD_WP);
        }
 
+       /*
+        * Userfaultfd write-protect can defer flushes. Ensure the TLB
+        * is flushed in this case before copying.
+        */
+       if (unlikely(userfaultfd_wp(vmf->vma) &&
+                    mm_tlb_flush_pending(vmf->vma->vm_mm)))
+               flush_tlb_page(vmf->vma, vmf->address);
+
        vmf->page = vm_normal_page(vma, vmf->address, vmf->orig_pte);
        if (!vmf->page) {
                /*
index 5ba51a8bdaeb208c51eea97f95738c16d3b7e3bf..0cdbbfbc57572e4e12f71b660af93e29bb9022fe 100644 (file)
@@ -1072,7 +1072,7 @@ static int online_memory_block(struct memory_block *mem, void *arg)
  */
 int __ref add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags)
 {
-       struct mhp_params params = { .pgprot = PAGE_KERNEL };
+       struct mhp_params params = { .pgprot = pgprot_mhp(PAGE_KERNEL) };
        u64 start, size;
        bool new_node = false;
        int ret;
index 3e4b29ee2b1e4a40c03257cfc5141709499ee512..cfc72873961d9e7a1e499ed50784f9f5651cf7d0 100644 (file)
@@ -1281,6 +1281,12 @@ static __always_inline bool free_pages_prepare(struct page *page,
 
        kernel_poison_pages(page, 1 << order);
 
+       /*
+        * With hardware tag-based KASAN, memory tags must be set before the
+        * page becomes unavailable via debug_pagealloc or arch_free_page.
+        */
+       kasan_free_nondeferred_pages(page, order);
+
        /*
         * arch_free_page() can make the page's contents inaccessible.  s390
         * does this.  So nothing which can access the page's contents should
@@ -1290,8 +1296,6 @@ static __always_inline bool free_pages_prepare(struct page *page,
 
        debug_pagealloc_unmap_pages(page, 1 << order);
 
-       kasan_free_nondeferred_pages(page, order);
-
        return true;
 }
 
@@ -3310,6 +3314,7 @@ void split_page(struct page *page, unsigned int order)
        for (i = 1; i < (1 << order); i++)
                set_page_refcounted(page + i);
        split_page_owner(page, 1 << order);
+       split_page_memcg(page, 1 << order);
 }
 EXPORT_SYMBOL_GPL(split_page);
 
@@ -6259,12 +6264,65 @@ static void __meminit zone_init_free_lists(struct zone *zone)
        }
 }
 
+#if !defined(CONFIG_FLAT_NODE_MEM_MAP)
+/*
+ * Only struct pages that correspond to ranges defined by memblock.memory
+ * are zeroed and initialized by going through __init_single_page() during
+ * memmap_init_zone().
+ *
+ * But, there could be struct pages that correspond to holes in
+ * memblock.memory. This can happen because of the following reasons:
+ * - physical memory bank size is not necessarily the exact multiple of the
+ *   arbitrary section size
+ * - early reserved memory may not be listed in memblock.memory
+ * - memory layouts defined with memmap= kernel parameter may not align
+ *   nicely with memmap sections
+ *
+ * Explicitly initialize those struct pages so that:
+ * - PG_Reserved is set
+ * - zone and node links point to zone and node that span the page if the
+ *   hole is in the middle of a zone
+ * - zone and node links point to adjacent zone/node if the hole falls on
+ *   the zone boundary; the pages in such holes will be prepended to the
+ *   zone/node above the hole except for the trailing pages in the last
+ *   section that will be appended to the zone/node below.
+ */
+static u64 __meminit init_unavailable_range(unsigned long spfn,
+                                           unsigned long epfn,
+                                           int zone, int node)
+{
+       unsigned long pfn;
+       u64 pgcnt = 0;
+
+       for (pfn = spfn; pfn < epfn; pfn++) {
+               if (!pfn_valid(ALIGN_DOWN(pfn, pageblock_nr_pages))) {
+                       pfn = ALIGN_DOWN(pfn, pageblock_nr_pages)
+                               + pageblock_nr_pages - 1;
+                       continue;
+               }
+               __init_single_page(pfn_to_page(pfn), pfn, zone, node);
+               __SetPageReserved(pfn_to_page(pfn));
+               pgcnt++;
+       }
+
+       return pgcnt;
+}
+#else
+static inline u64 init_unavailable_range(unsigned long spfn, unsigned long epfn,
+                                        int zone, int node)
+{
+       return 0;
+}
+#endif
+
 void __meminit __weak memmap_init_zone(struct zone *zone)
 {
        unsigned long zone_start_pfn = zone->zone_start_pfn;
        unsigned long zone_end_pfn = zone_start_pfn + zone->spanned_pages;
        int i, nid = zone_to_nid(zone), zone_id = zone_idx(zone);
+       static unsigned long hole_pfn;
        unsigned long start_pfn, end_pfn;
+       u64 pgcnt = 0;
 
        for_each_mem_pfn_range(i, nid, &start_pfn, &end_pfn, NULL) {
                start_pfn = clamp(start_pfn, zone_start_pfn, zone_end_pfn);
@@ -6274,7 +6332,29 @@ void __meminit __weak memmap_init_zone(struct zone *zone)
                        memmap_init_range(end_pfn - start_pfn, nid,
                                        zone_id, start_pfn, zone_end_pfn,
                                        MEMINIT_EARLY, NULL, MIGRATE_MOVABLE);
+
+               if (hole_pfn < start_pfn)
+                       pgcnt += init_unavailable_range(hole_pfn, start_pfn,
+                                                       zone_id, nid);
+               hole_pfn = end_pfn;
        }
+
+#ifdef CONFIG_SPARSEMEM
+       /*
+        * Initialize the hole in the range [zone_end_pfn, section_end].
+        * If zone boundary falls in the middle of a section, this hole
+        * will be re-initialized during the call to this function for the
+        * higher zone.
+        */
+       end_pfn = round_up(zone_end_pfn, PAGES_PER_SECTION);
+       if (hole_pfn < end_pfn)
+               pgcnt += init_unavailable_range(hole_pfn, end_pfn,
+                                               zone_id, nid);
+#endif
+
+       if (pgcnt)
+               pr_info("  %s zone: %llu pages in unavailable ranges\n",
+                       zone->name, pgcnt);
 }
 
 static int zone_batchsize(struct zone *zone)
@@ -7071,88 +7151,6 @@ void __init free_area_init_memoryless_node(int nid)
        free_area_init_node(nid);
 }
 
-#if !defined(CONFIG_FLAT_NODE_MEM_MAP)
-/*
- * Initialize all valid struct pages in the range [spfn, epfn) and mark them
- * PageReserved(). Return the number of struct pages that were initialized.
- */
-static u64 __init init_unavailable_range(unsigned long spfn, unsigned long epfn)
-{
-       unsigned long pfn;
-       u64 pgcnt = 0;
-
-       for (pfn = spfn; pfn < epfn; pfn++) {
-               if (!pfn_valid(ALIGN_DOWN(pfn, pageblock_nr_pages))) {
-                       pfn = ALIGN_DOWN(pfn, pageblock_nr_pages)
-                               + pageblock_nr_pages - 1;
-                       continue;
-               }
-               /*
-                * Use a fake node/zone (0) for now. Some of these pages
-                * (in memblock.reserved but not in memblock.memory) will
-                * get re-initialized via reserve_bootmem_region() later.
-                */
-               __init_single_page(pfn_to_page(pfn), pfn, 0, 0);
-               __SetPageReserved(pfn_to_page(pfn));
-               pgcnt++;
-       }
-
-       return pgcnt;
-}
-
-/*
- * Only struct pages that are backed by physical memory are zeroed and
- * initialized by going through __init_single_page(). But, there are some
- * struct pages which are reserved in memblock allocator and their fields
- * may be accessed (for example page_to_pfn() on some configuration accesses
- * flags). We must explicitly initialize those struct pages.
- *
- * This function also addresses a similar issue where struct pages are left
- * uninitialized because the physical address range is not covered by
- * memblock.memory or memblock.reserved. That could happen when memblock
- * layout is manually configured via memmap=, or when the highest physical
- * address (max_pfn) does not end on a section boundary.
- */
-static void __init init_unavailable_mem(void)
-{
-       phys_addr_t start, end;
-       u64 i, pgcnt;
-       phys_addr_t next = 0;
-
-       /*
-        * Loop through unavailable ranges not covered by memblock.memory.
-        */
-       pgcnt = 0;
-       for_each_mem_range(i, &start, &end) {
-               if (next < start)
-                       pgcnt += init_unavailable_range(PFN_DOWN(next),
-                                                       PFN_UP(start));
-               next = end;
-       }
-
-       /*
-        * Early sections always have a fully populated memmap for the whole
-        * section - see pfn_valid(). If the last section has holes at the
-        * end and that section is marked "online", the memmap will be
-        * considered initialized. Make sure that memmap has a well defined
-        * state.
-        */
-       pgcnt += init_unavailable_range(PFN_DOWN(next),
-                                       round_up(max_pfn, PAGES_PER_SECTION));
-
-       /*
-        * Struct pages that do not have backing memory. This could be because
-        * firmware is using some of this memory, or for some other reasons.
-        */
-       if (pgcnt)
-               pr_info("Zeroed struct page in unavailable ranges: %lld pages", pgcnt);
-}
-#else
-static inline void __init init_unavailable_mem(void)
-{
-}
-#endif /* !CONFIG_FLAT_NODE_MEM_MAP */
-
 #if MAX_NUMNODES > 1
 /*
  * Figure out the number of possible node ids.
@@ -7576,7 +7574,6 @@ void __init free_area_init(unsigned long *max_zone_pfn)
        /* Initialise every node */
        mminit_verify_pageflags_layout();
        setup_nr_node_ids();
-       init_unavailable_mem();
        for_each_online_node(nid) {
                pg_data_t *pgdat = NODE_DATA(nid);
                free_area_init_node(nid);
index 51fd424e0d6d03bc0f16338aee251bc47c60249e..ae651bf540b7033180c37221bdb4c2a4842d98fa 100644 (file)
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -2992,7 +2992,7 @@ static void *cache_alloc_debugcheck_after(struct kmem_cache *cachep,
                                gfp_t flags, void *objp, unsigned long caller)
 {
        WARN_ON_ONCE(cachep->ctor && (flags & __GFP_ZERO));
-       if (!objp)
+       if (!objp || is_kfence_address(objp))
                return objp;
        if (cachep->flags & SLAB_POISON) {
                check_poison_obj(cachep, objp);
index e26c274b4657f2a164643ffca3c7607f496b13d5..3021ce9bf1b3d704f6ade2300827a3178a2ae205 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1993,7 +1993,7 @@ static void *get_partial_node(struct kmem_cache *s, struct kmem_cache_node *n,
 
                t = acquire_slab(s, n, page, object == NULL, &objects);
                if (!t)
-                       continue; /* cmpxchg raced */
+                       break;
 
                available += objects;
                if (!object) {
index 4f62f299da0cfdbd99fa9a08b60c4aec891eccdf..0a9019da18f3956106d024ce1920d1ea27117500 100644 (file)
@@ -1623,10 +1623,6 @@ p9_client_read_once(struct p9_fid *fid, u64 offset, struct iov_iter *to,
        }
 
        p9_debug(P9_DEBUG_9P, "<<< RREAD count %d\n", count);
-       if (!count) {
-               p9_tag_remove(clnt, req);
-               return 0;
-       }
 
        if (non_zc) {
                int n = copy_to_iter(dataptr, count, to);
index e48f7ac8a854ccea054d70a26e90f58825bdcf52..3ddd66e4c29ef532de33c7182cc0cc470b33fd4f 100644 (file)
@@ -702,7 +702,6 @@ MODULE_LICENSE("GPL");
 
 MODULE_AUTHOR(BATADV_DRIVER_AUTHOR);
 MODULE_DESCRIPTION(BATADV_DRIVER_DESC);
-MODULE_SUPPORTED_DEVICE(BATADV_DRIVER_DEVICE);
 MODULE_VERSION(BATADV_SOURCE_VERSION);
 MODULE_ALIAS_RTNL_LINK("batadv");
 MODULE_ALIAS_GENL_FAMILY(BATADV_NL_NAME);
index 0edc0b2baaa433938883bee99ae90c9fca9663bd..1bdcb33fb561994472a7dde6b9a3c992a300bb87 100644 (file)
@@ -2147,7 +2147,7 @@ out:
 out_err:
        cb->args[1] = idx;
        cb->args[0] = h;
-       cb->seq = net->dev_base_seq;
+       cb->seq = tgt_net->dev_base_seq;
        nl_dump_check_consistent(cb, nlmsg_hdr(skb));
        if (netnsid >= 0)
                put_net(tgt_net);
index 545a472273a50387b0701d372d5f29db16385b0e..c421c8f809256f7b13a8b5a1331108449353ee2d 100644 (file)
@@ -3659,6 +3659,8 @@ unsigned int skb_find_text(struct sk_buff *skb, unsigned int from,
        struct ts_state state;
        unsigned int ret;
 
+       BUILD_BUG_ON(sizeof(struct skb_seq_state) > sizeof(state.cb));
+
        config->get_next_block = skb_ts_get_next_block;
        config->finish = skb_ts_finish;
 
index 3589224c8da9699fd474cc820fd9db8355be339a..58b8fc82cd3c4b833f9a3badf4e22b256f909fe1 100644 (file)
@@ -118,6 +118,8 @@ config NET_DSA_TAG_OCELOT
 
 config NET_DSA_TAG_OCELOT_8021Q
        tristate "Tag driver for Ocelot family of switches, using VLAN"
+       depends on MSCC_OCELOT_SWITCH_LIB || \
+                 (MSCC_OCELOT_SWITCH_LIB=n && COMPILE_TEST)
        select NET_DSA_TAG_8021Q
        help
          Say Y or M if you want to enable support for tagging frames with a
index 2eeaa42f2e083aa1287cd34ba2fbd582e0cb6d88..9d4b0e9b1aa1e3e720ee51670b7558d7ab79122c 100644 (file)
@@ -230,8 +230,8 @@ int dsa_port_hsr_join(struct dsa_port *dp, struct net_device *hsr);
 void dsa_port_hsr_leave(struct dsa_port *dp, struct net_device *hsr);
 extern const struct phylink_mac_ops dsa_port_phylink_mac_ops;
 
-static inline bool dsa_port_offloads_netdev(struct dsa_port *dp,
-                                           struct net_device *dev)
+static inline bool dsa_port_offloads_bridge_port(struct dsa_port *dp,
+                                                struct net_device *dev)
 {
        /* Switchdev offloading can be configured on: */
 
@@ -241,12 +241,6 @@ static inline bool dsa_port_offloads_netdev(struct dsa_port *dp,
                 */
                return true;
 
-       if (dp->bridge_dev == dev)
-               /* DSA ports connected to a bridge, and event was emitted
-                * for the bridge.
-                */
-               return true;
-
        if (dp->lag_dev == dev)
                /* DSA ports connected to a bridge via a LAG */
                return true;
@@ -254,14 +248,23 @@ static inline bool dsa_port_offloads_netdev(struct dsa_port *dp,
        return false;
 }
 
+static inline bool dsa_port_offloads_bridge(struct dsa_port *dp,
+                                           struct net_device *bridge_dev)
+{
+       /* DSA ports connected to a bridge, and event was emitted
+        * for the bridge.
+        */
+       return dp->bridge_dev == bridge_dev;
+}
+
 /* Returns true if any port of this tree offloads the given net_device */
-static inline bool dsa_tree_offloads_netdev(struct dsa_switch_tree *dst,
-                                           struct net_device *dev)
+static inline bool dsa_tree_offloads_bridge_port(struct dsa_switch_tree *dst,
+                                                struct net_device *dev)
 {
        struct dsa_port *dp;
 
        list_for_each_entry(dp, &dst->ports, list)
-               if (dsa_port_offloads_netdev(dp, dev))
+               if (dsa_port_offloads_bridge_port(dp, dev))
                        return true;
 
        return false;
index 491e3761b5f4a443ec76e077a6fcff97ee6e9c49..992fcab4b55293e6629ea079d48766fa246b733c 100644 (file)
@@ -278,28 +278,43 @@ static int dsa_slave_port_attr_set(struct net_device *dev,
        struct dsa_port *dp = dsa_slave_to_port(dev);
        int ret;
 
-       if (!dsa_port_offloads_netdev(dp, attr->orig_dev))
-               return -EOPNOTSUPP;
-
        switch (attr->id) {
        case SWITCHDEV_ATTR_ID_PORT_STP_STATE:
+               if (!dsa_port_offloads_bridge_port(dp, attr->orig_dev))
+                       return -EOPNOTSUPP;
+
                ret = dsa_port_set_state(dp, attr->u.stp_state);
                break;
        case SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING:
+               if (!dsa_port_offloads_bridge(dp, attr->orig_dev))
+                       return -EOPNOTSUPP;
+
                ret = dsa_port_vlan_filtering(dp, attr->u.vlan_filtering,
                                              extack);
                break;
        case SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME:
+               if (!dsa_port_offloads_bridge(dp, attr->orig_dev))
+                       return -EOPNOTSUPP;
+
                ret = dsa_port_ageing_time(dp, attr->u.ageing_time);
                break;
        case SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS:
+               if (!dsa_port_offloads_bridge_port(dp, attr->orig_dev))
+                       return -EOPNOTSUPP;
+
                ret = dsa_port_pre_bridge_flags(dp, attr->u.brport_flags,
                                                extack);
                break;
        case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS:
+               if (!dsa_port_offloads_bridge_port(dp, attr->orig_dev))
+                       return -EOPNOTSUPP;
+
                ret = dsa_port_bridge_flags(dp, attr->u.brport_flags, extack);
                break;
        case SWITCHDEV_ATTR_ID_BRIDGE_MROUTER:
+               if (!dsa_port_offloads_bridge(dp, attr->orig_dev))
+                       return -EOPNOTSUPP;
+
                ret = dsa_port_mrouter(dp->cpu_dp, attr->u.mrouter, extack);
                break;
        default:
@@ -341,9 +356,6 @@ static int dsa_slave_vlan_add(struct net_device *dev,
        struct switchdev_obj_port_vlan vlan;
        int err;
 
-       if (!dsa_port_offloads_netdev(dp, obj->orig_dev))
-               return -EOPNOTSUPP;
-
        if (dsa_port_skip_vlan_configuration(dp)) {
                NL_SET_ERR_MSG_MOD(extack, "skipping configuration of VLAN");
                return 0;
@@ -391,27 +403,36 @@ static int dsa_slave_port_obj_add(struct net_device *dev,
 
        switch (obj->id) {
        case SWITCHDEV_OBJ_ID_PORT_MDB:
-               if (!dsa_port_offloads_netdev(dp, obj->orig_dev))
+               if (!dsa_port_offloads_bridge_port(dp, obj->orig_dev))
                        return -EOPNOTSUPP;
+
                err = dsa_port_mdb_add(dp, SWITCHDEV_OBJ_PORT_MDB(obj));
                break;
        case SWITCHDEV_OBJ_ID_HOST_MDB:
+               if (!dsa_port_offloads_bridge(dp, obj->orig_dev))
+                       return -EOPNOTSUPP;
+
                /* DSA can directly translate this to a normal MDB add,
                 * but on the CPU port.
                 */
                err = dsa_port_mdb_add(dp->cpu_dp, SWITCHDEV_OBJ_PORT_MDB(obj));
                break;
        case SWITCHDEV_OBJ_ID_PORT_VLAN:
+               if (!dsa_port_offloads_bridge_port(dp, obj->orig_dev))
+                       return -EOPNOTSUPP;
+
                err = dsa_slave_vlan_add(dev, obj, extack);
                break;
        case SWITCHDEV_OBJ_ID_MRP:
-               if (!dsa_port_offloads_netdev(dp, obj->orig_dev))
+               if (!dsa_port_offloads_bridge(dp, obj->orig_dev))
                        return -EOPNOTSUPP;
+
                err = dsa_port_mrp_add(dp, SWITCHDEV_OBJ_MRP(obj));
                break;
        case SWITCHDEV_OBJ_ID_RING_ROLE_MRP:
-               if (!dsa_port_offloads_netdev(dp, obj->orig_dev))
+               if (!dsa_port_offloads_bridge(dp, obj->orig_dev))
                        return -EOPNOTSUPP;
+
                err = dsa_port_mrp_add_ring_role(dp,
                                                 SWITCHDEV_OBJ_RING_ROLE_MRP(obj));
                break;
@@ -431,9 +452,6 @@ static int dsa_slave_vlan_del(struct net_device *dev,
        struct switchdev_obj_port_vlan *vlan;
        int err;
 
-       if (!dsa_port_offloads_netdev(dp, obj->orig_dev))
-               return -EOPNOTSUPP;
-
        if (dsa_port_skip_vlan_configuration(dp))
                return 0;
 
@@ -459,27 +477,36 @@ static int dsa_slave_port_obj_del(struct net_device *dev,
 
        switch (obj->id) {
        case SWITCHDEV_OBJ_ID_PORT_MDB:
-               if (!dsa_port_offloads_netdev(dp, obj->orig_dev))
+               if (!dsa_port_offloads_bridge_port(dp, obj->orig_dev))
                        return -EOPNOTSUPP;
+
                err = dsa_port_mdb_del(dp, SWITCHDEV_OBJ_PORT_MDB(obj));
                break;
        case SWITCHDEV_OBJ_ID_HOST_MDB:
+               if (!dsa_port_offloads_bridge(dp, obj->orig_dev))
+                       return -EOPNOTSUPP;
+
                /* DSA can directly translate this to a normal MDB add,
                 * but on the CPU port.
                 */
                err = dsa_port_mdb_del(dp->cpu_dp, SWITCHDEV_OBJ_PORT_MDB(obj));
                break;
        case SWITCHDEV_OBJ_ID_PORT_VLAN:
+               if (!dsa_port_offloads_bridge_port(dp, obj->orig_dev))
+                       return -EOPNOTSUPP;
+
                err = dsa_slave_vlan_del(dev, obj);
                break;
        case SWITCHDEV_OBJ_ID_MRP:
-               if (!dsa_port_offloads_netdev(dp, obj->orig_dev))
+               if (!dsa_port_offloads_bridge(dp, obj->orig_dev))
                        return -EOPNOTSUPP;
+
                err = dsa_port_mrp_del(dp, SWITCHDEV_OBJ_MRP(obj));
                break;
        case SWITCHDEV_OBJ_ID_RING_ROLE_MRP:
-               if (!dsa_port_offloads_netdev(dp, obj->orig_dev))
+               if (!dsa_port_offloads_bridge(dp, obj->orig_dev))
                        return -EOPNOTSUPP;
+
                err = dsa_port_mrp_del_ring_role(dp,
                                                 SWITCHDEV_OBJ_RING_ROLE_MRP(obj));
                break;
@@ -2298,7 +2325,7 @@ static int dsa_slave_switchdev_event(struct notifier_block *unused,
                         * other ports bridged with the LAG should be able to
                         * autonomously forward towards it.
                         */
-                       if (dsa_tree_offloads_netdev(dp->ds->dst, dev))
+                       if (dsa_tree_offloads_bridge_port(dp->ds->dst, dev))
                                return NOTIFY_DONE;
                }
 
index 38dcdded74c0524ab984468d64a16469dc91ed06..59748487664fe8e118b8c181b9caf9bc7ace65a9 100644 (file)
@@ -13,6 +13,7 @@
 #define MTK_HDR_LEN            4
 #define MTK_HDR_XMIT_UNTAGGED          0
 #define MTK_HDR_XMIT_TAGGED_TPID_8100  1
+#define MTK_HDR_XMIT_TAGGED_TPID_88A8  2
 #define MTK_HDR_RECV_SOURCE_PORT_MASK  GENMASK(2, 0)
 #define MTK_HDR_XMIT_DP_BIT_MASK       GENMASK(5, 0)
 #define MTK_HDR_XMIT_SA_DIS            BIT(6)
@@ -21,8 +22,8 @@ static struct sk_buff *mtk_tag_xmit(struct sk_buff *skb,
                                    struct net_device *dev)
 {
        struct dsa_port *dp = dsa_slave_to_port(dev);
+       u8 xmit_tpid;
        u8 *mtk_tag;
-       bool is_vlan_skb = true;
        unsigned char *dest = eth_hdr(skb)->h_dest;
        bool is_multicast_skb = is_multicast_ether_addr(dest) &&
                                !is_broadcast_ether_addr(dest);
@@ -33,10 +34,17 @@ static struct sk_buff *mtk_tag_xmit(struct sk_buff *skb,
         * the both special and VLAN tag at the same time and then look up VLAN
         * table with VID.
         */
-       if (!skb_vlan_tagged(skb)) {
+       switch (skb->protocol) {
+       case htons(ETH_P_8021Q):
+               xmit_tpid = MTK_HDR_XMIT_TAGGED_TPID_8100;
+               break;
+       case htons(ETH_P_8021AD):
+               xmit_tpid = MTK_HDR_XMIT_TAGGED_TPID_88A8;
+               break;
+       default:
+               xmit_tpid = MTK_HDR_XMIT_UNTAGGED;
                skb_push(skb, MTK_HDR_LEN);
                memmove(skb->data, skb->data + MTK_HDR_LEN, 2 * ETH_ALEN);
-               is_vlan_skb = false;
        }
 
        mtk_tag = skb->data + 2 * ETH_ALEN;
@@ -44,8 +52,7 @@ static struct sk_buff *mtk_tag_xmit(struct sk_buff *skb,
        /* Mark tag attribute on special tag insertion to notify hardware
         * whether that's a combined special tag with 802.1Q header.
         */
-       mtk_tag[0] = is_vlan_skb ? MTK_HDR_XMIT_TAGGED_TPID_8100 :
-                    MTK_HDR_XMIT_UNTAGGED;
+       mtk_tag[0] = xmit_tpid;
        mtk_tag[1] = (1 << dp->index) & MTK_HDR_XMIT_DP_BIT_MASK;
 
        /* Disable SA learning for multicast frames */
@@ -53,7 +60,7 @@ static struct sk_buff *mtk_tag_xmit(struct sk_buff *skb,
                mtk_tag[1] |= MTK_HDR_XMIT_SA_DIS;
 
        /* Tag control information is kept for 802.1Q */
-       if (!is_vlan_skb) {
+       if (xmit_tpid == MTK_HDR_XMIT_UNTAGGED) {
                mtk_tag[2] = 0;
                mtk_tag[3] = 0;
        }
index c17d39b4a1a04826fc9d631679d41ec62e4fb979..e9176475bac89541cd49581403881009d3b6dd4b 100644 (file)
@@ -35,14 +35,12 @@ static struct sk_buff *rtl4a_tag_xmit(struct sk_buff *skb,
                                      struct net_device *dev)
 {
        struct dsa_port *dp = dsa_slave_to_port(dev);
+       __be16 *p;
        u8 *tag;
-       u16 *p;
        u16 out;
 
        /* Pad out to at least 60 bytes */
-       if (unlikely(eth_skb_pad(skb)))
-               return NULL;
-       if (skb_cow_head(skb, RTL4_A_HDR_LEN) < 0)
+       if (unlikely(__skb_put_padto(skb, ETH_ZLEN, false)))
                return NULL;
 
        netdev_dbg(dev, "add realtek tag to package to port %d\n",
@@ -53,13 +51,13 @@ static struct sk_buff *rtl4a_tag_xmit(struct sk_buff *skb,
        tag = skb->data + 2 * ETH_ALEN;
 
        /* Set Ethertype */
-       p = (u16 *)tag;
+       p = (__be16 *)tag;
        *p = htons(RTL4_A_ETHERTYPE);
 
        out = (RTL4_A_PROTOCOL_RTL8366RB << 12) | (2 << 8);
-       /* The lower bits is the port numer */
+       /* The lower bits is the port number */
        out |= (u8)dp->index;
-       p = (u16 *)(tag + 2);
+       p = (__be16 *)(tag + 2);
        *p = htons(out);
 
        return skb;
index 25a9e566ef5cdd45c3e1c460fb6bf1c3404b6b5c..6a070dc8e4b0dba90656d92f742320200c6bdfe3 100644 (file)
@@ -116,10 +116,9 @@ int ethnl_set_channels(struct sk_buff *skb, struct genl_info *info)
        struct ethtool_channels channels = {};
        struct ethnl_req_info req_info = {};
        struct nlattr **tb = info->attrs;
-       const struct nlattr *err_attr;
+       u32 err_attr, max_rx_in_use = 0;
        const struct ethtool_ops *ops;
        struct net_device *dev;
-       u32 max_rx_in_use = 0;
        int ret;
 
        ret = ethnl_parse_header_dev_get(&req_info,
@@ -157,34 +156,35 @@ int ethnl_set_channels(struct sk_buff *skb, struct genl_info *info)
 
        /* ensure new channel counts are within limits */
        if (channels.rx_count > channels.max_rx)
-               err_attr = tb[ETHTOOL_A_CHANNELS_RX_COUNT];
+               err_attr = ETHTOOL_A_CHANNELS_RX_COUNT;
        else if (channels.tx_count > channels.max_tx)
-               err_attr = tb[ETHTOOL_A_CHANNELS_TX_COUNT];
+               err_attr = ETHTOOL_A_CHANNELS_TX_COUNT;
        else if (channels.other_count > channels.max_other)
-               err_attr = tb[ETHTOOL_A_CHANNELS_OTHER_COUNT];
+               err_attr = ETHTOOL_A_CHANNELS_OTHER_COUNT;
        else if (channels.combined_count > channels.max_combined)
-               err_attr = tb[ETHTOOL_A_CHANNELS_COMBINED_COUNT];
+               err_attr = ETHTOOL_A_CHANNELS_COMBINED_COUNT;
        else
-               err_attr = NULL;
+               err_attr = 0;
        if (err_attr) {
                ret = -EINVAL;
-               NL_SET_ERR_MSG_ATTR(info->extack, err_attr,
+               NL_SET_ERR_MSG_ATTR(info->extack, tb[err_attr],
                                    "requested channel count exceeds maximum");
                goto out_ops;
        }
 
        /* ensure there is at least one RX and one TX channel */
        if (!channels.combined_count && !channels.rx_count)
-               err_attr = tb[ETHTOOL_A_CHANNELS_RX_COUNT];
+               err_attr = ETHTOOL_A_CHANNELS_RX_COUNT;
        else if (!channels.combined_count && !channels.tx_count)
-               err_attr = tb[ETHTOOL_A_CHANNELS_TX_COUNT];
+               err_attr = ETHTOOL_A_CHANNELS_TX_COUNT;
        else
-               err_attr = NULL;
+               err_attr = 0;
        if (err_attr) {
                if (mod_combined)
-                       err_attr = tb[ETHTOOL_A_CHANNELS_COMBINED_COUNT];
+                       err_attr = ETHTOOL_A_CHANNELS_COMBINED_COUNT;
                ret = -EINVAL;
-               NL_SET_ERR_MSG_ATTR(info->extack, err_attr, "requested channel counts would result in no RX or TX channel being configured");
+               NL_SET_ERR_MSG_ATTR(info->extack, tb[err_attr],
+                                   "requested channel counts would result in no RX or TX channel being configured");
                goto out_ops;
        }
 
index 471d33a0d095fc32b8a8303124bc6718acdb207d..bfaf327e9d1214af9d1952ca68dde9c30a878199 100644 (file)
@@ -519,16 +519,10 @@ int cipso_v4_doi_remove(u32 doi, struct netlbl_audit *audit_info)
                ret_val = -ENOENT;
                goto doi_remove_return;
        }
-       if (!refcount_dec_and_test(&doi_def->refcount)) {
-               spin_unlock(&cipso_v4_doi_list_lock);
-               ret_val = -EBUSY;
-               goto doi_remove_return;
-       }
        list_del_rcu(&doi_def->list);
        spin_unlock(&cipso_v4_doi_list_lock);
 
-       cipso_v4_cache_invalidate();
-       call_rcu(&doi_def->rcu, cipso_v4_doi_free_rcu);
+       cipso_v4_doi_putdef(doi_def);
        ret_val = 0;
 
 doi_remove_return:
@@ -585,9 +579,6 @@ void cipso_v4_doi_putdef(struct cipso_v4_doi *doi_def)
 
        if (!refcount_dec_and_test(&doi_def->refcount))
                return;
-       spin_lock(&cipso_v4_doi_list_lock);
-       list_del_rcu(&doi_def->list);
-       spin_unlock(&cipso_v4_doi_list_lock);
 
        cipso_v4_cache_invalidate();
        call_rcu(&doi_def->rcu, cipso_v4_doi_free_rcu);
@@ -1162,7 +1153,7 @@ static void cipso_v4_gentag_hdr(const struct cipso_v4_doi *doi_def,
 {
        buf[0] = IPOPT_CIPSO;
        buf[1] = CIPSO_V4_HDR_LEN + len;
-       *(__be32 *)&buf[2] = htonl(doi_def->doi);
+       put_unaligned_be32(doi_def->doi, &buf[2]);
 }
 
 /**
index ff327a62c9ce9b1794104c3c924f5f2b9820ac8b..da21dfce24d7390bdc51899e03a0c7b3efbc3cec 100644 (file)
@@ -65,7 +65,7 @@ EXPORT_SYMBOL_GPL(inet_peer_base_init);
 #define PEER_MAX_GC 32
 
 /* Exported for sysctl_net_ipv4.  */
-int inet_peer_threshold __read_mostly = 65536 + 128;   /* start to throw entries more
+int inet_peer_threshold __read_mostly; /* start to throw entries more
                                         * aggressively at this stage */
 int inet_peer_minttl __read_mostly = 120 * HZ; /* TTL under high load: 120 sec */
 int inet_peer_maxttl __read_mostly = 10 * 60 * HZ;     /* usual time to live: 10 min */
@@ -73,20 +73,13 @@ int inet_peer_maxttl __read_mostly = 10 * 60 * HZ;  /* usual time to live: 10 min
 /* Called from ip_output.c:ip_init  */
 void __init inet_initpeers(void)
 {
-       struct sysinfo si;
+       u64 nr_entries;
 
-       /* Use the straight interface to information about memory. */
-       si_meminfo(&si);
-       /* The values below were suggested by Alexey Kuznetsov
-        * <kuznet@ms2.inr.ac.ru>.  I don't have any opinion about the values
-        * myself.  --SAW
-        */
-       if (si.totalram <= (32768*1024)/PAGE_SIZE)
-               inet_peer_threshold >>= 1; /* max pool size about 1MB on IA32 */
-       if (si.totalram <= (16384*1024)/PAGE_SIZE)
-               inet_peer_threshold >>= 1; /* about 512KB */
-       if (si.totalram <= (8192*1024)/PAGE_SIZE)
-               inet_peer_threshold >>= 2; /* about 128KB */
+        /* 1% of physical memory */
+       nr_entries = div64_ul((u64)totalram_pages() << PAGE_SHIFT,
+                             100 * L1_CACHE_ALIGN(sizeof(struct inet_peer)));
+
+       inet_peer_threshold = clamp_val(nr_entries, 4096, 65536 + 128);
 
        peer_cachep = kmem_cache_create("inet_peer_cache",
                        sizeof(struct inet_peer),
index 76a420c76f16e701d36e0ffe235fc19e0ccd8235..f6cc26de5ed304e0d70bce9444bb4201b6172c11 100644 (file)
@@ -502,8 +502,7 @@ static int tnl_update_pmtu(struct net_device *dev, struct sk_buff *skb,
                if (!skb_is_gso(skb) &&
                    (inner_iph->frag_off & htons(IP_DF)) &&
                    mtu < pkt_size) {
-                       memset(IPCB(skb), 0, sizeof(*IPCB(skb)));
-                       icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, htonl(mtu));
+                       icmp_ndo_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, htonl(mtu));
                        return -E2BIG;
                }
        }
@@ -527,7 +526,7 @@ static int tnl_update_pmtu(struct net_device *dev, struct sk_buff *skb,
 
                if (!skb_is_gso(skb) && mtu >= IPV6_MIN_MTU &&
                                        mtu < pkt_size) {
-                       icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
+                       icmpv6_ndo_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
                        return -E2BIG;
                }
        }
index abc171e79d3e4f755182be054a6f948e20903c2d..eb207089ece0b29bbb96dd66544be79133be2ecc 100644 (file)
@@ -238,13 +238,13 @@ static netdev_tx_t vti_xmit(struct sk_buff *skb, struct net_device *dev,
        if (skb->len > mtu) {
                skb_dst_update_pmtu_no_confirm(skb, mtu);
                if (skb->protocol == htons(ETH_P_IP)) {
-                       icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
-                                 htonl(mtu));
+                       icmp_ndo_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
+                                     htonl(mtu));
                } else {
                        if (mtu < IPV6_MIN_MTU)
                                mtu = IPV6_MIN_MTU;
 
-                       icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
+                       icmpv6_ndo_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
                }
 
                dst_release(dst);
index f1c6cbdb9e43648dc1664ecb65cb9f05eeb1e673..743777bce179481ce46536e6b7ca866a2d7f7fbf 100644 (file)
@@ -1399,7 +1399,7 @@ out:
 
 /* rtnl */
 /* remove all nexthops tied to a device being deleted */
-static void nexthop_flush_dev(struct net_device *dev)
+static void nexthop_flush_dev(struct net_device *dev, unsigned long event)
 {
        unsigned int hash = nh_dev_hashfn(dev->ifindex);
        struct net *net = dev_net(dev);
@@ -1411,6 +1411,10 @@ static void nexthop_flush_dev(struct net_device *dev)
                if (nhi->fib_nhc.nhc_dev != dev)
                        continue;
 
+               if (nhi->reject_nh &&
+                   (event == NETDEV_DOWN || event == NETDEV_CHANGE))
+                       continue;
+
                remove_nexthop(net, nhi->nh_parent, NULL);
        }
 }
@@ -2189,11 +2193,11 @@ static int nh_netdev_event(struct notifier_block *this,
        switch (event) {
        case NETDEV_DOWN:
        case NETDEV_UNREGISTER:
-               nexthop_flush_dev(dev);
+               nexthop_flush_dev(dev, event);
                break;
        case NETDEV_CHANGE:
                if (!(dev_get_flags(dev) & (IFF_RUNNING | IFF_LOWER_UP)))
-                       nexthop_flush_dev(dev);
+                       nexthop_flush_dev(dev, event);
                break;
        case NETDEV_CHANGEMTU:
                info_ext = ptr;
index a3422e42784edfedeecd7e9cfe6ed68990c90957..de7cc8445ac035ff2f7d17b93acabd7342144da8 100644 (file)
@@ -3469,16 +3469,23 @@ static int do_tcp_setsockopt(struct sock *sk, int level, int optname,
                break;
 
        case TCP_QUEUE_SEQ:
-               if (sk->sk_state != TCP_CLOSE)
+               if (sk->sk_state != TCP_CLOSE) {
                        err = -EPERM;
-               else if (tp->repair_queue == TCP_SEND_QUEUE)
-                       WRITE_ONCE(tp->write_seq, val);
-               else if (tp->repair_queue == TCP_RECV_QUEUE) {
-                       WRITE_ONCE(tp->rcv_nxt, val);
-                       WRITE_ONCE(tp->copied_seq, val);
-               }
-               else
+               } else if (tp->repair_queue == TCP_SEND_QUEUE) {
+                       if (!tcp_rtx_queue_empty(sk))
+                               err = -EPERM;
+                       else
+                               WRITE_ONCE(tp->write_seq, val);
+               } else if (tp->repair_queue == TCP_RECV_QUEUE) {
+                       if (tp->rcv_nxt != tp->copied_seq) {
+                               err = -EPERM;
+                       } else {
+                               WRITE_ONCE(tp->rcv_nxt, val);
+                               WRITE_ONCE(tp->copied_seq, val);
+                       }
+               } else {
                        err = -EINVAL;
+               }
                break;
 
        case TCP_REPAIR_OPTIONS:
@@ -4143,7 +4150,8 @@ static int do_tcp_getsockopt(struct sock *sk, int level,
 
                if (get_user(len, optlen))
                        return -EFAULT;
-               if (len < offsetofend(struct tcp_zerocopy_receive, length))
+               if (len < 0 ||
+                   len < offsetofend(struct tcp_zerocopy_receive, length))
                        return -EINVAL;
                if (unlikely(len > sizeof(zc))) {
                        err = check_zeroed_user(optval + sizeof(zc),
index b76c48efd37ee5f7de8a15ad5ea791b2f3fee625..c5b4b586570feab5bea5303ab55097727d69dd90 100644 (file)
@@ -526,7 +526,7 @@ struct sk_buff *udp_gro_receive(struct list_head *head, struct sk_buff *skb,
        }
 
        if (!sk || NAPI_GRO_CB(skb)->encap_mark ||
-           (skb->ip_summed != CHECKSUM_PARTIAL &&
+           (uh->check && skb->ip_summed != CHECKSUM_PARTIAL &&
             NAPI_GRO_CB(skb)->csum_cnt == 0 &&
             !NAPI_GRO_CB(skb)->csum_valid) ||
            !udp_sk(sk)->gro_receive)
index 51184a70ac7e545c1c1d440a717c0b220ed420b7..1578ed9e97d892eab85514a21ceff9a4aa79b22d 100644 (file)
@@ -83,6 +83,9 @@ struct calipso_map_cache_entry {
 
 static struct calipso_map_cache_bkt *calipso_cache;
 
+static void calipso_cache_invalidate(void);
+static void calipso_doi_putdef(struct calipso_doi *doi_def);
+
 /* Label Mapping Cache Functions
  */
 
@@ -444,15 +447,10 @@ static int calipso_doi_remove(u32 doi, struct netlbl_audit *audit_info)
                ret_val = -ENOENT;
                goto doi_remove_return;
        }
-       if (!refcount_dec_and_test(&doi_def->refcount)) {
-               spin_unlock(&calipso_doi_list_lock);
-               ret_val = -EBUSY;
-               goto doi_remove_return;
-       }
        list_del_rcu(&doi_def->list);
        spin_unlock(&calipso_doi_list_lock);
 
-       call_rcu(&doi_def->rcu, calipso_doi_free_rcu);
+       calipso_doi_putdef(doi_def);
        ret_val = 0;
 
 doi_remove_return:
@@ -508,10 +506,8 @@ static void calipso_doi_putdef(struct calipso_doi *doi_def)
 
        if (!refcount_dec_and_test(&doi_def->refcount))
                return;
-       spin_lock(&calipso_doi_list_lock);
-       list_del_rcu(&doi_def->list);
-       spin_unlock(&calipso_doi_list_lock);
 
+       calipso_cache_invalidate();
        call_rcu(&doi_def->rcu, calipso_doi_free_rcu);
 }
 
index c3bc89b6b1a1afeb449fa29984450bbac2c81412..1baf43aacb2e4be20c7b2d7367b048bbb4c39c82 100644 (file)
@@ -678,8 +678,8 @@ static int prepare_ip6gre_xmit_ipv6(struct sk_buff *skb,
 
                tel = (struct ipv6_tlv_tnl_enc_lim *)&skb_network_header(skb)[offset];
                if (tel->encap_limit == 0) {
-                       icmpv6_send(skb, ICMPV6_PARAMPROB,
-                                   ICMPV6_HDR_FIELD, offset + 2);
+                       icmpv6_ndo_send(skb, ICMPV6_PARAMPROB,
+                                       ICMPV6_HDR_FIELD, offset + 2);
                        return -1;
                }
                *encap_limit = tel->encap_limit - 1;
@@ -805,8 +805,8 @@ static inline int ip6gre_xmit_ipv4(struct sk_buff *skb, struct net_device *dev)
        if (err != 0) {
                /* XXX: send ICMP error even if DF is not set. */
                if (err == -EMSGSIZE)
-                       icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
-                                 htonl(mtu));
+                       icmp_ndo_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
+                                     htonl(mtu));
                return -1;
        }
 
@@ -837,7 +837,7 @@ static inline int ip6gre_xmit_ipv6(struct sk_buff *skb, struct net_device *dev)
                          &mtu, skb->protocol);
        if (err != 0) {
                if (err == -EMSGSIZE)
-                       icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
+                       icmpv6_ndo_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
                return -1;
        }
 
@@ -1063,10 +1063,10 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
                /* XXX: send ICMP error even if DF is not set. */
                if (err == -EMSGSIZE) {
                        if (skb->protocol == htons(ETH_P_IP))
-                               icmp_send(skb, ICMP_DEST_UNREACH,
-                                         ICMP_FRAG_NEEDED, htonl(mtu));
+                               icmp_ndo_send(skb, ICMP_DEST_UNREACH,
+                                             ICMP_FRAG_NEEDED, htonl(mtu));
                        else
-                               icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
+                               icmpv6_ndo_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
                }
 
                goto tx_err;
index a7950baa05e511a4dabec54757a3057f1e4a25c7..3fa0eca5a06f8af1afef3a497f9411e98007b149 100644 (file)
@@ -1332,8 +1332,8 @@ ipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,
 
                                tel = (void *)&skb_network_header(skb)[offset];
                                if (tel->encap_limit == 0) {
-                                       icmpv6_send(skb, ICMPV6_PARAMPROB,
-                                               ICMPV6_HDR_FIELD, offset + 2);
+                                       icmpv6_ndo_send(skb, ICMPV6_PARAMPROB,
+                                                       ICMPV6_HDR_FIELD, offset + 2);
                                        return -1;
                                }
                                encap_limit = tel->encap_limit - 1;
@@ -1385,11 +1385,11 @@ ipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,
                if (err == -EMSGSIZE)
                        switch (protocol) {
                        case IPPROTO_IPIP:
-                               icmp_send(skb, ICMP_DEST_UNREACH,
-                                         ICMP_FRAG_NEEDED, htonl(mtu));
+                               icmp_ndo_send(skb, ICMP_DEST_UNREACH,
+                                             ICMP_FRAG_NEEDED, htonl(mtu));
                                break;
                        case IPPROTO_IPV6:
-                               icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
+                               icmpv6_ndo_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
                                break;
                        default:
                                break;
index 0225fd6941925ad2f1da6533801ab66cbd327b87..f10e7a72ea6248e5ec1fbdb8b4e1c4e0e874cb96 100644 (file)
@@ -521,10 +521,10 @@ vti6_xmit(struct sk_buff *skb, struct net_device *dev, struct flowi *fl)
                        if (mtu < IPV6_MIN_MTU)
                                mtu = IPV6_MIN_MTU;
 
-                       icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
+                       icmpv6_ndo_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
                } else {
-                       icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
-                                 htonl(mtu));
+                       icmp_ndo_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
+                                     htonl(mtu));
                }
 
                err = -EMSGSIZE;
index 93636867aee28dac0d166a4919ee26c77cb692a3..63ccd9f2dcccf972eebefa8f293fb47090feb8e1 100644 (file)
@@ -987,7 +987,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
                        skb_dst_update_pmtu_no_confirm(skb, mtu);
 
                if (skb->len > mtu && !skb_is_gso(skb)) {
-                       icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
+                       icmpv6_ndo_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
                        ip_rt_put(rt);
                        goto tx_error;
                }
index 7be5103ff2a84e19f1dfd4e4dfbbb04e4667e150..203890e378cb0b8acb42a2781b3cce80f9511fd3 100644 (file)
@@ -649,9 +649,9 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
        /* Parse and check optional cookie */
        if (session->peer_cookie_len > 0) {
                if (memcmp(ptr, &session->peer_cookie[0], session->peer_cookie_len)) {
-                       pr_warn_ratelimited("%s: cookie mismatch (%u/%u). Discarding.\n",
-                                           tunnel->name, tunnel->tunnel_id,
-                                           session->session_id);
+                       pr_debug_ratelimited("%s: cookie mismatch (%u/%u). Discarding.\n",
+                                            tunnel->name, tunnel->tunnel_id,
+                                            session->session_id);
                        atomic_long_inc(&session->stats.rx_cookie_discards);
                        goto discard;
                }
@@ -702,8 +702,8 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
                 * If user has configured mandatory sequence numbers, discard.
                 */
                if (session->recv_seq) {
-                       pr_warn_ratelimited("%s: recv data has no seq numbers when required. Discarding.\n",
-                                           session->name);
+                       pr_debug_ratelimited("%s: recv data has no seq numbers when required. Discarding.\n",
+                                            session->name);
                        atomic_long_inc(&session->stats.rx_seq_discards);
                        goto discard;
                }
@@ -718,8 +718,8 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
                        session->send_seq = 0;
                        l2tp_session_set_header_len(session, tunnel->version);
                } else if (session->send_seq) {
-                       pr_warn_ratelimited("%s: recv data has no seq numbers when required. Discarding.\n",
-                                           session->name);
+                       pr_debug_ratelimited("%s: recv data has no seq numbers when required. Discarding.\n",
+                                            session->name);
                        atomic_long_inc(&session->stats.rx_seq_discards);
                        goto discard;
                }
@@ -809,9 +809,9 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb)
 
        /* Short packet? */
        if (!pskb_may_pull(skb, L2TP_HDR_SIZE_MAX)) {
-               pr_warn_ratelimited("%s: recv short packet (len=%d)\n",
-                                   tunnel->name, skb->len);
-               goto error;
+               pr_debug_ratelimited("%s: recv short packet (len=%d)\n",
+                                    tunnel->name, skb->len);
+               goto invalid;
        }
 
        /* Point to L2TP header */
@@ -824,9 +824,9 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb)
        /* Check protocol version */
        version = hdrflags & L2TP_HDR_VER_MASK;
        if (version != tunnel->version) {
-               pr_warn_ratelimited("%s: recv protocol version mismatch: got %d expected %d\n",
-                                   tunnel->name, version, tunnel->version);
-               goto error;
+               pr_debug_ratelimited("%s: recv protocol version mismatch: got %d expected %d\n",
+                                    tunnel->name, version, tunnel->version);
+               goto invalid;
        }
 
        /* Get length of L2TP packet */
@@ -834,7 +834,7 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb)
 
        /* If type is control packet, it is handled by userspace. */
        if (hdrflags & L2TP_HDRFLAG_T)
-               goto error;
+               goto pass;
 
        /* Skip flags */
        ptr += 2;
@@ -863,21 +863,24 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb)
                        l2tp_session_dec_refcount(session);
 
                /* Not found? Pass to userspace to deal with */
-               pr_warn_ratelimited("%s: no session found (%u/%u). Passing up.\n",
-                                   tunnel->name, tunnel_id, session_id);
-               goto error;
+               pr_debug_ratelimited("%s: no session found (%u/%u). Passing up.\n",
+                                    tunnel->name, tunnel_id, session_id);
+               goto pass;
        }
 
        if (tunnel->version == L2TP_HDR_VER_3 &&
            l2tp_v3_ensure_opt_in_linear(session, skb, &ptr, &optr))
-               goto error;
+               goto invalid;
 
        l2tp_recv_common(session, skb, ptr, optr, hdrflags, length);
        l2tp_session_dec_refcount(session);
 
        return 0;
 
-error:
+invalid:
+       atomic_long_inc(&tunnel->stats.rx_invalid);
+
+pass:
        /* Put UDP header back */
        __skb_push(skb, sizeof(struct udphdr));
 
index cb21d906343e8a569307be62bd951db473d0e572..98ea98eb9567bc7bd3e96c48acc4fefecb05b58f 100644 (file)
@@ -39,6 +39,7 @@ struct l2tp_stats {
        atomic_long_t           rx_oos_packets;
        atomic_long_t           rx_errors;
        atomic_long_t           rx_cookie_discards;
+       atomic_long_t           rx_invalid;
 };
 
 struct l2tp_tunnel;
index 83956c9ee1fcc7b17ed33239d6c8df53ba4598fd..96eb91be9238ba13413e7948df07f1084389fd83 100644 (file)
@@ -428,6 +428,9 @@ static int l2tp_nl_tunnel_send(struct sk_buff *skb, u32 portid, u32 seq, int fla
                              L2TP_ATTR_STATS_PAD) ||
            nla_put_u64_64bit(skb, L2TP_ATTR_RX_ERRORS,
                              atomic_long_read(&tunnel->stats.rx_errors),
+                             L2TP_ATTR_STATS_PAD) ||
+           nla_put_u64_64bit(skb, L2TP_ATTR_RX_INVALID,
+                             atomic_long_read(&tunnel->stats.rx_invalid),
                              L2TP_ATTR_STATS_PAD))
                goto nla_put_failure;
        nla_nest_end(skb, nest);
@@ -771,6 +774,9 @@ static int l2tp_nl_session_send(struct sk_buff *skb, u32 portid, u32 seq, int fl
                              L2TP_ATTR_STATS_PAD) ||
            nla_put_u64_64bit(skb, L2TP_ATTR_RX_ERRORS,
                              atomic_long_read(&session->stats.rx_errors),
+                             L2TP_ATTR_STATS_PAD) ||
+           nla_put_u64_64bit(skb, L2TP_ATTR_RX_INVALID,
+                             atomic_long_read(&session->stats.rx_invalid),
                              L2TP_ATTR_STATS_PAD))
                goto nla_put_failure;
        nla_nest_end(skb, nest);
index b1690149b6fa08147b4bb582379ba2a9535f52ef..1482259de9b5d7a5e791f0deb34cedcb1f26bf21 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/netdev_features.h>
 #include <linux/netdevice.h>
 #include <linux/skbuff.h>
+#include <net/mpls.h>
 
 static struct sk_buff *mpls_gso_segment(struct sk_buff *skb,
                                       netdev_features_t features)
@@ -27,6 +28,8 @@ static struct sk_buff *mpls_gso_segment(struct sk_buff *skb,
 
        skb_reset_network_header(skb);
        mpls_hlen = skb_inner_network_header(skb) - skb_network_header(skb);
+       if (unlikely(!mpls_hlen || mpls_hlen % MPLS_HLEN))
+               goto out;
        if (unlikely(!pskb_may_pull(skb, mpls_hlen)))
                goto out;
 
index c5d5e68940ea2b6f88dccc0f8359fb961afc1f68..76958570ae7f258a0276e423bb7ddbbd0a200224 100644 (file)
@@ -1061,6 +1061,12 @@ out:
        }
 }
 
+static void __mptcp_clean_una_wakeup(struct sock *sk)
+{
+       __mptcp_clean_una(sk);
+       mptcp_write_space(sk);
+}
+
 static void mptcp_enter_memory_pressure(struct sock *sk)
 {
        struct mptcp_subflow_context *subflow;
@@ -1189,6 +1195,7 @@ static bool mptcp_tx_cache_refill(struct sock *sk, int size,
                         */
                        while (skbs->qlen > 1) {
                                skb = __skb_dequeue_tail(skbs);
+                               *total_ts -= skb->truesize;
                                __kfree_skb(skb);
                        }
                        return skbs->qlen > 0;
@@ -1444,7 +1451,7 @@ static void mptcp_push_release(struct sock *sk, struct sock *ssk,
        release_sock(ssk);
 }
 
-static void mptcp_push_pending(struct sock *sk, unsigned int flags)
+static void __mptcp_push_pending(struct sock *sk, unsigned int flags)
 {
        struct sock *prev_ssk = NULL, *ssk = NULL;
        struct mptcp_sock *msk = mptcp_sk(sk);
@@ -1696,14 +1703,14 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
 
 wait_for_memory:
                mptcp_set_nospace(sk);
-               mptcp_push_pending(sk, msg->msg_flags);
+               __mptcp_push_pending(sk, msg->msg_flags);
                ret = sk_stream_wait_memory(sk, &timeo);
                if (ret)
                        goto out;
        }
 
        if (copied)
-               mptcp_push_pending(sk, msg->msg_flags);
+               __mptcp_push_pending(sk, msg->msg_flags);
 
 out:
        release_sock(sk);
@@ -2115,6 +2122,14 @@ static struct sock *mptcp_subflow_get_retrans(const struct mptcp_sock *msk)
        return backup;
 }
 
+static void mptcp_dispose_initial_subflow(struct mptcp_sock *msk)
+{
+       if (msk->subflow) {
+               iput(SOCK_INODE(msk->subflow));
+               msk->subflow = NULL;
+       }
+}
+
 /* subflow sockets can be either outgoing (connect) or incoming
  * (accept).
  *
@@ -2126,6 +2141,8 @@ static struct sock *mptcp_subflow_get_retrans(const struct mptcp_sock *msk)
 static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
                              struct mptcp_subflow_context *subflow)
 {
+       struct mptcp_sock *msk = mptcp_sk(sk);
+
        list_del(&subflow->node);
 
        lock_sock_nested(ssk, SINGLE_DEPTH_NESTING);
@@ -2154,6 +2171,18 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
        release_sock(ssk);
 
        sock_put(ssk);
+
+       if (ssk == msk->last_snd)
+               msk->last_snd = NULL;
+
+       if (ssk == msk->ack_hint)
+               msk->ack_hint = NULL;
+
+       if (ssk == msk->first)
+               msk->first = NULL;
+
+       if (msk->subflow && ssk == msk->subflow->sk)
+               mptcp_dispose_initial_subflow(msk);
 }
 
 void mptcp_close_ssk(struct sock *sk, struct sock *ssk,
@@ -2238,14 +2267,58 @@ static void mptcp_check_fastclose(struct mptcp_sock *msk)
        mptcp_close_wake_up(sk);
 }
 
-static void mptcp_worker(struct work_struct *work)
+static void __mptcp_retrans(struct sock *sk)
 {
-       struct mptcp_sock *msk = container_of(work, struct mptcp_sock, work);
-       struct sock *ssk, *sk = &msk->sk.icsk_inet.sk;
+       struct mptcp_sock *msk = mptcp_sk(sk);
        struct mptcp_sendmsg_info info = {};
        struct mptcp_data_frag *dfrag;
        size_t copied = 0;
-       int state, ret;
+       struct sock *ssk;
+       int ret;
+
+       __mptcp_clean_una_wakeup(sk);
+       dfrag = mptcp_rtx_head(sk);
+       if (!dfrag)
+               return;
+
+       ssk = mptcp_subflow_get_retrans(msk);
+       if (!ssk)
+               goto reset_timer;
+
+       lock_sock(ssk);
+
+       /* limit retransmission to the bytes already sent on some subflows */
+       info.sent = 0;
+       info.limit = dfrag->already_sent;
+       while (info.sent < dfrag->already_sent) {
+               if (!mptcp_alloc_tx_skb(sk, ssk))
+                       break;
+
+               ret = mptcp_sendmsg_frag(sk, ssk, dfrag, &info);
+               if (ret <= 0)
+                       break;
+
+               MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RETRANSSEGS);
+               copied += ret;
+               info.sent += ret;
+       }
+       if (copied)
+               tcp_push(ssk, 0, info.mss_now, tcp_sk(ssk)->nonagle,
+                        info.size_goal);
+
+       mptcp_set_timeout(sk, ssk);
+       release_sock(ssk);
+
+reset_timer:
+       if (!mptcp_timer_pending(sk))
+               mptcp_reset_timer(sk);
+}
+
+static void mptcp_worker(struct work_struct *work)
+{
+       struct mptcp_sock *msk = container_of(work, struct mptcp_sock, work);
+       struct sock *sk = &msk->sk.icsk_inet.sk;
+       int state;
 
        lock_sock(sk);
        state = sk->sk_state;
@@ -2280,45 +2353,8 @@ static void mptcp_worker(struct work_struct *work)
        if (test_and_clear_bit(MPTCP_WORK_CLOSE_SUBFLOW, &msk->flags))
                __mptcp_close_subflow(msk);
 
-       if (!test_and_clear_bit(MPTCP_WORK_RTX, &msk->flags))
-               goto unlock;
-
-       __mptcp_clean_una(sk);
-       dfrag = mptcp_rtx_head(sk);
-       if (!dfrag)
-               goto unlock;
-
-       ssk = mptcp_subflow_get_retrans(msk);
-       if (!ssk)
-               goto reset_unlock;
-
-       lock_sock(ssk);
-
-       /* limit retransmission to the bytes already sent on some subflows */
-       info.sent = 0;
-       info.limit = dfrag->already_sent;
-       while (info.sent < dfrag->already_sent) {
-               if (!mptcp_alloc_tx_skb(sk, ssk))
-                       break;
-
-               ret = mptcp_sendmsg_frag(sk, ssk, dfrag, &info);
-               if (ret <= 0)
-                       break;
-
-               MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RETRANSSEGS);
-               copied += ret;
-               info.sent += ret;
-       }
-       if (copied)
-               tcp_push(ssk, 0, info.mss_now, tcp_sk(ssk)->nonagle,
-                        info.size_goal);
-
-       mptcp_set_timeout(sk, ssk);
-       release_sock(ssk);
-
-reset_unlock:
-       if (!mptcp_timer_pending(sk))
-               mptcp_reset_timer(sk);
+       if (test_and_clear_bit(MPTCP_WORK_RTX, &msk->flags))
+               __mptcp_retrans(sk);
 
 unlock:
        release_sock(sk);
@@ -2523,12 +2559,6 @@ static void __mptcp_destroy_sock(struct sock *sk)
 
        might_sleep();
 
-       /* dispose the ancillatory tcp socket, if any */
-       if (msk->subflow) {
-               iput(SOCK_INODE(msk->subflow));
-               msk->subflow = NULL;
-       }
-
        /* be sure to always acquire the join list lock, to sync vs
         * mptcp_finish_join().
         */
@@ -2553,6 +2583,7 @@ static void __mptcp_destroy_sock(struct sock *sk)
        sk_stream_kill_queues(sk);
        xfrm_sk_free_policy(sk);
        sk_refcnt_debug_release(sk);
+       mptcp_dispose_initial_subflow(msk);
        sock_put(sk);
 }
 
@@ -2934,13 +2965,14 @@ static void mptcp_release_cb(struct sock *sk)
 {
        unsigned long flags, nflags;
 
-       /* push_pending may touch wmem_reserved, do it before the later
-        * cleanup
-        */
-       if (test_and_clear_bit(MPTCP_CLEAN_UNA, &mptcp_sk(sk)->flags))
-               __mptcp_clean_una(sk);
-       if (test_and_clear_bit(MPTCP_PUSH_PENDING, &mptcp_sk(sk)->flags)) {
-               /* mptcp_push_pending() acquires the subflow socket lock
+       for (;;) {
+               flags = 0;
+               if (test_and_clear_bit(MPTCP_PUSH_PENDING, &mptcp_sk(sk)->flags))
+                       flags |= MPTCP_PUSH_PENDING;
+               if (!flags)
+                       break;
+
+               /* the following actions acquire the subflow socket lock
                 *
                 * 1) can't be invoked in atomic scope
                 * 2) must avoid ABBA deadlock with msk socket spinlock: the RX
@@ -2949,13 +2981,21 @@ static void mptcp_release_cb(struct sock *sk)
                 */
 
                spin_unlock_bh(&sk->sk_lock.slock);
-               mptcp_push_pending(sk, 0);
+               if (flags & MPTCP_PUSH_PENDING)
+                       __mptcp_push_pending(sk, 0);
+
+               cond_resched();
                spin_lock_bh(&sk->sk_lock.slock);
        }
+
+       if (test_and_clear_bit(MPTCP_CLEAN_UNA, &mptcp_sk(sk)->flags))
+               __mptcp_clean_una_wakeup(sk);
        if (test_and_clear_bit(MPTCP_ERROR_REPORT, &mptcp_sk(sk)->flags))
                __mptcp_error_report(sk);
 
-       /* clear any wmem reservation and errors */
+       /* push_pending may touch wmem_reserved, ensure we do the cleanup
+        * later
+        */
        __mptcp_update_wmem(sk);
        __mptcp_update_rmem(sk);
 
@@ -3285,6 +3325,9 @@ static int mptcp_stream_accept(struct socket *sock, struct socket *newsock,
                /* PM/worker can now acquire the first subflow socket
                 * lock without racing with listener queue cleanup,
                 * we can notify it, if needed.
+                *
+                * Even if remote has reset the initial subflow by now
+                * the refcnt is still at least one.
                 */
                subflow = mptcp_subflow_ctx(msk->first);
                list_add(&subflow->node, &msk->conn_list);
index 91827d94976691b490d2f1854b50f5a785904ee0..e21a5bc36cf08e425ace584cabca77f823f2811b 100644 (file)
 #define TCPOLEN_MPTCP_DSS_MAP64                14
 #define TCPOLEN_MPTCP_DSS_CHECKSUM     2
 #define TCPOLEN_MPTCP_ADD_ADDR         16
-#define TCPOLEN_MPTCP_ADD_ADDR_PORT    20
+#define TCPOLEN_MPTCP_ADD_ADDR_PORT    18
 #define TCPOLEN_MPTCP_ADD_ADDR_BASE    8
-#define TCPOLEN_MPTCP_ADD_ADDR_BASE_PORT       12
+#define TCPOLEN_MPTCP_ADD_ADDR_BASE_PORT       10
 #define TCPOLEN_MPTCP_ADD_ADDR6                28
-#define TCPOLEN_MPTCP_ADD_ADDR6_PORT   32
+#define TCPOLEN_MPTCP_ADD_ADDR6_PORT   30
 #define TCPOLEN_MPTCP_ADD_ADDR6_BASE   20
-#define TCPOLEN_MPTCP_ADD_ADDR6_BASE_PORT      24
-#define TCPOLEN_MPTCP_PORT_LEN         4
+#define TCPOLEN_MPTCP_ADD_ADDR6_BASE_PORT      22
+#define TCPOLEN_MPTCP_PORT_LEN         2
+#define TCPOLEN_MPTCP_PORT_ALIGN       2
 #define TCPOLEN_MPTCP_RM_ADDR_BASE     4
 #define TCPOLEN_MPTCP_PRIO             3
 #define TCPOLEN_MPTCP_PRIO_ALIGN       4
@@ -701,8 +702,9 @@ static inline unsigned int mptcp_add_addr_len(int family, bool echo, bool port)
                len = TCPOLEN_MPTCP_ADD_ADDR6_BASE;
        if (!echo)
                len += MPTCPOPT_THMAC_LEN;
+       /* account for 2 trailing 'nop' options */
        if (port)
-               len += TCPOLEN_MPTCP_PORT_LEN;
+               len += TCPOLEN_MPTCP_PORT_LEN + TCPOLEN_MPTCP_PORT_ALIGN;
 
        return len;
 }
index e1fbcab257e6dd044227b005bc4ec3a79422c2ea..3d47d670e66546f2f4cd4be7588cead55687be06 100644 (file)
@@ -687,11 +687,6 @@ create_child:
                        /* move the msk reference ownership to the subflow */
                        subflow_req->msk = NULL;
                        ctx->conn = (struct sock *)owner;
-                       if (!mptcp_finish_join(child))
-                               goto dispose_child;
-
-                       SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_JOINACKRX);
-                       tcp_rsk(req)->drop_req = true;
 
                        if (subflow_use_different_sport(owner, sk)) {
                                pr_debug("ack inet_sport=%d %d",
@@ -699,10 +694,16 @@ create_child:
                                         ntohs(inet_sk((struct sock *)owner)->inet_sport));
                                if (!mptcp_pm_sport_in_anno_list(owner, sk)) {
                                        SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_MISMATCHPORTACKRX);
-                                       goto out;
+                                       goto dispose_child;
                                }
                                SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_JOINPORTACKRX);
                        }
+
+                       if (!mptcp_finish_join(child))
+                               goto dispose_child;
+
+                       SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_JOINACKRX);
+                       tcp_rsk(req)->drop_req = true;
                }
        }
 
@@ -1297,6 +1298,7 @@ failed_unlink:
        spin_lock_bh(&msk->join_list_lock);
        list_del(&subflow->node);
        spin_unlock_bh(&msk->join_list_lock);
+       sock_put(mptcp_subflow_tcp_sock(subflow));
 
 failed:
        subflow->disposable = 1;
index 118f415928aefe26d7771379b98a2156e6b6b227..b055187235f87c0def9fef5f72d583b1ac2cf13a 100644 (file)
@@ -219,7 +219,7 @@ nf_ct_lookup_helper(struct nf_conn *ct, struct net *net)
                        return NULL;
                pr_info("nf_conntrack: default automatic helper assignment "
                        "has been turned off for security reasons and CT-based "
-                       " firewall rule not found. Use the iptables CT target "
+                       "firewall rule not found. Use the iptables CT target "
                        "to attach helpers instead.\n");
                net->ct.auto_assign_helper_warned = 1;
                return NULL;
@@ -228,7 +228,6 @@ nf_ct_lookup_helper(struct nf_conn *ct, struct net *net)
        return __nf_ct_helper_find(&ct->tuplehash[IP_CT_DIR_REPLY].tuple);
 }
 
-
 int __nf_ct_try_assign_helper(struct nf_conn *ct, struct nf_conn *tmpl,
                              gfp_t flags)
 {
index 1d7e1c5955463545edf96ba2b8a106f9db9f4121..ec23330687a5ed92f608c5836b47ebd8f6fa211e 100644 (file)
@@ -982,8 +982,10 @@ int nf_conntrack_tcp_packet(struct nf_conn *ct,
                                        IP_CT_EXP_CHALLENGE_ACK;
                }
                spin_unlock_bh(&ct->lock);
-               nf_ct_l4proto_log_invalid(skb, ct, "invalid packet ignored in "
-                                         "state %s ", tcp_conntrack_names[old_state]);
+               nf_ct_l4proto_log_invalid(skb, ct,
+                                         "packet (index %d) in dir %d ignored, state %s",
+                                         index, dir,
+                                         tcp_conntrack_names[old_state]);
                return NF_ACCEPT;
        case TCP_CONNTRACK_MAX:
                /* Special case for SYN proxy: when the SYN to the server or
index e87b6bd6b3cdb6b79b2d229df4ce3d74f8e374d8..4731d21fc3ad83022d59a43d0fea0c0945f333f6 100644 (file)
@@ -646,8 +646,8 @@ nf_nat_ipv4_fn(void *priv, struct sk_buff *skb,
 }
 
 static unsigned int
-nf_nat_ipv4_in(void *priv, struct sk_buff *skb,
-              const struct nf_hook_state *state)
+nf_nat_ipv4_pre_routing(void *priv, struct sk_buff *skb,
+                       const struct nf_hook_state *state)
 {
        unsigned int ret;
        __be32 daddr = ip_hdr(skb)->daddr;
@@ -659,6 +659,23 @@ nf_nat_ipv4_in(void *priv, struct sk_buff *skb,
        return ret;
 }
 
+static unsigned int
+nf_nat_ipv4_local_in(void *priv, struct sk_buff *skb,
+                    const struct nf_hook_state *state)
+{
+       __be32 saddr = ip_hdr(skb)->saddr;
+       struct sock *sk = skb->sk;
+       unsigned int ret;
+
+       ret = nf_nat_ipv4_fn(priv, skb, state);
+
+       if (ret == NF_ACCEPT && sk && saddr != ip_hdr(skb)->saddr &&
+           !inet_sk_transparent(sk))
+               skb_orphan(skb); /* TCP edemux obtained wrong socket */
+
+       return ret;
+}
+
 static unsigned int
 nf_nat_ipv4_out(void *priv, struct sk_buff *skb,
                const struct nf_hook_state *state)
@@ -736,7 +753,7 @@ nf_nat_ipv4_local_fn(void *priv, struct sk_buff *skb,
 static const struct nf_hook_ops nf_nat_ipv4_ops[] = {
        /* Before packet filtering, change destination */
        {
-               .hook           = nf_nat_ipv4_in,
+               .hook           = nf_nat_ipv4_pre_routing,
                .pf             = NFPROTO_IPV4,
                .hooknum        = NF_INET_PRE_ROUTING,
                .priority       = NF_IP_PRI_NAT_DST,
@@ -757,7 +774,7 @@ static const struct nf_hook_ops nf_nat_ipv4_ops[] = {
        },
        /* After packet filtering, change source */
        {
-               .hook           = nf_nat_ipv4_fn,
+               .hook           = nf_nat_ipv4_local_in,
                .pf             = NFPROTO_IPV4,
                .hooknum        = NF_INET_LOCAL_IN,
                .priority       = NF_IP_PRI_NAT_SRC,
index c1eb5cdb30330f5fdb1b3d58e10f87db6bf83ac7..224c8e537cb3357200da964ac29e336cf10798a4 100644 (file)
@@ -916,6 +916,12 @@ static int nf_tables_updtable(struct nft_ctx *ctx)
        if (flags == ctx->table->flags)
                return 0;
 
+       if ((nft_table_has_owner(ctx->table) &&
+            !(flags & NFT_TABLE_F_OWNER)) ||
+           (!nft_table_has_owner(ctx->table) &&
+            flags & NFT_TABLE_F_OWNER))
+               return -EOPNOTSUPP;
+
        trans = nft_trans_alloc(ctx, NFT_MSG_NEWTABLE,
                                sizeof(struct nft_trans_table));
        if (trans == NULL)
@@ -9022,8 +9028,12 @@ static void __nft_release_hooks(struct net *net)
 {
        struct nft_table *table;
 
-       list_for_each_entry(table, &net->nft.tables, list)
+       list_for_each_entry(table, &net->nft.tables, list) {
+               if (nft_table_has_owner(table))
+                       continue;
+
                __nft_release_hook(net, table);
+       }
 }
 
 static void __nft_release_table(struct net *net, struct nft_table *table)
@@ -9073,13 +9083,12 @@ static void __nft_release_table(struct net *net, struct nft_table *table)
        nf_tables_table_destroy(&ctx);
 }
 
-static void __nft_release_tables(struct net *net, u32 nlpid)
+static void __nft_release_tables(struct net *net)
 {
        struct nft_table *table, *nt;
 
        list_for_each_entry_safe(table, nt, &net->nft.tables, list) {
-               if (nft_table_has_owner(table) &&
-                   nlpid != table->nlpid)
+               if (nft_table_has_owner(table))
                        continue;
 
                __nft_release_table(net, table);
@@ -9145,7 +9154,7 @@ static void __net_exit nf_tables_exit_net(struct net *net)
        mutex_lock(&net->nft.commit_mutex);
        if (!list_empty(&net->nft.commit_list))
                __nf_tables_abort(net, NFNL_ABORT_NONE);
-       __nft_release_tables(net, 0);
+       __nft_release_tables(net);
        mutex_unlock(&net->nft.commit_mutex);
        WARN_ON_ONCE(!list_empty(&net->nft.tables));
        WARN_ON_ONCE(!list_empty(&net->nft.module_list));
index acce622582e3d769ecaa0bf09b588c07769ba53b..bce6ca203d46242aaa993ae5e485af1556e824de 100644 (file)
@@ -330,6 +330,7 @@ static int match_revfn(u8 af, const char *name, u8 revision, int *bestp)
        const struct xt_match *m;
        int have_rev = 0;
 
+       mutex_lock(&xt[af].mutex);
        list_for_each_entry(m, &xt[af].match, list) {
                if (strcmp(m->name, name) == 0) {
                        if (m->revision > *bestp)
@@ -338,6 +339,7 @@ static int match_revfn(u8 af, const char *name, u8 revision, int *bestp)
                                have_rev = 1;
                }
        }
+       mutex_unlock(&xt[af].mutex);
 
        if (af != NFPROTO_UNSPEC && !have_rev)
                return match_revfn(NFPROTO_UNSPEC, name, revision, bestp);
@@ -350,6 +352,7 @@ static int target_revfn(u8 af, const char *name, u8 revision, int *bestp)
        const struct xt_target *t;
        int have_rev = 0;
 
+       mutex_lock(&xt[af].mutex);
        list_for_each_entry(t, &xt[af].target, list) {
                if (strcmp(t->name, name) == 0) {
                        if (t->revision > *bestp)
@@ -358,6 +361,7 @@ static int target_revfn(u8 af, const char *name, u8 revision, int *bestp)
                                have_rev = 1;
                }
        }
+       mutex_unlock(&xt[af].mutex);
 
        if (af != NFPROTO_UNSPEC && !have_rev)
                return target_revfn(NFPROTO_UNSPEC, name, revision, bestp);
@@ -371,12 +375,10 @@ int xt_find_revision(u8 af, const char *name, u8 revision, int target,
 {
        int have_rev, best = -1;
 
-       mutex_lock(&xt[af].mutex);
        if (target == 1)
                have_rev = target_revfn(af, name, revision, &best);
        else
                have_rev = match_revfn(af, name, revision, &best);
-       mutex_unlock(&xt[af].mutex);
 
        /* Nothing at all?  Return 0 to try loading module. */
        if (best == -1) {
index 726dda95934c660b051fdbd618825080320e3775..4f50a64315cf0f8663d6f70116e5d0eb7e3d9264 100644 (file)
@@ -575,6 +575,7 @@ list_start:
 
                break;
        }
+       cipso_v4_doi_putdef(doi_def);
        rcu_read_unlock();
 
        genlmsg_end(ans_skb, data);
@@ -583,12 +584,14 @@ list_start:
 list_retry:
        /* XXX - this limit is a guesstimate */
        if (nlsze_mult < 4) {
+               cipso_v4_doi_putdef(doi_def);
                rcu_read_unlock();
                kfree_skb(ans_skb);
                nlsze_mult *= 2;
                goto list_start;
        }
 list_failure_lock:
+       cipso_v4_doi_putdef(doi_def);
        rcu_read_unlock();
 list_failure:
        kfree_skb(ans_skb);
index b34358282f3798157206e3836517bba937daa5b9..edb6ac17cecabd94fe392eb4f589dbbbf7bfa2c0 100644 (file)
@@ -439,7 +439,7 @@ int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len)
        if (len == 0 || len & 3)
                return -EINVAL;
 
-       skb = netdev_alloc_skb(NULL, len);
+       skb = __netdev_alloc_skb(NULL, len, GFP_ATOMIC | __GFP_NOWARN);
        if (!skb)
                return -ENOMEM;
 
@@ -958,8 +958,10 @@ static int qrtr_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
        plen = (len + 3) & ~3;
        skb = sock_alloc_send_skb(sk, plen + QRTR_HDR_MAX_SIZE,
                                  msg->msg_flags & MSG_DONTWAIT, &rc);
-       if (!skb)
+       if (!skb) {
+               rc = -ENOMEM;
                goto out_node;
+       }
 
        skb_reserve(skb, QRTR_HDR_MAX_SIZE);
 
index e2e4353db8a70d5fe3d0f41d93b446c7b5ff628f..f87d07736a1404edcfd17a792321758cd4bdd173 100644 (file)
@@ -2168,7 +2168,7 @@ static int tc_dump_tclass_qdisc(struct Qdisc *q, struct sk_buff *skb,
 
 static int tc_dump_tclass_root(struct Qdisc *root, struct sk_buff *skb,
                               struct tcmsg *tcm, struct netlink_callback *cb,
-                              int *t_p, int s_t)
+                              int *t_p, int s_t, bool recur)
 {
        struct Qdisc *q;
        int b;
@@ -2179,7 +2179,7 @@ static int tc_dump_tclass_root(struct Qdisc *root, struct sk_buff *skb,
        if (tc_dump_tclass_qdisc(root, skb, tcm, cb, t_p, s_t) < 0)
                return -1;
 
-       if (!qdisc_dev(root))
+       if (!qdisc_dev(root) || !recur)
                return 0;
 
        if (tcm->tcm_parent) {
@@ -2214,13 +2214,13 @@ static int tc_dump_tclass(struct sk_buff *skb, struct netlink_callback *cb)
        s_t = cb->args[0];
        t = 0;
 
-       if (tc_dump_tclass_root(dev->qdisc, skb, tcm, cb, &t, s_t) < 0)
+       if (tc_dump_tclass_root(dev->qdisc, skb, tcm, cb, &t, s_t, true) < 0)
                goto done;
 
        dev_queue = dev_ingress_queue(dev);
        if (dev_queue &&
            tc_dump_tclass_root(dev_queue->qdisc_sleeping, skb, tcm, cb,
-                               &t, s_t) < 0)
+                               &t, s_t, false) < 0)
                goto done;
 
 done:
index a9c6af5795d81bb1a368a91b76ffbfd50e428d6d..5ba456727f631887113b8b9a3f3ace8ff1c92eff 100644 (file)
@@ -75,7 +75,7 @@ int sctp_tsnmap_check(const struct sctp_tsnmap *map, __u32 tsn)
                return 1;
 
        /* Verify that we can hold this TSN and that it will not
-        * overlfow our map
+        * overflow our map
         */
        if (!TSN_lt(tsn, map->base_tsn + SCTP_TSN_MAP_SIZE))
                return -1;
index bd4678db9d76b2aada812da607502d40c369fd0d..6dff64374bfe11bb6fbbec0b8cf6fff25480189c 100644 (file)
@@ -1825,11 +1825,14 @@ static int
 svcauth_gss_release(struct svc_rqst *rqstp)
 {
        struct gss_svc_data *gsd = (struct gss_svc_data *)rqstp->rq_auth_data;
-       struct rpc_gss_wire_cred *gc = &gsd->clcred;
+       struct rpc_gss_wire_cred *gc;
        struct xdr_buf *resbuf = &rqstp->rq_res;
        int stat = -EINVAL;
        struct sunrpc_net *sn = net_generic(SVC_NET(rqstp), sunrpc_net_id);
 
+       if (!gsd)
+               goto out;
+       gc = &gsd->clcred;
        if (gc->gc_proc != RPC_GSS_PROC_DATA)
                goto out;
        /* Release can be called twice, but we only wrap once. */
@@ -1870,10 +1873,10 @@ out_err:
        if (rqstp->rq_cred.cr_group_info)
                put_group_info(rqstp->rq_cred.cr_group_info);
        rqstp->rq_cred.cr_group_info = NULL;
-       if (gsd->rsci)
+       if (gsd && gsd->rsci) {
                cache_put(&gsd->rsci->h, sn->rsc_cache);
-       gsd->rsci = NULL;
-
+               gsd->rsci = NULL;
+       }
        return stat;
 }
 
index cf702a5f7fe5de023edf4814a6c326999df254e5..39ed0e0afe6d9bc25069659e853fbde29326a062 100644 (file)
@@ -963,8 +963,11 @@ void rpc_execute(struct rpc_task *task)
 
        rpc_set_active(task);
        rpc_make_runnable(rpciod_workqueue, task);
-       if (!is_async)
+       if (!is_async) {
+               unsigned int pflags = memalloc_nofs_save();
                __rpc_execute(task);
+               memalloc_nofs_restore(pflags);
+       }
 }
 
 static void rpc_async_schedule(struct work_struct *work)
index 61fb8a18552cf58a6acd34821c4c92a78cb5ed20..d76dc9d95d1639a989a6011cd235c8b82b3fa469 100644 (file)
@@ -1413,7 +1413,7 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
 
  sendit:
        if (svc_authorise(rqstp))
-               goto close;
+               goto close_xprt;
        return 1;               /* Caller can now send it */
 
 release_dropit:
@@ -1425,6 +1425,8 @@ release_dropit:
        return 0;
 
  close:
+       svc_authorise(rqstp);
+close_xprt:
        if (rqstp->rq_xprt && test_bit(XPT_TEMP, &rqstp->rq_xprt->xpt_flags))
                svc_close_xprt(rqstp->rq_xprt);
        dprintk("svc: svc_process close\n");
@@ -1433,7 +1435,7 @@ release_dropit:
 err_short_len:
        svc_printk(rqstp, "short len %zd, dropping request\n",
                        argv->iov_len);
-       goto close;
+       goto close_xprt;
 
 err_bad_rpc:
        serv->sv_stats->rpcbadfmt++;
index dcc50ae545506f39d04908f6168c36ddda350f6f..3cdd71a8df1e777acf9180db81640776cd07f4d9 100644 (file)
@@ -1060,7 +1060,7 @@ static int svc_close_list(struct svc_serv *serv, struct list_head *xprt_list, st
        struct svc_xprt *xprt;
        int ret = 0;
 
-       spin_lock(&serv->sv_lock);
+       spin_lock_bh(&serv->sv_lock);
        list_for_each_entry(xprt, xprt_list, xpt_list) {
                if (xprt->xpt_net != net)
                        continue;
@@ -1068,7 +1068,7 @@ static int svc_close_list(struct svc_serv *serv, struct list_head *xprt_list, st
                set_bit(XPT_CLOSE, &xprt->xpt_flags);
                svc_xprt_enqueue(xprt);
        }
-       spin_unlock(&serv->sv_lock);
+       spin_unlock_bh(&serv->sv_lock);
        return ret;
 }
 
index 4a1edbb4028efb08f39f035efc1c4a973d994fb9..9150df35fb6f2633fb08f1180f8b14ebfcde505b 100644 (file)
@@ -252,9 +252,9 @@ xprt_setup_rdma_bc(struct xprt_create *args)
        xprt->timeout = &xprt_rdma_bc_timeout;
        xprt_set_bound(xprt);
        xprt_set_connected(xprt);
-       xprt->bind_timeout = RPCRDMA_BIND_TO;
-       xprt->reestablish_timeout = RPCRDMA_INIT_REEST_TO;
-       xprt->idle_timeout = RPCRDMA_IDLE_DISC_TO;
+       xprt->bind_timeout = 0;
+       xprt->reestablish_timeout = 0;
+       xprt->idle_timeout = 0;
 
        xprt->prot = XPRT_TRANSPORT_BC_RDMA;
        xprt->ops = &xprt_rdma_bc_procs;
index 6d28f23ceb35283826fb35773db16f9ece972515..7d34290e2ff8de633f24f5287d85e216e01cede3 100644 (file)
@@ -266,46 +266,33 @@ void svc_rdma_release_rqst(struct svc_rqst *rqstp)
                svc_rdma_recv_ctxt_put(rdma, ctxt);
 }
 
-static bool svc_rdma_refresh_recvs(struct svcxprt_rdma *rdma,
-                                  unsigned int wanted, bool temp)
+static int __svc_rdma_post_recv(struct svcxprt_rdma *rdma,
+                               struct svc_rdma_recv_ctxt *ctxt)
 {
-       const struct ib_recv_wr *bad_wr = NULL;
-       struct svc_rdma_recv_ctxt *ctxt;
-       struct ib_recv_wr *recv_chain;
        int ret;
 
-       recv_chain = NULL;
-       while (wanted--) {
-               ctxt = svc_rdma_recv_ctxt_get(rdma);
-               if (!ctxt)
-                       break;
-
-               trace_svcrdma_post_recv(ctxt);
-               ctxt->rc_temp = temp;
-               ctxt->rc_recv_wr.next = recv_chain;
-               recv_chain = &ctxt->rc_recv_wr;
-               rdma->sc_pending_recvs++;
-       }
-       if (!recv_chain)
-               return false;
-
-       ret = ib_post_recv(rdma->sc_qp, recv_chain, &bad_wr);
+       trace_svcrdma_post_recv(ctxt);
+       ret = ib_post_recv(rdma->sc_qp, &ctxt->rc_recv_wr, NULL);
        if (ret)
                goto err_post;
-       return true;
+       return 0;
 
 err_post:
-       while (bad_wr) {
-               ctxt = container_of(bad_wr, struct svc_rdma_recv_ctxt,
-                                   rc_recv_wr);
-               bad_wr = bad_wr->next;
-               svc_rdma_recv_ctxt_put(rdma, ctxt);
-       }
-
        trace_svcrdma_rq_post_err(rdma, ret);
-       /* Since we're destroying the xprt, no need to reset
-        * sc_pending_recvs. */
-       return false;
+       svc_rdma_recv_ctxt_put(rdma, ctxt);
+       return ret;
+}
+
+static int svc_rdma_post_recv(struct svcxprt_rdma *rdma)
+{
+       struct svc_rdma_recv_ctxt *ctxt;
+
+       if (test_bit(XPT_CLOSE, &rdma->sc_xprt.xpt_flags))
+               return 0;
+       ctxt = svc_rdma_recv_ctxt_get(rdma);
+       if (!ctxt)
+               return -ENOMEM;
+       return __svc_rdma_post_recv(rdma, ctxt);
 }
 
 /**
@@ -316,7 +303,20 @@ err_post:
  */
 bool svc_rdma_post_recvs(struct svcxprt_rdma *rdma)
 {
-       return svc_rdma_refresh_recvs(rdma, rdma->sc_max_requests, true);
+       struct svc_rdma_recv_ctxt *ctxt;
+       unsigned int i;
+       int ret;
+
+       for (i = 0; i < rdma->sc_max_requests; i++) {
+               ctxt = svc_rdma_recv_ctxt_get(rdma);
+               if (!ctxt)
+                       return false;
+               ctxt->rc_temp = true;
+               ret = __svc_rdma_post_recv(rdma, ctxt);
+               if (ret)
+                       return false;
+       }
+       return true;
 }
 
 /**
@@ -324,6 +324,8 @@ bool svc_rdma_post_recvs(struct svcxprt_rdma *rdma)
  * @cq: Completion Queue context
  * @wc: Work Completion object
  *
+ * NB: The svc_xprt/svcxprt_rdma is pinned whenever it's possible that
+ * the Receive completion handler could be running.
  */
 static void svc_rdma_wc_receive(struct ib_cq *cq, struct ib_wc *wc)
 {
@@ -331,8 +333,6 @@ static void svc_rdma_wc_receive(struct ib_cq *cq, struct ib_wc *wc)
        struct ib_cqe *cqe = wc->wr_cqe;
        struct svc_rdma_recv_ctxt *ctxt;
 
-       rdma->sc_pending_recvs--;
-
        /* WARNING: Only wc->wr_cqe and wc->status are reliable */
        ctxt = container_of(cqe, struct svc_rdma_recv_ctxt, rc_cqe);
 
@@ -340,6 +340,9 @@ static void svc_rdma_wc_receive(struct ib_cq *cq, struct ib_wc *wc)
        if (wc->status != IB_WC_SUCCESS)
                goto flushed;
 
+       if (svc_rdma_post_recv(rdma))
+               goto post_err;
+
        /* All wc fields are now known to be valid */
        ctxt->rc_byte_len = wc->byte_len;
 
@@ -350,18 +353,11 @@ static void svc_rdma_wc_receive(struct ib_cq *cq, struct ib_wc *wc)
        spin_unlock(&rdma->sc_rq_dto_lock);
        if (!test_bit(RDMAXPRT_CONN_PENDING, &rdma->sc_flags))
                svc_xprt_enqueue(&rdma->sc_xprt);
-
-       if (!test_bit(XPT_CLOSE, &rdma->sc_xprt.xpt_flags) &&
-           rdma->sc_pending_recvs < rdma->sc_max_requests)
-               if (!svc_rdma_refresh_recvs(rdma, RPCRDMA_MAX_RECV_BATCH,
-                                           false))
-                       goto post_err;
-
        return;
 
 flushed:
-       svc_rdma_recv_ctxt_put(rdma, ctxt);
 post_err:
+       svc_rdma_recv_ctxt_put(rdma, ctxt);
        set_bit(XPT_CLOSE, &rdma->sc_xprt.xpt_flags);
        svc_xprt_enqueue(&rdma->sc_xprt);
 }
index db0cb73513a58bdb8e2f346b4ef028aeb975e422..1e2a1105d0e67aba88a2bd4a3ab4998b549acdcb 100644 (file)
@@ -1699,5 +1699,7 @@ int main(int argc, char **argv)
 
        xdpsock_cleanup();
 
+       munmap(bufs, NUM_FRAMES * opt_xsk_frame_size);
+
        return 0;
 }
index eee59184de640ab94e7d0f5512a5286f0839f11f..8cd67b1b6d15ac4c6b397e004580b6f1ba97e11a 100644 (file)
@@ -327,7 +327,7 @@ $(obj)/%.dtb.S: $(obj)/%.dtb FORCE
 
 quiet_cmd_dtc = DTC     $@
 cmd_dtc = $(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
-       $(DTC) -O $(patsubst .%,%,$(suffix $@)) -o $@ -b 0 \
+       $(DTC) -o $@ -b 0 \
                $(addprefix -i,$(dir $<) $(DTC_INCLUDE)) $(DTC_FLAGS) \
                -d $(depfile).dtc.tmp $(dtc-tmp) ; \
        cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile)
@@ -352,7 +352,7 @@ define rule_dtc
 endef
 
 $(obj)/%.dt.yaml: $(src)/%.dts $(DTC) $(DT_TMP_SCHEMA) FORCE
-       $(call if_changed_rule,dtc,yaml)
+       $(call if_changed_rule,dtc)
 
 dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp)
 
index 5c113cad5601742083addba09cb076b116933bc8..39e65fee59bd3aaf720a2c5ac24c5c3eac9f5e3e 100755 (executable)
@@ -57,9 +57,9 @@ if arg_contain --version "$@"; then
 fi
 
 if arg_contain -E "$@"; then
-       # For scripts/gcc-version.sh; This emulates GCC 20.0.0
+       # For scripts/cc-version.sh; This emulates GCC 20.0.0
        if arg_contain - "$@"; then
-               sed 's/^__GNUC__$/20/; s/^__GNUC_MINOR__$/0/; s/^__GNUC_PATCHLEVEL__$/0/'
+               sed -n '/^GCC/{s/__GNUC__/20/; s/__GNUC_MINOR__/0/; s/__GNUC_PATCHLEVEL__/0/; p;}'
                exit 0
        else
                echo "no input files" >&2
@@ -73,6 +73,15 @@ if arg_contain -S "$@"; then
                echo "%gs"
                exit 0
        fi
+
+       # For arch/powerpc/tools/gcc-check-mprofile-kernel.sh
+       if arg_contain -m64 "$@" && arg_contain -mlittle-endian "$@" &&
+               arg_contain -mprofile-kernel "$@"; then
+               if ! test -t 0 && ! grep -q notrace; then
+                       echo "_mcount"
+               fi
+               exit 0
+       fi
 fi
 
 # To set GCC_PLUGINS
@@ -85,3 +94,8 @@ if arg_contain -print-file-name=plugin "$@"; then
        echo $plugin_dir
        exit 0
 fi
+
+# inverted return value
+if arg_contain -D__SIZEOF_INT128__=0 "$@"; then
+       exit 1
+fi
index b5487cce69e8e8c09c60e6889feb2780f9b3adfa..1952d3bb80c6979ab2ffdf2423589cacb4d25602 100644 (file)
@@ -22,6 +22,7 @@ always-y += $(GCC_PLUGIN)
 GCC_PLUGINS_DIR = $(shell $(CC) -print-file-name=plugin)
 
 plugin_cxxflags        = -Wp,-MMD,$(depfile) $(KBUILD_HOSTCXXFLAGS) -fPIC \
+                 -include $(srctree)/include/linux/compiler-version.h \
                   -I $(GCC_PLUGINS_DIR)/include -I $(obj) -std=gnu++11 \
                   -fno-rtti -fno-exceptions -fasynchronous-unwind-tables \
                   -ggdb -Wno-narrowing -Wno-unused-variable \
index a463273509b56bfce6157fc47e16b014971c3086..1bf3aadde9def9d18628c445751d00fbf46c4928 100755 (executable)
@@ -29,7 +29,7 @@ orig_args="$@"
 # Get the first line of the --version output.
 IFS='
 '
-set -- $("$@" --version)
+set -- $(LC_ALL=C "$@" --version)
 
 # Split the line on spaces.
 IFS=' '
@@ -44,14 +44,20 @@ if [ "$1" = GNU -a "$2" = ld ]; then
 elif [ "$1" = GNU -a "$2" = gold ]; then
        echo "gold linker is not supported as it is not capable of linking the kernel proper." >&2
        exit 1
-elif [ "$1" = LLD ]; then
-       version=$2
-       min_version=$lld_min_version
-       name=LLD
-       disp_name=LLD
 else
-       echo "$orig_args: unknown linker" >&2
-       exit 1
+       while [ $# -gt 1 -a "$1" != "LLD" ]; do
+               shift
+       done
+
+       if [ "$1" = LLD ]; then
+               version=$2
+               min_version=$lld_min_version
+               name=LLD
+               disp_name=LLD
+       else
+               echo "$orig_args: unknown linker" >&2
+               exit 1
+       fi
 fi
 
 # Some distributions append a package release number, as in 2.34-4.fc32
index 28f4d25480dfa018afd0703f714443f14843079d..1c519c87521765a0a474100a8b4309c44f44c3c5 100644 (file)
@@ -543,8 +543,7 @@ int cap_convert_nscap(struct user_namespace *mnt_userns, struct dentry *dentry,
        __u32 magic, nsmagic;
        struct inode *inode = d_backing_inode(dentry);
        struct user_namespace *task_ns = current_user_ns(),
-               *fs_ns = inode->i_sb->s_user_ns,
-               *ancestor;
+               *fs_ns = inode->i_sb->s_user_ns;
        kuid_t rootid;
        size_t newsize;
 
@@ -567,15 +566,6 @@ int cap_convert_nscap(struct user_namespace *mnt_userns, struct dentry *dentry,
        if (nsrootid == -1)
                return -EINVAL;
 
-       /*
-        * Do not allow allow adding a v3 filesystem capability xattr
-        * if the rootid field is ambiguous.
-        */
-       for (ancestor = task_ns->parent; ancestor; ancestor = ancestor->parent) {
-               if (from_kuid(ancestor, rootid) == 0)
-                       return -EINVAL;
-       }
-
        newsize = sizeof(struct vfs_ns_cap_data);
        nscap = kmalloc(newsize, GFP_ATOMIC);
        if (!nscap)
index 8a24e5ae7cef4e7b5f60b4f331d7c8750bea8799..52637180af3366e0472c9d23e820dbe46c8691d4 100644 (file)
@@ -33,7 +33,6 @@
 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 MODULE_DESCRIPTION("A loopback soundcard");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{ALSA,Loopback soundcard}}");
 
 #define MAX_PCM_SUBSTREAMS     8
 
index 316c9afadefee1740a1437d8a2dadf1934d453b5..01a3eab50d7b93c9ac1a8ac542a8249840c67d5d 100644 (file)
@@ -25,7 +25,6 @@
 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 MODULE_DESCRIPTION("Dummy soundcard (/dev/null)");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{ALSA,Dummy soundcard}}");
 
 #define MAX_PCM_DEVICES                4
 #define MAX_PCM_SUBSTREAMS     128
index ce5fd17bd720888e57c84db55444a03dcc75198b..df4b7f9cd50f6ceaef08c6673e65d7f93591a45f 100644 (file)
@@ -53,7 +53,6 @@
 MODULE_AUTHOR("Michael T. Mayers");
 MODULE_DESCRIPTION("MOTU MidiTimePiece AV multiport MIDI");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{MOTU,MidiTimePiece AV multiport MIDI}}");
 
 // io resources
 #define MTPAV_IOBASE           0x378
index 9c708b693cb330b42ede0ffbf6cb37519c4d4f67..322d530ab07b87cf9a1da290ae7ae71fa9fa2da1 100644 (file)
@@ -37,7 +37,6 @@ MODULE_PARM_DESC(enable, "Enable " CARD_NAME " soundcard.");
 MODULE_AUTHOR("Matthias Koenig <mk@phasorlab.de>");
 MODULE_DESCRIPTION("ESI Miditerminal 4140");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{ESI,Miditerminal 4140}}");
 
 /*********************************************************************
  * Chip specific
index fd79e57c85caec55f5a922d408edf031ea5acca7..7689fa2f953141ddb8ba02036e79cd374cc41d0e 100644 (file)
@@ -22,7 +22,6 @@
 MODULE_AUTHOR("Stas Sergeev <stsp@users.sourceforge.net>");
 MODULE_DESCRIPTION("PC-Speaker driver");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{PC-Speaker, pcsp}}");
 MODULE_ALIAS("platform:pcspkr");
 
 static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
index c876cf9b500531e38e658c2a3af781cbafebc9d1..2f4514ed47c5ef69eee470c948f31bc16c5abd27 100644 (file)
@@ -57,7 +57,6 @@ MODULE_PARM_DESC(enable, "Enable " CARD_NAME " soundcard.");
 MODULE_AUTHOR("Levent Guendogdu, Tobias Gehrig, Matthias Koenig");
 MODULE_DESCRIPTION("Midiman Portman2x4");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Midiman,Portman2x4}}");
 
 /*********************************************************************
  * Chip specific
index 3947f084dd6becdf123a454223f16509a788c919..6d5d1ca59ecfe3af2d16406cbf4118e7302d32ef 100644 (file)
@@ -34,7 +34,6 @@
 
 MODULE_DESCRIPTION("MIDI serial u16550");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{ALSA, MIDI serial u16550}}");
 
 #define SNDRV_SERIAL_SOUNDCANVAS 0 /* Roland Soundcanvas; F5 NN selects part */
 #define SNDRV_SERIAL_MS124T 1      /* Midiator MS-124T */
index f1fb68b15498f28cc22d626b33fc7508483cab52..4206d93ab47e40f97fd45ff0a0090dfbaedfb82c 100644 (file)
@@ -43,7 +43,6 @@
 MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
 MODULE_DESCRIPTION("Dummy soundcard for virtual rawmidi devices");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{ALSA,Virtual rawmidi device}}");
 
 #define MAX_MIDI_DEVICES       4
 
index 8e0c0380b4c4bdf11389e7bc38d2b7d5df9a213a..1a14c083e8ceaac63488d37f367878323d5a7459 100644 (file)
@@ -493,11 +493,10 @@ void snd_dice_stream_stop_duplex(struct snd_dice *dice)
        struct reg_params tx_params, rx_params;
 
        if (dice->substreams_counter == 0) {
-               if (get_register_params(dice, &tx_params, &rx_params) >= 0) {
-                       amdtp_domain_stop(&dice->domain);
+               if (get_register_params(dice, &tx_params, &rx_params) >= 0)
                        finish_session(dice, &tx_params, &rx_params);
-               }
 
+               amdtp_domain_stop(&dice->domain);
                release_resources(dice);
        }
 }
index d053beccfaec3e0f789b928f2a20b14fc4b00a47..e2237239d922a7c778148a160560340e97a95660 100644 (file)
@@ -39,6 +39,11 @@ int intel_nhlt_get_dmic_geo(struct device *dev, struct nhlt_acpi_table *nhlt)
        if (!nhlt)
                return 0;
 
+       if (nhlt->header.length <= sizeof(struct acpi_table_header)) {
+               dev_warn(dev, "Invalid DMIC description table\n");
+               return 0;
+       }
+
        for (j = 0, epnt = nhlt->desc; j < nhlt->endpoint_count; j++,
             epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length)) {
 
index ca18fe3ff8a59a9fc9745225ed76ba48d40eac80..f11af983b3b6ec1fe302ce743d711999d6b670f8 100644 (file)
 MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
 MODULE_DESCRIPTION("AD1816A, AD1815");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Highscreen,Sound-Boostar 16 3D},"
-               "{Analog Devices,AD1815},"
-               "{Analog Devices,AD1816A},"
-               "{TerraTec,Base 64},"
-               "{TerraTec,AudioSystem EWS64S},"
-               "{Aztech/Newcom SC-16 3D},"
-               "{Shark Predator ISA}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 1-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
index 6f221eed44e2110118c485141769153bfb45d1e4..edafb49797e7499ef9bbb53434e16da401d6b210 100644 (file)
@@ -22,9 +22,6 @@
 MODULE_DESCRIPTION(CRD_NAME);
 MODULE_AUTHOR("Tugrul Galatali <galatalt@stuy.edu>, Jaroslav Kysela <perex@perex.cz>");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Analog Devices,AD1848},"
-               "{Analog Devices,AD1847},"
-               "{Crystal Semiconductors,CS4248}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
index 1085f5b0131802e4201a7c97f95fee32186b05c0..bacb7a1b930c0bd15d4bb52425a89fc2672c427a 100644 (file)
 #define PFX "als100: "
 
 MODULE_DESCRIPTION("Avance Logic ALS007/ALS1X0");
-MODULE_SUPPORTED_DEVICE("{{Diamond Technologies DT-019X},"
-               "{Avance Logic ALS-007}}"
-               "{{Avance Logic,ALS100 - PRO16PNP},"
-               "{Avance Logic,ALS110},"
-               "{Avance Logic,ALS120},"
-               "{Avance Logic,ALS200},"
-               "{3D Melody,MF1000},"
-               "{Digimate,3D Sound},"
-               "{Avance Logic,ALS120},"
-               "{RTL,RTL3000}}");
-
 MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
 MODULE_LICENSE("GPL");
 
index 4ed52094fc8d87eefdd78ae38746564e97f93877..867e9ae8f65aa0db9d18ecddb3710ef2ef18a492 100644 (file)
 MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
 MODULE_DESCRIPTION("Aztech Systems AZT2320");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Aztech Systems,PRO16V},"
-               "{Aztech Systems,AZT2320},"
-               "{Aztech Systems,AZT3300},"
-               "{Aztech Systems,AZT2320},"
-               "{Aztech Systems,AZT3000}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
index 19e258527d690764b3819f0bb2f7e8721c9e6c25..bc112df10fc5748b330a3e910a6b03876a701930 100644 (file)
@@ -51,7 +51,6 @@
 MODULE_AUTHOR("George Talusan <gstalusan@uwaterloo.ca>");
 MODULE_DESCRIPTION("C-Media CMI8330/CMI8329");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{C-Media,CMI8330,isapnp:{CMI0001,@@@0001,@X@0001}}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
index c56cbc072918adcb7ab568795b868643e42348b2..ec054b929214e55324ce775f3402236b685567b8 100644 (file)
@@ -23,7 +23,6 @@
 MODULE_DESCRIPTION(CRD_NAME);
 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Crystal Semiconductors,CS4231}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
index 63fb0cb754d07f51b410207c330a584d4c76aefa..186d7d4db45eccb68fd984a18448e896d8696044 100644 (file)
 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Cirrus Logic CS4232-9");
-MODULE_SUPPORTED_DEVICE("{{Turtle Beach,TBS-2000},"
-               "{Turtle Beach,Tropez Plus},"
-               "{SIC CrystalWave 32},"
-               "{Hewlett Packard,Omnibook 5500},"
-               "{TerraTec,Maestro 32/96},"
-               "{Philips,PCA70PS}},"
-               "{{Crystal Semiconductors,CS4235},"
-               "{Crystal Semiconductors,CS4236},"
-               "{Crystal Semiconductors,CS4237},"
-               "{Crystal Semiconductors,CS4238},"
-               "{Crystal Semiconductors,CS4239},"
-               "{Acer,AW37},"
-               "{Acer,AW35/Pro},"
-               "{Crystal,3D},"
-               "{Crystal Computer,TidalWave128},"
-               "{Dell,Optiplex GX1},"
-               "{Dell,Workstation 400 sound},"
-               "{EliteGroup,P5TX-LA sound},"
-               "{Gallant,SC-70P},"
-               "{Gateway,E1000 Onboard CS4236B},"
-               "{Genius,Sound Maker 3DJ},"
-               "{Hewlett Packard,HP6330 sound},"
-               "{IBM,PC 300PL sound},"
-               "{IBM,Aptiva 2137 E24},"
-               "{IBM,IntelliStation M Pro},"
-               "{Intel,Marlin Spike Mobo CS4235},"
-               "{Intel PR440FX Onboard},"
-               "{Guillemot,MaxiSound 16 PnP},"
-               "{NewClear,3D},"
-               "{TerraTec,AudioSystem EWS64L/XL},"
-               "{Typhoon Soundsystem,CS4236B},"
-               "{Turtle Beach,Malibu},"
-               "{Unknown,Digital PC 5000 Onboard}}");
-
 MODULE_ALIAS("snd_cs4232");
 
 #define IDENT "CS4232+"
index 4a1f61f1a3310765d4007713db0f24c19607973f..750d4995634ff57d65dabdd42b0b550388478e42 100644 (file)
 MODULE_DESCRIPTION(CRD_NAME);
 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{ESS,ES688 PnP AudioDrive,pnp:ESS0100},"
-               "{ESS,ES1688 PnP AudioDrive,pnp:ESS0102},"
-               "{ESS,ES688 AudioDrive,pnp:ESS6881},"
-               "{ESS,ES1688 AudioDrive,pnp:ESS1681}}");
-
 MODULE_ALIAS("snd_es968");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
index 9beef807917753587418252b624325b297edc51c..375a4a6a4717fbb2b0b96e367b6f4065d0bff590 100644 (file)
@@ -1929,17 +1929,9 @@ static int snd_es18xx_mixer(struct snd_card *card)
 
 /* Card level */
 
-MODULE_AUTHOR("Christian Fischbach <fishbach@pool.informatik.rwth-aachen.de>, Abramo Bagnara <abramo@alsa-project.org>");  
+MODULE_AUTHOR("Christian Fischbach <fishbach@pool.informatik.rwth-aachen.de>, Abramo Bagnara <abramo@alsa-project.org>");
 MODULE_DESCRIPTION("ESS ES18xx AudioDrive");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{ESS,ES1868 PnP AudioDrive},"
-               "{ESS,ES1869 PnP AudioDrive},"
-               "{ESS,ES1878 PnP AudioDrive},"
-               "{ESS,ES1879 PnP AudioDrive},"
-               "{ESS,ES1887 PnP AudioDrive},"
-               "{ESS,ES1888 PnP AudioDrive},"
-               "{ESS,ES1887 AudioDrive},"
-               "{ESS,ES1888 AudioDrive}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
index 015f88a113524fb815a5f951ffd0259d782a2af7..0fba5d8fe84f5258400f70a40c01f5592e579df2 100644 (file)
@@ -23,7 +23,6 @@
 MODULE_DESCRIPTION(CRD_NAME);
 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Gravis,UltraSound Classic}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
index c9f31b4fb88737ea789b24ca8d2878f0a4c6c600..da2b2ca6b721148cf344ee31c84ae8bdf2bee089 100644 (file)
@@ -27,7 +27,6 @@
 MODULE_DESCRIPTION(CRD_NAME);
 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Gravis,UltraSound Extreme}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
index dc09fbd6f88da5d10c8ca2a71fff754edfdbd43c..24b945f1768d0874d5f3b2c94f1bfaac83fd4732 100644 (file)
@@ -21,7 +21,6 @@
 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 MODULE_DESCRIPTION("Gravis UltraSound MAX");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Gravis,UltraSound MAX}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
index e4d412e72b75afaf56882eb668785d8f54b6722d..99581fba4ca8ae3bc4e1f81110132236684139f9 100644 (file)
@@ -28,14 +28,8 @@ MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 MODULE_LICENSE("GPL");
 #ifndef SNDRV_STB
 MODULE_DESCRIPTION("AMD InterWave");
-MODULE_SUPPORTED_DEVICE("{{Gravis,UltraSound Plug & Play},"
-               "{STB,SoundRage32},"
-               "{MED,MED3210},"
-               "{Dynasonix,Dynasonix Pro},"
-               "{Panasonic,PCA761AW}}");
 #else
 MODULE_DESCRIPTION("AMD InterWave STB with TEA6330T");
-MODULE_SUPPORTED_DEVICE("{{AMD,InterWave STB with TEA6330T}}");
 #endif
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
index 7649a8a4128d10c081d49a538b839f04211980fd..9bde11d1cfe864839a3e504bbbc12c2a6bf325bf 100644 (file)
 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 MODULE_DESCRIPTION("Yamaha OPL3SA2+");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Yamaha,YMF719E-S},"
-               "{Genius,Sound Maker 3DX},"
-               "{Yamaha,OPL3SA3},"
-               "{Intel,AL440LX sound},"
-               "{NeoMagic,MagicWave 3DX}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
index 20933342f5eb3f088327f49452f8fad2c89f0e09..a510b201143cfa18591a8619e656d0059a244f78 100644 (file)
@@ -33,9 +33,6 @@
 MODULE_AUTHOR("Martin Langer <martin-langer@gmx.de>");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Miro miroSOUND PCM1 pro, PCM12, PCM20 Radio");
-MODULE_SUPPORTED_DEVICE("{{Miro,miroSOUND PCM1 pro}, "
-                       "{Miro,miroSOUND PCM12}, "
-                       "{Miro,miroSOUND PCM20 Radio}}");
 
 static int index = SNDRV_DEFAULT_IDX1;         /* Index 0-MAX */
 static char *id = SNDRV_DEFAULT_STR1;          /* ID for this card */
index 758f5b579138ac3ad13c4e2ce81cc0782de413e3..08e61d90057b60035194188161281e5f6d703b18 100644 (file)
@@ -36,17 +36,11 @@ MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
 MODULE_LICENSE("GPL");
 #ifdef OPTi93X
 MODULE_DESCRIPTION("OPTi93X");
-MODULE_SUPPORTED_DEVICE("{{OPTi,82C931/3}}");
 #else  /* OPTi93X */
 #ifdef CS4231
 MODULE_DESCRIPTION("OPTi92X - CS4231");
-MODULE_SUPPORTED_DEVICE("{{OPTi,82C924 (CS4231)},"
-               "{OPTi,82C925 (CS4231)}}");
 #else  /* CS4231 */
 MODULE_DESCRIPTION("OPTi92X - AD1848");
-MODULE_SUPPORTED_DEVICE("{{OPTi,82C924 (AD1848)},"
-               "{OPTi,82C925 (AD1848)},"
-               "{OAK,Mozart}}");
 #endif /* CS4231 */
 #endif /* OPTi93X */
 
index 0e2e0ab3b9e4c6559f07e35c85ebb9be67956943..7ba5dd1ec810d2af14b955a5ded72df6a80b44af 100644 (file)
@@ -28,9 +28,6 @@
 #define PFX "jazz16: "
 
 MODULE_DESCRIPTION("Media Vision Jazz16");
-MODULE_SUPPORTED_DEVICE("{{Media Vision ??? },"
-               "{RTL,RTL3000}}");
-
 MODULE_AUTHOR("Krzysztof Helt <krzysztof.h1@wp.pl>");
 MODULE_LICENSE("GPL");
 
index db284b7b88a7342343da831a48544d90f7952580..63ef960abd25f3282213676bea9256a57587c450 100644 (file)
@@ -31,16 +31,8 @@ MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 MODULE_LICENSE("GPL");
 #ifndef SNDRV_SBAWE
 MODULE_DESCRIPTION("Sound Blaster 16");
-MODULE_SUPPORTED_DEVICE("{{Creative Labs,SB 16},"
-               "{Creative Labs,SB Vibra16S},"
-               "{Creative Labs,SB Vibra16C},"
-               "{Creative Labs,SB Vibra16CL},"
-               "{Creative Labs,SB Vibra16X}}");
 #else
 MODULE_DESCRIPTION("Sound Blaster AWE");
-MODULE_SUPPORTED_DEVICE("{{Creative Labs,SB AWE 32},"
-               "{Creative Labs,SB AWE 64},"
-               "{Creative Labs,SB AWE 64 Gold}}");
 #endif
 
 #if 0
index 8e3e67b9a3414f36c83af62356d3bec99abd0599..6c9d534ce8b6133f57cd0f47dfd61b7a2945e83e 100644 (file)
@@ -17,7 +17,6 @@
 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 MODULE_DESCRIPTION("Sound Blaster 1.0/2.0/Pro");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Creative Labs,SB 1.0/SB 2.0/SB Pro}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
index def13757971712e5c6c62250e3346e9cc7acb44e..3462663050bb54b22e61b09780c3f5bbe9cfdc93 100644 (file)
@@ -29,9 +29,6 @@
 MODULE_AUTHOR("Krzysztof Helt");
 MODULE_DESCRIPTION("Gallant SC-6000");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Gallant, SC-6000},"
-                       "{AudioExcel, Audio Excel DSP 16},"
-                       "{Zoltrix, AV302}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
index b750a4fd40de7cc4d754d114efbdfe8b325f1831..a4437971df2fdb881896a24569547e756dc503ea 100644 (file)
@@ -21,7 +21,6 @@
 MODULE_AUTHOR("Paul Barton-Davis <pbd@op.net>");
 MODULE_DESCRIPTION("Turtle Beach Wavefront");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Turtle Beach,Maui/Tropez/Tropez+}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;         /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;          /* ID for this card */
index 5bf1ea150f26478791014bef55da611f1780a924..989f656e2de7dbf6f5ca6350e35d5a5d26737bb0 100644 (file)
@@ -32,7 +32,6 @@
 MODULE_AUTHOR("Vivien Chappelier <vivien.chappelier@linux-mips.org>");
 MODULE_DESCRIPTION("SGI O2 Audio");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Silicon Graphics, O2 Audio}}");
 
 static int index = SNDRV_DEFAULT_IDX1;  /* Index 0-MAX */
 static char *id = SNDRV_DEFAULT_STR1;   /* ID for this card */
index 5d835d2af0549068f927fe702b6253d31aed2154..4520022801d90df222620f1bfff6fdd5f143b2d5 100644 (file)
@@ -43,7 +43,6 @@
 MODULE_AUTHOR("Kyle McMartin <kyle@parisc-linux.org>, Thibaut Varene <t-bone@parisc-linux.org>");
 MODULE_DESCRIPTION("Analog Devices AD1889 ALSA sound driver");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Analog Devices,AD1889}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
 module_param_array(index, int, NULL, 0444);
index 51f24796f03faebfce4a1224039f041878d4076f..0d66b92466d54413ee85c18ca86ae6cc356b7f91 100644 (file)
@@ -29,7 +29,6 @@
 MODULE_AUTHOR("Matt Wu <Matt_Wu@acersoftech.com.cn>");
 MODULE_DESCRIPTION("ALI M5451");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{ALI,M5451,pci},{ALI,M5451}}");
 
 static int index = SNDRV_DEFAULT_IDX1; /* Index */
 static char *id = SNDRV_DEFAULT_STR1;  /* ID for this card */
index 1dc8c4ed0592bd5c69322829e205ce4399360101..bd4fd09e982b6ded655bea86e8ff1f0fdf84f5d7 100644 (file)
@@ -86,7 +86,6 @@ enum {DEVICE_ALS300, DEVICE_ALS300_PLUS};
 MODULE_AUTHOR("Ash Willis <ashwillis@programmer.net>");
 MODULE_DESCRIPTION("Avance Logic ALS300");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Avance Logic,ALS300},{Avance Logic,ALS300+}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
index 2edc7455285a47263f85845182fc3ab5bbd27a5a..139ac2a3a0efa0557e76337ea681f8f9acc42e31 100644 (file)
@@ -68,7 +68,6 @@
 MODULE_AUTHOR("Bart Hartgers <bart@etpmod.phys.tue.nl>, Andreas Mohr");
 MODULE_DESCRIPTION("Avance Logic ALS4000");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Avance Logic,ALS4000}}");
 
 #if IS_REACHABLE(CONFIG_GAMEPORT)
 #define SUPPORT_JOYSTICK 1
index a25d754558028aa0cf4ee18f2c5d6430b660b5f5..579425ccbb6a86e2bf856e8e3bc8e1418942ac46 100644 (file)
@@ -23,7 +23,6 @@
 MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
 MODULE_DESCRIPTION("ATI IXP AC97 controller");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{ATI,IXP150/200/250/300/400/600}}");
 
 static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
 static char *id = SNDRV_DEFAULT_STR1;  /* ID for this card */
index ae88217d685a96ee1a7e6946d7e6257fdc3fb696..45e75afec7a0c228c4cdc13cf764841ffd051e33 100644 (file)
@@ -23,7 +23,6 @@
 MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
 MODULE_DESCRIPTION("ATI IXP MC97 controller");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{ATI,IXP150/200/250}}");
 
 static int index = -2; /* Exclude the first card */
 static char *id = SNDRV_DEFAULT_STR1;  /* ID for this card */
index 5dd98e6ff34b9369c6ae232bd3091c5c93287c14..1b37b7225b1dcce2ab2f0f5fcead35b0a779af85 100644 (file)
@@ -41,8 +41,6 @@ MODULE_PARM_DESC(pcifix, "Enable VIA-workaround for " CARD_NAME " soundcard.");
 
 MODULE_DESCRIPTION("Aureal vortex");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Aureal Semiconductor Inc., Aureal Vortex Sound Processor}}");
-
 MODULE_DEVICE_TABLE(pci, snd_vortex_ids);
 
 static void vortex_fix_latency(struct pci_dev *vortex)
index 2ac594dcf21c8d88b8f959e57d2e2a0c694b4817..51dcf1bc4c0cfaca39433713a378d043a310135e 100644 (file)
 MODULE_AUTHOR("Andreas Mohr <andi AT lisas.de>");
 MODULE_DESCRIPTION("Aztech AZF3328 (PCI168)");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Aztech,AZF3328}}");
 
 #if IS_REACHABLE(CONFIG_GAMEPORT)
 #define SUPPORT_GAMEPORT 1
index cf9f8d80a0b61daf1900101a220b707e59b71c7c..91512b345d19b78b38e3baa6c82913b31f4cc9a9 100644 (file)
@@ -23,8 +23,6 @@
 MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
 MODULE_DESCRIPTION("Brooktree Bt87x audio driver");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Brooktree,Bt878},"
-               "{Brooktree,Bt879}}");
 
 static int index[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -2}; /* Exclude the first card */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
index ee20f9a1aae98d0188b355c7cebd5bf2e5132729..bee4710916c4707575d00b242c718c3847220b86 100644 (file)
 MODULE_AUTHOR("James Courtier-Dutton <James@superbug.demon.co.uk>");
 MODULE_DESCRIPTION("CA0106");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Creative,SB CA0106 chip}}");
 
 // module parameters (see "Module Parameters")
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
index 7363d61eaec23fc6754d5d39dbf8717dfc9d1d89..598446348da6356d6f1472fea48103b487c34e85 100644 (file)
 MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
 MODULE_DESCRIPTION("C-Media CMI8x38 PCI");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{C-Media,CMI8738},"
-               "{C-Media,CMI8738B},"
-               "{C-Media,CMI8338A},"
-               "{C-Media,CMI8338B}}");
 
 #if IS_REACHABLE(CONFIG_GAMEPORT)
 #define SUPPORT_JOYSTICK 1
index 94d2a6a466a8ceb94a98866a8da49697c49380e3..bf3bb70ffaf92a8ef18bae4415aa02e5152e2fa3 100644 (file)
@@ -25,7 +25,6 @@
 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 MODULE_DESCRIPTION("Cirrus Logic CS4281");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Cirrus Logic,CS4281}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
index a6e0a44393323f932cef6f88663dd5c0dbe2b019..1db7b411284028162dc3f0f4ee7d941266be3e61 100644 (file)
 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 MODULE_DESCRIPTION("Cirrus Logic Sound Fusion CS46XX");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Cirrus Logic,Sound Fusion (CS4280)},"
-               "{Cirrus Logic,Sound Fusion (CS4610)},"
-               "{Cirrus Logic,Sound Fusion (CS4612)},"
-               "{Cirrus Logic,Sound Fusion (CS4615)},"
-               "{Cirrus Logic,Sound Fusion (CS4622)},"
-               "{Cirrus Logic,Sound Fusion (CS4624)},"
-               "{Cirrus Logic,Sound Fusion (CS4630)}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
index 359bc6af867085da309a4f436c8eb7b4e92ff5dd..9b716b56d7392d001804770df449371e24d4eca7 100644 (file)
@@ -393,4 +393,3 @@ module_pci_driver(cs5535audio_driver);
 MODULE_AUTHOR("Jaya Kumar");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("CS5535 Audio");
-MODULE_SUPPORTED_DEVICE("CS5535 Audio");
index 8c07c6463c246f72e4e8eaa59f7dbb910c347169..713d36ea40cb5cd8bfc5b28165b3b94846aaabb9 100644 (file)
@@ -18,7 +18,6 @@
 MODULE_AUTHOR("Creative Technology Ltd");
 MODULE_DESCRIPTION("X-Fi driver version 1.03");
 MODULE_LICENSE("GPL v2");
-MODULE_SUPPORTED_DEVICE("{{Creative Labs, Sound Blaster X-Fi}");
 
 static unsigned int reference_rate = 48000;
 static unsigned int multiple = 2;
index a20b2bb5c898df01a6d5f7bd20fe2ab0d7765170..9bd67ac336575fe0abcc48ce9fad3ebaa2883477 100644 (file)
@@ -10,7 +10,6 @@
 MODULE_AUTHOR("Giuliano Pochini <pochini@shiny.it>");
 MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("Echoaudio " ECHOCARD_NAME " soundcards driver");
-MODULE_SUPPORTED_DEVICE("{{Echoaudio," ECHOCARD_NAME "}}");
 MODULE_DEVICE_TABLE(pci, snd_echo_ids);
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
index 353934c88cbd8340be10f87b1717047f3c9804c8..45833bc2a7e76716bcb67754e3188847063cdbd5 100644 (file)
@@ -18,8 +18,6 @@
 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 MODULE_DESCRIPTION("EMU10K1");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Creative Labs,SB Live!/PCI512/E-mu APS},"
-              "{Creative Labs,SB Audigy}}");
 
 #if IS_ENABLED(CONFIG_SND_SEQUENCER)
 #define ENABLE_SYNTH
index 785ec0cf3933a377fe56027fde6588ace3aa48be..d9a12cd01647878ca618a96d9c2cd99b38a096b4 100644 (file)
@@ -31,7 +31,6 @@
 MODULE_AUTHOR("Francisco Moraes <fmoraes@nc.rr.com>");
 MODULE_DESCRIPTION("EMU10K1X");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Dell Creative Labs,SB Live!}");
 
 // module parameters (see "Module Parameters")
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
index 93c4fd31331152dc7c0d60c6f326f69188010f34..3ccccdbc00298eedaa401a890be74b4264c06f16 100644 (file)
@@ -52,17 +52,9 @@ MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>, Thomas Sailer <sailer@ife.ee.et
 MODULE_LICENSE("GPL");
 #ifdef CHIP1370
 MODULE_DESCRIPTION("Ensoniq AudioPCI ES1370");
-MODULE_SUPPORTED_DEVICE("{{Ensoniq,AudioPCI-97 ES1370},"
-               "{Creative Labs,SB PCI64/128 (ES1370)}}");
 #endif
 #ifdef CHIP1371
 MODULE_DESCRIPTION("Ensoniq/Creative AudioPCI ES1371+");
-MODULE_SUPPORTED_DEVICE("{{Ensoniq,AudioPCI ES1371/73},"
-               "{Ensoniq,AudioPCI ES1373},"
-               "{Creative Labs,Ectiva EV1938},"
-               "{Creative Labs,SB PCI64/128 (ES1371/73)},"
-               "{Creative Labs,Vibra PCI128},"
-               "{Ectiva,EV1938}}");
 #endif
 
 #if IS_REACHABLE(CONFIG_GAMEPORT)
index 3b5d68ce9dd55b877467baf253e4856b1b10b945..afc66347d16247aacb782f240d2e1c1eae8e2744 100644 (file)
 MODULE_AUTHOR("Jaromir Koutek <miri@punknet.cz>");
 MODULE_DESCRIPTION("ESS Solo-1");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{ESS,ES1938},"
-                "{ESS,ES1946},"
-                "{ESS,ES1969},"
-               "{TerraTec,128i PCI}}");
 
 #if IS_REACHABLE(CONFIG_GAMEPORT)
 #define SUPPORT_JOYSTICK 1
index 747fa69bb1c90c4454af94fe9cf0780ca42e0eda..5fa1861236f5932f57d41663a150806a02b2b023 100644 (file)
 
 MODULE_DESCRIPTION("ESS Maestro");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{ESS,Maestro 2e},"
-               "{ESS,Maestro 2},"
-               "{ESS,Maestro 1},"
-               "{TerraTec,DMX}}");
 
 #if IS_REACHABLE(CONFIG_GAMEPORT)
 #define SUPPORT_JOYSTICK 1
index c6ad6235a66993c7d4a401af09eeefe766bb5e51..6279eb156e36d49cf7201a1342e50d269fb3dbfe 100644 (file)
@@ -26,8 +26,6 @@
 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 MODULE_DESCRIPTION("ForteMedia FM801");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{ForteMedia,FM801},"
-               "{Genius,SoundMaker Live 5.1}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
index 6a85645663759d097e2615444ae72618fb915526..17a25e453f60cc31cfdf5fca04d1369c400e235c 100644 (file)
@@ -47,6 +47,10 @@ static void hda_codec_unsol_event(struct hdac_device *dev, unsigned int ev)
        if (codec->bus->shutdown)
                return;
 
+       /* ignore unsol events during system suspend/resume */
+       if (codec->core.dev.power.power_state.event != PM_EVENT_ON)
+               return;
+
        if (codec->patch_ops.unsol_event)
                codec->patch_ops.unsol_event(codec, ev);
 }
index 9087981cd1f709f8b9a785d8fce079e28f46920a..ca2f2ecd14888115ad4e712b4d68b093f03ded1e 100644 (file)
@@ -609,13 +609,6 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)
                                     20,
                                     178000000);
 
-       /* by some reason, the playback stream stalls on PulseAudio with
-        * tsched=1 when a capture stream triggers.  Until we figure out the
-        * real cause, disable tsched mode by telling the PCM info flag.
-        */
-       if (chip->driver_caps & AZX_DCAPS_AMD_WORKAROUND)
-               runtime->hw.info |= SNDRV_PCM_INFO_BATCH;
-
        if (chip->align_buffer_size)
                /* constrain buffer sizes to be multiple of 128
                   bytes. This is more efficient in terms of memory
index 8b7c5508f368886623a70ce65937e78eb4fdb491..f5cba7afd1c662e2e5ced46397ef1924f26cb91b 100644 (file)
@@ -4065,7 +4065,7 @@ static int add_micmute_led_hook(struct hda_codec *codec)
 
        spec->micmute_led.led_mode = MICMUTE_LED_FOLLOW_MUTE;
        spec->micmute_led.capture = 0;
-       spec->micmute_led.led_value = 0;
+       spec->micmute_led.led_value = -1;
        spec->micmute_led.old_hook = spec->cap_sync_hook;
        spec->cap_sync_hook = update_micmute_led;
        if (!snd_hda_gen_add_kctl(spec, NULL, &micmute_led_mode_ctl))
index 5b492c3f816c1841a505fbea44af20178ab0d744..b59b0f323d4e0271598767bec73a1117bba650ce 100644 (file)
@@ -208,40 +208,6 @@ MODULE_PARM_DESC(snoop, "Enable/disable snooping");
 
 
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Intel, ICH6},"
-                        "{Intel, ICH6M},"
-                        "{Intel, ICH7},"
-                        "{Intel, ESB2},"
-                        "{Intel, ICH8},"
-                        "{Intel, ICH9},"
-                        "{Intel, ICH10},"
-                        "{Intel, PCH},"
-                        "{Intel, CPT},"
-                        "{Intel, PPT},"
-                        "{Intel, LPT},"
-                        "{Intel, LPT_LP},"
-                        "{Intel, WPT_LP},"
-                        "{Intel, SPT},"
-                        "{Intel, SPT_LP},"
-                        "{Intel, HPT},"
-                        "{Intel, PBG},"
-                        "{Intel, SCH},"
-                        "{ATI, SB450},"
-                        "{ATI, SB600},"
-                        "{ATI, RS600},"
-                        "{ATI, RS690},"
-                        "{ATI, RS780},"
-                        "{ATI, R600},"
-                        "{ATI, RV630},"
-                        "{ATI, RV610},"
-                        "{ATI, RV670},"
-                        "{ATI, RV635},"
-                        "{ATI, RV620},"
-                        "{ATI, RV770},"
-                        "{VIA, VT8251},"
-                        "{VIA, VT8237A},"
-                        "{SiS, SIS966},"
-                        "{ULI, M5461}}");
 MODULE_DESCRIPTION("Intel HDA driver");
 
 #if defined(CONFIG_PM) && defined(CONFIG_VGA_SWITCHEROO)
@@ -1026,6 +992,8 @@ static int azx_prepare(struct device *dev)
        chip = card->private_data;
        chip->pm_prepared = 1;
 
+       flush_work(&azx_bus(chip)->unsol_work);
+
        /* HDA controller always requires different WAKEEN for runtime suspend
         * and system suspend, so don't use direct-complete here.
         */
index c966f49fa942a1ac6d3e7148b2294d163bee6a60..b2b620f6c832094efd4a70bb0dfea6fec21901ed 100644 (file)
@@ -1309,6 +1309,7 @@ static const struct snd_pci_quirk ca0132_quirks[] = {
        SND_PCI_QUIRK(0x1102, 0x0013, "Recon3D", QUIRK_R3D),
        SND_PCI_QUIRK(0x1102, 0x0018, "Recon3D", QUIRK_R3D),
        SND_PCI_QUIRK(0x1102, 0x0051, "Sound Blaster AE-5", QUIRK_AE5),
+       SND_PCI_QUIRK(0x1102, 0x0191, "Sound Blaster AE-5 Plus", QUIRK_AE5),
        SND_PCI_QUIRK(0x1102, 0x0081, "Sound Blaster AE-7", QUIRK_AE7),
        {}
 };
index f2aa226d1373d1c680ae99662f8047729dc0d71b..c20dad46a7c90314ad879cd9d9e291ca730756eb 100644 (file)
@@ -149,6 +149,21 @@ static int cx_auto_vmaster_mute_led(struct led_classdev *led_cdev,
        return 0;
 }
 
+static void cxt_init_gpio_led(struct hda_codec *codec)
+{
+       struct conexant_spec *spec = codec->spec;
+       unsigned int mask = spec->gpio_mute_led_mask | spec->gpio_mic_led_mask;
+
+       if (mask) {
+               snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK,
+                                   mask);
+               snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DIRECTION,
+                                   mask);
+               snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
+                                   spec->gpio_led);
+       }
+}
+
 static int cx_auto_init(struct hda_codec *codec)
 {
        struct conexant_spec *spec = codec->spec;
@@ -156,6 +171,7 @@ static int cx_auto_init(struct hda_codec *codec)
        if (!spec->dynamic_eapd)
                cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, true);
 
+       cxt_init_gpio_led(codec);
        snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT);
 
        return 0;
@@ -215,6 +231,7 @@ enum {
        CXT_FIXUP_HP_SPECTRE,
        CXT_FIXUP_HP_GATE_MIC,
        CXT_FIXUP_MUTE_LED_GPIO,
+       CXT_FIXUP_HP_ZBOOK_MUTE_LED,
        CXT_FIXUP_HEADSET_MIC,
        CXT_FIXUP_HP_MIC_NO_PRESENCE,
 };
@@ -654,31 +671,36 @@ static int cxt_gpio_micmute_update(struct led_classdev *led_cdev,
        return 0;
 }
 
-
-static void cxt_fixup_mute_led_gpio(struct hda_codec *codec,
-                               const struct hda_fixup *fix, int action)
+static void cxt_setup_mute_led(struct hda_codec *codec,
+                              unsigned int mute, unsigned int mic_mute)
 {
        struct conexant_spec *spec = codec->spec;
-       static const struct hda_verb gpio_init[] = {
-               { 0x01, AC_VERB_SET_GPIO_MASK, 0x03 },
-               { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03 },
-               {}
-       };
 
-       if (action == HDA_FIXUP_ACT_PRE_PROBE) {
+       spec->gpio_led = 0;
+       spec->mute_led_polarity = 0;
+       if (mute) {
                snd_hda_gen_add_mute_led_cdev(codec, cxt_gpio_mute_update);
-               spec->gpio_led = 0;
-               spec->mute_led_polarity = 0;
-               spec->gpio_mute_led_mask = 0x01;
-               spec->gpio_mic_led_mask = 0x02;
+               spec->gpio_mute_led_mask = mute;
+       }
+       if (mic_mute) {
                snd_hda_gen_add_micmute_led_cdev(codec, cxt_gpio_micmute_update);
+               spec->gpio_mic_led_mask = mic_mute;
        }
-       snd_hda_add_verbs(codec, gpio_init);
-       if (spec->gpio_led)
-               snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
-                                   spec->gpio_led);
 }
 
+static void cxt_fixup_mute_led_gpio(struct hda_codec *codec,
+                               const struct hda_fixup *fix, int action)
+{
+       if (action == HDA_FIXUP_ACT_PRE_PROBE)
+               cxt_setup_mute_led(codec, 0x01, 0x02);
+}
+
+static void cxt_fixup_hp_zbook_mute_led(struct hda_codec *codec,
+                                       const struct hda_fixup *fix, int action)
+{
+       if (action == HDA_FIXUP_ACT_PRE_PROBE)
+               cxt_setup_mute_led(codec, 0x10, 0x20);
+}
 
 /* ThinkPad X200 & co with cxt5051 */
 static const struct hda_pintbl cxt_pincfg_lenovo_x200[] = {
@@ -839,6 +861,10 @@ static const struct hda_fixup cxt_fixups[] = {
                .type = HDA_FIXUP_FUNC,
                .v.func = cxt_fixup_mute_led_gpio,
        },
+       [CXT_FIXUP_HP_ZBOOK_MUTE_LED] = {
+               .type = HDA_FIXUP_FUNC,
+               .v.func = cxt_fixup_hp_zbook_mute_led,
+       },
        [CXT_FIXUP_HEADSET_MIC] = {
                .type = HDA_FIXUP_FUNC,
                .v.func = cxt_fixup_headset_mic,
@@ -917,6 +943,7 @@ static const struct snd_pci_quirk cxt5066_fixups[] = {
        SND_PCI_QUIRK(0x103c, 0x8299, "HP 800 G3 SFF", CXT_FIXUP_HP_MIC_NO_PRESENCE),
        SND_PCI_QUIRK(0x103c, 0x829a, "HP 800 G3 DM", CXT_FIXUP_HP_MIC_NO_PRESENCE),
        SND_PCI_QUIRK(0x103c, 0x8402, "HP ProBook 645 G4", CXT_FIXUP_MUTE_LED_GPIO),
+       SND_PCI_QUIRK(0x103c, 0x8427, "HP ZBook Studio G5", CXT_FIXUP_HP_ZBOOK_MUTE_LED),
        SND_PCI_QUIRK(0x103c, 0x8455, "HP Z2 G4", CXT_FIXUP_HP_MIC_NO_PRESENCE),
        SND_PCI_QUIRK(0x103c, 0x8456, "HP Z2 G4 SFF", CXT_FIXUP_HP_MIC_NO_PRESENCE),
        SND_PCI_QUIRK(0x103c, 0x8457, "HP Z2 G4 mini", CXT_FIXUP_HP_MIC_NO_PRESENCE),
@@ -956,6 +983,7 @@ static const struct hda_model_fixup cxt5066_fixup_models[] = {
        { .id = CXT_FIXUP_MUTE_LED_EAPD, .name = "mute-led-eapd" },
        { .id = CXT_FIXUP_HP_DOCK, .name = "hp-dock" },
        { .id = CXT_FIXUP_MUTE_LED_GPIO, .name = "mute-led-gpio" },
+       { .id = CXT_FIXUP_HP_ZBOOK_MUTE_LED, .name = "hp-zbook-mute-led" },
        { .id = CXT_FIXUP_HP_MIC_NO_PRESENCE, .name = "hp-mic-fix" },
        {}
 };
index e6d0843ee9df2aab82ae35372549c6d0452a3402..45ae845e82df6859ed880a88005824ce646d5664 100644 (file)
@@ -2480,6 +2480,18 @@ static void generic_hdmi_free(struct hda_codec *codec)
 }
 
 #ifdef CONFIG_PM
+static int generic_hdmi_suspend(struct hda_codec *codec)
+{
+       struct hdmi_spec *spec = codec->spec;
+       int pin_idx;
+
+       for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
+               struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
+               cancel_delayed_work_sync(&per_pin->work);
+       }
+       return 0;
+}
+
 static int generic_hdmi_resume(struct hda_codec *codec)
 {
        struct hdmi_spec *spec = codec->spec;
@@ -2503,6 +2515,7 @@ static const struct hda_codec_ops generic_hdmi_patch_ops = {
        .build_controls         = generic_hdmi_build_controls,
        .unsol_event            = hdmi_unsol_event,
 #ifdef CONFIG_PM
+       .suspend                = generic_hdmi_suspend,
        .resume                 = generic_hdmi_resume,
 #endif
 };
index b47504fa8dfd0e1c4ef7236d04c84c18e45fd6d0..316b9b4ccb32d179a00a2c87645d85b231a5ee1d 100644 (file)
@@ -4225,6 +4225,12 @@ static void alc_fixup_hp_gpio_led(struct hda_codec *codec,
        }
 }
 
+static void alc236_fixup_hp_gpio_led(struct hda_codec *codec,
+                               const struct hda_fixup *fix, int action)
+{
+       alc_fixup_hp_gpio_led(codec, action, 0x02, 0x01);
+}
+
 static void alc269_fixup_hp_gpio_led(struct hda_codec *codec,
                                const struct hda_fixup *fix, int action)
 {
@@ -6381,6 +6387,7 @@ enum {
        ALC294_FIXUP_ASUS_GX502_VERBS,
        ALC285_FIXUP_HP_GPIO_LED,
        ALC285_FIXUP_HP_MUTE_LED,
+       ALC236_FIXUP_HP_GPIO_LED,
        ALC236_FIXUP_HP_MUTE_LED,
        ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET,
        ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
@@ -7616,6 +7623,10 @@ static const struct hda_fixup alc269_fixups[] = {
                .type = HDA_FIXUP_FUNC,
                .v.func = alc285_fixup_hp_mute_led,
        },
+       [ALC236_FIXUP_HP_GPIO_LED] = {
+               .type = HDA_FIXUP_FUNC,
+               .v.func = alc236_fixup_hp_gpio_led,
+       },
        [ALC236_FIXUP_HP_MUTE_LED] = {
                .type = HDA_FIXUP_FUNC,
                .v.func = alc236_fixup_hp_mute_led,
@@ -8045,9 +8056,12 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
        SND_PCI_QUIRK(0x103c, 0x8783, "HP ZBook Fury 15 G7 Mobile Workstation",
                      ALC285_FIXUP_HP_GPIO_AMP_INIT),
        SND_PCI_QUIRK(0x103c, 0x87c8, "HP", ALC287_FIXUP_HP_GPIO_LED),
+       SND_PCI_QUIRK(0x103c, 0x87e5, "HP ProBook 440 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED),
        SND_PCI_QUIRK(0x103c, 0x87f4, "HP", ALC287_FIXUP_HP_GPIO_LED),
        SND_PCI_QUIRK(0x103c, 0x87f5, "HP", ALC287_FIXUP_HP_GPIO_LED),
        SND_PCI_QUIRK(0x103c, 0x87f7, "HP Spectre x360 14", ALC245_FIXUP_HP_X360_AMP),
+       SND_PCI_QUIRK(0x103c, 0x8846, "HP EliteBook 850 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED),
+       SND_PCI_QUIRK(0x103c, 0x884c, "HP EliteBook 840 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED),
        SND_PCI_QUIRK(0x1043, 0x103e, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC),
        SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300),
        SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
@@ -8242,7 +8256,9 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
        SND_PCI_QUIRK(0x1b35, 0x1237, "CZC L101", ALC269_FIXUP_CZC_L101),
        SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */
        SND_PCI_QUIRK(0x1d72, 0x1602, "RedmiBook", ALC255_FIXUP_XIAOMI_HEADSET_MIC),
+       SND_PCI_QUIRK(0x1d72, 0x1701, "XiaomiNotebook Pro", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE),
        SND_PCI_QUIRK(0x1d72, 0x1901, "RedmiBook 14", ALC256_FIXUP_ASUS_HEADSET_MIC),
+       SND_PCI_QUIRK(0x1d72, 0x1947, "RedmiBook Air", ALC255_FIXUP_XIAOMI_HEADSET_MIC),
        SND_PCI_QUIRK(0x10ec, 0x118c, "Medion EE4254 MD62100", ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE),
        SND_PCI_QUIRK(0x1c06, 0x2013, "Lemote A1802", ALC269_FIXUP_LEMOTE_A1802),
        SND_PCI_QUIRK(0x1c06, 0x2015, "Lemote A190X", ALC269_FIXUP_LEMOTE_A190X),
index f814dbbec2a4316736e96676e00cf1b04a25d307..d54cd5143e9fbf254494c92970a06fa5b7f5f738 100644 (file)
 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 MODULE_DESCRIPTION("ICEnsemble ICE1712 (Envy24)");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{"
-              HOONTECH_DEVICE_DESC
-              DELTA_DEVICE_DESC
-              EWS_DEVICE_DESC
-              "{ICEnsemble,Generic ICE1712},"
-              "{ICEnsemble,Generic Envy24}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
index c0fca94c1dd2792e0d74f118ee0616c97d11463f..ef2367d861484eaff9087b6a3b06cd6330fbc59b 100644 (file)
 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 MODULE_DESCRIPTION("VIA ICEnsemble ICE1724/1720 (Envy24HT/PT)");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{"
-              REVO_DEVICE_DESC
-              AMP_AUDIO2000_DEVICE_DESC
-              AUREON_DEVICE_DESC
-              VT1720_MOBO_DEVICE_DESC
-              PONTIS_DEVICE_DESC
-              PRODIGY192_DEVICE_DESC
-              PRODIGY_HIFI_DEVICE_DESC
-              JULI_DEVICE_DESC
-              MAYA44_DEVICE_DESC
-              PHASE_DEVICE_DESC
-              WTM_DEVICE_DESC
-              SE_DEVICE_DESC
-              QTET_DEVICE_DESC
-               "{VIA,VT1720},"
-               "{VIA,VT1724},"
-               "{ICEnsemble,Generic ICE1724},"
-               "{ICEnsemble,Generic Envy24HT}"
-               "{ICEnsemble,Generic Envy24PT}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
index 3349e455a871ad2a5bc2e6e44f6518001edb709f..35903d1a1cbd27696e28cac536d5cfc03ea629cf 100644 (file)
 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 MODULE_DESCRIPTION("Intel 82801AA,82901AB,i810,i820,i830,i840,i845,MX440; SiS 7012; Ali 5455");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Intel,82801AA-ICH},"
-               "{Intel,82901AB-ICH0},"
-               "{Intel,82801BA-ICH2},"
-               "{Intel,82801CA-ICH3},"
-               "{Intel,82801DB-ICH4},"
-               "{Intel,ICH5},"
-               "{Intel,ICH6},"
-               "{Intel,ICH7},"
-               "{Intel,6300ESB},"
-               "{Intel,ESB2},"
-               "{Intel,MX440},"
-               "{SiS,SI7012},"
-               "{NVidia,nForce Audio},"
-               "{NVidia,nForce2 Audio},"
-               "{NVidia,nForce3 Audio},"
-               "{NVidia,MCP04},"
-               "{NVidia,MCP501},"
-               "{NVidia,CK804},"
-               "{NVidia,CK8},"
-               "{NVidia,CK8S},"
-               "{AMD,AMD768},"
-               "{AMD,AMD8111},"
-               "{ALI,M5455}}");
 
 static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
 static char *id = SNDRV_DEFAULT_STR1;  /* ID for this card */
index 19872cecc9d2eb0d3d88e9ea4b4c33dd41635470..13ef838b26c192ca727e9364fad09ec1c5678ca9 100644 (file)
@@ -25,21 +25,6 @@ MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 MODULE_DESCRIPTION("Intel 82801AA,82901AB,i810,i820,i830,i840,i845,MX440; "
                   "SiS 7013; NVidia MCP/2/2S/3 modems");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Intel,82801AA-ICH},"
-               "{Intel,82901AB-ICH0},"
-               "{Intel,82801BA-ICH2},"
-               "{Intel,82801CA-ICH3},"
-               "{Intel,82801DB-ICH4},"
-               "{Intel,ICH5},"
-               "{Intel,ICH6},"
-               "{Intel,ICH7},"
-               "{Intel,MX440},"
-               "{SiS,7013},"
-               "{NVidia,NForce Modem},"
-               "{NVidia,NForce2 Modem},"
-               "{NVidia,NForce2s Modem},"
-               "{NVidia,NForce3 Modem},"
-               "{AMD,AMD768}}");
 
 static int index = -2; /* Exclude the first card */
 static char *id = SNDRV_DEFAULT_STR1;  /* ID for this card */
index 2eddd9de9e6daaacdfdaafe11b4b07dab127f4b7..80ac3c6152ad86a9d855841a25c1a66ac847b145 100644 (file)
@@ -388,7 +388,6 @@ struct snd_korg1212 {
 
 MODULE_DESCRIPTION("korg1212");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{KORG,korg1212}}");
 MODULE_FIRMWARE("korg/k1212.dsp");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
index 491c90f83fbc0b2c58fd1bd24abad9bd7d46c8f0..03b4be44bb260ba885d6aea982cfcfbbf84231f1 100644 (file)
@@ -54,7 +54,6 @@ MODULE_PARM_DESC(sample_rate_min, "Minimal sample rate");
  */
 
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Digigram, Lola}}");
 MODULE_DESCRIPTION("Digigram Lola driver");
 MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
 
index b92ea074ff2af48ada45158ae757925f41380a33..1be97c38bc718eb64f325b9e45af61a1e273e42d 100644 (file)
@@ -21,8 +21,6 @@
 MODULE_AUTHOR("Tim Blechmann");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("digigram lx6464es");
-MODULE_SUPPORTED_DEVICE("{digigram lx6464es{}}");
-
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
index d2c2cd6006f04711b7a782c133508c058610e3fc..cdc4b610625266ac482d7524b2aa2623c6186e76 100644 (file)
 MODULE_AUTHOR("Zach Brown <zab@zabbo.net>, Takashi Iwai <tiwai@suse.de>");
 MODULE_DESCRIPTION("ESS Maestro3 PCI");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{ESS,Maestro3 PCI},"
-               "{ESS,ES1988},"
-               "{ESS,Allegro PCI},"
-               "{ESS,Allegro-1 PCI},"
-               "{ESS,Canyon3D-2/LE PCI}}");
 MODULE_FIRMWARE("ess/maestro3_assp_kernel.fw");
 MODULE_FIRMWARE("ess/maestro3_assp_minisrc.fw");
 
index efff220b26ea7cf27f11cfe9b8e4b251e778c3de..a0bbb386dc25207717a35eec471008c3c2eb8e4d 100644 (file)
@@ -32,7 +32,6 @@
 MODULE_AUTHOR("Digigram <alsa@digigram.com>");
 MODULE_DESCRIPTION("Digigram " CARD_NAME);
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Digigram," CARD_NAME "}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;             /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;              /* ID for this card */
index 975994623c2ceb9d5480bb6665a7989c54a3fbbe..6cb689aa28c21a40bfa9c1d906666d777c251381 100644 (file)
@@ -32,8 +32,6 @@
 MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
 MODULE_DESCRIPTION("NeoMagic NM256AV/ZX");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{NeoMagic,NM256AV},"
-               "{NeoMagic,NM256ZX}}");
 
 /*
  * some compile conditions.
index a751fcce7c8ebe16e40486827864b55f0f6b94d3..e335c4b5b38163ed6e9bf453d4a36a8be5d29a49 100644 (file)
@@ -56,9 +56,6 @@
 MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
 MODULE_DESCRIPTION("C-Media CMI8788 driver");
 MODULE_LICENSE("GPL v2");
-MODULE_SUPPORTED_DEVICE("{{C-Media,CMI8786}"
-                       ",{C-Media,CMI8787}"
-                       ",{C-Media,CMI8788}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
index 78c35a0a54776017c93b67100b620a09024e5969..434f885f6f918c7e8c7c054d580843fd9c798e8c 100644 (file)
@@ -29,7 +29,6 @@
 MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
 MODULE_DESCRIPTION("Studio Evolution SE6X driver");
 MODULE_LICENSE("GPL v2");
-MODULE_SUPPORTED_DEVICE("{{Studio Evolution,SE6X}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
index 98ab16329827450b4af88be4134006c5e891301f..baa3244d4dabea9e6f64cfffb4251f22108b8f7e 100644 (file)
@@ -16,7 +16,6 @@
 MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
 MODULE_DESCRIPTION("Asus Virtuoso driver");
 MODULE_LICENSE("GPL v2");
-MODULE_SUPPORTED_DEVICE("{{Asus,AV66},{Asus,AV100},{Asus,AV200}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
index c2e4831c3a13fbabe399e8c97acda7b0c45b7488..751f9744b089fb08b91886ae2e6c1a761dd4e0ff 100644 (file)
@@ -35,7 +35,6 @@ MODULE_AUTHOR("Markus Bollinger <bollinger@digigram.com>, "
              "Marc Titinger <titinger@digigram.com>");
 MODULE_DESCRIPTION("Digigram " DRIVER_NAME " " PCXHR_DRIVER_VERSION_STRING);
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Digigram," DRIVER_NAME "}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
index fcc2073c5025c2a413228da9ff85526e18c74742..56827db97239f7dcf6d166c8e1873c327faeda57 100644 (file)
 MODULE_AUTHOR("Peter Gruber <nokos@gmx.net>");
 MODULE_DESCRIPTION("riptide");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Conexant,Riptide}}");
 MODULE_FIRMWARE("riptide.hex");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
index 4eabece4dcbafd69af44de43509440f1fc29febf..54f3e39f97f5cbb9e9456a5bf6a0a2b09876a366 100644 (file)
@@ -88,7 +88,6 @@ MODULE_PARM_DESC(fullduplex, "Support full-duplex mode.");
 MODULE_AUTHOR("Martin Langer <martin-langer@gmx.de>, Pilo Chambert <pilo.c@wanadoo.fr>");
 MODULE_DESCRIPTION("RME Digi32, Digi32/8, Digi32 PRO");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{RME,Digi32}," "{RME,Digi32/8}," "{RME,Digi32 PRO}}");
 
 /* Defines for RME Digi32 series */
 #define RME32_SPDIF_NCHANNELS 2
index 84eef6a3739f5c32934492981f9411953b4283fb..66082e9f526dce39c4ddb412c0a86e8e6645a5cc 100644 (file)
@@ -31,11 +31,6 @@ MODULE_AUTHOR("Anders Torger <torger@ludd.luth.se>");
 MODULE_DESCRIPTION("RME Digi96, Digi96/8, Digi96/8 PRO, Digi96/8 PST, "
                   "Digi96/8 PAD");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{RME,Digi96},"
-               "{RME,Digi96/8},"
-               "{RME,Digi96/8 PRO},"
-               "{RME,Digi96/8 PST},"
-               "{RME,Digi96/8 PAD}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
index 6d9029333a12421fab33912c8cce19d077863d7a..4cf879c42dc4cc6738c2f13905c09e630e2c0470 100644 (file)
@@ -44,9 +44,6 @@ MODULE_PARM_DESC(enable, "Enable/disable specific Hammerfall DSP soundcards.");
 MODULE_AUTHOR("Paul Davis <paul@linuxaudiosystems.com>, Marcus Andersson, Thomas Charbonnel <thomas@undata.org>");
 MODULE_DESCRIPTION("RME Hammerfall DSP");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{RME Hammerfall-DSP},"
-               "{RME HDSP-9652},"
-               "{RME HDSP-9632}}");
 MODULE_FIRMWARE("rpm_firmware.bin");
 MODULE_FIRMWARE("multiface_firmware.bin");
 MODULE_FIRMWARE("multiface_firmware_rev11.bin");
index b66711574b1a6991995dbc542ff934bc4e580ef0..8d900c132f0f4434c9b7ea41944c894b444db49c 100644 (file)
@@ -165,7 +165,6 @@ MODULE_AUTHOR
 );
 MODULE_DESCRIPTION("RME HDSPM");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{RME HDSPM-MADI}}");
 
 /* --- Write registers. ---
   These are defined as byte-offsets from the iobase value.  */
index 012fbec5e6a74d39fcb882c8a6db2052d57ea81b..4df992e846f23ae5920e23ce9456eefa28f75ffa 100644 (file)
@@ -39,8 +39,6 @@ MODULE_PARM_DESC(precise_ptr, "Enable precise pointer (doesn't work reliably).")
 MODULE_AUTHOR("Paul Davis <pbd@op.net>, Winfried Ritsch");
 MODULE_DESCRIPTION("RME Digi9652/Digi9636");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{RME,Hammerfall},"
-               "{RME,Hammerfall-Light}}");
 
 /* The Hammerfall has two sets of 24 ADAT + 2 S/PDIF channels, one for
    capture, one for playback. Both the ADAT and S/PDIF channels appear
index 8ffa2f53c0b588a7986695d0eed08c156e67a135..00ab51c889da292c6f4456d38c143a0d8cf75e5f 100644 (file)
@@ -24,7 +24,6 @@
 MODULE_AUTHOR("David Dillow <dave@thedillows.org>");
 MODULE_DESCRIPTION("SiS7019");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{SiS,SiS7019 Audio Accelerator}}");
 
 static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
 static char *id = SNDRV_DEFAULT_STR1;  /* ID for this card */
index 26fd1d08c179fb86a5d9b34799db28dc3436b136..7de10997775f588fd7aa3e30733067541b00c24b 100644 (file)
@@ -29,7 +29,6 @@
 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 MODULE_DESCRIPTION("S3 SonicVibes PCI");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{S3,SonicVibes PCI}}");
 
 #if IS_REACHABLE(CONFIG_GAMEPORT)
 #define SUPPORT_JOYSTICK 1
index 5bc79da6e35e14a1ea57774b1e5dcdb61829a8cf..a51041205f7c11c3ebd3c5cdc6ed97bce9dd3598 100644 (file)
 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>, <audio@tridentmicro.com>");
 MODULE_DESCRIPTION("Trident 4D-WaveDX/NX & SiS SI7018");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Trident,4DWave DX},"
-               "{Trident,4DWave NX},"
-               "{SiS,SI7018 PCI Audio},"
-               "{Best Union,Miss Melody 4DWave PCI},"
-               "{HIS,4DWave PCI},"
-               "{Warpspeed,ONSpeed 4DWave PCI},"
-               "{Aztech Systems,PCI 64-Q3D},"
-               "{Addonics,SV 750},"
-               "{CHIC,True Sound 4Dwave},"
-               "{Shark,Predator4D-PCI},"
-               "{Jaton,SonicWave 4D},"
-               "{Hoontech,SoundTrack Digital 4DWave NX}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
index 154d88ce88131c96863360cf7dcdb926a56984c2..fd1f2f9cfbc32097eea5980bfdcbf9bc0058e7fe 100644 (file)
@@ -56,7 +56,6 @@
 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 MODULE_DESCRIPTION("VIA VT82xx audio");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{VIA,VT82C686A/B/C,pci},{VIA,VT8233A/C,8235}}");
 
 #if IS_REACHABLE(CONFIG_GAMEPORT)
 #define SUPPORT_JOYSTICK 1
index addfa196df21da577dfcb28b74d014236b9b01b4..30253306f67cc28031201401d6ec22f236a2ddcc 100644 (file)
@@ -38,7 +38,6 @@
 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 MODULE_DESCRIPTION("VIA VT82xx modem");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{VIA,VT82C686A/B/C modem,pci}}");
 
 static int index = -2; /* Exclude the first card */
 static char *id = SNDRV_DEFAULT_STR1;  /* ID for this card */
index f7800ed1b67ea7b0c07a5b81f0b370d72b3055b5..2a9e1a77a81a8a840fdafa394a220a6e50966c81 100644 (file)
@@ -20,7 +20,6 @@
 MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
 MODULE_DESCRIPTION("Digigram VX222 V2/Mic");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Digigram," CARD_NAME "}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
index 9b0d18a7bf356e929140adcaa8637a9b98f864f6..99be1490ef0eb1a48d87f7cb0c715bc60b95c7d4 100644 (file)
 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 MODULE_DESCRIPTION("Yamaha DS-1 PCI");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Yamaha,YMF724},"
-               "{Yamaha,YMF724F},"
-               "{Yamaha,YMF740},"
-               "{Yamaha,YMF740C},"
-               "{Yamaha,YMF744},"
-               "{Yamaha,YMF754}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
index 27d9da6d61e83b31a644e47065b9f15e7c38e54f..144582350a05b959afda768e05b82ec71a54755a 100644 (file)
@@ -22,7 +22,6 @@
 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 MODULE_DESCRIPTION("Sound Core " CARD_NAME);
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Sound Core," CARD_NAME "}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
index afd30a90c807bde6c5e8f93689399d8ce8377798..63632048980510ceb1eac4a0d1869d8a095ed259 100644 (file)
 #include <sound/initval.h>
 #include <sound/tlv.h>
 
-/*
- */
-
 MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
 MODULE_DESCRIPTION("Digigram VXPocket");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Digigram,VXPocket},{Digigram,VXPocket440}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
index 96ef55082bf9a99d714b4156b18488bdfcd756bb..9fb51ebafde1666ea6b3b3b34ca9617fc27f5ee3 100644 (file)
@@ -18,7 +18,6 @@
 #define CHIP_NAME "PMac"
 
 MODULE_DESCRIPTION("PowerMac");
-MODULE_SUPPORTED_DEVICE("{{Apple,PowerMac}}");
 MODULE_LICENSE("GPL");
 
 static int index = SNDRV_DEFAULT_IDX1;         /* Index 0-MAX */
index 8fa68432d3c1e4e906ae9d71bb49abb8b7444a86..6e9d6bd67369afca349114f379875841c7eda79f 100644 (file)
@@ -32,7 +32,6 @@
 MODULE_AUTHOR("Adrian McMenamin <adrian@mcmen.demon.co.uk>");
 MODULE_DESCRIPTION("Dreamcast AICA sound (pcm) driver");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Yamaha/SEGA, AICA}}");
 MODULE_FIRMWARE("aica_firmware.bin");
 
 /* module parameters */
index feb28502940f1add6f96568fb860acba1257bd48..8ebd972846acb5e7522dd0482d0758e5b2cc1305 100644 (file)
@@ -25,7 +25,6 @@
 MODULE_AUTHOR("Rafael Ignacio Zurita <rizurita@yahoo.com>");
 MODULE_DESCRIPTION("SuperH DAC audio driver");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{SuperH DAC audio support}}");
 
 /* Module Parameters */
 static int index = SNDRV_DEFAULT_IDX1;
index e4cf14e66a51b15adf36de0f74ef3d801fe50469..1c87b42606c9fb7f39ff8861ed2792c1962b786b 100644 (file)
@@ -186,7 +186,6 @@ config SND_SOC_ALL_CODECS
        imply SND_SOC_SI476X
        imply SND_SOC_SIMPLE_AMPLIFIER
        imply SND_SOC_SIMPLE_MUX
-       imply SND_SOC_SIRF_AUDIO_CODEC
        imply SND_SOC_SPDIF
        imply SND_SOC_SSM2305
        imply SND_SOC_SSM2518
@@ -1279,10 +1278,6 @@ config SND_SOC_SIMPLE_MUX
        tristate "Simple Audio Mux"
        select GPIOLIB
 
-config SND_SOC_SIRF_AUDIO_CODEC
-       tristate "SiRF SoC internal audio codec"
-       select REGMAP_MMIO
-
 config SND_SOC_SPDIF
        tristate "S/PDIF CODEC"
 
index 472caad17012e9f032563984528f084c03ea684d..85a1d00894a9cbb975e2a6b724533e8a78b65e24 100644 (file)
@@ -812,6 +812,7 @@ static const struct of_device_id ak4458_of_match[] = {
        { .compatible = "asahi-kasei,ak4497", .data = &ak4497_drvdata},
        { },
 };
+MODULE_DEVICE_TABLE(of, ak4458_of_match);
 
 static struct i2c_driver ak4458_i2c_driver = {
        .driver = {
index 8a32b0139cb0c080b03b393d547d4fd6c68b8b60..85bdd0534180353565efb96070134d99da9664dd 100644 (file)
@@ -419,6 +419,7 @@ static const struct of_device_id ak5558_i2c_dt_ids[] __maybe_unused = {
        { .compatible = "asahi-kasei,ak5558"},
        { }
 };
+MODULE_DEVICE_TABLE(of, ak5558_i2c_dt_ids);
 
 static struct i2c_driver ak5558_i2c_driver = {
        .driver = {
index 210fcbedf2413b41464e1c42759cab2433081ab6..811b7b1c9732e13ee365ca1ff223b4e0c28221b2 100644 (file)
@@ -401,7 +401,7 @@ static const struct regmap_config cs42l42_regmap = {
 };
 
 static DECLARE_TLV_DB_SCALE(adc_tlv, -9600, 100, false);
-static DECLARE_TLV_DB_SCALE(mixer_tlv, -6200, 100, false);
+static DECLARE_TLV_DB_SCALE(mixer_tlv, -6300, 100, true);
 
 static const char * const cs42l42_hpf_freq_text[] = {
        "1.86Hz", "120Hz", "235Hz", "466Hz"
@@ -458,7 +458,7 @@ static const struct snd_kcontrol_new cs42l42_snd_controls[] = {
                                CS42L42_DAC_HPF_EN_SHIFT, true, false),
        SOC_DOUBLE_R_TLV("Mixer Volume", CS42L42_MIXER_CHA_VOL,
                         CS42L42_MIXER_CHB_VOL, CS42L42_MIXER_CH_VOL_SHIFT,
-                               0x3e, 1, mixer_tlv)
+                               0x3f, 1, mixer_tlv)
 };
 
 static int cs42l42_hpdrv_evt(struct snd_soc_dapm_widget *w,
@@ -511,43 +511,6 @@ static const struct snd_soc_dapm_route cs42l42_audio_map[] = {
        {"HP", NULL, "HPDRV"}
 };
 
-static int cs42l42_set_bias_level(struct snd_soc_component *component,
-                                       enum snd_soc_bias_level level)
-{
-       struct cs42l42_private *cs42l42 = snd_soc_component_get_drvdata(component);
-       int ret;
-
-       switch (level) {
-       case SND_SOC_BIAS_ON:
-               break;
-       case SND_SOC_BIAS_PREPARE:
-               break;
-       case SND_SOC_BIAS_STANDBY:
-               if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
-                       regcache_cache_only(cs42l42->regmap, false);
-                       regcache_sync(cs42l42->regmap);
-                       ret = regulator_bulk_enable(
-                                               ARRAY_SIZE(cs42l42->supplies),
-                                               cs42l42->supplies);
-                       if (ret != 0) {
-                               dev_err(component->dev,
-                                       "Failed to enable regulators: %d\n",
-                                       ret);
-                               return ret;
-                       }
-               }
-               break;
-       case SND_SOC_BIAS_OFF:
-
-               regcache_cache_only(cs42l42->regmap, true);
-               regulator_bulk_disable(ARRAY_SIZE(cs42l42->supplies),
-                                                   cs42l42->supplies);
-               break;
-       }
-
-       return 0;
-}
-
 static int cs42l42_component_probe(struct snd_soc_component *component)
 {
        struct cs42l42_private *cs42l42 =
@@ -560,7 +523,6 @@ static int cs42l42_component_probe(struct snd_soc_component *component)
 
 static const struct snd_soc_component_driver soc_component_dev_cs42l42 = {
        .probe                  = cs42l42_component_probe,
-       .set_bias_level         = cs42l42_set_bias_level,
        .dapm_widgets           = cs42l42_dapm_widgets,
        .num_dapm_widgets       = ARRAY_SIZE(cs42l42_dapm_widgets),
        .dapm_routes            = cs42l42_audio_map,
@@ -691,24 +653,6 @@ static int cs42l42_pll_config(struct snd_soc_component *component)
                                        CS42L42_CLK_OASRC_SEL_MASK,
                                        CS42L42_CLK_OASRC_SEL_12 <<
                                        CS42L42_CLK_OASRC_SEL_SHIFT);
-                       /* channel 1 on low LRCLK, 32 bit */
-                       snd_soc_component_update_bits(component,
-                                       CS42L42_ASP_RX_DAI0_CH1_AP_RES,
-                                       CS42L42_ASP_RX_CH_AP_MASK |
-                                       CS42L42_ASP_RX_CH_RES_MASK,
-                                       (CS42L42_ASP_RX_CH_AP_LOW <<
-                                       CS42L42_ASP_RX_CH_AP_SHIFT) |
-                                       (CS42L42_ASP_RX_CH_RES_32 <<
-                                       CS42L42_ASP_RX_CH_RES_SHIFT));
-                       /* Channel 2 on high LRCLK, 32 bit */
-                       snd_soc_component_update_bits(component,
-                                       CS42L42_ASP_RX_DAI0_CH2_AP_RES,
-                                       CS42L42_ASP_RX_CH_AP_MASK |
-                                       CS42L42_ASP_RX_CH_RES_MASK,
-                                       (CS42L42_ASP_RX_CH_AP_HI <<
-                                       CS42L42_ASP_RX_CH_AP_SHIFT) |
-                                       (CS42L42_ASP_RX_CH_RES_32 <<
-                                       CS42L42_ASP_RX_CH_RES_SHIFT));
                        if (pll_ratio_table[i].mclk_src_sel == 0) {
                                /* Pass the clock straight through */
                                snd_soc_component_update_bits(component,
@@ -797,27 +741,23 @@ static int cs42l42_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
        /* Bitclock/frame inversion */
        switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
        case SND_SOC_DAIFMT_NB_NF:
+               asp_cfg_val |= CS42L42_ASP_SCPOL_NOR << CS42L42_ASP_SCPOL_SHIFT;
                break;
        case SND_SOC_DAIFMT_NB_IF:
-               asp_cfg_val |= CS42L42_ASP_POL_INV <<
-                               CS42L42_ASP_LCPOL_IN_SHIFT;
+               asp_cfg_val |= CS42L42_ASP_SCPOL_NOR << CS42L42_ASP_SCPOL_SHIFT;
+               asp_cfg_val |= CS42L42_ASP_LCPOL_INV << CS42L42_ASP_LCPOL_SHIFT;
                break;
        case SND_SOC_DAIFMT_IB_NF:
-               asp_cfg_val |= CS42L42_ASP_POL_INV <<
-                               CS42L42_ASP_SCPOL_IN_DAC_SHIFT;
                break;
        case SND_SOC_DAIFMT_IB_IF:
-               asp_cfg_val |= CS42L42_ASP_POL_INV <<
-                               CS42L42_ASP_LCPOL_IN_SHIFT;
-               asp_cfg_val |= CS42L42_ASP_POL_INV <<
-                               CS42L42_ASP_SCPOL_IN_DAC_SHIFT;
+               asp_cfg_val |= CS42L42_ASP_LCPOL_INV << CS42L42_ASP_LCPOL_SHIFT;
                break;
        }
 
-       snd_soc_component_update_bits(component, CS42L42_ASP_CLK_CFG,
-                               CS42L42_ASP_MODE_MASK |
-                               CS42L42_ASP_SCPOL_IN_DAC_MASK |
-                               CS42L42_ASP_LCPOL_IN_MASK, asp_cfg_val);
+       snd_soc_component_update_bits(component, CS42L42_ASP_CLK_CFG, CS42L42_ASP_MODE_MASK |
+                                                                     CS42L42_ASP_SCPOL_MASK |
+                                                                     CS42L42_ASP_LCPOL_MASK,
+                                                                     asp_cfg_val);
 
        return 0;
 }
@@ -828,14 +768,29 @@ static int cs42l42_pcm_hw_params(struct snd_pcm_substream *substream,
 {
        struct snd_soc_component *component = dai->component;
        struct cs42l42_private *cs42l42 = snd_soc_component_get_drvdata(component);
-       int retval;
+       unsigned int width = (params_width(params) / 8) - 1;
+       unsigned int val = 0;
 
        cs42l42->srate = params_rate(params);
-       cs42l42->swidth = params_width(params);
 
-       retval = cs42l42_pll_config(component);
+       switch(substream->stream) {
+       case SNDRV_PCM_STREAM_PLAYBACK:
+               val |= width << CS42L42_ASP_RX_CH_RES_SHIFT;
+               /* channel 1 on low LRCLK */
+               snd_soc_component_update_bits(component, CS42L42_ASP_RX_DAI0_CH1_AP_RES,
+                                                        CS42L42_ASP_RX_CH_AP_MASK |
+                                                        CS42L42_ASP_RX_CH_RES_MASK, val);
+               /* Channel 2 on high LRCLK */
+               val |= CS42L42_ASP_RX_CH_AP_HI << CS42L42_ASP_RX_CH_AP_SHIFT;
+               snd_soc_component_update_bits(component, CS42L42_ASP_RX_DAI0_CH2_AP_RES,
+                                                        CS42L42_ASP_RX_CH_AP_MASK |
+                                                        CS42L42_ASP_RX_CH_RES_MASK, val);
+               break;
+       default:
+               break;
+       }
 
-       return retval;
+       return cs42l42_pll_config(component);
 }
 
 static int cs42l42_set_sysclk(struct snd_soc_dai *dai,
@@ -900,9 +855,9 @@ static int cs42l42_mute(struct snd_soc_dai *dai, int mute, int direction)
        return 0;
 }
 
-#define CS42L42_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S18_3LE | \
-                       SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE | \
-                       SNDRV_PCM_FMTBIT_S32_LE)
+#define CS42L42_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\
+                        SNDRV_PCM_FMTBIT_S24_LE |\
+                        SNDRV_PCM_FMTBIT_S32_LE )
 
 
 static const struct snd_soc_dai_ops cs42l42_ops = {
@@ -1801,7 +1756,7 @@ static int cs42l42_i2c_probe(struct i2c_client *i2c_client,
                dev_dbg(&i2c_client->dev, "Found reset GPIO\n");
                gpiod_set_value_cansleep(cs42l42->reset_gpio, 1);
        }
-       mdelay(3);
+       usleep_range(CS42L42_BOOT_TIME_US, CS42L42_BOOT_TIME_US * 2);
 
        /* Request IRQ */
        ret = devm_request_threaded_irq(&i2c_client->dev,
@@ -1926,6 +1881,7 @@ static int cs42l42_runtime_resume(struct device *dev)
        }
 
        gpiod_set_value_cansleep(cs42l42->reset_gpio, 1);
+       usleep_range(CS42L42_BOOT_TIME_US, CS42L42_BOOT_TIME_US * 2);
 
        regcache_cache_only(cs42l42->regmap, false);
        regcache_sync(cs42l42->regmap);
index 9e3cc528dcff0838e4ab0645909708b558ef6a01..866d7c873e3c95b0800f2081588cc5c6e3c5994a 100644 (file)
 #define CS42L42_ASP_SLAVE_MODE         0x00
 #define CS42L42_ASP_MODE_SHIFT         4
 #define CS42L42_ASP_MODE_MASK          (1 << CS42L42_ASP_MODE_SHIFT)
-#define CS42L42_ASP_SCPOL_IN_DAC_SHIFT 2
-#define CS42L42_ASP_SCPOL_IN_DAC_MASK  (1 << CS42L42_ASP_SCPOL_IN_DAC_SHIFT)
-#define CS42L42_ASP_LCPOL_IN_SHIFT     0
-#define CS42L42_ASP_LCPOL_IN_MASK      (1 << CS42L42_ASP_LCPOL_IN_SHIFT)
-#define CS42L42_ASP_POL_INV            1
+#define CS42L42_ASP_SCPOL_SHIFT                2
+#define CS42L42_ASP_SCPOL_MASK         (3 << CS42L42_ASP_SCPOL_SHIFT)
+#define CS42L42_ASP_SCPOL_NOR          3
+#define CS42L42_ASP_LCPOL_SHIFT                0
+#define CS42L42_ASP_LCPOL_MASK         (3 << CS42L42_ASP_LCPOL_SHIFT)
+#define CS42L42_ASP_LCPOL_INV          3
 
 #define CS42L42_ASP_FRM_CFG            (CS42L42_PAGE_12 + 0x08)
 #define CS42L42_ASP_STP_SHIFT          4
 #define CS42L42_FRAC2_VAL(val) (((val) & 0xff0000) >> 16)
 
 #define CS42L42_NUM_SUPPLIES   5
+#define CS42L42_BOOT_TIME_US   3000
 
 static const char *const cs42l42_supply_names[CS42L42_NUM_SUPPLIES] = {
        "VA",
@@ -756,7 +758,6 @@ struct  cs42l42_private {
        struct completion pdn_done;
        u32 sclk;
        u32 srate;
-       u32 swidth;
        u8 plug_state;
        u8 hs_type;
        u8 ts_inv;
index d632055370e09208cf6af576f9541e89d1a12b2e..067757d1d70a3bfb39b5083b12e7a5159fe8e1a8 100644 (file)
@@ -63,13 +63,8 @@ static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(adc_pga_gain_tlv,
        1, 1, TLV_DB_SCALE_ITEM(0, 0, 0),
        2, 2, TLV_DB_SCALE_ITEM(250, 0, 0),
        3, 3, TLV_DB_SCALE_ITEM(450, 0, 0),
-       4, 4, TLV_DB_SCALE_ITEM(700, 0, 0),
-       5, 5, TLV_DB_SCALE_ITEM(1000, 0, 0),
-       6, 6, TLV_DB_SCALE_ITEM(1300, 0, 0),
-       7, 7, TLV_DB_SCALE_ITEM(1600, 0, 0),
-       8, 8, TLV_DB_SCALE_ITEM(1800, 0, 0),
-       9, 9, TLV_DB_SCALE_ITEM(2100, 0, 0),
-       10, 10, TLV_DB_SCALE_ITEM(2400, 0, 0),
+       4, 7, TLV_DB_SCALE_ITEM(700, 300, 0),
+       8, 10, TLV_DB_SCALE_ITEM(1800, 300, 0),
 );
 
 static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(hpout_vol_tlv,
index c9c21d22c2c454ef6f2e49b30bf54e4ada971fd4..8c04b3b2c9075df41fa38cb2ed503ea39bf74a7f 100644 (file)
@@ -2895,7 +2895,7 @@ static int rx_macro_enable_echo(struct snd_soc_dapm_widget *w,
 {
        struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
        u16 val, ec_hq_reg;
-       int ec_tx;
+       int ec_tx = -1;
 
        val = snd_soc_component_read(component,
                        CDC_RX_INP_MUX_RX_MIX_CFG4);
index 91e6890d6efcb63ef91a27a1894e4b2c66fb7dd5..3d6976a3d9e42171208e56faa5da68631fb38fce 100644 (file)
@@ -189,7 +189,6 @@ struct va_macro {
        struct device *dev;
        unsigned long active_ch_mask[VA_MACRO_MAX_DAIS];
        unsigned long active_ch_cnt[VA_MACRO_MAX_DAIS];
-       unsigned long active_decimator[VA_MACRO_MAX_DAIS];
        u16 dmic_clk_div;
 
        int dec_mode[VA_MACRO_NUM_DECIMATORS];
@@ -549,11 +548,9 @@ static int va_macro_tx_mixer_put(struct snd_kcontrol *kcontrol,
        if (enable) {
                set_bit(dec_id, &va->active_ch_mask[dai_id]);
                va->active_ch_cnt[dai_id]++;
-               va->active_decimator[dai_id] = dec_id;
        } else {
                clear_bit(dec_id, &va->active_ch_mask[dai_id]);
                va->active_ch_cnt[dai_id]--;
-               va->active_decimator[dai_id] = -1;
        }
 
        snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, update);
@@ -880,18 +877,19 @@ static int va_macro_digital_mute(struct snd_soc_dai *dai, int mute, int stream)
        struct va_macro *va = snd_soc_component_get_drvdata(component);
        u16 tx_vol_ctl_reg, decimator;
 
-       decimator = va->active_decimator[dai->id];
-
-       tx_vol_ctl_reg = CDC_VA_TX0_TX_PATH_CTL +
-                               VA_MACRO_TX_PATH_OFFSET * decimator;
-       if (mute)
-               snd_soc_component_update_bits(component, tx_vol_ctl_reg,
-                                             CDC_VA_TX_PATH_PGA_MUTE_EN_MASK,
-                                             CDC_VA_TX_PATH_PGA_MUTE_EN);
-       else
-               snd_soc_component_update_bits(component, tx_vol_ctl_reg,
-                                             CDC_VA_TX_PATH_PGA_MUTE_EN_MASK,
-                                             CDC_VA_TX_PATH_PGA_MUTE_DISABLE);
+       for_each_set_bit(decimator, &va->active_ch_mask[dai->id],
+                        VA_MACRO_DEC_MAX) {
+               tx_vol_ctl_reg = CDC_VA_TX0_TX_PATH_CTL +
+                                       VA_MACRO_TX_PATH_OFFSET * decimator;
+               if (mute)
+                       snd_soc_component_update_bits(component, tx_vol_ctl_reg,
+                                       CDC_VA_TX_PATH_PGA_MUTE_EN_MASK,
+                                       CDC_VA_TX_PATH_PGA_MUTE_EN);
+               else
+                       snd_soc_component_update_bits(component, tx_vol_ctl_reg,
+                                       CDC_VA_TX_PATH_PGA_MUTE_EN_MASK,
+                                       CDC_VA_TX_PATH_PGA_MUTE_DISABLE);
+       }
 
        return 0;
 }
index 5ebcd935ba898e7367c3387a594976d631599182..9ca49a165f693090875ee92ef3eff94835e8f3cc 100644 (file)
@@ -1211,14 +1211,16 @@ static int wsa_macro_enable_mix_path(struct snd_soc_dapm_widget *w,
                                     struct snd_kcontrol *kcontrol, int event)
 {
        struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
-       u16 gain_reg;
+       u16 path_reg, gain_reg;
        int val;
 
-       switch (w->reg) {
-       case CDC_WSA_RX0_RX_PATH_MIX_CTL:
+       switch (w->shift) {
+       case WSA_MACRO_RX_MIX0:
+               path_reg = CDC_WSA_RX0_RX_PATH_MIX_CTL;
                gain_reg = CDC_WSA_RX0_RX_VOL_MIX_CTL;
                break;
-       case CDC_WSA_RX1_RX_PATH_MIX_CTL:
+       case WSA_MACRO_RX_MIX1:
+               path_reg = CDC_WSA_RX1_RX_PATH_MIX_CTL;
                gain_reg = CDC_WSA_RX1_RX_VOL_MIX_CTL;
                break;
        default:
@@ -1231,7 +1233,7 @@ static int wsa_macro_enable_mix_path(struct snd_soc_dapm_widget *w,
                snd_soc_component_write(component, gain_reg, val);
                break;
        case SND_SOC_DAPM_POST_PMD:
-               snd_soc_component_update_bits(component, w->reg,
+               snd_soc_component_update_bits(component, path_reg,
                                              CDC_WSA_RX_PATH_MIX_CLK_EN_MASK,
                                              CDC_WSA_RX_PATH_MIX_CLK_DISABLE);
                break;
@@ -2068,14 +2070,14 @@ static const struct snd_soc_dapm_widget wsa_macro_dapm_widgets[] = {
        SND_SOC_DAPM_MUX("WSA_RX0 INP0", SND_SOC_NOPM, 0, 0, &rx0_prim_inp0_mux),
        SND_SOC_DAPM_MUX("WSA_RX0 INP1", SND_SOC_NOPM, 0, 0, &rx0_prim_inp1_mux),
        SND_SOC_DAPM_MUX("WSA_RX0 INP2", SND_SOC_NOPM, 0, 0, &rx0_prim_inp2_mux),
-       SND_SOC_DAPM_MUX_E("WSA_RX0 MIX INP", CDC_WSA_RX0_RX_PATH_MIX_CTL,
-                          0, 0, &rx0_mix_mux, wsa_macro_enable_mix_path,
+       SND_SOC_DAPM_MUX_E("WSA_RX0 MIX INP", SND_SOC_NOPM, WSA_MACRO_RX_MIX0,
+                          0, &rx0_mix_mux, wsa_macro_enable_mix_path,
                           SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
        SND_SOC_DAPM_MUX("WSA_RX1 INP0", SND_SOC_NOPM, 0, 0, &rx1_prim_inp0_mux),
        SND_SOC_DAPM_MUX("WSA_RX1 INP1", SND_SOC_NOPM, 0, 0, &rx1_prim_inp1_mux),
        SND_SOC_DAPM_MUX("WSA_RX1 INP2", SND_SOC_NOPM, 0, 0, &rx1_prim_inp2_mux),
-       SND_SOC_DAPM_MUX_E("WSA_RX1 MIX INP", CDC_WSA_RX1_RX_PATH_MIX_CTL,
-                          0, 0, &rx1_mix_mux, wsa_macro_enable_mix_path,
+       SND_SOC_DAPM_MUX_E("WSA_RX1 MIX INP", SND_SOC_NOPM, WSA_MACRO_RX_MIX1,
+                          0, &rx1_mix_mux, wsa_macro_enable_mix_path,
                           SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
 
        SND_SOC_DAPM_MIXER_E("WSA_RX INT0 MIX", SND_SOC_NOPM, 0, 0, NULL, 0,
index 37b5795b00d138eb9ee8043dbc364f9be086004c..844e4079d176022b8a2f36049454ffcbb6d93c0f 100644 (file)
@@ -209,6 +209,7 @@ static bool rt1015_volatile_register(struct device *dev, unsigned int reg)
        case RT1015_VENDOR_ID:
        case RT1015_DEVICE_ID:
        case RT1015_PRO_ALT:
+       case RT1015_MAN_I2C:
        case RT1015_DAC3:
        case RT1015_VBAT_TEST_OUT1:
        case RT1015_VBAT_TEST_OUT2:
@@ -513,6 +514,7 @@ static void rt1015_calibrate(struct rt1015_priv *rt1015)
        msleep(300);
        regmap_write(regmap, RT1015_PWR_STATE_CTRL, 0x0008);
        regmap_write(regmap, RT1015_SYS_RST1, 0x05F5);
+       regmap_write(regmap, RT1015_CLK_DET, 0x8000);
 
        regcache_cache_bypass(regmap, false);
        regcache_mark_dirty(regmap);
index 1414ad15d01cff3478239f647e212e51d57f3ba1..a5674c227b3a603b2023bee5ccfea2ded0a0f2c2 100644 (file)
@@ -339,9 +339,9 @@ static bool rt5640_readable_register(struct device *dev, unsigned int reg)
 }
 
 static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0);
-static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -65625, 375, 0);
+static const DECLARE_TLV_DB_MINMAX(dac_vol_tlv, -6562, 0);
 static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0);
-static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -17625, 375, 0);
+static const DECLARE_TLV_DB_MINMAX(adc_vol_tlv, -1762, 3000);
 static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0);
 
 /* {0, +20, +24, +30, +35, +40, +44, +50, +52} dB */
index d198e191fb0c9b7f93611d725fc88647983ad4fc..e59fdc81dbd45e8bc1bd0e074cf5643fb1db3e88 100644 (file)
@@ -285,9 +285,9 @@ static bool rt5651_readable_register(struct device *dev, unsigned int reg)
 }
 
 static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0);
-static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -65625, 375, 0);
+static const DECLARE_TLV_DB_MINMAX(dac_vol_tlv, -6562, 0);
 static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0);
-static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -17625, 375, 0);
+static const DECLARE_TLV_DB_MINMAX(adc_vol_tlv, -1762, 3000);
 static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0);
 
 /* {0, +20, +24, +30, +35, +40, +44, +50, +52} dB */
index 41e5917b16a5eb8119282ef34ce146d855777ad8..91a4ef7f620ca42098e4d1c9f52822047ba46394 100644 (file)
@@ -3426,12 +3426,17 @@ static int rt5659_set_component_sysclk(struct snd_soc_component *component, int
 {
        struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component);
        unsigned int reg_val = 0;
+       int ret;
 
        if (freq == rt5659->sysclk && clk_id == rt5659->sysclk_src)
                return 0;
 
        switch (clk_id) {
        case RT5659_SCLK_S_MCLK:
+               ret = clk_set_rate(rt5659->mclk, freq);
+               if (ret)
+                       return ret;
+
                reg_val |= RT5659_SCLK_SRC_MCLK;
                break;
        case RT5659_SCLK_S_PLL1:
index c29317ea5df2fa0699ad9bec092a7158d64fb87c..4063aac2a4431ab9f64203a1850dd4f3005634b2 100644 (file)
@@ -629,21 +629,69 @@ static SOC_ENUM_SINGLE_DECL(rt5670_if2_dac_enum, RT5670_DIG_INF1_DATA,
 static SOC_ENUM_SINGLE_DECL(rt5670_if2_adc_enum, RT5670_DIG_INF1_DATA,
                                RT5670_IF2_ADC_SEL_SFT, rt5670_data_select);
 
+/*
+ * For reliable output-mute LED control we need a "DAC1 Playback Switch" control.
+ * We emulate this by only clearing the RT5670_M_DAC1_L/_R AD_DA_MIXER register
+ * bits when both our emulated DAC1 Playback Switch control and the DAC1 MIXL/R
+ * DAPM-mixer DAC1 input are enabled.
+ */
+static void rt5670_update_ad_da_mixer_dac1_m_bits(struct rt5670_priv *rt5670)
+{
+       int val = RT5670_M_DAC1_L | RT5670_M_DAC1_R;
+
+       if (rt5670->dac1_mixl_dac1_switch && rt5670->dac1_playback_switch_l)
+               val &= ~RT5670_M_DAC1_L;
+
+       if (rt5670->dac1_mixr_dac1_switch && rt5670->dac1_playback_switch_r)
+               val &= ~RT5670_M_DAC1_R;
+
+       regmap_update_bits(rt5670->regmap, RT5670_AD_DA_MIXER,
+                          RT5670_M_DAC1_L | RT5670_M_DAC1_R, val);
+}
+
+static int rt5670_dac1_playback_switch_get(struct snd_kcontrol *kcontrol,
+                                          struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
+       struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component);
+
+       ucontrol->value.integer.value[0] = rt5670->dac1_playback_switch_l;
+       ucontrol->value.integer.value[1] = rt5670->dac1_playback_switch_r;
+
+       return 0;
+}
+
+static int rt5670_dac1_playback_switch_put(struct snd_kcontrol *kcontrol,
+                                          struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
+       struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component);
+
+       if (rt5670->dac1_playback_switch_l == ucontrol->value.integer.value[0] &&
+           rt5670->dac1_playback_switch_r == ucontrol->value.integer.value[1])
+               return 0;
+
+       rt5670->dac1_playback_switch_l = ucontrol->value.integer.value[0];
+       rt5670->dac1_playback_switch_r = ucontrol->value.integer.value[1];
+
+       rt5670_update_ad_da_mixer_dac1_m_bits(rt5670);
+
+       return 1;
+}
+
 static const struct snd_kcontrol_new rt5670_snd_controls[] = {
        /* Headphone Output Volume */
-       SOC_DOUBLE("HP Playback Switch", RT5670_HP_VOL,
-               RT5670_L_MUTE_SFT, RT5670_R_MUTE_SFT, 1, 1),
        SOC_DOUBLE_TLV("HP Playback Volume", RT5670_HP_VOL,
                RT5670_L_VOL_SFT, RT5670_R_VOL_SFT,
                39, 1, out_vol_tlv),
        /* OUTPUT Control */
-       SOC_DOUBLE("OUT Channel Switch", RT5670_LOUT1,
-               RT5670_VOL_L_SFT, RT5670_VOL_R_SFT, 1, 1),
        SOC_DOUBLE_TLV("OUT Playback Volume", RT5670_LOUT1,
                RT5670_L_VOL_SFT, RT5670_R_VOL_SFT, 39, 1, out_vol_tlv),
        /* DAC Digital Volume */
        SOC_DOUBLE("DAC2 Playback Switch", RT5670_DAC_CTRL,
                RT5670_M_DAC_L2_VOL_SFT, RT5670_M_DAC_R2_VOL_SFT, 1, 1),
+       SOC_DOUBLE_EXT("DAC1 Playback Switch", SND_SOC_NOPM, 0, 1, 1, 0,
+                       rt5670_dac1_playback_switch_get, rt5670_dac1_playback_switch_put),
        SOC_DOUBLE_TLV("DAC1 Playback Volume", RT5670_DAC1_DIG_VOL,
                        RT5670_L_VOL_SFT, RT5670_R_VOL_SFT,
                        175, 0, dac_vol_tlv),
@@ -913,18 +961,44 @@ static const struct snd_kcontrol_new rt5670_mono_adc_r_mix[] = {
                        RT5670_M_MONO_ADC_R2_SFT, 1, 1),
 };
 
+/* See comment above rt5670_update_ad_da_mixer_dac1_m_bits() */
+static int rt5670_put_dac1_mix_dac1_switch(struct snd_kcontrol *kcontrol,
+                                          struct snd_ctl_elem_value *ucontrol)
+{
+       struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value;
+       struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol);
+       struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component);
+       int ret;
+
+       if (mc->shift == 0)
+               rt5670->dac1_mixl_dac1_switch = ucontrol->value.integer.value[0];
+       else
+               rt5670->dac1_mixr_dac1_switch = ucontrol->value.integer.value[0];
+
+       /* Apply the update (if any) */
+       ret = snd_soc_dapm_put_volsw(kcontrol, ucontrol);
+       if (ret == 0)
+               return 0;
+
+       rt5670_update_ad_da_mixer_dac1_m_bits(rt5670);
+
+       return 1;
+}
+
+#define SOC_DAPM_SINGLE_RT5670_DAC1_SW(name, shift) \
+       SOC_SINGLE_EXT(name, SND_SOC_NOPM, shift, 1, 0, \
+                      snd_soc_dapm_get_volsw, rt5670_put_dac1_mix_dac1_switch)
+
 static const struct snd_kcontrol_new rt5670_dac_l_mix[] = {
        SOC_DAPM_SINGLE("Stereo ADC Switch", RT5670_AD_DA_MIXER,
                        RT5670_M_ADCMIX_L_SFT, 1, 1),
-       SOC_DAPM_SINGLE("DAC1 Switch", RT5670_AD_DA_MIXER,
-                       RT5670_M_DAC1_L_SFT, 1, 1),
+       SOC_DAPM_SINGLE_RT5670_DAC1_SW("DAC1 Switch", 0),
 };
 
 static const struct snd_kcontrol_new rt5670_dac_r_mix[] = {
        SOC_DAPM_SINGLE("Stereo ADC Switch", RT5670_AD_DA_MIXER,
                        RT5670_M_ADCMIX_R_SFT, 1, 1),
-       SOC_DAPM_SINGLE("DAC1 Switch", RT5670_AD_DA_MIXER,
-                       RT5670_M_DAC1_R_SFT, 1, 1),
+       SOC_DAPM_SINGLE_RT5670_DAC1_SW("DAC1 Switch", 1),
 };
 
 static const struct snd_kcontrol_new rt5670_sto_dac_l_mix[] = {
@@ -1656,12 +1730,10 @@ static const struct snd_soc_dapm_widget rt5670_dapm_widgets[] = {
                            RT5670_PWR_ADC_S1F_BIT, 0, NULL, 0),
        SND_SOC_DAPM_SUPPLY("ADC Stereo2 Filter", RT5670_PWR_DIG2,
                            RT5670_PWR_ADC_S2F_BIT, 0, NULL, 0),
-       SND_SOC_DAPM_MIXER("Sto1 ADC MIXL", RT5670_STO1_ADC_DIG_VOL,
-                          RT5670_L_MUTE_SFT, 1, rt5670_sto1_adc_l_mix,
-                          ARRAY_SIZE(rt5670_sto1_adc_l_mix)),
-       SND_SOC_DAPM_MIXER("Sto1 ADC MIXR", RT5670_STO1_ADC_DIG_VOL,
-                          RT5670_R_MUTE_SFT, 1, rt5670_sto1_adc_r_mix,
-                          ARRAY_SIZE(rt5670_sto1_adc_r_mix)),
+       SND_SOC_DAPM_MIXER("Sto1 ADC MIXL", SND_SOC_NOPM, 0, 0,
+                          rt5670_sto1_adc_l_mix, ARRAY_SIZE(rt5670_sto1_adc_l_mix)),
+       SND_SOC_DAPM_MIXER("Sto1 ADC MIXR", SND_SOC_NOPM, 0, 0,
+                          rt5670_sto1_adc_r_mix, ARRAY_SIZE(rt5670_sto1_adc_r_mix)),
        SND_SOC_DAPM_MIXER("Sto2 ADC MIXL", SND_SOC_NOPM, 0, 0,
                           rt5670_sto2_adc_l_mix,
                           ARRAY_SIZE(rt5670_sto2_adc_l_mix)),
@@ -2999,6 +3071,16 @@ static int rt5670_i2c_probe(struct i2c_client *i2c,
                dev_info(&i2c->dev, "quirk JD mode 3\n");
        }
 
+       /*
+        * Enable the emulated "DAC1 Playback Switch" by default to avoid
+        * muting the output with older UCM profiles.
+        */
+       rt5670->dac1_playback_switch_l = true;
+       rt5670->dac1_playback_switch_r = true;
+       /* The Power-On-Reset values for the DAC1 mixer have the DAC1 input enabled. */
+       rt5670->dac1_mixl_dac1_switch = true;
+       rt5670->dac1_mixr_dac1_switch = true;
+
        rt5670->regmap = devm_regmap_init_i2c(i2c, &rt5670_regmap);
        if (IS_ERR(rt5670->regmap)) {
                ret = PTR_ERR(rt5670->regmap);
index 56b13fe6bd3cb9167ab4e6d81997ad8d3432f485..6fb3c369ee98935903e58709731920c4c5e1205d 100644 (file)
 /* global definition */
 #define RT5670_L_MUTE                          (0x1 << 15)
 #define RT5670_L_MUTE_SFT                      15
-#define RT5670_VOL_L_MUTE                      (0x1 << 14)
-#define RT5670_VOL_L_SFT                       14
 #define RT5670_R_MUTE                          (0x1 << 7)
 #define RT5670_R_MUTE_SFT                      7
-#define RT5670_VOL_R_MUTE                      (0x1 << 6)
-#define RT5670_VOL_R_SFT                       6
 #define RT5670_L_VOL_MASK                      (0x3f << 8)
 #define RT5670_L_VOL_SFT                       8
 #define RT5670_R_VOL_MASK                      (0x3f)
@@ -2017,6 +2013,11 @@ struct rt5670_priv {
        int dsp_rate;
        int jack_type;
        int jack_type_saved;
+
+       bool dac1_mixl_dac1_switch;
+       bool dac1_mixr_dac1_switch;
+       bool dac1_playback_switch_l;
+       bool dac1_playback_switch_r;
 };
 
 void rt5670_jack_suspend(struct snd_soc_component *component);
index 85f744184a60fe4302baf6e9a58f0190d23ab5a3..047f4e677d78cb16b2e0189067798b37a82d3fb7 100644 (file)
@@ -895,6 +895,13 @@ static int rt711_probe(struct snd_soc_component *component)
        return 0;
 }
 
+static void rt711_remove(struct snd_soc_component *component)
+{
+       struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component);
+
+       regcache_cache_only(rt711->regmap, true);
+}
+
 static const struct snd_soc_component_driver soc_codec_dev_rt711 = {
        .probe = rt711_probe,
        .set_bias_level = rt711_set_bias_level,
@@ -905,6 +912,7 @@ static const struct snd_soc_component_driver soc_codec_dev_rt711 = {
        .dapm_routes = rt711_audio_map,
        .num_dapm_routes = ARRAY_SIZE(rt711_audio_map),
        .set_jack = rt711_set_jack_detect,
+       .remove = rt711_remove,
 };
 
 static int rt711_set_sdw_stream(struct snd_soc_dai *dai, void *sdw_stream,
index 73551e36695e98123a35de8ee4dac3e6d96a5caa..6d9bb256a2cf56943a0fdd7dfce71c9437525474 100644 (file)
@@ -71,7 +71,7 @@ static const struct reg_default sgtl5000_reg_defaults[] = {
        { SGTL5000_DAP_EQ_BASS_BAND4,           0x002f },
        { SGTL5000_DAP_MAIN_CHAN,               0x8000 },
        { SGTL5000_DAP_MIX_CHAN,                0x0000 },
-       { SGTL5000_DAP_AVC_CTRL,                0x0510 },
+       { SGTL5000_DAP_AVC_CTRL,                0x5100 },
        { SGTL5000_DAP_AVC_THRESHOLD,           0x1473 },
        { SGTL5000_DAP_AVC_ATTACK,              0x0028 },
        { SGTL5000_DAP_AVC_DECAY,               0x0050 },
diff --git a/sound/soc/codecs/sirf-audio-codec.h b/sound/soc/codecs/sirf-audio-codec.h
deleted file mode 100644 (file)
index a7fe268..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * SiRF inner codec controllers define
- *
- * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company.
- */
-
-#ifndef _SIRF_AUDIO_CODEC_H
-#define _SIRF_AUDIO_CODEC_H
-
-
-#define AUDIO_IC_CODEC_PWR                     (0x00E0)
-#define AUDIO_IC_CODEC_CTRL0                   (0x00E4)
-#define AUDIO_IC_CODEC_CTRL1                   (0x00E8)
-#define AUDIO_IC_CODEC_CTRL2                   (0x00EC)
-#define AUDIO_IC_CODEC_CTRL3                   (0x00F0)
-
-#define MICBIASEN              (1 << 3)
-
-#define IC_RDACEN              (1 << 0)
-#define IC_LDACEN              (1 << 1)
-#define IC_HSREN               (1 << 2)
-#define IC_HSLEN               (1 << 3)
-#define IC_SPEN                        (1 << 4)
-#define IC_CPEN                        (1 << 5)
-
-#define IC_HPRSELR             (1 << 6)
-#define IC_HPLSELR             (1 << 7)
-#define IC_HPRSELL             (1 << 8)
-#define IC_HPLSELL             (1 << 9)
-#define IC_SPSELR              (1 << 10)
-#define IC_SPSELL              (1 << 11)
-
-#define IC_MONOR               (1 << 12)
-#define IC_MONOL               (1 << 13)
-
-#define IC_RXOSRSEL            (1 << 28)
-#define IC_CPFREQ              (1 << 29)
-#define IC_HSINVEN             (1 << 30)
-
-#define IC_MICINREN            (1 << 0)
-#define IC_MICINLEN            (1 << 1)
-#define IC_MICIN1SEL           (1 << 2)
-#define IC_MICIN2SEL           (1 << 3)
-#define IC_MICDIFSEL           (1 << 4)
-#define        IC_LINEIN1SEL           (1 << 5)
-#define        IC_LINEIN2SEL           (1 << 6)
-#define        IC_RADCEN               (1 << 7)
-#define        IC_LADCEN               (1 << 8)
-#define        IC_ALM                  (1 << 9)
-
-#define IC_DIGMICEN             (1 << 22)
-#define IC_DIGMICFREQ           (1 << 23)
-#define IC_ADC14B_12            (1 << 24)
-#define IC_FIRDAC_HSL_EN        (1 << 25)
-#define IC_FIRDAC_HSR_EN        (1 << 26)
-#define IC_FIRDAC_LOUT_EN       (1 << 27)
-#define IC_POR                  (1 << 28)
-#define IC_CODEC_CLK_EN         (1 << 29)
-#define IC_HP_3DB_BOOST         (1 << 30)
-
-#define IC_ADC_LEFT_GAIN_SHIFT 16
-#define IC_ADC_RIGHT_GAIN_SHIFT 10
-#define IC_ADC_GAIN_MASK       0x3F
-#define IC_MIC_MAX_GAIN                0x39
-
-#define IC_RXPGAR_MASK         0x3F
-#define IC_RXPGAR_SHIFT                14
-#define IC_RXPGAL_MASK         0x3F
-#define IC_RXPGAL_SHIFT                21
-#define IC_RXPGAR              0x7B
-#define IC_RXPGAL              0x7B
-
-#define AUDIO_PORT_TX_FIFO_LEVEL_CHECK_MASK     0x3F
-#define AUDIO_PORT_TX_FIFO_SC_OFFSET    0
-#define AUDIO_PORT_TX_FIFO_LC_OFFSET    10
-#define AUDIO_PORT_TX_FIFO_HC_OFFSET    20
-
-#define TX_FIFO_SC(x)           (((x) & AUDIO_PORT_TX_FIFO_LEVEL_CHECK_MASK) \
-                               << AUDIO_PORT_TX_FIFO_SC_OFFSET)
-#define TX_FIFO_LC(x)           (((x) & AUDIO_PORT_TX_FIFO_LEVEL_CHECK_MASK) \
-                               << AUDIO_PORT_TX_FIFO_LC_OFFSET)
-#define TX_FIFO_HC(x)           (((x) & AUDIO_PORT_TX_FIFO_LEVEL_CHECK_MASK) \
-                               << AUDIO_PORT_TX_FIFO_HC_OFFSET)
-
-#define AUDIO_PORT_RX_FIFO_LEVEL_CHECK_MASK     0x0F
-#define AUDIO_PORT_RX_FIFO_SC_OFFSET    0
-#define AUDIO_PORT_RX_FIFO_LC_OFFSET    10
-#define AUDIO_PORT_RX_FIFO_HC_OFFSET    20
-
-#define RX_FIFO_SC(x)           (((x) & AUDIO_PORT_RX_FIFO_LEVEL_CHECK_MASK) \
-                               << AUDIO_PORT_RX_FIFO_SC_OFFSET)
-#define RX_FIFO_LC(x)           (((x) & AUDIO_PORT_RX_FIFO_LEVEL_CHECK_MASK) \
-                               << AUDIO_PORT_RX_FIFO_LC_OFFSET)
-#define RX_FIFO_HC(x)           (((x) & AUDIO_PORT_RX_FIFO_LEVEL_CHECK_MASK) \
-                               << AUDIO_PORT_RX_FIFO_HC_OFFSET)
-#define AUDIO_PORT_IC_CODEC_TX_CTRL            (0x00F4)
-#define AUDIO_PORT_IC_CODEC_RX_CTRL            (0x00F8)
-
-#define AUDIO_PORT_IC_TXFIFO_OP                        (0x00FC)
-#define AUDIO_PORT_IC_TXFIFO_LEV_CHK           (0x0100)
-#define AUDIO_PORT_IC_TXFIFO_STS               (0x0104)
-#define AUDIO_PORT_IC_TXFIFO_INT               (0x0108)
-#define AUDIO_PORT_IC_TXFIFO_INT_MSK           (0x010C)
-
-#define AUDIO_PORT_IC_RXFIFO_OP                        (0x0110)
-#define AUDIO_PORT_IC_RXFIFO_LEV_CHK           (0x0114)
-#define AUDIO_PORT_IC_RXFIFO_STS               (0x0118)
-#define AUDIO_PORT_IC_RXFIFO_INT               (0x011C)
-#define AUDIO_PORT_IC_RXFIFO_INT_MSK           (0x0120)
-
-#define AUDIO_FIFO_START               (1 << 0)
-#define AUDIO_FIFO_RESET               (1 << 1)
-
-#define AUDIO_FIFO_FULL                        (1 << 0)
-#define AUDIO_FIFO_EMPTY               (1 << 1)
-#define AUDIO_FIFO_OFLOW               (1 << 2)
-#define AUDIO_FIFO_UFLOW               (1 << 3)
-
-#define IC_TX_ENABLE           (0x03)
-#define IC_RX_ENABLE_MONO      (0x01)
-#define IC_RX_ENABLE_STEREO    (0x03)
-
-#endif /*__SIRF_AUDIO_CODEC_H*/
index 40f682f5dab8bde1d1a6e7345336314032052e13..d18ae5e3ee809ddf31fd957d42d57b9f0f5c124f 100644 (file)
@@ -1873,6 +1873,12 @@ static int wcd934x_set_channel_map(struct snd_soc_dai *dai,
 
        wcd = snd_soc_component_get_drvdata(dai->component);
 
+       if (tx_num > WCD934X_TX_MAX || rx_num > WCD934X_RX_MAX) {
+               dev_err(wcd->dev, "Invalid tx %d or rx %d channel count\n",
+                       tx_num, rx_num);
+               return -EINVAL;
+       }
+
        if (!tx_slot || !rx_slot) {
                dev_err(wcd->dev, "Invalid tx_slot=%p, rx_slot=%p\n",
                        tx_slot, rx_slot);
index 57811743c2948b7ab5591e7f9ec60801eda55a65..ad8af3f450e29d9cd3e1dd14ff4f4235b61dd7e0 100644 (file)
@@ -878,6 +878,7 @@ static int fsl_ssi_hw_free(struct snd_pcm_substream *substream,
 static int _fsl_ssi_set_dai_fmt(struct fsl_ssi *ssi, unsigned int fmt)
 {
        u32 strcr = 0, scr = 0, stcr, srcr, mask;
+       unsigned int slots;
 
        ssi->dai_fmt = fmt;
 
@@ -909,10 +910,11 @@ static int _fsl_ssi_set_dai_fmt(struct fsl_ssi *ssi, unsigned int fmt)
                        return -EINVAL;
                }
 
+               slots = ssi->slots ? : 2;
                regmap_update_bits(ssi->regs, REG_SSI_STCCR,
-                                  SSI_SxCCR_DC_MASK, SSI_SxCCR_DC(2));
+                                  SSI_SxCCR_DC_MASK, SSI_SxCCR_DC(slots));
                regmap_update_bits(ssi->regs, REG_SSI_SRCCR,
-                                  SSI_SxCCR_DC_MASK, SSI_SxCCR_DC(2));
+                                  SSI_SxCCR_DC_MASK, SSI_SxCCR_DC(slots));
 
                /* Data on rising edge of bclk, frame low, 1clk before data */
                strcr |= SSI_STCR_TFSI | SSI_STCR_TSCKP | SSI_STCR_TEFS;
index ab31045cfc9525f6cf9d2ce08e4086196e6e3214..6cada4c1e283befe3c52848bda0340f082696a88 100644 (file)
@@ -172,15 +172,16 @@ int asoc_simple_parse_clk(struct device *dev,
         *  or device's module clock.
         */
        clk = devm_get_clk_from_child(dev, node, NULL);
-       if (IS_ERR(clk))
-               clk = devm_get_clk_from_child(dev, dlc->of_node, NULL);
-
        if (!IS_ERR(clk)) {
-               simple_dai->clk = clk;
                simple_dai->sysclk = clk_get_rate(clk);
-       } else if (!of_property_read_u32(node, "system-clock-frequency",
-                                        &val)) {
+
+               simple_dai->clk = clk;
+       } else if (!of_property_read_u32(node, "system-clock-frequency", &val)) {
                simple_dai->sysclk = val;
+       } else {
+               clk = devm_get_clk_from_child(dev, dlc->of_node, NULL);
+               if (!IS_ERR(clk))
+                       simple_dai->sysclk = clk_get_rate(clk);
        }
 
        if (of_property_read_bool(node, "system-clock-direction-out"))
index 782f2b4d72ad959d6332916255349e0eca3237d0..5d48cc359c3daf613a5f616a3ed6380f2bb7a7af 100644 (file)
@@ -581,7 +581,7 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = {
                },
                .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
                                        BYT_RT5640_JD_SRC_JD1_IN4P |
-                                       BYT_RT5640_OVCD_TH_1500UA |
+                                       BYT_RT5640_OVCD_TH_2000UA |
                                        BYT_RT5640_OVCD_SF_0P75 |
                                        BYT_RT5640_MCLK_EN),
        },
index f5de1d7696792daf5c38db90de2a16a2f04c809b..f3bebed2428a72bb4b57f7748aae4c9dc05b3249 100644 (file)
@@ -555,7 +555,9 @@ static int mtk_dai_tdm_hw_params(struct snd_pcm_substream *substream,
 
        /* set tdm */
        if (tdm_priv->bck_invert)
-               tdm_con |= 1 << BCK_INVERSE_SFT;
+               regmap_update_bits(afe->regmap, AUDIO_TOP_CON3,
+                                  BCK_INVERSE_MASK_SFT,
+                                  0x1 << BCK_INVERSE_SFT);
 
        if (tdm_priv->lck_invert)
                tdm_con |= 1 << LRCK_INVERSE_SFT;
index 562f25c79c3492c06edc878fd62c5445ed91caf0..b9fb80d4afecd6bab3e2420526c2338949bf43f8 100644 (file)
@@ -21,6 +21,11 @@ enum {
 /*****************************************************************************
  *                  R E G I S T E R       D E F I N I T I O N
  *****************************************************************************/
+/* AUDIO_TOP_CON3 */
+#define BCK_INVERSE_SFT                              3
+#define BCK_INVERSE_MASK                             0x1
+#define BCK_INVERSE_MASK_SFT                         (0x1 << 3)
+
 /* AFE_DAC_CON0 */
 #define VUL12_ON_SFT                                   31
 #define VUL12_ON_MASK                                  0x1
@@ -2079,9 +2084,6 @@ enum {
 #define TDM_EN_SFT                                     0
 #define TDM_EN_MASK                                    0x1
 #define TDM_EN_MASK_SFT                                (0x1 << 0)
-#define BCK_INVERSE_SFT                                1
-#define BCK_INVERSE_MASK                               0x1
-#define BCK_INVERSE_MASK_SFT                           (0x1 << 1)
 #define LRCK_INVERSE_SFT                               2
 #define LRCK_INVERSE_MASK                              0x1
 #define LRCK_INVERSE_MASK_SFT                          (0x1 << 2)
index c642e5f8f28c4c942689059d8ee9a98506621a56..be360a402b67f38937bab91b9331b95b18549cb0 100644 (file)
@@ -739,7 +739,7 @@ static void of_lpass_cpu_parse_dai_data(struct device *dev,
 
        for_each_child_of_node(dev->of_node, node) {
                ret = of_property_read_u32(node, "reg", &id);
-               if (ret || id < 0 || id >= data->variant->num_dai) {
+               if (ret || id < 0) {
                        dev_err(dev, "valid dai id not found: %d\n", ret);
                        continue;
                }
index 6c2760e27ea6fdbab1651e9f1ccbdc07887c73d7..153e9b2de0b53719a6037e984631f50b01f54970 100644 (file)
 #define SPK_TDM_RX_MASK         0x03
 #define NUM_TDM_SLOTS           8
 #define SLIM_MAX_TX_PORTS 16
-#define SLIM_MAX_RX_PORTS 16
+#define SLIM_MAX_RX_PORTS 13
 #define WCD934X_DEFAULT_MCLK_RATE      9600000
 
 struct sdm845_snd_data {
        struct snd_soc_jack jack;
        bool jack_setup;
-       bool stream_prepared[SLIM_MAX_RX_PORTS];
+       bool stream_prepared[AFE_PORT_MAX];
        struct snd_soc_card *card;
        uint32_t pri_mi2s_clk_count;
        uint32_t sec_mi2s_clk_count;
        uint32_t quat_tdm_clk_count;
-       struct sdw_stream_runtime *sruntime[SLIM_MAX_RX_PORTS];
+       struct sdw_stream_runtime *sruntime[AFE_PORT_MAX];
 };
 
 static unsigned int tdm_slot_offset[8] = {0, 4, 8, 12, 16, 20, 24, 28};
index f6d4e99b590c708ae185f54e05e4142a59f30ae3..0cffc9527e28902371f677b5a2c468560069e63c 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/of.h>
 #include <linux/of_graph.h>
 #include <linux/dmi.h>
+#include <linux/acpi.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -1573,6 +1574,9 @@ int snd_soc_set_dmi_name(struct snd_soc_card *card, const char *flavour)
        if (card->long_name)
                return 0; /* long name already set by driver or from DMI */
 
+       if (!is_acpi_device_node(card->dev->fwnode))
+               return 0;
+
        /* make up dmi long name as: vendor-product-version-board */
        vendor = dmi_get_system_info(DMI_BOARD_VENDOR);
        if (!vendor || !is_dmi_valid(vendor)) {
index 5788fe35696057874253b378a8e690c0da3343f4..c3b757cf01a04fb83d7e4c1fe832dd0ac14e15dc 100644 (file)
@@ -207,7 +207,7 @@ int hda_dsp_core_power_down(struct snd_sof_dev *sdev, unsigned int core_mask)
 
        ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR,
                                HDA_DSP_REG_ADSPCS, adspcs,
-                               !(adspcs & HDA_DSP_ADSPCS_SPA_MASK(core_mask)),
+                               !(adspcs & HDA_DSP_ADSPCS_CPA_MASK(core_mask)),
                                HDA_DSP_REG_POLL_INTERVAL_US,
                                HDA_DSP_PD_TIMEOUT * USEC_PER_MSEC);
        if (ret < 0)
index 1d29b1fd6a9493c0621628e2cbe408f29bd35778..0c096db07322de8cf9a2ee0ff69389e1c67a930b 100644 (file)
@@ -897,6 +897,7 @@ free_streams:
 /* dsp_unmap: not currently used */
        iounmap(sdev->bar[HDA_DSP_BAR]);
 hdac_bus_unmap:
+       platform_device_unregister(hdev->dmic_dev);
        iounmap(bus->remap_addr);
        hda_codec_i915_exit(sdev);
 err:
index 9d0da5fa1c70d98a706015783eb9e796b7ad2048..d24ae00878f5a75d5923d782254b367922af2e47 100644 (file)
@@ -62,7 +62,6 @@ MODULE_PARM_DESC(enable, "Enable Sun AMD7930 soundcard.");
 MODULE_AUTHOR("Thomas K. Dyas and David S. Miller");
 MODULE_DESCRIPTION("Sun AMD7930");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Sun,AMD7930}}");
 
 /* Device register layout.  */
 
index 0eed5f79a2bf9954163a5c902eb4f0b986e53e0b..35c17803a43098da1769b5fa6d5ef24a7de09b35 100644 (file)
@@ -52,7 +52,6 @@ MODULE_PARM_DESC(enable, "Enable Sun CS4231 soundcard.");
 MODULE_AUTHOR("Jaroslav Kysela, Derrick J. Brashear and David S. Miller");
 MODULE_DESCRIPTION("Sun CS4231");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Sun,CS4231}}");
 
 #ifdef SBUS_SUPPORT
 struct sbus_dma_info {
index 5a6fb66dd1187dba23bbecf21fe2875fa0e51afd..b055f583957877d462daaee0cb1a0888db752277 100644 (file)
@@ -76,7 +76,6 @@
 MODULE_AUTHOR("Rudolf Koenig, Brent Baccala and Martin Habets");
 MODULE_DESCRIPTION("Sun DBRI");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Sun,DBRI}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
index 08c6e6a52eb98a51822fb1643f7d9d3688ad3f9b..33e962178c9363aa4f36d40c1258e9d5dd643c9d 100644 (file)
@@ -26,7 +26,6 @@
 MODULE_AUTHOR("Torsten Schenk <torsten.schenk@zoho.com>");
 MODULE_DESCRIPTION("TerraTec DMX 6Fire USB audio driver");
 MODULE_LICENSE("GPL v2");
-MODULE_SUPPORTED_DEVICE("{{TerraTec,DMX 6Fire USB}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-max */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* Id for card */
index e03481caf7f62dba91962450df32b090a626d386..49f63f878e6fe8b7acbaa363dfebf3b2114dd753 100644 (file)
 MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>");
 MODULE_DESCRIPTION("caiaq USB audio");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Native Instruments,RigKontrol2},"
-                        "{Native Instruments,RigKontrol3},"
-                        "{Native Instruments,Kore Controller},"
-                        "{Native Instruments,Kore Controller 2},"
-                        "{Native Instruments,Audio Kontrol 1},"
-                        "{Native Instruments,Audio 2 DJ},"
-                        "{Native Instruments,Audio 4 DJ},"
-                        "{Native Instruments,Audio 8 DJ},"
-                        "{Native Instruments,Traktor Audio 2},"
-                        "{Native Instruments,Session I/O},"
-                        "{Native Instruments,GuitarRig mobile},"
-                        "{Native Instruments,Traktor Kontrol X1},"
-                        "{Native Instruments,Traktor Kontrol S4},"
-                        "{Native Instruments,Maschine Controller}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-max */
 static char* id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* Id for this card */
index 85ed8507e41a21d10008dd72dc7c6a957f84e68e..0826a437f8fcac17ad64fb8e3b796d2874f0ba1d 100644 (file)
@@ -58,8 +58,6 @@
 MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
 MODULE_DESCRIPTION("USB Audio");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{Generic,USB Audio}}");
-
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
@@ -830,6 +828,9 @@ static int usb_audio_probe(struct usb_interface *intf,
                snd_media_device_create(chip, intf);
        }
 
+       if (quirk)
+               chip->quirk_type = quirk->type;
+
        usb_chip[chip->index] = chip;
        chip->intf[chip->num_interfaces] = intf;
        chip->num_interfaces++;
@@ -904,6 +905,9 @@ static void usb_audio_disconnect(struct usb_interface *intf)
                }
        }
 
+       if (chip->quirk_type & QUIRK_SETUP_DISABLE_AUTOSUSPEND)
+               usb_enable_autosuspend(interface_to_usbdev(intf));
+
        chip->num_interfaces--;
        if (chip->num_interfaces <= 0) {
                usb_chip[chip->index] = NULL;
index c2824188d1420099eceff105fe3a425d690d01de..95385e90882c74199bcb3470dc2d16e100f60260 100644 (file)
@@ -21,23 +21,6 @@ MODULE_AUTHOR("Michael Trimarchi <michael@amarulasolutions.com>");
 MODULE_AUTHOR("Antonio Ospite <ao2@amarulasolutions.com>");
 MODULE_DESCRIPTION("M2Tech hiFace USB-SPDIF audio driver");
 MODULE_LICENSE("GPL v2");
-MODULE_SUPPORTED_DEVICE("{{M2Tech,Young},"
-                        "{M2Tech,hiFace},"
-                        "{M2Tech,North Star},"
-                        "{M2Tech,W4S Young},"
-                        "{M2Tech,Corrson},"
-                        "{M2Tech,AUDIA},"
-                        "{M2Tech,SL Audio},"
-                        "{M2Tech,Empirical},"
-                        "{M2Tech,Rockna},"
-                        "{M2Tech,Pathos},"
-                        "{M2Tech,Metronome},"
-                        "{M2Tech,CAD},"
-                        "{M2Tech,Audio Esclusive},"
-                        "{M2Tech,Rotel},"
-                        "{M2Tech,Eeaudio},"
-                        "{The Chord Company,CHORD},"
-                        "{AVA Group A/S,Vitus}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-max */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* Id for card */
index 6b30155964ec0b48b93f2b3756ba98344fe777ba..5834d1dc317efa1f819f475eb364b708a96e865a 100644 (file)
@@ -19,7 +19,6 @@
 MODULE_DESCRIPTION("Edirol UA-101/1000 driver");
 MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
 MODULE_LICENSE("GPL v2");
-MODULE_SUPPORTED_DEVICE("{{Edirol,UA-101},{Edirol,UA-1000}}");
 
 /*
  * Should not be lower than the minimum scheduling delay of the host
index 08873d2afe4d6606f97043f445c31219fc2f4fe3..ffd922327ae4a7707ad5b60aef3361929070704d 100644 (file)
@@ -2883,7 +2883,7 @@ static int snd_djm_controls_put(struct snd_kcontrol *kctl, struct snd_ctl_elem_v
        u8 group = (private_value & SND_DJM_GROUP_MASK) >> SND_DJM_GROUP_SHIFT;
        u16 value = elem->value.enumerated.item[0];
 
-       kctl->private_value = ((device << SND_DJM_DEVICE_SHIFT) |
+       kctl->private_value = (((unsigned long)device << SND_DJM_DEVICE_SHIFT) |
                              (group << SND_DJM_GROUP_SHIFT) |
                              value);
 
@@ -2921,7 +2921,7 @@ static int snd_djm_controls_create(struct usb_mixer_interface *mixer,
                value = device->controls[i].default_value;
                knew.name = device->controls[i].name;
                knew.private_value = (
-                       (device_idx << SND_DJM_DEVICE_SHIFT) |
+                       ((unsigned long)device_idx << SND_DJM_DEVICE_SHIFT) |
                        (i << SND_DJM_GROUP_SHIFT) |
                        value);
                err = snd_djm_controls_update(mixer, device_idx, i, value);
index 737b2729c0d3790be07206c505a2e13a7b3f9da0..d3001fb18141fe02317a3056dd35e9b9b541db91 100644 (file)
@@ -547,7 +547,7 @@ static int setup_disable_autosuspend(struct snd_usb_audio *chip,
                                       struct usb_driver *driver,
                                       const struct snd_usb_audio_quirk *quirk)
 {
-       driver->supports_autosuspend = 0;
+       usb_disable_autosuspend(interface_to_usbdev(iface));
        return 1;       /* Continue with creating streams and mixer */
 }
 
@@ -1520,6 +1520,7 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip)
        case USB_ID(0x1901, 0x0191): /* GE B850V3 CP2114 audio interface */
        case USB_ID(0x21b4, 0x0081): /* AudioQuest DragonFly */
        case USB_ID(0x2912, 0x30c8): /* Audioengine D1 */
+       case USB_ID(0x413c, 0xa506): /* Dell AE515 sound bar */
                return true;
        }
 
@@ -1670,6 +1671,14 @@ void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe,
            && (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
                msleep(20);
 
+       /*
+        * Plantronics headsets (C320, C320-M, etc) need a delay to avoid
+        * random microhpone failures.
+        */
+       if (USB_ID_VENDOR(chip->usb_id) == 0x047f &&
+           (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
+               msleep(20);
+
        /* Zoom R16/24, many Logitech(at least H650e/H570e/BCC950),
         * Jabra 550a, Kingston HyperX needs a tiny delay here,
         * otherwise requests like get/set frequency return
index 215c1771dd570725671ceab9913ca2cdadc33126..60b9dd7df6bb76e5c3e8e7dbaadfe43f16ce5b0f 100644 (file)
@@ -27,6 +27,7 @@ struct snd_usb_audio {
        struct snd_card *card;
        struct usb_interface *intf[MAX_CARD_INTERFACES];
        u32 usb_id;
+       uint16_t quirk_type;
        struct mutex mutex;
        unsigned int system_suspend;
        atomic_t active;
index c54158146917b42656cf94c1f62f583712a43f12..3cd28d24f0a731a9f512f4699fd2cb6123705735 100644 (file)
 MODULE_AUTHOR("Karsten Wiese <annabellesgarden@yahoo.de>");
 MODULE_DESCRIPTION("TASCAM "NAME_ALLCAPS" Version 0.8.7.2");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{TASCAM(0x1604),"NAME_ALLCAPS"(0x8001)(0x8005)(0x8007)}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-max */
 static char* id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* Id for this card */
index 1d66c3a4fb107e6e65bd6e8452226f4b65b50708..33b12aa67cf5bc6c1624c5c7bfe24a8f478c8d5a 100644 (file)
@@ -1887,4 +1887,3 @@ MODULE_AUTHOR("Vaibhav Agarwal <vaibhav.agarwal@intel.com>");
 MODULE_AUTHOR("Jerome Anand <jerome.anand@intel.com>");
 MODULE_DESCRIPTION("Intel HDMI Audio driver");
 MODULE_LICENSE("GPL v2");
-MODULE_SUPPORTED_DEVICE("{Intel,Intel_HAD}");
index 228d82031297319f7ca4224fc531d72459852810..2cb0a19be2b858883c25be4224da2c7febeb6a22 100644 (file)
@@ -391,4 +391,3 @@ module_exit(xen_drv_fini);
 MODULE_DESCRIPTION("Xen virtual sound device frontend");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS("xen:" XENSND_DRIVER_NAME);
-MODULE_SUPPORTED_DEVICE("{{ALSA,Virtual soundcard}}");
index 543dd70e12c81d59a9987c437f1895a216c2525b..ad64d673b5e6bb6372bf4e9ec0694c47d469c90b 100644 (file)
 #define ACR_SIZE       4
 
 
-#define PTRACE_OLDSETOPTIONS        21
-
+#define PTRACE_OLDSETOPTIONS           21
+#define PTRACE_SYSEMU                  31
+#define PTRACE_SYSEMU_SINGLESTEP       32
 #ifndef __ASSEMBLY__
 #include <linux/stddef.h>
 #include <linux/types.h>
index 84b887825f126b75727809dcb37cd6c8b5739ff4..cc96e26d69f7ae9fa04ccdbc35d1f72f93d735a2 100644 (file)
@@ -13,7 +13,7 @@
 /*
  * Defines x86 CPU feature bits
  */
-#define NCAPINTS                       19         /* N 32-bit words worth of info */
+#define NCAPINTS                       20         /* N 32-bit words worth of info */
 #define NBUGINTS                       1          /* N 32-bit bug flags */
 
 /*
@@ -96,7 +96,7 @@
 #define X86_FEATURE_SYSCALL32          ( 3*32+14) /* "" syscall in IA32 userspace */
 #define X86_FEATURE_SYSENTER32         ( 3*32+15) /* "" sysenter in IA32 userspace */
 #define X86_FEATURE_REP_GOOD           ( 3*32+16) /* REP microcode works well */
-#define X86_FEATURE_SME_COHERENT       ( 3*32+17) /* "" AMD hardware-enforced cache coherency */
+/* FREE!                                ( 3*32+17) */
 #define X86_FEATURE_LFENCE_RDTSC       ( 3*32+18) /* "" LFENCE synchronizes RDTSC */
 #define X86_FEATURE_ACC_POWER          ( 3*32+19) /* AMD Accumulated Power Mechanism */
 #define X86_FEATURE_NOPL               ( 3*32+20) /* The NOPL (0F 1F) instructions */
 #define X86_FEATURE_INVPCID_SINGLE     ( 7*32+ 7) /* Effectively INVPCID && CR4.PCIDE=1 */
 #define X86_FEATURE_HW_PSTATE          ( 7*32+ 8) /* AMD HW-PState */
 #define X86_FEATURE_PROC_FEEDBACK      ( 7*32+ 9) /* AMD ProcFeedbackInterface */
-#define X86_FEATURE_SME                        ( 7*32+10) /* AMD Secure Memory Encryption */
+/* FREE!                                ( 7*32+10) */
 #define X86_FEATURE_PTI                        ( 7*32+11) /* Kernel Page Table Isolation enabled */
 #define X86_FEATURE_RETPOLINE          ( 7*32+12) /* "" Generic Retpoline mitigation for Spectre variant 2 */
 #define X86_FEATURE_RETPOLINE_AMD      ( 7*32+13) /* "" AMD Retpoline mitigation for Spectre variant 2 */
 #define X86_FEATURE_SSBD               ( 7*32+17) /* Speculative Store Bypass Disable */
 #define X86_FEATURE_MBA                        ( 7*32+18) /* Memory Bandwidth Allocation */
 #define X86_FEATURE_RSB_CTXSW          ( 7*32+19) /* "" Fill RSB on context switches */
-#define X86_FEATURE_SEV                        ( 7*32+20) /* AMD Secure Encrypted Virtualization */
+/* FREE!                                ( 7*32+20) */
 #define X86_FEATURE_USE_IBPB           ( 7*32+21) /* "" Indirect Branch Prediction Barrier enabled */
 #define X86_FEATURE_USE_IBRS_FW                ( 7*32+22) /* "" Use IBRS during runtime firmware calls */
 #define X86_FEATURE_SPEC_STORE_BYPASS_DISABLE  ( 7*32+23) /* "" Disable Speculative Store Bypass. */
 #define X86_FEATURE_EPT_AD             ( 8*32+17) /* Intel Extended Page Table access-dirty bit */
 #define X86_FEATURE_VMCALL             ( 8*32+18) /* "" Hypervisor supports the VMCALL instruction */
 #define X86_FEATURE_VMW_VMMCALL                ( 8*32+19) /* "" VMware prefers VMMCALL hypercall instruction */
-#define X86_FEATURE_SEV_ES             ( 8*32+20) /* AMD Secure Encrypted Virtualization - Encrypted State */
-#define X86_FEATURE_VM_PAGE_FLUSH      ( 8*32+21) /* "" VM Page Flush MSR is supported */
 
 /* Intel-defined CPU features, CPUID level 0x00000007:0 (EBX), word 9 */
 #define X86_FEATURE_FSGSBASE           ( 9*32+ 0) /* RDFSBASE, WRFSBASE, RDGSBASE, WRGSBASE instructions*/
 #define X86_FEATURE_PER_THREAD_MBA     (11*32+ 7) /* "" Per-thread Memory Bandwidth Allocation */
 
 /* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */
+#define X86_FEATURE_AVX_VNNI           (12*32+ 4) /* AVX VNNI instructions */
 #define X86_FEATURE_AVX512_BF16                (12*32+ 5) /* AVX512 BFLOAT16 instructions */
 
 /* AMD-defined CPU features, CPUID level 0x80000008 (EBX), word 13 */
 #define X86_FEATURE_AVIC               (15*32+13) /* Virtual Interrupt Controller */
 #define X86_FEATURE_V_VMSAVE_VMLOAD    (15*32+15) /* Virtual VMSAVE VMLOAD */
 #define X86_FEATURE_VGIF               (15*32+16) /* Virtual GIF */
+#define X86_FEATURE_SVME_ADDR_CHK      (15*32+28) /* "" SVME addr check */
 
 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ECX), word 16 */
 #define X86_FEATURE_AVX512VBMI         (16*32+ 1) /* AVX512 Vector Bit Manipulation instructions*/
 #define X86_FEATURE_CORE_CAPABILITIES  (18*32+30) /* "" IA32_CORE_CAPABILITIES MSR */
 #define X86_FEATURE_SPEC_CTRL_SSBD     (18*32+31) /* "" Speculative Store Bypass Disable */
 
+/* AMD-defined memory encryption features, CPUID level 0x8000001f (EAX), word 19 */
+#define X86_FEATURE_SME                        (19*32+ 0) /* AMD Secure Memory Encryption */
+#define X86_FEATURE_SEV                        (19*32+ 1) /* AMD Secure Encrypted Virtualization */
+#define X86_FEATURE_VM_PAGE_FLUSH      (19*32+ 2) /* "" VM Page Flush MSR is supported */
+#define X86_FEATURE_SEV_ES             (19*32+ 3) /* AMD Secure Encrypted Virtualization - Encrypted State */
+#define X86_FEATURE_SME_COHERENT       (19*32+10) /* "" AMD hardware-enforced cache coherency */
+
 /*
  * BUG word(s)
  */
index 8e76d3701db3f2432c91c9bd32623202547593b1..5a3022c8af82b8af1b88e5ed9d8b9af8afc5c9dd 100644 (file)
@@ -112,6 +112,7 @@ struct kvm_ioapic_state {
 #define KVM_NR_IRQCHIPS          3
 
 #define KVM_RUN_X86_SMM                 (1 << 0)
+#define KVM_RUN_X86_BUS_LOCK     (1 << 1)
 
 /* for KVM_GET_REGS and KVM_SET_REGS */
 struct kvm_regs {
index ada955c5ebb6055d7d71d12e20f578dfe6d1ab91..b8e650a985e358f9ef91c140d910a781f93edd7b 100644 (file)
@@ -89,6 +89,7 @@
 #define EXIT_REASON_XRSTORS             64
 #define EXIT_REASON_UMWAIT              67
 #define EXIT_REASON_TPAUSE              68
+#define EXIT_REASON_BUS_LOCK            74
 
 #define VMX_EXIT_REASONS \
        { EXIT_REASON_EXCEPTION_NMI,         "EXCEPTION_NMI" }, \
        { EXIT_REASON_XSAVES,                "XSAVES" }, \
        { EXIT_REASON_XRSTORS,               "XRSTORS" }, \
        { EXIT_REASON_UMWAIT,                "UMWAIT" }, \
-       { EXIT_REASON_TPAUSE,                "TPAUSE" }
+       { EXIT_REASON_TPAUSE,                "TPAUSE" }, \
+       { EXIT_REASON_BUS_LOCK,              "BUS_LOCK" }
 
 #define VMX_EXIT_REASON_FLAGS \
        { VMX_EXIT_REASONS_FAILED_VMENTRY,      "FAILED_VMENTRY" }
index 7409d7860aa6c3167b6a9e282f4e046b06e6b91f..80d966cfcaa1461e2fb6199f8806dd578b0cf2bb 100644 (file)
@@ -260,6 +260,11 @@ static struct btf_id *add_symbol(struct rb_root *root, char *name, size_t size)
        return btf_id__add(root, id, false);
 }
 
+/* Older libelf.h and glibc elf.h might not yet define the ELF compression types. */
+#ifndef SHF_COMPRESSED
+#define SHF_COMPRESSED (1 << 11) /* Section with compressed data. */
+#endif
+
 /*
  * The data of compressed section should be aligned to 4
  * (for 32bit) or 8 (for 64 bit) bytes. The binutils ld
index bae48e6fa9952accdb6b61596020d74371e2f42c..5ed41b96fcdedabac4de5127da70322f5b8de961 100644 (file)
@@ -30,12 +30,18 @@ build     := -f $(srctree)/tools/build/Makefile.build dir=. obj
 
 all: $(OUTPUT)fixdep
 
+# Make sure there's anything to clean,
+# feature contains check for existing OUTPUT
+TMP_O := $(if $(OUTPUT),$(OUTPUT)/feature,./)
+
 clean:
        $(call QUIET_CLEAN, fixdep)
        $(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
        $(Q)rm -f $(OUTPUT)fixdep
        $(call QUIET_CLEAN, feature-detect)
-       $(Q)$(MAKE) -C feature/ clean >/dev/null
+ifneq ($(wildcard $(TMP_O)),)
+       $(Q)$(MAKE) -C feature OUTPUT=$(TMP_O) clean >/dev/null
+endif
 
 $(OUTPUT)fixdep-in.o: FORCE
        $(Q)$(MAKE) $(build)=fixdep
index b0e35eec6499bf4367da462c1f180c77821336e2..4ac5c081af93d729757bffaaad40bdb7076d05a4 100644 (file)
 #define CORESIGHT_ETM_PMU_NAME "cs_etm"
 #define CORESIGHT_ETM_PMU_SEED  0x10
 
-/* ETMv3.5/PTM's ETMCR config bit */
-#define ETM_OPT_CYCACC  12
-#define ETM_OPT_CTXTID 14
-#define ETM_OPT_TS      28
-#define ETM_OPT_RETSTK 29
+/*
+ * Below are the definition of bit offsets for perf option, and works as
+ * arbitrary values for all ETM versions.
+ *
+ * Most of them are orignally from ETMv3.5/PTM's ETMCR config, therefore,
+ * ETMv3.5/PTM doesn't define ETMCR config bits with prefix "ETM3_" and
+ * directly use below macros as config bits.
+ */
+#define ETM_OPT_CYCACC         12
+#define ETM_OPT_CTXTID         14
+#define ETM_OPT_CTXTID2                15
+#define ETM_OPT_TS             28
+#define ETM_OPT_RETSTK         29
 
 /* ETMv4 CONFIGR programming bits for the ETM OPTs */
 #define ETM4_CFG_BIT_CYCACC    4
 #define ETM4_CFG_BIT_CTXTID    6
+#define ETM4_CFG_BIT_VMID      7
 #define ETM4_CFG_BIT_TS                11
 #define ETM4_CFG_BIT_RETSTK    12
+#define ETM4_CFG_BIT_VMID_OPT  15
 
 static inline int coresight_get_trace_id(int cpu)
 {
index 808b48a93330bad83759a3cd81331f812296a12a..0827037c54847898c6771146c5ac285d57849ede 100644 (file)
@@ -1,11 +1,10 @@
-/**
- * \file drm.h
+/*
  * Header for the Direct Rendering Manager
  *
- * \author Rickard E. (Rik) Faith <faith@valinux.com>
+ * Author: Rickard E. (Rik) Faith <faith@valinux.com>
  *
- * \par Acknowledgments:
- * Dec 1999, Richard Henderson <rth@twiddle.net>, move to generic \c cmpxchg.
+ * Acknowledgments:
+ * Dec 1999, Richard Henderson <rth@twiddle.net>, move to generic cmpxchg.
  */
 
 /*
@@ -85,7 +84,7 @@ typedef unsigned int drm_context_t;
 typedef unsigned int drm_drawable_t;
 typedef unsigned int drm_magic_t;
 
-/**
+/*
  * Cliprect.
  *
  * \warning: If you change this structure, make sure you change
@@ -101,7 +100,7 @@ struct drm_clip_rect {
        unsigned short y2;
 };
 
-/**
+/*
  * Drawable information.
  */
 struct drm_drawable_info {
@@ -109,7 +108,7 @@ struct drm_drawable_info {
        struct drm_clip_rect *rects;
 };
 
-/**
+/*
  * Texture region,
  */
 struct drm_tex_region {
@@ -120,7 +119,7 @@ struct drm_tex_region {
        unsigned int age;
 };
 
-/**
+/*
  * Hardware lock.
  *
  * The lock structure is a simple cache-line aligned integer.  To avoid
@@ -132,7 +131,7 @@ struct drm_hw_lock {
        char padding[60];                       /**< Pad to cache line */
 };
 
-/**
+/*
  * DRM_IOCTL_VERSION ioctl argument type.
  *
  * \sa drmGetVersion().
@@ -149,7 +148,7 @@ struct drm_version {
        char __user *desc;        /**< User-space buffer to hold desc */
 };
 
-/**
+/*
  * DRM_IOCTL_GET_UNIQUE ioctl argument type.
  *
  * \sa drmGetBusid() and drmSetBusId().
@@ -168,7 +167,7 @@ struct drm_block {
        int unused;
 };
 
-/**
+/*
  * DRM_IOCTL_CONTROL ioctl argument type.
  *
  * \sa drmCtlInstHandler() and drmCtlUninstHandler().
@@ -183,7 +182,7 @@ struct drm_control {
        int irq;
 };
 
-/**
+/*
  * Type of memory to map.
  */
 enum drm_map_type {
@@ -195,7 +194,7 @@ enum drm_map_type {
        _DRM_CONSISTENT = 5       /**< Consistent memory for PCI DMA */
 };
 
-/**
+/*
  * Memory mapping flags.
  */
 enum drm_map_flags {
@@ -214,7 +213,7 @@ struct drm_ctx_priv_map {
        void *handle;            /**< Handle of map */
 };
 
-/**
+/*
  * DRM_IOCTL_GET_MAP, DRM_IOCTL_ADD_MAP and DRM_IOCTL_RM_MAP ioctls
  * argument type.
  *
@@ -231,7 +230,7 @@ struct drm_map {
        /*   Private data */
 };
 
-/**
+/*
  * DRM_IOCTL_GET_CLIENT ioctl argument type.
  */
 struct drm_client {
@@ -263,7 +262,7 @@ enum drm_stat_type {
            /* Add to the *END* of the list */
 };
 
-/**
+/*
  * DRM_IOCTL_GET_STATS ioctl argument type.
  */
 struct drm_stats {
@@ -274,7 +273,7 @@ struct drm_stats {
        } data[15];
 };
 
-/**
+/*
  * Hardware locking flags.
  */
 enum drm_lock_flags {
@@ -289,7 +288,7 @@ enum drm_lock_flags {
        _DRM_HALT_CUR_QUEUES = 0x20  /**< Halt all current queues */
 };
 
-/**
+/*
  * DRM_IOCTL_LOCK, DRM_IOCTL_UNLOCK and DRM_IOCTL_FINISH ioctl argument type.
  *
  * \sa drmGetLock() and drmUnlock().
@@ -299,7 +298,7 @@ struct drm_lock {
        enum drm_lock_flags flags;
 };
 
-/**
+/*
  * DMA flags
  *
  * \warning
@@ -328,7 +327,7 @@ enum drm_dma_flags {
        _DRM_DMA_LARGER_OK = 0x40     /**< Larger-than-requested buffers OK */
 };
 
-/**
+/*
  * DRM_IOCTL_ADD_BUFS and DRM_IOCTL_MARK_BUFS ioctl argument type.
  *
  * \sa drmAddBufs().
@@ -351,7 +350,7 @@ struct drm_buf_desc {
                                  */
 };
 
-/**
+/*
  * DRM_IOCTL_INFO_BUFS ioctl argument type.
  */
 struct drm_buf_info {
@@ -359,7 +358,7 @@ struct drm_buf_info {
        struct drm_buf_desc __user *list;
 };
 
-/**
+/*
  * DRM_IOCTL_FREE_BUFS ioctl argument type.
  */
 struct drm_buf_free {
@@ -367,7 +366,7 @@ struct drm_buf_free {
        int __user *list;
 };
 
-/**
+/*
  * Buffer information
  *
  * \sa drm_buf_map.
@@ -379,7 +378,7 @@ struct drm_buf_pub {
        void __user *address;          /**< Address of buffer */
 };
 
-/**
+/*
  * DRM_IOCTL_MAP_BUFS ioctl argument type.
  */
 struct drm_buf_map {
@@ -392,7 +391,7 @@ struct drm_buf_map {
        struct drm_buf_pub __user *list;        /**< Buffer information */
 };
 
-/**
+/*
  * DRM_IOCTL_DMA ioctl argument type.
  *
  * Indices here refer to the offset into the buffer list in drm_buf_get.
@@ -417,7 +416,7 @@ enum drm_ctx_flags {
        _DRM_CONTEXT_2DONLY = 0x02
 };
 
-/**
+/*
  * DRM_IOCTL_ADD_CTX ioctl argument type.
  *
  * \sa drmCreateContext() and drmDestroyContext().
@@ -427,7 +426,7 @@ struct drm_ctx {
        enum drm_ctx_flags flags;
 };
 
-/**
+/*
  * DRM_IOCTL_RES_CTX ioctl argument type.
  */
 struct drm_ctx_res {
@@ -435,14 +434,14 @@ struct drm_ctx_res {
        struct drm_ctx __user *contexts;
 };
 
-/**
+/*
  * DRM_IOCTL_ADD_DRAW and DRM_IOCTL_RM_DRAW ioctl argument type.
  */
 struct drm_draw {
        drm_drawable_t handle;
 };
 
-/**
+/*
  * DRM_IOCTL_UPDATE_DRAW ioctl argument type.
  */
 typedef enum {
@@ -456,14 +455,14 @@ struct drm_update_draw {
        unsigned long long data;
 };
 
-/**
+/*
  * DRM_IOCTL_GET_MAGIC and DRM_IOCTL_AUTH_MAGIC ioctl argument type.
  */
 struct drm_auth {
        drm_magic_t magic;
 };
 
-/**
+/*
  * DRM_IOCTL_IRQ_BUSID ioctl argument type.
  *
  * \sa drmGetInterruptFromBusID().
@@ -505,7 +504,7 @@ struct drm_wait_vblank_reply {
        long tval_usec;
 };
 
-/**
+/*
  * DRM_IOCTL_WAIT_VBLANK ioctl argument type.
  *
  * \sa drmWaitVBlank().
@@ -518,7 +517,7 @@ union drm_wait_vblank {
 #define _DRM_PRE_MODESET 1
 #define _DRM_POST_MODESET 2
 
-/**
+/*
  * DRM_IOCTL_MODESET_CTL ioctl argument type
  *
  * \sa drmModesetCtl().
@@ -528,7 +527,7 @@ struct drm_modeset_ctl {
        __u32 cmd;
 };
 
-/**
+/*
  * DRM_IOCTL_AGP_ENABLE ioctl argument type.
  *
  * \sa drmAgpEnable().
@@ -537,7 +536,7 @@ struct drm_agp_mode {
        unsigned long mode;     /**< AGP mode */
 };
 
-/**
+/*
  * DRM_IOCTL_AGP_ALLOC and DRM_IOCTL_AGP_FREE ioctls argument type.
  *
  * \sa drmAgpAlloc() and drmAgpFree().
@@ -549,7 +548,7 @@ struct drm_agp_buffer {
        unsigned long physical; /**< Physical used by i810 */
 };
 
-/**
+/*
  * DRM_IOCTL_AGP_BIND and DRM_IOCTL_AGP_UNBIND ioctls argument type.
  *
  * \sa drmAgpBind() and drmAgpUnbind().
@@ -559,7 +558,7 @@ struct drm_agp_binding {
        unsigned long offset;   /**< In bytes -- will round to page boundary */
 };
 
-/**
+/*
  * DRM_IOCTL_AGP_INFO ioctl argument type.
  *
  * \sa drmAgpVersionMajor(), drmAgpVersionMinor(), drmAgpGetMode(),
@@ -580,7 +579,7 @@ struct drm_agp_info {
        unsigned short id_device;
 };
 
-/**
+/*
  * DRM_IOCTL_SG_ALLOC ioctl argument type.
  */
 struct drm_scatter_gather {
@@ -588,7 +587,7 @@ struct drm_scatter_gather {
        unsigned long handle;   /**< Used for mapping / unmapping */
 };
 
-/**
+/*
  * DRM_IOCTL_SET_VERSION ioctl argument type.
  */
 struct drm_set_version {
@@ -598,14 +597,14 @@ struct drm_set_version {
        int drm_dd_minor;
 };
 
-/** DRM_IOCTL_GEM_CLOSE ioctl argument type */
+/* DRM_IOCTL_GEM_CLOSE ioctl argument type */
 struct drm_gem_close {
        /** Handle of the object to be closed. */
        __u32 handle;
        __u32 pad;
 };
 
-/** DRM_IOCTL_GEM_FLINK ioctl argument type */
+/* DRM_IOCTL_GEM_FLINK ioctl argument type */
 struct drm_gem_flink {
        /** Handle for the object being named */
        __u32 handle;
@@ -614,7 +613,7 @@ struct drm_gem_flink {
        __u32 name;
 };
 
-/** DRM_IOCTL_GEM_OPEN ioctl argument type */
+/* DRM_IOCTL_GEM_OPEN ioctl argument type */
 struct drm_gem_open {
        /** Name of object being opened */
        __u32 name;
@@ -652,7 +651,7 @@ struct drm_gem_open {
 #define DRM_CAP_SYNCOBJ                0x13
 #define DRM_CAP_SYNCOBJ_TIMELINE       0x14
 
-/** DRM_IOCTL_GET_CAP ioctl argument type */
+/* DRM_IOCTL_GET_CAP ioctl argument type */
 struct drm_get_cap {
        __u64 capability;
        __u64 value;
@@ -678,7 +677,9 @@ struct drm_get_cap {
 /**
  * DRM_CLIENT_CAP_ATOMIC
  *
- * If set to 1, the DRM core will expose atomic properties to userspace
+ * If set to 1, the DRM core will expose atomic properties to userspace. This
+ * implicitly enables &DRM_CLIENT_CAP_UNIVERSAL_PLANES and
+ * &DRM_CLIENT_CAP_ASPECT_RATIO.
  */
 #define DRM_CLIENT_CAP_ATOMIC  3
 
@@ -698,7 +699,7 @@ struct drm_get_cap {
  */
 #define DRM_CLIENT_CAP_WRITEBACK_CONNECTORS    5
 
-/** DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */
+/* DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */
 struct drm_set_client_cap {
        __u64 capability;
        __u64 value;
@@ -950,7 +951,7 @@ extern "C" {
 
 #define DRM_IOCTL_MODE_GETFB2          DRM_IOWR(0xCE, struct drm_mode_fb_cmd2)
 
-/**
+/*
  * Device specific ioctls should only be in their respective headers
  * The device specific ioctl range is from 0x40 to 0x9f.
  * Generic IOCTLS restart at 0xA0.
@@ -961,7 +962,7 @@ extern "C" {
 #define DRM_COMMAND_BASE                0x40
 #define DRM_COMMAND_END                        0xA0
 
-/**
+/*
  * Header for events written back to userspace on the drm fd.  The
  * type defines the type of event, the length specifies the total
  * length of the event (including the header), and user_data is
index fa1f3d62f9a6cebb300c63bf82955af91ab2a6ed..1987e2ea79a3b86263529b5d3207ac89c767e6fd 100644 (file)
@@ -177,8 +177,9 @@ enum drm_i915_pmu_engine_sample {
 #define I915_PMU_REQUESTED_FREQUENCY   __I915_PMU_OTHER(1)
 #define I915_PMU_INTERRUPTS            __I915_PMU_OTHER(2)
 #define I915_PMU_RC6_RESIDENCY         __I915_PMU_OTHER(3)
+#define I915_PMU_SOFTWARE_GT_AWAKE_TIME        __I915_PMU_OTHER(4)
 
-#define I915_PMU_LAST I915_PMU_RC6_RESIDENCY
+#define I915_PMU_LAST /* Deprecated - do not use */ I915_PMU_RC6_RESIDENCY
 
 /* Each region is a minimum of 16k, and there are at most 255 of them.
  */
index 4c24daa43bacc601cd3fc5ca8eeda3614bb45344..79c893310492b33689352b9dff5f53a42dd9d72b 100644 (file)
@@ -3850,7 +3850,6 @@ union bpf_attr {
  *
  * long bpf_check_mtu(void *ctx, u32 ifindex, u32 *mtu_len, s32 len_diff, u64 flags)
  *     Description
-
  *             Check ctx packet size against exceeding MTU of net device (based
  *             on *ifindex*).  This helper will likely be used in combination
  *             with helpers that adjust/change the packet size.
index abb89bbe563544034496af2271d77622aca86381..8b281f722e5bd8f098a384dd9f00c5115ad497d7 100644 (file)
@@ -216,6 +216,20 @@ struct kvm_hyperv_exit {
        } u;
 };
 
+struct kvm_xen_exit {
+#define KVM_EXIT_XEN_HCALL          1
+       __u32 type;
+       union {
+               struct {
+                       __u32 longmode;
+                       __u32 cpl;
+                       __u64 input;
+                       __u64 result;
+                       __u64 params[6];
+               } hcall;
+       } u;
+};
+
 #define KVM_S390_GET_SKEYS_NONE   1
 #define KVM_S390_SKEYS_MAX        1048576
 
@@ -252,6 +266,8 @@ struct kvm_hyperv_exit {
 #define KVM_EXIT_X86_WRMSR        30
 #define KVM_EXIT_DIRTY_RING_FULL  31
 #define KVM_EXIT_AP_RESET_HOLD    32
+#define KVM_EXIT_X86_BUS_LOCK     33
+#define KVM_EXIT_XEN              34
 
 /* For KVM_EXIT_INTERNAL_ERROR */
 /* Emulate instruction failed. */
@@ -428,6 +444,8 @@ struct kvm_run {
                        __u32 index; /* kernel -> user */
                        __u64 data; /* kernel <-> user */
                } msr;
+               /* KVM_EXIT_XEN */
+               struct kvm_xen_exit xen;
                /* Fix the size of the union. */
                char padding[256];
        };
@@ -1058,6 +1076,7 @@ struct kvm_ppc_resize_hpt {
 #define KVM_CAP_ENFORCE_PV_FEATURE_CPUID 190
 #define KVM_CAP_SYS_HYPERV_CPUID 191
 #define KVM_CAP_DIRTY_LOG_RING 192
+#define KVM_CAP_X86_BUS_LOCK_EXIT 193
 #define KVM_CAP_PPC_DAWR1 194
 
 #ifdef KVM_CAP_IRQ_ROUTING
@@ -1132,6 +1151,10 @@ struct kvm_x86_mce {
 #endif
 
 #ifdef KVM_CAP_XEN_HVM
+#define KVM_XEN_HVM_CONFIG_HYPERCALL_MSR       (1 << 0)
+#define KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL     (1 << 1)
+#define KVM_XEN_HVM_CONFIG_SHARED_INFO         (1 << 2)
+
 struct kvm_xen_hvm_config {
        __u32 flags;
        __u32 msr;
@@ -1566,6 +1589,45 @@ struct kvm_pv_cmd {
 /* Available with KVM_CAP_DIRTY_LOG_RING */
 #define KVM_RESET_DIRTY_RINGS          _IO(KVMIO, 0xc7)
 
+/* Per-VM Xen attributes */
+#define KVM_XEN_HVM_GET_ATTR   _IOWR(KVMIO, 0xc8, struct kvm_xen_hvm_attr)
+#define KVM_XEN_HVM_SET_ATTR   _IOW(KVMIO,  0xc9, struct kvm_xen_hvm_attr)
+
+struct kvm_xen_hvm_attr {
+       __u16 type;
+       __u16 pad[3];
+       union {
+               __u8 long_mode;
+               __u8 vector;
+               struct {
+                       __u64 gfn;
+               } shared_info;
+               __u64 pad[8];
+       } u;
+};
+
+/* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_SHARED_INFO */
+#define KVM_XEN_ATTR_TYPE_LONG_MODE            0x0
+#define KVM_XEN_ATTR_TYPE_SHARED_INFO          0x1
+#define KVM_XEN_ATTR_TYPE_UPCALL_VECTOR                0x2
+
+/* Per-vCPU Xen attributes */
+#define KVM_XEN_VCPU_GET_ATTR  _IOWR(KVMIO, 0xca, struct kvm_xen_vcpu_attr)
+#define KVM_XEN_VCPU_SET_ATTR  _IOW(KVMIO,  0xcb, struct kvm_xen_vcpu_attr)
+
+struct kvm_xen_vcpu_attr {
+       __u16 type;
+       __u16 pad[3];
+       union {
+               __u64 gpa;
+               __u64 pad[8];
+       } u;
+};
+
+/* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_SHARED_INFO */
+#define KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO       0x0
+#define KVM_XEN_VCPU_ATTR_TYPE_VCPU_TIME_INFO  0x1
+
 /* Secure Encrypted Virtualization command */
 enum sev_cmd_id {
        /* Guest initialization commands */
@@ -1594,6 +1656,8 @@ enum sev_cmd_id {
        KVM_SEV_DBG_ENCRYPT,
        /* Guest certificates commands */
        KVM_SEV_CERT_EXPORT,
+       /* Attestation report */
+       KVM_SEV_GET_ATTESTATION_REPORT,
 
        KVM_SEV_NR_MAX,
 };
@@ -1646,6 +1710,12 @@ struct kvm_sev_dbg {
        __u32 len;
 };
 
+struct kvm_sev_attestation_report {
+       __u8 mnonce[16];
+       __u64 uaddr;
+       __u32 len;
+};
+
 #define KVM_DEV_ASSIGN_ENABLE_IOMMU    (1 << 0)
 #define KVM_DEV_ASSIGN_PCI_2_3         (1 << 1)
 #define KVM_DEV_ASSIGN_MASK_INTX       (1 << 2)
@@ -1767,4 +1837,7 @@ struct kvm_dirty_gfn {
        __u64 offset;
 };
 
+#define KVM_BUS_LOCK_DETECTION_OFF             (1 << 0)
+#define KVM_BUS_LOCK_DETECTION_EXIT            (1 << 1)
+
 #endif /* __LINUX_KVM_H */
index dd8306ea336c19b695fa9a748c14f5ad92fe3e63..e6524ead2b7b9ead2cd5fa20435dd0ce2ecbe158 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef _UAPI_LINUX_MOUNT_H
 #define _UAPI_LINUX_MOUNT_H
 
+#include <linux/types.h>
+
 /*
  * These are the fs-independent mount-flags: up to 32 flags are supported
  *
@@ -117,5 +119,19 @@ enum fsconfig_command {
 #define MOUNT_ATTR_NOATIME     0x00000010 /* - Do not update access times. */
 #define MOUNT_ATTR_STRICTATIME 0x00000020 /* - Always perform atime updates */
 #define MOUNT_ATTR_NODIRATIME  0x00000080 /* Do not update directory access times */
+#define MOUNT_ATTR_IDMAP       0x00100000 /* Idmap mount to @userns_fd in struct mount_attr. */
+
+/*
+ * mount_setattr()
+ */
+struct mount_attr {
+       __u64 attr_set;
+       __u64 attr_clr;
+       __u64 propagation;
+       __u64 userns_fd;
+};
+
+/* List of all mount_attr versions. */
+#define MOUNT_ATTR_SIZE_VER0   32 /* sizeof first published struct */
 
 #endif /* _UAPI_LINUX_MOUNT_H */
index 58b1eb71136007727e8535eaeb19e2ea4a00fb9a..a5feb7604948791c7a34ec0876c24a97eb5a375b 100644 (file)
@@ -35,5 +35,9 @@ struct open_how {
 #define RESOLVE_IN_ROOT                0x10 /* Make all jumps to "/" and ".."
                                        be scoped inside the dirfd
                                        (similar to chroot(2)). */
+#define RESOLVE_CACHED         0x20 /* Only complete if resolution can be
+                                       completed through cached lookup. May
+                                       return -EAGAIN if that's not
+                                       possible. */
 
 #endif /* _UAPI_LINUX_OPENAT2_H */
index ffbb588724d8fc79bae9fd7ff8182b9eb649808f..526fc35c0b23318621ec9e70169192a776bcb499 100644 (file)
@@ -610,15 +610,16 @@ static int xsk_lookup_bpf_maps(struct xsk_socket *xsk)
                if (fd < 0)
                        continue;
 
+               memset(&map_info, 0, map_len);
                err = bpf_obj_get_info_by_fd(fd, &map_info, &map_len);
                if (err) {
                        close(fd);
                        continue;
                }
 
-               if (!strcmp(map_info.name, "xsks_map")) {
+               if (!strncmp(map_info.name, "xsks_map", sizeof(map_info.name))) {
                        ctx->xsks_map_fd = fd;
-                       continue;
+                       break;
                }
 
                close(fd);
index 17465d454a0e31d912f7d0782d3f0bc19b6bfcdd..a0aaf385cbb5855e48a46d37c49209a23c0c162e 100644 (file)
 
 void perf_evlist__init(struct perf_evlist *evlist)
 {
-       int i;
-
-       for (i = 0; i < PERF_EVLIST__HLIST_SIZE; ++i)
-               INIT_HLIST_HEAD(&evlist->heads[i]);
        INIT_LIST_HEAD(&evlist->entries);
        evlist->nr_entries = 0;
        fdarray__init(&evlist->pollfd, 64);
+       perf_evlist__reset_id_hash(evlist);
 }
 
 static void __perf_evlist__propagate_maps(struct perf_evlist *evlist,
@@ -237,6 +234,14 @@ static void perf_evlist__id_hash(struct perf_evlist *evlist,
        hlist_add_head(&sid->node, &evlist->heads[hash]);
 }
 
+void perf_evlist__reset_id_hash(struct perf_evlist *evlist)
+{
+       int i;
+
+       for (i = 0; i < PERF_EVLIST__HLIST_SIZE; ++i)
+               INIT_HLIST_HEAD(&evlist->heads[i]);
+}
+
 void perf_evlist__id_add(struct perf_evlist *evlist,
                         struct perf_evsel *evsel,
                         int cpu, int thread, u64 id)
index 2d0fa02b036f604646663ca5703bd13c12a00ae2..212c29063ad42ccc7891e5e17446ef6ab1827ef9 100644 (file)
@@ -124,4 +124,6 @@ int perf_evlist__id_add_fd(struct perf_evlist *evlist,
                           struct perf_evsel *evsel,
                           int cpu, int thread, int fd);
 
+void perf_evlist__reset_id_hash(struct perf_evlist *evlist);
+
 #endif /* __LIBPERF_INTERNAL_EVLIST_H */
index 068cdb41f76fd0a75069ae2519ffd99844f54306..5e5388a38e2a73878c9665285a72b6c43982adab 100644 (file)
@@ -2442,6 +2442,9 @@ static int handle_insn_ops(struct instruction *insn, struct insn_state *state)
                if (update_cfi_state(insn, &state->cfi, op))
                        return 1;
 
+               if (!insn->alt_group)
+                       continue;
+
                if (op->dest.type == OP_DEST_PUSHF) {
                        if (!state->uaccess_stack) {
                                state->uaccess_stack = 1;
index c0a66400a960d68cbf73690f608867f648d79797..9af8b8dfb7b60efb9491044ba8ded317a3f109eb 100644 (file)
@@ -29,7 +29,7 @@ OPTIONS
        Show just the sample frequency used for each event.
 
 -v::
---verbose=::
+--verbose::
        Show all fields.
 
 -g::
index 1e91121bac0f3815c3f3f9ba19e36ef8a5fca170..6e82b7cc0bf0f510d41168aed9b9eba16d6b3df2 100644 (file)
@@ -28,8 +28,8 @@ OPTIONS
        specified: function_graph or function.
 
 -v::
---verbose=::
-        Verbosity level.
+--verbose::
+        Increase the verbosity level.
 
 -F::
 --funcs::
index f3c620951f6eb945a211db4c7cb58156c9492c9c..c97527df8ecd26050a0db309870ef2e80bb398fc 100644 (file)
@@ -20,5 +20,5 @@ modules).
 OPTIONS
 -------
 -v::
---verbose=::
+--verbose::
        Increase verbosity level, showing details about symbol table loading, etc.
index abc9b5d833128c2bc803fd344308ff3059ea1a12..f0da8cf63e9a965a1ee162dc39559f8f172680e2 100644 (file)
@@ -97,8 +97,8 @@ filter out the startup phase of the program, which is often very different.
        Filter out events for these pids and for 'trace' itself (comma separated list).
 
 -v::
---verbose=::
-        Verbosity level.
+--verbose::
+        Increase the verbosity level.
 
 --no-inherit::
        Child tasks do not inherit counters.
index 5345ac70cd83250e4c2642ac9b44652e79c3b568..f6e609673de2b816850c6bff1f09ced894ac643e 100644 (file)
@@ -607,7 +607,7 @@ arch_errno_hdr_dir := $(srctree)/tools
 arch_errno_tbl := $(srctree)/tools/perf/trace/beauty/arch_errno_names.sh
 
 $(arch_errno_name_array): $(arch_errno_tbl)
-       $(Q)$(SHELL) '$(arch_errno_tbl)' $(firstword $(CC)) $(arch_errno_hdr_dir) > $@
+       $(Q)$(SHELL) '$(arch_errno_tbl)' '$(patsubst -%,,$(CC))' $(arch_errno_hdr_dir) > $@
 
 sync_file_range_arrays := $(beauty_outdir)/sync_file_range_arrays.c
 sync_file_range_tbls := $(srctree)/tools/perf/trace/beauty/sync_file_range.sh
@@ -1001,14 +1001,6 @@ $(INSTALL_DOC_TARGETS):
 
 ### Cleaning rules
 
-#
-# This is here, not in Makefile.config, because Makefile.config does
-# not get included for the clean target:
-#
-config-clean:
-       $(call QUIET_CLEAN, config)
-       $(Q)$(MAKE) -C $(srctree)/tools/build/feature/ $(if $(OUTPUT),OUTPUT=$(OUTPUT)feature/,) clean >/dev/null
-
 python-clean:
        $(python-clean)
 
@@ -1048,7 +1040,7 @@ endif # BUILD_BPF_SKEL
 bpf-skel-clean:
        $(call QUIET_CLEAN, bpf-skel) $(RM) -r $(SKEL_TMP_OUT) $(SKELETONS)
 
-clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBPERF)-clean config-clean fixdep-clean python-clean bpf-skel-clean
+clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBPERF)-clean fixdep-clean python-clean bpf-skel-clean
        $(call QUIET_CLEAN, core-objs)  $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(LANG_BINDINGS)
        $(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
        $(Q)$(RM) $(OUTPUT).config-detected
index bd446aba64f7272daea834e7360fc071b888a7a5..c25c878fd06c97dde942b0311f231e997c05ea4e 100644 (file)
@@ -156,6 +156,10 @@ out:
        return err;
 }
 
+#define ETM_SET_OPT_CTXTID     (1 << 0)
+#define ETM_SET_OPT_TS         (1 << 1)
+#define ETM_SET_OPT_MASK       (ETM_SET_OPT_CTXTID | ETM_SET_OPT_TS)
+
 static int cs_etm_set_option(struct auxtrace_record *itr,
                             struct evsel *evsel, u32 option)
 {
@@ -169,17 +173,17 @@ static int cs_etm_set_option(struct auxtrace_record *itr,
                    !cpu_map__has(online_cpus, i))
                        continue;
 
-               if (option & ETM_OPT_CTXTID) {
+               if (option & ETM_SET_OPT_CTXTID) {
                        err = cs_etm_set_context_id(itr, evsel, i);
                        if (err)
                                goto out;
                }
-               if (option & ETM_OPT_TS) {
+               if (option & ETM_SET_OPT_TS) {
                        err = cs_etm_set_timestamp(itr, evsel, i);
                        if (err)
                                goto out;
                }
-               if (option & ~(ETM_OPT_CTXTID | ETM_OPT_TS))
+               if (option & ~(ETM_SET_OPT_MASK))
                        /* Nothing else is currently supported */
                        goto out;
        }
@@ -406,7 +410,7 @@ static int cs_etm_recording_options(struct auxtrace_record *itr,
                evsel__set_sample_bit(cs_etm_evsel, CPU);
 
                err = cs_etm_set_option(itr, cs_etm_evsel,
-                                       ETM_OPT_CTXTID | ETM_OPT_TS);
+                                       ETM_SET_OPT_CTXTID | ETM_SET_OPT_TS);
                if (err)
                        goto out;
        }
index f744eb5cba887d398e150e9ef9fbb1293d5fe08f..0b2480cf3e4793bdedf18942696d8b2f118aa564 100644 (file)
@@ -9,9 +9,7 @@
 #
 0      nospu   restart_syscall                 sys_restart_syscall
 1      nospu   exit                            sys_exit
-2      32      fork                            ppc_fork                        sys_fork
-2      64      fork                            sys_fork
-2      spu     fork                            sys_ni_syscall
+2      nospu   fork                            sys_fork
 3      common  read                            sys_read
 4      common  write                           sys_write
 5      common  open                            sys_open                        compat_sys_open
 119    32      sigreturn                       sys_sigreturn                   compat_sys_sigreturn
 119    64      sigreturn                       sys_ni_syscall
 119    spu     sigreturn                       sys_ni_syscall
-120    32      clone                           ppc_clone                       sys_clone
-120    64      clone                           sys_clone
-120    spu     clone                           sys_ni_syscall
+120    nospu   clone                           sys_clone
 121    common  setdomainname                   sys_setdomainname
 122    common  uname                           sys_newuname
 123    common  modify_ldt                      sys_ni_syscall
 186    spu     sendfile                        sys_sendfile64
 187    common  getpmsg                         sys_ni_syscall
 188    common  putpmsg                         sys_ni_syscall
-189    32      vfork                           ppc_vfork                       sys_vfork
-189    64      vfork                           sys_vfork
-189    spu     vfork                           sys_ni_syscall
+189    nospu   vfork                           sys_vfork
 190    common  ugetrlimit                      sys_getrlimit                   compat_sys_getrlimit
 191    common  readahead                       sys_readahead                   compat_sys_readahead
 192    32      mmap2                           sys_mmap2                       compat_sys_mmap2
 248    32      clock_nanosleep                 sys_clock_nanosleep_time32
 248    64      clock_nanosleep                 sys_clock_nanosleep
 248    spu     clock_nanosleep                 sys_clock_nanosleep
-249    32      swapcontext                     ppc_swapcontext                 compat_sys_swapcontext
-249    64      swapcontext                     sys_swapcontext
-249    spu     swapcontext                     sys_ni_syscall
+249    nospu   swapcontext                     sys_swapcontext                 compat_sys_swapcontext
 250    common  tgkill                          sys_tgkill
 251    32      utimes                          sys_utimes_time32
 251    64      utimes                          sys_utimes
 432    common  fsmount                         sys_fsmount
 433    common  fspick                          sys_fspick
 434    common  pidfd_open                      sys_pidfd_open
-435    32      clone3                          ppc_clone3                      sys_clone3
-435    64      clone3                          sys_clone3
-435    spu     clone3                          sys_ni_syscall
+435    nospu   clone3                          sys_clone3
 436    common  close_range                     sys_close_range
 437    common  openat2                         sys_openat2
 438    common  pidfd_getfd                     sys_pidfd_getfd
 439    common  faccessat2                      sys_faccessat2
 440    common  process_madvise                 sys_process_madvise
 441    common  epoll_pwait2                    sys_epoll_pwait2                compat_sys_epoll_pwait2
+442    common  mount_setattr                   sys_mount_setattr
index d443423495e565e49a8e57527f00dfdd4ffbea17..3abef2144dac79b69b25852ce28ffb2e5b284afe 100644 (file)
 439  common    faccessat2              sys_faccessat2                  sys_faccessat2
 440  common    process_madvise         sys_process_madvise             sys_process_madvise
 441  common    epoll_pwait2            sys_epoll_pwait2                compat_sys_epoll_pwait2
+442  common    mount_setattr           sys_mount_setattr               sys_mount_setattr
index 8cc6642fce7a6699e3e3fd816ced37d7ae627f5a..5a9f9a7bf07d1750c4a868cd6e19f33632c30d6e 100644 (file)
@@ -10,10 +10,11 @@ PERF_HAVE_JITDUMP := 1
 # Syscall table generation
 #
 
-out    := $(OUTPUT)arch/x86/include/generated/asm
-header := $(out)/syscalls_64.c
-sys    := $(srctree)/tools/perf/arch/x86/entry/syscalls
-systbl := $(sys)/syscalltbl.sh
+generated := $(OUTPUT)arch/x86/include/generated
+out       := $(generated)/asm
+header    := $(out)/syscalls_64.c
+sys       := $(srctree)/tools/perf/arch/x86/entry/syscalls
+systbl    := $(sys)/syscalltbl.sh
 
 # Create output directory if not already present
 _dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)')
@@ -22,6 +23,6 @@ $(header): $(sys)/syscall_64.tbl $(systbl)
        $(Q)$(SHELL) '$(systbl)' $(sys)/syscall_64.tbl 'x86_64' > $@
 
 clean::
-       $(call QUIET_CLEAN, x86) $(RM) $(header)
+       $(call QUIET_CLEAN, x86) $(RM) -r $(header) $(generated)
 
 archheaders: $(header)
index 78672124d28be0da465300ee9a301bab59c1ac1d..7bf01cbe582f03bc26adb4092bb9023384ec217f 100644 (file)
 439    common  faccessat2              sys_faccessat2
 440    common  process_madvise         sys_process_madvise
 441    common  epoll_pwait2            sys_epoll_pwait2
+442    common  mount_setattr           sys_mount_setattr
 
 #
 # Due to a historical design error, certain syscalls are numbered differently
index 6a54b94f1c25b4c2798861e9662e0c957b4d5ce9..0e20f3dc69f3c847a1047f8a03f9852d1b3c0f6d 100644 (file)
@@ -10,6 +10,7 @@ int test__rdpmc(struct test *test __maybe_unused, int subtest);
 int test__insn_x86(struct test *test __maybe_unused, int subtest);
 int test__intel_pt_pkt_decoder(struct test *test, int subtest);
 int test__bp_modify(struct test *test, int subtest);
+int test__x86_sample_parsing(struct test *test, int subtest);
 
 #ifdef HAVE_DWARF_UNWIND_SUPPORT
 struct thread;
index 36d4f248b51dbceda1364767b6949fe720cd6770..28d793390198f1416206c9013e0c1f445b8feb3b 100644 (file)
@@ -3,5 +3,6 @@ perf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.o
 
 perf-y += arch-tests.o
 perf-y += rdpmc.o
+perf-y += sample-parsing.o
 perf-$(CONFIG_AUXTRACE) += insn-x86.o intel-pt-pkt-decoder-test.o
 perf-$(CONFIG_X86_64) += bp-modify.o
index bc25d727b4e9af4be2b2d360b928d9ab01fca7ae..71aa67367ad6bd352e7c16e0ca389fdc9d07c672 100644 (file)
@@ -30,6 +30,10 @@ struct test arch_tests[] = {
                .func = test__bp_modify,
        },
 #endif
+       {
+               .desc = "x86 Sample parsing",
+               .func = test__x86_sample_parsing,
+       },
        {
                .func = NULL,
        },
index f782ef8c5982fc6831e3a268454ad9e060cfe2ba..4f75ae9901403d34649da89dc7dedd3c38bbfe51 100644 (file)
@@ -1,11 +1,11 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <linux/types.h>
-#include "../../../../arch/x86/include/asm/insn.h"
 #include <string.h>
 
 #include "debug.h"
 #include "tests/tests.h"
 #include "arch-tests.h"
+#include "../../../../arch/x86/include/asm/insn.h"
 
 #include "intel-pt-decoder/intel-pt-insn-decoder.h"
 
diff --git a/tools/perf/arch/x86/tests/sample-parsing.c b/tools/perf/arch/x86/tests/sample-parsing.c
new file mode 100644 (file)
index 0000000..c92db87
--- /dev/null
@@ -0,0 +1,121 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include <stdbool.h>
+#include <inttypes.h>
+#include <stdlib.h>
+#include <string.h>
+#include <linux/bitops.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+
+#include "event.h"
+#include "evsel.h"
+#include "debug.h"
+#include "util/synthetic-events.h"
+
+#include "tests/tests.h"
+#include "arch-tests.h"
+
+#define COMP(m) do {                                   \
+       if (s1->m != s2->m) {                           \
+               pr_debug("Samples differ at '"#m"'\n"); \
+               return false;                           \
+       }                                               \
+} while (0)
+
+static bool samples_same(const struct perf_sample *s1,
+                        const struct perf_sample *s2,
+                        u64 type)
+{
+       if (type & PERF_SAMPLE_WEIGHT_STRUCT)
+               COMP(ins_lat);
+
+       return true;
+}
+
+static int do_test(u64 sample_type)
+{
+       struct evsel evsel = {
+               .needs_swap = false,
+               .core = {
+                       . attr = {
+                               .sample_type = sample_type,
+                               .read_format = 0,
+                       },
+               },
+       };
+       union perf_event *event;
+       struct perf_sample sample = {
+               .weight         = 101,
+               .ins_lat        = 102,
+       };
+       struct perf_sample sample_out;
+       size_t i, sz, bufsz;
+       int err, ret = -1;
+
+       sz = perf_event__sample_event_size(&sample, sample_type, 0);
+       bufsz = sz + 4096; /* Add a bit for overrun checking */
+       event = malloc(bufsz);
+       if (!event) {
+               pr_debug("malloc failed\n");
+               return -1;
+       }
+
+       memset(event, 0xff, bufsz);
+       event->header.type = PERF_RECORD_SAMPLE;
+       event->header.misc = 0;
+       event->header.size = sz;
+
+       err = perf_event__synthesize_sample(event, sample_type, 0, &sample);
+       if (err) {
+               pr_debug("%s failed for sample_type %#"PRIx64", error %d\n",
+                        "perf_event__synthesize_sample", sample_type, err);
+               goto out_free;
+       }
+
+       /* The data does not contain 0xff so we use that to check the size */
+       for (i = bufsz; i > 0; i--) {
+               if (*(i - 1 + (u8 *)event) != 0xff)
+                       break;
+       }
+       if (i != sz) {
+               pr_debug("Event size mismatch: actual %zu vs expected %zu\n",
+                        i, sz);
+               goto out_free;
+       }
+
+       evsel.sample_size = __evsel__sample_size(sample_type);
+
+       err = evsel__parse_sample(&evsel, event, &sample_out);
+       if (err) {
+               pr_debug("%s failed for sample_type %#"PRIx64", error %d\n",
+                        "evsel__parse_sample", sample_type, err);
+               goto out_free;
+       }
+
+       if (!samples_same(&sample, &sample_out, sample_type)) {
+               pr_debug("parsing failed for sample_type %#"PRIx64"\n",
+                        sample_type);
+               goto out_free;
+       }
+
+       ret = 0;
+out_free:
+       free(event);
+
+       return ret;
+}
+
+/**
+ * test__x86_sample_parsing - test X86 specific sample parsing
+ *
+ * This function implements a test that synthesizes a sample event, parses it
+ * and then checks that the parsed sample matches the original sample. If the
+ * test passes %0 is returned, otherwise %-1 is returned.
+ *
+ * For now, the PERF_SAMPLE_WEIGHT_STRUCT is the only X86 specific sample type.
+ * The test only checks the PERF_SAMPLE_WEIGHT_STRUCT type.
+ */
+int test__x86_sample_parsing(struct test *test __maybe_unused, int subtest __maybe_unused)
+{
+       return do_test(PERF_SAMPLE_WEIGHT_STRUCT);
+}
index 3e6791531ca5a1799f92f7db8c11c9b3b107439b..34d600c5104403c2eba909017f6751d3fffbfb50 100644 (file)
@@ -1,10 +1,10 @@
 // SPDX-License-Identifier: GPL-2.0
-#include "../../../../arch/x86/include/asm/insn.h"
 #include "archinsn.h"
 #include "event.h"
 #include "machine.h"
 #include "thread.h"
 #include "symbol.h"
+#include "../../../../arch/x86/include/asm/insn.h"
 
 void arch_fetch_insn(struct perf_sample *sample,
                     struct thread *thread,
index 11726ec6285f3d3f05a92ced8c30978e4cfbf0c4..20b87e29c96f4b4c2832e8f3271b435575898168 100644 (file)
@@ -344,18 +344,22 @@ static void mempol_restore(void)
 
 static void bind_to_memnode(int node)
 {
-       unsigned long nodemask;
+       struct bitmask *node_mask;
        int ret;
 
        if (node == NUMA_NO_NODE)
                return;
 
-       BUG_ON(g->p.nr_nodes > (int)sizeof(nodemask)*8);
-       nodemask = 1L << node;
+       node_mask = numa_allocate_nodemask();
+       BUG_ON(!node_mask);
 
-       ret = set_mempolicy(MPOL_BIND, &nodemask, sizeof(nodemask)*8);
-       dprintf("binding to node %d, mask: %016lx => %d\n", node, nodemask, ret);
+       numa_bitmask_clearall(node_mask);
+       numa_bitmask_setbit(node_mask, node);
 
+       ret = set_mempolicy(MPOL_BIND, node_mask->maskp, node_mask->size + 1);
+       dprintf("binding to node %d, mask: %016lx => %d\n", node, *node_mask->maskp, ret);
+
+       numa_bitmask_free(node_mask);
        BUG_ON(ret);
 }
 
@@ -876,8 +880,6 @@ static void update_curr_cpu(int task_nr, unsigned long bytes_worked)
        prctl(0, bytes_worked);
 }
 
-#define MAX_NR_NODES   64
-
 /*
  * Count the number of nodes a process's threads
  * are spread out on.
@@ -888,10 +890,15 @@ static void update_curr_cpu(int task_nr, unsigned long bytes_worked)
  */
 static int count_process_nodes(int process_nr)
 {
-       char node_present[MAX_NR_NODES] = { 0, };
+       char *node_present;
        int nodes;
        int n, t;
 
+       node_present = (char *)malloc(g->p.nr_nodes * sizeof(char));
+       BUG_ON(!node_present);
+       for (nodes = 0; nodes < g->p.nr_nodes; nodes++)
+               node_present[nodes] = 0;
+
        for (t = 0; t < g->p.nr_threads; t++) {
                struct thread_data *td;
                int task_nr;
@@ -901,17 +908,20 @@ static int count_process_nodes(int process_nr)
                td = g->threads + task_nr;
 
                node = numa_node_of_cpu(td->curr_cpu);
-               if (node < 0) /* curr_cpu was likely still -1 */
+               if (node < 0) /* curr_cpu was likely still -1 */ {
+                       free(node_present);
                        return 0;
+               }
 
                node_present[node] = 1;
        }
 
        nodes = 0;
 
-       for (n = 0; n < MAX_NR_NODES; n++)
+       for (n = 0; n < g->p.nr_nodes; n++)
                nodes += node_present[n];
 
+       free(node_present);
        return nodes;
 }
 
@@ -980,7 +990,7 @@ static void calc_convergence(double runtime_ns_max, double *convergence)
 {
        unsigned int loops_done_min, loops_done_max;
        int process_groups;
-       int nodes[MAX_NR_NODES];
+       int *nodes;
        int distance;
        int nr_min;
        int nr_max;
@@ -994,6 +1004,8 @@ static void calc_convergence(double runtime_ns_max, double *convergence)
        if (!g->p.show_convergence && !g->p.measure_convergence)
                return;
 
+       nodes = (int *)malloc(g->p.nr_nodes * sizeof(int));
+       BUG_ON(!nodes);
        for (node = 0; node < g->p.nr_nodes; node++)
                nodes[node] = 0;
 
@@ -1035,8 +1047,10 @@ static void calc_convergence(double runtime_ns_max, double *convergence)
 
        BUG_ON(sum > g->p.nr_tasks);
 
-       if (0 && (sum < g->p.nr_tasks))
+       if (0 && (sum < g->p.nr_tasks)) {
+               free(nodes);
                return;
+       }
 
        /*
         * Count the number of distinct process groups present
@@ -1088,6 +1102,8 @@ static void calc_convergence(double runtime_ns_max, double *convergence)
                }
                tprintf("\n");
        }
+
+       free(nodes);
 }
 
 static void show_summary(double runtime_ns_max, int l, double *convergence)
@@ -1413,7 +1429,7 @@ static int init(void)
        g->p.nr_nodes = numa_max_node() + 1;
 
        /* char array in count_process_nodes(): */
-       BUG_ON(g->p.nr_nodes > MAX_NR_NODES || g->p.nr_nodes < 0);
+       BUG_ON(g->p.nr_nodes < 0);
 
        if (g->p.show_quiet && !g->p.show_details)
                g->p.show_details = -1;
index cecce93ccc63600cb857e45c2bb02c6378843e4d..488f6e6ba1a55e8decd839c98a8d6a8ee838209b 100644 (file)
@@ -309,11 +309,11 @@ int bench_sched_messaging(int argc, const char **argv)
                       num_groups, num_groups * 2 * num_fds,
                       thread_mode ? "threads" : "processes");
                printf(" %14s: %lu.%03lu [sec]\n", "Total time",
-                      diff.tv_sec,
+                      (unsigned long) diff.tv_sec,
                       (unsigned long) (diff.tv_usec / USEC_PER_MSEC));
                break;
        case BENCH_FORMAT_SIMPLE:
-               printf("%lu.%03lu\n", diff.tv_sec,
+               printf("%lu.%03lu\n", (unsigned long) diff.tv_sec,
                       (unsigned long) (diff.tv_usec / USEC_PER_MSEC));
                break;
        default:
index 3c88d1f201f1cf81393edf432c90024f8bbe02d2..a960e7a93aecf1d6c0930be1ba0f28dc00103788 100644 (file)
@@ -156,7 +156,7 @@ int bench_sched_pipe(int argc, const char **argv)
                result_usec += diff.tv_usec;
 
                printf(" %14s: %lu.%03lu [sec]\n\n", "Total time",
-                      diff.tv_sec,
+                      (unsigned long) diff.tv_sec,
                       (unsigned long) (diff.tv_usec / USEC_PER_MSEC));
 
                printf(" %14lf usecs/op\n",
@@ -168,7 +168,7 @@ int bench_sched_pipe(int argc, const char **argv)
 
        case BENCH_FORMAT_SIMPLE:
                printf("%lu.%03lu\n",
-                      diff.tv_sec,
+                      (unsigned long) diff.tv_sec,
                       (unsigned long) (diff.tv_usec / USEC_PER_MSEC));
                break;
 
index 5fe621cff8e9330f1fb1dc46d4c4c6edbcac2e4f..9b751016f4b65560ad128153b9e6e1c05590e89f 100644 (file)
@@ -54,7 +54,7 @@ int bench_syscall_basic(int argc, const char **argv)
                result_usec += diff.tv_usec;
 
                printf(" %14s: %lu.%03lu [sec]\n\n", "Total time",
-                      diff.tv_sec,
+                      (unsigned long) diff.tv_sec,
                       (unsigned long) (diff.tv_usec/1000));
 
                printf(" %14lf usecs/op\n",
@@ -66,7 +66,7 @@ int bench_syscall_basic(int argc, const char **argv)
 
        case BENCH_FORMAT_SIMPLE:
                printf("%lu.%03lu\n",
-                      diff.tv_sec,
+                      (unsigned long) diff.tv_sec,
                       (unsigned long) (diff.tv_usec / 1000));
                break;
 
index 617feaf020f65db005da17732a00a1d8a2ae0832..ace8772a4f038d6b4f0730cd0d06d832f1d6c976 100644 (file)
@@ -161,7 +161,7 @@ static int session_config(struct daemon *daemon, const char *var, const char *va
        struct daemon_session *session;
        char name[100];
 
-       if (get_session_name(var, name, sizeof(name)))
+       if (get_session_name(var, name, sizeof(name) - 1))
                return -EINVAL;
 
        var = strchr(var, '.');
@@ -373,12 +373,12 @@ static int daemon_session__run(struct daemon_session *session,
        dup2(fd, 2);
        close(fd);
 
-       if (mkfifo(SESSION_CONTROL, O_RDWR) && errno != EEXIST) {
+       if (mkfifo(SESSION_CONTROL, 0600) && errno != EEXIST) {
                perror("failed: create control fifo");
                return -1;
        }
 
-       if (mkfifo(SESSION_ACK, O_RDWR) && errno != EEXIST) {
+       if (mkfifo(SESSION_ACK, 0600) && errno != EEXIST) {
                perror("failed: create ack fifo");
                return -1;
        }
index 8f6c784ce629c99efd3153f37c92fad7c32368f7..878e04b1fab746a234884a612080e53e5f6f8b5e 100644 (file)
@@ -1236,7 +1236,8 @@ static int __cmd_diff(void)
 
  out_delete:
        data__for_each_file(i, d) {
-               perf_session__delete(d->session);
+               if (!IS_ERR(d->session))
+                       perf_session__delete(d->session);
                data__free(d);
        }
 
index 85b6a46e85b686b99b2e7b99ba5e7a4de71b13d3..7ec18ff57fc4ae353eae76c8d53f26e68ea6b1c7 100644 (file)
@@ -3964,9 +3964,6 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
 
        evlist__config(evlist, &trace->opts, &callchain_param);
 
-       signal(SIGCHLD, sig_handler);
-       signal(SIGINT, sig_handler);
-
        if (forks) {
                err = evlist__prepare_workload(evlist, &trace->opts.target, argv, false, NULL);
                if (err < 0) {
@@ -4827,6 +4824,8 @@ int cmd_trace(int argc, const char **argv)
 
        signal(SIGSEGV, sighandler_dump_stack);
        signal(SIGFPE, sighandler_dump_stack);
+       signal(SIGCHLD, sig_handler);
+       signal(SIGINT, sig_handler);
 
        trace.evlist = evlist__new();
        trace.sctbl = syscalltbl__new();
index 0cfb3e2cefef48bd630f0463469738f0c72692cc..133f0eddbcc4604e6731cd53aa62979398f36bd9 100644 (file)
@@ -20,9 +20,8 @@ else
 fi
 
 BUILDIDS=$(mktemp /tmp/perf-archive-buildids.XXXXXX)
-NOBUILDID=0000000000000000000000000000000000000000
 
-perf buildid-list -i $PERF_DATA --with-hits | grep -v "^$NOBUILDID " > $BUILDIDS
+perf buildid-list -i $PERF_DATA --with-hits | grep -v "^ " > $BUILDIDS
 if [ ! -s $BUILDIDS ] ; then
        echo "perf archive: no build-ids found"
        rm $BUILDIDS || true
index ec972e0892abe38d7cb9f112944b9f8b39d1177e..dd39ce9b027789ef1028eb76b0629ff08a8b6ab7 100644 (file)
@@ -182,14 +182,20 @@ int test__attr(struct test *test __maybe_unused, int subtest __maybe_unused)
        struct stat st;
        char path_perf[PATH_MAX];
        char path_dir[PATH_MAX];
+       char *exec_path;
 
        /* First try development tree tests. */
        if (!lstat("./tests", &st))
                return run_dir("./tests", "./perf");
 
+       exec_path = get_argv_exec_path();
+       if (exec_path == NULL)
+               return -1;
+
        /* Then installed path. */
-       snprintf(path_dir,  PATH_MAX, "%s/tests", get_argv_exec_path());
+       snprintf(path_dir,  PATH_MAX, "%s/tests", exec_path);
        snprintf(path_perf, PATH_MAX, "%s/perf", BINDIR);
+       free(exec_path);
 
        if (!lstat(path_dir, &st) &&
            !lstat(path_perf, &st))
index 280f0348a09c0ba01d164057e9b84bf36cd5658b..2fdc7b2f996ed5eefa6d1f186dc01edfa84a8755 100644 (file)
@@ -706,13 +706,9 @@ static int do_test_code_reading(bool try_kcore)
 out_put:
        thread__put(thread);
 out_err:
-
-       if (evlist) {
-               evlist__delete(evlist);
-       } else {
-               perf_cpu_map__put(cpus);
-               perf_thread_map__put(threads);
-       }
+       evlist__delete(evlist);
+       perf_cpu_map__put(cpus);
+       perf_thread_map__put(threads);
        machine__delete_threads(machine);
        machine__delete(machine);
 
index 29c793ac7d108baef49b2c2d1738f8272997adf9..0472b110fe651ffe1da7c0e7aec71bb6128f0439 100644 (file)
@@ -106,6 +106,8 @@ static int cpu_map_print(const char *str)
                return -1;
 
        cpu_map__snprint(map, buf, sizeof(buf));
+       perf_cpu_map__put(map);
+
        return !strcmp(buf, str);
 }
 
index e6f1b2a38e03222be1ef4836b26929b436b1d1a8..a0438b0f080526d4b6f4e8713aa14d35b987418d 100644 (file)
@@ -154,10 +154,9 @@ out_err:
        if (evlist) {
                evlist__disable(evlist);
                evlist__delete(evlist);
-       } else {
-               perf_cpu_map__put(cpus);
-               perf_thread_map__put(threads);
        }
+       perf_cpu_map__put(cpus);
+       perf_thread_map__put(threads);
 
        return err;
 }
index 57093aeacc6f4688a2cd90e04146e44a848254b3..73ae8f7aa0660eae32bfba5a0d81ac871a1b68aa 100644 (file)
@@ -158,8 +158,6 @@ out_init:
 
 out_delete_evlist:
        evlist__delete(evlist);
-       cpus    = NULL;
-       threads = NULL;
 out_free_cpus:
        perf_cpu_map__put(cpus);
 out_free_threads:
index 7cff02664d0e631196faf43bb9047b3640efe1a5..680c3cffb1286aa96c8a681bb340cc62980dd4f3 100644 (file)
@@ -167,6 +167,8 @@ next_event:
 
 out_err:
        evlist__delete(evlist);
+       perf_cpu_map__put(cpus);
+       perf_thread_map__put(threads);
        return err;
 }
 
index 0dbe3aa9985362d8ccc9c84d97c2922fba9f2e46..8fd8a4ef97da1521f3441ead3f367b328bc815c1 100644 (file)
@@ -129,9 +129,6 @@ static bool samples_same(const struct perf_sample *s1,
        if (type & PERF_SAMPLE_WEIGHT)
                COMP(weight);
 
-       if (type & PERF_SAMPLE_WEIGHT_STRUCT)
-               COMP(ins_lat);
-
        if (type & PERF_SAMPLE_DATA_SRC)
                COMP(data_src);
 
@@ -245,7 +242,6 @@ static int do_test(u64 sample_type, u64 sample_regs, u64 read_format)
                .cgroup         = 114,
                .data_page_size = 115,
                .code_page_size = 116,
-               .ins_lat        = 117,
                .aux_sample     = {
                        .size   = sizeof(aux_data),
                        .data   = (void *)aux_data,
index e5b824dd08d9d0d2d0506d98abe52c90801dcb03..5ad3ca8d681b7d8a8d8156942c39dfe61d10836a 100755 (executable)
@@ -140,10 +140,10 @@ test_list()
 base=BASE
 
 [session-size]
-run = -e cpu-clock
+run = -e cpu-clock -m 1 sleep 10
 
 [session-time]
-run = -e task-clock
+run = -e task-clock -m 1 sleep 10
 EOF
 
        sed -i -e "s|BASE|${base}|" ${config}
@@ -159,14 +159,14 @@ EOF
        # check 1st session
        # pid:size:-e cpu-clock:base/size:base/size/output:base/size/control:base/size/ack:0
        local line=`perf daemon --config ${config} -x: | head -2 | tail -1`
-       check_line_other "${line}" size "-e cpu-clock" ${base}/session-size \
+       check_line_other "${line}" size "-e cpu-clock -m 1 sleep 10" ${base}/session-size \
                         ${base}/session-size/output ${base}/session-size/control \
                         ${base}/session-size/ack "0"
 
        # check 2nd session
        # pid:time:-e task-clock:base/time:base/time/output:base/time/control:base/time/ack:0
        local line=`perf daemon --config ${config} -x: | head -3 | tail -1`
-       check_line_other "${line}" time "-e task-clock" ${base}/session-time \
+       check_line_other "${line}" time "-e task-clock -m 1 sleep 10" ${base}/session-time \
                         ${base}/session-time/output ${base}/session-time/control \
                         ${base}/session-time/ack "0"
 
@@ -190,10 +190,10 @@ test_reconfig()
 base=BASE
 
 [session-size]
-run = -e cpu-clock
+run = -e cpu-clock -m 1 sleep 10
 
 [session-time]
-run = -e task-clock
+run = -e task-clock -m 1 sleep 10
 EOF
 
        sed -i -e "s|BASE|${base}|" ${config}
@@ -204,7 +204,7 @@ EOF
        # check 2nd session
        # pid:time:-e task-clock:base/time:base/time/output:base/time/control:base/time/ack:0
        local line=`perf daemon --config ${config} -x: | head -3 | tail -1`
-       check_line_other "${line}" time "-e task-clock" ${base}/session-time \
+       check_line_other "${line}" time "-e task-clock -m 1 sleep 10" ${base}/session-time \
                         ${base}/session-time/output ${base}/session-time/control ${base}/session-time/ack "0"
        local pid=`echo "${line}" | awk 'BEGIN { FS = ":" } ; { print $1 }'`
 
@@ -215,10 +215,10 @@ EOF
 base=BASE
 
 [session-size]
-run = -e cpu-clock
+run = -e cpu-clock -m 1 sleep 10
 
 [session-time]
-run = -e cpu-clock
+run = -e cpu-clock -m 1 sleep 10
 EOF
 
        # TEST 1 - change config
@@ -238,7 +238,7 @@ EOF
        # check reconfigured 2nd session
        # pid:time:-e task-clock:base/time:base/time/output:base/time/control:base/time/ack:0
        local line=`perf daemon --config ${config} -x: | head -3 | tail -1`
-       check_line_other "${line}" time "-e cpu-clock" ${base}/session-time \
+       check_line_other "${line}" time "-e cpu-clock -m 1 sleep 10" ${base}/session-time \
                         ${base}/session-time/output ${base}/session-time/control ${base}/session-time/ack "0"
 
        # TEST 2 - empty config
@@ -309,10 +309,10 @@ test_stop()
 base=BASE
 
 [session-size]
-run = -e cpu-clock
+run = -e cpu-clock -m 1 sleep 10
 
 [session-time]
-run = -e task-clock
+run = -e task-clock -m 1 sleep 10
 EOF
 
        sed -i -e "s|BASE|${base}|" ${config}
@@ -361,7 +361,7 @@ test_signal()
 base=BASE
 
 [session-test]
-run = -e cpu-clock --switch-output
+run = -e cpu-clock --switch-output -m 1 sleep 10
 EOF
 
        sed -i -e "s|BASE|${base}|" ${config}
@@ -400,10 +400,10 @@ test_ping()
 base=BASE
 
 [session-size]
-run = -e cpu-clock
+run = -e cpu-clock -m 1 sleep 10
 
 [session-time]
-run = -e task-clock
+run = -e task-clock -m 1 sleep 10
 EOF
 
        sed -i -e "s|BASE|${base}|" ${config}
@@ -439,7 +439,7 @@ test_lock()
 base=BASE
 
 [session-size]
-run = -e cpu-clock
+run = -e cpu-clock -m 1 sleep 10
 EOF
 
        sed -i -e "s|BASE|${base}|" ${config}
index a49c9e23053bd4bfe2e19ad7a1d1cfd3cb3d3da8..74988846be1da9ae2dae55873ae977376417c57f 100644 (file)
@@ -42,8 +42,8 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id)
                .disabled = 1,
                .freq = 1,
        };
-       struct perf_cpu_map *cpus;
-       struct perf_thread_map *threads;
+       struct perf_cpu_map *cpus = NULL;
+       struct perf_thread_map *threads = NULL;
        struct mmap *md;
 
        attr.sample_freq = 500;
@@ -66,14 +66,11 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id)
        if (!cpus || !threads) {
                err = -ENOMEM;
                pr_debug("Not enough memory to create thread/cpu maps\n");
-               goto out_free_maps;
+               goto out_delete_evlist;
        }
 
        perf_evlist__set_maps(&evlist->core, cpus, threads);
 
-       cpus    = NULL;
-       threads = NULL;
-
        if (evlist__open(evlist)) {
                const char *knob = "/proc/sys/kernel/perf_event_max_sample_rate";
 
@@ -129,10 +126,9 @@ out_init:
                err = -1;
        }
 
-out_free_maps:
+out_delete_evlist:
        perf_cpu_map__put(cpus);
        perf_thread_map__put(threads);
-out_delete_evlist:
        evlist__delete(evlist);
        return err;
 }
index 15a2ab765d8901baa4fda4587652d920589aadbd..3ebaa758df77e18ebd1b6ea0d8d80c88d74539cc 100644 (file)
@@ -574,10 +574,9 @@ out:
        if (evlist) {
                evlist__disable(evlist);
                evlist__delete(evlist);
-       } else {
-               perf_cpu_map__put(cpus);
-               perf_thread_map__put(threads);
        }
+       perf_cpu_map__put(cpus);
+       perf_thread_map__put(threads);
 
        return err;
 
index bbf94e4aa1450b50a8f76e48e8955b27c25f36b9..4c2969db59b0777a7117d2e29647082e2d9c0bec 100644 (file)
@@ -75,14 +75,11 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused
        if (!cpus || !threads) {
                err = -ENOMEM;
                pr_debug("Not enough memory to create thread/cpu maps\n");
-               goto out_free_maps;
+               goto out_delete_evlist;
        }
 
        perf_evlist__set_maps(&evlist->core, cpus, threads);
 
-       cpus    = NULL;
-       threads = NULL;
-
        err = evlist__prepare_workload(evlist, &target, argv, false, workload_exec_failed_signal);
        if (err < 0) {
                pr_debug("Couldn't run the workload!\n");
@@ -137,7 +134,7 @@ out_init:
                if (retry_count++ > 1000) {
                        pr_debug("Failed after retrying 1000 times\n");
                        err = -1;
-                       goto out_free_maps;
+                       goto out_delete_evlist;
                }
 
                goto retry;
@@ -148,10 +145,9 @@ out_init:
                err = -1;
        }
 
-out_free_maps:
+out_delete_evlist:
        perf_cpu_map__put(cpus);
        perf_thread_map__put(threads);
-out_delete_evlist:
        evlist__delete(evlist);
        return err;
 }
index 28f51c4bd373c3d0de18e271c5266174594c0e0a..d1e208b4a571c939a0cf241b41dfa15eefddfcf0 100644 (file)
@@ -102,6 +102,7 @@ int test__thread_map_synthesize(struct test *test __maybe_unused, int subtest __
        TEST_ASSERT_VAL("failed to synthesize map",
                !perf_event__synthesize_thread_map2(NULL, threads, process_event, NULL));
 
+       perf_thread_map__put(threads);
        return 0;
 }
 
@@ -109,12 +110,12 @@ int test__thread_map_remove(struct test *test __maybe_unused, int subtest __mayb
 {
        struct perf_thread_map *threads;
        char *str;
-       int i;
 
        TEST_ASSERT_VAL("failed to allocate map string",
                        asprintf(&str, "%d,%d", getpid(), getppid()) >= 0);
 
        threads = thread_map__new_str(str, NULL, 0, false);
+       free(str);
 
        TEST_ASSERT_VAL("failed to allocate thread_map",
                        threads);
@@ -141,9 +142,6 @@ int test__thread_map_remove(struct test *test __maybe_unused, int subtest __mayb
        TEST_ASSERT_VAL("failed to not remove thread",
                        thread_map__remove(threads, 0));
 
-       for (i = 0; i < threads->nr; i++)
-               zfree(&threads->map[i].comm);
-
-       free(threads);
+       perf_thread_map__put(threads);
        return 0;
 }
index 5121b4db66fe5d58abc48aab2b2a025240a8eb51..882cd1f721d958aa607793d79c70ecdbe33955a2 100644 (file)
@@ -1306,6 +1306,7 @@ void evlist__close(struct evlist *evlist)
                perf_evsel__free_fd(&evsel->core);
                perf_evsel__free_id(&evsel->core);
        }
+       perf_evlist__reset_id_hash(&evlist->core);
 }
 
 static int evlist__create_syswide_maps(struct evlist *evlist)
index 1bf76864c4f26cc61036b5c0f57eda2fd42b5ede..7ecbc8e2fbfa8ec576c9366618881e286b2d7f64 100644 (file)
@@ -46,6 +46,7 @@
 #include "string2.h"
 #include "memswap.h"
 #include "util.h"
+#include "hashmap.h"
 #include "../perf-sys.h"
 #include "util/parse-branch-options.h"
 #include <internal/xyarray.h>
@@ -1390,7 +1391,9 @@ void evsel__exit(struct evsel *evsel)
        zfree(&evsel->group_name);
        zfree(&evsel->name);
        zfree(&evsel->pmu_name);
-       zfree(&evsel->per_pkg_mask);
+       evsel__zero_per_pkg(evsel);
+       hashmap__free(evsel->per_pkg_mask);
+       evsel->per_pkg_mask = NULL;
        zfree(&evsel->metric_events);
        perf_evsel__object.fini(evsel);
 }
@@ -2781,3 +2784,16 @@ int evsel__store_ids(struct evsel *evsel, struct evlist *evlist)
 
        return store_evsel_ids(evsel, evlist);
 }
+
+void evsel__zero_per_pkg(struct evsel *evsel)
+{
+       struct hashmap_entry *cur;
+       size_t bkt;
+
+       if (evsel->per_pkg_mask) {
+               hashmap__for_each_entry(evsel->per_pkg_mask, cur, bkt)
+                       free((char *)cur->key);
+
+               hashmap__clear(evsel->per_pkg_mask);
+       }
+}
index 4e8e49fb7e9de5f3a742e1ddf2743b95cd2ea0c7..6026487353dd834851061d74343ad2883873369b 100644 (file)
@@ -19,6 +19,7 @@ struct perf_stat_evsel;
 union perf_event;
 struct bpf_counter_ops;
 struct target;
+struct hashmap;
 
 typedef int (evsel__sb_cb_t)(union perf_event *event, void *data);
 
@@ -112,7 +113,7 @@ struct evsel {
        bool                    merged_stat;
        bool                    reset_group;
        bool                    errored;
-       unsigned long           *per_pkg_mask;
+       struct hashmap          *per_pkg_mask;
        struct evsel            *leader;
        struct list_head        config_terms;
        int                     err;
@@ -433,4 +434,5 @@ struct perf_env *evsel__env(struct evsel *evsel);
 
 int evsel__store_ids(struct evsel *evsel, struct evlist *evlist);
 
+void evsel__zero_per_pkg(struct evsel *evsel);
 #endif /* __PERF_EVSEL_H */
index 4fe9e2a54346e51fca8ad6b4f0b4396b6af966cf..20effdff76ceb6afc90ffb4f4796ccd7af97412a 100644 (file)
@@ -1618,8 +1618,8 @@ static void print_clock_data(struct feat_fd *ff, FILE *fp)
 
        fprintf(fp, "# clockid: %s (%u)\n", clockid_name(clockid), clockid);
        fprintf(fp, "# reference time: %s = %ld.%06d (TOD) = %ld.%09ld (%s)\n",
-                   tstr, tod_ns.tv_sec, (int) tod_ns.tv_usec,
-                   clockid_ns.tv_sec, clockid_ns.tv_nsec,
+                   tstr, (long) tod_ns.tv_sec, (int) tod_ns.tv_usec,
+                   (long) clockid_ns.tv_sec, clockid_ns.tv_nsec,
                    clockid_name(clockid));
 }
 
index 692e56dc832e78b0079b18e6bd5c1fd7b1753246..fbc40a2c17d4dca0658b9b0c129eb4253e64a2bc 100644 (file)
@@ -77,8 +77,7 @@ static inline bool replace_android_lib(const char *filename, char *newfilename)
        if (strstarts(filename, "/system/lib/")) {
                char *ndk, *app;
                const char *arch;
-               size_t ndk_length;
-               size_t app_length;
+               int ndk_length, app_length;
 
                ndk = getenv("NDK_ROOT");
                app = getenv("APP_PLATFORM");
@@ -106,8 +105,8 @@ static inline bool replace_android_lib(const char *filename, char *newfilename)
                if (new_length > PATH_MAX)
                        return false;
                snprintf(newfilename, new_length,
-                       "%s/platforms/%s/arch-%s/usr/lib/%s",
-                       ndk, app, arch, libname);
+                       "%.*s/platforms/%.*s/arch-%s/usr/lib/%s",
+                       ndk_length, ndk, app_length, app, arch, libname);
 
                return true;
        }
index d5b6aff82f21704d06c71def88677a27faa0dff3..d57ac86ce7ca2e3b04f8b4107e2709279cb07af9 100644 (file)
@@ -89,6 +89,7 @@ static void inc_group_count(struct list_head *list,
 %type <str> PE_EVENT_NAME
 %type <str> PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_KERNEL_PMU_EVENT PE_PMU_EVENT_FAKE
 %type <str> PE_DRV_CFG_TERM
+%type <str> event_pmu_name
 %destructor { free ($$); } <str>
 %type <term> event_term
 %destructor { parse_events_term__delete ($$); } <term>
@@ -272,8 +273,11 @@ event_def: event_pmu |
           event_legacy_raw sep_dc |
           event_bpf_file
 
+event_pmu_name:
+PE_NAME | PE_PMU_EVENT_PRE
+
 event_pmu:
-PE_NAME opt_pmu_config
+event_pmu_name opt_pmu_config
 {
        struct parse_events_state *parse_state = _parse_state;
        struct parse_events_error *error = parse_state->error;
index 71b753523fac0f6791a0076d1311e6b91281960b..845dd46e3c6186a34ed6a0b4a2910cbbaba9d692 100644 (file)
@@ -36,3 +36,4 @@ util/symbol_fprintf.c
 util/units.c
 util/affinity.c
 util/rwsem.c
+util/hashmap.c
index 0d5ad42812b9d784cb6b67a17f632df9e76c9281..552b590485bf1008082193824579c72a92cbb981 100644 (file)
@@ -3140,7 +3140,7 @@ int output_field_add(struct perf_hpp_list *list, char *tok)
                if (strncasecmp(tok, sd->name, strlen(tok)))
                        continue;
 
-               if (sort__mode != SORT_MODE__MEMORY)
+               if (sort__mode != SORT_MODE__BRANCH)
                        return -EINVAL;
 
                return __sort_dimension__add_output(list, sd);
@@ -3152,7 +3152,7 @@ int output_field_add(struct perf_hpp_list *list, char *tok)
                if (strncasecmp(tok, sd->name, strlen(tok)))
                        continue;
 
-               if (sort__mode != SORT_MODE__BRANCH)
+               if (sort__mode != SORT_MODE__MEMORY)
                        return -EINVAL;
 
                return __sort_dimension__add_output(list, sd);
index cce7a76d6473c380dcbc544b120f57f48159c9ad..7f09cdaf5b6002350937f09c17dec329864514d0 100644 (file)
@@ -983,7 +983,7 @@ static void print_interval(struct perf_stat_config *config,
        if (config->interval_clear)
                puts(CONSOLE_CLEAR);
 
-       sprintf(prefix, "%6lu.%09lu%s", ts->tv_sec, ts->tv_nsec, config->csv_sep);
+       sprintf(prefix, "%6lu.%09lu%s", (unsigned long) ts->tv_sec, ts->tv_nsec, config->csv_sep);
 
        if ((num_print_interval == 0 && !config->csv_output) || config->interval_clear) {
                switch (config->aggr_mode) {
index 5d8af29447f44b959d75b06acd09a2e1aa62c796..c400f8dde017b0b9fc14dddce4fad25d8b787862 100644 (file)
@@ -13,6 +13,7 @@
 #include "evlist.h"
 #include "evsel.h"
 #include "thread_map.h"
+#include "hashmap.h"
 #include <linux/zalloc.h>
 
 void update_stats(struct stats *stats, u64 val)
@@ -277,18 +278,29 @@ void evlist__save_aggr_prev_raw_counts(struct evlist *evlist)
        }
 }
 
-static void zero_per_pkg(struct evsel *counter)
+static size_t pkg_id_hash(const void *__key, void *ctx __maybe_unused)
 {
-       if (counter->per_pkg_mask)
-               memset(counter->per_pkg_mask, 0, cpu__max_cpu());
+       uint64_t *key = (uint64_t *) __key;
+
+       return *key & 0xffffffff;
+}
+
+static bool pkg_id_equal(const void *__key1, const void *__key2,
+                        void *ctx __maybe_unused)
+{
+       uint64_t *key1 = (uint64_t *) __key1;
+       uint64_t *key2 = (uint64_t *) __key2;
+
+       return *key1 == *key2;
 }
 
 static int check_per_pkg(struct evsel *counter,
                         struct perf_counts_values *vals, int cpu, bool *skip)
 {
-       unsigned long *mask = counter->per_pkg_mask;
+       struct hashmap *mask = counter->per_pkg_mask;
        struct perf_cpu_map *cpus = evsel__cpus(counter);
-       int s;
+       int s, d, ret = 0;
+       uint64_t *key;
 
        *skip = false;
 
@@ -299,7 +311,7 @@ static int check_per_pkg(struct evsel *counter,
                return 0;
 
        if (!mask) {
-               mask = zalloc(cpu__max_cpu());
+               mask = hashmap__new(pkg_id_hash, pkg_id_equal, NULL);
                if (!mask)
                        return -ENOMEM;
 
@@ -321,8 +333,25 @@ static int check_per_pkg(struct evsel *counter,
        if (s < 0)
                return -1;
 
-       *skip = test_and_set_bit(s, mask) == 1;
-       return 0;
+       /*
+        * On multi-die system, die_id > 0. On no-die system, die_id = 0.
+        * We use hashmap(socket, die) to check the used socket+die pair.
+        */
+       d = cpu_map__get_die(cpus, cpu, NULL).die;
+       if (d < 0)
+               return -1;
+
+       key = malloc(sizeof(*key));
+       if (!key)
+               return -ENOMEM;
+
+       *key = (uint64_t)d << 32 | s;
+       if (hashmap__find(mask, (void *)key, NULL))
+               *skip = true;
+       else
+               ret = hashmap__add(mask, (void *)key, (void *)1);
+
+       return ret;
 }
 
 static int
@@ -422,7 +451,7 @@ int perf_stat_process_counter(struct perf_stat_config *config,
        }
 
        if (counter->per_pkg)
-               zero_per_pkg(counter);
+               evsel__zero_per_pkg(counter);
 
        ret = process_counter_maps(config, counter);
        if (ret)
index f507dff713c9f8e55df4a233517ce531132a239f..8a01af783310a580d2c0f5e3fb11eee57850d993 100644 (file)
@@ -361,6 +361,7 @@ static int read_saved_cmdline(struct tep_handle *pevent)
                pr_debug("error reading saved cmdlines\n");
                goto out;
        }
+       buf[ret] = '\0';
 
        parse_saved_cmdline(pevent, buf, size);
        ret = 0;
index b2282be6f9384cb193e6ed9f54b75c3b6e5d1e75..612d3899614ac6be12c02696c204fe3a4252b96a 100644 (file)
@@ -332,5 +332,5 @@ int main(void)
 
        ksft_print_cnts();
 
-       return 0;
+       return ret;
 }
index 6b670039ea6799d7026ec3896b90a211a6405ffb..1d8918dfbd3ff541b5abaf51b4bb9e6106e924f2 100644 (file)
@@ -16,6 +16,13 @@ bool skip = false;
 #define STRSIZE                        2048
 #define EXPECTED_STRSIZE       256
 
+#if defined(bpf_target_s390)
+/* NULL points to a readable struct lowcore on s390, so take the last page */
+#define BADPTR                 ((void *)0xFFFFFFFFFFFFF000ULL)
+#else
+#define BADPTR                 0
+#endif
+
 #ifndef ARRAY_SIZE
 #define ARRAY_SIZE(x)  (sizeof(x) / sizeof((x)[0]))
 #endif
@@ -113,11 +120,11 @@ int BPF_PROG(trace_netif_receive_skb, struct sk_buff *skb)
        }
 
        /* Check invalid ptr value */
-       p.ptr = 0;
+       p.ptr = BADPTR;
        __ret = bpf_snprintf_btf(str, STRSIZE, &p, sizeof(p), 0);
        if (__ret >= 0) {
-               bpf_printk("printing NULL should generate error, got (%d)",
-                          __ret);
+               bpf_printk("printing %llx should generate error, got (%d)",
+                          (unsigned long long)BADPTR, __ret);
                ret = -ERANGE;
        }
 
index 28488047c84913fd992e781b6fbe05b2e724c26d..ef5277d982d92148a4b10d1819471fdd773f8587 100644 (file)
@@ -15,5 +15,5 @@ __noinline int foo(const struct S *s)
 SEC("cgroup_skb/ingress")
 int test_cls(struct __sk_buff *skb)
 {
-       return foo(skb);
+       return foo((const void *)skb);
 }
index a621b58ab079d57467da21da5947b9246847eba3..9afe947cfae95302937b36264791475acce22fc3 100644 (file)
@@ -446,10 +446,8 @@ int _geneve_get_tunnel(struct __sk_buff *skb)
        }
 
        ret = bpf_skb_get_tunnel_opt(skb, &gopt, sizeof(gopt));
-       if (ret < 0) {
-               ERROR(ret);
-               return TC_ACT_SHOT;
-       }
+       if (ret < 0)
+               gopt.opt_class = 0;
 
        bpf_trace_printk(fmt, sizeof(fmt),
                        key.tunnel_id, key.remote_ipv4, gopt.opt_class);
index bed53b561e0443328c0a82015c38abc56015650a..1b138cd2b187d982428092dfd7217d9f32b2f385 100644 (file)
        BPF_MOV64_IMM(BPF_REG_5, 0),
        BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
                     BPF_FUNC_csum_diff),
+       BPF_ALU64_IMM(BPF_AND, BPF_REG_0, 0xffff),
        BPF_EXIT_INSN(),
        },
        .prog_type = BPF_PROG_TYPE_SCHED_CLS,
        .fixup_map_array_ro = { 3 },
        .result = ACCEPT,
-       .retval = -29,
+       .retval = 65507,
 },
 {
        "invalid write map access into a read-only array 1",
index 1bdc8e6684f7c2d314d894dee82b3d0aaf1e2e5a..fe4bb70eb9c572f970c917e4e798244eebb20499 100644 (file)
        },
        .result = ACCEPT,
 },
+{
+       "BPF_ATOMIC_AND with fetch - r0 as source reg",
+       .insns = {
+               /* val = 0x110; */
+               BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0x110),
+               /* old = atomic_fetch_and(&val, 0x011); */
+               BPF_MOV64_IMM(BPF_REG_0, 0x011),
+               BPF_ATOMIC_OP(BPF_DW, BPF_AND | BPF_FETCH, BPF_REG_10, BPF_REG_0, -8),
+               /* if (old != 0x110) exit(3); */
+               BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0x110, 2),
+               BPF_MOV64_IMM(BPF_REG_0, 3),
+               BPF_EXIT_INSN(),
+               /* if (val != 0x010) exit(2); */
+               BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -8),
+               BPF_JMP_IMM(BPF_JEQ, BPF_REG_1, 0x010, 2),
+               BPF_MOV64_IMM(BPF_REG_1, 2),
+               BPF_EXIT_INSN(),
+               /* exit(0); */
+               BPF_MOV64_IMM(BPF_REG_0, 0),
+               BPF_EXIT_INSN(),
+       },
+       .result = ACCEPT,
+},
index 2efd8bcf57a1e4c514afa4aad30b5b95422da30b..6e52dfc644153f08af2587ed27eda74fa66bfa5c 100644 (file)
        .result = REJECT,
        .errstr = "invalid read from stack",
 },
+{
+       "BPF_W cmpxchg should zero top 32 bits",
+       .insns = {
+               /* r0 = U64_MAX; */
+               BPF_MOV64_IMM(BPF_REG_0, 0),
+               BPF_ALU64_IMM(BPF_SUB, BPF_REG_0, 1),
+               /* u64 val = r0; */
+               BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_0, -8),
+               /* r0 = (u32)atomic_cmpxchg((u32 *)&val, r0, 1); */
+               BPF_MOV32_IMM(BPF_REG_1, 1),
+               BPF_ATOMIC_OP(BPF_W, BPF_CMPXCHG, BPF_REG_10, BPF_REG_1, -8),
+               /* r1 = 0x00000000FFFFFFFFull; */
+               BPF_MOV64_IMM(BPF_REG_1, 1),
+               BPF_ALU64_IMM(BPF_LSH, BPF_REG_1, 32),
+               BPF_ALU64_IMM(BPF_SUB, BPF_REG_1, 1),
+               /* if (r0 != r1) exit(1); */
+               BPF_JMP_REG(BPF_JEQ, BPF_REG_0, BPF_REG_1, 2),
+               BPF_MOV32_IMM(BPF_REG_0, 1),
+               BPF_EXIT_INSN(),
+               /* exit(0); */
+               BPF_MOV32_IMM(BPF_REG_0, 0),
+               BPF_EXIT_INSN(),
+       },
+       .result = ACCEPT,
+},
index 70f982e1f9f05fc41c9da5f887d26f05df6e742b..9d0716ac508080a86db2109a96cbfd9ac2707055 100644 (file)
        },
        .result = ACCEPT,
 },
+{
+       "BPF_W atomic_fetch_or should zero top 32 bits",
+       .insns = {
+               /* r1 = U64_MAX; */
+               BPF_MOV64_IMM(BPF_REG_1, 0),
+               BPF_ALU64_IMM(BPF_SUB, BPF_REG_1, 1),
+               /* u64 val = r1; */
+               BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_1, -8),
+               /* r1 = (u32)atomic_fetch_or((u32 *)&val, 2); */
+               BPF_MOV32_IMM(BPF_REG_1, 2),
+               BPF_ATOMIC_OP(BPF_W, BPF_OR | BPF_FETCH, BPF_REG_10, BPF_REG_1, -8),
+               /* r2 = 0x00000000FFFFFFFF; */
+               BPF_MOV64_IMM(BPF_REG_2, 1),
+               BPF_ALU64_IMM(BPF_LSH, BPF_REG_2, 32),
+               BPF_ALU64_IMM(BPF_SUB, BPF_REG_2, 1),
+               /* if (r2 != r1) exit(1); */
+               BPF_JMP_REG(BPF_JEQ, BPF_REG_2, BPF_REG_1, 2),
+               BPF_MOV64_REG(BPF_REG_0, BPF_REG_1),
+               BPF_EXIT_INSN(),
+               /* exit(0); */
+               BPF_MOV32_IMM(BPF_REG_0, 0),
+               BPF_EXIT_INSN(),
+       },
+       .result = ACCEPT,
+},
index 4c69408f3e84004a5282349017463988fe92ae5b..a4969f7ee020d51f1f243808c3155667cbecf06d 100644 (file)
@@ -1,2 +1,2 @@
 # SPDX-License-Identifier: GPL-2.0-only
-gpio-mockup-chardev
+gpio-mockup-cdev
index 32b87cc77c8e05b0b2646a4af462875017b2ed20..7bd7e776c266a6f90dc5fa49a31d9f4c604b693d 100644 (file)
@@ -8,10 +8,13 @@
 /x86_64/debug_regs
 /x86_64/evmcs_test
 /x86_64/get_cpuid_test
+/x86_64/get_msr_index_features
 /x86_64/kvm_pv_test
+/x86_64/hyperv_clock
 /x86_64/hyperv_cpuid
 /x86_64/mmio_warning_test
 /x86_64/platform_info_test
+/x86_64/set_boot_cpu_id
 /x86_64/set_sregs_test
 /x86_64/smm_test
 /x86_64/state_test
index a6d61f451f884048e5b4af5418c008ca00dcf7b8..67eebb53235fdb3a6b6a00fac3a698c494f3c73e 100644 (file)
@@ -39,12 +39,15 @@ LIBKVM_aarch64 = lib/aarch64/processor.c lib/aarch64/ucall.c
 LIBKVM_s390x = lib/s390x/processor.c lib/s390x/ucall.c lib/s390x/diag318_test_handler.c
 
 TEST_GEN_PROGS_x86_64 = x86_64/cr4_cpuid_sync_test
+TEST_GEN_PROGS_x86_64 += x86_64/get_msr_index_features
 TEST_GEN_PROGS_x86_64 += x86_64/evmcs_test
 TEST_GEN_PROGS_x86_64 += x86_64/get_cpuid_test
+TEST_GEN_PROGS_x86_64 += x86_64/hyperv_clock
 TEST_GEN_PROGS_x86_64 += x86_64/hyperv_cpuid
 TEST_GEN_PROGS_x86_64 += x86_64/kvm_pv_test
 TEST_GEN_PROGS_x86_64 += x86_64/mmio_warning_test
 TEST_GEN_PROGS_x86_64 += x86_64/platform_info_test
+TEST_GEN_PROGS_x86_64 += x86_64/set_boot_cpu_id
 TEST_GEN_PROGS_x86_64 += x86_64/set_sregs_test
 TEST_GEN_PROGS_x86_64 += x86_64/smm_test
 TEST_GEN_PROGS_x86_64 += x86_64/state_test
index 2d7eb6989e834b854b5a4a69623e9d9f4983638f..0f4258eaa629e029a4b550e875da8cd3e9535fe7 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "sparsebit.h"
 
+#define KVM_DEV_PATH "/dev/kvm"
 #define KVM_MAX_VCPUS 512
 
 /*
@@ -133,6 +134,7 @@ void vcpu_ioctl(struct kvm_vm *vm, uint32_t vcpuid, unsigned long ioctl,
 int _vcpu_ioctl(struct kvm_vm *vm, uint32_t vcpuid, unsigned long ioctl,
                void *arg);
 void vm_ioctl(struct kvm_vm *vm, unsigned long ioctl, void *arg);
+int _vm_ioctl(struct kvm_vm *vm, unsigned long cmd, void *arg);
 void kvm_ioctl(struct kvm_vm *vm, unsigned long ioctl, void *arg);
 int _kvm_ioctl(struct kvm_vm *vm, unsigned long ioctl, void *arg);
 void vm_mem_region_set_flags(struct kvm_vm *vm, uint32_t slot, uint32_t flags);
index e5fbf16f725b5c01f7585f8dad952499fe0bbabf..b8849a1aca79233496b52b24e86b9cfd30b913e8 100644 (file)
@@ -1697,11 +1697,16 @@ void vm_ioctl(struct kvm_vm *vm, unsigned long cmd, void *arg)
 {
        int ret;
 
-       ret = ioctl(vm->fd, cmd, arg);
+       ret = _vm_ioctl(vm, cmd, arg);
        TEST_ASSERT(ret == 0, "vm ioctl %lu failed, rc: %i errno: %i (%s)",
                cmd, ret, errno, strerror(errno));
 }
 
+int _vm_ioctl(struct kvm_vm *vm, unsigned long cmd, void *arg)
+{
+       return ioctl(vm->fd, cmd, arg);
+}
+
 /*
  * KVM system ioctl
  *
index 34465dc562d8cf809890f0a2060ba5fe282a32d7..91ce1b5d480b2d8b0987851f8864b930d27a6ff6 100644 (file)
@@ -10,8 +10,6 @@
 
 #include "sparsebit.h"
 
-#define KVM_DEV_PATH           "/dev/kvm"
-
 struct userspace_mem_region {
        struct kvm_userspace_memory_region region;
        struct sparsebit *unused_phy_pages;
diff --git a/tools/testing/selftests/kvm/x86_64/get_msr_index_features.c b/tools/testing/selftests/kvm/x86_64/get_msr_index_features.c
new file mode 100644 (file)
index 0000000..cb953df
--- /dev/null
@@ -0,0 +1,134 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Test that KVM_GET_MSR_INDEX_LIST and
+ * KVM_GET_MSR_FEATURE_INDEX_LIST work as intended
+ *
+ * Copyright (C) 2020, Red Hat, Inc.
+ */
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+
+#include "test_util.h"
+#include "kvm_util.h"
+#include "processor.h"
+
+static int kvm_num_index_msrs(int kvm_fd, int nmsrs)
+{
+       struct kvm_msr_list *list;
+       int r;
+
+       list = malloc(sizeof(*list) + nmsrs * sizeof(list->indices[0]));
+       list->nmsrs = nmsrs;
+       r = ioctl(kvm_fd, KVM_GET_MSR_INDEX_LIST, list);
+       TEST_ASSERT(r == -1 && errno == E2BIG,
+                               "Unexpected result from KVM_GET_MSR_INDEX_LIST probe, r: %i",
+                               r);
+
+       r = list->nmsrs;
+       free(list);
+       return r;
+}
+
+static void test_get_msr_index(void)
+{
+       int old_res, res, kvm_fd, r;
+       struct kvm_msr_list *list;
+
+       kvm_fd = open(KVM_DEV_PATH, O_RDONLY);
+       if (kvm_fd < 0)
+               exit(KSFT_SKIP);
+
+       old_res = kvm_num_index_msrs(kvm_fd, 0);
+       TEST_ASSERT(old_res != 0, "Expecting nmsrs to be > 0");
+
+       if (old_res != 1) {
+               res = kvm_num_index_msrs(kvm_fd, 1);
+               TEST_ASSERT(res > 1, "Expecting nmsrs to be > 1");
+               TEST_ASSERT(res == old_res, "Expecting nmsrs to be identical");
+       }
+
+       list = malloc(sizeof(*list) + old_res * sizeof(list->indices[0]));
+       list->nmsrs = old_res;
+       r = ioctl(kvm_fd, KVM_GET_MSR_INDEX_LIST, list);
+
+       TEST_ASSERT(r == 0,
+                   "Unexpected result from KVM_GET_MSR_FEATURE_INDEX_LIST, r: %i",
+                   r);
+       TEST_ASSERT(list->nmsrs == old_res, "Expecting nmsrs to be identical");
+       free(list);
+
+       close(kvm_fd);
+}
+
+static int kvm_num_feature_msrs(int kvm_fd, int nmsrs)
+{
+       struct kvm_msr_list *list;
+       int r;
+
+       list = malloc(sizeof(*list) + nmsrs * sizeof(list->indices[0]));
+       list->nmsrs = nmsrs;
+       r = ioctl(kvm_fd, KVM_GET_MSR_FEATURE_INDEX_LIST, list);
+       TEST_ASSERT(r == -1 && errno == E2BIG,
+               "Unexpected result from KVM_GET_MSR_FEATURE_INDEX_LIST probe, r: %i",
+                               r);
+
+       r = list->nmsrs;
+       free(list);
+       return r;
+}
+
+struct kvm_msr_list *kvm_get_msr_feature_list(int kvm_fd, int nmsrs)
+{
+       struct kvm_msr_list *list;
+       int r;
+
+       list = malloc(sizeof(*list) + nmsrs * sizeof(list->indices[0]));
+       list->nmsrs = nmsrs;
+       r = ioctl(kvm_fd, KVM_GET_MSR_FEATURE_INDEX_LIST, list);
+
+       TEST_ASSERT(r == 0,
+               "Unexpected result from KVM_GET_MSR_FEATURE_INDEX_LIST, r: %i",
+               r);
+
+       return list;
+}
+
+static void test_get_msr_feature(void)
+{
+       int res, old_res, i, kvm_fd;
+       struct kvm_msr_list *feature_list;
+
+       kvm_fd = open(KVM_DEV_PATH, O_RDONLY);
+       if (kvm_fd < 0)
+               exit(KSFT_SKIP);
+
+       old_res = kvm_num_feature_msrs(kvm_fd, 0);
+       TEST_ASSERT(old_res != 0, "Expecting nmsrs to be > 0");
+
+       if (old_res != 1) {
+               res = kvm_num_feature_msrs(kvm_fd, 1);
+               TEST_ASSERT(res > 1, "Expecting nmsrs to be > 1");
+               TEST_ASSERT(res == old_res, "Expecting nmsrs to be identical");
+       }
+
+       feature_list = kvm_get_msr_feature_list(kvm_fd, old_res);
+       TEST_ASSERT(old_res == feature_list->nmsrs,
+                               "Unmatching number of msr indexes");
+
+       for (i = 0; i < feature_list->nmsrs; i++)
+               kvm_get_feature_msr(feature_list->indices[i]);
+
+       free(feature_list);
+       close(kvm_fd);
+}
+
+int main(int argc, char *argv[])
+{
+       if (kvm_check_cap(KVM_CAP_GET_MSR_FEATURES))
+               test_get_msr_feature();
+
+       test_get_msr_index();
+}
diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_clock.c b/tools/testing/selftests/kvm/x86_64/hyperv_clock.c
new file mode 100644 (file)
index 0000000..ffbc455
--- /dev/null
@@ -0,0 +1,260 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2021, Red Hat, Inc.
+ *
+ * Tests for Hyper-V clocksources
+ */
+#include "test_util.h"
+#include "kvm_util.h"
+#include "processor.h"
+
+struct ms_hyperv_tsc_page {
+       volatile u32 tsc_sequence;
+       u32 reserved1;
+       volatile u64 tsc_scale;
+       volatile s64 tsc_offset;
+} __packed;
+
+#define HV_X64_MSR_GUEST_OS_ID                 0x40000000
+#define HV_X64_MSR_TIME_REF_COUNT              0x40000020
+#define HV_X64_MSR_REFERENCE_TSC               0x40000021
+#define HV_X64_MSR_TSC_FREQUENCY               0x40000022
+#define HV_X64_MSR_REENLIGHTENMENT_CONTROL     0x40000106
+#define HV_X64_MSR_TSC_EMULATION_CONTROL       0x40000107
+
+/* Simplified mul_u64_u64_shr() */
+static inline u64 mul_u64_u64_shr64(u64 a, u64 b)
+{
+       union {
+               u64 ll;
+               struct {
+                       u32 low, high;
+               } l;
+       } rm, rn, rh, a0, b0;
+       u64 c;
+
+       a0.ll = a;
+       b0.ll = b;
+
+       rm.ll = (u64)a0.l.low * b0.l.high;
+       rn.ll = (u64)a0.l.high * b0.l.low;
+       rh.ll = (u64)a0.l.high * b0.l.high;
+
+       rh.l.low = c = rm.l.high + rn.l.high + rh.l.low;
+       rh.l.high = (c >> 32) + rh.l.high;
+
+       return rh.ll;
+}
+
+static inline void nop_loop(void)
+{
+       int i;
+
+       for (i = 0; i < 1000000; i++)
+               asm volatile("nop");
+}
+
+static inline void check_tsc_msr_rdtsc(void)
+{
+       u64 tsc_freq, r1, r2, t1, t2;
+       s64 delta_ns;
+
+       tsc_freq = rdmsr(HV_X64_MSR_TSC_FREQUENCY);
+       GUEST_ASSERT(tsc_freq > 0);
+
+       /* First, check MSR-based clocksource */
+       r1 = rdtsc();
+       t1 = rdmsr(HV_X64_MSR_TIME_REF_COUNT);
+       nop_loop();
+       r2 = rdtsc();
+       t2 = rdmsr(HV_X64_MSR_TIME_REF_COUNT);
+
+       GUEST_ASSERT(r2 > r1 && t2 > t1);
+
+       /* HV_X64_MSR_TIME_REF_COUNT is in 100ns */
+       delta_ns = ((t2 - t1) * 100) - ((r2 - r1) * 1000000000 / tsc_freq);
+       if (delta_ns < 0)
+               delta_ns = -delta_ns;
+
+       /* 1% tolerance */
+       GUEST_ASSERT(delta_ns * 100 < (t2 - t1) * 100);
+}
+
+static inline void check_tsc_msr_tsc_page(struct ms_hyperv_tsc_page *tsc_page)
+{
+       u64 r1, r2, t1, t2;
+
+       /* Compare TSC page clocksource with HV_X64_MSR_TIME_REF_COUNT */
+       t1 = mul_u64_u64_shr64(rdtsc(), tsc_page->tsc_scale) + tsc_page->tsc_offset;
+       r1 = rdmsr(HV_X64_MSR_TIME_REF_COUNT);
+
+       /* 10 ms tolerance */
+       GUEST_ASSERT(r1 >= t1 && r1 - t1 < 100000);
+       nop_loop();
+
+       t2 = mul_u64_u64_shr64(rdtsc(), tsc_page->tsc_scale) + tsc_page->tsc_offset;
+       r2 = rdmsr(HV_X64_MSR_TIME_REF_COUNT);
+       GUEST_ASSERT(r2 >= t1 && r2 - t2 < 100000);
+}
+
+static void guest_main(struct ms_hyperv_tsc_page *tsc_page, vm_paddr_t tsc_page_gpa)
+{
+       u64 tsc_scale, tsc_offset;
+
+       /* Set Guest OS id to enable Hyper-V emulation */
+       GUEST_SYNC(1);
+       wrmsr(HV_X64_MSR_GUEST_OS_ID, (u64)0x8100 << 48);
+       GUEST_SYNC(2);
+
+       check_tsc_msr_rdtsc();
+
+       GUEST_SYNC(3);
+
+       /* Set up TSC page is disabled state, check that it's clean */
+       wrmsr(HV_X64_MSR_REFERENCE_TSC, tsc_page_gpa);
+       GUEST_ASSERT(tsc_page->tsc_sequence == 0);
+       GUEST_ASSERT(tsc_page->tsc_scale == 0);
+       GUEST_ASSERT(tsc_page->tsc_offset == 0);
+
+       GUEST_SYNC(4);
+
+       /* Set up TSC page is enabled state */
+       wrmsr(HV_X64_MSR_REFERENCE_TSC, tsc_page_gpa | 0x1);
+       GUEST_ASSERT(tsc_page->tsc_sequence != 0);
+
+       GUEST_SYNC(5);
+
+       check_tsc_msr_tsc_page(tsc_page);
+
+       GUEST_SYNC(6);
+
+       tsc_offset = tsc_page->tsc_offset;
+       /* Call KVM_SET_CLOCK from userspace, check that TSC page was updated */
+       GUEST_SYNC(7);
+       GUEST_ASSERT(tsc_page->tsc_offset != tsc_offset);
+
+       nop_loop();
+
+       /*
+        * Enable Re-enlightenment and check that TSC page stays constant across
+        * KVM_SET_CLOCK.
+        */
+       wrmsr(HV_X64_MSR_REENLIGHTENMENT_CONTROL, 0x1 << 16 | 0xff);
+       wrmsr(HV_X64_MSR_TSC_EMULATION_CONTROL, 0x1);
+       tsc_offset = tsc_page->tsc_offset;
+       tsc_scale = tsc_page->tsc_scale;
+       GUEST_SYNC(8);
+       GUEST_ASSERT(tsc_page->tsc_offset == tsc_offset);
+       GUEST_ASSERT(tsc_page->tsc_scale == tsc_scale);
+
+       GUEST_SYNC(9);
+
+       check_tsc_msr_tsc_page(tsc_page);
+
+       /*
+        * Disable re-enlightenment and TSC page, check that KVM doesn't update
+        * it anymore.
+        */
+       wrmsr(HV_X64_MSR_REENLIGHTENMENT_CONTROL, 0);
+       wrmsr(HV_X64_MSR_TSC_EMULATION_CONTROL, 0);
+       wrmsr(HV_X64_MSR_REFERENCE_TSC, 0);
+       memset(tsc_page, 0, sizeof(*tsc_page));
+
+       GUEST_SYNC(10);
+       GUEST_ASSERT(tsc_page->tsc_sequence == 0);
+       GUEST_ASSERT(tsc_page->tsc_offset == 0);
+       GUEST_ASSERT(tsc_page->tsc_scale == 0);
+
+       GUEST_DONE();
+}
+
+#define VCPU_ID 0
+
+static void host_check_tsc_msr_rdtsc(struct kvm_vm *vm)
+{
+       u64 tsc_freq, r1, r2, t1, t2;
+       s64 delta_ns;
+
+       tsc_freq = vcpu_get_msr(vm, VCPU_ID, HV_X64_MSR_TSC_FREQUENCY);
+       TEST_ASSERT(tsc_freq > 0, "TSC frequency must be nonzero");
+
+       /* First, check MSR-based clocksource */
+       r1 = rdtsc();
+       t1 = vcpu_get_msr(vm, VCPU_ID, HV_X64_MSR_TIME_REF_COUNT);
+       nop_loop();
+       r2 = rdtsc();
+       t2 = vcpu_get_msr(vm, VCPU_ID, HV_X64_MSR_TIME_REF_COUNT);
+
+       TEST_ASSERT(t2 > t1, "Time reference MSR is not monotonic (%ld <= %ld)", t1, t2);
+
+       /* HV_X64_MSR_TIME_REF_COUNT is in 100ns */
+       delta_ns = ((t2 - t1) * 100) - ((r2 - r1) * 1000000000 / tsc_freq);
+       if (delta_ns < 0)
+               delta_ns = -delta_ns;
+
+       /* 1% tolerance */
+       TEST_ASSERT(delta_ns * 100 < (t2 - t1) * 100,
+                   "Elapsed time does not match (MSR=%ld, TSC=%ld)",
+                   (t2 - t1) * 100, (r2 - r1) * 1000000000 / tsc_freq);
+}
+
+int main(void)
+{
+       struct kvm_vm *vm;
+       struct kvm_run *run;
+       struct ucall uc;
+       vm_vaddr_t tsc_page_gva;
+       int stage;
+
+       vm = vm_create_default(VCPU_ID, 0, guest_main);
+       run = vcpu_state(vm, VCPU_ID);
+
+       vcpu_set_hv_cpuid(vm, VCPU_ID);
+
+       tsc_page_gva = vm_vaddr_alloc(vm, getpagesize(), 0x10000, 0, 0);
+       memset(addr_gpa2hva(vm, tsc_page_gva), 0x0, getpagesize());
+       TEST_ASSERT((addr_gva2gpa(vm, tsc_page_gva) & (getpagesize() - 1)) == 0,
+               "TSC page has to be page aligned\n");
+       vcpu_args_set(vm, VCPU_ID, 2, tsc_page_gva, addr_gva2gpa(vm, tsc_page_gva));
+
+       host_check_tsc_msr_rdtsc(vm);
+
+       for (stage = 1;; stage++) {
+               _vcpu_run(vm, VCPU_ID);
+               TEST_ASSERT(run->exit_reason == KVM_EXIT_IO,
+                           "Stage %d: unexpected exit reason: %u (%s),\n",
+                           stage, run->exit_reason,
+                           exit_reason_str(run->exit_reason));
+
+               switch (get_ucall(vm, VCPU_ID, &uc)) {
+               case UCALL_ABORT:
+                       TEST_FAIL("%s at %s:%ld", (const char *)uc.args[0],
+                                 __FILE__, uc.args[1]);
+                       /* NOT REACHED */
+               case UCALL_SYNC:
+                       break;
+               case UCALL_DONE:
+                       /* Keep in sync with guest_main() */
+                       TEST_ASSERT(stage == 11, "Testing ended prematurely, stage %d\n",
+                                   stage);
+                       goto out;
+               default:
+                       TEST_FAIL("Unknown ucall %lu", uc.cmd);
+               }
+
+               TEST_ASSERT(!strcmp((const char *)uc.args[0], "hello") &&
+                           uc.args[1] == stage,
+                           "Stage %d: Unexpected register values vmexit, got %lx",
+                           stage, (ulong)uc.args[1]);
+
+               /* Reset kvmclock triggering TSC page update */
+               if (stage == 7 || stage == 8 || stage == 10) {
+                       struct kvm_clock_data clock = {0};
+
+                       vm_ioctl(vm, KVM_SET_CLOCK, &clock);
+               }
+       }
+
+out:
+       kvm_vm_free(vm);
+}
diff --git a/tools/testing/selftests/kvm/x86_64/set_boot_cpu_id.c b/tools/testing/selftests/kvm/x86_64/set_boot_cpu_id.c
new file mode 100644 (file)
index 0000000..12c558f
--- /dev/null
@@ -0,0 +1,166 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Test that KVM_SET_BOOT_CPU_ID works as intended
+ *
+ * Copyright (C) 2020, Red Hat, Inc.
+ */
+#define _GNU_SOURCE /* for program_invocation_name */
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+
+#include "test_util.h"
+#include "kvm_util.h"
+#include "processor.h"
+
+#define N_VCPU 2
+#define VCPU_ID0 0
+#define VCPU_ID1 1
+
+static uint32_t get_bsp_flag(void)
+{
+       return rdmsr(MSR_IA32_APICBASE) & MSR_IA32_APICBASE_BSP;
+}
+
+static void guest_bsp_vcpu(void *arg)
+{
+       GUEST_SYNC(1);
+
+       GUEST_ASSERT(get_bsp_flag() != 0);
+
+       GUEST_DONE();
+}
+
+static void guest_not_bsp_vcpu(void *arg)
+{
+       GUEST_SYNC(1);
+
+       GUEST_ASSERT(get_bsp_flag() == 0);
+
+       GUEST_DONE();
+}
+
+static void test_set_boot_busy(struct kvm_vm *vm)
+{
+       int res;
+
+       res = _vm_ioctl(vm, KVM_SET_BOOT_CPU_ID, (void *) VCPU_ID0);
+       TEST_ASSERT(res == -1 && errno == EBUSY,
+                       "KVM_SET_BOOT_CPU_ID set while running vm");
+}
+
+static void run_vcpu(struct kvm_vm *vm, uint32_t vcpuid)
+{
+       struct ucall uc;
+       int stage;
+
+       for (stage = 0; stage < 2; stage++) {
+
+               vcpu_run(vm, vcpuid);
+
+               switch (get_ucall(vm, vcpuid, &uc)) {
+               case UCALL_SYNC:
+                       TEST_ASSERT(!strcmp((const char *)uc.args[0], "hello") &&
+                                       uc.args[1] == stage + 1,
+                                       "Stage %d: Unexpected register values vmexit, got %lx",
+                                       stage + 1, (ulong)uc.args[1]);
+                       test_set_boot_busy(vm);
+                       break;
+               case UCALL_DONE:
+                       TEST_ASSERT(stage == 1,
+                                       "Expected GUEST_DONE in stage 2, got stage %d",
+                                       stage);
+                       break;
+               case UCALL_ABORT:
+                       TEST_ASSERT(false, "%s at %s:%ld\n\tvalues: %#lx, %#lx",
+                                               (const char *)uc.args[0], __FILE__,
+                                               uc.args[1], uc.args[2], uc.args[3]);
+               default:
+                       TEST_ASSERT(false, "Unexpected exit: %s",
+                                       exit_reason_str(vcpu_state(vm, vcpuid)->exit_reason));
+               }
+       }
+}
+
+static struct kvm_vm *create_vm(void)
+{
+       struct kvm_vm *vm;
+       uint64_t vcpu_pages = (DEFAULT_STACK_PGS) * 2;
+       uint64_t extra_pg_pages = vcpu_pages / PTES_PER_MIN_PAGE * N_VCPU;
+       uint64_t pages = DEFAULT_GUEST_PHY_PAGES + vcpu_pages + extra_pg_pages;
+
+       pages = vm_adjust_num_guest_pages(VM_MODE_DEFAULT, pages);
+       vm = vm_create(VM_MODE_DEFAULT, pages, O_RDWR);
+
+       kvm_vm_elf_load(vm, program_invocation_name, 0, 0);
+       vm_create_irqchip(vm);
+
+       return vm;
+}
+
+static void add_x86_vcpu(struct kvm_vm *vm, uint32_t vcpuid, bool bsp_code)
+{
+       if (bsp_code)
+               vm_vcpu_add_default(vm, vcpuid, guest_bsp_vcpu);
+       else
+               vm_vcpu_add_default(vm, vcpuid, guest_not_bsp_vcpu);
+
+       vcpu_set_cpuid(vm, vcpuid, kvm_get_supported_cpuid());
+}
+
+static void run_vm_bsp(uint32_t bsp_vcpu)
+{
+       struct kvm_vm *vm;
+       bool is_bsp_vcpu1 = bsp_vcpu == VCPU_ID1;
+
+       vm = create_vm();
+
+       if (is_bsp_vcpu1)
+               vm_ioctl(vm, KVM_SET_BOOT_CPU_ID, (void *) VCPU_ID1);
+
+       add_x86_vcpu(vm, VCPU_ID0, !is_bsp_vcpu1);
+       add_x86_vcpu(vm, VCPU_ID1, is_bsp_vcpu1);
+
+       run_vcpu(vm, VCPU_ID0);
+       run_vcpu(vm, VCPU_ID1);
+
+       kvm_vm_free(vm);
+}
+
+static void check_set_bsp_busy(void)
+{
+       struct kvm_vm *vm;
+       int res;
+
+       vm = create_vm();
+
+       add_x86_vcpu(vm, VCPU_ID0, true);
+       add_x86_vcpu(vm, VCPU_ID1, false);
+
+       res = _vm_ioctl(vm, KVM_SET_BOOT_CPU_ID, (void *) VCPU_ID1);
+       TEST_ASSERT(res == -1 && errno == EBUSY, "KVM_SET_BOOT_CPU_ID set after adding vcpu");
+
+       run_vcpu(vm, VCPU_ID0);
+       run_vcpu(vm, VCPU_ID1);
+
+       res = _vm_ioctl(vm, KVM_SET_BOOT_CPU_ID, (void *) VCPU_ID1);
+       TEST_ASSERT(res == -1 && errno == EBUSY, "KVM_SET_BOOT_CPU_ID set to a terminated vcpu");
+
+       kvm_vm_free(vm);
+}
+
+int main(int argc, char *argv[])
+{
+       if (!kvm_check_cap(KVM_CAP_SET_BOOT_CPU_ID)) {
+               print_skip("set_boot_cpu_id not available");
+               return 0;
+       }
+
+       run_vm_bsp(VCPU_ID0);
+       run_vm_bsp(VCPU_ID1);
+       run_vm_bsp(VCPU_ID0);
+
+       check_set_bsp_busy();
+}
index 4c7d33618437c658bf014afff57da52b1a7d36f9..d98fb85e201c810c3d6796ca6dfeca2485ce10b1 100755 (executable)
@@ -1524,6 +1524,14 @@ basic()
        run_cmd "$IP nexthop replace id 2 blackhole dev veth1"
        log_test $? 2 "Blackhole nexthop with other attributes"
 
+       # blackhole nexthop should not be affected by the state of the loopback
+       # device
+       run_cmd "$IP link set dev lo down"
+       check_nexthop "id 2" "id 2 blackhole"
+       log_test $? 0 "Blackhole nexthop with loopback device down"
+
+       run_cmd "$IP link set dev lo up"
+
        #
        # groups
        #
index 197e769c2ed16a65826c3bd67fb560725a28697b..f8cda822c1cec3291b01ad7c8f30e73090c216a9 100755 (executable)
@@ -86,11 +86,20 @@ test_ip6gretap()
 
 test_gretap_stp()
 {
+       # Sometimes after mirror installation, the neighbor's state is not valid.
+       # The reason is that there is no SW datapath activity related to the
+       # neighbor for the remote GRE address. Therefore whether the corresponding
+       # neighbor will be valid is a matter of luck, and the test is thus racy.
+       # Set the neighbor's state to permanent, so it would be always valid.
+       ip neigh replace 192.0.2.130 lladdr $(mac_get $h3) \
+               nud permanent dev br2
        full_test_span_gre_stp gt4 $swp3.555 "mirror to gretap"
 }
 
 test_ip6gretap_stp()
 {
+       ip neigh replace 2001:db8:2::2 lladdr $(mac_get $h3) \
+               nud permanent dev br2
        full_test_span_gre_stp gt6 $swp3.555 "mirror to ip6gretap"
 }
 
index 17ced7d6ce259c671e7ec63e7c9a4575a1db9bd4..f23438d512c58d3f3e1fbb5c0638f6d588cdf1f9 100644 (file)
@@ -1785,7 +1785,7 @@ static void grand_child_serv(unsigned int nr, int cmd_fd, void *buf,
                break;
        default:
                printk("got unknown msg type %d", msg->type);
-       };
+       }
 }
 
 static int grand_child_f(unsigned int nr, int cmd_fd, void *buf)
index 3006a8e5b41a1031af0231a7a17fa49f5f98edd3..3171069a6b461a7015acfc7fcef53dba257c46c3 100644 (file)
@@ -4,7 +4,7 @@
 TEST_PROGS := nft_trans_stress.sh nft_nat.sh bridge_brouter.sh \
        conntrack_icmp_related.sh nft_flowtable.sh ipvs.sh \
        nft_concat_range.sh nft_conntrack_helper.sh \
-       nft_queue.sh nft_meta.sh \
+       nft_queue.sh nft_meta.sh nf_nat_edemux.sh \
        ipip-conntrack-mtu.sh
 
 LDLIBS = -lmnl
diff --git a/tools/testing/selftests/netfilter/nf_nat_edemux.sh b/tools/testing/selftests/netfilter/nf_nat_edemux.sh
new file mode 100755 (executable)
index 0000000..cfee3b6
--- /dev/null
@@ -0,0 +1,99 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# Test NAT source port clash resolution
+#
+
+# Kselftest framework requirement - SKIP code is 4.
+ksft_skip=4
+ret=0
+
+sfx=$(mktemp -u "XXXXXXXX")
+ns1="ns1-$sfx"
+ns2="ns2-$sfx"
+
+cleanup()
+{
+       ip netns del $ns1
+       ip netns del $ns2
+}
+
+iperf3 -v > /dev/null 2>&1
+if [ $? -ne 0 ];then
+       echo "SKIP: Could not run test without iperf3"
+       exit $ksft_skip
+fi
+
+iptables --version > /dev/null 2>&1
+if [ $? -ne 0 ];then
+       echo "SKIP: Could not run test without iptables"
+       exit $ksft_skip
+fi
+
+ip -Version > /dev/null 2>&1
+if [ $? -ne 0 ];then
+       echo "SKIP: Could not run test without ip tool"
+       exit $ksft_skip
+fi
+
+ip netns add "$ns1"
+if [ $? -ne 0 ];then
+       echo "SKIP: Could not create net namespace $ns1"
+       exit $ksft_skip
+fi
+
+trap cleanup EXIT
+
+ip netns add $ns2
+
+# Connect the namespaces using a veth pair
+ip link add name veth2 type veth peer name veth1
+ip link set netns $ns1 dev veth1
+ip link set netns $ns2 dev veth2
+
+ip netns exec $ns1 ip link set up dev lo
+ip netns exec $ns1 ip link set up dev veth1
+ip netns exec $ns1 ip addr add 192.168.1.1/24 dev veth1
+
+ip netns exec $ns2 ip link set up dev lo
+ip netns exec $ns2 ip link set up dev veth2
+ip netns exec $ns2 ip addr add 192.168.1.2/24 dev veth2
+
+# Create a server in one namespace
+ip netns exec $ns1 iperf3 -s > /dev/null 2>&1 &
+iperfs=$!
+
+# Restrict source port to just one so we don't have to exhaust
+# all others.
+ip netns exec $ns2 sysctl -q net.ipv4.ip_local_port_range="10000 10000"
+
+# add a virtual IP using DNAT
+ip netns exec $ns2 iptables -t nat -A OUTPUT -d 10.96.0.1/32 -p tcp --dport 443 -j DNAT --to-destination 192.168.1.1:5201
+
+# ... and route it to the other namespace
+ip netns exec $ns2 ip route add 10.96.0.1 via 192.168.1.1
+
+sleep 1
+
+# add a persistent connection from the other namespace
+ip netns exec $ns2 nc -q 10 -w 10 192.168.1.1 5201 > /dev/null &
+
+sleep 1
+
+# ip daddr:dport will be rewritten to 192.168.1.1 5201
+# NAT must reallocate source port 10000 because
+# 192.168.1.2:10000 -> 192.168.1.1:5201 is already in use
+echo test | ip netns exec $ns2 nc -w 3 -q 3 10.96.0.1 443 >/dev/null
+ret=$?
+
+kill $iperfs
+
+# Check nc can connect to 10.96.0.1:443 (aka 192.168.1.1:5201).
+if [ $ret -eq 0 ]; then
+       echo "PASS: nc can connect via NAT'd address"
+else
+       echo "FAIL: nc cannot connect via NAT'd address"
+       exit 1
+fi
+
+exit 0