From 801fbe3d40bfcdf99683b02942f811c671e19e9a Mon Sep 17 00:00:00 2001 From: Vasily Khoruzhick Date: Sun, 14 Mar 2010 16:32:28 +0200 Subject: [PATCH] --- yaml --- r: 188382 b: refs/heads/master c: 664e87e47e086962a832f9a613a8fd4042a02ac1 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/Documentation/networking/Makefile | 2 - .../networking/timestamping/Makefile | 11 +- .../networking/timestamping/timestamping.c | 10 +- trunk/MAINTAINERS | 15 - .../s3c2440-cpufreq.c | 0 trunk/arch/microblaze/Kconfig | 64 +- trunk/arch/microblaze/Makefile | 1 - trunk/arch/microblaze/include/asm/device.h | 4 - .../arch/microblaze/include/asm/dma-mapping.h | 154 +- trunk/arch/microblaze/include/asm/io.h | 31 +- trunk/arch/microblaze/include/asm/irq.h | 37 +- trunk/arch/microblaze/include/asm/page.h | 12 +- .../arch/microblaze/include/asm/pci-bridge.h | 195 -- trunk/arch/microblaze/include/asm/pci.h | 178 +- trunk/arch/microblaze/include/asm/pgalloc.h | 2 +- trunk/arch/microblaze/include/asm/pgtable.h | 40 +- trunk/arch/microblaze/include/asm/prom.h | 15 - trunk/arch/microblaze/include/asm/system.h | 3 - trunk/arch/microblaze/include/asm/tlbflush.h | 2 +- trunk/arch/microblaze/kernel/Makefile | 2 +- trunk/arch/microblaze/kernel/asm-offsets.c | 1 - trunk/arch/microblaze/kernel/cpu/cache.c | 211 +- trunk/arch/microblaze/kernel/dma.c | 156 -- trunk/arch/microblaze/kernel/entry.S | 116 +- trunk/arch/microblaze/kernel/head.S | 13 +- trunk/arch/microblaze/kernel/irq.c | 15 - trunk/arch/microblaze/kernel/setup.c | 45 +- trunk/arch/microblaze/mm/Makefile | 2 +- trunk/arch/microblaze/mm/consistent.c | 246 --- trunk/arch/microblaze/mm/init.c | 39 +- trunk/arch/microblaze/mm/pgtable.c | 2 +- trunk/arch/microblaze/pci/Makefile | 6 - trunk/arch/microblaze/pci/indirect_pci.c | 163 -- trunk/arch/microblaze/pci/iomap.c | 39 - trunk/arch/microblaze/pci/pci-common.c | 1642 --------------- trunk/arch/microblaze/pci/pci_32.c | 430 ---- trunk/arch/microblaze/pci/xilinx_pci.c | 168 -- trunk/arch/powerpc/kernel/perf_event.c | 21 +- trunk/arch/sh/kernel/perf_event.c | 20 +- trunk/arch/x86/kernel/cpu/perf_event.c | 183 +- trunk/arch/x86/kernel/cpu/perf_event_amd.c | 62 +- trunk/arch/x86/kernel/cpu/perf_event_intel.c | 57 +- trunk/arch/x86/kernel/cpu/perf_event_p6.c | 10 +- trunk/arch/x86/kernel/dumpstack.h | 15 - trunk/arch/x86/kernel/dumpstack_64.c | 4 +- trunk/drivers/acpi/video.c | 9 +- trunk/drivers/ata/ahci.c | 66 +- trunk/drivers/atm/lanai.c | 7 +- trunk/drivers/base/memory.c | 15 +- trunk/drivers/char/hpet.c | 4 +- .../gpu/drm/nouveau/nouveau_backlight.c | 12 +- trunk/drivers/hid/hid-core.c | 1 - trunk/drivers/hid/hid-debug.c | 6 +- trunk/drivers/hid/hid-ids.h | 1 - trunk/drivers/hid/hid-magicmouse.c | 7 +- trunk/drivers/hid/hid-ntrig.c | 11 - trunk/drivers/hid/hid-tmff.c | 2 - trunk/drivers/hid/usbhid/hid-quirks.c | 1 - .../drivers/infiniband/ulp/iser/iscsi_iser.c | 2 +- trunk/drivers/isdn/gigaset/capi.c | 46 +- trunk/drivers/isdn/gigaset/common.c | 6 +- trunk/drivers/isdn/gigaset/dummyll.c | 14 +- trunk/drivers/isdn/gigaset/ev-layer.c | 12 +- trunk/drivers/isdn/gigaset/gigaset.h | 6 +- trunk/drivers/isdn/gigaset/i4l.c | 28 +- trunk/drivers/isdn/gigaset/interface.c | 1 + trunk/drivers/isdn/hardware/eicon/message.c | 35 +- trunk/drivers/isdn/hardware/mISDN/hfcmulti.c | 6 - trunk/drivers/isdn/hysdn/hysdn_boot.c | 2 +- trunk/drivers/leds/Kconfig | 80 +- trunk/drivers/leds/Makefile | 1 - trunk/drivers/leds/dell-led.c | 200 -- trunk/drivers/leds/led-class.c | 42 +- trunk/drivers/leds/leds-gpio.c | 3 +- trunk/drivers/leds/leds-ss4200.c | 2 +- trunk/drivers/macintosh/via-pmu-backlight.c | 7 +- trunk/drivers/md/linear.c | 12 +- trunk/drivers/md/multipath.c | 20 +- trunk/drivers/md/raid0.c | 13 +- trunk/drivers/md/raid1.c | 28 +- trunk/drivers/md/raid10.c | 28 +- trunk/drivers/net/benet/be_cmds.c | 2 +- trunk/drivers/net/bnx2x_main.c | 10 +- trunk/drivers/net/davinci_emac.c | 72 +- trunk/drivers/net/e100.c | 2 +- trunk/drivers/net/irda/w83977af_ir.c | 36 + trunk/drivers/net/ksz884x.c | 8 +- trunk/drivers/net/myri10ge/myri10ge.c | 1 + trunk/drivers/net/ne.c | 2 +- trunk/drivers/net/pppol2tp.c | 6 +- trunk/drivers/net/s2io.c | 4 +- trunk/drivers/net/usb/Kconfig | 8 - trunk/drivers/net/usb/Makefile | 1 - trunk/drivers/net/usb/hso.c | 3 + trunk/drivers/net/usb/smsc75xx.c | 1288 ------------ trunk/drivers/net/usb/smsc75xx.h | 421 ---- trunk/drivers/net/usb/smsc95xx.c | 15 - trunk/drivers/pci/Makefile | 1 - trunk/drivers/pcmcia/i82092.c | 1 - trunk/drivers/pcmcia/i82365.h | 1 - trunk/drivers/pcmcia/pcmcia_resource.c | 36 +- trunk/drivers/pcmcia/pd6729.c | 1 - trunk/drivers/pcmcia/ti113x.h | 37 +- trunk/drivers/pcmcia/vrc4171_card.c | 5 +- trunk/drivers/pcmcia/yenta_socket.c | 46 +- trunk/drivers/platform/x86/acer-wmi.c | 7 +- trunk/drivers/platform/x86/asus-laptop.c | 7 +- trunk/drivers/platform/x86/asus_acpi.c | 7 +- trunk/drivers/platform/x86/classmate-laptop.c | 12 +- trunk/drivers/platform/x86/compal-laptop.c | 11 +- trunk/drivers/platform/x86/dell-laptop.c | 13 +- trunk/drivers/platform/x86/eeepc-laptop.c | 8 +- trunk/drivers/platform/x86/fujitsu-laptop.c | 14 +- trunk/drivers/platform/x86/msi-laptop.c | 7 +- trunk/drivers/platform/x86/msi-wmi.c | 15 +- trunk/drivers/platform/x86/panasonic-laptop.c | 28 +- trunk/drivers/platform/x86/sony-laptop.c | 8 +- trunk/drivers/platform/x86/thinkpad_acpi.c | 12 +- trunk/drivers/platform/x86/toshiba_acpi.c | 10 +- trunk/drivers/s390/char/sclp_cmd.c | 7 - trunk/drivers/scsi/Kconfig | 6 - trunk/drivers/scsi/be2iscsi/be_cmds.c | 7 + trunk/drivers/scsi/be2iscsi/be_iscsi.c | 4 +- trunk/drivers/scsi/be2iscsi/be_main.c | 201 +- trunk/drivers/scsi/be2iscsi/be_main.h | 11 +- trunk/drivers/scsi/be2iscsi/be_mgmt.c | 14 +- trunk/drivers/scsi/be2iscsi/be_mgmt.h | 8 +- trunk/drivers/scsi/bfa/Makefile | 8 +- trunk/drivers/scsi/bfa/bfa_core.c | 19 - trunk/drivers/scsi/bfa/bfa_fcport.c | 1709 +++++++--------- trunk/drivers/scsi/bfa/bfa_fcs.c | 63 +- trunk/drivers/scsi/bfa/bfa_fcs_lport.c | 75 +- trunk/drivers/scsi/bfa/bfa_fcs_port.c | 11 +- trunk/drivers/scsi/bfa/bfa_fcs_uf.c | 8 +- trunk/drivers/scsi/bfa/bfa_hw_cb.c | 13 - trunk/drivers/scsi/bfa/bfa_hw_ct.c | 9 - trunk/drivers/scsi/bfa/bfa_intr.c | 111 +- trunk/drivers/scsi/bfa/bfa_ioc.c | 762 ++++--- trunk/drivers/scsi/bfa/bfa_ioc.h | 57 +- trunk/drivers/scsi/bfa/bfa_ioc_cb.c | 274 --- trunk/drivers/scsi/bfa/bfa_ioc_ct.c | 423 ---- trunk/drivers/scsi/bfa/bfa_iocfc.c | 24 +- trunk/drivers/scsi/bfa/bfa_iocfc.h | 3 - trunk/drivers/scsi/bfa/bfa_ioim.c | 22 +- trunk/drivers/scsi/bfa/bfa_itnim.c | 30 +- trunk/drivers/scsi/bfa/bfa_lps.c | 134 +- trunk/drivers/scsi/bfa/bfa_module.c | 4 +- trunk/drivers/scsi/bfa/bfa_modules_priv.h | 2 +- trunk/drivers/scsi/bfa/bfa_port_priv.h | 57 +- trunk/drivers/scsi/bfa/bfa_priv.h | 2 +- trunk/drivers/scsi/bfa/bfa_rport.c | 26 +- trunk/drivers/scsi/bfa/bfa_trcmod_priv.h | 62 +- trunk/drivers/scsi/bfa/bfa_tskim.c | 14 +- trunk/drivers/scsi/bfa/bfad.c | 208 +- trunk/drivers/scsi/bfa/bfad_attr.c | 76 +- trunk/drivers/scsi/bfa/bfad_attr.h | 9 + trunk/drivers/scsi/bfa/bfad_drv.h | 35 +- trunk/drivers/scsi/bfa/bfad_im.c | 53 +- trunk/drivers/scsi/bfa/bfad_im.h | 5 + trunk/drivers/scsi/bfa/bfad_intr.c | 11 +- trunk/drivers/scsi/bfa/fabric.c | 59 +- trunk/drivers/scsi/bfa/fcbuild.h | 6 - trunk/drivers/scsi/bfa/fcpim.c | 51 +- trunk/drivers/scsi/bfa/fcs_fabric.h | 2 - trunk/drivers/scsi/bfa/fcs_fcpim.h | 5 + trunk/drivers/scsi/bfa/fcs_lport.h | 7 +- trunk/drivers/scsi/bfa/fcs_port.h | 3 +- trunk/drivers/scsi/bfa/fcs_rport.h | 3 + trunk/drivers/scsi/bfa/fcs_uf.h | 3 +- trunk/drivers/scsi/bfa/fcs_vport.h | 8 + trunk/drivers/scsi/bfa/fdmi.c | 79 +- trunk/drivers/scsi/bfa/include/aen/bfa_aen.h | 50 +- trunk/drivers/scsi/bfa/include/bfa.h | 22 - trunk/drivers/scsi/bfa/include/bfa_svc.h | 101 +- trunk/drivers/scsi/bfa/include/bfa_timer.h | 2 +- trunk/drivers/scsi/bfa/include/bfi/bfi.h | 4 +- .../drivers/scsi/bfa/include/bfi/bfi_cbreg.h | 16 +- .../drivers/scsi/bfa/include/bfi/bfi_ctreg.h | 26 - trunk/drivers/scsi/bfa/include/bfi/bfi_ioc.h | 2 +- trunk/drivers/scsi/bfa/include/bfi/bfi_lps.h | 8 - .../drivers/scsi/bfa/include/bfi/bfi_pport.h | 172 +- .../scsi/bfa/include/cna/bfa_cna_trcmod.h | 4 - trunk/drivers/scsi/bfa/include/cs/bfa_log.h | 2 +- trunk/drivers/scsi/bfa/include/cs/bfa_plog.h | 9 +- trunk/drivers/scsi/bfa/include/cs/bfa_sm.h | 8 - .../scsi/bfa/include/defs/bfa_defs_aen.h | 10 - .../scsi/bfa/include/defs/bfa_defs_auth.h | 22 - .../scsi/bfa/include/defs/bfa_defs_cee.h | 14 +- .../scsi/bfa/include/defs/bfa_defs_driver.h | 3 +- .../scsi/bfa/include/defs/bfa_defs_ethport.h | 1 - .../scsi/bfa/include/defs/bfa_defs_fcport.h | 94 - .../bfa/include/defs/bfa_defs_im_common.h | 32 + .../scsi/bfa/include/defs/bfa_defs_im_team.h | 72 + .../scsi/bfa/include/defs/bfa_defs_ioc.h | 3 +- .../scsi/bfa/include/defs/bfa_defs_iocfc.h | 12 +- .../scsi/bfa/include/defs/bfa_defs_lport.h | 4 +- .../scsi/bfa/include/defs/bfa_defs_mfg.h | 111 +- .../scsi/bfa/include/defs/bfa_defs_port.h | 19 +- .../scsi/bfa/include/defs/bfa_defs_pport.h | 151 +- .../scsi/bfa/include/defs/bfa_defs_status.h | 17 +- .../scsi/bfa/include/fcb/bfa_fcb_fcpim.h | 1 + trunk/drivers/scsi/bfa/include/fcs/bfa_fcs.h | 5 +- .../scsi/bfa/include/fcs/bfa_fcs_lport.h | 8 + .../scsi/bfa/include/log/bfa_log_hal.h | 6 - .../scsi/bfa/include/log/bfa_log_linux.h | 16 - trunk/drivers/scsi/bfa/include/protocol/fc.h | 5 - .../drivers/scsi/bfa/include/protocol/pcifw.h | 75 + trunk/drivers/scsi/bfa/loop.c | 2 +- trunk/drivers/scsi/bfa/lport_api.c | 5 +- trunk/drivers/scsi/bfa/ms.c | 29 +- trunk/drivers/scsi/bfa/ns.c | 36 +- trunk/drivers/scsi/bfa/rport.c | 91 +- trunk/drivers/scsi/bfa/rport_api.c | 2 +- trunk/drivers/scsi/bfa/rport_ftrs.c | 12 +- trunk/drivers/scsi/bfa/scn.c | 10 +- trunk/drivers/scsi/bfa/vport.c | 86 +- trunk/drivers/scsi/bnx2i/bnx2i_iscsi.c | 2 +- trunk/drivers/scsi/cxgb3i/cxgb3i_iscsi.c | 2 +- .../drivers/scsi/device_handler/scsi_dh_emc.c | 6 +- trunk/drivers/scsi/hpsa.c | 330 ++-- trunk/drivers/scsi/hpsa.h | 7 +- trunk/drivers/scsi/hpsa_cmd.h | 20 +- trunk/drivers/scsi/ibmvscsi/ibmvfc.c | 27 - trunk/drivers/scsi/ibmvscsi/ibmvscsi.c | 19 - trunk/drivers/scsi/ibmvscsi/ibmvscsi.h | 1 - trunk/drivers/scsi/ibmvscsi/iseries_vscsi.c | 6 - trunk/drivers/scsi/ibmvscsi/rpa_vscsi.c | 13 - trunk/drivers/scsi/ipr.c | 1756 ++++------------- trunk/drivers/scsi/ipr.h | 467 +---- trunk/drivers/scsi/iscsi_tcp.c | 2 +- trunk/drivers/scsi/libiscsi.c | 23 +- trunk/drivers/scsi/lpfc/lpfc.h | 10 +- trunk/drivers/scsi/lpfc/lpfc_attr.c | 7 +- trunk/drivers/scsi/lpfc/lpfc_bsg.c | 332 ---- trunk/drivers/scsi/lpfc/lpfc_bsg.h | 12 - trunk/drivers/scsi/lpfc/lpfc_crtn.h | 7 +- trunk/drivers/scsi/lpfc/lpfc_els.c | 142 +- trunk/drivers/scsi/lpfc/lpfc_hbadisc.c | 527 ++--- trunk/drivers/scsi/lpfc/lpfc_init.c | 277 +-- trunk/drivers/scsi/lpfc/lpfc_logmsg.h | 1 - trunk/drivers/scsi/lpfc/lpfc_mbox.c | 8 +- trunk/drivers/scsi/lpfc/lpfc_scsi.c | 49 +- trunk/drivers/scsi/lpfc/lpfc_sli.c | 413 +--- trunk/drivers/scsi/lpfc/lpfc_sli.h | 1 - trunk/drivers/scsi/lpfc/lpfc_sli4.h | 38 +- trunk/drivers/scsi/lpfc/lpfc_version.h | 2 +- trunk/drivers/scsi/lpfc/lpfc_vport.c | 7 +- trunk/drivers/scsi/osd/osd_initiator.c | 4 - trunk/drivers/scsi/pcmcia/nsp_cs.c | 1 - trunk/drivers/scsi/raid_class.c | 2 - trunk/drivers/scsi/scsi_transport_fc.c | 24 +- trunk/drivers/scsi/sd.c | 4 +- trunk/drivers/serial/sunsab.c | 2 +- .../staging/samsung-laptop/samsung-laptop.c | 7 +- trunk/drivers/usb/misc/appledisplay.c | 7 +- trunk/drivers/video/Kconfig | 2 +- trunk/drivers/video/atmel_lcdfb.c | 8 +- trunk/drivers/video/aty/aty128fb.c | 7 +- trunk/drivers/video/aty/atyfb_base.c | 7 +- trunk/drivers/video/aty/radeon_backlight.c | 7 +- trunk/drivers/video/backlight/88pm860x_bl.c | 6 +- trunk/drivers/video/backlight/Kconfig | 7 - trunk/drivers/video/backlight/Makefile | 1 - trunk/drivers/video/backlight/adp5520_bl.c | 11 +- trunk/drivers/video/backlight/adx_bl.c | 10 +- trunk/drivers/video/backlight/atmel-pwm-bl.c | 8 +- trunk/drivers/video/backlight/backlight.c | 10 +- trunk/drivers/video/backlight/corgi_lcd.c | 8 +- trunk/drivers/video/backlight/cr_bllcd.c | 8 +- trunk/drivers/video/backlight/da903x_bl.c | 7 +- trunk/drivers/video/backlight/generic_bl.c | 8 +- trunk/drivers/video/backlight/hp680_bl.c | 8 +- trunk/drivers/video/backlight/jornada720_bl.c | 7 +- trunk/drivers/video/backlight/kb3886_bl.c | 8 +- trunk/drivers/video/backlight/l4f00242t03.c | 257 --- trunk/drivers/video/backlight/locomolcd.c | 8 +- trunk/drivers/video/backlight/max8925_bl.c | 6 +- trunk/drivers/video/backlight/mbp_nvidia_bl.c | 55 +- trunk/drivers/video/backlight/omap1_bl.c | 7 +- trunk/drivers/video/backlight/progear_bl.c | 23 +- trunk/drivers/video/backlight/pwm_bl.c | 8 +- trunk/drivers/video/backlight/tosa_bl.c | 8 +- trunk/drivers/video/backlight/wm831x_bl.c | 7 +- trunk/drivers/video/bf54x-lq043fb.c | 19 +- trunk/drivers/video/bfin-t350mcqb-fb.c | 19 +- trunk/drivers/video/nvidia/nv_backlight.c | 7 +- .../drivers/video/omap2/displays/panel-taal.c | 15 +- trunk/drivers/video/riva/fbdev.c | 7 +- trunk/fs/btrfs/btrfs_inode.h | 5 - trunk/fs/btrfs/compression.c | 2 +- trunk/fs/btrfs/ctree.h | 13 +- trunk/fs/btrfs/disk-io.c | 15 +- trunk/fs/btrfs/export.c | 4 +- trunk/fs/btrfs/extent-tree.c | 11 +- trunk/fs/btrfs/extent_io.c | 79 +- trunk/fs/btrfs/extent_io.h | 10 +- trunk/fs/btrfs/file.c | 23 +- trunk/fs/btrfs/inode.c | 139 +- trunk/fs/btrfs/ioctl.c | 706 +------ trunk/fs/btrfs/ioctl.h | 111 -- trunk/fs/btrfs/ordered-data.c | 41 +- trunk/fs/btrfs/ordered-data.h | 7 +- trunk/fs/btrfs/relocation.c | 4 +- trunk/fs/btrfs/super.c | 238 +-- trunk/fs/btrfs/transaction.c | 5 +- trunk/fs/btrfs/tree-log.c | 2 +- trunk/fs/btrfs/volumes.c | 39 +- trunk/fs/jffs2/readinode.c | 2 +- trunk/fs/nfs/callback_xdr.c | 1 - trunk/fs/nfs/delegation.h | 6 - trunk/fs/nfs/dir.c | 2 +- trunk/fs/nfs/inode.c | 2 +- trunk/fs/nfs/nfs4proc.c | 1 - trunk/fs/nfs/pagelist.c | 23 +- trunk/fs/nfs/super.c | 25 +- trunk/fs/ntfs/super.c | 25 +- trunk/fs/xfs/linux-2.6/xfs_aops.c | 13 +- trunk/fs/xfs/linux-2.6/xfs_buf.c | 81 +- trunk/include/linux/backlight.h | 11 +- trunk/include/linux/ftrace_event.h | 23 +- trunk/include/linux/memory.h | 2 - trunk/include/linux/perf_event.h | 59 +- trunk/include/linux/spi/l4f00242t03.h | 31 - trunk/include/linux/syscalls.h | 24 +- trunk/include/scsi/libiscsi.h | 3 +- trunk/include/trace/ftrace.h | 44 +- trunk/include/trace/syscall.h | 8 +- trunk/kernel/kprobes.c | 3 +- trunk/kernel/lockdep.c | 9 +- trunk/kernel/perf_event.c | 84 +- trunk/kernel/trace/Makefile | 2 +- ...ace_event_perf.c => trace_event_profile.c} | 50 +- trunk/kernel/trace/trace_events.c | 2 +- trunk/kernel/trace/trace_kprobe.c | 29 +- trunk/kernel/trace/trace_syscalls.c | 72 +- trunk/mm/page_cgroup.c | 20 +- trunk/net/bridge/br_device.c | 2 +- trunk/net/bridge/br_forward.c | 18 +- trunk/net/bridge/br_input.c | 4 +- trunk/net/bridge/br_multicast.c | 18 +- trunk/net/bridge/br_private.h | 10 +- trunk/net/core/netpoll.c | 4 +- trunk/net/dccp/ipv4.c | 8 +- trunk/net/dccp/ipv6.c | 8 +- trunk/net/dccp/proto.c | 16 +- trunk/net/ipv4/route.c | 16 +- trunk/net/phonet/pn_dev.c | 3 +- trunk/net/phonet/pn_netlink.c | 3 +- trunk/net/sunrpc/xprtsock.c | 8 +- trunk/net/tipc/ref.c | 26 +- trunk/sound/oss/sequencer.c | 2 + trunk/sound/pci/hda/hda_codec.c | 4 +- trunk/sound/pci/hda/hda_intel.c | 9 - trunk/sound/pci/hda/patch_realtek.c | 6 +- trunk/tools/perf/Documentation/Makefile | 4 +- trunk/tools/perf/Makefile | 6 +- trunk/tools/perf/builtin-annotate.c | 6 +- trunk/tools/perf/builtin-diff.c | 13 +- trunk/tools/perf/builtin-record.c | 13 +- trunk/tools/perf/builtin-report.c | 112 +- trunk/tools/perf/builtin-stat.c | 10 +- trunk/tools/perf/builtin-top.c | 9 +- trunk/tools/perf/util/cpumap.c | 59 - trunk/tools/perf/util/cpumap.h | 7 - trunk/tools/perf/util/event.h | 9 - trunk/tools/perf/util/hist.c | 50 +- trunk/tools/perf/util/hist.h | 12 +- trunk/tools/perf/util/probe-finder.c | 2 +- trunk/tools/perf/util/session.c | 1 - trunk/tools/perf/util/session.h | 1 - trunk/tools/perf/util/thread.c | 41 +- trunk/tools/perf/util/thread.h | 3 - 373 files changed, 5038 insertions(+), 16276 deletions(-) rename trunk/arch/arm/{plat-s3c24xx => mach-s3c2440}/s3c2440-cpufreq.c (100%) delete mode 100644 trunk/arch/microblaze/kernel/dma.c delete mode 100644 trunk/arch/microblaze/mm/consistent.c delete mode 100644 trunk/arch/microblaze/pci/Makefile delete mode 100644 trunk/arch/microblaze/pci/indirect_pci.c delete mode 100644 trunk/arch/microblaze/pci/iomap.c delete mode 100644 trunk/arch/microblaze/pci/pci-common.c delete mode 100644 trunk/arch/microblaze/pci/pci_32.c delete mode 100644 trunk/arch/microblaze/pci/xilinx_pci.c delete mode 100644 trunk/drivers/leds/dell-led.c delete mode 100644 trunk/drivers/net/usb/smsc75xx.c delete mode 100644 trunk/drivers/net/usb/smsc75xx.h delete mode 100644 trunk/drivers/scsi/bfa/bfa_ioc_cb.c delete mode 100644 trunk/drivers/scsi/bfa/bfa_ioc_ct.c delete mode 100644 trunk/drivers/scsi/bfa/include/defs/bfa_defs_fcport.h create mode 100644 trunk/drivers/scsi/bfa/include/defs/bfa_defs_im_common.h create mode 100644 trunk/drivers/scsi/bfa/include/defs/bfa_defs_im_team.h create mode 100644 trunk/drivers/scsi/bfa/include/protocol/pcifw.h delete mode 100644 trunk/drivers/video/backlight/l4f00242t03.c delete mode 100644 trunk/include/linux/spi/l4f00242t03.h rename trunk/kernel/trace/{trace_event_perf.c => trace_event_profile.c} (68%) delete mode 100644 trunk/tools/perf/util/cpumap.c delete mode 100644 trunk/tools/perf/util/cpumap.h diff --git a/[refs] b/[refs] index adb2c860959a..13d6ccf39bf3 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 722874465e3cd3268387b96e02220f84b35a8d98 +refs/heads/master: 664e87e47e086962a832f9a613a8fd4042a02ac1 diff --git a/trunk/Documentation/networking/Makefile b/trunk/Documentation/networking/Makefile index 5aba7a33aeeb..6d8af1ac56c4 100644 --- a/trunk/Documentation/networking/Makefile +++ b/trunk/Documentation/networking/Makefile @@ -6,5 +6,3 @@ hostprogs-y := ifenslave # Tell kbuild to always build the programs always := $(hostprogs-y) - -obj-m := timestamping/ diff --git a/trunk/Documentation/networking/timestamping/Makefile b/trunk/Documentation/networking/timestamping/Makefile index e79973443e9f..2a1489fdc036 100644 --- a/trunk/Documentation/networking/timestamping/Makefile +++ b/trunk/Documentation/networking/timestamping/Makefile @@ -1,13 +1,6 @@ -# kbuild trick to avoid linker error. Can be omitted if a module is built. -obj- := dummy.o +CPPFLAGS = -I../../../include -# List of programs to build -hostprogs-y := timestamping - -# Tell kbuild to always build the programs -always := $(hostprogs-y) - -HOSTCFLAGS_timestamping.o += -I$(objtree)/usr/include +timestamping: timestamping.c clean: rm -f timestamping diff --git a/trunk/Documentation/networking/timestamping/timestamping.c b/trunk/Documentation/networking/timestamping/timestamping.c index 8ba82bfe6a33..bab619a48214 100644 --- a/trunk/Documentation/networking/timestamping/timestamping.c +++ b/trunk/Documentation/networking/timestamping/timestamping.c @@ -41,9 +41,9 @@ #include #include -#include -#include -#include +#include "asm/types.h" +#include "linux/net_tstamp.h" +#include "linux/errqueue.h" #ifndef SO_TIMESTAMPING # define SO_TIMESTAMPING 37 @@ -164,7 +164,7 @@ static void printpacket(struct msghdr *msg, int res, gettimeofday(&now, 0); - printf("%ld.%06ld: received %s data, %d bytes from %s, %zu bytes control messages\n", + printf("%ld.%06ld: received %s data, %d bytes from %s, %d bytes control messages\n", (long)now.tv_sec, (long)now.tv_usec, (recvmsg_flags & MSG_ERRQUEUE) ? "error" : "regular", res, @@ -173,7 +173,7 @@ static void printpacket(struct msghdr *msg, int res, for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) { - printf(" cmsg len %zu: ", cmsg->cmsg_len); + printf(" cmsg len %d: ", cmsg->cmsg_len); switch (cmsg->cmsg_level) { case SOL_SOCKET: printf("SOL_SOCKET "); diff --git a/trunk/MAINTAINERS b/trunk/MAINTAINERS index 382eaa4d0068..47cc449d89d8 100644 --- a/trunk/MAINTAINERS +++ b/trunk/MAINTAINERS @@ -5214,21 +5214,6 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-next-2.6.git S: Maintained F: arch/sparc/ -SPARC SERIAL DRIVERS -M: "David S. Miller" -L: sparclinux@vger.kernel.org -T: git git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6.git -T: git git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-next-2.6.git -S: Maintained -F: drivers/serial/suncore.c -F: drivers/serial/suncore.h -F: drivers/serial/sunhv.c -F: drivers/serial/sunsab.c -F: drivers/serial/sunsab.h -F: drivers/serial/sunsu.c -F: drivers/serial/sunzilog.c -F: drivers/serial/sunzilog.h - SPECIALIX IO8+ MULTIPORT SERIAL CARD DRIVER M: Roger Wolff S: Supported diff --git a/trunk/arch/arm/plat-s3c24xx/s3c2440-cpufreq.c b/trunk/arch/arm/mach-s3c2440/s3c2440-cpufreq.c similarity index 100% rename from trunk/arch/arm/plat-s3c24xx/s3c2440-cpufreq.c rename to trunk/arch/arm/mach-s3c2440/s3c2440-cpufreq.c diff --git a/trunk/arch/microblaze/Kconfig b/trunk/arch/microblaze/Kconfig index 203ec61c6d4c..b008168ae946 100644 --- a/trunk/arch/microblaze/Kconfig +++ b/trunk/arch/microblaze/Kconfig @@ -14,8 +14,6 @@ config MICROBLAZE select USB_ARCH_HAS_EHCI select ARCH_WANT_OPTIONAL_GPIOLIB select HAVE_OPROFILE - select HAVE_DMA_ATTRS - select HAVE_DMA_API_DEBUG select TRACING_SUPPORT config SWAP @@ -78,6 +76,9 @@ config HAVE_LATENCYTOP_SUPPORT config PCI def_bool n +config NO_DMA + def_bool y + config DTC def_bool y @@ -145,6 +146,7 @@ menu "Advanced setup" config ADVANCED_OPTIONS bool "Prompt for advanced kernel configuration options" + depends on MMU help This option will enable prompting for a variety of advanced kernel configuration options. These options can cause the kernel to not @@ -156,15 +158,6 @@ config ADVANCED_OPTIONS comment "Default settings for advanced configuration options are used" depends on !ADVANCED_OPTIONS -config XILINX_UNCACHED_SHADOW - bool "Are you using uncached shadow for RAM ?" - depends on ADVANCED_OPTIONS && !MMU - default n - help - This is needed to be able to allocate uncachable memory regions. - The feature requires the design to define the RAM memory controller - window to be twice as large as the actual physical memory. - config HIGHMEM_START_BOOL bool "Set high memory pool address" depends on ADVANCED_OPTIONS && HIGHMEM @@ -182,7 +175,7 @@ config HIGHMEM_START config LOWMEM_SIZE_BOOL bool "Set maximum low memory" - depends on ADVANCED_OPTIONS && MMU + depends on ADVANCED_OPTIONS help This option allows you to set the maximum amount of memory which will be used as "low memory", that is, memory which the kernel can @@ -194,6 +187,7 @@ config LOWMEM_SIZE_BOOL config LOWMEM_SIZE hex "Maximum low memory size (in bytes)" if LOWMEM_SIZE_BOOL + depends on MMU default "0x30000000" config KERNEL_START_BOOL @@ -214,7 +208,7 @@ config KERNEL_START config TASK_SIZE_BOOL bool "Set custom user task size" - depends on ADVANCED_OPTIONS && MMU + depends on ADVANCED_OPTIONS help This option allows you to set the amount of virtual address space allocated to user tasks. This can be useful in optimizing the @@ -224,34 +218,42 @@ config TASK_SIZE_BOOL config TASK_SIZE hex "Size of user task space" if TASK_SIZE_BOOL + depends on MMU default "0x80000000" -endmenu +config CONSISTENT_START_BOOL + bool "Set custom consistent memory pool address" + depends on ADVANCED_OPTIONS && NOT_COHERENT_CACHE + help + This option allows you to set the base virtual address + of the the consistent memory pool. This pool of virtual + memory is used to make consistent memory allocations. -source "mm/Kconfig" +config CONSISTENT_START + hex "Base virtual address of consistent memory pool" if CONSISTENT_START_BOOL + depends on MMU + default "0xff100000" if NOT_COHERENT_CACHE -menu "Exectuable file formats" +config CONSISTENT_SIZE_BOOL + bool "Set custom consistent memory pool size" + depends on ADVANCED_OPTIONS && NOT_COHERENT_CACHE + help + This option allows you to set the size of the the + consistent memory pool. This pool of virtual memory + is used to make consistent memory allocations. -source "fs/Kconfig.binfmt" +config CONSISTENT_SIZE + hex "Size of consistent memory pool" if CONSISTENT_SIZE_BOOL + depends on MMU + default "0x00200000" if NOT_COHERENT_CACHE endmenu -menu "Bus Options" - -config PCI - bool "PCI support" - -config PCI_DOMAINS - def_bool PCI - -config PCI_SYSCALL - def_bool PCI +source "mm/Kconfig" -config PCI_XILINX - bool "Xilinx PCI host bridge support" - depends on PCI +menu "Exectuable file formats" -source "drivers/pci/Kconfig" +source "fs/Kconfig.binfmt" endmenu diff --git a/trunk/arch/microblaze/Makefile b/trunk/arch/microblaze/Makefile index 836832dd9b26..d2d6cfcb1a30 100644 --- a/trunk/arch/microblaze/Makefile +++ b/trunk/arch/microblaze/Makefile @@ -50,7 +50,6 @@ libs-y += $(LIBGCC) core-y += arch/microblaze/kernel/ core-y += arch/microblaze/mm/ core-y += arch/microblaze/platform/ -core-$(CONFIG_PCI) += arch/microblaze/pci/ drivers-$(CONFIG_OPROFILE) += arch/microblaze/oprofile/ diff --git a/trunk/arch/microblaze/include/asm/device.h b/trunk/arch/microblaze/include/asm/device.h index 402b46e630f6..78a038452c0f 100644 --- a/trunk/arch/microblaze/include/asm/device.h +++ b/trunk/arch/microblaze/include/asm/device.h @@ -14,10 +14,6 @@ struct device_node; struct dev_archdata { /* Optional pointer to an OF device node */ struct device_node *of_node; - - /* DMA operations on that device */ - struct dma_map_ops *dma_ops; - void *dma_data; }; struct pdev_archdata { diff --git a/trunk/arch/microblaze/include/asm/dma-mapping.h b/trunk/arch/microblaze/include/asm/dma-mapping.h index 18b3731c8509..d00e40099165 100644 --- a/trunk/arch/microblaze/include/asm/dma-mapping.h +++ b/trunk/arch/microblaze/include/asm/dma-mapping.h @@ -1,153 +1 @@ -/* - * Implements the generic device dma API for microblaze and the pci - * - * Copyright (C) 2009-2010 Michal Simek - * Copyright (C) 2009-2010 PetaLogix - * - * This file is subject to the terms and conditions of the GNU General - * Public License. See the file COPYING in the main directory of this - * archive for more details. - * - * This file is base on powerpc and x86 dma-mapping.h versions - * Copyright (C) 2004 IBM - */ - -#ifndef _ASM_MICROBLAZE_DMA_MAPPING_H -#define _ASM_MICROBLAZE_DMA_MAPPING_H - -/* - * See Documentation/PCI/PCI-DMA-mapping.txt and - * Documentation/DMA-API.txt for documentation. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define DMA_ERROR_CODE (~(dma_addr_t)0x0) - -#define __dma_alloc_coherent(dev, gfp, size, handle) NULL -#define __dma_free_coherent(size, addr) ((void)0) -#define __dma_sync(addr, size, rw) ((void)0) - -static inline unsigned long device_to_mask(struct device *dev) -{ - if (dev->dma_mask && *dev->dma_mask) - return *dev->dma_mask; - /* Assume devices without mask can take 32 bit addresses */ - return 0xfffffffful; -} - -extern struct dma_map_ops *dma_ops; - -/* - * Available generic sets of operations - */ -extern struct dma_map_ops dma_direct_ops; - -static inline struct dma_map_ops *get_dma_ops(struct device *dev) -{ - /* We don't handle the NULL dev case for ISA for now. We could - * do it via an out of line call but it is not needed for now. The - * only ISA DMA device we support is the floppy and we have a hack - * in the floppy driver directly to get a device for us. - */ - if (unlikely(!dev) || !dev->archdata.dma_ops) - return NULL; - - return dev->archdata.dma_ops; -} - -static inline void set_dma_ops(struct device *dev, struct dma_map_ops *ops) -{ - dev->archdata.dma_ops = ops; -} - -static inline int dma_supported(struct device *dev, u64 mask) -{ - struct dma_map_ops *ops = get_dma_ops(dev); - - if (unlikely(!ops)) - return 0; - if (!ops->dma_supported) - return 1; - return ops->dma_supported(dev, mask); -} - -#ifdef CONFIG_PCI -/* We have our own implementation of pci_set_dma_mask() */ -#define HAVE_ARCH_PCI_SET_DMA_MASK - -#endif - -static inline int dma_set_mask(struct device *dev, u64 dma_mask) -{ - struct dma_map_ops *ops = get_dma_ops(dev); - - if (unlikely(ops == NULL)) - return -EIO; - if (ops->set_dma_mask) - return ops->set_dma_mask(dev, dma_mask); - if (!dev->dma_mask || !dma_supported(dev, dma_mask)) - return -EIO; - *dev->dma_mask = dma_mask; - return 0; -} - -#include - -static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) -{ - struct dma_map_ops *ops = get_dma_ops(dev); - if (ops->mapping_error) - return ops->mapping_error(dev, dma_addr); - - return (dma_addr == DMA_ERROR_CODE); -} - -#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) -#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) -#define dma_is_consistent(d, h) (1) - -static inline void *dma_alloc_coherent(struct device *dev, size_t size, - dma_addr_t *dma_handle, gfp_t flag) -{ - struct dma_map_ops *ops = get_dma_ops(dev); - void *memory; - - BUG_ON(!ops); - - memory = ops->alloc_coherent(dev, size, dma_handle, flag); - - debug_dma_alloc_coherent(dev, size, *dma_handle, memory); - return memory; -} - -static inline void dma_free_coherent(struct device *dev, size_t size, - void *cpu_addr, dma_addr_t dma_handle) -{ - struct dma_map_ops *ops = get_dma_ops(dev); - - BUG_ON(!ops); - debug_dma_free_coherent(dev, size, cpu_addr, dma_handle); - ops->free_coherent(dev, size, cpu_addr, dma_handle); -} - -static inline int dma_get_cache_alignment(void) -{ - return L1_CACHE_BYTES; -} - -static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size, - enum dma_data_direction direction) -{ - BUG_ON(direction == DMA_NONE); - __dma_sync(vaddr, size, (int)direction); -} - -#endif /* _ASM_MICROBLAZE_DMA_MAPPING_H */ +#include diff --git a/trunk/arch/microblaze/include/asm/io.h b/trunk/arch/microblaze/include/asm/io.h index 32d621a56aee..267c7c779e53 100644 --- a/trunk/arch/microblaze/include/asm/io.h +++ b/trunk/arch/microblaze/include/asm/io.h @@ -15,23 +15,7 @@ #include #include #include /* Get struct page {...} */ -#include -#ifndef CONFIG_PCI -#define _IO_BASE 0 -#define _ISA_MEM_BASE 0 -#define PCI_DRAM_OFFSET 0 -#else -#define _IO_BASE isa_io_base -#define _ISA_MEM_BASE isa_mem_base -#define PCI_DRAM_OFFSET pci_dram_offset -#endif - -extern unsigned long isa_io_base; -extern unsigned long pci_io_base; -extern unsigned long pci_dram_offset; - -extern resource_size_t isa_mem_base; #define IO_SPACE_LIMIT (0xFFFFFFFF) @@ -140,6 +124,9 @@ static inline void writel(unsigned int v, volatile void __iomem *addr) #define virt_to_phys(addr) ((unsigned long)__virt_to_phys(addr)) #define virt_to_bus(addr) ((unsigned long)__virt_to_phys(addr)) +#define __page_address(page) \ + (PAGE_OFFSET + (((page) - mem_map) << PAGE_SHIFT)) +#define page_to_phys(page) virt_to_phys((void *)__page_address(page)) #define page_to_bus(page) (page_to_phys(page)) #define bus_to_virt(addr) (phys_to_virt(addr)) @@ -240,7 +227,15 @@ static inline void __iomem *__ioremap(phys_addr_t address, unsigned long size, #define out_8(a, v) __raw_writeb((v), (a)) #define in_8(a) __raw_readb(a) -#define ioport_map(port, nr) ((void __iomem *)(port)) -#define ioport_unmap(addr) +/* FIXME */ +static inline void __iomem *ioport_map(unsigned long port, unsigned int len) +{ + return (void __iomem *) (port); +} + +static inline void ioport_unmap(void __iomem *addr) +{ + /* Nothing to do */ +} #endif /* _ASM_MICROBLAZE_IO_H */ diff --git a/trunk/arch/microblaze/include/asm/irq.h b/trunk/arch/microblaze/include/asm/irq.h index 31a35c33df63..90f050535ebe 100644 --- a/trunk/arch/microblaze/include/asm/irq.h +++ b/trunk/arch/microblaze/include/asm/irq.h @@ -14,12 +14,6 @@ #include -/* This type is the placeholder for a hardware interrupt number. It has to - * be big enough to enclose whatever representation is used by a given - * platform. - */ -typedef unsigned long irq_hw_number_t; - extern unsigned int nr_irq; #define NO_IRQ (-1) @@ -27,8 +21,7 @@ extern unsigned int nr_irq; struct pt_regs; extern void do_IRQ(struct pt_regs *regs); -/** - * irq_of_parse_and_map - Parse and Map an interrupt into linux virq space +/* irq_of_parse_and_map - Parse and Map an interrupt into linux virq space * @device: Device node of the device whose interrupt is to be mapped * @index: Index of the interrupt to map * @@ -47,32 +40,4 @@ static inline void irq_dispose_mapping(unsigned int virq) return; } -struct irq_host; - -/** - * irq_create_mapping - Map a hardware interrupt into linux virq space - * @host: host owning this hardware interrupt or NULL for default host - * @hwirq: hardware irq number in that host space - * - * Only one mapping per hardware interrupt is permitted. Returns a linux - * virq number. - * If the sense/trigger is to be specified, set_irq_type() should be called - * on the number returned from that call. - */ -extern unsigned int irq_create_mapping(struct irq_host *host, - irq_hw_number_t hwirq); - -/** - * irq_create_of_mapping - Map a hardware interrupt into linux virq space - * @controller: Device node of the interrupt controller - * @inspec: Interrupt specifier from the device-tree - * @intsize: Size of the interrupt specifier from the device-tree - * - * This function is identical to irq_create_mapping except that it takes - * as input informations straight from the device-tree (typically the results - * of the of_irq_map_*() functions. - */ -extern unsigned int irq_create_of_mapping(struct device_node *controller, - u32 *intspec, unsigned int intsize); - #endif /* _ASM_MICROBLAZE_IRQ_H */ diff --git a/trunk/arch/microblaze/include/asm/page.h b/trunk/arch/microblaze/include/asm/page.h index 2dd1d04129e0..9b66c0fa9a32 100644 --- a/trunk/arch/microblaze/include/asm/page.h +++ b/trunk/arch/microblaze/include/asm/page.h @@ -61,6 +61,12 @@ extern unsigned int __page_offset; */ #define PAGE_OFFSET CONFIG_KERNEL_START +/* + * MAP_NR -- given an address, calculate the index of the page struct which + * points to the address's page. + */ +#define MAP_NR(addr) (((unsigned long)(addr) - PAGE_OFFSET) >> PAGE_SHIFT) + /* * The basic type of a PTE - 32 bit physical addressing. */ @@ -148,11 +154,7 @@ extern int page_is_ram(unsigned long pfn); # define pfn_to_virt(pfn) __va(pfn_to_phys((pfn))) # ifdef CONFIG_MMU - -# define virt_to_page(kaddr) (pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)) -# define page_to_virt(page) __va(page_to_pfn(page) << PAGE_SHIFT) -# define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) - +# define virt_to_page(kaddr) (mem_map + MAP_NR(kaddr)) # else /* CONFIG_MMU */ # define virt_to_page(vaddr) (pfn_to_page(virt_to_pfn(vaddr))) # define page_to_virt(page) (pfn_to_virt(page_to_pfn(page))) diff --git a/trunk/arch/microblaze/include/asm/pci-bridge.h b/trunk/arch/microblaze/include/asm/pci-bridge.h index 0c77cda9f5d8..7ad28f6f5f1a 100644 --- a/trunk/arch/microblaze/include/asm/pci-bridge.h +++ b/trunk/arch/microblaze/include/asm/pci-bridge.h @@ -1,196 +1 @@ -#ifndef _ASM_MICROBLAZE_PCI_BRIDGE_H -#define _ASM_MICROBLAZE_PCI_BRIDGE_H -#ifdef __KERNEL__ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. - */ #include -#include -#include - -struct device_node; - -enum { - /* Force re-assigning all resources (ignore firmware - * setup completely) - */ - PCI_REASSIGN_ALL_RSRC = 0x00000001, - - /* Re-assign all bus numbers */ - PCI_REASSIGN_ALL_BUS = 0x00000002, - - /* Do not try to assign, just use existing setup */ - PCI_PROBE_ONLY = 0x00000004, - - /* Don't bother with ISA alignment unless the bridge has - * ISA forwarding enabled - */ - PCI_CAN_SKIP_ISA_ALIGN = 0x00000008, - - /* Enable domain numbers in /proc */ - PCI_ENABLE_PROC_DOMAINS = 0x00000010, - /* ... except for domain 0 */ - PCI_COMPAT_DOMAIN_0 = 0x00000020, -}; - -/* - * Structure of a PCI controller (host bridge) - */ -struct pci_controller { - struct pci_bus *bus; - char is_dynamic; - struct device_node *dn; - struct list_head list_node; - struct device *parent; - - int first_busno; - int last_busno; - - int self_busno; - - void __iomem *io_base_virt; - resource_size_t io_base_phys; - - resource_size_t pci_io_size; - - /* Some machines (PReP) have a non 1:1 mapping of - * the PCI memory space in the CPU bus space - */ - resource_size_t pci_mem_offset; - - /* Some machines have a special region to forward the ISA - * "memory" cycles such as VGA memory regions. Left to 0 - * if unsupported - */ - resource_size_t isa_mem_phys; - resource_size_t isa_mem_size; - - struct pci_ops *ops; - unsigned int __iomem *cfg_addr; - void __iomem *cfg_data; - - /* - * Used for variants of PCI indirect handling and possible quirks: - * SET_CFG_TYPE - used on 4xx or any PHB that does explicit type0/1 - * EXT_REG - provides access to PCI-e extended registers - * SURPRESS_PRIMARY_BUS - we surpress the setting of PCI_PRIMARY_BUS - * on Freescale PCI-e controllers since they used the PCI_PRIMARY_BUS - * to determine which bus number to match on when generating type0 - * config cycles - * NO_PCIE_LINK - the Freescale PCI-e controllers have issues with - * hanging if we don't have link and try to do config cycles to - * anything but the PHB. Only allow talking to the PHB if this is - * set. - * BIG_ENDIAN - cfg_addr is a big endian register - * BROKEN_MRM - the 440EPx/GRx chips have an errata that causes hangs - * on the PLB4. Effectively disable MRM commands by setting this. - */ -#define INDIRECT_TYPE_SET_CFG_TYPE 0x00000001 -#define INDIRECT_TYPE_EXT_REG 0x00000002 -#define INDIRECT_TYPE_SURPRESS_PRIMARY_BUS 0x00000004 -#define INDIRECT_TYPE_NO_PCIE_LINK 0x00000008 -#define INDIRECT_TYPE_BIG_ENDIAN 0x00000010 -#define INDIRECT_TYPE_BROKEN_MRM 0x00000020 - u32 indirect_type; - - /* Currently, we limit ourselves to 1 IO range and 3 mem - * ranges since the common pci_bus structure can't handle more - */ - struct resource io_resource; - struct resource mem_resources[3]; - int global_number; /* PCI domain number */ -}; - -static inline struct pci_controller *pci_bus_to_host(const struct pci_bus *bus) -{ - return bus->sysdata; -} - -static inline int isa_vaddr_is_ioport(void __iomem *address) -{ - /* No specific ISA handling on ppc32 at this stage, it - * all goes through PCI - */ - return 0; -} - -/* These are used for config access before all the PCI probing - has been done. */ -extern int early_read_config_byte(struct pci_controller *hose, int bus, - int dev_fn, int where, u8 *val); -extern int early_read_config_word(struct pci_controller *hose, int bus, - int dev_fn, int where, u16 *val); -extern int early_read_config_dword(struct pci_controller *hose, int bus, - int dev_fn, int where, u32 *val); -extern int early_write_config_byte(struct pci_controller *hose, int bus, - int dev_fn, int where, u8 val); -extern int early_write_config_word(struct pci_controller *hose, int bus, - int dev_fn, int where, u16 val); -extern int early_write_config_dword(struct pci_controller *hose, int bus, - int dev_fn, int where, u32 val); - -extern int early_find_capability(struct pci_controller *hose, int bus, - int dev_fn, int cap); - -extern void setup_indirect_pci(struct pci_controller *hose, - resource_size_t cfg_addr, - resource_size_t cfg_data, u32 flags); - -/* Get the PCI host controller for an OF device */ -extern struct pci_controller *pci_find_hose_for_OF_device( - struct device_node *node); - -/* Fill up host controller resources from the OF node */ -extern void pci_process_bridge_OF_ranges(struct pci_controller *hose, - struct device_node *dev, int primary); - -/* Allocate & free a PCI host bridge structure */ -extern struct pci_controller *pcibios_alloc_controller(struct device_node *dev); -extern void pcibios_free_controller(struct pci_controller *phb); -extern void pcibios_setup_phb_resources(struct pci_controller *hose); - -#ifdef CONFIG_PCI -extern unsigned int pci_flags; - -static inline void pci_set_flags(int flags) -{ - pci_flags = flags; -} - -static inline void pci_add_flags(int flags) -{ - pci_flags |= flags; -} - -static inline int pci_has_flag(int flag) -{ - return pci_flags & flag; -} - -extern struct list_head hose_list; - -extern unsigned long pci_address_to_pio(phys_addr_t address); -extern int pcibios_vaddr_is_ioport(void __iomem *address); -#else -static inline unsigned long pci_address_to_pio(phys_addr_t address) -{ - return (unsigned long)-1; -} -static inline int pcibios_vaddr_is_ioport(void __iomem *address) -{ - return 0; -} - -static inline void pci_set_flags(int flags) { } -static inline void pci_add_flags(int flags) { } -static inline int pci_has_flag(int flag) -{ - return 0; -} -#endif /* CONFIG_PCI */ - -#endif /* __KERNEL__ */ -#endif /* _ASM_MICROBLAZE_PCI_BRIDGE_H */ diff --git a/trunk/arch/microblaze/include/asm/pci.h b/trunk/arch/microblaze/include/asm/pci.h index bdd65aaee30d..9f0df5faf2c8 100644 --- a/trunk/arch/microblaze/include/asm/pci.h +++ b/trunk/arch/microblaze/include/asm/pci.h @@ -1,177 +1 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. - * - * Based on powerpc version - */ - -#ifndef __ASM_MICROBLAZE_PCI_H -#define __ASM_MICROBLAZE_PCI_H -#ifdef __KERNEL__ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#define PCIBIOS_MIN_IO 0x1000 -#define PCIBIOS_MIN_MEM 0x10000000 - -struct pci_dev; - -/* Values for the `which' argument to sys_pciconfig_iobase syscall. */ -#define IOBASE_BRIDGE_NUMBER 0 -#define IOBASE_MEMORY 1 -#define IOBASE_IO 2 -#define IOBASE_ISA_IO 3 -#define IOBASE_ISA_MEM 4 - -#define pcibios_scan_all_fns(a, b) 0 - -/* - * Set this to 1 if you want the kernel to re-assign all PCI - * bus numbers (don't do that on ppc64 yet !) - */ -#define pcibios_assign_all_busses() \ - (pci_has_flag(PCI_REASSIGN_ALL_BUS)) - -static inline void pcibios_set_master(struct pci_dev *dev) -{ - /* No special bus mastering setup handling */ -} - -static inline void pcibios_penalize_isa_irq(int irq, int active) -{ - /* We don't do dynamic PCI IRQ allocation */ -} - -#ifdef CONFIG_PCI -extern void set_pci_dma_ops(struct dma_map_ops *dma_ops); -extern struct dma_map_ops *get_pci_dma_ops(void); -#else /* CONFIG_PCI */ -#define set_pci_dma_ops(d) -#define get_pci_dma_ops() NULL -#endif - -#ifdef CONFIG_PCI -static inline void pci_dma_burst_advice(struct pci_dev *pdev, - enum pci_dma_burst_strategy *strat, - unsigned long *strategy_parameter) -{ - *strat = PCI_DMA_BURST_INFINITY; - *strategy_parameter = ~0UL; -} -#endif - -extern int pci_domain_nr(struct pci_bus *bus); - -/* Decide whether to display the domain number in /proc */ -extern int pci_proc_domain(struct pci_bus *bus); - -struct vm_area_struct; -/* Map a range of PCI memory or I/O space for a device into user space */ -int pci_mmap_page_range(struct pci_dev *pdev, struct vm_area_struct *vma, - enum pci_mmap_state mmap_state, int write_combine); - -/* Tell drivers/pci/proc.c that we have pci_mmap_page_range() */ -#define HAVE_PCI_MMAP 1 - -extern int pci_legacy_read(struct pci_bus *bus, loff_t port, u32 *val, - size_t count); -extern int pci_legacy_write(struct pci_bus *bus, loff_t port, u32 val, - size_t count); -extern int pci_mmap_legacy_page_range(struct pci_bus *bus, - struct vm_area_struct *vma, - enum pci_mmap_state mmap_state); - -#define HAVE_PCI_LEGACY 1 - -/* pci_unmap_{page,single} is a nop so... */ -#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) -#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) -#define pci_unmap_addr(PTR, ADDR_NAME) (0) -#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0) -#define pci_unmap_len(PTR, LEN_NAME) (0) -#define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0) - -/* The PCI address space does equal the physical memory - * address space (no IOMMU). The IDE and SCSI device layers use - * this boolean for bounce buffer decisions. - */ -#define PCI_DMA_BUS_IS_PHYS (1) - -extern void pcibios_resource_to_bus(struct pci_dev *dev, - struct pci_bus_region *region, - struct resource *res); - -extern void pcibios_bus_to_resource(struct pci_dev *dev, - struct resource *res, - struct pci_bus_region *region); - -static inline struct resource *pcibios_select_root(struct pci_dev *pdev, - struct resource *res) -{ - struct resource *root = NULL; - - if (res->flags & IORESOURCE_IO) - root = &ioport_resource; - if (res->flags & IORESOURCE_MEM) - root = &iomem_resource; - - return root; -} - -extern void pcibios_claim_one_bus(struct pci_bus *b); - -extern void pcibios_finish_adding_to_bus(struct pci_bus *bus); - -extern void pcibios_resource_survey(void); - -extern struct pci_controller *init_phb_dynamic(struct device_node *dn); -extern int remove_phb_dynamic(struct pci_controller *phb); - -extern struct pci_dev *of_create_pci_dev(struct device_node *node, - struct pci_bus *bus, int devfn); - -extern void of_scan_pci_bridge(struct device_node *node, - struct pci_dev *dev); - -extern void of_scan_bus(struct device_node *node, struct pci_bus *bus); -extern void of_rescan_bus(struct device_node *node, struct pci_bus *bus); - -extern int pci_read_irq_line(struct pci_dev *dev); - -extern int pci_bus_find_capability(struct pci_bus *bus, - unsigned int devfn, int cap); - -struct file; -extern pgprot_t pci_phys_mem_access_prot(struct file *file, - unsigned long pfn, - unsigned long size, - pgprot_t prot); - -#define HAVE_ARCH_PCI_RESOURCE_TO_USER -extern void pci_resource_to_user(const struct pci_dev *dev, int bar, - const struct resource *rsrc, - resource_size_t *start, resource_size_t *end); - -extern void pcibios_setup_bus_devices(struct pci_bus *bus); -extern void pcibios_setup_bus_self(struct pci_bus *bus); - -/* This part of code was originaly in xilinx-pci.h */ -#ifdef CONFIG_PCI_XILINX -extern void __init xilinx_pci_init(void); -#else -static inline void __init xilinx_pci_init(void) { return; } -#endif - -#endif /* __KERNEL__ */ -#endif /* __ASM_MICROBLAZE_PCI_H */ +#include diff --git a/trunk/arch/microblaze/include/asm/pgalloc.h b/trunk/arch/microblaze/include/asm/pgalloc.h index f44b0d696fe2..7547f5064560 100644 --- a/trunk/arch/microblaze/include/asm/pgalloc.h +++ b/trunk/arch/microblaze/include/asm/pgalloc.h @@ -19,7 +19,6 @@ #include #include #include -#include #define PGDIR_ORDER 0 @@ -112,6 +111,7 @@ static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address) { pte_t *pte; + extern int mem_init_done; extern void *early_get_page(void); if (mem_init_done) { pte = (pte_t *)__get_free_page(GFP_KERNEL | diff --git a/trunk/arch/microblaze/include/asm/pgtable.h b/trunk/arch/microblaze/include/asm/pgtable.h index dd2bb60651c7..cc3a4dfc3eaa 100644 --- a/trunk/arch/microblaze/include/asm/pgtable.h +++ b/trunk/arch/microblaze/include/asm/pgtable.h @@ -16,10 +16,6 @@ #define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \ remap_pfn_range(vma, vaddr, pfn, size, prot) -#ifndef __ASSEMBLY__ -extern int mem_init_done; -#endif - #ifndef CONFIG_MMU #define pgd_present(pgd) (1) /* pages are always present on non MMU */ @@ -55,8 +51,6 @@ static inline int pte_file(pte_t pte) { return 0; } #define arch_enter_lazy_cpu_mode() do {} while (0) -#define pgprot_noncached_wc(prot) prot - #else /* CONFIG_MMU */ #include @@ -74,6 +68,7 @@ static inline int pte_file(pte_t pte) { return 0; } extern unsigned long va_to_phys(unsigned long address); extern pte_t *va_to_pte(unsigned long address); +extern unsigned long ioremap_bot, ioremap_base; /* * The following only work if pte_present() is true. @@ -90,24 +85,10 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; } #define VMALLOC_START (CONFIG_KERNEL_START + \ max(32 * 1024 * 1024UL, memory_size)) #define VMALLOC_END ioremap_bot +#define VMALLOC_VMADDR(x) ((unsigned long)(x)) #endif /* __ASSEMBLY__ */ -/* - * Macro to mark a page protection value as "uncacheable". - */ - -#define _PAGE_CACHE_CTL (_PAGE_GUARDED | _PAGE_NO_CACHE | \ - _PAGE_WRITETHRU) - -#define pgprot_noncached(prot) \ - (__pgprot((pgprot_val(prot) & ~_PAGE_CACHE_CTL) | \ - _PAGE_NO_CACHE | _PAGE_GUARDED)) - -#define pgprot_noncached_wc(prot) \ - (__pgprot((pgprot_val(prot) & ~_PAGE_CACHE_CTL) | \ - _PAGE_NO_CACHE)) - /* * The MicroBlaze MMU is identical to the PPC-40x MMU, and uses a hash * table containing PTEs, together with a set of 16 segment registers, to @@ -416,7 +397,7 @@ static inline unsigned long pte_update(pte_t *p, unsigned long clr, mts rmsr, %2\n\ nop" : "=&r" (old), "=&r" (tmp), "=&r" (msr), "=m" (*p) - : "r" ((unsigned long)(p + 1) - 4), "r" (clr), "r" (set), "m" (*p) + : "r" ((unsigned long)(p+1) - 4), "r" (clr), "r" (set), "m" (*p) : "cc"); return old; @@ -585,11 +566,18 @@ void mapin_ram(void); int map_page(unsigned long va, phys_addr_t pa, int flags); extern int mem_init_done; +extern unsigned long ioremap_base; +extern unsigned long ioremap_bot; asmlinkage void __init mmu_init(void); void __init *early_get_page(void); +void *consistent_alloc(int gfp, size_t size, dma_addr_t *dma_handle); +void consistent_free(void *vaddr); +void consistent_sync(void *vaddr, size_t size, int direction); +void consistent_sync_page(struct page *page, unsigned long offset, + size_t size, int direction); #endif /* __ASSEMBLY__ */ #endif /* __KERNEL__ */ @@ -598,14 +586,6 @@ void __init *early_get_page(void); #ifndef __ASSEMBLY__ #include -extern unsigned long ioremap_bot, ioremap_base; - -void *consistent_alloc(int gfp, size_t size, dma_addr_t *dma_handle); -void consistent_free(void *vaddr); -void consistent_sync(void *vaddr, size_t size, int direction); -void consistent_sync_page(struct page *page, unsigned long offset, - size_t size, int direction); - void setup_memory(void); #endif /* __ASSEMBLY__ */ diff --git a/trunk/arch/microblaze/include/asm/prom.h b/trunk/arch/microblaze/include/asm/prom.h index e7d67a329bd7..03f45a963204 100644 --- a/trunk/arch/microblaze/include/asm/prom.h +++ b/trunk/arch/microblaze/include/asm/prom.h @@ -31,21 +31,6 @@ /* Other Prototypes */ extern int early_uartlite_console(void); -#ifdef CONFIG_PCI -/* - * PCI <-> OF matching functions - * (XXX should these be here?) - */ -struct pci_bus; -struct pci_dev; -extern int pci_device_from_OF_node(struct device_node *node, - u8 *bus, u8 *devfn); -extern struct device_node *pci_busdev_to_OF_node(struct pci_bus *bus, - int devfn); -extern struct device_node *pci_device_to_OF_node(struct pci_dev *dev); -extern void pci_create_OF_bus_map(void); -#endif - /* * OF address retreival & translation */ diff --git a/trunk/arch/microblaze/include/asm/system.h b/trunk/arch/microblaze/include/asm/system.h index 59efb3fef957..157970688b2a 100644 --- a/trunk/arch/microblaze/include/asm/system.h +++ b/trunk/arch/microblaze/include/asm/system.h @@ -87,9 +87,6 @@ void free_initmem(void); extern char *klimit; extern void ret_from_fork(void); -extern void *alloc_maybe_bootmem(size_t size, gfp_t mask); -extern void *zalloc_maybe_bootmem(size_t size, gfp_t mask); - #ifdef CONFIG_DEBUG_FS extern struct dentry *of_debugfs_root; #endif diff --git a/trunk/arch/microblaze/include/asm/tlbflush.h b/trunk/arch/microblaze/include/asm/tlbflush.h index bcb8b41d55af..10ec70cd8735 100644 --- a/trunk/arch/microblaze/include/asm/tlbflush.h +++ b/trunk/arch/microblaze/include/asm/tlbflush.h @@ -23,7 +23,7 @@ extern void _tlbie(unsigned long address); extern void _tlbia(void); -#define __tlbia() { preempt_disable(); _tlbia(); preempt_enable(); } +#define __tlbia() _tlbia() static inline void local_flush_tlb_all(void) { __tlbia(); } diff --git a/trunk/arch/microblaze/kernel/Makefile b/trunk/arch/microblaze/kernel/Makefile index e51bc1520825..b07594eccf9b 100644 --- a/trunk/arch/microblaze/kernel/Makefile +++ b/trunk/arch/microblaze/kernel/Makefile @@ -14,7 +14,7 @@ endif extra-y := head.o vmlinux.lds -obj-y += dma.o exceptions.o \ +obj-y += exceptions.o \ hw_exception_handler.o init_task.o intc.o irq.o of_device.o \ of_platform.o process.o prom.o prom_parse.o ptrace.o \ setup.o signal.o sys_microblaze.o timer.o traps.o reset.o diff --git a/trunk/arch/microblaze/kernel/asm-offsets.c b/trunk/arch/microblaze/kernel/asm-offsets.c index 0071260a672c..7bc7b68f97db 100644 --- a/trunk/arch/microblaze/kernel/asm-offsets.c +++ b/trunk/arch/microblaze/kernel/asm-offsets.c @@ -90,7 +90,6 @@ int main(int argc, char *argv[]) DEFINE(TI_FLAGS, offsetof(struct thread_info, flags)); DEFINE(TI_ADDR_LIMIT, offsetof(struct thread_info, addr_limit)); DEFINE(TI_CPU_CONTEXT, offsetof(struct thread_info, cpu_context)); - DEFINE(TI_PREEMPT_COUNT, offsetof(struct thread_info, preempt_count)); BLANK(); /* struct cpu_context */ diff --git a/trunk/arch/microblaze/kernel/cpu/cache.c b/trunk/arch/microblaze/kernel/cpu/cache.c index f04d8a86dead..2a56bccce4e0 100644 --- a/trunk/arch/microblaze/kernel/cpu/cache.c +++ b/trunk/arch/microblaze/kernel/cpu/cache.c @@ -15,6 +15,25 @@ #include #include +static inline void __invalidate_flush_icache(unsigned int addr) +{ + __asm__ __volatile__ ("wic %0, r0;" \ + : : "r" (addr)); +} + +static inline void __flush_dcache(unsigned int addr) +{ + __asm__ __volatile__ ("wdc.flush %0, r0;" \ + : : "r" (addr)); +} + +static inline void __invalidate_dcache(unsigned int baseaddr, + unsigned int offset) +{ + __asm__ __volatile__ ("wdc.clear %0, %1;" \ + : : "r" (baseaddr), "r" (offset)); +} + static inline void __enable_icache_msr(void) { __asm__ __volatile__ (" msrset r0, %0; \ @@ -129,9 +148,9 @@ do { \ int step = -line_length; \ BUG_ON(step >= 0); \ \ - __asm__ __volatile__ (" 1: " #op " r0, %0; \ - bgtid %0, 1b; \ - addk %0, %0, %1; \ + __asm__ __volatile__ (" 1: " #op " r0, %0; \ + bgtid %0, 1b; \ + addk %0, %0, %1; \ " : : "r" (len), "r" (step) \ : "memory"); \ } while (0); @@ -143,9 +162,9 @@ do { \ int count = end - start; \ BUG_ON(count <= 0); \ \ - __asm__ __volatile__ (" 1: " #op " %0, %1; \ - bgtid %1, 1b; \ - addk %1, %1, %2; \ + __asm__ __volatile__ (" 1: " #op " %0, %1; \ + bgtid %1, 1b; \ + addk %1, %1, %2; \ " : : "r" (start), "r" (count), \ "r" (step) : "memory"); \ } while (0); @@ -156,7 +175,7 @@ do { \ int volatile temp; \ BUG_ON(end - start <= 0); \ \ - __asm__ __volatile__ (" 1: " #op " %1, r0; \ + __asm__ __volatile__ (" 1: " #op " %1, r0; \ cmpu %0, %1, %2; \ bgtid %0, 1b; \ addk %1, %1, %3; \ @@ -164,14 +183,10 @@ do { \ "r" (line_length) : "memory"); \ } while (0); -#define ASM_LOOP - static void __flush_icache_range_msr_irq(unsigned long start, unsigned long end) { unsigned long flags; -#ifndef ASM_LOOP - int i; -#endif + pr_debug("%s: start 0x%x, end 0x%x\n", __func__, (unsigned int)start, (unsigned int) end); @@ -181,13 +196,8 @@ static void __flush_icache_range_msr_irq(unsigned long start, unsigned long end) local_irq_save(flags); __disable_icache_msr(); -#ifdef ASM_LOOP CACHE_RANGE_LOOP_1(start, end, cpuinfo.icache_line_length, wic); -#else - for (i = start; i < end; i += cpuinfo.icache_line_length) - __asm__ __volatile__ ("wic %0, r0;" \ - : : "r" (i)); -#endif + __enable_icache_msr(); local_irq_restore(flags); } @@ -196,9 +206,7 @@ static void __flush_icache_range_nomsr_irq(unsigned long start, unsigned long end) { unsigned long flags; -#ifndef ASM_LOOP - int i; -#endif + pr_debug("%s: start 0x%x, end 0x%x\n", __func__, (unsigned int)start, (unsigned int) end); @@ -208,13 +216,7 @@ static void __flush_icache_range_nomsr_irq(unsigned long start, local_irq_save(flags); __disable_icache_nomsr(); -#ifdef ASM_LOOP CACHE_RANGE_LOOP_1(start, end, cpuinfo.icache_line_length, wic); -#else - for (i = start; i < end; i += cpuinfo.icache_line_length) - __asm__ __volatile__ ("wic %0, r0;" \ - : : "r" (i)); -#endif __enable_icache_nomsr(); local_irq_restore(flags); @@ -223,41 +225,25 @@ static void __flush_icache_range_nomsr_irq(unsigned long start, static void __flush_icache_range_noirq(unsigned long start, unsigned long end) { -#ifndef ASM_LOOP - int i; -#endif pr_debug("%s: start 0x%x, end 0x%x\n", __func__, (unsigned int)start, (unsigned int) end); CACHE_LOOP_LIMITS(start, end, cpuinfo.icache_line_length, cpuinfo.icache_size); -#ifdef ASM_LOOP CACHE_RANGE_LOOP_1(start, end, cpuinfo.icache_line_length, wic); -#else - for (i = start; i < end; i += cpuinfo.icache_line_length) - __asm__ __volatile__ ("wic %0, r0;" \ - : : "r" (i)); -#endif } static void __flush_icache_all_msr_irq(void) { unsigned long flags; -#ifndef ASM_LOOP - int i; -#endif + pr_debug("%s\n", __func__); local_irq_save(flags); __disable_icache_msr(); -#ifdef ASM_LOOP + CACHE_ALL_LOOP(cpuinfo.icache_size, cpuinfo.icache_line_length, wic); -#else - for (i = 0; i < cpuinfo.icache_size; - i += cpuinfo.icache_line_length) - __asm__ __volatile__ ("wic %0, r0;" \ - : : "r" (i)); -#endif + __enable_icache_msr(); local_irq_restore(flags); } @@ -265,59 +251,35 @@ static void __flush_icache_all_msr_irq(void) static void __flush_icache_all_nomsr_irq(void) { unsigned long flags; -#ifndef ASM_LOOP - int i; -#endif + pr_debug("%s\n", __func__); local_irq_save(flags); __disable_icache_nomsr(); -#ifdef ASM_LOOP + CACHE_ALL_LOOP(cpuinfo.icache_size, cpuinfo.icache_line_length, wic); -#else - for (i = 0; i < cpuinfo.icache_size; - i += cpuinfo.icache_line_length) - __asm__ __volatile__ ("wic %0, r0;" \ - : : "r" (i)); -#endif + __enable_icache_nomsr(); local_irq_restore(flags); } static void __flush_icache_all_noirq(void) { -#ifndef ASM_LOOP - int i; -#endif pr_debug("%s\n", __func__); -#ifdef ASM_LOOP CACHE_ALL_LOOP(cpuinfo.icache_size, cpuinfo.icache_line_length, wic); -#else - for (i = 0; i < cpuinfo.icache_size; - i += cpuinfo.icache_line_length) - __asm__ __volatile__ ("wic %0, r0;" \ - : : "r" (i)); -#endif } static void __invalidate_dcache_all_msr_irq(void) { unsigned long flags; -#ifndef ASM_LOOP - int i; -#endif + pr_debug("%s\n", __func__); local_irq_save(flags); __disable_dcache_msr(); -#ifdef ASM_LOOP + CACHE_ALL_LOOP(cpuinfo.dcache_size, cpuinfo.dcache_line_length, wdc); -#else - for (i = 0; i < cpuinfo.dcache_size; - i += cpuinfo.dcache_line_length) - __asm__ __volatile__ ("wdc %0, r0;" \ - : : "r" (i)); -#endif + __enable_dcache_msr(); local_irq_restore(flags); } @@ -325,107 +287,60 @@ static void __invalidate_dcache_all_msr_irq(void) static void __invalidate_dcache_all_nomsr_irq(void) { unsigned long flags; -#ifndef ASM_LOOP - int i; -#endif + pr_debug("%s\n", __func__); local_irq_save(flags); __disable_dcache_nomsr(); -#ifdef ASM_LOOP + CACHE_ALL_LOOP(cpuinfo.dcache_size, cpuinfo.dcache_line_length, wdc); -#else - for (i = 0; i < cpuinfo.dcache_size; - i += cpuinfo.dcache_line_length) - __asm__ __volatile__ ("wdc %0, r0;" \ - : : "r" (i)); -#endif + __enable_dcache_nomsr(); local_irq_restore(flags); } static void __invalidate_dcache_all_noirq_wt(void) { -#ifndef ASM_LOOP - int i; -#endif pr_debug("%s\n", __func__); -#ifdef ASM_LOOP CACHE_ALL_LOOP(cpuinfo.dcache_size, cpuinfo.dcache_line_length, wdc) -#else - for (i = 0; i < cpuinfo.dcache_size; - i += cpuinfo.dcache_line_length) - __asm__ __volatile__ ("wdc %0, r0;" \ - : : "r" (i)); -#endif } /* FIXME this is weird - should be only wdc but not work * MS: I am getting bus errors and other weird things */ static void __invalidate_dcache_all_wb(void) { -#ifndef ASM_LOOP - int i; -#endif pr_debug("%s\n", __func__); -#ifdef ASM_LOOP CACHE_ALL_LOOP2(cpuinfo.dcache_size, cpuinfo.dcache_line_length, wdc.clear) -#else - for (i = 0; i < cpuinfo.dcache_size; - i += cpuinfo.dcache_line_length) - __asm__ __volatile__ ("wdc.clear %0, r0;" \ - : : "r" (i)); -#endif } static void __invalidate_dcache_range_wb(unsigned long start, unsigned long end) { -#ifndef ASM_LOOP - int i; -#endif pr_debug("%s: start 0x%x, end 0x%x\n", __func__, (unsigned int)start, (unsigned int) end); CACHE_LOOP_LIMITS(start, end, cpuinfo.dcache_line_length, cpuinfo.dcache_size); -#ifdef ASM_LOOP CACHE_RANGE_LOOP_2(start, end, cpuinfo.dcache_line_length, wdc.clear); -#else - for (i = start; i < end; i += cpuinfo.icache_line_length) - __asm__ __volatile__ ("wdc.clear %0, r0;" \ - : : "r" (i)); -#endif } static void __invalidate_dcache_range_nomsr_wt(unsigned long start, unsigned long end) { -#ifndef ASM_LOOP - int i; -#endif pr_debug("%s: start 0x%x, end 0x%x\n", __func__, (unsigned int)start, (unsigned int) end); CACHE_LOOP_LIMITS(start, end, cpuinfo.dcache_line_length, cpuinfo.dcache_size); -#ifdef ASM_LOOP CACHE_RANGE_LOOP_1(start, end, cpuinfo.dcache_line_length, wdc); -#else - for (i = start; i < end; i += cpuinfo.icache_line_length) - __asm__ __volatile__ ("wdc %0, r0;" \ - : : "r" (i)); -#endif } static void __invalidate_dcache_range_msr_irq_wt(unsigned long start, unsigned long end) { unsigned long flags; -#ifndef ASM_LOOP - int i; -#endif + pr_debug("%s: start 0x%x, end 0x%x\n", __func__, (unsigned int)start, (unsigned int) end); CACHE_LOOP_LIMITS(start, end, @@ -434,13 +349,7 @@ static void __invalidate_dcache_range_msr_irq_wt(unsigned long start, local_irq_save(flags); __disable_dcache_msr(); -#ifdef ASM_LOOP CACHE_RANGE_LOOP_1(start, end, cpuinfo.dcache_line_length, wdc); -#else - for (i = start; i < end; i += cpuinfo.icache_line_length) - __asm__ __volatile__ ("wdc %0, r0;" \ - : : "r" (i)); -#endif __enable_dcache_msr(); local_irq_restore(flags); @@ -450,9 +359,7 @@ static void __invalidate_dcache_range_nomsr_irq(unsigned long start, unsigned long end) { unsigned long flags; -#ifndef ASM_LOOP - int i; -#endif + pr_debug("%s: start 0x%x, end 0x%x\n", __func__, (unsigned int)start, (unsigned int) end); @@ -462,13 +369,7 @@ static void __invalidate_dcache_range_nomsr_irq(unsigned long start, local_irq_save(flags); __disable_dcache_nomsr(); -#ifdef ASM_LOOP CACHE_RANGE_LOOP_1(start, end, cpuinfo.dcache_line_length, wdc); -#else - for (i = start; i < end; i += cpuinfo.icache_line_length) - __asm__ __volatile__ ("wdc %0, r0;" \ - : : "r" (i)); -#endif __enable_dcache_nomsr(); local_irq_restore(flags); @@ -476,38 +377,19 @@ static void __invalidate_dcache_range_nomsr_irq(unsigned long start, static void __flush_dcache_all_wb(void) { -#ifndef ASM_LOOP - int i; -#endif pr_debug("%s\n", __func__); -#ifdef ASM_LOOP CACHE_ALL_LOOP(cpuinfo.dcache_size, cpuinfo.dcache_line_length, wdc.flush); -#else - for (i = 0; i < cpuinfo.dcache_size; - i += cpuinfo.dcache_line_length) - __asm__ __volatile__ ("wdc.flush %0, r0;" \ - : : "r" (i)); -#endif } static void __flush_dcache_range_wb(unsigned long start, unsigned long end) { -#ifndef ASM_LOOP - int i; -#endif pr_debug("%s: start 0x%x, end 0x%x\n", __func__, (unsigned int)start, (unsigned int) end); CACHE_LOOP_LIMITS(start, end, cpuinfo.dcache_line_length, cpuinfo.dcache_size); -#ifdef ASM_LOOP CACHE_RANGE_LOOP_2(start, end, cpuinfo.dcache_line_length, wdc.flush); -#else - for (i = start; i < end; i += cpuinfo.icache_line_length) - __asm__ __volatile__ ("wdc.flush %0, r0;" \ - : : "r" (i)); -#endif } /* struct for wb caches and for wt caches */ @@ -611,7 +493,7 @@ const struct scache wt_nomsr_noirq = { #define CPUVER_7_20_A 0x0c #define CPUVER_7_20_D 0x0f -#define INFO(s) printk(KERN_INFO "cache: " s "\n"); +#define INFO(s) printk(KERN_INFO "cache: " s " \n"); void microblaze_cache_init(void) { @@ -650,9 +532,4 @@ void microblaze_cache_init(void) } } } - invalidate_dcache(); - enable_dcache(); - - invalidate_icache(); - enable_icache(); } diff --git a/trunk/arch/microblaze/kernel/dma.c b/trunk/arch/microblaze/kernel/dma.c deleted file mode 100644 index b1084974fccd..000000000000 --- a/trunk/arch/microblaze/kernel/dma.c +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (C) 2009-2010 PetaLogix - * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corporation - * - * Provide default implementations of the DMA mapping callbacks for - * directly mapped busses. - */ - -#include -#include -#include -#include -#include - -/* - * Generic direct DMA implementation - * - * This implementation supports a per-device offset that can be applied if - * the address at which memory is visible to devices is not 0. Platform code - * can set archdata.dma_data to an unsigned long holding the offset. By - * default the offset is PCI_DRAM_OFFSET. - */ -static inline void __dma_sync_page(unsigned long paddr, unsigned long offset, - size_t size, enum dma_data_direction direction) -{ - switch (direction) { - case DMA_TO_DEVICE: - flush_dcache_range(paddr + offset, paddr + offset + size); - break; - case DMA_FROM_DEVICE: - invalidate_dcache_range(paddr + offset, paddr + offset + size); - break; - default: - BUG(); - } -} - -static unsigned long get_dma_direct_offset(struct device *dev) -{ - if (dev) - return (unsigned long)dev->archdata.dma_data; - - return PCI_DRAM_OFFSET; /* FIXME Not sure if is correct */ -} - -#define NOT_COHERENT_CACHE - -static void *dma_direct_alloc_coherent(struct device *dev, size_t size, - dma_addr_t *dma_handle, gfp_t flag) -{ -#ifdef NOT_COHERENT_CACHE - return consistent_alloc(flag, size, dma_handle); -#else - void *ret; - struct page *page; - int node = dev_to_node(dev); - - /* ignore region specifiers */ - flag &= ~(__GFP_HIGHMEM); - - page = alloc_pages_node(node, flag, get_order(size)); - if (page == NULL) - return NULL; - ret = page_address(page); - memset(ret, 0, size); - *dma_handle = virt_to_phys(ret) + get_dma_direct_offset(dev); - - return ret; -#endif -} - -static void dma_direct_free_coherent(struct device *dev, size_t size, - void *vaddr, dma_addr_t dma_handle) -{ -#ifdef NOT_COHERENT_CACHE - consistent_free(vaddr); -#else - free_pages((unsigned long)vaddr, get_order(size)); -#endif -} - -static int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, - int nents, enum dma_data_direction direction, - struct dma_attrs *attrs) -{ - struct scatterlist *sg; - int i; - - /* FIXME this part of code is untested */ - for_each_sg(sgl, sg, nents, i) { - sg->dma_address = sg_phys(sg) + get_dma_direct_offset(dev); - sg->dma_length = sg->length; - __dma_sync_page(page_to_phys(sg_page(sg)), sg->offset, - sg->length, direction); - } - - return nents; -} - -static void dma_direct_unmap_sg(struct device *dev, struct scatterlist *sg, - int nents, enum dma_data_direction direction, - struct dma_attrs *attrs) -{ -} - -static int dma_direct_dma_supported(struct device *dev, u64 mask) -{ - return 1; -} - -static inline dma_addr_t dma_direct_map_page(struct device *dev, - struct page *page, - unsigned long offset, - size_t size, - enum dma_data_direction direction, - struct dma_attrs *attrs) -{ - __dma_sync_page(page_to_phys(page), offset, size, direction); - return page_to_phys(page) + offset + get_dma_direct_offset(dev); -} - -static inline void dma_direct_unmap_page(struct device *dev, - dma_addr_t dma_address, - size_t size, - enum dma_data_direction direction, - struct dma_attrs *attrs) -{ -/* There is not necessary to do cache cleanup - * - * phys_to_virt is here because in __dma_sync_page is __virt_to_phys and - * dma_address is physical address - */ - __dma_sync_page(dma_address, 0 , size, direction); -} - -struct dma_map_ops dma_direct_ops = { - .alloc_coherent = dma_direct_alloc_coherent, - .free_coherent = dma_direct_free_coherent, - .map_sg = dma_direct_map_sg, - .unmap_sg = dma_direct_unmap_sg, - .dma_supported = dma_direct_dma_supported, - .map_page = dma_direct_map_page, - .unmap_page = dma_direct_unmap_page, -}; -EXPORT_SYMBOL(dma_direct_ops); - -/* Number of entries preallocated for DMA-API debugging */ -#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16) - -static int __init dma_init(void) -{ - dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES); - - return 0; -} -fs_initcall(dma_init); diff --git a/trunk/arch/microblaze/kernel/entry.S b/trunk/arch/microblaze/kernel/entry.S index c0ede25c5b99..3bad4ff49471 100644 --- a/trunk/arch/microblaze/kernel/entry.S +++ b/trunk/arch/microblaze/kernel/entry.S @@ -305,7 +305,7 @@ C_ENTRY(_user_exception): swi r11, r1, PTO+PT_R1; /* Store user SP. */ addi r11, r0, 1; swi r11, r0, TOPHYS(PER_CPU(KM)); /* Now we're in kernel-mode. */ -2: lwi CURRENT_TASK, r0, TOPHYS(PER_CPU(CURRENT_SAVE)); +2: lwi r31, r0, TOPHYS(PER_CPU(CURRENT_SAVE)); /* get saved current */ /* Save away the syscall number. */ swi r12, r1, PTO+PT_R0; tovirt(r1,r1) @@ -322,7 +322,8 @@ C_ENTRY(_user_exception): rtid r11, 0 nop 3: - lwi r11, CURRENT_TASK, TS_THREAD_INFO /* get thread info */ + add r11, r0, CURRENT_TASK /* Get current task ptr into r11 */ + lwi r11, r11, TS_THREAD_INFO /* get thread info */ lwi r11, r11, TI_FLAGS /* get flags in thread info */ andi r11, r11, _TIF_WORK_SYSCALL_MASK beqi r11, 4f @@ -381,50 +382,60 @@ C_ENTRY(ret_from_trap): /* See if returning to kernel mode, if so, skip resched &c. */ bnei r11, 2f; - swi r3, r1, PTO + PT_R3 - swi r4, r1, PTO + PT_R4 - /* We're returning to user mode, so check for various conditions that * trigger rescheduling. */ - /* FIXME: Restructure all these flag checks. */ - lwi r11, CURRENT_TASK, TS_THREAD_INFO; /* get thread info */ + # FIXME: Restructure all these flag checks. + add r11, r0, CURRENT_TASK; /* Get current task ptr into r11 */ + lwi r11, r11, TS_THREAD_INFO; /* get thread info */ lwi r11, r11, TI_FLAGS; /* get flags in thread info */ andi r11, r11, _TIF_WORK_SYSCALL_MASK beqi r11, 1f + swi r3, r1, PTO + PT_R3 + swi r4, r1, PTO + PT_R4 brlid r15, do_syscall_trace_leave addik r5, r1, PTO + PT_R0 + lwi r3, r1, PTO + PT_R3 + lwi r4, r1, PTO + PT_R4 1: + /* We're returning to user mode, so check for various conditions that * trigger rescheduling. */ - /* get thread info from current task */ - lwi r11, CURRENT_TASK, TS_THREAD_INFO; + /* Get current task ptr into r11 */ + add r11, r0, CURRENT_TASK; /* Get current task ptr into r11 */ + lwi r11, r11, TS_THREAD_INFO; /* get thread info */ lwi r11, r11, TI_FLAGS; /* get flags in thread info */ andi r11, r11, _TIF_NEED_RESCHED; beqi r11, 5f; + swi r3, r1, PTO + PT_R3; /* store syscall result */ + swi r4, r1, PTO + PT_R4; bralid r15, schedule; /* Call scheduler */ nop; /* delay slot */ + lwi r3, r1, PTO + PT_R3; /* restore syscall result */ + lwi r4, r1, PTO + PT_R4; /* Maybe handle a signal */ -5: /* get thread info from current task*/ - lwi r11, CURRENT_TASK, TS_THREAD_INFO; +5: add r11, r0, CURRENT_TASK; /* Get current task ptr into r11 */ + lwi r11, r11, TS_THREAD_INFO; /* get thread info */ lwi r11, r11, TI_FLAGS; /* get flags in thread info */ andi r11, r11, _TIF_SIGPENDING; beqi r11, 1f; /* Signals to handle, handle them */ + swi r3, r1, PTO + PT_R3; /* store syscall result */ + swi r4, r1, PTO + PT_R4; la r5, r1, PTO; /* Arg 1: struct pt_regs *regs */ + add r6, r0, r0; /* Arg 2: sigset_t *oldset */ addi r7, r0, 1; /* Arg 3: int in_syscall */ bralid r15, do_signal; /* Handle any signals */ - add r6, r0, r0; /* Arg 2: sigset_t *oldset */ - -/* Finally, return to user state. */ -1: + nop; lwi r3, r1, PTO + PT_R3; /* restore syscall result */ lwi r4, r1, PTO + PT_R4; - swi r0, r0, PER_CPU(KM); /* Now officially in user state. */ - swi CURRENT_TASK, r0, PER_CPU(CURRENT_SAVE); /* save current */ +/* Finally, return to user state. */ +1: swi r0, r0, PER_CPU(KM); /* Now officially in user state. */ + add r11, r0, CURRENT_TASK; /* Get current task ptr into r11 */ + swi r11, r0, PER_CPU(CURRENT_SAVE); /* save current */ VM_OFF; tophys(r1,r1); RESTORE_REGS; @@ -554,7 +565,7 @@ C_ENTRY(sys_rt_sigreturn_wrapper): swi r11, r1, PTO+PT_R1; /* Store user SP. */ \ addi r11, r0, 1; \ swi r11, r0, TOPHYS(PER_CPU(KM)); /* Now we're in kernel-mode.*/\ -2: lwi CURRENT_TASK, r0, TOPHYS(PER_CPU(CURRENT_SAVE)); \ +2: lwi r31, r0, TOPHYS(PER_CPU(CURRENT_SAVE)); /* get saved current */\ /* Save away the syscall number. */ \ swi r0, r1, PTO+PT_R0; \ tovirt(r1,r1) @@ -662,7 +673,9 @@ C_ENTRY(ret_from_exc): /* We're returning to user mode, so check for various conditions that trigger rescheduling. */ - lwi r11, CURRENT_TASK, TS_THREAD_INFO; /* get thread info */ + /* Get current task ptr into r11 */ + add r11, r0, CURRENT_TASK; /* Get current task ptr into r11 */ + lwi r11, r11, TS_THREAD_INFO; /* get thread info */ lwi r11, r11, TI_FLAGS; /* get flags in thread info */ andi r11, r11, _TIF_NEED_RESCHED; beqi r11, 5f; @@ -672,7 +685,8 @@ C_ENTRY(ret_from_exc): nop; /* delay slot */ /* Maybe handle a signal */ -5: lwi r11, CURRENT_TASK, TS_THREAD_INFO; /* get thread info */ +5: add r11, r0, CURRENT_TASK; /* Get current task ptr into r11 */ + lwi r11, r11, TS_THREAD_INFO; /* get thread info */ lwi r11, r11, TI_FLAGS; /* get flags in thread info */ andi r11, r11, _TIF_SIGPENDING; beqi r11, 1f; /* Signals to handle, handle them */ @@ -691,13 +705,15 @@ C_ENTRY(ret_from_exc): * store return registers separately because this macros is use * for others exceptions */ la r5, r1, PTO; /* Arg 1: struct pt_regs *regs */ + add r6, r0, r0; /* Arg 2: sigset_t *oldset */ addi r7, r0, 0; /* Arg 3: int in_syscall */ bralid r15, do_signal; /* Handle any signals */ - add r6, r0, r0; /* Arg 2: sigset_t *oldset */ + nop; /* Finally, return to user state. */ 1: swi r0, r0, PER_CPU(KM); /* Now officially in user state. */ - swi CURRENT_TASK, r0, PER_CPU(CURRENT_SAVE); /* save current */ + add r11, r0, CURRENT_TASK; /* Get current task ptr into r11 */ + swi r11, r0, PER_CPU(CURRENT_SAVE); /* save current */ VM_OFF; tophys(r1,r1); @@ -786,7 +802,7 @@ C_ENTRY(_interrupt): swi r11, r0, TOPHYS(PER_CPU(KM)); 2: - lwi CURRENT_TASK, r0, TOPHYS(PER_CPU(CURRENT_SAVE)); + lwi r31, r0, TOPHYS(PER_CPU(CURRENT_SAVE)); swi r0, r1, PTO + PT_R0; tovirt(r1,r1) la r5, r1, PTO; @@ -801,7 +817,8 @@ ret_from_irq: lwi r11, r1, PTO + PT_MODE; bnei r11, 2f; - lwi r11, CURRENT_TASK, TS_THREAD_INFO; + add r11, r0, CURRENT_TASK; + lwi r11, r11, TS_THREAD_INFO; lwi r11, r11, TI_FLAGS; /* MS: get flags from thread info */ andi r11, r11, _TIF_NEED_RESCHED; beqi r11, 5f @@ -809,7 +826,8 @@ ret_from_irq: nop; /* delay slot */ /* Maybe handle a signal */ -5: lwi r11, CURRENT_TASK, TS_THREAD_INFO; /* MS: get thread info */ +5: add r11, r0, CURRENT_TASK; + lwi r11, r11, TS_THREAD_INFO; /* MS: get thread info */ lwi r11, r11, TI_FLAGS; /* get flags in thread info */ andi r11, r11, _TIF_SIGPENDING; beqid r11, no_intr_resched @@ -824,7 +842,8 @@ no_intr_resched: /* Disable interrupts, we are now committed to the state restore */ disable_irq swi r0, r0, PER_CPU(KM); /* MS: Now officially in user state. */ - swi CURRENT_TASK, r0, PER_CPU(CURRENT_SAVE); + add r11, r0, CURRENT_TASK; + swi r11, r0, PER_CPU(CURRENT_SAVE); VM_OFF; tophys(r1,r1); lwi r3, r1, PTO + PT_R3; /* MS: restore saved r3, r4 registers */ @@ -834,28 +853,7 @@ no_intr_resched: lwi r1, r1, PT_R1 - PT_SIZE; bri 6f; /* MS: Return to kernel state. */ -2: -#ifdef CONFIG_PREEMPT - lwi r11, CURRENT_TASK, TS_THREAD_INFO; - /* MS: get preempt_count from thread info */ - lwi r5, r11, TI_PREEMPT_COUNT; - bgti r5, restore; - - lwi r5, r11, TI_FLAGS; /* get flags in thread info */ - andi r5, r5, _TIF_NEED_RESCHED; - beqi r5, restore /* if zero jump over */ - -preempt: - /* interrupts are off that's why I am calling preempt_chedule_irq */ - bralid r15, preempt_schedule_irq - nop - lwi r11, CURRENT_TASK, TS_THREAD_INFO; /* get thread info */ - lwi r5, r11, TI_FLAGS; /* get flags in thread info */ - andi r5, r5, _TIF_NEED_RESCHED; - bnei r5, preempt /* if non zero jump to resched */ -restore: -#endif - VM_OFF /* MS: turn off MMU */ +2: VM_OFF /* MS: turn off MMU */ tophys(r1,r1) lwi r3, r1, PTO + PT_R3; /* MS: restore saved r3, r4 registers */ lwi r4, r1, PTO + PT_R4; @@ -917,7 +915,7 @@ C_ENTRY(_debug_exception): swi r11, r1, PTO+PT_R1; /* Store user SP. */ addi r11, r0, 1; swi r11, r0, TOPHYS(PER_CPU(KM)); /* Now we're in kernel-mode. */ -2: lwi CURRENT_TASK, r0, TOPHYS(PER_CPU(CURRENT_SAVE)); +2: lwi r31, r0, TOPHYS(PER_CPU(CURRENT_SAVE)); /* get saved current */ /* Save away the syscall number. */ swi r0, r1, PTO+PT_R0; tovirt(r1,r1) @@ -937,7 +935,8 @@ dbtrap_call: rtbd r11, 0; bnei r11, 2f; /* Get current task ptr into r11 */ - lwi r11, CURRENT_TASK, TS_THREAD_INFO; /* get thread info */ + add r11, r0, CURRENT_TASK; /* Get current task ptr into r11 */ + lwi r11, r11, TS_THREAD_INFO; /* get thread info */ lwi r11, r11, TI_FLAGS; /* get flags in thread info */ andi r11, r11, _TIF_NEED_RESCHED; beqi r11, 5f; @@ -950,7 +949,8 @@ dbtrap_call: rtbd r11, 0; /* XXX m68knommu also checks TASK_STATE & TASK_COUNTER here. */ /* Maybe handle a signal */ -5: lwi r11, CURRENT_TASK, TS_THREAD_INFO; /* get thread info */ +5: add r11, r0, CURRENT_TASK; /* Get current task ptr into r11 */ + lwi r11, r11, TS_THREAD_INFO; /* get thread info */ lwi r11, r11, TI_FLAGS; /* get flags in thread info */ andi r11, r11, _TIF_SIGPENDING; beqi r11, 1f; /* Signals to handle, handle them */ @@ -966,14 +966,16 @@ dbtrap_call: rtbd r11, 0; (in a possibly modified form) after do_signal returns. */ la r5, r1, PTO; /* Arg 1: struct pt_regs *regs */ + add r6, r0, r0; /* Arg 2: sigset_t *oldset */ addi r7, r0, 0; /* Arg 3: int in_syscall */ bralid r15, do_signal; /* Handle any signals */ - add r6, r0, r0; /* Arg 2: sigset_t *oldset */ + nop; /* Finally, return to user state. */ 1: swi r0, r0, PER_CPU(KM); /* Now officially in user state. */ - swi CURRENT_TASK, r0, PER_CPU(CURRENT_SAVE); /* save current */ + add r11, r0, CURRENT_TASK; /* Get current task ptr into r11 */ + swi r11, r0, PER_CPU(CURRENT_SAVE); /* save current */ VM_OFF; tophys(r1,r1); @@ -1005,7 +1007,7 @@ DBTRAP_return: /* Make global symbol for debugging */ ENTRY(_switch_to) /* prepare return value */ - addk r3, r0, CURRENT_TASK + addk r3, r0, r31 /* save registers in cpu_context */ /* use r11 and r12, volatile registers, as temp register */ @@ -1049,10 +1051,10 @@ ENTRY(_switch_to) nop swi r12, r11, CC_FSR - /* update r31, the current-give me pointer to task which will be next */ - lwi CURRENT_TASK, r6, TI_TASK + /* update r31, the current */ + lwi r31, r6, TI_TASK/* give me pointer to task which will be next */ /* stored it to current_save too */ - swi CURRENT_TASK, r0, PER_CPU(CURRENT_SAVE) + swi r31, r0, PER_CPU(CURRENT_SAVE) /* get new process' cpu context and restore */ /* give me start where start context of next task */ diff --git a/trunk/arch/microblaze/kernel/head.S b/trunk/arch/microblaze/kernel/head.S index cb7815cfe5ab..30916193fcc7 100644 --- a/trunk/arch/microblaze/kernel/head.S +++ b/trunk/arch/microblaze/kernel/head.S @@ -99,8 +99,8 @@ no_fdt_arg: tophys(r4,r4) /* convert to phys address */ ori r3, r0, COMMAND_LINE_SIZE - 1 /* number of loops */ _copy_command_line: - lbu r2, r5, r6 /* r7=r5+r6 - r5 contain pointer to command line */ - sb r2, r4, r6 /* addr[r4+r6]= r7*/ + lbu r7, r5, r6 /* r7=r5+r6 - r5 contain pointer to command line */ + sb r7, r4, r6 /* addr[r4+r6]= r7*/ addik r6, r6, 1 /* increment counting */ bgtid r3, _copy_command_line /* loop for all entries */ addik r3, r3, -1 /* descrement loop */ @@ -136,11 +136,6 @@ _invalidate: addik r3, r3, -1 /* sync */ - /* Setup the kernel PID */ - mts rpid,r0 /* Load the kernel PID */ - nop - bri 4 - /* * We should still be executing code at physical address area * RAM_BASEADDR at this point. However, kernel code is at @@ -151,6 +146,10 @@ _invalidate: addik r3,r0, CONFIG_KERNEL_START /* Load the kernel virtual address */ tophys(r4,r3) /* Load the kernel physical address */ + mts rpid,r0 /* Load the kernel PID */ + nop + bri 4 + /* * Configure and load two entries into TLB slots 0 and 1. * In case we are pinning TLBs, these are reserved in by the diff --git a/trunk/arch/microblaze/kernel/irq.c b/trunk/arch/microblaze/kernel/irq.c index 6f39e2c001f3..0f06034d1fe0 100644 --- a/trunk/arch/microblaze/kernel/irq.c +++ b/trunk/arch/microblaze/kernel/irq.c @@ -93,18 +93,3 @@ int show_interrupts(struct seq_file *p, void *v) } return 0; } - -/* MS: There is no any advance mapping mechanism. We are using simple 32bit - intc without any cascades or any connection that's why mapping is 1:1 */ -unsigned int irq_create_mapping(struct irq_host *host, irq_hw_number_t hwirq) -{ - return hwirq; -} -EXPORT_SYMBOL_GPL(irq_create_mapping); - -unsigned int irq_create_of_mapping(struct device_node *controller, - u32 *intspec, unsigned int intsize) -{ - return intspec[0]; -} -EXPORT_SYMBOL_GPL(irq_create_of_mapping); diff --git a/trunk/arch/microblaze/kernel/setup.c b/trunk/arch/microblaze/kernel/setup.c index f974ec7aa357..bb8c4b9ccb80 100644 --- a/trunk/arch/microblaze/kernel/setup.c +++ b/trunk/arch/microblaze/kernel/setup.c @@ -22,10 +22,7 @@ #include #include #include -#include #include -#include -#include #include #include #include @@ -57,9 +54,13 @@ void __init setup_arch(char **cmdline_p) microblaze_cache_init(); - setup_memory(); + invalidate_dcache(); + enable_dcache(); + + invalidate_icache(); + enable_icache(); - xilinx_pci_init(); + setup_memory(); #if defined(CONFIG_SELFMOD_INTC) || defined(CONFIG_SELFMOD_TIMER) printk(KERN_NOTICE "Self modified code enable\n"); @@ -187,37 +188,3 @@ static int microblaze_debugfs_init(void) } arch_initcall(microblaze_debugfs_init); #endif - -static int dflt_bus_notify(struct notifier_block *nb, - unsigned long action, void *data) -{ - struct device *dev = data; - - /* We are only intereted in device addition */ - if (action != BUS_NOTIFY_ADD_DEVICE) - return 0; - - set_dma_ops(dev, &dma_direct_ops); - - return NOTIFY_DONE; -} - -static struct notifier_block dflt_plat_bus_notifier = { - .notifier_call = dflt_bus_notify, - .priority = INT_MAX, -}; - -static struct notifier_block dflt_of_bus_notifier = { - .notifier_call = dflt_bus_notify, - .priority = INT_MAX, -}; - -static int __init setup_bus_notifier(void) -{ - bus_register_notifier(&platform_bus_type, &dflt_plat_bus_notifier); - bus_register_notifier(&of_platform_bus_type, &dflt_of_bus_notifier); - - return 0; -} - -arch_initcall(setup_bus_notifier); diff --git a/trunk/arch/microblaze/mm/Makefile b/trunk/arch/microblaze/mm/Makefile index 09c49ed87235..6c8a924d9e26 100644 --- a/trunk/arch/microblaze/mm/Makefile +++ b/trunk/arch/microblaze/mm/Makefile @@ -2,6 +2,6 @@ # Makefile # -obj-y := consistent.o init.o +obj-y := init.o obj-$(CONFIG_MMU) += pgtable.o mmu_context.o fault.o diff --git a/trunk/arch/microblaze/mm/consistent.c b/trunk/arch/microblaze/mm/consistent.c deleted file mode 100644 index a9b443e3fb98..000000000000 --- a/trunk/arch/microblaze/mm/consistent.c +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Microblaze support for cache consistent memory. - * Copyright (C) 2010 Michal Simek - * Copyright (C) 2010 PetaLogix - * Copyright (C) 2005 John Williams - * - * Based on PowerPC version derived from arch/arm/mm/consistent.c - * Copyright (C) 2001 Dan Malek (dmalek@jlc.net) - * Copyright (C) 2000 Russell King - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef CONFIG_MMU - -/* I have to use dcache values because I can't relate on ram size */ -#define UNCACHED_SHADOW_MASK (cpuinfo.dcache_high - cpuinfo.dcache_base + 1) - -/* - * Consistent memory allocators. Used for DMA devices that want to - * share uncached memory with the processor core. - * My crufty no-MMU approach is simple. In the HW platform we can optionally - * mirror the DDR up above the processor cacheable region. So, memory accessed - * in this mirror region will not be cached. It's alloced from the same - * pool as normal memory, but the handle we return is shifted up into the - * uncached region. This will no doubt cause big problems if memory allocated - * here is not also freed properly. -- JW - */ -void *consistent_alloc(int gfp, size_t size, dma_addr_t *dma_handle) -{ - struct page *page, *end, *free; - unsigned long order; - void *ret, *virt; - - if (in_interrupt()) - BUG(); - - size = PAGE_ALIGN(size); - order = get_order(size); - - page = alloc_pages(gfp, order); - if (!page) - goto no_page; - - /* We could do with a page_to_phys and page_to_bus here. */ - virt = page_address(page); - ret = ioremap(virt_to_phys(virt), size); - if (!ret) - goto no_remap; - - /* - * Here's the magic! Note if the uncached shadow is not implemented, - * it's up to the calling code to also test that condition and make - * other arranegments, such as manually flushing the cache and so on. - */ -#ifdef CONFIG_XILINX_UNCACHED_SHADOW - ret = (void *)((unsigned) ret | UNCACHED_SHADOW_MASK); -#endif - /* dma_handle is same as physical (shadowed) address */ - *dma_handle = (dma_addr_t)ret; - - /* - * free wasted pages. We skip the first page since we know - * that it will have count = 1 and won't require freeing. - * We also mark the pages in use as reserved so that - * remap_page_range works. - */ - page = virt_to_page(virt); - free = page + (size >> PAGE_SHIFT); - end = page + (1 << order); - - for (; page < end; page++) { - init_page_count(page); - if (page >= free) - __free_page(page); - else - SetPageReserved(page); - } - - return ret; -no_remap: - __free_pages(page, order); -no_page: - return NULL; -} - -#else - -void *consistent_alloc(int gfp, size_t size, dma_addr_t *dma_handle) -{ - int order, err, i; - unsigned long page, va, flags; - phys_addr_t pa; - struct vm_struct *area; - void *ret; - - if (in_interrupt()) - BUG(); - - /* Only allocate page size areas. */ - size = PAGE_ALIGN(size); - order = get_order(size); - - page = __get_free_pages(gfp, order); - if (!page) { - BUG(); - return NULL; - } - - /* - * we need to ensure that there are no cachelines in use, - * or worse dirty in this area. - */ - flush_dcache_range(virt_to_phys(page), virt_to_phys(page) + size); - - /* Allocate some common virtual space to map the new pages. */ - area = get_vm_area(size, VM_ALLOC); - if (area == NULL) { - free_pages(page, order); - return NULL; - } - va = (unsigned long) area->addr; - ret = (void *)va; - - /* This gives us the real physical address of the first page. */ - *dma_handle = pa = virt_to_bus((void *)page); - - /* MS: This is the whole magic - use cache inhibit pages */ - flags = _PAGE_KERNEL | _PAGE_NO_CACHE; - - /* - * Set refcount=1 on all pages in an order>0 - * allocation so that vfree() will actually - * free all pages that were allocated. - */ - if (order > 0) { - struct page *rpage = virt_to_page(page); - for (i = 1; i < (1 << order); i++) - init_page_count(rpage+i); - } - - err = 0; - for (i = 0; i < size && err == 0; i += PAGE_SIZE) - err = map_page(va+i, pa+i, flags); - - if (err) { - vfree((void *)va); - return NULL; - } - - return ret; -} -#endif /* CONFIG_MMU */ -EXPORT_SYMBOL(consistent_alloc); - -/* - * free page(s) as defined by the above mapping. - */ -void consistent_free(void *vaddr) -{ - if (in_interrupt()) - BUG(); - - /* Clear SHADOW_MASK bit in address, and free as per usual */ -#ifdef CONFIG_XILINX_UNCACHED_SHADOW - vaddr = (void *)((unsigned)vaddr & ~UNCACHED_SHADOW_MASK); -#endif - vfree(vaddr); -} -EXPORT_SYMBOL(consistent_free); - -/* - * make an area consistent. - */ -void consistent_sync(void *vaddr, size_t size, int direction) -{ - unsigned long start; - unsigned long end; - - start = (unsigned long)vaddr; - - /* Convert start address back down to unshadowed memory region */ -#ifdef CONFIG_XILINX_UNCACHED_SHADOW - start &= ~UNCACHED_SHADOW_MASK; -#endif - end = start + size; - - switch (direction) { - case PCI_DMA_NONE: - BUG(); - case PCI_DMA_FROMDEVICE: /* invalidate only */ - flush_dcache_range(start, end); - break; - case PCI_DMA_TODEVICE: /* writeback only */ - flush_dcache_range(start, end); - break; - case PCI_DMA_BIDIRECTIONAL: /* writeback and invalidate */ - flush_dcache_range(start, end); - break; - } -} -EXPORT_SYMBOL(consistent_sync); - -/* - * consistent_sync_page makes memory consistent. identical - * to consistent_sync, but takes a struct page instead of a - * virtual address - */ -void consistent_sync_page(struct page *page, unsigned long offset, - size_t size, int direction) -{ - unsigned long start = (unsigned long)page_address(page) + offset; - consistent_sync((void *)start, size, direction); -} -EXPORT_SYMBOL(consistent_sync_page); diff --git a/trunk/arch/microblaze/mm/init.c b/trunk/arch/microblaze/mm/init.c index 1608e2e1a44a..a57cedf36715 100644 --- a/trunk/arch/microblaze/mm/init.c +++ b/trunk/arch/microblaze/mm/init.c @@ -23,9 +23,6 @@ #include #include -/* Use for MMU and noMMU because of PCI generic code */ -int mem_init_done; - #ifndef CONFIG_MMU unsigned int __page_offset; EXPORT_SYMBOL(__page_offset); @@ -33,6 +30,7 @@ EXPORT_SYMBOL(__page_offset); #else DEFINE_PER_CPU(struct mmu_gather, mmu_gathers); +int mem_init_done; static int init_bootmem_done; #endif /* CONFIG_MMU */ @@ -195,6 +193,12 @@ void free_initmem(void) (unsigned long)(&__init_end)); } +/* FIXME from arch/powerpc/mm/mem.c*/ +void show_mem(void) +{ + printk(KERN_NOTICE "%s\n", __func__); +} + void __init mem_init(void) { high_memory = (void *)__va(memory_end); @@ -204,7 +208,9 @@ void __init mem_init(void) printk(KERN_INFO "Memory: %luk/%luk available\n", nr_free_pages() << (PAGE_SHIFT-10), num_physpages << (PAGE_SHIFT-10)); +#ifdef CONFIG_MMU mem_init_done = 1; +#endif } #ifndef CONFIG_MMU @@ -216,10 +222,6 @@ int ___range_ok(unsigned long addr, unsigned long size) } EXPORT_SYMBOL(___range_ok); -int page_is_ram(unsigned long pfn) -{ - return __range_ok(pfn, 0); -} #else int page_is_ram(unsigned long pfn) { @@ -347,27 +349,4 @@ void __init *early_get_page(void) } return p; } - #endif /* CONFIG_MMU */ - -void * __init_refok alloc_maybe_bootmem(size_t size, gfp_t mask) -{ - if (mem_init_done) - return kmalloc(size, mask); - else - return alloc_bootmem(size); -} - -void * __init_refok zalloc_maybe_bootmem(size_t size, gfp_t mask) -{ - void *p; - - if (mem_init_done) - p = kzalloc(size, mask); - else { - p = alloc_bootmem(size); - if (p) - memset(p, 0, size); - } - return p; -} diff --git a/trunk/arch/microblaze/mm/pgtable.c b/trunk/arch/microblaze/mm/pgtable.c index 63a6fd07c48f..2820081b21ab 100644 --- a/trunk/arch/microblaze/mm/pgtable.c +++ b/trunk/arch/microblaze/mm/pgtable.c @@ -103,7 +103,7 @@ static void __iomem *__ioremap(phys_addr_t addr, unsigned long size, area = get_vm_area(size, VM_IOREMAP); if (area == NULL) return NULL; - v = (unsigned long) area->addr; + v = VMALLOC_VMADDR(area->addr); } else { v = (ioremap_bot -= size); } diff --git a/trunk/arch/microblaze/pci/Makefile b/trunk/arch/microblaze/pci/Makefile deleted file mode 100644 index 9889cc2e1294..000000000000 --- a/trunk/arch/microblaze/pci/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# -# Makefile -# - -obj-$(CONFIG_PCI) += pci_32.o pci-common.o indirect_pci.o iomap.o -obj-$(CONFIG_PCI_XILINX) += xilinx_pci.o diff --git a/trunk/arch/microblaze/pci/indirect_pci.c b/trunk/arch/microblaze/pci/indirect_pci.c deleted file mode 100644 index 25f18f017f21..000000000000 --- a/trunk/arch/microblaze/pci/indirect_pci.c +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Support for indirect PCI bridges. - * - * Copyright (C) 1998 Gabriel Paubert. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. - */ - -#include -#include -#include -#include -#include - -#include -#include -#include - -static int -indirect_read_config(struct pci_bus *bus, unsigned int devfn, int offset, - int len, u32 *val) -{ - struct pci_controller *hose = pci_bus_to_host(bus); - volatile void __iomem *cfg_data; - u8 cfg_type = 0; - u32 bus_no, reg; - - if (hose->indirect_type & INDIRECT_TYPE_NO_PCIE_LINK) { - if (bus->number != hose->first_busno) - return PCIBIOS_DEVICE_NOT_FOUND; - if (devfn != 0) - return PCIBIOS_DEVICE_NOT_FOUND; - } - - if (hose->indirect_type & INDIRECT_TYPE_SET_CFG_TYPE) - if (bus->number != hose->first_busno) - cfg_type = 1; - - bus_no = (bus->number == hose->first_busno) ? - hose->self_busno : bus->number; - - if (hose->indirect_type & INDIRECT_TYPE_EXT_REG) - reg = ((offset & 0xf00) << 16) | (offset & 0xfc); - else - reg = offset & 0xfc; /* Only 3 bits for function */ - - if (hose->indirect_type & INDIRECT_TYPE_BIG_ENDIAN) - out_be32(hose->cfg_addr, (0x80000000 | (bus_no << 16) | - (devfn << 8) | reg | cfg_type)); - else - out_le32(hose->cfg_addr, (0x80000000 | (bus_no << 16) | - (devfn << 8) | reg | cfg_type)); - - /* - * Note: the caller has already checked that offset is - * suitably aligned and that len is 1, 2 or 4. - */ - cfg_data = hose->cfg_data + (offset & 3); /* Only 3 bits for function */ - switch (len) { - case 1: - *val = in_8(cfg_data); - break; - case 2: - *val = in_le16(cfg_data); - break; - default: - *val = in_le32(cfg_data); - break; - } - return PCIBIOS_SUCCESSFUL; -} - -static int -indirect_write_config(struct pci_bus *bus, unsigned int devfn, int offset, - int len, u32 val) -{ - struct pci_controller *hose = pci_bus_to_host(bus); - volatile void __iomem *cfg_data; - u8 cfg_type = 0; - u32 bus_no, reg; - - if (hose->indirect_type & INDIRECT_TYPE_NO_PCIE_LINK) { - if (bus->number != hose->first_busno) - return PCIBIOS_DEVICE_NOT_FOUND; - if (devfn != 0) - return PCIBIOS_DEVICE_NOT_FOUND; - } - - if (hose->indirect_type & INDIRECT_TYPE_SET_CFG_TYPE) - if (bus->number != hose->first_busno) - cfg_type = 1; - - bus_no = (bus->number == hose->first_busno) ? - hose->self_busno : bus->number; - - if (hose->indirect_type & INDIRECT_TYPE_EXT_REG) - reg = ((offset & 0xf00) << 16) | (offset & 0xfc); - else - reg = offset & 0xfc; - - if (hose->indirect_type & INDIRECT_TYPE_BIG_ENDIAN) - out_be32(hose->cfg_addr, (0x80000000 | (bus_no << 16) | - (devfn << 8) | reg | cfg_type)); - else - out_le32(hose->cfg_addr, (0x80000000 | (bus_no << 16) | - (devfn << 8) | reg | cfg_type)); - - /* surpress setting of PCI_PRIMARY_BUS */ - if (hose->indirect_type & INDIRECT_TYPE_SURPRESS_PRIMARY_BUS) - if ((offset == PCI_PRIMARY_BUS) && - (bus->number == hose->first_busno)) - val &= 0xffffff00; - - /* Workaround for PCI_28 Errata in 440EPx/GRx */ - if ((hose->indirect_type & INDIRECT_TYPE_BROKEN_MRM) && - offset == PCI_CACHE_LINE_SIZE) { - val = 0; - } - - /* - * Note: the caller has already checked that offset is - * suitably aligned and that len is 1, 2 or 4. - */ - cfg_data = hose->cfg_data + (offset & 3); - switch (len) { - case 1: - out_8(cfg_data, val); - break; - case 2: - out_le16(cfg_data, val); - break; - default: - out_le32(cfg_data, val); - break; - } - - return PCIBIOS_SUCCESSFUL; -} - -static struct pci_ops indirect_pci_ops = { - .read = indirect_read_config, - .write = indirect_write_config, -}; - -void __init -setup_indirect_pci(struct pci_controller *hose, - resource_size_t cfg_addr, - resource_size_t cfg_data, u32 flags) -{ - resource_size_t base = cfg_addr & PAGE_MASK; - void __iomem *mbase; - - mbase = ioremap(base, PAGE_SIZE); - hose->cfg_addr = mbase + (cfg_addr & ~PAGE_MASK); - if ((cfg_data & PAGE_MASK) != base) - mbase = ioremap(cfg_data & PAGE_MASK, PAGE_SIZE); - hose->cfg_data = mbase + (cfg_data & ~PAGE_MASK); - hose->ops = &indirect_pci_ops; - hose->indirect_type = flags; -} diff --git a/trunk/arch/microblaze/pci/iomap.c b/trunk/arch/microblaze/pci/iomap.c deleted file mode 100644 index 3fbf16f4e16c..000000000000 --- a/trunk/arch/microblaze/pci/iomap.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * ppc64 "iomap" interface implementation. - * - * (C) Copyright 2004 Linus Torvalds - */ -#include -#include -#include -#include -#include - -void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max) -{ - resource_size_t start = pci_resource_start(dev, bar); - resource_size_t len = pci_resource_len(dev, bar); - unsigned long flags = pci_resource_flags(dev, bar); - - if (!len) - return NULL; - if (max && len > max) - len = max; - if (flags & IORESOURCE_IO) - return ioport_map(start, len); - if (flags & IORESOURCE_MEM) - return ioremap(start, len); - /* What? */ - return NULL; -} -EXPORT_SYMBOL(pci_iomap); - -void pci_iounmap(struct pci_dev *dev, void __iomem *addr) -{ - if (isa_vaddr_is_ioport(addr)) - return; - if (pcibios_vaddr_is_ioport(addr)) - return; - iounmap(addr); -} -EXPORT_SYMBOL(pci_iounmap); diff --git a/trunk/arch/microblaze/pci/pci-common.c b/trunk/arch/microblaze/pci/pci-common.c deleted file mode 100644 index 0be34350d733..000000000000 --- a/trunk/arch/microblaze/pci/pci-common.c +++ /dev/null @@ -1,1642 +0,0 @@ -/* - * Contains common pci routines for ALL ppc platform - * (based on pci_32.c and pci_64.c) - * - * Port for PPC64 David Engebretsen, IBM Corp. - * Contains common pci routines for ppc64 platform, pSeries and iSeries brands. - * - * Copyright (C) 2003 Anton Blanchard , IBM - * Rework, based on alpha PCI code. - * - * Common pmac/prep/chrp pci routines. -- Cort - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -static DEFINE_SPINLOCK(hose_spinlock); -LIST_HEAD(hose_list); - -/* XXX kill that some day ... */ -static int global_phb_number; /* Global phb counter */ - -/* ISA Memory physical address */ -resource_size_t isa_mem_base; - -/* Default PCI flags is 0 on ppc32, modified at boot on ppc64 */ -unsigned int pci_flags; - -static struct dma_map_ops *pci_dma_ops = &dma_direct_ops; - -void set_pci_dma_ops(struct dma_map_ops *dma_ops) -{ - pci_dma_ops = dma_ops; -} - -struct dma_map_ops *get_pci_dma_ops(void) -{ - return pci_dma_ops; -} -EXPORT_SYMBOL(get_pci_dma_ops); - -int pci_set_dma_mask(struct pci_dev *dev, u64 mask) -{ - return dma_set_mask(&dev->dev, mask); -} - -int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask) -{ - int rc; - - rc = dma_set_mask(&dev->dev, mask); - dev->dev.coherent_dma_mask = dev->dma_mask; - - return rc; -} - -struct pci_controller *pcibios_alloc_controller(struct device_node *dev) -{ - struct pci_controller *phb; - - phb = zalloc_maybe_bootmem(sizeof(struct pci_controller), GFP_KERNEL); - if (!phb) - return NULL; - spin_lock(&hose_spinlock); - phb->global_number = global_phb_number++; - list_add_tail(&phb->list_node, &hose_list); - spin_unlock(&hose_spinlock); - phb->dn = dev; - phb->is_dynamic = mem_init_done; - return phb; -} - -void pcibios_free_controller(struct pci_controller *phb) -{ - spin_lock(&hose_spinlock); - list_del(&phb->list_node); - spin_unlock(&hose_spinlock); - - if (phb->is_dynamic) - kfree(phb); -} - -static resource_size_t pcibios_io_size(const struct pci_controller *hose) -{ - return hose->io_resource.end - hose->io_resource.start + 1; -} - -int pcibios_vaddr_is_ioport(void __iomem *address) -{ - int ret = 0; - struct pci_controller *hose; - resource_size_t size; - - spin_lock(&hose_spinlock); - list_for_each_entry(hose, &hose_list, list_node) { - size = pcibios_io_size(hose); - if (address >= hose->io_base_virt && - address < (hose->io_base_virt + size)) { - ret = 1; - break; - } - } - spin_unlock(&hose_spinlock); - return ret; -} - -unsigned long pci_address_to_pio(phys_addr_t address) -{ - struct pci_controller *hose; - resource_size_t size; - unsigned long ret = ~0; - - spin_lock(&hose_spinlock); - list_for_each_entry(hose, &hose_list, list_node) { - size = pcibios_io_size(hose); - if (address >= hose->io_base_phys && - address < (hose->io_base_phys + size)) { - unsigned long base = - (unsigned long)hose->io_base_virt - _IO_BASE; - ret = base + (address - hose->io_base_phys); - break; - } - } - spin_unlock(&hose_spinlock); - - return ret; -} -EXPORT_SYMBOL_GPL(pci_address_to_pio); - -/* - * Return the domain number for this bus. - */ -int pci_domain_nr(struct pci_bus *bus) -{ - struct pci_controller *hose = pci_bus_to_host(bus); - - return hose->global_number; -} -EXPORT_SYMBOL(pci_domain_nr); - -/* This routine is meant to be used early during boot, when the - * PCI bus numbers have not yet been assigned, and you need to - * issue PCI config cycles to an OF device. - * It could also be used to "fix" RTAS config cycles if you want - * to set pci_assign_all_buses to 1 and still use RTAS for PCI - * config cycles. - */ -struct pci_controller *pci_find_hose_for_OF_device(struct device_node *node) -{ - while (node) { - struct pci_controller *hose, *tmp; - list_for_each_entry_safe(hose, tmp, &hose_list, list_node) - if (hose->dn == node) - return hose; - node = node->parent; - } - return NULL; -} - -static ssize_t pci_show_devspec(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct pci_dev *pdev; - struct device_node *np; - - pdev = to_pci_dev(dev); - np = pci_device_to_OF_node(pdev); - if (np == NULL || np->full_name == NULL) - return 0; - return sprintf(buf, "%s", np->full_name); -} -static DEVICE_ATTR(devspec, S_IRUGO, pci_show_devspec, NULL); - -/* Add sysfs properties */ -int pcibios_add_platform_entries(struct pci_dev *pdev) -{ - return device_create_file(&pdev->dev, &dev_attr_devspec); -} - -char __devinit *pcibios_setup(char *str) -{ - return str; -} - -/* - * Reads the interrupt pin to determine if interrupt is use by card. - * If the interrupt is used, then gets the interrupt line from the - * openfirmware and sets it in the pci_dev and pci_config line. - */ -int pci_read_irq_line(struct pci_dev *pci_dev) -{ - struct of_irq oirq; - unsigned int virq; - - /* The current device-tree that iSeries generates from the HV - * PCI informations doesn't contain proper interrupt routing, - * and all the fallback would do is print out crap, so we - * don't attempt to resolve the interrupts here at all, some - * iSeries specific fixup does it. - * - * In the long run, we will hopefully fix the generated device-tree - * instead. - */ - pr_debug("PCI: Try to map irq for %s...\n", pci_name(pci_dev)); - -#ifdef DEBUG - memset(&oirq, 0xff, sizeof(oirq)); -#endif - /* Try to get a mapping from the device-tree */ - if (of_irq_map_pci(pci_dev, &oirq)) { - u8 line, pin; - - /* If that fails, lets fallback to what is in the config - * space and map that through the default controller. We - * also set the type to level low since that's what PCI - * interrupts are. If your platform does differently, then - * either provide a proper interrupt tree or don't use this - * function. - */ - if (pci_read_config_byte(pci_dev, PCI_INTERRUPT_PIN, &pin)) - return -1; - if (pin == 0) - return -1; - if (pci_read_config_byte(pci_dev, PCI_INTERRUPT_LINE, &line) || - line == 0xff || line == 0) { - return -1; - } - pr_debug(" No map ! Using line %d (pin %d) from PCI config\n", - line, pin); - - virq = irq_create_mapping(NULL, line); - if (virq != NO_IRQ) - set_irq_type(virq, IRQ_TYPE_LEVEL_LOW); - } else { - pr_debug(" Got one, spec %d cells (0x%08x 0x%08x...) on %s\n", - oirq.size, oirq.specifier[0], oirq.specifier[1], - oirq.controller ? oirq.controller->full_name : - ""); - - virq = irq_create_of_mapping(oirq.controller, oirq.specifier, - oirq.size); - } - if (virq == NO_IRQ) { - pr_debug(" Failed to map !\n"); - return -1; - } - - pr_debug(" Mapped to linux irq %d\n", virq); - - pci_dev->irq = virq; - - return 0; -} -EXPORT_SYMBOL(pci_read_irq_line); - -/* - * Platform support for /proc/bus/pci/X/Y mmap()s, - * modelled on the sparc64 implementation by Dave Miller. - * -- paulus. - */ - -/* - * Adjust vm_pgoff of VMA such that it is the physical page offset - * corresponding to the 32-bit pci bus offset for DEV requested by the user. - * - * Basically, the user finds the base address for his device which he wishes - * to mmap. They read the 32-bit value from the config space base register, - * add whatever PAGE_SIZE multiple offset they wish, and feed this into the - * offset parameter of mmap on /proc/bus/pci/XXX for that device. - * - * Returns negative error code on failure, zero on success. - */ -static struct resource *__pci_mmap_make_offset(struct pci_dev *dev, - resource_size_t *offset, - enum pci_mmap_state mmap_state) -{ - struct pci_controller *hose = pci_bus_to_host(dev->bus); - unsigned long io_offset = 0; - int i, res_bit; - - if (hose == 0) - return NULL; /* should never happen */ - - /* If memory, add on the PCI bridge address offset */ - if (mmap_state == pci_mmap_mem) { -#if 0 /* See comment in pci_resource_to_user() for why this is disabled */ - *offset += hose->pci_mem_offset; -#endif - res_bit = IORESOURCE_MEM; - } else { - io_offset = (unsigned long)hose->io_base_virt - _IO_BASE; - *offset += io_offset; - res_bit = IORESOURCE_IO; - } - - /* - * Check that the offset requested corresponds to one of the - * resources of the device. - */ - for (i = 0; i <= PCI_ROM_RESOURCE; i++) { - struct resource *rp = &dev->resource[i]; - int flags = rp->flags; - - /* treat ROM as memory (should be already) */ - if (i == PCI_ROM_RESOURCE) - flags |= IORESOURCE_MEM; - - /* Active and same type? */ - if ((flags & res_bit) == 0) - continue; - - /* In the range of this resource? */ - if (*offset < (rp->start & PAGE_MASK) || *offset > rp->end) - continue; - - /* found it! construct the final physical address */ - if (mmap_state == pci_mmap_io) - *offset += hose->io_base_phys - io_offset; - return rp; - } - - return NULL; -} - -/* - * Set vm_page_prot of VMA, as appropriate for this architecture, for a pci - * device mapping. - */ -static pgprot_t __pci_mmap_set_pgprot(struct pci_dev *dev, struct resource *rp, - pgprot_t protection, - enum pci_mmap_state mmap_state, - int write_combine) -{ - pgprot_t prot = protection; - - /* Write combine is always 0 on non-memory space mappings. On - * memory space, if the user didn't pass 1, we check for a - * "prefetchable" resource. This is a bit hackish, but we use - * this to workaround the inability of /sysfs to provide a write - * combine bit - */ - if (mmap_state != pci_mmap_mem) - write_combine = 0; - else if (write_combine == 0) { - if (rp->flags & IORESOURCE_PREFETCH) - write_combine = 1; - } - - return pgprot_noncached(prot); -} - -/* - * This one is used by /dev/mem and fbdev who have no clue about the - * PCI device, it tries to find the PCI device first and calls the - * above routine - */ -pgprot_t pci_phys_mem_access_prot(struct file *file, - unsigned long pfn, - unsigned long size, - pgprot_t prot) -{ - struct pci_dev *pdev = NULL; - struct resource *found = NULL; - resource_size_t offset = ((resource_size_t)pfn) << PAGE_SHIFT; - int i; - - if (page_is_ram(pfn)) - return prot; - - prot = pgprot_noncached(prot); - for_each_pci_dev(pdev) { - for (i = 0; i <= PCI_ROM_RESOURCE; i++) { - struct resource *rp = &pdev->resource[i]; - int flags = rp->flags; - - /* Active and same type? */ - if ((flags & IORESOURCE_MEM) == 0) - continue; - /* In the range of this resource? */ - if (offset < (rp->start & PAGE_MASK) || - offset > rp->end) - continue; - found = rp; - break; - } - if (found) - break; - } - if (found) { - if (found->flags & IORESOURCE_PREFETCH) - prot = pgprot_noncached_wc(prot); - pci_dev_put(pdev); - } - - pr_debug("PCI: Non-PCI map for %llx, prot: %lx\n", - (unsigned long long)offset, pgprot_val(prot)); - - return prot; -} - -/* - * Perform the actual remap of the pages for a PCI device mapping, as - * appropriate for this architecture. The region in the process to map - * is described by vm_start and vm_end members of VMA, the base physical - * address is found in vm_pgoff. - * The pci device structure is provided so that architectures may make mapping - * decisions on a per-device or per-bus basis. - * - * Returns a negative error code on failure, zero on success. - */ -int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, - enum pci_mmap_state mmap_state, int write_combine) -{ - resource_size_t offset = - ((resource_size_t)vma->vm_pgoff) << PAGE_SHIFT; - struct resource *rp; - int ret; - - rp = __pci_mmap_make_offset(dev, &offset, mmap_state); - if (rp == NULL) - return -EINVAL; - - vma->vm_pgoff = offset >> PAGE_SHIFT; - vma->vm_page_prot = __pci_mmap_set_pgprot(dev, rp, - vma->vm_page_prot, - mmap_state, write_combine); - - ret = remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, - vma->vm_end - vma->vm_start, vma->vm_page_prot); - - return ret; -} - -/* This provides legacy IO read access on a bus */ -int pci_legacy_read(struct pci_bus *bus, loff_t port, u32 *val, size_t size) -{ - unsigned long offset; - struct pci_controller *hose = pci_bus_to_host(bus); - struct resource *rp = &hose->io_resource; - void __iomem *addr; - - /* Check if port can be supported by that bus. We only check - * the ranges of the PHB though, not the bus itself as the rules - * for forwarding legacy cycles down bridges are not our problem - * here. So if the host bridge supports it, we do it. - */ - offset = (unsigned long)hose->io_base_virt - _IO_BASE; - offset += port; - - if (!(rp->flags & IORESOURCE_IO)) - return -ENXIO; - if (offset < rp->start || (offset + size) > rp->end) - return -ENXIO; - addr = hose->io_base_virt + port; - - switch (size) { - case 1: - *((u8 *)val) = in_8(addr); - return 1; - case 2: - if (port & 1) - return -EINVAL; - *((u16 *)val) = in_le16(addr); - return 2; - case 4: - if (port & 3) - return -EINVAL; - *((u32 *)val) = in_le32(addr); - return 4; - } - return -EINVAL; -} - -/* This provides legacy IO write access on a bus */ -int pci_legacy_write(struct pci_bus *bus, loff_t port, u32 val, size_t size) -{ - unsigned long offset; - struct pci_controller *hose = pci_bus_to_host(bus); - struct resource *rp = &hose->io_resource; - void __iomem *addr; - - /* Check if port can be supported by that bus. We only check - * the ranges of the PHB though, not the bus itself as the rules - * for forwarding legacy cycles down bridges are not our problem - * here. So if the host bridge supports it, we do it. - */ - offset = (unsigned long)hose->io_base_virt - _IO_BASE; - offset += port; - - if (!(rp->flags & IORESOURCE_IO)) - return -ENXIO; - if (offset < rp->start || (offset + size) > rp->end) - return -ENXIO; - addr = hose->io_base_virt + port; - - /* WARNING: The generic code is idiotic. It gets passed a pointer - * to what can be a 1, 2 or 4 byte quantity and always reads that - * as a u32, which means that we have to correct the location of - * the data read within those 32 bits for size 1 and 2 - */ - switch (size) { - case 1: - out_8(addr, val >> 24); - return 1; - case 2: - if (port & 1) - return -EINVAL; - out_le16(addr, val >> 16); - return 2; - case 4: - if (port & 3) - return -EINVAL; - out_le32(addr, val); - return 4; - } - return -EINVAL; -} - -/* This provides legacy IO or memory mmap access on a bus */ -int pci_mmap_legacy_page_range(struct pci_bus *bus, - struct vm_area_struct *vma, - enum pci_mmap_state mmap_state) -{ - struct pci_controller *hose = pci_bus_to_host(bus); - resource_size_t offset = - ((resource_size_t)vma->vm_pgoff) << PAGE_SHIFT; - resource_size_t size = vma->vm_end - vma->vm_start; - struct resource *rp; - - pr_debug("pci_mmap_legacy_page_range(%04x:%02x, %s @%llx..%llx)\n", - pci_domain_nr(bus), bus->number, - mmap_state == pci_mmap_mem ? "MEM" : "IO", - (unsigned long long)offset, - (unsigned long long)(offset + size - 1)); - - if (mmap_state == pci_mmap_mem) { - /* Hack alert ! - * - * Because X is lame and can fail starting if it gets an error - * trying to mmap legacy_mem (instead of just moving on without - * legacy memory access) we fake it here by giving it anonymous - * memory, effectively behaving just like /dev/zero - */ - if ((offset + size) > hose->isa_mem_size) { -#ifdef CONFIG_MMU - printk(KERN_DEBUG - "Process %s (pid:%d) mapped non-existing PCI" - "legacy memory for 0%04x:%02x\n", - current->comm, current->pid, pci_domain_nr(bus), - bus->number); -#endif - if (vma->vm_flags & VM_SHARED) - return shmem_zero_setup(vma); - return 0; - } - offset += hose->isa_mem_phys; - } else { - unsigned long io_offset = (unsigned long)hose->io_base_virt - \ - _IO_BASE; - unsigned long roffset = offset + io_offset; - rp = &hose->io_resource; - if (!(rp->flags & IORESOURCE_IO)) - return -ENXIO; - if (roffset < rp->start || (roffset + size) > rp->end) - return -ENXIO; - offset += hose->io_base_phys; - } - pr_debug(" -> mapping phys %llx\n", (unsigned long long)offset); - - vma->vm_pgoff = offset >> PAGE_SHIFT; - vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); - return remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, - vma->vm_end - vma->vm_start, - vma->vm_page_prot); -} - -void pci_resource_to_user(const struct pci_dev *dev, int bar, - const struct resource *rsrc, - resource_size_t *start, resource_size_t *end) -{ - struct pci_controller *hose = pci_bus_to_host(dev->bus); - resource_size_t offset = 0; - - if (hose == NULL) - return; - - if (rsrc->flags & IORESOURCE_IO) - offset = (unsigned long)hose->io_base_virt - _IO_BASE; - - /* We pass a fully fixed up address to userland for MMIO instead of - * a BAR value because X is lame and expects to be able to use that - * to pass to /dev/mem ! - * - * That means that we'll have potentially 64 bits values where some - * userland apps only expect 32 (like X itself since it thinks only - * Sparc has 64 bits MMIO) but if we don't do that, we break it on - * 32 bits CHRPs :-( - * - * Hopefully, the sysfs insterface is immune to that gunk. Once X - * has been fixed (and the fix spread enough), we can re-enable the - * 2 lines below and pass down a BAR value to userland. In that case - * we'll also have to re-enable the matching code in - * __pci_mmap_make_offset(). - * - * BenH. - */ -#if 0 - else if (rsrc->flags & IORESOURCE_MEM) - offset = hose->pci_mem_offset; -#endif - - *start = rsrc->start - offset; - *end = rsrc->end - offset; -} - -/** - * pci_process_bridge_OF_ranges - Parse PCI bridge resources from device tree - * @hose: newly allocated pci_controller to be setup - * @dev: device node of the host bridge - * @primary: set if primary bus (32 bits only, soon to be deprecated) - * - * This function will parse the "ranges" property of a PCI host bridge device - * node and setup the resource mapping of a pci controller based on its - * content. - * - * Life would be boring if it wasn't for a few issues that we have to deal - * with here: - * - * - We can only cope with one IO space range and up to 3 Memory space - * ranges. However, some machines (thanks Apple !) tend to split their - * space into lots of small contiguous ranges. So we have to coalesce. - * - * - We can only cope with all memory ranges having the same offset - * between CPU addresses and PCI addresses. Unfortunately, some bridges - * are setup for a large 1:1 mapping along with a small "window" which - * maps PCI address 0 to some arbitrary high address of the CPU space in - * order to give access to the ISA memory hole. - * The way out of here that I've chosen for now is to always set the - * offset based on the first resource found, then override it if we - * have a different offset and the previous was set by an ISA hole. - * - * - Some busses have IO space not starting at 0, which causes trouble with - * the way we do our IO resource renumbering. The code somewhat deals with - * it for 64 bits but I would expect problems on 32 bits. - * - * - Some 32 bits platforms such as 4xx can have physical space larger than - * 32 bits so we need to use 64 bits values for the parsing - */ -void __devinit pci_process_bridge_OF_ranges(struct pci_controller *hose, - struct device_node *dev, - int primary) -{ - const u32 *ranges; - int rlen; - int pna = of_n_addr_cells(dev); - int np = pna + 5; - int memno = 0, isa_hole = -1; - u32 pci_space; - unsigned long long pci_addr, cpu_addr, pci_next, cpu_next, size; - unsigned long long isa_mb = 0; - struct resource *res; - - printk(KERN_INFO "PCI host bridge %s %s ranges:\n", - dev->full_name, primary ? "(primary)" : ""); - - /* Get ranges property */ - ranges = of_get_property(dev, "ranges", &rlen); - if (ranges == NULL) - return; - - /* Parse it */ - pr_debug("Parsing ranges property...\n"); - while ((rlen -= np * 4) >= 0) { - /* Read next ranges element */ - pci_space = ranges[0]; - pci_addr = of_read_number(ranges + 1, 2); - cpu_addr = of_translate_address(dev, ranges + 3); - size = of_read_number(ranges + pna + 3, 2); - - pr_debug("pci_space: 0x%08x pci_addr:0x%016llx " - "cpu_addr:0x%016llx size:0x%016llx\n", - pci_space, pci_addr, cpu_addr, size); - - ranges += np; - - /* If we failed translation or got a zero-sized region - * (some FW try to feed us with non sensical zero sized regions - * such as power3 which look like some kind of attempt - * at exposing the VGA memory hole) - */ - if (cpu_addr == OF_BAD_ADDR || size == 0) - continue; - - /* Now consume following elements while they are contiguous */ - for (; rlen >= np * sizeof(u32); - ranges += np, rlen -= np * 4) { - if (ranges[0] != pci_space) - break; - pci_next = of_read_number(ranges + 1, 2); - cpu_next = of_translate_address(dev, ranges + 3); - if (pci_next != pci_addr + size || - cpu_next != cpu_addr + size) - break; - size += of_read_number(ranges + pna + 3, 2); - } - - /* Act based on address space type */ - res = NULL; - switch ((pci_space >> 24) & 0x3) { - case 1: /* PCI IO space */ - printk(KERN_INFO - " IO 0x%016llx..0x%016llx -> 0x%016llx\n", - cpu_addr, cpu_addr + size - 1, pci_addr); - - /* We support only one IO range */ - if (hose->pci_io_size) { - printk(KERN_INFO - " \\--> Skipped (too many) !\n"); - continue; - } - /* On 32 bits, limit I/O space to 16MB */ - if (size > 0x01000000) - size = 0x01000000; - - /* 32 bits needs to map IOs here */ - hose->io_base_virt = ioremap(cpu_addr, size); - - /* Expect trouble if pci_addr is not 0 */ - if (primary) - isa_io_base = - (unsigned long)hose->io_base_virt; - /* pci_io_size and io_base_phys always represent IO - * space starting at 0 so we factor in pci_addr - */ - hose->pci_io_size = pci_addr + size; - hose->io_base_phys = cpu_addr - pci_addr; - - /* Build resource */ - res = &hose->io_resource; - res->flags = IORESOURCE_IO; - res->start = pci_addr; - break; - case 2: /* PCI Memory space */ - case 3: /* PCI 64 bits Memory space */ - printk(KERN_INFO - " MEM 0x%016llx..0x%016llx -> 0x%016llx %s\n", - cpu_addr, cpu_addr + size - 1, pci_addr, - (pci_space & 0x40000000) ? "Prefetch" : ""); - - /* We support only 3 memory ranges */ - if (memno >= 3) { - printk(KERN_INFO - " \\--> Skipped (too many) !\n"); - continue; - } - /* Handles ISA memory hole space here */ - if (pci_addr == 0) { - isa_mb = cpu_addr; - isa_hole = memno; - if (primary || isa_mem_base == 0) - isa_mem_base = cpu_addr; - hose->isa_mem_phys = cpu_addr; - hose->isa_mem_size = size; - } - - /* We get the PCI/Mem offset from the first range or - * the, current one if the offset came from an ISA - * hole. If they don't match, bugger. - */ - if (memno == 0 || - (isa_hole >= 0 && pci_addr != 0 && - hose->pci_mem_offset == isa_mb)) - hose->pci_mem_offset = cpu_addr - pci_addr; - else if (pci_addr != 0 && - hose->pci_mem_offset != cpu_addr - pci_addr) { - printk(KERN_INFO - " \\--> Skipped (offset mismatch) !\n"); - continue; - } - - /* Build resource */ - res = &hose->mem_resources[memno++]; - res->flags = IORESOURCE_MEM; - if (pci_space & 0x40000000) - res->flags |= IORESOURCE_PREFETCH; - res->start = cpu_addr; - break; - } - if (res != NULL) { - res->name = dev->full_name; - res->end = res->start + size - 1; - res->parent = NULL; - res->sibling = NULL; - res->child = NULL; - } - } - - /* If there's an ISA hole and the pci_mem_offset is -not- matching - * the ISA hole offset, then we need to remove the ISA hole from - * the resource list for that brige - */ - if (isa_hole >= 0 && hose->pci_mem_offset != isa_mb) { - unsigned int next = isa_hole + 1; - printk(KERN_INFO " Removing ISA hole at 0x%016llx\n", isa_mb); - if (next < memno) - memmove(&hose->mem_resources[isa_hole], - &hose->mem_resources[next], - sizeof(struct resource) * (memno - next)); - hose->mem_resources[--memno].flags = 0; - } -} - -/* Decide whether to display the domain number in /proc */ -int pci_proc_domain(struct pci_bus *bus) -{ - struct pci_controller *hose = pci_bus_to_host(bus); - - if (!(pci_flags & PCI_ENABLE_PROC_DOMAINS)) - return 0; - if (pci_flags & PCI_COMPAT_DOMAIN_0) - return hose->global_number != 0; - return 1; -} - -void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, - struct resource *res) -{ - resource_size_t offset = 0, mask = (resource_size_t)-1; - struct pci_controller *hose = pci_bus_to_host(dev->bus); - - if (!hose) - return; - if (res->flags & IORESOURCE_IO) { - offset = (unsigned long)hose->io_base_virt - _IO_BASE; - mask = 0xffffffffu; - } else if (res->flags & IORESOURCE_MEM) - offset = hose->pci_mem_offset; - - region->start = (res->start - offset) & mask; - region->end = (res->end - offset) & mask; -} -EXPORT_SYMBOL(pcibios_resource_to_bus); - -void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, - struct pci_bus_region *region) -{ - resource_size_t offset = 0, mask = (resource_size_t)-1; - struct pci_controller *hose = pci_bus_to_host(dev->bus); - - if (!hose) - return; - if (res->flags & IORESOURCE_IO) { - offset = (unsigned long)hose->io_base_virt - _IO_BASE; - mask = 0xffffffffu; - } else if (res->flags & IORESOURCE_MEM) - offset = hose->pci_mem_offset; - res->start = (region->start + offset) & mask; - res->end = (region->end + offset) & mask; -} -EXPORT_SYMBOL(pcibios_bus_to_resource); - -/* Fixup a bus resource into a linux resource */ -static void __devinit fixup_resource(struct resource *res, struct pci_dev *dev) -{ - struct pci_controller *hose = pci_bus_to_host(dev->bus); - resource_size_t offset = 0, mask = (resource_size_t)-1; - - if (res->flags & IORESOURCE_IO) { - offset = (unsigned long)hose->io_base_virt - _IO_BASE; - mask = 0xffffffffu; - } else if (res->flags & IORESOURCE_MEM) - offset = hose->pci_mem_offset; - - res->start = (res->start + offset) & mask; - res->end = (res->end + offset) & mask; -} - -/* This header fixup will do the resource fixup for all devices as they are - * probed, but not for bridge ranges - */ -static void __devinit pcibios_fixup_resources(struct pci_dev *dev) -{ - struct pci_controller *hose = pci_bus_to_host(dev->bus); - int i; - - if (!hose) { - printk(KERN_ERR "No host bridge for PCI dev %s !\n", - pci_name(dev)); - return; - } - for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { - struct resource *res = dev->resource + i; - if (!res->flags) - continue; - /* On platforms that have PCI_PROBE_ONLY set, we don't - * consider 0 as an unassigned BAR value. It's technically - * a valid value, but linux doesn't like it... so when we can - * re-assign things, we do so, but if we can't, we keep it - * around and hope for the best... - */ - if (res->start == 0 && !(pci_flags & PCI_PROBE_ONLY)) { - pr_debug("PCI:%s Resource %d %016llx-%016llx [%x]" \ - "is unassigned\n", - pci_name(dev), i, - (unsigned long long)res->start, - (unsigned long long)res->end, - (unsigned int)res->flags); - res->end -= res->start; - res->start = 0; - res->flags |= IORESOURCE_UNSET; - continue; - } - - pr_debug("PCI:%s Resource %d %016llx-%016llx [%x] fixup...\n", - pci_name(dev), i, - (unsigned long long)res->start,\ - (unsigned long long)res->end, - (unsigned int)res->flags); - - fixup_resource(res, dev); - - pr_debug("PCI:%s %016llx-%016llx\n", - pci_name(dev), - (unsigned long long)res->start, - (unsigned long long)res->end); - } -} -DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pcibios_fixup_resources); - -/* This function tries to figure out if a bridge resource has been initialized - * by the firmware or not. It doesn't have to be absolutely bullet proof, but - * things go more smoothly when it gets it right. It should covers cases such - * as Apple "closed" bridge resources and bare-metal pSeries unassigned bridges - */ -static int __devinit pcibios_uninitialized_bridge_resource(struct pci_bus *bus, - struct resource *res) -{ - struct pci_controller *hose = pci_bus_to_host(bus); - struct pci_dev *dev = bus->self; - resource_size_t offset; - u16 command; - int i; - - /* We don't do anything if PCI_PROBE_ONLY is set */ - if (pci_flags & PCI_PROBE_ONLY) - return 0; - - /* Job is a bit different between memory and IO */ - if (res->flags & IORESOURCE_MEM) { - /* If the BAR is non-0 (res != pci_mem_offset) then it's - * probably been initialized by somebody - */ - if (res->start != hose->pci_mem_offset) - return 0; - - /* The BAR is 0, let's check if memory decoding is enabled on - * the bridge. If not, we consider it unassigned - */ - pci_read_config_word(dev, PCI_COMMAND, &command); - if ((command & PCI_COMMAND_MEMORY) == 0) - return 1; - - /* Memory decoding is enabled and the BAR is 0. If any of - * the bridge resources covers that starting address (0 then - * it's good enough for us for memory - */ - for (i = 0; i < 3; i++) { - if ((hose->mem_resources[i].flags & IORESOURCE_MEM) && - hose->mem_resources[i].start == hose->pci_mem_offset) - return 0; - } - - /* Well, it starts at 0 and we know it will collide so we may as - * well consider it as unassigned. That covers the Apple case. - */ - return 1; - } else { - /* If the BAR is non-0, then we consider it assigned */ - offset = (unsigned long)hose->io_base_virt - _IO_BASE; - if (((res->start - offset) & 0xfffffffful) != 0) - return 0; - - /* Here, we are a bit different than memory as typically IO - * space starting at low addresses -is- valid. What we do - * instead if that we consider as unassigned anything that - * doesn't have IO enabled in the PCI command register, - * and that's it. - */ - pci_read_config_word(dev, PCI_COMMAND, &command); - if (command & PCI_COMMAND_IO) - return 0; - - /* It's starting at 0 and IO is disabled in the bridge, consider - * it unassigned - */ - return 1; - } -} - -/* Fixup resources of a PCI<->PCI bridge */ -static void __devinit pcibios_fixup_bridge(struct pci_bus *bus) -{ - struct resource *res; - int i; - - struct pci_dev *dev = bus->self; - - for (i = 0; i < PCI_BUS_NUM_RESOURCES; ++i) { - res = bus->resource[i]; - if (!res) - continue; - if (!res->flags) - continue; - if (i >= 3 && bus->self->transparent) - continue; - - pr_debug("PCI:%s Bus rsrc %d %016llx-%016llx [%x] fixup...\n", - pci_name(dev), i, - (unsigned long long)res->start,\ - (unsigned long long)res->end, - (unsigned int)res->flags); - - /* Perform fixup */ - fixup_resource(res, dev); - - /* Try to detect uninitialized P2P bridge resources, - * and clear them out so they get re-assigned later - */ - if (pcibios_uninitialized_bridge_resource(bus, res)) { - res->flags = 0; - pr_debug("PCI:%s (unassigned)\n", - pci_name(dev)); - } else { - pr_debug("PCI:%s %016llx-%016llx\n", - pci_name(dev), - (unsigned long long)res->start, - (unsigned long long)res->end); - } - } -} - -void __devinit pcibios_setup_bus_self(struct pci_bus *bus) -{ - /* Fix up the bus resources for P2P bridges */ - if (bus->self != NULL) - pcibios_fixup_bridge(bus); -} - -void __devinit pcibios_setup_bus_devices(struct pci_bus *bus) -{ - struct pci_dev *dev; - - pr_debug("PCI: Fixup bus devices %d (%s)\n", - bus->number, bus->self ? pci_name(bus->self) : "PHB"); - - list_for_each_entry(dev, &bus->devices, bus_list) { - struct dev_archdata *sd = &dev->dev.archdata; - - /* Setup OF node pointer in archdata */ - sd->of_node = pci_device_to_OF_node(dev); - - /* Fixup NUMA node as it may not be setup yet by the generic - * code and is needed by the DMA init - */ - set_dev_node(&dev->dev, pcibus_to_node(dev->bus)); - - /* Hook up default DMA ops */ - sd->dma_ops = pci_dma_ops; - sd->dma_data = (void *)PCI_DRAM_OFFSET; - - /* Read default IRQs and fixup if necessary */ - pci_read_irq_line(dev); - } -} - -void __devinit pcibios_fixup_bus(struct pci_bus *bus) -{ - /* When called from the generic PCI probe, read PCI<->PCI bridge - * bases. This is -not- called when generating the PCI tree from - * the OF device-tree. - */ - if (bus->self != NULL) - pci_read_bridge_bases(bus); - - /* Now fixup the bus bus */ - pcibios_setup_bus_self(bus); - - /* Now fixup devices on that bus */ - pcibios_setup_bus_devices(bus); -} -EXPORT_SYMBOL(pcibios_fixup_bus); - -static int skip_isa_ioresource_align(struct pci_dev *dev) -{ - if ((pci_flags & PCI_CAN_SKIP_ISA_ALIGN) && - !(dev->bus->bridge_ctl & PCI_BRIDGE_CTL_ISA)) - return 1; - return 0; -} - -/* - * We need to avoid collisions with `mirrored' VGA ports - * and other strange ISA hardware, so we always want the - * addresses to be allocated in the 0x000-0x0ff region - * modulo 0x400. - * - * Why? Because some silly external IO cards only decode - * the low 10 bits of the IO address. The 0x00-0xff region - * is reserved for motherboard devices that decode all 16 - * bits, so it's ok to allocate at, say, 0x2800-0x28ff, - * but we want to try to avoid allocating at 0x2900-0x2bff - * which might have be mirrored at 0x0100-0x03ff.. - */ -void pcibios_align_resource(void *data, struct resource *res, - resource_size_t size, resource_size_t align) -{ - struct pci_dev *dev = data; - - if (res->flags & IORESOURCE_IO) { - resource_size_t start = res->start; - - if (skip_isa_ioresource_align(dev)) - return; - if (start & 0x300) { - start = (start + 0x3ff) & ~0x3ff; - res->start = start; - } - } -} -EXPORT_SYMBOL(pcibios_align_resource); - -/* - * Reparent resource children of pr that conflict with res - * under res, and make res replace those children. - */ -static int __init reparent_resources(struct resource *parent, - struct resource *res) -{ - struct resource *p, **pp; - struct resource **firstpp = NULL; - - for (pp = &parent->child; (p = *pp) != NULL; pp = &p->sibling) { - if (p->end < res->start) - continue; - if (res->end < p->start) - break; - if (p->start < res->start || p->end > res->end) - return -1; /* not completely contained */ - if (firstpp == NULL) - firstpp = pp; - } - if (firstpp == NULL) - return -1; /* didn't find any conflicting entries? */ - res->parent = parent; - res->child = *firstpp; - res->sibling = *pp; - *firstpp = res; - *pp = NULL; - for (p = res->child; p != NULL; p = p->sibling) { - p->parent = res; - pr_debug("PCI: Reparented %s [%llx..%llx] under %s\n", - p->name, - (unsigned long long)p->start, - (unsigned long long)p->end, res->name); - } - return 0; -} - -/* - * Handle resources of PCI devices. If the world were perfect, we could - * just allocate all the resource regions and do nothing more. It isn't. - * On the other hand, we cannot just re-allocate all devices, as it would - * require us to know lots of host bridge internals. So we attempt to - * keep as much of the original configuration as possible, but tweak it - * when it's found to be wrong. - * - * Known BIOS problems we have to work around: - * - I/O or memory regions not configured - * - regions configured, but not enabled in the command register - * - bogus I/O addresses above 64K used - * - expansion ROMs left enabled (this may sound harmless, but given - * the fact the PCI specs explicitly allow address decoders to be - * shared between expansion ROMs and other resource regions, it's - * at least dangerous) - * - * Our solution: - * (1) Allocate resources for all buses behind PCI-to-PCI bridges. - * This gives us fixed barriers on where we can allocate. - * (2) Allocate resources for all enabled devices. If there is - * a collision, just mark the resource as unallocated. Also - * disable expansion ROMs during this step. - * (3) Try to allocate resources for disabled devices. If the - * resources were assigned correctly, everything goes well, - * if they weren't, they won't disturb allocation of other - * resources. - * (4) Assign new addresses to resources which were either - * not configured at all or misconfigured. If explicitly - * requested by the user, configure expansion ROM address - * as well. - */ - -void pcibios_allocate_bus_resources(struct pci_bus *bus) -{ - struct pci_bus *b; - int i; - struct resource *res, *pr; - - pr_debug("PCI: Allocating bus resources for %04x:%02x...\n", - pci_domain_nr(bus), bus->number); - - for (i = 0; i < PCI_BUS_NUM_RESOURCES; ++i) { - res = bus->resource[i]; - if (!res || !res->flags - || res->start > res->end || res->parent) - continue; - if (bus->parent == NULL) - pr = (res->flags & IORESOURCE_IO) ? - &ioport_resource : &iomem_resource; - else { - /* Don't bother with non-root busses when - * re-assigning all resources. We clear the - * resource flags as if they were colliding - * and as such ensure proper re-allocation - * later. - */ - if (pci_flags & PCI_REASSIGN_ALL_RSRC) - goto clear_resource; - pr = pci_find_parent_resource(bus->self, res); - if (pr == res) { - /* this happens when the generic PCI - * code (wrongly) decides that this - * bridge is transparent -- paulus - */ - continue; - } - } - - pr_debug("PCI: %s (bus %d) bridge rsrc %d: %016llx-%016llx " - "[0x%x], parent %p (%s)\n", - bus->self ? pci_name(bus->self) : "PHB", - bus->number, i, - (unsigned long long)res->start, - (unsigned long long)res->end, - (unsigned int)res->flags, - pr, (pr && pr->name) ? pr->name : "nil"); - - if (pr && !(pr->flags & IORESOURCE_UNSET)) { - if (request_resource(pr, res) == 0) - continue; - /* - * Must be a conflict with an existing entry. - * Move that entry (or entries) under the - * bridge resource and try again. - */ - if (reparent_resources(pr, res) == 0) - continue; - } - printk(KERN_WARNING "PCI: Cannot allocate resource region " - "%d of PCI bridge %d, will remap\n", i, bus->number); -clear_resource: - res->flags = 0; - } - - list_for_each_entry(b, &bus->children, node) - pcibios_allocate_bus_resources(b); -} - -static inline void __devinit alloc_resource(struct pci_dev *dev, int idx) -{ - struct resource *pr, *r = &dev->resource[idx]; - - pr_debug("PCI: Allocating %s: Resource %d: %016llx..%016llx [%x]\n", - pci_name(dev), idx, - (unsigned long long)r->start, - (unsigned long long)r->end, - (unsigned int)r->flags); - - pr = pci_find_parent_resource(dev, r); - if (!pr || (pr->flags & IORESOURCE_UNSET) || - request_resource(pr, r) < 0) { - printk(KERN_WARNING "PCI: Cannot allocate resource region %d" - " of device %s, will remap\n", idx, pci_name(dev)); - if (pr) - pr_debug("PCI: parent is %p: %016llx-%016llx [%x]\n", - pr, - (unsigned long long)pr->start, - (unsigned long long)pr->end, - (unsigned int)pr->flags); - /* We'll assign a new address later */ - r->flags |= IORESOURCE_UNSET; - r->end -= r->start; - r->start = 0; - } -} - -static void __init pcibios_allocate_resources(int pass) -{ - struct pci_dev *dev = NULL; - int idx, disabled; - u16 command; - struct resource *r; - - for_each_pci_dev(dev) { - pci_read_config_word(dev, PCI_COMMAND, &command); - for (idx = 0; idx <= PCI_ROM_RESOURCE; idx++) { - r = &dev->resource[idx]; - if (r->parent) /* Already allocated */ - continue; - if (!r->flags || (r->flags & IORESOURCE_UNSET)) - continue; /* Not assigned at all */ - /* We only allocate ROMs on pass 1 just in case they - * have been screwed up by firmware - */ - if (idx == PCI_ROM_RESOURCE) - disabled = 1; - if (r->flags & IORESOURCE_IO) - disabled = !(command & PCI_COMMAND_IO); - else - disabled = !(command & PCI_COMMAND_MEMORY); - if (pass == disabled) - alloc_resource(dev, idx); - } - if (pass) - continue; - r = &dev->resource[PCI_ROM_RESOURCE]; - if (r->flags) { - /* Turn the ROM off, leave the resource region, - * but keep it unregistered. - */ - u32 reg; - pci_read_config_dword(dev, dev->rom_base_reg, ®); - if (reg & PCI_ROM_ADDRESS_ENABLE) { - pr_debug("PCI: Switching off ROM of %s\n", - pci_name(dev)); - r->flags &= ~IORESOURCE_ROM_ENABLE; - pci_write_config_dword(dev, dev->rom_base_reg, - reg & ~PCI_ROM_ADDRESS_ENABLE); - } - } - } -} - -static void __init pcibios_reserve_legacy_regions(struct pci_bus *bus) -{ - struct pci_controller *hose = pci_bus_to_host(bus); - resource_size_t offset; - struct resource *res, *pres; - int i; - - pr_debug("Reserving legacy ranges for domain %04x\n", - pci_domain_nr(bus)); - - /* Check for IO */ - if (!(hose->io_resource.flags & IORESOURCE_IO)) - goto no_io; - offset = (unsigned long)hose->io_base_virt - _IO_BASE; - res = kzalloc(sizeof(struct resource), GFP_KERNEL); - BUG_ON(res == NULL); - res->name = "Legacy IO"; - res->flags = IORESOURCE_IO; - res->start = offset; - res->end = (offset + 0xfff) & 0xfffffffful; - pr_debug("Candidate legacy IO: %pR\n", res); - if (request_resource(&hose->io_resource, res)) { - printk(KERN_DEBUG - "PCI %04x:%02x Cannot reserve Legacy IO %pR\n", - pci_domain_nr(bus), bus->number, res); - kfree(res); - } - - no_io: - /* Check for memory */ - offset = hose->pci_mem_offset; - pr_debug("hose mem offset: %016llx\n", (unsigned long long)offset); - for (i = 0; i < 3; i++) { - pres = &hose->mem_resources[i]; - if (!(pres->flags & IORESOURCE_MEM)) - continue; - pr_debug("hose mem res: %pR\n", pres); - if ((pres->start - offset) <= 0xa0000 && - (pres->end - offset) >= 0xbffff) - break; - } - if (i >= 3) - return; - res = kzalloc(sizeof(struct resource), GFP_KERNEL); - BUG_ON(res == NULL); - res->name = "Legacy VGA memory"; - res->flags = IORESOURCE_MEM; - res->start = 0xa0000 + offset; - res->end = 0xbffff + offset; - pr_debug("Candidate VGA memory: %pR\n", res); - if (request_resource(pres, res)) { - printk(KERN_DEBUG - "PCI %04x:%02x Cannot reserve VGA memory %pR\n", - pci_domain_nr(bus), bus->number, res); - kfree(res); - } -} - -void __init pcibios_resource_survey(void) -{ - struct pci_bus *b; - - /* Allocate and assign resources. If we re-assign everything, then - * we skip the allocate phase - */ - list_for_each_entry(b, &pci_root_buses, node) - pcibios_allocate_bus_resources(b); - - if (!(pci_flags & PCI_REASSIGN_ALL_RSRC)) { - pcibios_allocate_resources(0); - pcibios_allocate_resources(1); - } - - /* Before we start assigning unassigned resource, we try to reserve - * the low IO area and the VGA memory area if they intersect the - * bus available resources to avoid allocating things on top of them - */ - if (!(pci_flags & PCI_PROBE_ONLY)) { - list_for_each_entry(b, &pci_root_buses, node) - pcibios_reserve_legacy_regions(b); - } - - /* Now, if the platform didn't decide to blindly trust the firmware, - * we proceed to assigning things that were left unassigned - */ - if (!(pci_flags & PCI_PROBE_ONLY)) { - pr_debug("PCI: Assigning unassigned resources...\n"); - pci_assign_unassigned_resources(); - } -} - -#ifdef CONFIG_HOTPLUG - -/* This is used by the PCI hotplug driver to allocate resource - * of newly plugged busses. We can try to consolidate with the - * rest of the code later, for now, keep it as-is as our main - * resource allocation function doesn't deal with sub-trees yet. - */ -void __devinit pcibios_claim_one_bus(struct pci_bus *bus) -{ - struct pci_dev *dev; - struct pci_bus *child_bus; - - list_for_each_entry(dev, &bus->devices, bus_list) { - int i; - - for (i = 0; i < PCI_NUM_RESOURCES; i++) { - struct resource *r = &dev->resource[i]; - - if (r->parent || !r->start || !r->flags) - continue; - - pr_debug("PCI: Claiming %s: " - "Resource %d: %016llx..%016llx [%x]\n", - pci_name(dev), i, - (unsigned long long)r->start, - (unsigned long long)r->end, - (unsigned int)r->flags); - - pci_claim_resource(dev, i); - } - } - - list_for_each_entry(child_bus, &bus->children, node) - pcibios_claim_one_bus(child_bus); -} -EXPORT_SYMBOL_GPL(pcibios_claim_one_bus); - - -/* pcibios_finish_adding_to_bus - * - * This is to be called by the hotplug code after devices have been - * added to a bus, this include calling it for a PHB that is just - * being added - */ -void pcibios_finish_adding_to_bus(struct pci_bus *bus) -{ - pr_debug("PCI: Finishing adding to hotplug bus %04x:%02x\n", - pci_domain_nr(bus), bus->number); - - /* Allocate bus and devices resources */ - pcibios_allocate_bus_resources(bus); - pcibios_claim_one_bus(bus); - - /* Add new devices to global lists. Register in proc, sysfs. */ - pci_bus_add_devices(bus); - - /* Fixup EEH */ - eeh_add_device_tree_late(bus); -} -EXPORT_SYMBOL_GPL(pcibios_finish_adding_to_bus); - -#endif /* CONFIG_HOTPLUG */ - -int pcibios_enable_device(struct pci_dev *dev, int mask) -{ - return pci_enable_resources(dev, mask); -} - -void __devinit pcibios_setup_phb_resources(struct pci_controller *hose) -{ - struct pci_bus *bus = hose->bus; - struct resource *res; - int i; - - /* Hookup PHB IO resource */ - bus->resource[0] = res = &hose->io_resource; - - if (!res->flags) { - printk(KERN_WARNING "PCI: I/O resource not set for host" - " bridge %s (domain %d)\n", - hose->dn->full_name, hose->global_number); - /* Workaround for lack of IO resource only on 32-bit */ - res->start = (unsigned long)hose->io_base_virt - isa_io_base; - res->end = res->start + IO_SPACE_LIMIT; - res->flags = IORESOURCE_IO; - } - - pr_debug("PCI: PHB IO resource = %016llx-%016llx [%lx]\n", - (unsigned long long)res->start, - (unsigned long long)res->end, - (unsigned long)res->flags); - - /* Hookup PHB Memory resources */ - for (i = 0; i < 3; ++i) { - res = &hose->mem_resources[i]; - if (!res->flags) { - if (i > 0) - continue; - printk(KERN_ERR "PCI: Memory resource 0 not set for " - "host bridge %s (domain %d)\n", - hose->dn->full_name, hose->global_number); - - /* Workaround for lack of MEM resource only on 32-bit */ - res->start = hose->pci_mem_offset; - res->end = (resource_size_t)-1LL; - res->flags = IORESOURCE_MEM; - - } - bus->resource[i+1] = res; - - pr_debug("PCI: PHB MEM resource %d = %016llx-%016llx [%lx]\n", - i, (unsigned long long)res->start, - (unsigned long long)res->end, - (unsigned long)res->flags); - } - - pr_debug("PCI: PHB MEM offset = %016llx\n", - (unsigned long long)hose->pci_mem_offset); - pr_debug("PCI: PHB IO offset = %08lx\n", - (unsigned long)hose->io_base_virt - _IO_BASE); -} - -/* - * Null PCI config access functions, for the case when we can't - * find a hose. - */ -#define NULL_PCI_OP(rw, size, type) \ -static int \ -null_##rw##_config_##size(struct pci_dev *dev, int offset, type val) \ -{ \ - return PCIBIOS_DEVICE_NOT_FOUND; \ -} - -static int -null_read_config(struct pci_bus *bus, unsigned int devfn, int offset, - int len, u32 *val) -{ - return PCIBIOS_DEVICE_NOT_FOUND; -} - -static int -null_write_config(struct pci_bus *bus, unsigned int devfn, int offset, - int len, u32 val) -{ - return PCIBIOS_DEVICE_NOT_FOUND; -} - -static struct pci_ops null_pci_ops = { - .read = null_read_config, - .write = null_write_config, -}; - -/* - * These functions are used early on before PCI scanning is done - * and all of the pci_dev and pci_bus structures have been created. - */ -static struct pci_bus * -fake_pci_bus(struct pci_controller *hose, int busnr) -{ - static struct pci_bus bus; - - if (!hose) - printk(KERN_ERR "Can't find hose for PCI bus %d!\n", busnr); - - bus.number = busnr; - bus.sysdata = hose; - bus.ops = hose ? hose->ops : &null_pci_ops; - return &bus; -} - -#define EARLY_PCI_OP(rw, size, type) \ -int early_##rw##_config_##size(struct pci_controller *hose, int bus, \ - int devfn, int offset, type value) \ -{ \ - return pci_bus_##rw##_config_##size(fake_pci_bus(hose, bus), \ - devfn, offset, value); \ -} - -EARLY_PCI_OP(read, byte, u8 *) -EARLY_PCI_OP(read, word, u16 *) -EARLY_PCI_OP(read, dword, u32 *) -EARLY_PCI_OP(write, byte, u8) -EARLY_PCI_OP(write, word, u16) -EARLY_PCI_OP(write, dword, u32) - -int early_find_capability(struct pci_controller *hose, int bus, int devfn, - int cap) -{ - return pci_bus_find_capability(fake_pci_bus(hose, bus), devfn, cap); -} diff --git a/trunk/arch/microblaze/pci/pci_32.c b/trunk/arch/microblaze/pci/pci_32.c deleted file mode 100644 index 7e0c94f501cc..000000000000 --- a/trunk/arch/microblaze/pci/pci_32.c +++ /dev/null @@ -1,430 +0,0 @@ -/* - * Common pmac/prep/chrp pci routines. -- Cort - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#undef DEBUG - -unsigned long isa_io_base; -unsigned long pci_dram_offset; -int pcibios_assign_bus_offset = 1; - -static u8 *pci_to_OF_bus_map; - -/* By default, we don't re-assign bus numbers. We do this only on - * some pmacs - */ -static int pci_assign_all_buses; - -static int pci_bus_count; - -/* - * Functions below are used on OpenFirmware machines. - */ -static void -make_one_node_map(struct device_node *node, u8 pci_bus) -{ - const int *bus_range; - int len; - - if (pci_bus >= pci_bus_count) - return; - bus_range = of_get_property(node, "bus-range", &len); - if (bus_range == NULL || len < 2 * sizeof(int)) { - printk(KERN_WARNING "Can't get bus-range for %s, " - "assuming it starts at 0\n", node->full_name); - pci_to_OF_bus_map[pci_bus] = 0; - } else - pci_to_OF_bus_map[pci_bus] = bus_range[0]; - - for_each_child_of_node(node, node) { - struct pci_dev *dev; - const unsigned int *class_code, *reg; - - class_code = of_get_property(node, "class-code", NULL); - if (!class_code || - ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI && - (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS)) - continue; - reg = of_get_property(node, "reg", NULL); - if (!reg) - continue; - dev = pci_get_bus_and_slot(pci_bus, ((reg[0] >> 8) & 0xff)); - if (!dev || !dev->subordinate) { - pci_dev_put(dev); - continue; - } - make_one_node_map(node, dev->subordinate->number); - pci_dev_put(dev); - } -} - -void -pcibios_make_OF_bus_map(void) -{ - int i; - struct pci_controller *hose, *tmp; - struct property *map_prop; - struct device_node *dn; - - pci_to_OF_bus_map = kmalloc(pci_bus_count, GFP_KERNEL); - if (!pci_to_OF_bus_map) { - printk(KERN_ERR "Can't allocate OF bus map !\n"); - return; - } - - /* We fill the bus map with invalid values, that helps - * debugging. - */ - for (i = 0; i < pci_bus_count; i++) - pci_to_OF_bus_map[i] = 0xff; - - /* For each hose, we begin searching bridges */ - list_for_each_entry_safe(hose, tmp, &hose_list, list_node) { - struct device_node *node = hose->dn; - - if (!node) - continue; - make_one_node_map(node, hose->first_busno); - } - dn = of_find_node_by_path("/"); - map_prop = of_find_property(dn, "pci-OF-bus-map", NULL); - if (map_prop) { - BUG_ON(pci_bus_count > map_prop->length); - memcpy(map_prop->value, pci_to_OF_bus_map, pci_bus_count); - } - of_node_put(dn); -#ifdef DEBUG - printk(KERN_INFO "PCI->OF bus map:\n"); - for (i = 0; i < pci_bus_count; i++) { - if (pci_to_OF_bus_map[i] == 0xff) - continue; - printk(KERN_INFO "%d -> %d\n", i, pci_to_OF_bus_map[i]); - } -#endif -} - -typedef int (*pci_OF_scan_iterator)(struct device_node *node, void *data); - -static struct device_node *scan_OF_pci_childs(struct device_node *parent, - pci_OF_scan_iterator filter, void *data) -{ - struct device_node *node; - struct device_node *sub_node; - - for_each_child_of_node(parent, node) { - const unsigned int *class_code; - - if (filter(node, data)) { - of_node_put(node); - return node; - } - - /* For PCI<->PCI bridges or CardBus bridges, we go down - * Note: some OFs create a parent node "multifunc-device" as - * a fake root for all functions of a multi-function device, - * we go down them as well. - */ - class_code = of_get_property(node, "class-code", NULL); - if ((!class_code || - ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI && - (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS)) && - strcmp(node->name, "multifunc-device")) - continue; - sub_node = scan_OF_pci_childs(node, filter, data); - if (sub_node) { - of_node_put(node); - return sub_node; - } - } - return NULL; -} - -static struct device_node *scan_OF_for_pci_dev(struct device_node *parent, - unsigned int devfn) -{ - struct device_node *np, *cnp; - const u32 *reg; - unsigned int psize; - - for_each_child_of_node(parent, np) { - reg = of_get_property(np, "reg", &psize); - if (reg && psize >= 4 && ((reg[0] >> 8) & 0xff) == devfn) - return np; - - /* Note: some OFs create a parent node "multifunc-device" as - * a fake root for all functions of a multi-function device, - * we go down them as well. */ - if (!strcmp(np->name, "multifunc-device")) { - cnp = scan_OF_for_pci_dev(np, devfn); - if (cnp) - return cnp; - } - } - return NULL; -} - - -static struct device_node *scan_OF_for_pci_bus(struct pci_bus *bus) -{ - struct device_node *parent, *np; - - /* Are we a root bus ? */ - if (bus->self == NULL || bus->parent == NULL) { - struct pci_controller *hose = pci_bus_to_host(bus); - if (hose == NULL) - return NULL; - return of_node_get(hose->dn); - } - - /* not a root bus, we need to get our parent */ - parent = scan_OF_for_pci_bus(bus->parent); - if (parent == NULL) - return NULL; - - /* now iterate for children for a match */ - np = scan_OF_for_pci_dev(parent, bus->self->devfn); - of_node_put(parent); - - return np; -} - -/* - * Scans the OF tree for a device node matching a PCI device - */ -struct device_node * -pci_busdev_to_OF_node(struct pci_bus *bus, int devfn) -{ - struct device_node *parent, *np; - - pr_debug("pci_busdev_to_OF_node(%d,0x%x)\n", bus->number, devfn); - parent = scan_OF_for_pci_bus(bus); - if (parent == NULL) - return NULL; - pr_debug(" parent is %s\n", parent ? parent->full_name : ""); - np = scan_OF_for_pci_dev(parent, devfn); - of_node_put(parent); - pr_debug(" result is %s\n", np ? np->full_name : ""); - - /* XXX most callers don't release the returned node - * mostly because ppc64 doesn't increase the refcount, - * we need to fix that. - */ - return np; -} -EXPORT_SYMBOL(pci_busdev_to_OF_node); - -struct device_node* -pci_device_to_OF_node(struct pci_dev *dev) -{ - return pci_busdev_to_OF_node(dev->bus, dev->devfn); -} -EXPORT_SYMBOL(pci_device_to_OF_node); - -static int -find_OF_pci_device_filter(struct device_node *node, void *data) -{ - return ((void *)node == data); -} - -/* - * Returns the PCI device matching a given OF node - */ -int -pci_device_from_OF_node(struct device_node *node, u8 *bus, u8 *devfn) -{ - const unsigned int *reg; - struct pci_controller *hose; - struct pci_dev *dev = NULL; - - /* Make sure it's really a PCI device */ - hose = pci_find_hose_for_OF_device(node); - if (!hose || !hose->dn) - return -ENODEV; - if (!scan_OF_pci_childs(hose->dn, - find_OF_pci_device_filter, (void *)node)) - return -ENODEV; - reg = of_get_property(node, "reg", NULL); - if (!reg) - return -ENODEV; - *bus = (reg[0] >> 16) & 0xff; - *devfn = ((reg[0] >> 8) & 0xff); - - /* Ok, here we need some tweak. If we have already renumbered - * all busses, we can't rely on the OF bus number any more. - * the pci_to_OF_bus_map is not enough as several PCI busses - * may match the same OF bus number. - */ - if (!pci_to_OF_bus_map) - return 0; - - for_each_pci_dev(dev) - if (pci_to_OF_bus_map[dev->bus->number] == *bus && - dev->devfn == *devfn) { - *bus = dev->bus->number; - pci_dev_put(dev); - return 0; - } - - return -ENODEV; -} -EXPORT_SYMBOL(pci_device_from_OF_node); - -/* We create the "pci-OF-bus-map" property now so it appears in the - * /proc device tree - */ -void __init -pci_create_OF_bus_map(void) -{ - struct property *of_prop; - struct device_node *dn; - - of_prop = (struct property *) alloc_bootmem(sizeof(struct property) + \ - 256); - if (!of_prop) - return; - dn = of_find_node_by_path("/"); - if (dn) { - memset(of_prop, -1, sizeof(struct property) + 256); - of_prop->name = "pci-OF-bus-map"; - of_prop->length = 256; - of_prop->value = &of_prop[1]; - prom_add_property(dn, of_prop); - of_node_put(dn); - } -} - -static void __devinit pcibios_scan_phb(struct pci_controller *hose) -{ - struct pci_bus *bus; - struct device_node *node = hose->dn; - unsigned long io_offset; - struct resource *res = &hose->io_resource; - - pr_debug("PCI: Scanning PHB %s\n", - node ? node->full_name : ""); - - /* Create an empty bus for the toplevel */ - bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops, hose); - if (bus == NULL) { - printk(KERN_ERR "Failed to create bus for PCI domain %04x\n", - hose->global_number); - return; - } - bus->secondary = hose->first_busno; - hose->bus = bus; - - /* Fixup IO space offset */ - io_offset = (unsigned long)hose->io_base_virt - isa_io_base; - res->start = (res->start + io_offset) & 0xffffffffu; - res->end = (res->end + io_offset) & 0xffffffffu; - - /* Wire up PHB bus resources */ - pcibios_setup_phb_resources(hose); - - /* Scan children */ - hose->last_busno = bus->subordinate = pci_scan_child_bus(bus); -} - -static int __init pcibios_init(void) -{ - struct pci_controller *hose, *tmp; - int next_busno = 0; - - printk(KERN_INFO "PCI: Probing PCI hardware\n"); - - if (pci_flags & PCI_REASSIGN_ALL_BUS) { - printk(KERN_INFO "setting pci_asign_all_busses\n"); - pci_assign_all_buses = 1; - } - - /* Scan all of the recorded PCI controllers. */ - list_for_each_entry_safe(hose, tmp, &hose_list, list_node) { - if (pci_assign_all_buses) - hose->first_busno = next_busno; - hose->last_busno = 0xff; - pcibios_scan_phb(hose); - printk(KERN_INFO "calling pci_bus_add_devices()\n"); - pci_bus_add_devices(hose->bus); - if (pci_assign_all_buses || next_busno <= hose->last_busno) - next_busno = hose->last_busno + \ - pcibios_assign_bus_offset; - } - pci_bus_count = next_busno; - - /* OpenFirmware based machines need a map of OF bus - * numbers vs. kernel bus numbers since we may have to - * remap them. - */ - if (pci_assign_all_buses) - pcibios_make_OF_bus_map(); - - /* Call common code to handle resource allocation */ - pcibios_resource_survey(); - - return 0; -} - -subsys_initcall(pcibios_init); - -static struct pci_controller* -pci_bus_to_hose(int bus) -{ - struct pci_controller *hose, *tmp; - - list_for_each_entry_safe(hose, tmp, &hose_list, list_node) - if (bus >= hose->first_busno && bus <= hose->last_busno) - return hose; - return NULL; -} - -/* Provide information on locations of various I/O regions in physical - * memory. Do this on a per-card basis so that we choose the right - * root bridge. - * Note that the returned IO or memory base is a physical address - */ - -long sys_pciconfig_iobase(long which, unsigned long bus, unsigned long devfn) -{ - struct pci_controller *hose; - long result = -EOPNOTSUPP; - - hose = pci_bus_to_hose(bus); - if (!hose) - return -ENODEV; - - switch (which) { - case IOBASE_BRIDGE_NUMBER: - return (long)hose->first_busno; - case IOBASE_MEMORY: - return (long)hose->pci_mem_offset; - case IOBASE_IO: - return (long)hose->io_base_phys; - case IOBASE_ISA_IO: - return (long)isa_io_base; - case IOBASE_ISA_MEM: - return (long)isa_mem_base; - } - - return result; -} diff --git a/trunk/arch/microblaze/pci/xilinx_pci.c b/trunk/arch/microblaze/pci/xilinx_pci.c deleted file mode 100644 index 7869a41b0f94..000000000000 --- a/trunk/arch/microblaze/pci/xilinx_pci.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - * PCI support for Xilinx plbv46_pci soft-core which can be used on - * Xilinx Virtex ML410 / ML510 boards. - * - * Copyright 2009 Roderick Colenbrander - * Copyright 2009 Secret Lab Technologies Ltd. - * - * The pci bridge fixup code was copied from ppc4xx_pci.c and was written - * by Benjamin Herrenschmidt. - * Copyright 2007 Ben. Herrenschmidt , IBM Corp. - * - * This file is licensed under the terms of the GNU General Public License - * version 2. This program is licensed "as is" without any warranty of any - * kind, whether express or implied. - */ - -#include -#include -#include -#include - -#define XPLB_PCI_ADDR 0x10c -#define XPLB_PCI_DATA 0x110 -#define XPLB_PCI_BUS 0x114 - -#define PCI_HOST_ENABLE_CMD (PCI_COMMAND_SERR | PCI_COMMAND_PARITY | \ - PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY) - -static struct of_device_id xilinx_pci_match[] = { - { .compatible = "xlnx,plbv46-pci-1.03.a", }, - {} -}; - -/** - * xilinx_pci_fixup_bridge - Block Xilinx PHB configuration. - */ -static void xilinx_pci_fixup_bridge(struct pci_dev *dev) -{ - struct pci_controller *hose; - int i; - - if (dev->devfn || dev->bus->self) - return; - - hose = pci_bus_to_host(dev->bus); - if (!hose) - return; - - if (!of_match_node(xilinx_pci_match, hose->dn)) - return; - - /* Hide the PCI host BARs from the kernel as their content doesn't - * fit well in the resource management - */ - for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { - dev->resource[i].start = 0; - dev->resource[i].end = 0; - dev->resource[i].flags = 0; - } - - dev_info(&dev->dev, "Hiding Xilinx plb-pci host bridge resources %s\n", - pci_name(dev)); -} -DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, xilinx_pci_fixup_bridge); - -#ifdef DEBUG -/** - * xilinx_pci_exclude_device - Don't do config access for non-root bus - * - * This is a hack. Config access to any bus other than bus 0 does not - * currently work on the ML510 so we prevent it here. - */ -static int -xilinx_pci_exclude_device(struct pci_controller *hose, u_char bus, u8 devfn) -{ - return (bus != 0); -} - -/** - * xilinx_early_pci_scan - List pci config space for available devices - * - * List pci devices in very early phase. - */ -void __init xilinx_early_pci_scan(struct pci_controller *hose) -{ - u32 bus = 0; - u32 val, dev, func, offset; - - /* Currently we have only 2 device connected - up-to 32 devices */ - for (dev = 0; dev < 2; dev++) { - /* List only first function number - up-to 8 functions */ - for (func = 0; func < 1; func++) { - printk(KERN_INFO "%02x:%02x:%02x", bus, dev, func); - /* read the first 64 standardized bytes */ - /* Up-to 192 bytes can be list of capabilities */ - for (offset = 0; offset < 64; offset += 4) { - early_read_config_dword(hose, bus, - PCI_DEVFN(dev, func), offset, &val); - if (offset == 0 && val == 0xFFFFFFFF) { - printk(KERN_CONT "\nABSENT"); - break; - } - if (!(offset % 0x10)) - printk(KERN_CONT "\n%04x: ", offset); - - printk(KERN_CONT "%08x ", val); - } - printk(KERN_INFO "\n"); - } - } -} -#else -void __init xilinx_early_pci_scan(struct pci_controller *hose) -{ -} -#endif - -/** - * xilinx_pci_init - Find and register a Xilinx PCI host bridge - */ -void __init xilinx_pci_init(void) -{ - struct pci_controller *hose; - struct resource r; - void __iomem *pci_reg; - struct device_node *pci_node; - - pci_node = of_find_matching_node(NULL, xilinx_pci_match); - if (!pci_node) - return; - - if (of_address_to_resource(pci_node, 0, &r)) { - pr_err("xilinx-pci: cannot resolve base address\n"); - return; - } - - hose = pcibios_alloc_controller(pci_node); - if (!hose) { - pr_err("xilinx-pci: pcibios_alloc_controller() failed\n"); - return; - } - - /* Setup config space */ - setup_indirect_pci(hose, r.start + XPLB_PCI_ADDR, - r.start + XPLB_PCI_DATA, - INDIRECT_TYPE_SET_CFG_TYPE); - - /* According to the xilinx plbv46_pci documentation the soft-core starts - * a self-init when the bus master enable bit is set. Without this bit - * set the pci bus can't be scanned. - */ - early_write_config_word(hose, 0, 0, PCI_COMMAND, PCI_HOST_ENABLE_CMD); - - /* Set the max latency timer to 255 */ - early_write_config_byte(hose, 0, 0, PCI_LATENCY_TIMER, 0xff); - - /* Set the max bus number to 255, and bus/subbus no's to 0 */ - pci_reg = of_iomap(pci_node, 0); - out_be32(pci_reg + XPLB_PCI_BUS, 0x000000ff); - iounmap(pci_reg); - - /* Register the host bridge with the linux kernel! */ - pci_process_bridge_OF_ranges(hose, pci_node, - INDIRECT_TYPE_SET_CFG_TYPE); - - pr_info("xilinx-pci: Registered PCI host bridge\n"); - xilinx_early_pci_scan(hose); -} diff --git a/trunk/arch/powerpc/kernel/perf_event.c b/trunk/arch/powerpc/kernel/perf_event.c index 08460a2e9f41..5120bd44f69a 100644 --- a/trunk/arch/powerpc/kernel/perf_event.c +++ b/trunk/arch/powerpc/kernel/perf_event.c @@ -1287,7 +1287,7 @@ static void perf_event_interrupt(struct pt_regs *regs) irq_exit(); } -static void power_pmu_setup(int cpu) +void hw_perf_event_setup(int cpu) { struct cpu_hw_events *cpuhw = &per_cpu(cpu_hw_events, cpu); @@ -1297,23 +1297,6 @@ static void power_pmu_setup(int cpu) cpuhw->mmcr[0] = MMCR0_FC; } -static int __cpuinit -power_pmu_notifier(struct notifier_block *self, unsigned long action, void *hcpu) -{ - unsigned int cpu = (long)hcpu; - - switch (action & ~CPU_TASKS_FROZEN) { - case CPU_UP_PREPARE: - power_pmu_setup(cpu); - break; - - default: - break; - } - - return NOTIFY_OK; -} - int register_power_pmu(struct power_pmu *pmu) { if (ppmu) @@ -1331,7 +1314,5 @@ int register_power_pmu(struct power_pmu *pmu) freeze_events_kernel = MMCR0_FCHV; #endif /* CONFIG_PPC64 */ - perf_cpu_notifier(power_pmu_notifier); - return 0; } diff --git a/trunk/arch/sh/kernel/perf_event.c b/trunk/arch/sh/kernel/perf_event.c index 9f253e9cce01..7ff0943e7a08 100644 --- a/trunk/arch/sh/kernel/perf_event.c +++ b/trunk/arch/sh/kernel/perf_event.c @@ -275,30 +275,13 @@ const struct pmu *hw_perf_event_init(struct perf_event *event) return &pmu; } -static void sh_pmu_setup(int cpu) +void hw_perf_event_setup(int cpu) { struct cpu_hw_events *cpuhw = &per_cpu(cpu_hw_events, cpu); memset(cpuhw, 0, sizeof(struct cpu_hw_events)); } -static int __cpuinit -sh_pmu_notifier(struct notifier_block *self, unsigned long action, void *hcpu) -{ - unsigned int cpu = (long)hcpu; - - switch (action & ~CPU_TASKS_FROZEN) { - case CPU_UP_PREPARE: - sh_pmu_setup(cpu); - break; - - default: - break; - } - - return NOTIFY_OK; -} - void hw_perf_enable(void) { if (!sh_pmu_initialized()) @@ -325,6 +308,5 @@ int register_sh_pmu(struct sh_pmu *pmu) WARN_ON(pmu->num_events > MAX_HWEVENTS); - perf_cpu_notifier(sh_pmu_notifier); return 0; } diff --git a/trunk/arch/x86/kernel/cpu/perf_event.c b/trunk/arch/x86/kernel/cpu/perf_event.c index 60398a0d947c..42aafd11e170 100644 --- a/trunk/arch/x86/kernel/cpu/perf_event.c +++ b/trunk/arch/x86/kernel/cpu/perf_event.c @@ -133,8 +133,8 @@ struct x86_pmu { int (*handle_irq)(struct pt_regs *); void (*disable_all)(void); void (*enable_all)(void); - void (*enable)(struct perf_event *); - void (*disable)(struct perf_event *); + void (*enable)(struct hw_perf_event *, int); + void (*disable)(struct hw_perf_event *, int); unsigned eventsel; unsigned perfctr; u64 (*event_map)(int); @@ -157,11 +157,6 @@ struct x86_pmu { void (*put_event_constraints)(struct cpu_hw_events *cpuc, struct perf_event *event); struct event_constraint *event_constraints; - - void (*cpu_prepare)(int cpu); - void (*cpu_starting)(int cpu); - void (*cpu_dying)(int cpu); - void (*cpu_dead)(int cpu); }; static struct x86_pmu x86_pmu __read_mostly; @@ -170,7 +165,8 @@ static DEFINE_PER_CPU(struct cpu_hw_events, cpu_hw_events) = { .enabled = 1, }; -static int x86_perf_event_set_period(struct perf_event *event); +static int x86_perf_event_set_period(struct perf_event *event, + struct hw_perf_event *hwc, int idx); /* * Generalized hw caching related hw_event table, filled @@ -193,12 +189,11 @@ static u64 __read_mostly hw_cache_event_ids * Returns the delta events processed. */ static u64 -x86_perf_event_update(struct perf_event *event) +x86_perf_event_update(struct perf_event *event, + struct hw_perf_event *hwc, int idx) { - struct hw_perf_event *hwc = &event->hw; int shift = 64 - x86_pmu.event_bits; u64 prev_raw_count, new_raw_count; - int idx = hwc->idx; s64 delta; if (idx == X86_PMC_IDX_FIXED_BTS) @@ -298,7 +293,7 @@ static inline bool bts_available(void) return x86_pmu.enable_bts != NULL; } -static void init_debug_store_on_cpu(int cpu) +static inline void init_debug_store_on_cpu(int cpu) { struct debug_store *ds = per_cpu(cpu_hw_events, cpu).ds; @@ -310,7 +305,7 @@ static void init_debug_store_on_cpu(int cpu) (u32)((u64)(unsigned long)ds >> 32)); } -static void fini_debug_store_on_cpu(int cpu) +static inline void fini_debug_store_on_cpu(int cpu) { if (!per_cpu(cpu_hw_events, cpu).ds) return; @@ -643,7 +638,7 @@ static int x86_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign) if (test_bit(hwc->idx, used_mask)) break; - __set_bit(hwc->idx, used_mask); + set_bit(hwc->idx, used_mask); if (assign) assign[i] = hwc->idx; } @@ -692,7 +687,7 @@ static int x86_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign) if (j == X86_PMC_IDX_MAX) break; - __set_bit(j, used_mask); + set_bit(j, used_mask); if (assign) assign[i] = j; @@ -785,7 +780,6 @@ static inline int match_prev_assignment(struct hw_perf_event *hwc, hwc->last_tag == cpuc->tags[i]; } -static int x86_pmu_start(struct perf_event *event); static void x86_pmu_stop(struct perf_event *event); void hw_perf_enable(void) @@ -802,7 +796,6 @@ void hw_perf_enable(void) return; if (cpuc->n_added) { - int n_running = cpuc->n_events - cpuc->n_added; /* * apply assignment obtained either from * hw_perf_group_sched_in() or x86_pmu_enable() @@ -810,7 +803,8 @@ void hw_perf_enable(void) * step1: save events moving to new counters * step2: reprogram moved events into new counters */ - for (i = 0; i < n_running; i++) { + for (i = 0; i < cpuc->n_events; i++) { + event = cpuc->event_list[i]; hwc = &event->hw; @@ -825,18 +819,29 @@ void hw_perf_enable(void) continue; x86_pmu_stop(event); + + hwc->idx = -1; } for (i = 0; i < cpuc->n_events; i++) { + event = cpuc->event_list[i]; hwc = &event->hw; - if (!match_prev_assignment(hwc, cpuc, i)) + if (hwc->idx == -1) { x86_assign_hw_event(event, cpuc, i); - else if (i < n_running) - continue; + x86_perf_event_set_period(event, hwc, hwc->idx); + } + /* + * need to mark as active because x86_pmu_disable() + * clear active_mask and events[] yet it preserves + * idx + */ + set_bit(hwc->idx, cpuc->active_mask); + cpuc->events[hwc->idx] = event; - x86_pmu_start(event); + x86_pmu.enable(hwc, hwc->idx); + perf_event_update_userpage(event); } cpuc->n_added = 0; perf_events_lapic_init(); @@ -848,16 +853,15 @@ void hw_perf_enable(void) x86_pmu.enable_all(); } -static inline void __x86_pmu_enable_event(struct hw_perf_event *hwc) +static inline void __x86_pmu_enable_event(struct hw_perf_event *hwc, int idx) { - (void)checking_wrmsrl(hwc->config_base + hwc->idx, + (void)checking_wrmsrl(hwc->config_base + idx, hwc->config | ARCH_PERFMON_EVENTSEL_ENABLE); } -static inline void x86_pmu_disable_event(struct perf_event *event) +static inline void x86_pmu_disable_event(struct hw_perf_event *hwc, int idx) { - struct hw_perf_event *hwc = &event->hw; - (void)checking_wrmsrl(hwc->config_base + hwc->idx, hwc->config); + (void)checking_wrmsrl(hwc->config_base + idx, hwc->config); } static DEFINE_PER_CPU(u64 [X86_PMC_IDX_MAX], pmc_prev_left); @@ -867,12 +871,12 @@ static DEFINE_PER_CPU(u64 [X86_PMC_IDX_MAX], pmc_prev_left); * To be called with the event disabled in hw: */ static int -x86_perf_event_set_period(struct perf_event *event) +x86_perf_event_set_period(struct perf_event *event, + struct hw_perf_event *hwc, int idx) { - struct hw_perf_event *hwc = &event->hw; s64 left = atomic64_read(&hwc->period_left); s64 period = hwc->sample_period; - int err, ret = 0, idx = hwc->idx; + int err, ret = 0; if (idx == X86_PMC_IDX_FIXED_BTS) return 0; @@ -918,11 +922,11 @@ x86_perf_event_set_period(struct perf_event *event) return ret; } -static void x86_pmu_enable_event(struct perf_event *event) +static void x86_pmu_enable_event(struct hw_perf_event *hwc, int idx) { struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); if (cpuc->enabled) - __x86_pmu_enable_event(&event->hw); + __x86_pmu_enable_event(hwc, idx); } /* @@ -958,32 +962,34 @@ static int x86_pmu_enable(struct perf_event *event) memcpy(cpuc->assign, assign, n*sizeof(int)); cpuc->n_events = n; - cpuc->n_added += n - n0; + cpuc->n_added = n - n0; return 0; } static int x86_pmu_start(struct perf_event *event) { - struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); - int idx = event->hw.idx; + struct hw_perf_event *hwc = &event->hw; - if (idx == -1) + if (hwc->idx == -1) return -EAGAIN; - x86_perf_event_set_period(event); - cpuc->events[idx] = event; - __set_bit(idx, cpuc->active_mask); - x86_pmu.enable(event); - perf_event_update_userpage(event); + x86_perf_event_set_period(event, hwc, hwc->idx); + x86_pmu.enable(hwc, hwc->idx); return 0; } static void x86_pmu_unthrottle(struct perf_event *event) { - int ret = x86_pmu_start(event); - WARN_ON_ONCE(ret); + struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); + struct hw_perf_event *hwc = &event->hw; + + if (WARN_ON_ONCE(hwc->idx >= X86_PMC_IDX_MAX || + cpuc->events[hwc->idx] != event)) + return; + + x86_pmu.enable(hwc, hwc->idx); } void perf_event_print_debug(void) @@ -1043,16 +1049,18 @@ static void x86_pmu_stop(struct perf_event *event) struct hw_perf_event *hwc = &event->hw; int idx = hwc->idx; - if (!__test_and_clear_bit(idx, cpuc->active_mask)) - return; - - x86_pmu.disable(event); + /* + * Must be done before we disable, otherwise the nmi handler + * could reenable again: + */ + clear_bit(idx, cpuc->active_mask); + x86_pmu.disable(hwc, idx); /* * Drain the remaining delta count out of a event * that we are disabling: */ - x86_perf_event_update(event); + x86_perf_event_update(event, hwc, idx); cpuc->events[idx] = NULL; } @@ -1100,7 +1108,7 @@ static int x86_pmu_handle_irq(struct pt_regs *regs) event = cpuc->events[idx]; hwc = &event->hw; - val = x86_perf_event_update(event); + val = x86_perf_event_update(event, hwc, idx); if (val & (1ULL << (x86_pmu.event_bits - 1))) continue; @@ -1110,11 +1118,11 @@ static int x86_pmu_handle_irq(struct pt_regs *regs) handled = 1; data.period = event->hw.last_period; - if (!x86_perf_event_set_period(event)) + if (!x86_perf_event_set_period(event, hwc, idx)) continue; if (perf_event_overflow(event, 1, &data, regs)) - x86_pmu_stop(event); + x86_pmu.disable(hwc, idx); } if (handled) @@ -1301,7 +1309,7 @@ int hw_perf_group_sched_in(struct perf_event *leader, memcpy(cpuc->assign, assign, n0*sizeof(int)); cpuc->n_events = n0; - cpuc->n_added += n1; + cpuc->n_added = n1; ctx->nr_active += n1; /* @@ -1329,39 +1337,6 @@ int hw_perf_group_sched_in(struct perf_event *leader, #include "perf_event_p6.c" #include "perf_event_intel.c" -static int __cpuinit -x86_pmu_notifier(struct notifier_block *self, unsigned long action, void *hcpu) -{ - unsigned int cpu = (long)hcpu; - - switch (action & ~CPU_TASKS_FROZEN) { - case CPU_UP_PREPARE: - if (x86_pmu.cpu_prepare) - x86_pmu.cpu_prepare(cpu); - break; - - case CPU_STARTING: - if (x86_pmu.cpu_starting) - x86_pmu.cpu_starting(cpu); - break; - - case CPU_DYING: - if (x86_pmu.cpu_dying) - x86_pmu.cpu_dying(cpu); - break; - - case CPU_DEAD: - if (x86_pmu.cpu_dead) - x86_pmu.cpu_dead(cpu); - break; - - default: - break; - } - - return NOTIFY_OK; -} - static void __init pmu_check_apic(void) { if (cpu_has_apic) @@ -1440,13 +1415,11 @@ void __init init_hw_perf_events(void) pr_info("... max period: %016Lx\n", x86_pmu.max_period); pr_info("... fixed-purpose events: %d\n", x86_pmu.num_events_fixed); pr_info("... event mask: %016Lx\n", perf_event_mask); - - perf_cpu_notifier(x86_pmu_notifier); } static inline void x86_pmu_read(struct perf_event *event) { - x86_perf_event_update(event); + x86_perf_event_update(event, &event->hw, event->hw.idx); } static const struct pmu pmu = { @@ -1702,16 +1675,28 @@ struct perf_callchain_entry *perf_callchain(struct pt_regs *regs) return entry; } -#ifdef CONFIG_EVENT_TRACING -void perf_arch_fetch_caller_regs(struct pt_regs *regs, unsigned long ip, int skip) +void hw_perf_event_setup_online(int cpu) { - regs->ip = ip; - /* - * perf_arch_fetch_caller_regs adds another call, we need to increment - * the skip level - */ - regs->bp = rewind_frame_pointer(skip + 1); - regs->cs = __KERNEL_CS; - local_save_flags(regs->flags); + init_debug_store_on_cpu(cpu); + + switch (boot_cpu_data.x86_vendor) { + case X86_VENDOR_AMD: + amd_pmu_cpu_online(cpu); + break; + default: + return; + } +} + +void hw_perf_event_setup_offline(int cpu) +{ + init_debug_store_on_cpu(cpu); + + switch (boot_cpu_data.x86_vendor) { + case X86_VENDOR_AMD: + amd_pmu_cpu_offline(cpu); + break; + default: + return; + } } -#endif diff --git a/trunk/arch/x86/kernel/cpu/perf_event_amd.c b/trunk/arch/x86/kernel/cpu/perf_event_amd.c index 573458f1caf2..8f3dbfda3c4f 100644 --- a/trunk/arch/x86/kernel/cpu/perf_event_amd.c +++ b/trunk/arch/x86/kernel/cpu/perf_event_amd.c @@ -271,6 +271,28 @@ amd_get_event_constraints(struct cpu_hw_events *cpuc, struct perf_event *event) return &emptyconstraint; } +static __initconst struct x86_pmu amd_pmu = { + .name = "AMD", + .handle_irq = x86_pmu_handle_irq, + .disable_all = x86_pmu_disable_all, + .enable_all = x86_pmu_enable_all, + .enable = x86_pmu_enable_event, + .disable = x86_pmu_disable_event, + .eventsel = MSR_K7_EVNTSEL0, + .perfctr = MSR_K7_PERFCTR0, + .event_map = amd_pmu_event_map, + .raw_event = amd_pmu_raw_event, + .max_events = ARRAY_SIZE(amd_perfmon_event_map), + .num_events = 4, + .event_bits = 48, + .event_mask = (1ULL << 48) - 1, + .apic = 1, + /* use highest bit to detect overflow */ + .max_period = (1ULL << 47) - 1, + .get_event_constraints = amd_get_event_constraints, + .put_event_constraints = amd_put_event_constraints +}; + static struct amd_nb *amd_alloc_nb(int cpu, int nb_id) { struct amd_nb *nb; @@ -287,7 +309,7 @@ static struct amd_nb *amd_alloc_nb(int cpu, int nb_id) * initialize all possible NB constraints */ for (i = 0; i < x86_pmu.num_events; i++) { - __set_bit(i, nb->event_constraints[i].idxmsk); + set_bit(i, nb->event_constraints[i].idxmsk); nb->event_constraints[i].weight = 1; } return nb; @@ -356,31 +378,6 @@ static void amd_pmu_cpu_offline(int cpu) raw_spin_unlock(&amd_nb_lock); } -static __initconst struct x86_pmu amd_pmu = { - .name = "AMD", - .handle_irq = x86_pmu_handle_irq, - .disable_all = x86_pmu_disable_all, - .enable_all = x86_pmu_enable_all, - .enable = x86_pmu_enable_event, - .disable = x86_pmu_disable_event, - .eventsel = MSR_K7_EVNTSEL0, - .perfctr = MSR_K7_PERFCTR0, - .event_map = amd_pmu_event_map, - .raw_event = amd_pmu_raw_event, - .max_events = ARRAY_SIZE(amd_perfmon_event_map), - .num_events = 4, - .event_bits = 48, - .event_mask = (1ULL << 48) - 1, - .apic = 1, - /* use highest bit to detect overflow */ - .max_period = (1ULL << 47) - 1, - .get_event_constraints = amd_get_event_constraints, - .put_event_constraints = amd_put_event_constraints, - - .cpu_prepare = amd_pmu_cpu_online, - .cpu_dead = amd_pmu_cpu_offline, -}; - static __init int amd_pmu_init(void) { /* Performance-monitoring supported from K7 and later: */ @@ -393,6 +390,11 @@ static __init int amd_pmu_init(void) memcpy(hw_cache_event_ids, amd_hw_cache_event_ids, sizeof(hw_cache_event_ids)); + /* + * explicitly initialize the boot cpu, other cpus will get + * the cpu hotplug callbacks from smp_init() + */ + amd_pmu_cpu_online(smp_processor_id()); return 0; } @@ -403,4 +405,12 @@ static int amd_pmu_init(void) return 0; } +static void amd_pmu_cpu_online(int cpu) +{ +} + +static void amd_pmu_cpu_offline(int cpu) +{ +} + #endif diff --git a/trunk/arch/x86/kernel/cpu/perf_event_intel.c b/trunk/arch/x86/kernel/cpu/perf_event_intel.c index 84bfde64a337..44b60c852107 100644 --- a/trunk/arch/x86/kernel/cpu/perf_event_intel.c +++ b/trunk/arch/x86/kernel/cpu/perf_event_intel.c @@ -548,9 +548,9 @@ static inline void intel_pmu_ack_status(u64 ack) } static inline void -intel_pmu_disable_fixed(struct hw_perf_event *hwc) +intel_pmu_disable_fixed(struct hw_perf_event *hwc, int __idx) { - int idx = hwc->idx - X86_PMC_IDX_FIXED; + int idx = __idx - X86_PMC_IDX_FIXED; u64 ctrl_val, mask; mask = 0xfULL << (idx * 4); @@ -621,28 +621,26 @@ static void intel_pmu_drain_bts_buffer(void) } static inline void -intel_pmu_disable_event(struct perf_event *event) +intel_pmu_disable_event(struct hw_perf_event *hwc, int idx) { - struct hw_perf_event *hwc = &event->hw; - - if (unlikely(hwc->idx == X86_PMC_IDX_FIXED_BTS)) { + if (unlikely(idx == X86_PMC_IDX_FIXED_BTS)) { intel_pmu_disable_bts(); intel_pmu_drain_bts_buffer(); return; } if (unlikely(hwc->config_base == MSR_ARCH_PERFMON_FIXED_CTR_CTRL)) { - intel_pmu_disable_fixed(hwc); + intel_pmu_disable_fixed(hwc, idx); return; } - x86_pmu_disable_event(event); + x86_pmu_disable_event(hwc, idx); } static inline void -intel_pmu_enable_fixed(struct hw_perf_event *hwc) +intel_pmu_enable_fixed(struct hw_perf_event *hwc, int __idx) { - int idx = hwc->idx - X86_PMC_IDX_FIXED; + int idx = __idx - X86_PMC_IDX_FIXED; u64 ctrl_val, bits, mask; int err; @@ -672,11 +670,9 @@ intel_pmu_enable_fixed(struct hw_perf_event *hwc) err = checking_wrmsrl(hwc->config_base, ctrl_val); } -static void intel_pmu_enable_event(struct perf_event *event) +static void intel_pmu_enable_event(struct hw_perf_event *hwc, int idx) { - struct hw_perf_event *hwc = &event->hw; - - if (unlikely(hwc->idx == X86_PMC_IDX_FIXED_BTS)) { + if (unlikely(idx == X86_PMC_IDX_FIXED_BTS)) { if (!__get_cpu_var(cpu_hw_events).enabled) return; @@ -685,11 +681,11 @@ static void intel_pmu_enable_event(struct perf_event *event) } if (unlikely(hwc->config_base == MSR_ARCH_PERFMON_FIXED_CTR_CTRL)) { - intel_pmu_enable_fixed(hwc); + intel_pmu_enable_fixed(hwc, idx); return; } - __x86_pmu_enable_event(hwc); + __x86_pmu_enable_event(hwc, idx); } /* @@ -698,8 +694,14 @@ static void intel_pmu_enable_event(struct perf_event *event) */ static int intel_pmu_save_and_restart(struct perf_event *event) { - x86_perf_event_update(event); - return x86_perf_event_set_period(event); + struct hw_perf_event *hwc = &event->hw; + int idx = hwc->idx; + int ret; + + x86_perf_event_update(event, hwc, idx); + ret = x86_perf_event_set_period(event, hwc, idx); + + return ret; } static void intel_pmu_reset(void) @@ -743,11 +745,11 @@ static int intel_pmu_handle_irq(struct pt_regs *regs) cpuc = &__get_cpu_var(cpu_hw_events); - intel_pmu_disable_all(); + perf_disable(); intel_pmu_drain_bts_buffer(); status = intel_pmu_get_status(); if (!status) { - intel_pmu_enable_all(); + perf_enable(); return 0; } @@ -757,7 +759,8 @@ static int intel_pmu_handle_irq(struct pt_regs *regs) WARN_ONCE(1, "perfevents: irq loop stuck!\n"); perf_event_print_debug(); intel_pmu_reset(); - goto done; + perf_enable(); + return 1; } inc_irq_stat(apic_perf_irqs); @@ -765,6 +768,7 @@ static int intel_pmu_handle_irq(struct pt_regs *regs) for_each_set_bit(bit, (unsigned long *)&status, X86_PMC_IDX_MAX) { struct perf_event *event = cpuc->events[bit]; + clear_bit(bit, (unsigned long *) &status); if (!test_bit(bit, cpuc->active_mask)) continue; @@ -774,7 +778,7 @@ static int intel_pmu_handle_irq(struct pt_regs *regs) data.period = event->hw.last_period; if (perf_event_overflow(event, 1, &data, regs)) - x86_pmu_stop(event); + intel_pmu_disable_event(&event->hw, bit); } intel_pmu_ack_status(ack); @@ -786,8 +790,8 @@ static int intel_pmu_handle_irq(struct pt_regs *regs) if (status) goto again; -done: - intel_pmu_enable_all(); + perf_enable(); + return 1; } @@ -866,10 +870,7 @@ static __initconst struct x86_pmu intel_pmu = { .max_period = (1ULL << 31) - 1, .enable_bts = intel_pmu_enable_bts, .disable_bts = intel_pmu_disable_bts, - .get_event_constraints = intel_get_event_constraints, - - .cpu_starting = init_debug_store_on_cpu, - .cpu_dying = fini_debug_store_on_cpu, + .get_event_constraints = intel_get_event_constraints }; static __init int intel_pmu_init(void) diff --git a/trunk/arch/x86/kernel/cpu/perf_event_p6.c b/trunk/arch/x86/kernel/cpu/perf_event_p6.c index a330485d14da..a4e67b99d91c 100644 --- a/trunk/arch/x86/kernel/cpu/perf_event_p6.c +++ b/trunk/arch/x86/kernel/cpu/perf_event_p6.c @@ -77,29 +77,27 @@ static void p6_pmu_enable_all(void) } static inline void -p6_pmu_disable_event(struct perf_event *event) +p6_pmu_disable_event(struct hw_perf_event *hwc, int idx) { struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); - struct hw_perf_event *hwc = &event->hw; u64 val = P6_NOP_EVENT; if (cpuc->enabled) val |= ARCH_PERFMON_EVENTSEL_ENABLE; - (void)checking_wrmsrl(hwc->config_base + hwc->idx, val); + (void)checking_wrmsrl(hwc->config_base + idx, val); } -static void p6_pmu_enable_event(struct perf_event *event) +static void p6_pmu_enable_event(struct hw_perf_event *hwc, int idx) { struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); - struct hw_perf_event *hwc = &event->hw; u64 val; val = hwc->config; if (cpuc->enabled) val |= ARCH_PERFMON_EVENTSEL_ENABLE; - (void)checking_wrmsrl(hwc->config_base + hwc->idx, val); + (void)checking_wrmsrl(hwc->config_base + idx, val); } static __initconst struct x86_pmu p6_pmu = { diff --git a/trunk/arch/x86/kernel/dumpstack.h b/trunk/arch/x86/kernel/dumpstack.h index 29e5f7c845b2..4fd1420faffa 100644 --- a/trunk/arch/x86/kernel/dumpstack.h +++ b/trunk/arch/x86/kernel/dumpstack.h @@ -29,19 +29,4 @@ struct stack_frame { struct stack_frame *next_frame; unsigned long return_address; }; - -static inline unsigned long rewind_frame_pointer(int n) -{ - struct stack_frame *frame; - - get_bp(frame); - -#ifdef CONFIG_FRAME_POINTER - while (n--) - frame = frame->next_frame; #endif - - return (unsigned long)frame; -} - -#endif /* DUMPSTACK_H */ diff --git a/trunk/arch/x86/kernel/dumpstack_64.c b/trunk/arch/x86/kernel/dumpstack_64.c index 272c9f1f05f3..d5e2a2ebb627 100644 --- a/trunk/arch/x86/kernel/dumpstack_64.c +++ b/trunk/arch/x86/kernel/dumpstack_64.c @@ -208,7 +208,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs, if (in_irq_stack(stack, irq_stack, irq_stack_end)) { if (ops->stack(data, "IRQ") < 0) break; - bp = ops->walk_stack(tinfo, stack, bp, + bp = print_context_stack(tinfo, stack, bp, ops, data, irq_stack_end, &graph); /* * We link to the next stack (which would be @@ -229,7 +229,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs, /* * This handles the process stack: */ - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph); + bp = print_context_stack(tinfo, stack, bp, ops, data, NULL, &graph); put_cpu(); } EXPORT_SYMBOL(dump_trace); diff --git a/trunk/drivers/acpi/video.c b/trunk/drivers/acpi/video.c index cbe6f3924a10..2ff2b6ab5b6c 100644 --- a/trunk/drivers/acpi/video.c +++ b/trunk/drivers/acpi/video.c @@ -998,7 +998,6 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) } if (acpi_video_backlight_support()) { - struct backlight_properties props; int result; static int count = 0; char *name; @@ -1011,14 +1010,12 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) return; sprintf(name, "acpi_video%d", count++); - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = device->brightness->count - 3; - device->backlight = backlight_device_register(name, NULL, device, - &acpi_backlight_ops, - &props); + device->backlight = backlight_device_register(name, + NULL, device, &acpi_backlight_ops); kfree(name); if (IS_ERR(device->backlight)) return; + device->backlight->props.max_brightness = device->brightness->count-3; result = sysfs_create_link(&device->backlight->dev.kobj, &device->dev->dev.kobj, "device"); diff --git a/trunk/drivers/ata/ahci.c b/trunk/drivers/ata/ahci.c index fdc9bcbe55a2..6bd930b93bcc 100644 --- a/trunk/drivers/ata/ahci.c +++ b/trunk/drivers/ata/ahci.c @@ -641,21 +641,6 @@ static const struct pci_device_id ahci_pci_tbl[] = { { PCI_VDEVICE(NVIDIA, 0x055a), board_ahci_yesncq }, /* MCP67 */ { PCI_VDEVICE(NVIDIA, 0x055b), board_ahci_yesncq }, /* MCP67 */ { PCI_VDEVICE(NVIDIA, 0x0580), board_ahci_yesncq }, /* Linux ID */ - { PCI_VDEVICE(NVIDIA, 0x0581), board_ahci_yesncq }, /* Linux ID */ - { PCI_VDEVICE(NVIDIA, 0x0582), board_ahci_yesncq }, /* Linux ID */ - { PCI_VDEVICE(NVIDIA, 0x0583), board_ahci_yesncq }, /* Linux ID */ - { PCI_VDEVICE(NVIDIA, 0x0584), board_ahci_yesncq }, /* Linux ID */ - { PCI_VDEVICE(NVIDIA, 0x0585), board_ahci_yesncq }, /* Linux ID */ - { PCI_VDEVICE(NVIDIA, 0x0586), board_ahci_yesncq }, /* Linux ID */ - { PCI_VDEVICE(NVIDIA, 0x0587), board_ahci_yesncq }, /* Linux ID */ - { PCI_VDEVICE(NVIDIA, 0x0588), board_ahci_yesncq }, /* Linux ID */ - { PCI_VDEVICE(NVIDIA, 0x0589), board_ahci_yesncq }, /* Linux ID */ - { PCI_VDEVICE(NVIDIA, 0x058a), board_ahci_yesncq }, /* Linux ID */ - { PCI_VDEVICE(NVIDIA, 0x058b), board_ahci_yesncq }, /* Linux ID */ - { PCI_VDEVICE(NVIDIA, 0x058c), board_ahci_yesncq }, /* Linux ID */ - { PCI_VDEVICE(NVIDIA, 0x058d), board_ahci_yesncq }, /* Linux ID */ - { PCI_VDEVICE(NVIDIA, 0x058e), board_ahci_yesncq }, /* Linux ID */ - { PCI_VDEVICE(NVIDIA, 0x058f), board_ahci_yesncq }, /* Linux ID */ { PCI_VDEVICE(NVIDIA, 0x07f0), board_ahci_yesncq }, /* MCP73 */ { PCI_VDEVICE(NVIDIA, 0x07f1), board_ahci_yesncq }, /* MCP73 */ { PCI_VDEVICE(NVIDIA, 0x07f2), board_ahci_yesncq }, /* MCP73 */ @@ -2278,7 +2263,7 @@ static void ahci_port_intr(struct ata_port *ap) struct ahci_port_priv *pp = ap->private_data; struct ahci_host_priv *hpriv = ap->host->private_data; int resetting = !!(ap->pflags & ATA_PFLAG_RESETTING); - u32 status, qc_active = 0; + u32 status, qc_active; int rc; status = readl(port_mmio + PORT_IRQ_STAT); @@ -2336,22 +2321,11 @@ static void ahci_port_intr(struct ata_port *ap) } } - /* pp->active_link is not reliable once FBS is enabled, both - * PORT_SCR_ACT and PORT_CMD_ISSUE should be checked because - * NCQ and non-NCQ commands may be in flight at the same time. - */ - if (pp->fbs_enabled) { - if (ap->qc_active) { - qc_active = readl(port_mmio + PORT_SCR_ACT); - qc_active |= readl(port_mmio + PORT_CMD_ISSUE); - } - } else { - /* pp->active_link is valid iff any command is in flight */ - if (ap->qc_active && pp->active_link->sactive) - qc_active = readl(port_mmio + PORT_SCR_ACT); - else - qc_active = readl(port_mmio + PORT_CMD_ISSUE); - } + /* pp->active_link is valid iff any command is in flight */ + if (ap->qc_active && pp->active_link->sactive) + qc_active = readl(port_mmio + PORT_SCR_ACT); + else + qc_active = readl(port_mmio + PORT_CMD_ISSUE); rc = ata_qc_complete_multiple(ap, qc_active); @@ -3048,14 +3022,6 @@ static bool ahci_broken_suspend(struct pci_dev *pdev) * On HP dv[4-6] and HDX18 with earlier BIOSen, link * to the harddisk doesn't become online after * resuming from STR. Warn and fail suspend. - * - * http://bugzilla.kernel.org/show_bug.cgi?id=12276 - * - * Use dates instead of versions to match as HP is - * apparently recycling both product and version - * strings. - * - * http://bugzilla.kernel.org/show_bug.cgi?id=15462 */ { .ident = "dv4", @@ -3064,7 +3030,7 @@ static bool ahci_broken_suspend(struct pci_dev *pdev) DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv4 Notebook PC"), }, - .driver_data = "20090105", /* F.30 */ + .driver_data = "F.30", /* cutoff BIOS version */ }, { .ident = "dv5", @@ -3073,7 +3039,7 @@ static bool ahci_broken_suspend(struct pci_dev *pdev) DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv5 Notebook PC"), }, - .driver_data = "20090506", /* F.16 */ + .driver_data = "F.16", /* cutoff BIOS version */ }, { .ident = "dv6", @@ -3082,7 +3048,7 @@ static bool ahci_broken_suspend(struct pci_dev *pdev) DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv6 Notebook PC"), }, - .driver_data = "20090423", /* F.21 */ + .driver_data = "F.21", /* cutoff BIOS version */ }, { .ident = "HDX18", @@ -3091,7 +3057,7 @@ static bool ahci_broken_suspend(struct pci_dev *pdev) DMI_MATCH(DMI_PRODUCT_NAME, "HP HDX18 Notebook PC"), }, - .driver_data = "20090430", /* F.23 */ + .driver_data = "F.23", /* cutoff BIOS version */ }, /* * Acer eMachines G725 has the same problem. BIOS @@ -3099,8 +3065,6 @@ static bool ahci_broken_suspend(struct pci_dev *pdev) * work. Inbetween, there are V1.06, V2.06 and V3.03 * that we don't have much idea about. For now, * blacklist anything older than V3.04. - * - * http://bugzilla.kernel.org/show_bug.cgi?id=15104 */ { .ident = "G725", @@ -3108,21 +3072,19 @@ static bool ahci_broken_suspend(struct pci_dev *pdev) DMI_MATCH(DMI_SYS_VENDOR, "eMachines"), DMI_MATCH(DMI_PRODUCT_NAME, "eMachines G725"), }, - .driver_data = "20091216", /* V3.04 */ + .driver_data = "V3.04", /* cutoff BIOS version */ }, { } /* terminate list */ }; const struct dmi_system_id *dmi = dmi_first_match(sysids); - int year, month, date; - char buf[9]; + const char *ver; if (!dmi || pdev->bus->number || pdev->devfn != PCI_DEVFN(0x1f, 2)) return false; - dmi_get_date(DMI_BIOS_DATE, &year, &month, &date); - snprintf(buf, sizeof(buf), "%04d%02d%02d", year, month, date); + ver = dmi_get_system_info(DMI_BIOS_VERSION); - return strcmp(buf, dmi->driver_data) < 0; + return !ver || strcmp(ver, dmi->driver_data) < 0; } static bool ahci_broken_online(struct pci_dev *pdev) diff --git a/trunk/drivers/atm/lanai.c b/trunk/drivers/atm/lanai.c index 23d95054705b..7fe7c324e7ef 100644 --- a/trunk/drivers/atm/lanai.c +++ b/trunk/drivers/atm/lanai.c @@ -306,10 +306,11 @@ static void vci_bitfield_iterate(struct lanai_dev *lanai, const unsigned long *lp, void (*func)(struct lanai_dev *,vci_t vci)) { - vci_t vci; - - for_each_set_bit(vci, lp, NUM_VCI) + vci_t vci = find_first_bit(lp, NUM_VCI); + while (vci < NUM_VCI) { func(lanai, vci); + vci = find_next_bit(lp, NUM_VCI, vci + 1); + } } /* -------------------- BUFFER UTILITIES: */ diff --git a/trunk/drivers/base/memory.c b/trunk/drivers/base/memory.c index db0848e54cc6..2f8691511190 100644 --- a/trunk/drivers/base/memory.c +++ b/trunk/drivers/base/memory.c @@ -429,16 +429,12 @@ static inline int memory_fail_init(void) * differentiation between which *physical* devices each * section belongs to... */ -int __weak arch_get_memory_phys_device(unsigned long start_pfn) -{ - return 0; -} static int add_memory_block(int nid, struct mem_section *section, - unsigned long state, enum mem_add_context context) + unsigned long state, int phys_device, + enum mem_add_context context) { struct memory_block *mem = kzalloc(sizeof(*mem), GFP_KERNEL); - unsigned long start_pfn; int ret = 0; if (!mem) @@ -447,8 +443,7 @@ static int add_memory_block(int nid, struct mem_section *section, mem->phys_index = __section_nr(section); mem->state = state; mutex_init(&mem->state_mutex); - start_pfn = section_nr_to_pfn(mem->phys_index); - mem->phys_device = arch_get_memory_phys_device(start_pfn); + mem->phys_device = phys_device; ret = register_memory(mem, section); if (!ret) @@ -520,7 +515,7 @@ int remove_memory_block(unsigned long node_id, struct mem_section *section, */ int register_new_memory(int nid, struct mem_section *section) { - return add_memory_block(nid, section, MEM_OFFLINE, HOTPLUG); + return add_memory_block(nid, section, MEM_OFFLINE, 0, HOTPLUG); } int unregister_memory_section(struct mem_section *section) @@ -553,7 +548,7 @@ int __init memory_dev_init(void) if (!present_section_nr(i)) continue; err = add_memory_block(0, __nr_to_section(i), MEM_ONLINE, - BOOT); + 0, BOOT); if (!ret) ret = err; } diff --git a/trunk/drivers/char/hpet.c b/trunk/drivers/char/hpet.c index 9c5eea3ea4de..e481c5938bad 100644 --- a/trunk/drivers/char/hpet.c +++ b/trunk/drivers/char/hpet.c @@ -215,7 +215,9 @@ static void hpet_timer_set_irq(struct hpet_dev *devp) else v &= ~0xffff; - for_each_set_bit(irq, &v, HPET_MAX_IRQ) { + for (irq = find_first_bit(&v, HPET_MAX_IRQ); irq < HPET_MAX_IRQ; + irq = find_next_bit(&v, HPET_MAX_IRQ, 1 + irq)) { + if (irq >= nr_irqs) { irq = HPET_MAX_IRQ; break; diff --git a/trunk/drivers/gpu/drm/nouveau/nouveau_backlight.c b/trunk/drivers/gpu/drm/nouveau/nouveau_backlight.c index 406228f4a2a0..20564f8cb0ec 100644 --- a/trunk/drivers/gpu/drm/nouveau/nouveau_backlight.c +++ b/trunk/drivers/gpu/drm/nouveau/nouveau_backlight.c @@ -89,21 +89,19 @@ static struct backlight_ops nv50_bl_ops = { static int nouveau_nv40_backlight_init(struct drm_device *dev) { - struct backlight_properties props; struct drm_nouveau_private *dev_priv = dev->dev_private; struct backlight_device *bd; if (!(nv_rd32(dev, NV40_PMC_BACKLIGHT) & NV40_PMC_BACKLIGHT_MASK)) return 0; - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = 31; bd = backlight_device_register("nv_backlight", &dev->pdev->dev, dev, - &nv40_bl_ops, &props); + &nv40_bl_ops); if (IS_ERR(bd)) return PTR_ERR(bd); dev_priv->backlight = bd; + bd->props.max_brightness = 31; bd->props.brightness = nv40_get_intensity(bd); backlight_update_status(bd); @@ -112,21 +110,19 @@ static int nouveau_nv40_backlight_init(struct drm_device *dev) static int nouveau_nv50_backlight_init(struct drm_device *dev) { - struct backlight_properties props; struct drm_nouveau_private *dev_priv = dev->dev_private; struct backlight_device *bd; if (!nv_rd32(dev, NV50_PDISPLAY_SOR_BACKLIGHT)) return 0; - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = 1025; bd = backlight_device_register("nv_backlight", &dev->pdev->dev, dev, - &nv50_bl_ops, &props); + &nv50_bl_ops); if (IS_ERR(bd)) return PTR_ERR(bd); dev_priv->backlight = bd; + bd->props.max_brightness = 1025; bd->props.brightness = nv50_get_intensity(bd); backlight_update_status(bd); return 0; diff --git a/trunk/drivers/hid/hid-core.c b/trunk/drivers/hid/hid-core.c index 2e2aa759d230..368fbb0c4ca6 100644 --- a/trunk/drivers/hid/hid-core.c +++ b/trunk/drivers/hid/hid-core.c @@ -1357,7 +1357,6 @@ static const struct hid_device_id hid_blacklist[] = { { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb323) }, { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb324) }, { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651) }, - { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb653) }, { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654) }, { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) }, { HID_USB_DEVICE(USB_VENDOR_ID_TWINHAN, USB_DEVICE_ID_TWINHAN_IR_REMOTE) }, diff --git a/trunk/drivers/hid/hid-debug.c b/trunk/drivers/hid/hid-debug.c index 0c4e75573186..cd4ece6fdfb9 100644 --- a/trunk/drivers/hid/hid-debug.c +++ b/trunk/drivers/hid/hid-debug.c @@ -564,10 +564,10 @@ void hid_debug_event(struct hid_device *hdev, char *buf) struct hid_debug_list *list; list_for_each_entry(list, &hdev->debug_list, node) { - for (i = 0; i < strlen(buf); i++) - list->hid_debug_buf[(list->tail + i) % HID_DEBUG_BUFSIZE] = + for (i = 0; i <= strlen(buf); i++) + list->hid_debug_buf[(list->tail + i) % (HID_DEBUG_BUFSIZE - 1)] = buf[i]; - list->tail = (list->tail + i) % HID_DEBUG_BUFSIZE; + list->tail = (list->tail + i) % (HID_DEBUG_BUFSIZE - 1); } } EXPORT_SYMBOL_GPL(hid_debug_event); diff --git a/trunk/drivers/hid/hid-ids.h b/trunk/drivers/hid/hid-ids.h index 797e06470356..72c05f90553c 100644 --- a/trunk/drivers/hid/hid-ids.h +++ b/trunk/drivers/hid/hid-ids.h @@ -445,7 +445,6 @@ #define USB_VENDOR_ID_UCLOGIC 0x5543 #define USB_DEVICE_ID_UCLOGIC_TABLET_PF1209 0x0042 -#define USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U 0x0003 #define USB_VENDOR_ID_VERNIER 0x08f7 #define USB_DEVICE_ID_VERNIER_LABPRO 0x0001 diff --git a/trunk/drivers/hid/hid-magicmouse.c b/trunk/drivers/hid/hid-magicmouse.c index c174b64c3810..4a3a94f2b10c 100644 --- a/trunk/drivers/hid/hid-magicmouse.c +++ b/trunk/drivers/hid/hid-magicmouse.c @@ -353,7 +353,7 @@ static int magicmouse_probe(struct hid_device *hdev, goto err_free; } - ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_HIDINPUT); + ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); if (ret) { dev_err(&hdev->dev, "magicmouse hw start failed\n"); goto err_free; @@ -409,11 +409,8 @@ static int magicmouse_probe(struct hid_device *hdev, static void magicmouse_remove(struct hid_device *hdev) { - struct magicmouse_sc *msc = hid_get_drvdata(hdev); - hid_hw_stop(hdev); - input_unregister_device(msc->input); - kfree(msc); + kfree(hid_get_drvdata(hdev)); } static const struct hid_device_id magic_mice[] = { diff --git a/trunk/drivers/hid/hid-ntrig.c b/trunk/drivers/hid/hid-ntrig.c index edcc0c4247bb..3234c729a895 100644 --- a/trunk/drivers/hid/hid-ntrig.c +++ b/trunk/drivers/hid/hid-ntrig.c @@ -140,9 +140,6 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field, nd->reading_mt = 1; nd->first_contact_confidence = 0; break; - case HID_DG_TIPSWITCH: - /* Prevent emission of touch until validated */ - return 1; case HID_DG_CONFIDENCE: nd->confidence = value; break; @@ -262,7 +259,6 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field, BTN_TOOL_TRIPLETAP, 0); input_report_key(input, BTN_TOOL_QUADTAP, 0); - input_report_key(input, BTN_TOUCH, 0); } break; @@ -312,20 +308,13 @@ static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id) list_for_each_entry(hidinput, &hdev->inputs, list) { - if (hidinput->report->maxfield < 1) - continue; - input = hidinput->input; switch (hidinput->report->field[0]->application) { case HID_DG_PEN: input->name = "N-Trig Pen"; break; case HID_DG_TOUCHSCREEN: - /* These keys are redundant for fingers, clear them - * to prevent incorrect identification */ __clear_bit(BTN_TOOL_PEN, input->keybit); - __clear_bit(BTN_TOOL_FINGER, input->keybit); - __clear_bit(BTN_0, input->keybit); /* * A little something special to enable * two and three finger taps. diff --git a/trunk/drivers/hid/hid-tmff.c b/trunk/drivers/hid/hid-tmff.c index c32f32c84ac8..167ea746fb9c 100644 --- a/trunk/drivers/hid/hid-tmff.c +++ b/trunk/drivers/hid/hid-tmff.c @@ -251,8 +251,6 @@ static const struct hid_device_id tm_devices[] = { .driver_data = (unsigned long)ff_rumble }, { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651), /* FGT Rumble Force Wheel */ .driver_data = (unsigned long)ff_rumble }, - { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb653), /* RGT Force Feedback CLUTCH Raging Wheel */ - .driver_data = (unsigned long)ff_joystick }, { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654), /* FGT Force Feedback Wheel */ .driver_data = (unsigned long)ff_joystick }, { } diff --git a/trunk/drivers/hid/usbhid/hid-quirks.c b/trunk/drivers/hid/usbhid/hid-quirks.c index 928943c7ce9a..7844280897d1 100644 --- a/trunk/drivers/hid/usbhid/hid-quirks.c +++ b/trunk/drivers/hid/usbhid/hid-quirks.c @@ -63,7 +63,6 @@ static const struct hid_blacklist { { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET }, { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET }, { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_PF1209, HID_QUIRK_MULTI_INPUT }, - { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U, HID_QUIRK_MULTI_INPUT }, { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS }, { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_QUAD_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, diff --git a/trunk/drivers/infiniband/ulp/iser/iscsi_iser.c b/trunk/drivers/infiniband/ulp/iser/iscsi_iser.c index e78af36d3a0e..71237f8f78f7 100644 --- a/trunk/drivers/infiniband/ulp/iser/iscsi_iser.c +++ b/trunk/drivers/infiniband/ulp/iser/iscsi_iser.c @@ -613,7 +613,7 @@ static struct scsi_host_template iscsi_iser_sht = { .cmd_per_lun = ISER_DEF_CMD_PER_LUN, .eh_abort_handler = iscsi_eh_abort, .eh_device_reset_handler= iscsi_eh_device_reset, - .eh_target_reset_handler = iscsi_eh_recover_target, + .eh_target_reset_handler= iscsi_eh_target_reset, .target_alloc = iscsi_target_alloc, .use_clustering = DISABLE_CLUSTERING, .proc_name = "iscsi_iser", diff --git a/trunk/drivers/isdn/gigaset/capi.c b/trunk/drivers/isdn/gigaset/capi.c index 0220c19351d9..6643d6533ccb 100644 --- a/trunk/drivers/isdn/gigaset/capi.c +++ b/trunk/drivers/isdn/gigaset/capi.c @@ -1301,7 +1301,7 @@ static void do_connect_req(struct gigaset_capi_ctr *iif, } /* check parameter: CIP Value */ - if (cmsg->CIPValue >= ARRAY_SIZE(cip2bchlc) || + if (cmsg->CIPValue > ARRAY_SIZE(cip2bchlc) || (cmsg->CIPValue > 0 && cip2bchlc[cmsg->CIPValue].bc == NULL)) { dev_notice(cs->dev, "%s: unknown CIP value %d\n", "CONNECT_REQ", cmsg->CIPValue); @@ -2191,24 +2191,36 @@ static const struct file_operations gigaset_proc_fops = { .release = single_release, }; +static struct capi_driver capi_driver_gigaset = { + .name = "gigaset", + .revision = "1.0", +}; + /** - * gigaset_isdn_regdev() - register device to LL + * gigaset_isdn_register() - register to LL * @cs: device descriptor structure. * @isdnid: device name. * + * Called by main module to register the device with the LL. + * * Return value: 1 for success, 0 for failure */ -int gigaset_isdn_regdev(struct cardstate *cs, const char *isdnid) +int gigaset_isdn_register(struct cardstate *cs, const char *isdnid) { struct gigaset_capi_ctr *iif; int rc; + pr_info("Kernel CAPI interface\n"); + iif = kmalloc(sizeof(*iif), GFP_KERNEL); if (!iif) { pr_err("%s: out of memory\n", __func__); return 0; } + /* register driver with CAPI (ToDo: what for?) */ + register_capi_driver(&capi_driver_gigaset); + /* prepare controller structure */ iif->ctr.owner = THIS_MODULE; iif->ctr.driverdata = cs; @@ -2229,6 +2241,7 @@ int gigaset_isdn_regdev(struct cardstate *cs, const char *isdnid) rc = attach_capi_ctr(&iif->ctr); if (rc) { pr_err("attach_capi_ctr failed (%d)\n", rc); + unregister_capi_driver(&capi_driver_gigaset); kfree(iif); return 0; } @@ -2239,36 +2252,17 @@ int gigaset_isdn_regdev(struct cardstate *cs, const char *isdnid) } /** - * gigaset_isdn_unregdev() - unregister device from LL + * gigaset_isdn_unregister() - unregister from LL * @cs: device descriptor structure. + * + * Called by main module to unregister the device from the LL. */ -void gigaset_isdn_unregdev(struct cardstate *cs) +void gigaset_isdn_unregister(struct cardstate *cs) { struct gigaset_capi_ctr *iif = cs->iif; detach_capi_ctr(&iif->ctr); kfree(iif); cs->iif = NULL; -} - -static struct capi_driver capi_driver_gigaset = { - .name = "gigaset", - .revision = "1.0", -}; - -/** - * gigaset_isdn_regdrv() - register driver to LL - */ -void gigaset_isdn_regdrv(void) -{ - pr_info("Kernel CAPI interface\n"); - register_capi_driver(&capi_driver_gigaset); -} - -/** - * gigaset_isdn_unregdrv() - unregister driver from LL - */ -void gigaset_isdn_unregdrv(void) -{ unregister_capi_driver(&capi_driver_gigaset); } diff --git a/trunk/drivers/isdn/gigaset/common.c b/trunk/drivers/isdn/gigaset/common.c index bdc01cb9f0ab..85de3399a2f2 100644 --- a/trunk/drivers/isdn/gigaset/common.c +++ b/trunk/drivers/isdn/gigaset/common.c @@ -507,7 +507,7 @@ void gigaset_freecs(struct cardstate *cs) case 2: /* error in initcshw */ /* Deregister from LL */ make_invalid(cs, VALID_ID); - gigaset_isdn_unregdev(cs); + gigaset_isdn_unregister(cs); /* fall through */ case 1: /* error when registering to LL */ @@ -769,7 +769,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, cs->cmdbytes = 0; gig_dbg(DEBUG_INIT, "setting up iif"); - if (!gigaset_isdn_regdev(cs, modulename)) { + if (!gigaset_isdn_register(cs, modulename)) { pr_err("error registering ISDN device\n"); goto error; } @@ -1205,13 +1205,11 @@ static int __init gigaset_init_module(void) gigaset_debuglevel = DEBUG_DEFAULT; pr_info(DRIVER_DESC DRIVER_DESC_DEBUG "\n"); - gigaset_isdn_regdrv(); return 0; } static void __exit gigaset_exit_module(void) { - gigaset_isdn_unregdrv(); } module_init(gigaset_init_module); diff --git a/trunk/drivers/isdn/gigaset/dummyll.c b/trunk/drivers/isdn/gigaset/dummyll.c index bd0b1eaa7572..5b27c996af6d 100644 --- a/trunk/drivers/isdn/gigaset/dummyll.c +++ b/trunk/drivers/isdn/gigaset/dummyll.c @@ -57,20 +57,12 @@ void gigaset_isdn_stop(struct cardstate *cs) { } -int gigaset_isdn_regdev(struct cardstate *cs, const char *isdnid) -{ - return 1; -} - -void gigaset_isdn_unregdev(struct cardstate *cs) -{ -} - -void gigaset_isdn_regdrv(void) +int gigaset_isdn_register(struct cardstate *cs, const char *isdnid) { pr_info("no ISDN subsystem interface\n"); + return 1; } -void gigaset_isdn_unregdrv(void) +void gigaset_isdn_unregister(struct cardstate *cs) { } diff --git a/trunk/drivers/isdn/gigaset/ev-layer.c b/trunk/drivers/isdn/gigaset/ev-layer.c index 206c380c5235..c8f89b78b233 100644 --- a/trunk/drivers/isdn/gigaset/ev-layer.c +++ b/trunk/drivers/isdn/gigaset/ev-layer.c @@ -1258,10 +1258,14 @@ static void do_action(int action, struct cardstate *cs, * note that bcs may be NULL if no B channel is free */ at_state2->ConState = 700; - for (i = 0; i < STR_NUM; ++i) { - kfree(at_state2->str_var[i]); - at_state2->str_var[i] = NULL; - } + kfree(at_state2->str_var[STR_NMBR]); + at_state2->str_var[STR_NMBR] = NULL; + kfree(at_state2->str_var[STR_ZCPN]); + at_state2->str_var[STR_ZCPN] = NULL; + kfree(at_state2->str_var[STR_ZBC]); + at_state2->str_var[STR_ZBC] = NULL; + kfree(at_state2->str_var[STR_ZHLC]); + at_state2->str_var[STR_ZHLC] = NULL; at_state2->int_var[VAR_ZCTP] = -1; spin_lock_irqsave(&cs->lock, flags); diff --git a/trunk/drivers/isdn/gigaset/gigaset.h b/trunk/drivers/isdn/gigaset/gigaset.h index cdd144ecdc5f..1875ab80b335 100644 --- a/trunk/drivers/isdn/gigaset/gigaset.h +++ b/trunk/drivers/isdn/gigaset/gigaset.h @@ -675,10 +675,8 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size); */ /* Called from common.c for setting up/shutting down with the ISDN subsystem */ -void gigaset_isdn_regdrv(void); -void gigaset_isdn_unregdrv(void); -int gigaset_isdn_regdev(struct cardstate *cs, const char *isdnid); -void gigaset_isdn_unregdev(struct cardstate *cs); +int gigaset_isdn_register(struct cardstate *cs, const char *isdnid); +void gigaset_isdn_unregister(struct cardstate *cs); /* Called from hardware module to indicate completion of an skb */ void gigaset_skb_sent(struct bc_state *bcs, struct sk_buff *skb); diff --git a/trunk/drivers/isdn/gigaset/i4l.c b/trunk/drivers/isdn/gigaset/i4l.c index c22e5ace8276..f0acb9dc9e33 100644 --- a/trunk/drivers/isdn/gigaset/i4l.c +++ b/trunk/drivers/isdn/gigaset/i4l.c @@ -592,13 +592,15 @@ void gigaset_isdn_stop(struct cardstate *cs) } /** - * gigaset_isdn_regdev() - register to LL + * gigaset_isdn_register() - register to LL * @cs: device descriptor structure. * @isdnid: device name. * + * Called by main module to register the device with the LL. + * * Return value: 1 for success, 0 for failure */ -int gigaset_isdn_regdev(struct cardstate *cs, const char *isdnid) +int gigaset_isdn_register(struct cardstate *cs, const char *isdnid) { isdn_if *iif; @@ -648,29 +650,15 @@ int gigaset_isdn_regdev(struct cardstate *cs, const char *isdnid) } /** - * gigaset_isdn_unregdev() - unregister device from LL + * gigaset_isdn_unregister() - unregister from LL * @cs: device descriptor structure. + * + * Called by main module to unregister the device from the LL. */ -void gigaset_isdn_unregdev(struct cardstate *cs) +void gigaset_isdn_unregister(struct cardstate *cs) { gig_dbg(DEBUG_CMD, "sending UNLOAD"); gigaset_i4l_cmd(cs, ISDN_STAT_UNLOAD); kfree(cs->iif); cs->iif = NULL; } - -/** - * gigaset_isdn_regdrv() - register driver to LL - */ -void gigaset_isdn_regdrv(void) -{ - /* nothing to do */ -} - -/** - * gigaset_isdn_unregdrv() - unregister driver from LL - */ -void gigaset_isdn_unregdrv(void) -{ - /* nothing to do */ -} diff --git a/trunk/drivers/isdn/gigaset/interface.c b/trunk/drivers/isdn/gigaset/interface.c index f0dc6c9cc283..a1bcbc21ff71 100644 --- a/trunk/drivers/isdn/gigaset/interface.c +++ b/trunk/drivers/isdn/gigaset/interface.c @@ -628,6 +628,7 @@ void gigaset_if_receive(struct cardstate *cs, if (tty == NULL) gig_dbg(DEBUG_IF, "receive on closed device"); else { + tty_buffer_request_room(tty, len); tty_insert_flip_string(tty, buffer, len); tty_flip_buffer_push(tty); } diff --git a/trunk/drivers/isdn/hardware/eicon/message.c b/trunk/drivers/isdn/hardware/eicon/message.c index 341ef17c22ac..ae89fb89da64 100644 --- a/trunk/drivers/isdn/hardware/eicon/message.c +++ b/trunk/drivers/isdn/hardware/eicon/message.c @@ -2754,7 +2754,7 @@ static byte connect_b3_req(dword Id, word Number, DIVA_CAPI_ADAPTER *a, for (i = 0; i < w; i++) ((T30_INFO *)(plci->fax_connect_info_buffer))->station_id[i] = fax_parms[4].info[1+i]; ((T30_INFO *)(plci->fax_connect_info_buffer))->head_line_len = 0; - len = offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH; + len = offsetof(T30_INFO, station_id) + 20; w = fax_parms[5].length; if (w > 20) w = 20; @@ -2892,7 +2892,7 @@ static byte connect_b3_res(dword Id, word Number, DIVA_CAPI_ADAPTER *a, && (plci->nsf_control_bits & T30_NSF_CONTROL_BIT_ENABLE_NSF) && (plci->nsf_control_bits & T30_NSF_CONTROL_BIT_NEGOTIATE_RESP)) { - len = offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH; + len = offsetof(T30_INFO, station_id) + 20; if (plci->fax_connect_info_length < len) { ((T30_INFO *)(plci->fax_connect_info_buffer))->station_id_len = 0; @@ -3802,7 +3802,7 @@ static byte manufacturer_res(dword Id, word Number, DIVA_CAPI_ADAPTER *a, break; } ncpi = &m_parms[1]; - len = offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH; + len = offsetof(T30_INFO, station_id) + 20; if (plci->fax_connect_info_length < len) { ((T30_INFO *)(plci->fax_connect_info_buffer))->station_id_len = 0; @@ -6830,7 +6830,7 @@ static void nl_ind(PLCI *plci) if(((T30_INFO *)plci->NL.RBuffer->P)->station_id_len) { plci->ncpi_buffer[len] = 20; - for (i = 0; i < T30_MAX_STATION_ID_LENGTH; i++) + for (i = 0; i < 20; i++) plci->ncpi_buffer[++len] = ((T30_INFO *)plci->NL.RBuffer->P)->station_id[i]; } if (((plci->NL.Ind & 0x0f) == N_DISC) || ((plci->NL.Ind & 0x0f) == N_DISC_ACK)) @@ -6844,7 +6844,7 @@ static void nl_ind(PLCI *plci) if ((plci->requested_options_conn | plci->requested_options | a->requested_options_table[plci->appl->Id-1]) & ((1L << PRIVATE_FAX_SUB_SEP_PWD) | (1L << PRIVATE_FAX_NONSTANDARD))) { - i = offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH + ((T30_INFO *)plci->NL.RBuffer->P)->head_line_len; + i = offsetof(T30_INFO, station_id) + 20 + ((T30_INFO *)plci->NL.RBuffer->P)->head_line_len; while (i < plci->NL.RBuffer->length) plci->ncpi_buffer[++len] = plci->NL.RBuffer->P[i++]; } @@ -8400,7 +8400,7 @@ static word add_b23(PLCI *plci, API_PARSE *bp) } } /* copy station id to NLC */ - for(i=0; i < T30_MAX_STATION_ID_LENGTH; i++) + for(i=0; i<20; i++) { if(istation_id[i] = ' '; } } - ((T30_INFO *)&nlc[1])->station_id_len = T30_MAX_STATION_ID_LENGTH; + ((T30_INFO *)&nlc[1])->station_id_len = 20; /* copy head line to NLC */ if(b3_config_parms[3].length) { - pos = (byte)(fax_head_line_time (&(((T30_INFO *)&nlc[1])->station_id[T30_MAX_STATION_ID_LENGTH]))); + pos = (byte)(fax_head_line_time (&(((T30_INFO *)&nlc[1])->station_id[20]))); if (pos != 0) { if (CAPI_MAX_DATE_TIME_LENGTH + 2 + b3_config_parms[3].length > CAPI_MAX_HEAD_LINE_SPACE) pos = 0; else { - nlc[1 + offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH + pos++] = ' '; - nlc[1 + offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH + pos++] = ' '; + ((T30_INFO *)&nlc[1])->station_id[20 + pos++] = ' '; + ((T30_INFO *)&nlc[1])->station_id[20 + pos++] = ' '; len = (byte)b3_config_parms[2].length; if (len > 20) len = 20; if (CAPI_MAX_DATE_TIME_LENGTH + 2 + len + 2 + b3_config_parms[3].length <= CAPI_MAX_HEAD_LINE_SPACE) { for (i = 0; i < len; i++) - nlc[1 + offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH + pos++] = ((byte *)b3_config_parms[2].info)[1+i]; - nlc[1 + offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH + pos++] = ' '; - nlc[1 + offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH + pos++] = ' '; + ((T30_INFO *)&nlc[1])->station_id[20 + pos++] = ((byte *)b3_config_parms[2].info)[1+i]; + ((T30_INFO *)&nlc[1])->station_id[20 + pos++] = ' '; + ((T30_INFO *)&nlc[1])->station_id[20 + pos++] = ' '; } } } @@ -8444,8 +8444,9 @@ static word add_b23(PLCI *plci, API_PARSE *bp) ((T30_INFO *)&nlc[1])->head_line_len = (byte)(pos + len); nlc[0] += (byte)(pos + len); for (i = 0; i < len; i++) - nlc[1 + offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH + pos++] = ((byte *)b3_config_parms[3].info)[1+i]; - } else + ((T30_INFO *)&nlc[1])->station_id[20 + pos++] = ((byte *)b3_config_parms[3].info)[1+i]; + } + else ((T30_INFO *)&nlc[1])->head_line_len = 0; plci->nsf_control_bits = 0; @@ -8472,7 +8473,7 @@ static word add_b23(PLCI *plci, API_PARSE *bp) fax_control_bits |= T30_CONTROL_BIT_ACCEPT_SEL_POLLING; } len = nlc[0]; - pos = offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH; + pos = offsetof(T30_INFO, station_id) + 20; if (pos < plci->fax_connect_info_length) { for (i = 1 + plci->fax_connect_info_buffer[pos]; i != 0; i--) @@ -8524,7 +8525,7 @@ static word add_b23(PLCI *plci, API_PARSE *bp) } PUT_WORD(&(((T30_INFO *)&nlc[1])->control_bits_low), fax_control_bits); - len = offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH; + len = offsetof(T30_INFO, station_id) + 20; for (i = 0; i < len; i++) plci->fax_connect_info_buffer[i] = nlc[1+i]; ((T30_INFO *) plci->fax_connect_info_buffer)->head_line_len = 0; diff --git a/trunk/drivers/isdn/hardware/mISDN/hfcmulti.c b/trunk/drivers/isdn/hardware/mISDN/hfcmulti.c index 8affba3e569d..ad36df9b759c 100644 --- a/trunk/drivers/isdn/hardware/mISDN/hfcmulti.c +++ b/trunk/drivers/isdn/hardware/mISDN/hfcmulti.c @@ -5265,8 +5265,6 @@ static const struct hm_map hfcm_map[] = { /*31*/ {VENDOR_CCD, "XHFC-4S Speech Design", 5, 4, 0, 0, 0, 0, HFC_IO_MODE_EMBSD, XHFC_IRQ}, /*32*/ {VENDOR_JH, "HFC-8S (junghanns)", 8, 8, 1, 0, 0, 0, 0, 0}, -/*33*/ {VENDOR_BN, "HFC-2S Beronet Card PCIe", 4, 2, 1, 3, 0, DIP_4S, 0, 0}, -/*34*/ {VENDOR_BN, "HFC-4S Beronet Card PCIe", 4, 4, 1, 2, 0, DIP_4S, 0, 0}, }; #undef H @@ -5302,10 +5300,6 @@ static struct pci_device_id hfmultipci_ids[] __devinitdata = { PCI_SUBDEVICE_ID_CCD_OV4S, 0, 0, H(28)}, /* OpenVox 4 */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD, PCI_SUBDEVICE_ID_CCD_OV2S, 0, 0, H(29)}, /* OpenVox 2 */ - { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD, - 0xb761, 0, 0, H(33)}, /* BN2S PCIe */ - { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD, - 0xb762, 0, 0, H(34)}, /* BN4S PCIe */ /* Cards with HFC-8S Chip */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD, diff --git a/trunk/drivers/isdn/hysdn/hysdn_boot.c b/trunk/drivers/isdn/hysdn/hysdn_boot.c index 4f541ef14f9e..be787e16bb79 100644 --- a/trunk/drivers/isdn/hysdn/hysdn_boot.c +++ b/trunk/drivers/isdn/hysdn/hysdn_boot.c @@ -143,7 +143,7 @@ pof_handle_data(hysdn_card * card, int datlen) (boot->pof_recid == TAG_CABSDATA) ? "CABSDATA" : "ABSDATA", datlen, boot->pof_recoffset); - if ((boot->last_error = card->writebootseq(card, boot->buf.BootBuf, datlen)) < 0) + if ((boot->last_error = card->writebootseq(card, boot->buf.BootBuf, datlen) < 0)) return (boot->last_error); /* error writing data */ if (boot->pof_recoffset + datlen >= boot->pof_reclen) diff --git a/trunk/drivers/leds/Kconfig b/trunk/drivers/leds/Kconfig index 505eb64c329c..e0b64312e66a 100644 --- a/trunk/drivers/leds/Kconfig +++ b/trunk/drivers/leds/Kconfig @@ -15,8 +15,6 @@ config LEDS_CLASS This option enables the led sysfs class in /sys/class/leds. You'll need this to do anything useful with LEDs. If unsure, say N. -if LEDS_CLASS - comment "LED drivers" config LEDS_88PM860X @@ -28,73 +26,73 @@ config LEDS_88PM860X config LEDS_ATMEL_PWM tristate "LED Support using Atmel PWM outputs" - depends on ATMEL_PWM + depends on LEDS_CLASS && ATMEL_PWM help This option enables support for LEDs driven using outputs of the dedicated PWM controller found on newer Atmel SOCs. config LEDS_LOCOMO tristate "LED Support for Locomo device" - depends on SHARP_LOCOMO + depends on LEDS_CLASS && SHARP_LOCOMO help This option enables support for the LEDs on Sharp Locomo. Zaurus models SL-5500 and SL-5600. config LEDS_MIKROTIK_RB532 tristate "LED Support for Mikrotik Routerboard 532" - depends on MIKROTIK_RB532 + depends on LEDS_CLASS && MIKROTIK_RB532 help This option enables support for the so called "User LED" of Mikrotik's Routerboard 532. config LEDS_S3C24XX tristate "LED Support for Samsung S3C24XX GPIO LEDs" - depends on ARCH_S3C2410 + depends on LEDS_CLASS && ARCH_S3C2410 help This option enables support for LEDs connected to GPIO lines on Samsung S3C24XX series CPUs, such as the S3C2410 and S3C2440. config LEDS_AMS_DELTA tristate "LED Support for the Amstrad Delta (E3)" - depends on MACH_AMS_DELTA + depends on LEDS_CLASS && MACH_AMS_DELTA help This option enables support for the LEDs on Amstrad Delta (E3). config LEDS_NET48XX tristate "LED Support for Soekris net48xx series Error LED" - depends on SCx200_GPIO + depends on LEDS_CLASS && SCx200_GPIO help This option enables support for the Soekris net4801 and net4826 error LED. config LEDS_FSG tristate "LED Support for the Freecom FSG-3" - depends on MACH_FSG + depends on LEDS_CLASS && MACH_FSG help This option enables support for the LEDs on the Freecom FSG-3. config LEDS_WRAP tristate "LED Support for the WRAP series LEDs" - depends on SCx200_GPIO + depends on LEDS_CLASS && SCx200_GPIO help This option enables support for the PCEngines WRAP programmable LEDs. config LEDS_ALIX2 tristate "LED Support for ALIX.2 and ALIX.3 series" - depends on X86 && !GPIO_CS5535 && !CS5535_GPIO + depends on LEDS_CLASS && X86 && EXPERIMENTAL help This option enables support for the PCEngines ALIX.2 and ALIX.3 LEDs. You have to set leds-alix2.force=1 for boards with Award BIOS. config LEDS_H1940 tristate "LED Support for iPAQ H1940 device" - depends on ARCH_H1940 + depends on LEDS_CLASS && ARCH_H1940 help This option enables support for the LEDs on the h1940. config LEDS_COBALT_QUBE tristate "LED Support for the Cobalt Qube series front LED" - depends on MIPS_COBALT + depends on LEDS_CLASS && MIPS_COBALT help This option enables support for the front LED on Cobalt Qube series @@ -107,7 +105,7 @@ config LEDS_COBALT_RAQ config LEDS_SUNFIRE tristate "LED support for SunFire servers." - depends on SPARC64 + depends on LEDS_CLASS && SPARC64 select LEDS_TRIGGERS help This option enables support for the Left, Middle, and Right @@ -115,14 +113,14 @@ config LEDS_SUNFIRE config LEDS_HP6XX tristate "LED Support for the HP Jornada 6xx" - depends on SH_HP6XX + depends on LEDS_CLASS && SH_HP6XX help This option enables LED support for the handheld HP Jornada 620/660/680/690. config LEDS_PCA9532 tristate "LED driver for PCA9532 dimmer" - depends on I2C && INPUT && EXPERIMENTAL + depends on LEDS_CLASS && I2C && INPUT && EXPERIMENTAL help This option enables support for NXP pca9532 LED controller. It is generally only useful @@ -130,7 +128,7 @@ config LEDS_PCA9532 config LEDS_GPIO tristate "LED Support for GPIO connected LEDs" - depends on GENERIC_GPIO + depends on LEDS_CLASS && GENERIC_GPIO help This option enables support for the LEDs connected to GPIO outputs. To be useful the particular board must have LEDs @@ -157,7 +155,7 @@ config LEDS_GPIO_OF config LEDS_LP3944 tristate "LED Support for N.S. LP3944 (Fun Light) I2C chip" - depends on I2C + depends on LEDS_CLASS && I2C help This option enables support for LEDs connected to the National Semiconductor LP3944 Lighting Management Unit (LMU) also known as @@ -168,7 +166,7 @@ config LEDS_LP3944 config LEDS_CLEVO_MAIL tristate "Mail LED on Clevo notebook" - depends on X86 && SERIO_I8042 && DMI + depends on LEDS_CLASS && X86 && SERIO_I8042 && DMI help This driver makes the mail LED accessible from userspace programs through the leds subsystem. This LED have three @@ -198,7 +196,7 @@ config LEDS_CLEVO_MAIL config LEDS_PCA955X tristate "LED Support for PCA955x I2C chips" - depends on I2C + depends on LEDS_CLASS && I2C help This option enables support for LEDs connected to PCA955x LED driver chips accessed via the I2C bus. Supported @@ -206,54 +204,54 @@ config LEDS_PCA955X config LEDS_WM831X_STATUS tristate "LED support for status LEDs on WM831x PMICs" - depends on MFD_WM831X + depends on LEDS_CLASS && MFD_WM831X help This option enables support for the status LEDs of the WM831x series of PMICs. config LEDS_WM8350 tristate "LED Support for WM8350 AudioPlus PMIC" - depends on MFD_WM8350 + depends on LEDS_CLASS && MFD_WM8350 help This option enables support for LEDs driven by the Wolfson Microelectronics WM8350 AudioPlus PMIC. config LEDS_DA903X tristate "LED Support for DA9030/DA9034 PMIC" - depends on PMIC_DA903X + depends on LEDS_CLASS && PMIC_DA903X help This option enables support for on-chip LED drivers found on Dialog Semiconductor DA9030/DA9034 PMICs. config LEDS_DAC124S085 tristate "LED Support for DAC124S085 SPI DAC" - depends on SPI + depends on LEDS_CLASS && SPI help This option enables support for DAC124S085 SPI DAC from NatSemi, which can be used to control up to four LEDs. config LEDS_PWM tristate "PWM driven LED Support" - depends on HAVE_PWM + depends on LEDS_CLASS && HAVE_PWM help This option enables support for pwm driven LEDs config LEDS_REGULATOR tristate "REGULATOR driven LED support" - depends on REGULATOR + depends on LEDS_CLASS && REGULATOR help This option enables support for regulator driven LEDs. config LEDS_BD2802 tristate "LED driver for BD2802 RGB LED" - depends on I2C + depends on LEDS_CLASS && I2C help This option enables support for BD2802GU RGB LED driver chips accessed via the I2C bus. config LEDS_INTEL_SS4200 tristate "LED driver for Intel NAS SS4200 series" - depends on PCI && DMI + depends on LEDS_CLASS && PCI && DMI help This option enables support for the Intel SS4200 series of Network Attached Storage servers. You may control the hard @@ -262,7 +260,7 @@ config LEDS_INTEL_SS4200 config LEDS_LT3593 tristate "LED driver for LT3593 controllers" - depends on GENERIC_GPIO + depends on LEDS_CLASS && GENERIC_GPIO help This option enables support for LEDs driven by a Linear Technology LT3593 controller. This controller uses a special one-wire pulse @@ -270,7 +268,7 @@ config LEDS_LT3593 config LEDS_ADP5520 tristate "LED Support for ADP5520/ADP5501 PMIC" - depends on PMIC_ADP5520 + depends on LEDS_CLASS && PMIC_ADP5520 help This option enables support for on-chip LED drivers found on Analog Devices ADP5520/ADP5501 PMICs. @@ -278,12 +276,7 @@ config LEDS_ADP5520 To compile this driver as a module, choose M here: the module will be called leds-adp5520. -config LEDS_DELL_NETBOOKS - tristate "External LED on Dell Business Netbooks" - depends on X86 && ACPI_WMI - help - This adds support for the Latitude 2100 and similar - notebooks that have an external LED. +comment "LED Triggers" config LEDS_TRIGGERS bool "LED Trigger support" @@ -292,12 +285,9 @@ config LEDS_TRIGGERS These triggers allow kernel events to drive the LEDs and can be configured via sysfs. If unsure, say Y. -if LEDS_TRIGGERS - -comment "LED Triggers" - config LEDS_TRIGGER_TIMER tristate "LED Timer Trigger" + depends on LEDS_TRIGGERS help This allows LEDs to be controlled by a programmable timer via sysfs. Some LED hardware can be programmed to start @@ -308,13 +298,14 @@ config LEDS_TRIGGER_TIMER config LEDS_TRIGGER_IDE_DISK bool "LED IDE Disk Trigger" - depends on IDE_GD_ATA + depends on LEDS_TRIGGERS && IDE_GD_ATA help This allows LEDs to be controlled by IDE disk activity. If unsure, say Y. config LEDS_TRIGGER_HEARTBEAT tristate "LED Heartbeat Trigger" + depends on LEDS_TRIGGERS help This allows LEDs to be controlled by a CPU load average. The flash frequency is a hyperbolic function of the 1-minute @@ -323,6 +314,7 @@ config LEDS_TRIGGER_HEARTBEAT config LEDS_TRIGGER_BACKLIGHT tristate "LED backlight Trigger" + depends on LEDS_TRIGGERS help This allows LEDs to be controlled as a backlight device: they turn off and on when the display is blanked and unblanked. @@ -331,6 +323,7 @@ config LEDS_TRIGGER_BACKLIGHT config LEDS_TRIGGER_GPIO tristate "LED GPIO Trigger" + depends on LEDS_TRIGGERS depends on GPIOLIB help This allows LEDs to be controlled by gpio events. It's good @@ -343,6 +336,7 @@ config LEDS_TRIGGER_GPIO config LEDS_TRIGGER_DEFAULT_ON tristate "LED Default ON Trigger" + depends on LEDS_TRIGGERS help This allows LEDs to be initialised in the ON state. If unsure, say Y. @@ -350,8 +344,4 @@ config LEDS_TRIGGER_DEFAULT_ON comment "iptables trigger is under Netfilter config (LED target)" depends on LEDS_TRIGGERS -endif # LEDS_TRIGGERS - -endif # LEDS_CLASS - endif # NEW_LEDS diff --git a/trunk/drivers/leds/Makefile b/trunk/drivers/leds/Makefile index 0cd8b9957380..d76fb32b77c0 100644 --- a/trunk/drivers/leds/Makefile +++ b/trunk/drivers/leds/Makefile @@ -34,7 +34,6 @@ obj-$(CONFIG_LEDS_REGULATOR) += leds-regulator.o obj-$(CONFIG_LEDS_INTEL_SS4200) += leds-ss4200.o obj-$(CONFIG_LEDS_LT3593) += leds-lt3593.o obj-$(CONFIG_LEDS_ADP5520) += leds-adp5520.o -obj-$(CONFIG_LEDS_DELL_NETBOOKS) += dell-led.o # LED SPI Drivers obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o diff --git a/trunk/drivers/leds/dell-led.c b/trunk/drivers/leds/dell-led.c deleted file mode 100644 index ee310891fff8..000000000000 --- a/trunk/drivers/leds/dell-led.c +++ /dev/null @@ -1,200 +0,0 @@ -/* - * dell_led.c - Dell LED Driver - * - * Copyright (C) 2010 Dell Inc. - * Louis Davis - * Jim Dailey - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation. - * - */ - -#include -#include - -MODULE_AUTHOR("Louis Davis/Jim Dailey"); -MODULE_DESCRIPTION("Dell LED Control Driver"); -MODULE_LICENSE("GPL"); - -#define DELL_LED_BIOS_GUID "F6E4FE6E-909D-47cb-8BAB-C9F6F2F8D396" -MODULE_ALIAS("wmi:" DELL_LED_BIOS_GUID); - -/* Error Result Codes: */ -#define INVALID_DEVICE_ID 250 -#define INVALID_PARAMETER 251 -#define INVALID_BUFFER 252 -#define INTERFACE_ERROR 253 -#define UNSUPPORTED_COMMAND 254 -#define UNSPECIFIED_ERROR 255 - -/* Device ID */ -#define DEVICE_ID_PANEL_BACK 1 - -/* LED Commands */ -#define CMD_LED_ON 16 -#define CMD_LED_OFF 17 -#define CMD_LED_BLINK 18 - -struct bios_args { - unsigned char length; - unsigned char result_code; - unsigned char device_id; - unsigned char command; - unsigned char on_time; - unsigned char off_time; -}; - -static int dell_led_perform_fn(u8 length, - u8 result_code, - u8 device_id, - u8 command, - u8 on_time, - u8 off_time) -{ - struct bios_args *bios_return; - u8 return_code; - union acpi_object *obj; - struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; - struct acpi_buffer input; - acpi_status status; - - struct bios_args args; - args.length = length; - args.result_code = result_code; - args.device_id = device_id; - args.command = command; - args.on_time = on_time; - args.off_time = off_time; - - input.length = sizeof(struct bios_args); - input.pointer = &args; - - status = wmi_evaluate_method(DELL_LED_BIOS_GUID, - 1, - 1, - &input, - &output); - - if (ACPI_FAILURE(status)) - return status; - - obj = output.pointer; - - if (!obj) - return -EINVAL; - else if (obj->type != ACPI_TYPE_BUFFER) { - kfree(obj); - return -EINVAL; - } - - bios_return = ((struct bios_args *)obj->buffer.pointer); - return_code = bios_return->result_code; - - kfree(obj); - - return return_code; -} - -static int led_on(void) -{ - return dell_led_perform_fn(3, /* Length of command */ - INTERFACE_ERROR, /* Init to INTERFACE_ERROR */ - DEVICE_ID_PANEL_BACK, /* Device ID */ - CMD_LED_ON, /* Command */ - 0, /* not used */ - 0); /* not used */ -} - -static int led_off(void) -{ - return dell_led_perform_fn(3, /* Length of command */ - INTERFACE_ERROR, /* Init to INTERFACE_ERROR */ - DEVICE_ID_PANEL_BACK, /* Device ID */ - CMD_LED_OFF, /* Command */ - 0, /* not used */ - 0); /* not used */ -} - -static int led_blink(unsigned char on_eighths, - unsigned char off_eighths) -{ - return dell_led_perform_fn(5, /* Length of command */ - INTERFACE_ERROR, /* Init to INTERFACE_ERROR */ - DEVICE_ID_PANEL_BACK, /* Device ID */ - CMD_LED_BLINK, /* Command */ - on_eighths, /* blink on in eigths of a second */ - off_eighths); /* blink off in eights of a second */ -} - -static void dell_led_set(struct led_classdev *led_cdev, - enum led_brightness value) -{ - if (value == LED_OFF) - led_off(); - else - led_on(); -} - -static int dell_led_blink(struct led_classdev *led_cdev, - unsigned long *delay_on, - unsigned long *delay_off) -{ - unsigned long on_eighths; - unsigned long off_eighths; - - /* The Dell LED delay is based on 125ms intervals. - Need to round up to next interval. */ - - on_eighths = (*delay_on + 124) / 125; - if (0 == on_eighths) - on_eighths = 1; - if (on_eighths > 255) - on_eighths = 255; - *delay_on = on_eighths * 125; - - off_eighths = (*delay_off + 124) / 125; - if (0 == off_eighths) - off_eighths = 1; - if (off_eighths > 255) - off_eighths = 255; - *delay_off = off_eighths * 125; - - led_blink(on_eighths, off_eighths); - - return 0; -} - -static struct led_classdev dell_led = { - .name = "dell::lid", - .brightness = LED_OFF, - .max_brightness = 1, - .brightness_set = dell_led_set, - .blink_set = dell_led_blink, - .flags = LED_CORE_SUSPENDRESUME, -}; - -static int __init dell_led_init(void) -{ - int error = 0; - - if (!wmi_has_guid(DELL_LED_BIOS_GUID)) - return -ENODEV; - - error = led_off(); - if (error != 0) - return -ENODEV; - - return led_classdev_register(NULL, &dell_led); -} - -static void __exit dell_led_exit(void) -{ - led_classdev_unregister(&dell_led); - - led_off(); -} - -module_init(dell_led_init); -module_exit(dell_led_exit); diff --git a/trunk/drivers/leds/led-class.c b/trunk/drivers/leds/led-class.c index 69e7d86a5143..782f95822eab 100644 --- a/trunk/drivers/leds/led-class.c +++ b/trunk/drivers/leds/led-class.c @@ -72,14 +72,11 @@ static ssize_t led_max_brightness_show(struct device *dev, return sprintf(buf, "%u\n", led_cdev->max_brightness); } -static struct device_attribute led_class_attrs[] = { - __ATTR(brightness, 0644, led_brightness_show, led_brightness_store), - __ATTR(max_brightness, 0644, led_max_brightness_show, NULL), +static DEVICE_ATTR(brightness, 0644, led_brightness_show, led_brightness_store); +static DEVICE_ATTR(max_brightness, 0444, led_max_brightness_show, NULL); #ifdef CONFIG_LEDS_TRIGGERS - __ATTR(trigger, 0644, led_trigger_show, led_trigger_store), +static DEVICE_ATTR(trigger, 0644, led_trigger_show, led_trigger_store); #endif - __ATTR_NULL, -}; /** * led_classdev_suspend - suspend an led_classdev. @@ -130,11 +127,18 @@ static int led_resume(struct device *dev) */ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev) { + int rc; + led_cdev->dev = device_create(leds_class, parent, 0, led_cdev, "%s", led_cdev->name); if (IS_ERR(led_cdev->dev)) return PTR_ERR(led_cdev->dev); + /* register the attributes */ + rc = device_create_file(led_cdev->dev, &dev_attr_brightness); + if (rc) + goto err_out; + #ifdef CONFIG_LEDS_TRIGGERS init_rwsem(&led_cdev->trigger_lock); #endif @@ -146,18 +150,36 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev) if (!led_cdev->max_brightness) led_cdev->max_brightness = LED_FULL; + rc = device_create_file(led_cdev->dev, &dev_attr_max_brightness); + if (rc) + goto err_out_attr_max; + led_update_brightness(led_cdev); #ifdef CONFIG_LEDS_TRIGGERS + rc = device_create_file(led_cdev->dev, &dev_attr_trigger); + if (rc) + goto err_out_led_list; + led_trigger_set_default(led_cdev); #endif - printk(KERN_DEBUG "Registered led device: %s\n", + printk(KERN_INFO "Registered led device: %s\n", led_cdev->name); return 0; -} +#ifdef CONFIG_LEDS_TRIGGERS +err_out_led_list: + device_remove_file(led_cdev->dev, &dev_attr_max_brightness); +#endif +err_out_attr_max: + device_remove_file(led_cdev->dev, &dev_attr_brightness); + list_del(&led_cdev->node); +err_out: + device_unregister(led_cdev->dev); + return rc; +} EXPORT_SYMBOL_GPL(led_classdev_register); /** @@ -168,7 +190,10 @@ EXPORT_SYMBOL_GPL(led_classdev_register); */ void led_classdev_unregister(struct led_classdev *led_cdev) { + device_remove_file(led_cdev->dev, &dev_attr_max_brightness); + device_remove_file(led_cdev->dev, &dev_attr_brightness); #ifdef CONFIG_LEDS_TRIGGERS + device_remove_file(led_cdev->dev, &dev_attr_trigger); down_write(&led_cdev->trigger_lock); if (led_cdev->trigger) led_trigger_set(led_cdev, NULL); @@ -190,7 +215,6 @@ static int __init leds_init(void) return PTR_ERR(leds_class); leds_class->suspend = led_suspend; leds_class->resume = led_resume; - leds_class->dev_attrs = led_class_attrs; return 0; } diff --git a/trunk/drivers/leds/leds-gpio.c b/trunk/drivers/leds/leds-gpio.c index 0823e2622e8c..e5225d28f392 100644 --- a/trunk/drivers/leds/leds-gpio.c +++ b/trunk/drivers/leds/leds-gpio.c @@ -211,6 +211,7 @@ static int __devinit of_gpio_leds_probe(struct of_device *ofdev, const struct of_device_id *match) { struct device_node *np = ofdev->node, *child; + struct gpio_led led; struct gpio_led_of_platform_data *pdata; int count = 0, ret; @@ -225,8 +226,8 @@ static int __devinit of_gpio_leds_probe(struct of_device *ofdev, if (!pdata) return -ENOMEM; + memset(&led, 0, sizeof(led)); for_each_child_of_node(np, child) { - struct gpio_led led = {}; enum of_gpio_flags flags; const char *state; diff --git a/trunk/drivers/leds/leds-ss4200.c b/trunk/drivers/leds/leds-ss4200.c index 51477ec71391..97f04984c1ca 100644 --- a/trunk/drivers/leds/leds-ss4200.c +++ b/trunk/drivers/leds/leds-ss4200.c @@ -63,7 +63,7 @@ MODULE_LICENSE("GPL"); /* * PCI ID of the Intel ICH7 LPC Device within which the GPIO block lives. */ -static const struct pci_device_id ich7_lpc_pci_id[] = +static struct pci_device_id ich7_lpc_pci_id[] = { { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_0) }, { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_1) }, diff --git a/trunk/drivers/macintosh/via-pmu-backlight.c b/trunk/drivers/macintosh/via-pmu-backlight.c index 1cec02f6c431..4f3c4479c16a 100644 --- a/trunk/drivers/macintosh/via-pmu-backlight.c +++ b/trunk/drivers/macintosh/via-pmu-backlight.c @@ -144,7 +144,6 @@ void pmu_backlight_set_sleep(int sleep) void __init pmu_backlight_init() { - struct backlight_properties props; struct backlight_device *bd; char name[10]; int level, autosave; @@ -162,15 +161,13 @@ void __init pmu_backlight_init() snprintf(name, sizeof(name), "pmubl"); - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = FB_BACKLIGHT_LEVELS - 1; - bd = backlight_device_register(name, NULL, NULL, &pmu_backlight_data, - &props); + bd = backlight_device_register(name, NULL, NULL, &pmu_backlight_data); if (IS_ERR(bd)) { printk(KERN_ERR "PMU Backlight registration failed\n"); return; } uses_pmu_bl = 1; + bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1; pmu_backlight_init_curve(0x7F, 0x46, 0x0E); level = bd->props.max_brightness; diff --git a/trunk/drivers/md/linear.c b/trunk/drivers/md/linear.c index bb2a23159b21..af2d39d603c7 100644 --- a/trunk/drivers/md/linear.c +++ b/trunk/drivers/md/linear.c @@ -172,14 +172,12 @@ static linear_conf_t *linear_conf(mddev_t *mddev, int raid_disks) disk_stack_limits(mddev->gendisk, rdev->bdev, rdev->data_offset << 9); /* as we don't honour merge_bvec_fn, we must never risk - * violating it, so limit max_segments to 1 lying within - * a single page. + * violating it, so limit ->max_sector to one PAGE, as + * a one page request is never in violation. */ - if (rdev->bdev->bd_disk->queue->merge_bvec_fn) { - blk_queue_max_segments(mddev->queue, 1); - blk_queue_segment_boundary(mddev->queue, - PAGE_CACHE_SIZE - 1); - } + if (rdev->bdev->bd_disk->queue->merge_bvec_fn && + queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9)) + blk_queue_max_hw_sectors(mddev->queue, PAGE_SIZE>>9); conf->array_sectors += rdev->sectors; cnt++; diff --git a/trunk/drivers/md/multipath.c b/trunk/drivers/md/multipath.c index 5558ebc705c8..4b323f45ad74 100644 --- a/trunk/drivers/md/multipath.c +++ b/trunk/drivers/md/multipath.c @@ -301,16 +301,14 @@ static int multipath_add_disk(mddev_t *mddev, mdk_rdev_t *rdev) rdev->data_offset << 9); /* as we don't honour merge_bvec_fn, we must never risk - * violating it, so limit ->max_segments to one, lying - * within a single page. + * violating it, so limit ->max_sector to one PAGE, as + * a one page request is never in violation. * (Note: it is very unlikely that a device with * merge_bvec_fn will be involved in multipath.) */ - if (q->merge_bvec_fn) { - blk_queue_max_segments(mddev->queue, 1); - blk_queue_segment_boundary(mddev->queue, - PAGE_CACHE_SIZE - 1); - } + if (q->merge_bvec_fn && + queue_max_sectors(q) > (PAGE_SIZE>>9)) + blk_queue_max_hw_sectors(mddev->queue, PAGE_SIZE>>9); conf->working_disks++; mddev->degraded--; @@ -478,11 +476,9 @@ static int multipath_run (mddev_t *mddev) /* as we don't honour merge_bvec_fn, we must never risk * violating it, not that we ever expect a device with * a merge_bvec_fn to be involved in multipath */ - if (rdev->bdev->bd_disk->queue->merge_bvec_fn) { - blk_queue_max_segments(mddev->queue, 1); - blk_queue_segment_boundary(mddev->queue, - PAGE_CACHE_SIZE - 1); - } + if (rdev->bdev->bd_disk->queue->merge_bvec_fn && + queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9)) + blk_queue_max_hw_sectors(mddev->queue, PAGE_SIZE>>9); if (!test_bit(Faulty, &rdev->flags)) conf->working_disks++; diff --git a/trunk/drivers/md/raid0.c b/trunk/drivers/md/raid0.c index 377cf2a3c333..a1f7147b757f 100644 --- a/trunk/drivers/md/raid0.c +++ b/trunk/drivers/md/raid0.c @@ -176,15 +176,14 @@ static int create_strip_zones(mddev_t *mddev) disk_stack_limits(mddev->gendisk, rdev1->bdev, rdev1->data_offset << 9); /* as we don't honour merge_bvec_fn, we must never risk - * violating it, so limit ->max_segments to 1, lying within - * a single page. + * violating it, so limit ->max_sector to one PAGE, as + * a one page request is never in violation. */ - if (rdev1->bdev->bd_disk->queue->merge_bvec_fn) { - blk_queue_max_segments(mddev->queue, 1); - blk_queue_segment_boundary(mddev->queue, - PAGE_CACHE_SIZE - 1); - } + if (rdev1->bdev->bd_disk->queue->merge_bvec_fn && + queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9)) + blk_queue_max_hw_sectors(mddev->queue, PAGE_SIZE>>9); + if (!smallest || (rdev1->sectors < smallest->sectors)) smallest = rdev1; cnt++; diff --git a/trunk/drivers/md/raid1.c b/trunk/drivers/md/raid1.c index f741f77eeb2b..5a06122abd3b 100644 --- a/trunk/drivers/md/raid1.c +++ b/trunk/drivers/md/raid1.c @@ -1152,17 +1152,13 @@ static int raid1_add_disk(mddev_t *mddev, mdk_rdev_t *rdev) disk_stack_limits(mddev->gendisk, rdev->bdev, rdev->data_offset << 9); - /* as we don't honour merge_bvec_fn, we must - * never risk violating it, so limit - * ->max_segments to one lying with a single - * page, as a one page request is never in - * violation. + /* as we don't honour merge_bvec_fn, we must never risk + * violating it, so limit ->max_sector to one PAGE, as + * a one page request is never in violation. */ - if (rdev->bdev->bd_disk->queue->merge_bvec_fn) { - blk_queue_max_segments(mddev->queue, 1); - blk_queue_segment_boundary(mddev->queue, - PAGE_CACHE_SIZE - 1); - } + if (rdev->bdev->bd_disk->queue->merge_bvec_fn && + queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9)) + blk_queue_max_hw_sectors(mddev->queue, PAGE_SIZE>>9); p->head_position = 0; rdev->raid_disk = mirror; @@ -2102,14 +2098,12 @@ static int run(mddev_t *mddev) disk_stack_limits(mddev->gendisk, rdev->bdev, rdev->data_offset << 9); /* as we don't honour merge_bvec_fn, we must never risk - * violating it, so limit ->max_segments to 1 lying within - * a single page, as a one page request is never in violation. + * violating it, so limit ->max_sector to one PAGE, as + * a one page request is never in violation. */ - if (rdev->bdev->bd_disk->queue->merge_bvec_fn) { - blk_queue_max_segments(mddev->queue, 1); - blk_queue_segment_boundary(mddev->queue, - PAGE_CACHE_SIZE - 1); - } + if (rdev->bdev->bd_disk->queue->merge_bvec_fn && + queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9)) + blk_queue_max_hw_sectors(mddev->queue, PAGE_SIZE>>9); } mddev->degraded = 0; diff --git a/trunk/drivers/md/raid10.c b/trunk/drivers/md/raid10.c index b4ba41ecbd20..7584f9ab9bcf 100644 --- a/trunk/drivers/md/raid10.c +++ b/trunk/drivers/md/raid10.c @@ -1155,17 +1155,13 @@ static int raid10_add_disk(mddev_t *mddev, mdk_rdev_t *rdev) disk_stack_limits(mddev->gendisk, rdev->bdev, rdev->data_offset << 9); - /* as we don't honour merge_bvec_fn, we must - * never risk violating it, so limit - * ->max_segments to one lying with a single - * page, as a one page request is never in - * violation. + /* as we don't honour merge_bvec_fn, we must never risk + * violating it, so limit ->max_sector to one PAGE, as + * a one page request is never in violation. */ - if (rdev->bdev->bd_disk->queue->merge_bvec_fn) { - blk_queue_max_segments(mddev->queue, 1); - blk_queue_segment_boundary(mddev->queue, - PAGE_CACHE_SIZE - 1); - } + if (rdev->bdev->bd_disk->queue->merge_bvec_fn && + queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9)) + blk_queue_max_hw_sectors(mddev->queue, PAGE_SIZE>>9); p->head_position = 0; rdev->raid_disk = mirror; @@ -2259,14 +2255,12 @@ static int run(mddev_t *mddev) disk_stack_limits(mddev->gendisk, rdev->bdev, rdev->data_offset << 9); /* as we don't honour merge_bvec_fn, we must never risk - * violating it, so limit max_segments to 1 lying - * within a single page. + * violating it, so limit ->max_sector to one PAGE, as + * a one page request is never in violation. */ - if (rdev->bdev->bd_disk->queue->merge_bvec_fn) { - blk_queue_max_segments(mddev->queue, 1); - blk_queue_segment_boundary(mddev->queue, - PAGE_CACHE_SIZE - 1); - } + if (rdev->bdev->bd_disk->queue->merge_bvec_fn && + queue_max_sectors(mddev->queue) > (PAGE_SIZE>>9)) + blk_queue_max_hw_sectors(mddev->queue, PAGE_SIZE>>9); disk->head_position = 0; } diff --git a/trunk/drivers/net/benet/be_cmds.c b/trunk/drivers/net/benet/be_cmds.c index 50e6259b50e4..c59215361f4e 100644 --- a/trunk/drivers/net/benet/be_cmds.c +++ b/trunk/drivers/net/benet/be_cmds.c @@ -673,7 +673,7 @@ int be_cmd_mccq_create(struct be_adapter *adapter, be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, OPCODE_COMMON_MCC_CREATE, sizeof(*req)); - req->num_pages = cpu_to_le16(PAGES_4K_SPANNED(q_mem->va, q_mem->size)); + req->num_pages = PAGES_4K_SPANNED(q_mem->va, q_mem->size); AMAP_SET_BITS(struct amap_mcc_context, valid, ctxt, 1); AMAP_SET_BITS(struct amap_mcc_context, ring_size, ctxt, diff --git a/trunk/drivers/net/bnx2x_main.c b/trunk/drivers/net/bnx2x_main.c index 6c042a72d6cc..ed785a30e98b 100644 --- a/trunk/drivers/net/bnx2x_main.c +++ b/trunk/drivers/net/bnx2x_main.c @@ -893,6 +893,7 @@ static inline u16 bnx2x_tx_avail(struct bnx2x_fastpath *fp) u16 prod; u16 cons; + barrier(); /* Tell compiler that prod and cons can change */ prod = fp->tx_bd_prod; cons = fp->tx_bd_cons; @@ -962,7 +963,7 @@ static int bnx2x_tx_int(struct bnx2x_fastpath *fp) * start_xmit() will miss it and cause the queue to be stopped * forever. */ - smp_mb(); + smp_wmb(); /* TBD need a thresh? */ if (unlikely(netif_tx_queue_stopped(txq))) { @@ -11428,12 +11429,9 @@ static netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev) if (unlikely(bnx2x_tx_avail(fp) < MAX_SKB_FRAGS + 3)) { netif_tx_stop_queue(txq); - - /* paired memory barrier is in bnx2x_tx_int(), we have to keep - * ordering of set_bit() in netif_tx_stop_queue() and read of - * fp->bd_tx_cons */ + /* We want bnx2x_tx_int to "see" the updated tx_bd_prod + if we put Tx into XOFF state. */ smp_mb(); - fp->eth_q_stats.driver_xoff++; if (bnx2x_tx_avail(fp) >= MAX_SKB_FRAGS + 3) netif_tx_wake_queue(txq); diff --git a/trunk/drivers/net/davinci_emac.c b/trunk/drivers/net/davinci_emac.c index 2b8edd2efbf6..8bd086aee56d 100644 --- a/trunk/drivers/net/davinci_emac.c +++ b/trunk/drivers/net/davinci_emac.c @@ -29,6 +29,10 @@ * PHY layer usage */ +/** Pending Items in this driver: + * 1. Use Linux cache infrastcture for DMA'ed memory (dma_xxx functions) + */ + #include #include #include @@ -500,6 +504,12 @@ static unsigned long mdio_max_freq; /* Cache macros - Packet buffers would be from skb pool which is cached */ #define EMAC_VIRT_NOCACHE(addr) (addr) +#define EMAC_CACHE_INVALIDATE(addr, size) \ + dma_cache_maint((void *)addr, size, DMA_FROM_DEVICE) +#define EMAC_CACHE_WRITEBACK(addr, size) \ + dma_cache_maint((void *)addr, size, DMA_TO_DEVICE) +#define EMAC_CACHE_WRITEBACK_INVALIDATE(addr, size) \ + dma_cache_maint((void *)addr, size, DMA_BIDIRECTIONAL) /* DM644x does not have BD's in cached memory - so no cache functions */ #define BD_CACHE_INVALIDATE(addr, size) @@ -1225,10 +1235,6 @@ static void emac_txch_teardown(struct emac_priv *priv, u32 ch) if (1 == txch->queue_active) { curr_bd = txch->active_queue_head; while (curr_bd != NULL) { - dma_unmap_single(emac_dev, curr_bd->buff_ptr, - curr_bd->off_b_len & EMAC_RX_BD_BUF_SIZE, - DMA_TO_DEVICE); - emac_net_tx_complete(priv, (void __force *) &curr_bd->buf_token, 1, ch); if (curr_bd != txch->active_queue_tail) @@ -1321,11 +1327,6 @@ static int emac_tx_bdproc(struct emac_priv *priv, u32 ch, u32 budget) txch->queue_active = 0; /* end of queue */ } } - - dma_unmap_single(emac_dev, curr_bd->buff_ptr, - curr_bd->off_b_len & EMAC_RX_BD_BUF_SIZE, - DMA_TO_DEVICE); - *tx_complete_ptr = (u32) curr_bd->buf_token; ++tx_complete_ptr; ++tx_complete_cnt; @@ -1386,8 +1387,8 @@ static int emac_send(struct emac_priv *priv, struct emac_netpktobj *pkt, u32 ch) txch->bd_pool_head = curr_bd->next; curr_bd->buf_token = buf_list->buf_token; - curr_bd->buff_ptr = dma_map_single(&priv->ndev->dev, buf_list->data_ptr, - buf_list->length, DMA_TO_DEVICE); + /* FIXME buff_ptr = dma_map_single(... data_ptr ...) */ + curr_bd->buff_ptr = virt_to_phys(buf_list->data_ptr); curr_bd->off_b_len = buf_list->length; curr_bd->h_next = 0; curr_bd->next = NULL; @@ -1467,6 +1468,7 @@ static int emac_dev_xmit(struct sk_buff *skb, struct net_device *ndev) tx_buf.length = skb->len; tx_buf.buf_token = (void *)skb; tx_buf.data_ptr = skb->data; + EMAC_CACHE_WRITEBACK((unsigned long)skb->data, skb->len); ndev->trans_start = jiffies; ret_code = emac_send(priv, &tx_packet, EMAC_DEF_TX_CH); if (unlikely(ret_code != 0)) { @@ -1541,6 +1543,7 @@ static void *emac_net_alloc_rx_buf(struct emac_priv *priv, int buf_size, p_skb->dev = ndev; skb_reserve(p_skb, NET_IP_ALIGN); *data_token = (void *) p_skb; + EMAC_CACHE_WRITEBACK_INVALIDATE((unsigned long)p_skb->data, buf_size); return p_skb->data; } @@ -1609,8 +1612,8 @@ static int emac_init_rxch(struct emac_priv *priv, u32 ch, char *param) /* populate the hardware descriptor */ curr_bd->h_next = emac_virt_to_phys(rxch->active_queue_head, priv); - curr_bd->buff_ptr = dma_map_single(emac_dev, curr_bd->data_ptr, - rxch->buf_size, DMA_FROM_DEVICE); + /* FIXME buff_ptr = dma_map_single(... data_ptr ...) */ + curr_bd->buff_ptr = virt_to_phys(curr_bd->data_ptr); curr_bd->off_b_len = rxch->buf_size; curr_bd->mode = EMAC_CPPI_OWNERSHIP_BIT; @@ -1694,12 +1697,6 @@ static void emac_cleanup_rxch(struct emac_priv *priv, u32 ch) curr_bd = rxch->active_queue_head; while (curr_bd) { if (curr_bd->buf_token) { - dma_unmap_single(&priv->ndev->dev, - curr_bd->buff_ptr, - curr_bd->off_b_len - & EMAC_RX_BD_BUF_SIZE, - DMA_FROM_DEVICE); - dev_kfree_skb_any((struct sk_buff *)\ curr_bd->buf_token); } @@ -1874,8 +1871,8 @@ static void emac_addbd_to_rx_queue(struct emac_priv *priv, u32 ch, /* populate the hardware descriptor */ curr_bd->h_next = 0; - curr_bd->buff_ptr = dma_map_single(&priv->ndev->dev, buffer, - rxch->buf_size, DMA_FROM_DEVICE); + /* FIXME buff_ptr = dma_map_single(... buffer ...) */ + curr_bd->buff_ptr = virt_to_phys(buffer); curr_bd->off_b_len = rxch->buf_size; curr_bd->mode = EMAC_CPPI_OWNERSHIP_BIT; curr_bd->next = NULL; @@ -1930,6 +1927,7 @@ static int emac_net_rx_cb(struct emac_priv *priv, p_skb = (struct sk_buff *)net_pkt_list->pkt_token; /* set length of packet */ skb_put(p_skb, net_pkt_list->pkt_length); + EMAC_CACHE_INVALIDATE((unsigned long)p_skb->data, p_skb->len); p_skb->protocol = eth_type_trans(p_skb, priv->ndev); netif_receive_skb(p_skb); priv->net_dev_stats.rx_bytes += net_pkt_list->pkt_length; @@ -1992,11 +1990,6 @@ static int emac_rx_bdproc(struct emac_priv *priv, u32 ch, u32 budget) rx_buf_obj->data_ptr = (char *)curr_bd->data_ptr; rx_buf_obj->length = curr_bd->off_b_len & EMAC_RX_BD_BUF_SIZE; rx_buf_obj->buf_token = curr_bd->buf_token; - - dma_unmap_single(&priv->ndev->dev, curr_bd->buff_ptr, - curr_bd->off_b_len & EMAC_RX_BD_BUF_SIZE, - DMA_FROM_DEVICE); - curr_pkt->pkt_token = curr_pkt->buf_list->buf_token; curr_pkt->num_bufs = 1; curr_pkt->pkt_length = @@ -2827,37 +2820,31 @@ static int __devexit davinci_emac_remove(struct platform_device *pdev) return 0; } -static int davinci_emac_suspend(struct device *dev) +static +int davinci_emac_suspend(struct platform_device *pdev, pm_message_t state) { - struct platform_device *pdev = to_platform_device(dev); - struct net_device *ndev = platform_get_drvdata(pdev); + struct net_device *dev = platform_get_drvdata(pdev); - if (netif_running(ndev)) - emac_dev_stop(ndev); + if (netif_running(dev)) + emac_dev_stop(dev); clk_disable(emac_clk); return 0; } -static int davinci_emac_resume(struct device *dev) +static int davinci_emac_resume(struct platform_device *pdev) { - struct platform_device *pdev = to_platform_device(dev); - struct net_device *ndev = platform_get_drvdata(pdev); + struct net_device *dev = platform_get_drvdata(pdev); clk_enable(emac_clk); - if (netif_running(ndev)) - emac_dev_open(ndev); + if (netif_running(dev)) + emac_dev_open(dev); return 0; } -static const struct dev_pm_ops davinci_emac_pm_ops = { - .suspend = davinci_emac_suspend, - .resume = davinci_emac_resume, -}; - /** * davinci_emac_driver: EMAC platform driver structure */ @@ -2865,10 +2852,11 @@ static struct platform_driver davinci_emac_driver = { .driver = { .name = "davinci_emac", .owner = THIS_MODULE, - .pm = &davinci_emac_pm_ops, }, .probe = davinci_emac_probe, .remove = __devexit_p(davinci_emac_remove), + .suspend = davinci_emac_suspend, + .resume = davinci_emac_resume, }; /** diff --git a/trunk/drivers/net/e100.c b/trunk/drivers/net/e100.c index b997e578e58f..a26ccab057d5 100644 --- a/trunk/drivers/net/e100.c +++ b/trunk/drivers/net/e100.c @@ -2858,7 +2858,7 @@ static int __devinit e100_probe(struct pci_dev *pdev, } nic->cbs_pool = pci_pool_create(netdev->name, nic->pdev, - nic->params.cbs.max * sizeof(struct cb), + nic->params.cbs.count * sizeof(struct cb), sizeof(u32), 0); DPRINTK(PROBE, INFO, "addr 0x%llx, irq %d, MAC addr %pM\n", diff --git a/trunk/drivers/net/irda/w83977af_ir.c b/trunk/drivers/net/irda/w83977af_ir.c index 980625feb2c0..551810fd2976 100644 --- a/trunk/drivers/net/irda/w83977af_ir.c +++ b/trunk/drivers/net/irda/w83977af_ir.c @@ -65,6 +65,7 @@ #undef CONFIG_NETWINDER_TX_DMA_PROBLEMS /* Not needed */ #define CONFIG_NETWINDER_RX_DMA_PROBLEMS /* Must have this one! */ #endif +#undef CONFIG_USE_INTERNAL_TIMER /* Just cannot make that timer work */ #define CONFIG_USE_W977_PNP /* Currently needed */ #define PIO_MAX_SPEED 115200 @@ -532,6 +533,25 @@ static netdev_tx_t w83977af_hard_xmit(struct sk_buff *skb, self->tx_buff.len = skb->len; mtt = irda_get_mtt(skb); +#ifdef CONFIG_USE_INTERNAL_TIMER + if (mtt > 50) { + /* Adjust for timer resolution */ + mtt /= 1000+1; + + /* Setup timer */ + switch_bank(iobase, SET4); + outb(mtt & 0xff, iobase+TMRL); + outb((mtt >> 8) & 0x0f, iobase+TMRH); + + /* Start timer */ + outb(IR_MSL_EN_TMR, iobase+IR_MSL); + self->io.direction = IO_XMIT; + + /* Enable timer interrupt */ + switch_bank(iobase, SET0); + outb(ICR_ETMRI, iobase+ICR); + } else { +#endif IRDA_DEBUG(4, "%s(%ld), mtt=%d\n", __func__ , jiffies, mtt); if (mtt) udelay(mtt); @@ -540,6 +560,9 @@ static netdev_tx_t w83977af_hard_xmit(struct sk_buff *skb, switch_bank(iobase, SET0); outb(ICR_EDMAI, iobase+ICR); w83977af_dma_write(self, iobase); +#ifdef CONFIG_USE_INTERNAL_TIMER + } +#endif } else { self->tx_buff.data = self->tx_buff.head; self->tx_buff.len = async_wrap_skb(skb, self->tx_buff.data, @@ -853,7 +876,20 @@ static int w83977af_dma_receive_complete(struct w83977af_ir *self) /* Check if we have transferred all data to memory */ switch_bank(iobase, SET0); if (inb(iobase+USR) & USR_RDR) { +#ifdef CONFIG_USE_INTERNAL_TIMER + /* Put this entry back in fifo */ + st_fifo->head--; + st_fifo->len++; + st_fifo->entries[st_fifo->head].status = status; + st_fifo->entries[st_fifo->head].len = len; + + /* Restore set register */ + outb(set, iobase+SSR); + + return FALSE; /* I'll be back! */ +#else udelay(80); /* Should be enough!? */ +#endif } skb = dev_alloc_skb(len+1); diff --git a/trunk/drivers/net/ksz884x.c b/trunk/drivers/net/ksz884x.c index 0f59099ee72f..7264a3e5c2c0 100644 --- a/trunk/drivers/net/ksz884x.c +++ b/trunk/drivers/net/ksz884x.c @@ -4899,10 +4899,8 @@ static int netdev_tx(struct sk_buff *skb, struct net_device *dev) struct sk_buff *org_skb = skb; skb = dev_alloc_skb(org_skb->len); - if (!skb) { - rc = NETDEV_TX_BUSY; - goto unlock; - } + if (!skb) + return NETDEV_TX_BUSY; skb_copy_and_csum_dev(org_skb, skb->data); org_skb->ip_summed = 0; skb->len = org_skb->len; @@ -4916,7 +4914,7 @@ static int netdev_tx(struct sk_buff *skb, struct net_device *dev) netif_stop_queue(dev); rc = NETDEV_TX_BUSY; } -unlock: + spin_unlock_irq(&hw_priv->hwlock); return rc; diff --git a/trunk/drivers/net/myri10ge/myri10ge.c b/trunk/drivers/net/myri10ge/myri10ge.c index e84dd3ee9c5a..676c513e12fc 100644 --- a/trunk/drivers/net/myri10ge/myri10ge.c +++ b/trunk/drivers/net/myri10ge/myri10ge.c @@ -3687,6 +3687,7 @@ static void myri10ge_probe_slices(struct myri10ge_priv *mgp) if (status != 0) { dev_err(&mgp->pdev->dev, "failed reset\n"); goto abort_with_fw; + return; } mgp->max_intr_slots = cmd.data0 / sizeof(struct mcp_slot); diff --git a/trunk/drivers/net/ne.c b/trunk/drivers/net/ne.c index f4347f88b6f2..992dbfffdb05 100644 --- a/trunk/drivers/net/ne.c +++ b/trunk/drivers/net/ne.c @@ -142,7 +142,7 @@ bad_clone_list[] __initdata = { {"PCM-4823", "PCM-4823", {0x00, 0xc0, 0x6c}}, /* Broken Advantech MoBo */ {"REALTEK", "RTL8019", {0x00, 0x00, 0xe8}}, /* no-name with Realtek chip */ #ifdef CONFIG_MACH_TX49XX - {"RBHMA4X00-RTL8019", "RBHMA4X00-RTL8019", {0x00, 0x60, 0x0a}}, /* Toshiba built-in */ + {"RBHMA4X00-RTL8019", "RBHMA4X00/RTL8019", {0x00, 0x60, 0x0a}}, /* Toshiba built-in */ #endif {"LCS-8834", "LCS-8836", {0x04, 0x04, 0x37}}, /* ShinyNet (SET) */ {NULL,} diff --git a/trunk/drivers/net/pppol2tp.c b/trunk/drivers/net/pppol2tp.c index 449a9825200d..9fbb2eba9a06 100644 --- a/trunk/drivers/net/pppol2tp.c +++ b/trunk/drivers/net/pppol2tp.c @@ -756,7 +756,6 @@ static int pppol2tp_recv_core(struct sock *sock, struct sk_buff *skb) /* Try to dequeue as many skbs from reorder_q as we can. */ pppol2tp_recv_dequeue(session); - sock_put(sock); return 0; @@ -773,7 +772,6 @@ static int pppol2tp_recv_core(struct sock *sock, struct sk_buff *skb) UDP_INC_STATS_USER(&init_net, UDP_MIB_INERRORS, 0); tunnel->stats.rx_errors++; kfree_skb(skb); - sock_put(sock); return 0; @@ -1182,8 +1180,7 @@ static int pppol2tp_xmit(struct ppp_channel *chan, struct sk_buff *skb) /* Calculate UDP checksum if configured to do so */ if (sk_tun->sk_no_check == UDP_CSUM_NOXMIT) skb->ip_summed = CHECKSUM_NONE; - else if ((skb_dst(skb) && skb_dst(skb)->dev) && - (!(skb_dst(skb)->dev->features & NETIF_F_V4_CSUM))) { + else if (!(skb_dst(skb)->dev->features & NETIF_F_V4_CSUM)) { skb->ip_summed = CHECKSUM_COMPLETE; csum = skb_checksum(skb, 0, udp_len, 0); uh->check = csum_tcpudp_magic(inet->inet_saddr, @@ -1664,7 +1661,6 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr, if (tunnel_sock == NULL) goto end; - sock_hold(tunnel_sock); tunnel = tunnel_sock->sk_user_data; } else { tunnel = pppol2tp_tunnel_find(sock_net(sk), sp->pppol2tp.s_tunnel); diff --git a/trunk/drivers/net/s2io.c b/trunk/drivers/net/s2io.c index 2eb7f8a0d926..df70657260dd 100644 --- a/trunk/drivers/net/s2io.c +++ b/trunk/drivers/net/s2io.c @@ -5819,8 +5819,10 @@ static void s2io_vpd_read(struct s2io_nic *nic) } } - if ((!fail) && (vpd_data[1] < VPD_STRING_LEN)) + if ((!fail) && (vpd_data[1] < VPD_STRING_LEN)) { + memset(nic->product_name, 0, vpd_data[1]); memcpy(nic->product_name, &vpd_data[3], vpd_data[1]); + } kfree(vpd_data); swstats->mem_freed += 256; } diff --git a/trunk/drivers/net/usb/Kconfig b/trunk/drivers/net/usb/Kconfig index ba56ce4382d9..32d93564a74d 100644 --- a/trunk/drivers/net/usb/Kconfig +++ b/trunk/drivers/net/usb/Kconfig @@ -204,14 +204,6 @@ config USB_NET_DM9601 This option adds support for Davicom DM9601 based USB 1.1 10/100 Ethernet adapters. -config USB_NET_SMSC75XX - tristate "SMSC LAN75XX based USB 2.0 gigabit ethernet devices" - depends on USB_USBNET - select CRC32 - help - This option adds support for SMSC LAN95XX based USB 2.0 - Gigabit Ethernet adapters. - config USB_NET_SMSC95XX tristate "SMSC LAN95XX based USB 2.0 10/100 ethernet devices" depends on USB_USBNET diff --git a/trunk/drivers/net/usb/Makefile b/trunk/drivers/net/usb/Makefile index 82ea62955b56..e17afb78f372 100644 --- a/trunk/drivers/net/usb/Makefile +++ b/trunk/drivers/net/usb/Makefile @@ -11,7 +11,6 @@ obj-$(CONFIG_USB_NET_AX8817X) += asix.o obj-$(CONFIG_USB_NET_CDCETHER) += cdc_ether.o obj-$(CONFIG_USB_NET_CDC_EEM) += cdc_eem.o obj-$(CONFIG_USB_NET_DM9601) += dm9601.o -obj-$(CONFIG_USB_NET_SMSC75XX) += smsc75xx.o obj-$(CONFIG_USB_NET_SMSC95XX) += smsc95xx.o obj-$(CONFIG_USB_NET_GL620A) += gl620a.o obj-$(CONFIG_USB_NET_NET1080) += net1080.o diff --git a/trunk/drivers/net/usb/hso.c b/trunk/drivers/net/usb/hso.c index be0cc99e881a..6895f1531238 100644 --- a/trunk/drivers/net/usb/hso.c +++ b/trunk/drivers/net/usb/hso.c @@ -1155,6 +1155,9 @@ static void _hso_serial_set_termios(struct tty_struct *tty, static void hso_resubmit_rx_bulk_urb(struct hso_serial *serial, struct urb *urb) { int result; +#ifdef CONFIG_HSO_AUTOPM + usb_mark_last_busy(urb->dev); +#endif /* We are done with this URB, resubmit it. Prep the USB to wait for * another frame */ usb_fill_bulk_urb(urb, serial->parent->usb, diff --git a/trunk/drivers/net/usb/smsc75xx.c b/trunk/drivers/net/usb/smsc75xx.c deleted file mode 100644 index 300e3e764fa2..000000000000 --- a/trunk/drivers/net/usb/smsc75xx.c +++ /dev/null @@ -1,1288 +0,0 @@ - /*************************************************************************** - * - * Copyright (C) 2007-2010 SMSC - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - *****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "smsc75xx.h" - -#define SMSC_CHIPNAME "smsc75xx" -#define SMSC_DRIVER_VERSION "1.0.0" -#define HS_USB_PKT_SIZE (512) -#define FS_USB_PKT_SIZE (64) -#define DEFAULT_HS_BURST_CAP_SIZE (16 * 1024 + 5 * HS_USB_PKT_SIZE) -#define DEFAULT_FS_BURST_CAP_SIZE (6 * 1024 + 33 * FS_USB_PKT_SIZE) -#define DEFAULT_BULK_IN_DELAY (0x00002000) -#define MAX_SINGLE_PACKET_SIZE (9000) -#define LAN75XX_EEPROM_MAGIC (0x7500) -#define EEPROM_MAC_OFFSET (0x01) -#define DEFAULT_TX_CSUM_ENABLE (true) -#define DEFAULT_RX_CSUM_ENABLE (true) -#define DEFAULT_TSO_ENABLE (true) -#define SMSC75XX_INTERNAL_PHY_ID (1) -#define SMSC75XX_TX_OVERHEAD (8) -#define MAX_RX_FIFO_SIZE (20 * 1024) -#define MAX_TX_FIFO_SIZE (12 * 1024) -#define USB_VENDOR_ID_SMSC (0x0424) -#define USB_PRODUCT_ID_LAN7500 (0x7500) -#define USB_PRODUCT_ID_LAN7505 (0x7505) - -#define check_warn(ret, fmt, args...) \ - ({ if (ret < 0) netdev_warn(dev->net, fmt, ##args); }) - -#define check_warn_return(ret, fmt, args...) \ - ({ if (ret < 0) { netdev_warn(dev->net, fmt, ##args); return ret; } }) - -#define check_warn_goto_done(ret, fmt, args...) \ - ({ if (ret < 0) { netdev_warn(dev->net, fmt, ##args); goto done; } }) - -struct smsc75xx_priv { - struct usbnet *dev; - u32 rfe_ctl; - u32 multicast_hash_table[DP_SEL_VHF_HASH_LEN]; - bool use_rx_csum; - struct mutex dataport_mutex; - spinlock_t rfe_ctl_lock; - struct work_struct set_multicast; -}; - -struct usb_context { - struct usb_ctrlrequest req; - struct usbnet *dev; -}; - -static int turbo_mode = true; -module_param(turbo_mode, bool, 0644); -MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction"); - -static int __must_check smsc75xx_read_reg(struct usbnet *dev, u32 index, - u32 *data) -{ - u32 *buf = kmalloc(4, GFP_KERNEL); - int ret; - - BUG_ON(!dev); - - if (!buf) - return -ENOMEM; - - ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), - USB_VENDOR_REQUEST_READ_REGISTER, - USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, - 00, index, buf, 4, USB_CTRL_GET_TIMEOUT); - - if (unlikely(ret < 0)) - netdev_warn(dev->net, - "Failed to read register index 0x%08x", index); - - le32_to_cpus(buf); - *data = *buf; - kfree(buf); - - return ret; -} - -static int __must_check smsc75xx_write_reg(struct usbnet *dev, u32 index, - u32 data) -{ - u32 *buf = kmalloc(4, GFP_KERNEL); - int ret; - - BUG_ON(!dev); - - if (!buf) - return -ENOMEM; - - *buf = data; - cpu_to_le32s(buf); - - ret = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), - USB_VENDOR_REQUEST_WRITE_REGISTER, - USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, - 00, index, buf, 4, USB_CTRL_SET_TIMEOUT); - - if (unlikely(ret < 0)) - netdev_warn(dev->net, - "Failed to write register index 0x%08x", index); - - kfree(buf); - - return ret; -} - -/* Loop until the read is completed with timeout - * called with phy_mutex held */ -static int smsc75xx_phy_wait_not_busy(struct usbnet *dev) -{ - unsigned long start_time = jiffies; - u32 val; - int ret; - - do { - ret = smsc75xx_read_reg(dev, MII_ACCESS, &val); - check_warn_return(ret, "Error reading MII_ACCESS"); - - if (!(val & MII_ACCESS_BUSY)) - return 0; - } while (!time_after(jiffies, start_time + HZ)); - - return -EIO; -} - -static int smsc75xx_mdio_read(struct net_device *netdev, int phy_id, int idx) -{ - struct usbnet *dev = netdev_priv(netdev); - u32 val, addr; - int ret; - - mutex_lock(&dev->phy_mutex); - - /* confirm MII not busy */ - ret = smsc75xx_phy_wait_not_busy(dev); - check_warn_goto_done(ret, "MII is busy in smsc75xx_mdio_read"); - - /* set the address, index & direction (read from PHY) */ - phy_id &= dev->mii.phy_id_mask; - idx &= dev->mii.reg_num_mask; - addr = ((phy_id << MII_ACCESS_PHY_ADDR_SHIFT) & MII_ACCESS_PHY_ADDR) - | ((idx << MII_ACCESS_REG_ADDR_SHIFT) & MII_ACCESS_REG_ADDR) - | MII_ACCESS_READ; - ret = smsc75xx_write_reg(dev, MII_ACCESS, addr); - check_warn_goto_done(ret, "Error writing MII_ACCESS"); - - ret = smsc75xx_phy_wait_not_busy(dev); - check_warn_goto_done(ret, "Timed out reading MII reg %02X", idx); - - ret = smsc75xx_read_reg(dev, MII_DATA, &val); - check_warn_goto_done(ret, "Error reading MII_DATA"); - - ret = (u16)(val & 0xFFFF); - -done: - mutex_unlock(&dev->phy_mutex); - return ret; -} - -static void smsc75xx_mdio_write(struct net_device *netdev, int phy_id, int idx, - int regval) -{ - struct usbnet *dev = netdev_priv(netdev); - u32 val, addr; - int ret; - - mutex_lock(&dev->phy_mutex); - - /* confirm MII not busy */ - ret = smsc75xx_phy_wait_not_busy(dev); - check_warn_goto_done(ret, "MII is busy in smsc75xx_mdio_write"); - - val = regval; - ret = smsc75xx_write_reg(dev, MII_DATA, val); - check_warn_goto_done(ret, "Error writing MII_DATA"); - - /* set the address, index & direction (write to PHY) */ - phy_id &= dev->mii.phy_id_mask; - idx &= dev->mii.reg_num_mask; - addr = ((phy_id << MII_ACCESS_PHY_ADDR_SHIFT) & MII_ACCESS_PHY_ADDR) - | ((idx << MII_ACCESS_REG_ADDR_SHIFT) & MII_ACCESS_REG_ADDR) - | MII_ACCESS_WRITE; - ret = smsc75xx_write_reg(dev, MII_ACCESS, addr); - check_warn_goto_done(ret, "Error writing MII_ACCESS"); - - ret = smsc75xx_phy_wait_not_busy(dev); - check_warn_goto_done(ret, "Timed out writing MII reg %02X", idx); - -done: - mutex_unlock(&dev->phy_mutex); -} - -static int smsc75xx_wait_eeprom(struct usbnet *dev) -{ - unsigned long start_time = jiffies; - u32 val; - int ret; - - do { - ret = smsc75xx_read_reg(dev, E2P_CMD, &val); - check_warn_return(ret, "Error reading E2P_CMD"); - - if (!(val & E2P_CMD_BUSY) || (val & E2P_CMD_TIMEOUT)) - break; - udelay(40); - } while (!time_after(jiffies, start_time + HZ)); - - if (val & (E2P_CMD_TIMEOUT | E2P_CMD_BUSY)) { - netdev_warn(dev->net, "EEPROM read operation timeout"); - return -EIO; - } - - return 0; -} - -static int smsc75xx_eeprom_confirm_not_busy(struct usbnet *dev) -{ - unsigned long start_time = jiffies; - u32 val; - int ret; - - do { - ret = smsc75xx_read_reg(dev, E2P_CMD, &val); - check_warn_return(ret, "Error reading E2P_CMD"); - - if (!(val & E2P_CMD_BUSY)) - return 0; - - udelay(40); - } while (!time_after(jiffies, start_time + HZ)); - - netdev_warn(dev->net, "EEPROM is busy"); - return -EIO; -} - -static int smsc75xx_read_eeprom(struct usbnet *dev, u32 offset, u32 length, - u8 *data) -{ - u32 val; - int i, ret; - - BUG_ON(!dev); - BUG_ON(!data); - - ret = smsc75xx_eeprom_confirm_not_busy(dev); - if (ret) - return ret; - - for (i = 0; i < length; i++) { - val = E2P_CMD_BUSY | E2P_CMD_READ | (offset & E2P_CMD_ADDR); - ret = smsc75xx_write_reg(dev, E2P_CMD, val); - check_warn_return(ret, "Error writing E2P_CMD"); - - ret = smsc75xx_wait_eeprom(dev); - if (ret < 0) - return ret; - - ret = smsc75xx_read_reg(dev, E2P_DATA, &val); - check_warn_return(ret, "Error reading E2P_DATA"); - - data[i] = val & 0xFF; - offset++; - } - - return 0; -} - -static int smsc75xx_write_eeprom(struct usbnet *dev, u32 offset, u32 length, - u8 *data) -{ - u32 val; - int i, ret; - - BUG_ON(!dev); - BUG_ON(!data); - - ret = smsc75xx_eeprom_confirm_not_busy(dev); - if (ret) - return ret; - - /* Issue write/erase enable command */ - val = E2P_CMD_BUSY | E2P_CMD_EWEN; - ret = smsc75xx_write_reg(dev, E2P_CMD, val); - check_warn_return(ret, "Error writing E2P_CMD"); - - ret = smsc75xx_wait_eeprom(dev); - if (ret < 0) - return ret; - - for (i = 0; i < length; i++) { - - /* Fill data register */ - val = data[i]; - ret = smsc75xx_write_reg(dev, E2P_DATA, val); - check_warn_return(ret, "Error writing E2P_DATA"); - - /* Send "write" command */ - val = E2P_CMD_BUSY | E2P_CMD_WRITE | (offset & E2P_CMD_ADDR); - ret = smsc75xx_write_reg(dev, E2P_CMD, val); - check_warn_return(ret, "Error writing E2P_CMD"); - - ret = smsc75xx_wait_eeprom(dev); - if (ret < 0) - return ret; - - offset++; - } - - return 0; -} - -static int smsc75xx_dataport_wait_not_busy(struct usbnet *dev) -{ - int i, ret; - - for (i = 0; i < 100; i++) { - u32 dp_sel; - ret = smsc75xx_read_reg(dev, DP_SEL, &dp_sel); - check_warn_return(ret, "Error reading DP_SEL"); - - if (dp_sel & DP_SEL_DPRDY) - return 0; - - udelay(40); - } - - netdev_warn(dev->net, "smsc75xx_dataport_wait_not_busy timed out"); - - return -EIO; -} - -static int smsc75xx_dataport_write(struct usbnet *dev, u32 ram_select, u32 addr, - u32 length, u32 *buf) -{ - struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); - u32 dp_sel; - int i, ret; - - mutex_lock(&pdata->dataport_mutex); - - ret = smsc75xx_dataport_wait_not_busy(dev); - check_warn_goto_done(ret, "smsc75xx_dataport_write busy on entry"); - - ret = smsc75xx_read_reg(dev, DP_SEL, &dp_sel); - check_warn_goto_done(ret, "Error reading DP_SEL"); - - dp_sel &= ~DP_SEL_RSEL; - dp_sel |= ram_select; - ret = smsc75xx_write_reg(dev, DP_SEL, dp_sel); - check_warn_goto_done(ret, "Error writing DP_SEL"); - - for (i = 0; i < length; i++) { - ret = smsc75xx_write_reg(dev, DP_ADDR, addr + i); - check_warn_goto_done(ret, "Error writing DP_ADDR"); - - ret = smsc75xx_write_reg(dev, DP_DATA, buf[i]); - check_warn_goto_done(ret, "Error writing DP_DATA"); - - ret = smsc75xx_write_reg(dev, DP_CMD, DP_CMD_WRITE); - check_warn_goto_done(ret, "Error writing DP_CMD"); - - ret = smsc75xx_dataport_wait_not_busy(dev); - check_warn_goto_done(ret, "smsc75xx_dataport_write timeout"); - } - -done: - mutex_unlock(&pdata->dataport_mutex); - return ret; -} - -/* returns hash bit number for given MAC address */ -static u32 smsc75xx_hash(char addr[ETH_ALEN]) -{ - return (ether_crc(ETH_ALEN, addr) >> 23) & 0x1ff; -} - -static void smsc75xx_deferred_multicast_write(struct work_struct *param) -{ - struct smsc75xx_priv *pdata = - container_of(param, struct smsc75xx_priv, set_multicast); - struct usbnet *dev = pdata->dev; - int ret; - - netif_dbg(dev, drv, dev->net, "deferred multicast write 0x%08x", - pdata->rfe_ctl); - - smsc75xx_dataport_write(dev, DP_SEL_VHF, DP_SEL_VHF_VLAN_LEN, - DP_SEL_VHF_HASH_LEN, pdata->multicast_hash_table); - - ret = smsc75xx_write_reg(dev, RFE_CTL, pdata->rfe_ctl); - check_warn(ret, "Error writing RFE_CRL"); -} - -static void smsc75xx_set_multicast(struct net_device *netdev) -{ - struct usbnet *dev = netdev_priv(netdev); - struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); - unsigned long flags; - int i; - - spin_lock_irqsave(&pdata->rfe_ctl_lock, flags); - - pdata->rfe_ctl &= - ~(RFE_CTL_AU | RFE_CTL_AM | RFE_CTL_DPF | RFE_CTL_MHF); - pdata->rfe_ctl |= RFE_CTL_AB; - - for (i = 0; i < DP_SEL_VHF_HASH_LEN; i++) - pdata->multicast_hash_table[i] = 0; - - if (dev->net->flags & IFF_PROMISC) { - netif_dbg(dev, drv, dev->net, "promiscuous mode enabled"); - pdata->rfe_ctl |= RFE_CTL_AM | RFE_CTL_AU; - } else if (dev->net->flags & IFF_ALLMULTI) { - netif_dbg(dev, drv, dev->net, "receive all multicast enabled"); - pdata->rfe_ctl |= RFE_CTL_AM | RFE_CTL_DPF; - } else if (!netdev_mc_empty(dev->net)) { - struct dev_mc_list *mc_list; - - netif_dbg(dev, drv, dev->net, "receive multicast hash filter"); - - pdata->rfe_ctl |= RFE_CTL_MHF | RFE_CTL_DPF; - - netdev_for_each_mc_addr(mc_list, netdev) { - u32 bitnum = smsc75xx_hash(mc_list->dmi_addr); - pdata->multicast_hash_table[bitnum / 32] |= - (1 << (bitnum % 32)); - } - } else { - netif_dbg(dev, drv, dev->net, "receive own packets only"); - pdata->rfe_ctl |= RFE_CTL_DPF; - } - - spin_unlock_irqrestore(&pdata->rfe_ctl_lock, flags); - - /* defer register writes to a sleepable context */ - schedule_work(&pdata->set_multicast); -} - -static int smsc75xx_update_flowcontrol(struct usbnet *dev, u8 duplex, - u16 lcladv, u16 rmtadv) -{ - u32 flow = 0, fct_flow = 0; - int ret; - - if (duplex == DUPLEX_FULL) { - u8 cap = mii_resolve_flowctrl_fdx(lcladv, rmtadv); - - if (cap & FLOW_CTRL_TX) { - flow = (FLOW_TX_FCEN | 0xFFFF); - /* set fct_flow thresholds to 20% and 80% */ - fct_flow = (8 << 8) | 32; - } - - if (cap & FLOW_CTRL_RX) - flow |= FLOW_RX_FCEN; - - netif_dbg(dev, link, dev->net, "rx pause %s, tx pause %s", - (cap & FLOW_CTRL_RX ? "enabled" : "disabled"), - (cap & FLOW_CTRL_TX ? "enabled" : "disabled")); - } else { - netif_dbg(dev, link, dev->net, "half duplex"); - } - - ret = smsc75xx_write_reg(dev, FLOW, flow); - check_warn_return(ret, "Error writing FLOW"); - - ret = smsc75xx_write_reg(dev, FCT_FLOW, fct_flow); - check_warn_return(ret, "Error writing FCT_FLOW"); - - return 0; -} - -static int smsc75xx_link_reset(struct usbnet *dev) -{ - struct mii_if_info *mii = &dev->mii; - struct ethtool_cmd ecmd; - u16 lcladv, rmtadv; - int ret; - - /* clear interrupt status */ - ret = smsc75xx_mdio_read(dev->net, mii->phy_id, PHY_INT_SRC); - check_warn_return(ret, "Error reading PHY_INT_SRC"); - - ret = smsc75xx_write_reg(dev, INT_STS, INT_STS_CLEAR_ALL); - check_warn_return(ret, "Error writing INT_STS"); - - mii_check_media(mii, 1, 1); - mii_ethtool_gset(&dev->mii, &ecmd); - lcladv = smsc75xx_mdio_read(dev->net, mii->phy_id, MII_ADVERTISE); - rmtadv = smsc75xx_mdio_read(dev->net, mii->phy_id, MII_LPA); - - netif_dbg(dev, link, dev->net, "speed: %d duplex: %d lcladv: %04x" - " rmtadv: %04x", ecmd.speed, ecmd.duplex, lcladv, rmtadv); - - return smsc75xx_update_flowcontrol(dev, ecmd.duplex, lcladv, rmtadv); -} - -static void smsc75xx_status(struct usbnet *dev, struct urb *urb) -{ - u32 intdata; - - if (urb->actual_length != 4) { - netdev_warn(dev->net, - "unexpected urb length %d", urb->actual_length); - return; - } - - memcpy(&intdata, urb->transfer_buffer, 4); - le32_to_cpus(&intdata); - - netif_dbg(dev, link, dev->net, "intdata: 0x%08X", intdata); - - if (intdata & INT_ENP_PHY_INT) - usbnet_defer_kevent(dev, EVENT_LINK_RESET); - else - netdev_warn(dev->net, - "unexpected interrupt, intdata=0x%08X", intdata); -} - -/* Enable or disable Rx checksum offload engine */ -static int smsc75xx_set_rx_csum_offload(struct usbnet *dev) -{ - struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); - unsigned long flags; - int ret; - - spin_lock_irqsave(&pdata->rfe_ctl_lock, flags); - - if (pdata->use_rx_csum) - pdata->rfe_ctl |= RFE_CTL_TCPUDP_CKM | RFE_CTL_IP_CKM; - else - pdata->rfe_ctl &= ~(RFE_CTL_TCPUDP_CKM | RFE_CTL_IP_CKM); - - spin_unlock_irqrestore(&pdata->rfe_ctl_lock, flags); - - ret = smsc75xx_write_reg(dev, RFE_CTL, pdata->rfe_ctl); - check_warn_return(ret, "Error writing RFE_CTL"); - - return 0; -} - -static int smsc75xx_ethtool_get_eeprom_len(struct net_device *net) -{ - return MAX_EEPROM_SIZE; -} - -static int smsc75xx_ethtool_get_eeprom(struct net_device *netdev, - struct ethtool_eeprom *ee, u8 *data) -{ - struct usbnet *dev = netdev_priv(netdev); - - ee->magic = LAN75XX_EEPROM_MAGIC; - - return smsc75xx_read_eeprom(dev, ee->offset, ee->len, data); -} - -static int smsc75xx_ethtool_set_eeprom(struct net_device *netdev, - struct ethtool_eeprom *ee, u8 *data) -{ - struct usbnet *dev = netdev_priv(netdev); - - if (ee->magic != LAN75XX_EEPROM_MAGIC) { - netdev_warn(dev->net, - "EEPROM: magic value mismatch: 0x%x", ee->magic); - return -EINVAL; - } - - return smsc75xx_write_eeprom(dev, ee->offset, ee->len, data); -} - -static u32 smsc75xx_ethtool_get_rx_csum(struct net_device *netdev) -{ - struct usbnet *dev = netdev_priv(netdev); - struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); - - return pdata->use_rx_csum; -} - -static int smsc75xx_ethtool_set_rx_csum(struct net_device *netdev, u32 val) -{ - struct usbnet *dev = netdev_priv(netdev); - struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); - - pdata->use_rx_csum = !!val; - - return smsc75xx_set_rx_csum_offload(dev); -} - -static int smsc75xx_ethtool_set_tso(struct net_device *netdev, u32 data) -{ - if (data) - netdev->features |= NETIF_F_TSO | NETIF_F_TSO6; - else - netdev->features &= ~(NETIF_F_TSO | NETIF_F_TSO6); - - return 0; -} - -static const struct ethtool_ops smsc75xx_ethtool_ops = { - .get_link = usbnet_get_link, - .nway_reset = usbnet_nway_reset, - .get_drvinfo = usbnet_get_drvinfo, - .get_msglevel = usbnet_get_msglevel, - .set_msglevel = usbnet_set_msglevel, - .get_settings = usbnet_get_settings, - .set_settings = usbnet_set_settings, - .get_eeprom_len = smsc75xx_ethtool_get_eeprom_len, - .get_eeprom = smsc75xx_ethtool_get_eeprom, - .set_eeprom = smsc75xx_ethtool_set_eeprom, - .get_tx_csum = ethtool_op_get_tx_csum, - .set_tx_csum = ethtool_op_set_tx_hw_csum, - .get_rx_csum = smsc75xx_ethtool_get_rx_csum, - .set_rx_csum = smsc75xx_ethtool_set_rx_csum, - .get_tso = ethtool_op_get_tso, - .set_tso = smsc75xx_ethtool_set_tso, -}; - -static int smsc75xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd) -{ - struct usbnet *dev = netdev_priv(netdev); - - if (!netif_running(netdev)) - return -EINVAL; - - return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); -} - -static void smsc75xx_init_mac_address(struct usbnet *dev) -{ - /* try reading mac address from EEPROM */ - if (smsc75xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN, - dev->net->dev_addr) == 0) { - if (is_valid_ether_addr(dev->net->dev_addr)) { - /* eeprom values are valid so use them */ - netif_dbg(dev, ifup, dev->net, - "MAC address read from EEPROM"); - return; - } - } - - /* no eeprom, or eeprom values are invalid. generate random MAC */ - random_ether_addr(dev->net->dev_addr); - netif_dbg(dev, ifup, dev->net, "MAC address set to random_ether_addr"); -} - -static int smsc75xx_set_mac_address(struct usbnet *dev) -{ - u32 addr_lo = dev->net->dev_addr[0] | dev->net->dev_addr[1] << 8 | - dev->net->dev_addr[2] << 16 | dev->net->dev_addr[3] << 24; - u32 addr_hi = dev->net->dev_addr[4] | dev->net->dev_addr[5] << 8; - - int ret = smsc75xx_write_reg(dev, RX_ADDRH, addr_hi); - check_warn_return(ret, "Failed to write RX_ADDRH: %d", ret); - - ret = smsc75xx_write_reg(dev, RX_ADDRL, addr_lo); - check_warn_return(ret, "Failed to write RX_ADDRL: %d", ret); - - addr_hi |= ADDR_FILTX_FB_VALID; - ret = smsc75xx_write_reg(dev, ADDR_FILTX, addr_hi); - check_warn_return(ret, "Failed to write ADDR_FILTX: %d", ret); - - ret = smsc75xx_write_reg(dev, ADDR_FILTX + 4, addr_lo); - check_warn_return(ret, "Failed to write ADDR_FILTX+4: %d", ret); - - return 0; -} - -static int smsc75xx_phy_initialize(struct usbnet *dev) -{ - int bmcr, timeout = 0; - - /* Initialize MII structure */ - dev->mii.dev = dev->net; - dev->mii.mdio_read = smsc75xx_mdio_read; - dev->mii.mdio_write = smsc75xx_mdio_write; - dev->mii.phy_id_mask = 0x1f; - dev->mii.reg_num_mask = 0x1f; - dev->mii.phy_id = SMSC75XX_INTERNAL_PHY_ID; - - /* reset phy and wait for reset to complete */ - smsc75xx_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET); - - do { - msleep(10); - bmcr = smsc75xx_mdio_read(dev->net, dev->mii.phy_id, MII_BMCR); - check_warn_return(bmcr, "Error reading MII_BMCR"); - timeout++; - } while ((bmcr & MII_BMCR) && (timeout < 100)); - - if (timeout >= 100) { - netdev_warn(dev->net, "timeout on PHY Reset"); - return -EIO; - } - - smsc75xx_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, - ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP | - ADVERTISE_PAUSE_ASYM); - - /* read to clear */ - smsc75xx_mdio_read(dev->net, dev->mii.phy_id, PHY_INT_SRC); - check_warn_return(bmcr, "Error reading PHY_INT_SRC"); - - smsc75xx_mdio_write(dev->net, dev->mii.phy_id, PHY_INT_MASK, - PHY_INT_MASK_DEFAULT); - mii_nway_restart(&dev->mii); - - netif_dbg(dev, ifup, dev->net, "phy initialised successfully"); - return 0; -} - -static int smsc75xx_set_rx_max_frame_length(struct usbnet *dev, int size) -{ - int ret = 0; - u32 buf; - bool rxenabled; - - ret = smsc75xx_read_reg(dev, MAC_RX, &buf); - check_warn_return(ret, "Failed to read MAC_RX: %d", ret); - - rxenabled = ((buf & MAC_RX_RXEN) != 0); - - if (rxenabled) { - buf &= ~MAC_RX_RXEN; - ret = smsc75xx_write_reg(dev, MAC_RX, buf); - check_warn_return(ret, "Failed to write MAC_RX: %d", ret); - } - - /* add 4 to size for FCS */ - buf &= ~MAC_RX_MAX_SIZE; - buf |= (((size + 4) << MAC_RX_MAX_SIZE_SHIFT) & MAC_RX_MAX_SIZE); - - ret = smsc75xx_write_reg(dev, MAC_RX, buf); - check_warn_return(ret, "Failed to write MAC_RX: %d", ret); - - if (rxenabled) { - buf |= MAC_RX_RXEN; - ret = smsc75xx_write_reg(dev, MAC_RX, buf); - check_warn_return(ret, "Failed to write MAC_RX: %d", ret); - } - - return 0; -} - -static int smsc75xx_change_mtu(struct net_device *netdev, int new_mtu) -{ - struct usbnet *dev = netdev_priv(netdev); - - int ret = smsc75xx_set_rx_max_frame_length(dev, new_mtu); - check_warn_return(ret, "Failed to set mac rx frame length"); - - return usbnet_change_mtu(netdev, new_mtu); -} - -static int smsc75xx_reset(struct usbnet *dev) -{ - struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); - u32 buf; - int ret = 0, timeout; - - netif_dbg(dev, ifup, dev->net, "entering smsc75xx_reset"); - - ret = smsc75xx_read_reg(dev, HW_CFG, &buf); - check_warn_return(ret, "Failed to read HW_CFG: %d", ret); - - buf |= HW_CFG_LRST; - - ret = smsc75xx_write_reg(dev, HW_CFG, buf); - check_warn_return(ret, "Failed to write HW_CFG: %d", ret); - - timeout = 0; - do { - msleep(10); - ret = smsc75xx_read_reg(dev, HW_CFG, &buf); - check_warn_return(ret, "Failed to read HW_CFG: %d", ret); - timeout++; - } while ((buf & HW_CFG_LRST) && (timeout < 100)); - - if (timeout >= 100) { - netdev_warn(dev->net, "timeout on completion of Lite Reset"); - return -EIO; - } - - netif_dbg(dev, ifup, dev->net, "Lite reset complete, resetting PHY"); - - ret = smsc75xx_read_reg(dev, PMT_CTL, &buf); - check_warn_return(ret, "Failed to read PMT_CTL: %d", ret); - - buf |= PMT_CTL_PHY_RST; - - ret = smsc75xx_write_reg(dev, PMT_CTL, buf); - check_warn_return(ret, "Failed to write PMT_CTL: %d", ret); - - timeout = 0; - do { - msleep(10); - ret = smsc75xx_read_reg(dev, PMT_CTL, &buf); - check_warn_return(ret, "Failed to read PMT_CTL: %d", ret); - timeout++; - } while ((buf & PMT_CTL_PHY_RST) && (timeout < 100)); - - if (timeout >= 100) { - netdev_warn(dev->net, "timeout waiting for PHY Reset"); - return -EIO; - } - - netif_dbg(dev, ifup, dev->net, "PHY reset complete"); - - smsc75xx_init_mac_address(dev); - - ret = smsc75xx_set_mac_address(dev); - check_warn_return(ret, "Failed to set mac address"); - - netif_dbg(dev, ifup, dev->net, "MAC Address: %pM", dev->net->dev_addr); - - ret = smsc75xx_read_reg(dev, HW_CFG, &buf); - check_warn_return(ret, "Failed to read HW_CFG: %d", ret); - - netif_dbg(dev, ifup, dev->net, "Read Value from HW_CFG : 0x%08x", buf); - - buf |= HW_CFG_BIR; - - ret = smsc75xx_write_reg(dev, HW_CFG, buf); - check_warn_return(ret, "Failed to write HW_CFG: %d", ret); - - ret = smsc75xx_read_reg(dev, HW_CFG, &buf); - check_warn_return(ret, "Failed to read HW_CFG: %d", ret); - - netif_dbg(dev, ifup, dev->net, "Read Value from HW_CFG after " - "writing HW_CFG_BIR: 0x%08x", buf); - - if (!turbo_mode) { - buf = 0; - dev->rx_urb_size = MAX_SINGLE_PACKET_SIZE; - } else if (dev->udev->speed == USB_SPEED_HIGH) { - buf = DEFAULT_HS_BURST_CAP_SIZE / HS_USB_PKT_SIZE; - dev->rx_urb_size = DEFAULT_HS_BURST_CAP_SIZE; - } else { - buf = DEFAULT_FS_BURST_CAP_SIZE / FS_USB_PKT_SIZE; - dev->rx_urb_size = DEFAULT_FS_BURST_CAP_SIZE; - } - - netif_dbg(dev, ifup, dev->net, "rx_urb_size=%ld", - (ulong)dev->rx_urb_size); - - ret = smsc75xx_write_reg(dev, BURST_CAP, buf); - check_warn_return(ret, "Failed to write BURST_CAP: %d", ret); - - ret = smsc75xx_read_reg(dev, BURST_CAP, &buf); - check_warn_return(ret, "Failed to read BURST_CAP: %d", ret); - - netif_dbg(dev, ifup, dev->net, - "Read Value from BURST_CAP after writing: 0x%08x", buf); - - ret = smsc75xx_write_reg(dev, BULK_IN_DLY, DEFAULT_BULK_IN_DELAY); - check_warn_return(ret, "Failed to write BULK_IN_DLY: %d", ret); - - ret = smsc75xx_read_reg(dev, BULK_IN_DLY, &buf); - check_warn_return(ret, "Failed to read BULK_IN_DLY: %d", ret); - - netif_dbg(dev, ifup, dev->net, - "Read Value from BULK_IN_DLY after writing: 0x%08x", buf); - - if (turbo_mode) { - ret = smsc75xx_read_reg(dev, HW_CFG, &buf); - check_warn_return(ret, "Failed to read HW_CFG: %d", ret); - - netif_dbg(dev, ifup, dev->net, "HW_CFG: 0x%08x", buf); - - buf |= (HW_CFG_MEF | HW_CFG_BCE); - - ret = smsc75xx_write_reg(dev, HW_CFG, buf); - check_warn_return(ret, "Failed to write HW_CFG: %d", ret); - - ret = smsc75xx_read_reg(dev, HW_CFG, &buf); - check_warn_return(ret, "Failed to read HW_CFG: %d", ret); - - netif_dbg(dev, ifup, dev->net, "HW_CFG: 0x%08x", buf); - } - - /* set FIFO sizes */ - buf = (MAX_RX_FIFO_SIZE - 512) / 512; - ret = smsc75xx_write_reg(dev, FCT_RX_FIFO_END, buf); - check_warn_return(ret, "Failed to write FCT_RX_FIFO_END: %d", ret); - - netif_dbg(dev, ifup, dev->net, "FCT_RX_FIFO_END set to 0x%08x", buf); - - buf = (MAX_TX_FIFO_SIZE - 512) / 512; - ret = smsc75xx_write_reg(dev, FCT_TX_FIFO_END, buf); - check_warn_return(ret, "Failed to write FCT_TX_FIFO_END: %d", ret); - - netif_dbg(dev, ifup, dev->net, "FCT_TX_FIFO_END set to 0x%08x", buf); - - ret = smsc75xx_write_reg(dev, INT_STS, INT_STS_CLEAR_ALL); - check_warn_return(ret, "Failed to write INT_STS: %d", ret); - - ret = smsc75xx_read_reg(dev, ID_REV, &buf); - check_warn_return(ret, "Failed to read ID_REV: %d", ret); - - netif_dbg(dev, ifup, dev->net, "ID_REV = 0x%08x", buf); - - /* Configure GPIO pins as LED outputs */ - ret = smsc75xx_read_reg(dev, LED_GPIO_CFG, &buf); - check_warn_return(ret, "Failed to read LED_GPIO_CFG: %d", ret); - - buf &= ~(LED_GPIO_CFG_LED2_FUN_SEL | LED_GPIO_CFG_LED10_FUN_SEL); - buf |= LED_GPIO_CFG_LEDGPIO_EN | LED_GPIO_CFG_LED2_FUN_SEL; - - ret = smsc75xx_write_reg(dev, LED_GPIO_CFG, buf); - check_warn_return(ret, "Failed to write LED_GPIO_CFG: %d", ret); - - ret = smsc75xx_write_reg(dev, FLOW, 0); - check_warn_return(ret, "Failed to write FLOW: %d", ret); - - ret = smsc75xx_write_reg(dev, FCT_FLOW, 0); - check_warn_return(ret, "Failed to write FCT_FLOW: %d", ret); - - /* Don't need rfe_ctl_lock during initialisation */ - ret = smsc75xx_read_reg(dev, RFE_CTL, &pdata->rfe_ctl); - check_warn_return(ret, "Failed to read RFE_CTL: %d", ret); - - pdata->rfe_ctl |= RFE_CTL_AB | RFE_CTL_DPF; - - ret = smsc75xx_write_reg(dev, RFE_CTL, pdata->rfe_ctl); - check_warn_return(ret, "Failed to write RFE_CTL: %d", ret); - - ret = smsc75xx_read_reg(dev, RFE_CTL, &pdata->rfe_ctl); - check_warn_return(ret, "Failed to read RFE_CTL: %d", ret); - - netif_dbg(dev, ifup, dev->net, "RFE_CTL set to 0x%08x", pdata->rfe_ctl); - - /* Enable or disable checksum offload engines */ - ethtool_op_set_tx_hw_csum(dev->net, DEFAULT_TX_CSUM_ENABLE); - ret = smsc75xx_set_rx_csum_offload(dev); - check_warn_return(ret, "Failed to set rx csum offload: %d", ret); - - smsc75xx_ethtool_set_tso(dev->net, DEFAULT_TSO_ENABLE); - - smsc75xx_set_multicast(dev->net); - - ret = smsc75xx_phy_initialize(dev); - check_warn_return(ret, "Failed to initialize PHY: %d", ret); - - ret = smsc75xx_read_reg(dev, INT_EP_CTL, &buf); - check_warn_return(ret, "Failed to read INT_EP_CTL: %d", ret); - - /* enable PHY interrupts */ - buf |= INT_ENP_PHY_INT; - - ret = smsc75xx_write_reg(dev, INT_EP_CTL, buf); - check_warn_return(ret, "Failed to write INT_EP_CTL: %d", ret); - - ret = smsc75xx_read_reg(dev, MAC_TX, &buf); - check_warn_return(ret, "Failed to read MAC_TX: %d", ret); - - buf |= MAC_TX_TXEN; - - ret = smsc75xx_write_reg(dev, MAC_TX, buf); - check_warn_return(ret, "Failed to write MAC_TX: %d", ret); - - netif_dbg(dev, ifup, dev->net, "MAC_TX set to 0x%08x", buf); - - ret = smsc75xx_read_reg(dev, FCT_TX_CTL, &buf); - check_warn_return(ret, "Failed to read FCT_TX_CTL: %d", ret); - - buf |= FCT_TX_CTL_EN; - - ret = smsc75xx_write_reg(dev, FCT_TX_CTL, buf); - check_warn_return(ret, "Failed to write FCT_TX_CTL: %d", ret); - - netif_dbg(dev, ifup, dev->net, "FCT_TX_CTL set to 0x%08x", buf); - - ret = smsc75xx_set_rx_max_frame_length(dev, 1514); - check_warn_return(ret, "Failed to set max rx frame length"); - - ret = smsc75xx_read_reg(dev, MAC_RX, &buf); - check_warn_return(ret, "Failed to read MAC_RX: %d", ret); - - buf |= MAC_RX_RXEN; - - ret = smsc75xx_write_reg(dev, MAC_RX, buf); - check_warn_return(ret, "Failed to write MAC_RX: %d", ret); - - netif_dbg(dev, ifup, dev->net, "MAC_RX set to 0x%08x", buf); - - ret = smsc75xx_read_reg(dev, FCT_RX_CTL, &buf); - check_warn_return(ret, "Failed to read FCT_RX_CTL: %d", ret); - - buf |= FCT_RX_CTL_EN; - - ret = smsc75xx_write_reg(dev, FCT_RX_CTL, buf); - check_warn_return(ret, "Failed to write FCT_RX_CTL: %d", ret); - - netif_dbg(dev, ifup, dev->net, "FCT_RX_CTL set to 0x%08x", buf); - - netif_dbg(dev, ifup, dev->net, "smsc75xx_reset, return 0"); - return 0; -} - -static const struct net_device_ops smsc75xx_netdev_ops = { - .ndo_open = usbnet_open, - .ndo_stop = usbnet_stop, - .ndo_start_xmit = usbnet_start_xmit, - .ndo_tx_timeout = usbnet_tx_timeout, - .ndo_change_mtu = smsc75xx_change_mtu, - .ndo_set_mac_address = eth_mac_addr, - .ndo_validate_addr = eth_validate_addr, - .ndo_do_ioctl = smsc75xx_ioctl, - .ndo_set_multicast_list = smsc75xx_set_multicast, -}; - -static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf) -{ - struct smsc75xx_priv *pdata = NULL; - int ret; - - printk(KERN_INFO SMSC_CHIPNAME " v" SMSC_DRIVER_VERSION "\n"); - - ret = usbnet_get_endpoints(dev, intf); - check_warn_return(ret, "usbnet_get_endpoints failed: %d", ret); - - dev->data[0] = (unsigned long)kzalloc(sizeof(struct smsc75xx_priv), - GFP_KERNEL); - - pdata = (struct smsc75xx_priv *)(dev->data[0]); - if (!pdata) { - netdev_warn(dev->net, "Unable to allocate smsc75xx_priv"); - return -ENOMEM; - } - - pdata->dev = dev; - - spin_lock_init(&pdata->rfe_ctl_lock); - mutex_init(&pdata->dataport_mutex); - - INIT_WORK(&pdata->set_multicast, smsc75xx_deferred_multicast_write); - - pdata->use_rx_csum = DEFAULT_RX_CSUM_ENABLE; - - /* We have to advertise SG otherwise TSO cannot be enabled */ - dev->net->features |= NETIF_F_SG; - - /* Init all registers */ - ret = smsc75xx_reset(dev); - - dev->net->netdev_ops = &smsc75xx_netdev_ops; - dev->net->ethtool_ops = &smsc75xx_ethtool_ops; - dev->net->flags |= IFF_MULTICAST; - dev->net->hard_header_len += SMSC75XX_TX_OVERHEAD; - return 0; -} - -static void smsc75xx_unbind(struct usbnet *dev, struct usb_interface *intf) -{ - struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); - if (pdata) { - netif_dbg(dev, ifdown, dev->net, "free pdata"); - kfree(pdata); - pdata = NULL; - dev->data[0] = 0; - } -} - -static void smsc75xx_rx_csum_offload(struct sk_buff *skb, u32 rx_cmd_a, - u32 rx_cmd_b) -{ - if (unlikely(rx_cmd_a & RX_CMD_A_LCSM)) { - skb->ip_summed = CHECKSUM_NONE; - } else { - skb->csum = ntohs((u16)(rx_cmd_b >> RX_CMD_B_CSUM_SHIFT)); - skb->ip_summed = CHECKSUM_COMPLETE; - } -} - -static int smsc75xx_rx_fixup(struct usbnet *dev, struct sk_buff *skb) -{ - struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); - - while (skb->len > 0) { - u32 rx_cmd_a, rx_cmd_b, align_count, size; - struct sk_buff *ax_skb; - unsigned char *packet; - - memcpy(&rx_cmd_a, skb->data, sizeof(rx_cmd_a)); - le32_to_cpus(&rx_cmd_a); - skb_pull(skb, 4); - - memcpy(&rx_cmd_b, skb->data, sizeof(rx_cmd_b)); - le32_to_cpus(&rx_cmd_b); - skb_pull(skb, 4 + NET_IP_ALIGN); - - packet = skb->data; - - /* get the packet length */ - size = (rx_cmd_a & RX_CMD_A_LEN) - NET_IP_ALIGN; - align_count = (4 - ((size + NET_IP_ALIGN) % 4)) % 4; - - if (unlikely(rx_cmd_a & RX_CMD_A_RED)) { - netif_dbg(dev, rx_err, dev->net, - "Error rx_cmd_a=0x%08x", rx_cmd_a); - dev->net->stats.rx_errors++; - dev->net->stats.rx_dropped++; - - if (rx_cmd_a & RX_CMD_A_FCS) - dev->net->stats.rx_crc_errors++; - else if (rx_cmd_a & (RX_CMD_A_LONG | RX_CMD_A_RUNT)) - dev->net->stats.rx_frame_errors++; - } else { - /* ETH_FRAME_LEN + 4(CRC) + 2(COE) + 4(Vlan) */ - if (unlikely(size > (ETH_FRAME_LEN + 12))) { - netif_dbg(dev, rx_err, dev->net, - "size err rx_cmd_a=0x%08x", rx_cmd_a); - return 0; - } - - /* last frame in this batch */ - if (skb->len == size) { - if (pdata->use_rx_csum) - smsc75xx_rx_csum_offload(skb, rx_cmd_a, - rx_cmd_b); - else - skb->ip_summed = CHECKSUM_NONE; - - skb_trim(skb, skb->len - 4); /* remove fcs */ - skb->truesize = size + sizeof(struct sk_buff); - - return 1; - } - - ax_skb = skb_clone(skb, GFP_ATOMIC); - if (unlikely(!ax_skb)) { - netdev_warn(dev->net, "Error allocating skb"); - return 0; - } - - ax_skb->len = size; - ax_skb->data = packet; - skb_set_tail_pointer(ax_skb, size); - - if (pdata->use_rx_csum) - smsc75xx_rx_csum_offload(ax_skb, rx_cmd_a, - rx_cmd_b); - else - ax_skb->ip_summed = CHECKSUM_NONE; - - skb_trim(ax_skb, ax_skb->len - 4); /* remove fcs */ - ax_skb->truesize = size + sizeof(struct sk_buff); - - usbnet_skb_return(dev, ax_skb); - } - - skb_pull(skb, size); - - /* padding bytes before the next frame starts */ - if (skb->len) - skb_pull(skb, align_count); - } - - if (unlikely(skb->len < 0)) { - netdev_warn(dev->net, "invalid rx length<0 %d", skb->len); - return 0; - } - - return 1; -} - -static struct sk_buff *smsc75xx_tx_fixup(struct usbnet *dev, - struct sk_buff *skb, gfp_t flags) -{ - u32 tx_cmd_a, tx_cmd_b; - - skb_linearize(skb); - - if (skb_headroom(skb) < SMSC75XX_TX_OVERHEAD) { - struct sk_buff *skb2 = - skb_copy_expand(skb, SMSC75XX_TX_OVERHEAD, 0, flags); - dev_kfree_skb_any(skb); - skb = skb2; - if (!skb) - return NULL; - } - - tx_cmd_a = (u32)(skb->len & TX_CMD_A_LEN) | TX_CMD_A_FCS; - - if (skb->ip_summed == CHECKSUM_PARTIAL) - tx_cmd_a |= TX_CMD_A_IPE | TX_CMD_A_TPE; - - if (skb_is_gso(skb)) { - u16 mss = max(skb_shinfo(skb)->gso_size, TX_MSS_MIN); - tx_cmd_b = (mss << TX_CMD_B_MSS_SHIFT) & TX_CMD_B_MSS; - - tx_cmd_a |= TX_CMD_A_LSO; - } else { - tx_cmd_b = 0; - } - - skb_push(skb, 4); - cpu_to_le32s(&tx_cmd_b); - memcpy(skb->data, &tx_cmd_b, 4); - - skb_push(skb, 4); - cpu_to_le32s(&tx_cmd_a); - memcpy(skb->data, &tx_cmd_a, 4); - - return skb; -} - -static const struct driver_info smsc75xx_info = { - .description = "smsc75xx USB 2.0 Gigabit Ethernet", - .bind = smsc75xx_bind, - .unbind = smsc75xx_unbind, - .link_reset = smsc75xx_link_reset, - .reset = smsc75xx_reset, - .rx_fixup = smsc75xx_rx_fixup, - .tx_fixup = smsc75xx_tx_fixup, - .status = smsc75xx_status, - .flags = FLAG_ETHER | FLAG_SEND_ZLP, -}; - -static const struct usb_device_id products[] = { - { - /* SMSC7500 USB Gigabit Ethernet Device */ - USB_DEVICE(USB_VENDOR_ID_SMSC, USB_PRODUCT_ID_LAN7500), - .driver_info = (unsigned long) &smsc75xx_info, - }, - { - /* SMSC7500 USB Gigabit Ethernet Device */ - USB_DEVICE(USB_VENDOR_ID_SMSC, USB_PRODUCT_ID_LAN7505), - .driver_info = (unsigned long) &smsc75xx_info, - }, - { }, /* END */ -}; -MODULE_DEVICE_TABLE(usb, products); - -static struct usb_driver smsc75xx_driver = { - .name = SMSC_CHIPNAME, - .id_table = products, - .probe = usbnet_probe, - .suspend = usbnet_suspend, - .resume = usbnet_resume, - .disconnect = usbnet_disconnect, -}; - -static int __init smsc75xx_init(void) -{ - return usb_register(&smsc75xx_driver); -} -module_init(smsc75xx_init); - -static void __exit smsc75xx_exit(void) -{ - usb_deregister(&smsc75xx_driver); -} -module_exit(smsc75xx_exit); - -MODULE_AUTHOR("Nancy Lin"); -MODULE_AUTHOR("Steve Glendinning "); -MODULE_DESCRIPTION("SMSC75XX USB 2.0 Gigabit Ethernet Devices"); -MODULE_LICENSE("GPL"); diff --git a/trunk/drivers/net/usb/smsc75xx.h b/trunk/drivers/net/usb/smsc75xx.h deleted file mode 100644 index 16e98c778344..000000000000 --- a/trunk/drivers/net/usb/smsc75xx.h +++ /dev/null @@ -1,421 +0,0 @@ - /*************************************************************************** - * - * Copyright (C) 2007-2010 SMSC - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - *****************************************************************************/ - -#ifndef _SMSC75XX_H -#define _SMSC75XX_H - -/* Tx command words */ -#define TX_CMD_A_LSO (0x08000000) -#define TX_CMD_A_IPE (0x04000000) -#define TX_CMD_A_TPE (0x02000000) -#define TX_CMD_A_IVTG (0x01000000) -#define TX_CMD_A_RVTG (0x00800000) -#define TX_CMD_A_FCS (0x00400000) -#define TX_CMD_A_LEN (0x000FFFFF) - -#define TX_CMD_B_MSS (0x3FFF0000) -#define TX_CMD_B_MSS_SHIFT (16) -#define TX_MSS_MIN ((u16)8) -#define TX_CMD_B_VTAG (0x0000FFFF) - -/* Rx command words */ -#define RX_CMD_A_ICE (0x80000000) -#define RX_CMD_A_TCE (0x40000000) -#define RX_CMD_A_IPV (0x20000000) -#define RX_CMD_A_PID (0x18000000) -#define RX_CMD_A_PID_NIP (0x00000000) -#define RX_CMD_A_PID_TCP (0x08000000) -#define RX_CMD_A_PID_UDP (0x10000000) -#define RX_CMD_A_PID_PP (0x18000000) -#define RX_CMD_A_PFF (0x04000000) -#define RX_CMD_A_BAM (0x02000000) -#define RX_CMD_A_MAM (0x01000000) -#define RX_CMD_A_FVTG (0x00800000) -#define RX_CMD_A_RED (0x00400000) -#define RX_CMD_A_RWT (0x00200000) -#define RX_CMD_A_RUNT (0x00100000) -#define RX_CMD_A_LONG (0x00080000) -#define RX_CMD_A_RXE (0x00040000) -#define RX_CMD_A_DRB (0x00020000) -#define RX_CMD_A_FCS (0x00010000) -#define RX_CMD_A_UAM (0x00008000) -#define RX_CMD_A_LCSM (0x00004000) -#define RX_CMD_A_LEN (0x00003FFF) - -#define RX_CMD_B_CSUM (0xFFFF0000) -#define RX_CMD_B_CSUM_SHIFT (16) -#define RX_CMD_B_VTAG (0x0000FFFF) - -/* SCSRs */ -#define ID_REV (0x0000) - -#define FPGA_REV (0x0004) - -#define BOND_CTL (0x0008) - -#define INT_STS (0x000C) -#define INT_STS_RDFO_INT (0x00400000) -#define INT_STS_TXE_INT (0x00200000) -#define INT_STS_MACRTO_INT (0x00100000) -#define INT_STS_TX_DIS_INT (0x00080000) -#define INT_STS_RX_DIS_INT (0x00040000) -#define INT_STS_PHY_INT_ (0x00020000) -#define INT_STS_MAC_ERR_INT (0x00008000) -#define INT_STS_TDFU (0x00004000) -#define INT_STS_TDFO (0x00002000) -#define INT_STS_GPIOS (0x00000FFF) -#define INT_STS_CLEAR_ALL (0xFFFFFFFF) - -#define HW_CFG (0x0010) -#define HW_CFG_SMDET_STS (0x00008000) -#define HW_CFG_SMDET_EN (0x00004000) -#define HW_CFG_EEM (0x00002000) -#define HW_CFG_RST_PROTECT (0x00001000) -#define HW_CFG_PORT_SWAP (0x00000800) -#define HW_CFG_PHY_BOOST (0x00000600) -#define HW_CFG_PHY_BOOST_NORMAL (0x00000000) -#define HW_CFG_PHY_BOOST_4 (0x00002000) -#define HW_CFG_PHY_BOOST_8 (0x00004000) -#define HW_CFG_PHY_BOOST_12 (0x00006000) -#define HW_CFG_LEDB (0x00000100) -#define HW_CFG_BIR (0x00000080) -#define HW_CFG_SBP (0x00000040) -#define HW_CFG_IME (0x00000020) -#define HW_CFG_MEF (0x00000010) -#define HW_CFG_ETC (0x00000008) -#define HW_CFG_BCE (0x00000004) -#define HW_CFG_LRST (0x00000002) -#define HW_CFG_SRST (0x00000001) - -#define PMT_CTL (0x0014) -#define PMT_CTL_PHY_PWRUP (0x00000400) -#define PMT_CTL_RES_CLR_WKP_EN (0x00000100) -#define PMT_CTL_DEV_RDY (0x00000080) -#define PMT_CTL_SUS_MODE (0x00000060) -#define PMT_CTL_SUS_MODE_0 (0x00000000) -#define PMT_CTL_SUS_MODE_1 (0x00000020) -#define PMT_CTL_SUS_MODE_2 (0x00000040) -#define PMT_CTL_SUS_MODE_3 (0x00000060) -#define PMT_CTL_PHY_RST (0x00000010) -#define PMT_CTL_WOL_EN (0x00000008) -#define PMT_CTL_ED_EN (0x00000004) -#define PMT_CTL_WUPS (0x00000003) -#define PMT_CTL_WUPS_NO (0x00000000) -#define PMT_CTL_WUPS_ED (0x00000001) -#define PMT_CTL_WUPS_WOL (0x00000002) -#define PMT_CTL_WUPS_MULTI (0x00000003) - -#define LED_GPIO_CFG (0x0018) -#define LED_GPIO_CFG_LED2_FUN_SEL (0x80000000) -#define LED_GPIO_CFG_LED10_FUN_SEL (0x40000000) -#define LED_GPIO_CFG_LEDGPIO_EN (0x0000F000) -#define LED_GPIO_CFG_LEDGPIO_EN_0 (0x00001000) -#define LED_GPIO_CFG_LEDGPIO_EN_1 (0x00002000) -#define LED_GPIO_CFG_LEDGPIO_EN_2 (0x00004000) -#define LED_GPIO_CFG_LEDGPIO_EN_3 (0x00008000) -#define LED_GPIO_CFG_GPBUF (0x00000F00) -#define LED_GPIO_CFG_GPBUF_0 (0x00000100) -#define LED_GPIO_CFG_GPBUF_1 (0x00000200) -#define LED_GPIO_CFG_GPBUF_2 (0x00000400) -#define LED_GPIO_CFG_GPBUF_3 (0x00000800) -#define LED_GPIO_CFG_GPDIR (0x000000F0) -#define LED_GPIO_CFG_GPDIR_0 (0x00000010) -#define LED_GPIO_CFG_GPDIR_1 (0x00000020) -#define LED_GPIO_CFG_GPDIR_2 (0x00000040) -#define LED_GPIO_CFG_GPDIR_3 (0x00000080) -#define LED_GPIO_CFG_GPDATA (0x0000000F) -#define LED_GPIO_CFG_GPDATA_0 (0x00000001) -#define LED_GPIO_CFG_GPDATA_1 (0x00000002) -#define LED_GPIO_CFG_GPDATA_2 (0x00000004) -#define LED_GPIO_CFG_GPDATA_3 (0x00000008) - -#define GPIO_CFG (0x001C) -#define GPIO_CFG_SHIFT (24) -#define GPIO_CFG_GPEN (0xFF000000) -#define GPIO_CFG_GPBUF (0x00FF0000) -#define GPIO_CFG_GPDIR (0x0000FF00) -#define GPIO_CFG_GPDATA (0x000000FF) - -#define GPIO_WAKE (0x0020) -#define GPIO_WAKE_PHY_LINKUP_EN (0x80000000) -#define GPIO_WAKE_POL (0x0FFF0000) -#define GPIO_WAKE_POL_SHIFT (16) -#define GPIO_WAKE_WK (0x00000FFF) - -#define DP_SEL (0x0024) -#define DP_SEL_DPRDY (0x80000000) -#define DP_SEL_RSEL (0x0000000F) -#define DP_SEL_URX (0x00000000) -#define DP_SEL_VHF (0x00000001) -#define DP_SEL_VHF_HASH_LEN (16) -#define DP_SEL_VHF_VLAN_LEN (128) -#define DP_SEL_LSO_HEAD (0x00000002) -#define DP_SEL_FCT_RX (0x00000003) -#define DP_SEL_FCT_TX (0x00000004) -#define DP_SEL_DESCRIPTOR (0x00000005) -#define DP_SEL_WOL (0x00000006) - -#define DP_CMD (0x0028) -#define DP_CMD_WRITE (0x01) -#define DP_CMD_READ (0x00) - -#define DP_ADDR (0x002C) - -#define DP_DATA (0x0030) - -#define BURST_CAP (0x0034) -#define BURST_CAP_MASK (0x0000000F) - -#define INT_EP_CTL (0x0038) -#define INT_EP_CTL_INTEP_ON (0x80000000) -#define INT_EP_CTL_RDFO_EN (0x00400000) -#define INT_EP_CTL_TXE_EN (0x00200000) -#define INT_EP_CTL_MACROTO_EN (0x00100000) -#define INT_EP_CTL_TX_DIS_EN (0x00080000) -#define INT_EP_CTL_RX_DIS_EN (0x00040000) -#define INT_EP_CTL_PHY_EN_ (0x00020000) -#define INT_EP_CTL_MAC_ERR_EN (0x00008000) -#define INT_EP_CTL_TDFU_EN (0x00004000) -#define INT_EP_CTL_TDFO_EN (0x00002000) -#define INT_EP_CTL_RX_FIFO_EN (0x00001000) -#define INT_EP_CTL_GPIOX_EN (0x00000FFF) - -#define BULK_IN_DLY (0x003C) -#define BULK_IN_DLY_MASK (0xFFFF) - -#define E2P_CMD (0x0040) -#define E2P_CMD_BUSY (0x80000000) -#define E2P_CMD_MASK (0x70000000) -#define E2P_CMD_READ (0x00000000) -#define E2P_CMD_EWDS (0x10000000) -#define E2P_CMD_EWEN (0x20000000) -#define E2P_CMD_WRITE (0x30000000) -#define E2P_CMD_WRAL (0x40000000) -#define E2P_CMD_ERASE (0x50000000) -#define E2P_CMD_ERAL (0x60000000) -#define E2P_CMD_RELOAD (0x70000000) -#define E2P_CMD_TIMEOUT (0x00000400) -#define E2P_CMD_LOADED (0x00000200) -#define E2P_CMD_ADDR (0x000001FF) - -#define MAX_EEPROM_SIZE (512) - -#define E2P_DATA (0x0044) -#define E2P_DATA_MASK_ (0x000000FF) - -#define RFE_CTL (0x0060) -#define RFE_CTL_TCPUDP_CKM (0x00001000) -#define RFE_CTL_IP_CKM (0x00000800) -#define RFE_CTL_AB (0x00000400) -#define RFE_CTL_AM (0x00000200) -#define RFE_CTL_AU (0x00000100) -#define RFE_CTL_VS (0x00000080) -#define RFE_CTL_UF (0x00000040) -#define RFE_CTL_VF (0x00000020) -#define RFE_CTL_SPF (0x00000010) -#define RFE_CTL_MHF (0x00000008) -#define RFE_CTL_DHF (0x00000004) -#define RFE_CTL_DPF (0x00000002) -#define RFE_CTL_RST_RF (0x00000001) - -#define VLAN_TYPE (0x0064) -#define VLAN_TYPE_MASK (0x0000FFFF) - -#define FCT_RX_CTL (0x0090) -#define FCT_RX_CTL_EN (0x80000000) -#define FCT_RX_CTL_RST (0x40000000) -#define FCT_RX_CTL_SBF (0x02000000) -#define FCT_RX_CTL_OVERFLOW (0x01000000) -#define FCT_RX_CTL_FRM_DROP (0x00800000) -#define FCT_RX_CTL_RX_NOT_EMPTY (0x00400000) -#define FCT_RX_CTL_RX_EMPTY (0x00200000) -#define FCT_RX_CTL_RX_DISABLED (0x00100000) -#define FCT_RX_CTL_RXUSED (0x0000FFFF) - -#define FCT_TX_CTL (0x0094) -#define FCT_TX_CTL_EN (0x80000000) -#define FCT_TX_CTL_RST (0x40000000) -#define FCT_TX_CTL_TX_NOT_EMPTY (0x00400000) -#define FCT_TX_CTL_TX_EMPTY (0x00200000) -#define FCT_TX_CTL_TX_DISABLED (0x00100000) -#define FCT_TX_CTL_TXUSED (0x0000FFFF) - -#define FCT_RX_FIFO_END (0x0098) -#define FCT_RX_FIFO_END_MASK (0x0000007F) - -#define FCT_TX_FIFO_END (0x009C) -#define FCT_TX_FIFO_END_MASK (0x0000003F) - -#define FCT_FLOW (0x00A0) -#define FCT_FLOW_THRESHOLD_OFF (0x00007F00) -#define FCT_FLOW_THRESHOLD_OFF_SHIFT (8) -#define FCT_FLOW_THRESHOLD_ON (0x0000007F) - -/* MAC CSRs */ -#define MAC_CR (0x100) -#define MAC_CR_ADP (0x00002000) -#define MAC_CR_ADD (0x00001000) -#define MAC_CR_ASD (0x00000800) -#define MAC_CR_INT_LOOP (0x00000400) -#define MAC_CR_BOLMT (0x000000C0) -#define MAC_CR_FDPX (0x00000008) -#define MAC_CR_CFG (0x00000006) -#define MAC_CR_CFG_10 (0x00000000) -#define MAC_CR_CFG_100 (0x00000002) -#define MAC_CR_CFG_1000 (0x00000004) -#define MAC_CR_RST (0x00000001) - -#define MAC_RX (0x104) -#define MAC_RX_MAX_SIZE (0x3FFF0000) -#define MAC_RX_MAX_SIZE_SHIFT (16) -#define MAC_RX_FCS_STRIP (0x00000010) -#define MAC_RX_FSE (0x00000004) -#define MAC_RX_RXD (0x00000002) -#define MAC_RX_RXEN (0x00000001) - -#define MAC_TX (0x108) -#define MAC_TX_BFCS (0x00000004) -#define MAC_TX_TXD (0x00000002) -#define MAC_TX_TXEN (0x00000001) - -#define FLOW (0x10C) -#define FLOW_FORCE_FC (0x80000000) -#define FLOW_TX_FCEN (0x40000000) -#define FLOW_RX_FCEN (0x20000000) -#define FLOW_FPF (0x10000000) -#define FLOW_PAUSE_TIME (0x0000FFFF) - -#define RAND_SEED (0x110) -#define RAND_SEED_MASK (0x0000FFFF) - -#define ERR_STS (0x114) -#define ERR_STS_FCS_ERR (0x00000100) -#define ERR_STS_LFRM_ERR (0x00000080) -#define ERR_STS_RUNT_ERR (0x00000040) -#define ERR_STS_COLLISION_ERR (0x00000010) -#define ERR_STS_ALIGN_ERR (0x00000008) -#define ERR_STS_URUN_ERR (0x00000004) - -#define RX_ADDRH (0x118) -#define RX_ADDRH_MASK (0x0000FFFF) - -#define RX_ADDRL (0x11C) - -#define MII_ACCESS (0x120) -#define MII_ACCESS_PHY_ADDR (0x0000F800) -#define MII_ACCESS_PHY_ADDR_SHIFT (11) -#define MII_ACCESS_REG_ADDR (0x000007C0) -#define MII_ACCESS_REG_ADDR_SHIFT (6) -#define MII_ACCESS_READ (0x00000000) -#define MII_ACCESS_WRITE (0x00000002) -#define MII_ACCESS_BUSY (0x00000001) - -#define MII_DATA (0x124) -#define MII_DATA_MASK (0x0000FFFF) - -#define WUCSR (0x140) -#define WUCSR_PFDA_FR (0x00000080) -#define WUCSR_WUFR (0x00000040) -#define WUCSR_MPR (0x00000020) -#define WUCSR_BCAST_FR (0x00000010) -#define WUCSR_PFDA_EN (0x00000008) -#define WUCSR_WUEN (0x00000004) -#define WUCSR_MPEN (0x00000002) -#define WUCSR_BCST_EN (0x00000001) - -#define WUF_CFGX (0x144) -#define WUF_CFGX_EN (0x80000000) -#define WUF_CFGX_ATYPE (0x03000000) -#define WUF_CFGX_ATYPE_UNICAST (0x00000000) -#define WUF_CFGX_ATYPE_MULTICAST (0x02000000) -#define WUF_CFGX_ATYPE_ALL (0x03000000) -#define WUF_CFGX_PATTERN_OFFSET (0x007F0000) -#define WUF_CFGX_PATTERN_OFFSET_SHIFT (16) -#define WUF_CFGX_CRC16 (0x0000FFFF) -#define WUF_NUM (8) - -#define WUF_MASKX (0x170) -#define WUF_MASKX_AVALID (0x80000000) -#define WUF_MASKX_ATYPE (0x40000000) - -#define ADDR_FILTX (0x300) -#define ADDR_FILTX_FB_VALID (0x80000000) -#define ADDR_FILTX_FB_TYPE (0x40000000) -#define ADDR_FILTX_FB_ADDRHI (0x0000FFFF) -#define ADDR_FILTX_SB_ADDRLO (0xFFFFFFFF) - -#define WUCSR2 (0x500) -#define WUCSR2_NS_RCD (0x00000040) -#define WUCSR2_ARP_RCD (0x00000020) -#define WUCSR2_TCPSYN_RCD (0x00000010) -#define WUCSR2_NS_OFFLOAD (0x00000004) -#define WUCSR2_ARP_OFFLOAD (0x00000002) -#define WUCSR2_TCPSYN_OFFLOAD (0x00000001) - -#define WOL_FIFO_STS (0x504) - -#define IPV6_ADDRX (0x510) - -#define IPV4_ADDRX (0x590) - - -/* Vendor-specific PHY Definitions */ - -/* Mode Control/Status Register */ -#define PHY_MODE_CTRL_STS (17) -#define MODE_CTRL_STS_EDPWRDOWN ((u16)0x2000) -#define MODE_CTRL_STS_ENERGYON ((u16)0x0002) - -#define PHY_INT_SRC (29) -#define PHY_INT_SRC_ENERGY_ON ((u16)0x0080) -#define PHY_INT_SRC_ANEG_COMP ((u16)0x0040) -#define PHY_INT_SRC_REMOTE_FAULT ((u16)0x0020) -#define PHY_INT_SRC_LINK_DOWN ((u16)0x0010) - -#define PHY_INT_MASK (30) -#define PHY_INT_MASK_ENERGY_ON ((u16)0x0080) -#define PHY_INT_MASK_ANEG_COMP ((u16)0x0040) -#define PHY_INT_MASK_REMOTE_FAULT ((u16)0x0020) -#define PHY_INT_MASK_LINK_DOWN ((u16)0x0010) -#define PHY_INT_MASK_DEFAULT (PHY_INT_MASK_ANEG_COMP | \ - PHY_INT_MASK_LINK_DOWN) - -#define PHY_SPECIAL (31) -#define PHY_SPECIAL_SPD ((u16)0x001C) -#define PHY_SPECIAL_SPD_10HALF ((u16)0x0004) -#define PHY_SPECIAL_SPD_10FULL ((u16)0x0014) -#define PHY_SPECIAL_SPD_100HALF ((u16)0x0008) -#define PHY_SPECIAL_SPD_100FULL ((u16)0x0018) - -/* USB Vendor Requests */ -#define USB_VENDOR_REQUEST_WRITE_REGISTER 0xA0 -#define USB_VENDOR_REQUEST_READ_REGISTER 0xA1 -#define USB_VENDOR_REQUEST_GET_STATS 0xA2 - -/* Interrupt Endpoint status word bitfields */ -#define INT_ENP_RDFO_INT ((u32)BIT(22)) -#define INT_ENP_TXE_INT ((u32)BIT(21)) -#define INT_ENP_TX_DIS_INT ((u32)BIT(19)) -#define INT_ENP_RX_DIS_INT ((u32)BIT(18)) -#define INT_ENP_PHY_INT ((u32)BIT(17)) -#define INT_ENP_MAC_ERR_INT ((u32)BIT(15)) -#define INT_ENP_RX_FIFO_DATA_INT ((u32)BIT(12)) - -#endif /* _SMSC75XX_H */ diff --git a/trunk/drivers/net/usb/smsc95xx.c b/trunk/drivers/net/usb/smsc95xx.c index d222d7e25273..df9179a1c93b 100644 --- a/trunk/drivers/net/usb/smsc95xx.c +++ b/trunk/drivers/net/usb/smsc95xx.c @@ -709,8 +709,6 @@ static void smsc95xx_start_rx_path(struct usbnet *dev) static int smsc95xx_phy_initialize(struct usbnet *dev) { - int bmcr, timeout = 0; - /* Initialize MII structure */ dev->mii.dev = dev->net; dev->mii.mdio_read = smsc95xx_mdio_read; @@ -719,20 +717,7 @@ static int smsc95xx_phy_initialize(struct usbnet *dev) dev->mii.reg_num_mask = 0x1f; dev->mii.phy_id = SMSC95XX_INTERNAL_PHY_ID; - /* reset phy and wait for reset to complete */ smsc95xx_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET); - - do { - msleep(10); - bmcr = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, MII_BMCR); - timeout++; - } while ((bmcr & MII_BMCR) && (timeout < 100)); - - if (timeout >= 100) { - netdev_warn(dev->net, "timeout on PHY Reset"); - return -EIO; - } - smsc95xx_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM); diff --git a/trunk/drivers/pci/Makefile b/trunk/drivers/pci/Makefile index 0b51857fbaf7..3d102dd87c9f 100644 --- a/trunk/drivers/pci/Makefile +++ b/trunk/drivers/pci/Makefile @@ -48,7 +48,6 @@ obj-$(CONFIG_PPC) += setup-bus.o obj-$(CONFIG_MIPS) += setup-bus.o setup-irq.o obj-$(CONFIG_X86_VISWS) += setup-irq.o obj-$(CONFIG_MN10300) += setup-bus.o -obj-$(CONFIG_MICROBLAZE) += setup-bus.o # # ACPI Related PCI FW Functions diff --git a/trunk/drivers/pcmcia/i82092.c b/trunk/drivers/pcmcia/i82092.c index f5da62653313..a04f21c8170f 100644 --- a/trunk/drivers/pcmcia/i82092.c +++ b/trunk/drivers/pcmcia/i82092.c @@ -133,7 +133,6 @@ static int __devinit i82092aa_pci_probe(struct pci_dev *dev, const struct pci_de sockets[i].socket.map_size = 0x1000; sockets[i].socket.irq_mask = 0; sockets[i].socket.pci_irq = dev->irq; - sockets[i].socket.cb_dev = dev; sockets[i].socket.owner = THIS_MODULE; sockets[i].number = i; diff --git a/trunk/drivers/pcmcia/i82365.h b/trunk/drivers/pcmcia/i82365.h index 3f84d7a2dc84..849ef1b5d687 100644 --- a/trunk/drivers/pcmcia/i82365.h +++ b/trunk/drivers/pcmcia/i82365.h @@ -95,7 +95,6 @@ #define I365_CSC_DETECT 0x08 #define I365_CSC_ANY 0x0F #define I365_CSC_GPI 0x10 -#define I365_CSC_IRQ_MASK 0xF0 /* Flags for I365_ADDRWIN */ #define I365_ENA_IO(map) (0x40 << (map)) diff --git a/trunk/drivers/pcmcia/pcmcia_resource.c b/trunk/drivers/pcmcia/pcmcia_resource.c index c4612c52e4cb..b2df04199a21 100644 --- a/trunk/drivers/pcmcia/pcmcia_resource.c +++ b/trunk/drivers/pcmcia/pcmcia_resource.c @@ -256,7 +256,6 @@ int pcmcia_modify_configuration(struct pcmcia_device *p_dev, { struct pcmcia_socket *s; config_t *c; - int ret; s = p_dev->socket; @@ -265,13 +264,13 @@ int pcmcia_modify_configuration(struct pcmcia_device *p_dev, if (!(s->state & SOCKET_PRESENT)) { dev_dbg(&s->dev, "No card present\n"); - ret = -ENODEV; - goto unlock; + mutex_unlock(&s->ops_mutex); + return -ENODEV; } if (!(c->state & CONFIG_LOCKED)) { dev_dbg(&s->dev, "Configuration isnt't locked\n"); - ret = -EACCES; - goto unlock; + mutex_unlock(&s->ops_mutex); + return -EACCES; } if (mod->Attributes & CONF_IRQ_CHANGE_VALID) { @@ -287,8 +286,7 @@ int pcmcia_modify_configuration(struct pcmcia_device *p_dev, if (mod->Attributes & CONF_VCC_CHANGE_VALID) { dev_dbg(&s->dev, "changing Vcc is not allowed at this time\n"); - ret = -EINVAL; - goto unlock; + return -EINVAL; } /* We only allow changing Vpp1 and Vpp2 to the same value */ @@ -296,21 +294,21 @@ int pcmcia_modify_configuration(struct pcmcia_device *p_dev, (mod->Attributes & CONF_VPP2_CHANGE_VALID)) { if (mod->Vpp1 != mod->Vpp2) { dev_dbg(&s->dev, "Vpp1 and Vpp2 must be the same\n"); - ret = -EINVAL; - goto unlock; + mutex_unlock(&s->ops_mutex); + return -EINVAL; } s->socket.Vpp = mod->Vpp1; if (s->ops->set_socket(s, &s->socket)) { + mutex_unlock(&s->ops_mutex); dev_printk(KERN_WARNING, &s->dev, "Unable to set VPP\n"); - ret = -EIO; - goto unlock; + return -EIO; } } else if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) || (mod->Attributes & CONF_VPP2_CHANGE_VALID)) { dev_dbg(&s->dev, "changing Vcc is not allowed at this time\n"); - ret = -EINVAL; - goto unlock; + mutex_unlock(&s->ops_mutex); + return -EINVAL; } if (mod->Attributes & CONF_IO_CHANGE_WIDTH) { @@ -334,11 +332,9 @@ int pcmcia_modify_configuration(struct pcmcia_device *p_dev, s->ops->set_io_map(s, &io_on); } } - ret = 0; -unlock: mutex_unlock(&s->ops_mutex); - return ret; + return 0; } /* modify_configuration */ EXPORT_SYMBOL(pcmcia_modify_configuration); @@ -756,6 +752,14 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req) #ifdef CONFIG_PCMCIA_PROBE +#ifdef IRQ_NOAUTOEN + /* if the underlying IRQ infrastructure allows for it, only allocate + * the IRQ, but do not enable it + */ + if (!(req->Handler)) + type |= IRQ_NOAUTOEN; +#endif /* IRQ_NOAUTOEN */ + if (s->irq.AssignedIRQ != 0) { /* If the interrupt is already assigned, it must be the same */ irq = s->irq.AssignedIRQ; diff --git a/trunk/drivers/pcmcia/pd6729.c b/trunk/drivers/pcmcia/pd6729.c index 7ba57a565cd7..7c204910a777 100644 --- a/trunk/drivers/pcmcia/pd6729.c +++ b/trunk/drivers/pcmcia/pd6729.c @@ -671,7 +671,6 @@ static int __devinit pd6729_pci_probe(struct pci_dev *dev, socket[i].socket.map_size = 0x1000; socket[i].socket.irq_mask = mask; socket[i].socket.pci_irq = dev->irq; - socket[i].socket.cb_dev = dev; socket[i].socket.owner = THIS_MODULE; socket[i].number = i; diff --git a/trunk/drivers/pcmcia/ti113x.h b/trunk/drivers/pcmcia/ti113x.h index 9ffa97d0b16c..aaa70227bfb0 100644 --- a/trunk/drivers/pcmcia/ti113x.h +++ b/trunk/drivers/pcmcia/ti113x.h @@ -296,7 +296,7 @@ static int ti_init(struct yenta_socket *socket) u8 new, reg = exca_readb(socket, I365_INTCTL); new = reg & ~I365_INTR_ENA; - if (socket->dev->irq) + if (socket->cb_irq) new |= I365_INTR_ENA; if (new != reg) exca_writeb(socket, I365_INTCTL, new); @@ -316,47 +316,14 @@ static int ti_override(struct yenta_socket *socket) return 0; } -static void ti113x_use_isa_irq(struct yenta_socket *socket) -{ - int isa_irq = -1; - u8 intctl; - u32 isa_irq_mask = 0; - - if (!isa_probe) - return; - - /* get a free isa int */ - isa_irq_mask = yenta_probe_irq(socket, isa_interrupts); - if (!isa_irq_mask) - return; /* no useable isa irq found */ - - /* choose highest available */ - for (; isa_irq_mask; isa_irq++) - isa_irq_mask >>= 1; - socket->cb_irq = isa_irq; - - exca_writeb(socket, I365_CSCINT, (isa_irq << 4)); - - intctl = exca_readb(socket, I365_INTCTL); - intctl &= ~(I365_INTR_ENA | I365_IRQ_MASK); /* CSC Enable */ - exca_writeb(socket, I365_INTCTL, intctl); - - dev_info(&socket->dev->dev, - "Yenta TI113x: using isa irq %d for CardBus\n", isa_irq); -} - - static int ti113x_override(struct yenta_socket *socket) { u8 cardctl; cardctl = config_readb(socket, TI113X_CARD_CONTROL); cardctl &= ~(TI113X_CCR_PCI_IRQ_ENA | TI113X_CCR_PCI_IREQ | TI113X_CCR_PCI_CSC); - if (socket->dev->irq) + if (socket->cb_irq) cardctl |= TI113X_CCR_PCI_IRQ_ENA | TI113X_CCR_PCI_CSC | TI113X_CCR_PCI_IREQ; - else - ti113x_use_isa_irq(socket); - config_writeb(socket, TI113X_CARD_CONTROL, cardctl); return ti_override(socket); diff --git a/trunk/drivers/pcmcia/vrc4171_card.c b/trunk/drivers/pcmcia/vrc4171_card.c index aaccdb9f4ba1..c9fcbdc164ea 100644 --- a/trunk/drivers/pcmcia/vrc4171_card.c +++ b/trunk/drivers/pcmcia/vrc4171_card.c @@ -105,7 +105,6 @@ typedef struct vrc4171_socket { char name[24]; int csc_irq; int io_irq; - spinlock_t lock; } vrc4171_socket_t; static vrc4171_socket_t vrc4171_sockets[CARD_MAX_SLOTS]; @@ -328,7 +327,7 @@ static int pccard_set_socket(struct pcmcia_socket *sock, socket_state_t *state) slot = sock->sock; socket = &vrc4171_sockets[slot]; - spin_lock_irq(&socket->lock); + spin_lock_irq(&sock->lock); voltage = set_Vcc_value(state->Vcc); exca_write_byte(slot, CARD_VOLTAGE_SELECT, voltage); @@ -371,7 +370,7 @@ static int pccard_set_socket(struct pcmcia_socket *sock, socket_state_t *state) cscint |= I365_CSC_DETECT; exca_write_byte(slot, I365_CSCINT, cscint); - spin_unlock_irq(&socket->lock); + spin_unlock_irq(&sock->lock); return 0; } diff --git a/trunk/drivers/pcmcia/yenta_socket.c b/trunk/drivers/pcmcia/yenta_socket.c index 418988ab6edf..967c766f53ba 100644 --- a/trunk/drivers/pcmcia/yenta_socket.c +++ b/trunk/drivers/pcmcia/yenta_socket.c @@ -42,18 +42,6 @@ module_param_string(o2_speedup, o2_speedup, sizeof(o2_speedup), 0444); MODULE_PARM_DESC(o2_speedup, "Use prefetch/burst for O2-bridges: 'on', 'off' " "or 'default' (uses recommended behaviour for the detected bridge)"); -/* - * Only probe "regular" interrupts, don't - * touch dangerous spots like the mouse irq, - * because there are mice that apparently - * get really confused if they get fondled - * too intimately. - * - * Default to 11, 10, 9, 7, 6, 5, 4, 3. - */ -static u32 isa_interrupts = 0x0ef8; - - #define debug(x, s, args...) dev_dbg(&s->dev->dev, x, ##args) /* Don't ask.. */ @@ -66,8 +54,6 @@ static u32 isa_interrupts = 0x0ef8; */ #ifdef CONFIG_YENTA_TI static int yenta_probe_cb_irq(struct yenta_socket *socket); -static unsigned int yenta_probe_irq(struct yenta_socket *socket, - u32 isa_irq_mask); #endif @@ -343,8 +329,8 @@ static int yenta_set_socket(struct pcmcia_socket *sock, socket_state_t *state) /* ISA interrupt control? */ intr = exca_readb(socket, I365_INTCTL); intr = (intr & ~0xf); - if (!socket->dev->irq) { - intr |= socket->cb_irq ? socket->cb_irq : state->io_irq; + if (!socket->cb_irq) { + intr |= state->io_irq; bridge |= CB_BRIDGE_INTR; } exca_writeb(socket, I365_INTCTL, intr); @@ -354,7 +340,7 @@ static int yenta_set_socket(struct pcmcia_socket *sock, socket_state_t *state) reg = exca_readb(socket, I365_INTCTL) & (I365_RING_ENA | I365_INTR_ENA); reg |= (state->flags & SS_RESET) ? 0 : I365_PC_RESET; reg |= (state->flags & SS_IOCARD) ? I365_PC_IOCARD : 0; - if (state->io_irq != socket->dev->irq) { + if (state->io_irq != socket->cb_irq) { reg |= state->io_irq; bridge |= CB_BRIDGE_INTR; } @@ -370,9 +356,7 @@ static int yenta_set_socket(struct pcmcia_socket *sock, socket_state_t *state) exca_writeb(socket, I365_POWER, reg); /* CSC interrupt: no ISA irq for CSC */ - reg = exca_readb(socket, I365_CSCINT); - reg &= I365_CSC_IRQ_MASK; - reg |= I365_CSC_DETECT; + reg = I365_CSC_DETECT; if (state->flags & SS_IOCARD) { if (state->csc_mask & SS_STSCHG) reg |= I365_CSC_STSCHG; @@ -912,12 +896,22 @@ static struct cardbus_type cardbus_type[] = { }; +/* + * Only probe "regular" interrupts, don't + * touch dangerous spots like the mouse irq, + * because there are mice that apparently + * get really confused if they get fondled + * too intimately. + * + * Default to 11, 10, 9, 7, 6, 5, 4, 3. + */ +static u32 isa_interrupts = 0x0ef8; + static unsigned int yenta_probe_irq(struct yenta_socket *socket, u32 isa_irq_mask) { int i; unsigned long val; u32 mask; - u8 reg; /* * Probe for usable interrupts using the force @@ -925,7 +919,6 @@ static unsigned int yenta_probe_irq(struct yenta_socket *socket, u32 isa_irq_mas */ cb_writel(socket, CB_SOCKET_EVENT, -1); cb_writel(socket, CB_SOCKET_MASK, CB_CSTSMASK); - reg = exca_readb(socket, I365_CSCINT); exca_writeb(socket, I365_CSCINT, 0); val = probe_irq_on() & isa_irq_mask; for (i = 1; i < 16; i++) { @@ -937,7 +930,7 @@ static unsigned int yenta_probe_irq(struct yenta_socket *socket, u32 isa_irq_mas cb_writel(socket, CB_SOCKET_EVENT, -1); } cb_writel(socket, CB_SOCKET_MASK, 0); - exca_writeb(socket, I365_CSCINT, reg); + exca_writeb(socket, I365_CSCINT, 0); mask = probe_irq_mask(val) & 0xffff; @@ -974,8 +967,6 @@ static irqreturn_t yenta_probe_handler(int irq, void *dev_id) /* probes the PCI interrupt, use only on override functions */ static int yenta_probe_cb_irq(struct yenta_socket *socket) { - u8 reg; - if (!socket->cb_irq) return -1; @@ -988,8 +979,7 @@ static int yenta_probe_cb_irq(struct yenta_socket *socket) } /* generate interrupt, wait */ - reg = exca_readb(socket, I365_CSCINT); - exca_writeb(socket, I365_CSCINT, reg | I365_CSC_STSCHG); + exca_writeb(socket, I365_CSCINT, I365_CSC_STSCHG); cb_writel(socket, CB_SOCKET_EVENT, -1); cb_writel(socket, CB_SOCKET_MASK, CB_CSTSMASK); cb_writel(socket, CB_SOCKET_FORCE, CB_FCARDSTS); @@ -998,7 +988,7 @@ static int yenta_probe_cb_irq(struct yenta_socket *socket) /* disable interrupts */ cb_writel(socket, CB_SOCKET_MASK, 0); - exca_writeb(socket, I365_CSCINT, reg); + exca_writeb(socket, I365_CSCINT, 0); cb_writel(socket, CB_SOCKET_EVENT, -1); exca_readb(socket, I365_CSC); diff --git a/trunk/drivers/platform/x86/acer-wmi.c b/trunk/drivers/platform/x86/acer-wmi.c index cbca40aa4006..226b3e93498c 100644 --- a/trunk/drivers/platform/x86/acer-wmi.c +++ b/trunk/drivers/platform/x86/acer-wmi.c @@ -922,13 +922,9 @@ static struct backlight_ops acer_bl_ops = { static int __devinit acer_backlight_init(struct device *dev) { - struct backlight_properties props; struct backlight_device *bd; - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = max_brightness; - bd = backlight_device_register("acer-wmi", dev, NULL, &acer_bl_ops, - &props); + bd = backlight_device_register("acer-wmi", dev, NULL, &acer_bl_ops); if (IS_ERR(bd)) { printk(ACER_ERR "Could not register Acer backlight device\n"); acer_backlight_device = NULL; @@ -939,6 +935,7 @@ static int __devinit acer_backlight_init(struct device *dev) bd->props.power = FB_BLANK_UNBLANK; bd->props.brightness = read_brightness(bd); + bd->props.max_brightness = max_brightness; backlight_update_status(bd); return 0; } diff --git a/trunk/drivers/platform/x86/asus-laptop.c b/trunk/drivers/platform/x86/asus-laptop.c index db5f7db2ba33..791fcf321506 100644 --- a/trunk/drivers/platform/x86/asus-laptop.c +++ b/trunk/drivers/platform/x86/asus-laptop.c @@ -639,16 +639,12 @@ static int asus_backlight_init(struct asus_laptop *asus) { struct backlight_device *bd; struct device *dev = &asus->platform_device->dev; - struct backlight_properties props; if (!acpi_check_handle(asus->handle, METHOD_BRIGHTNESS_GET, NULL) && !acpi_check_handle(asus->handle, METHOD_BRIGHTNESS_SET, NULL) && lcd_switch_handle) { - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = 15; - bd = backlight_device_register(ASUS_LAPTOP_FILE, dev, - asus, &asusbl_ops, &props); + asus, &asusbl_ops); if (IS_ERR(bd)) { pr_err("Could not register asus backlight device\n"); asus->backlight_device = NULL; @@ -657,6 +653,7 @@ static int asus_backlight_init(struct asus_laptop *asus) asus->backlight_device = bd; + bd->props.max_brightness = 15; bd->props.power = FB_BLANK_UNBLANK; bd->props.brightness = asus_read_brightness(bd); backlight_update_status(bd); diff --git a/trunk/drivers/platform/x86/asus_acpi.c b/trunk/drivers/platform/x86/asus_acpi.c index ee520357abaa..1381430e1105 100644 --- a/trunk/drivers/platform/x86/asus_acpi.c +++ b/trunk/drivers/platform/x86/asus_acpi.c @@ -1481,7 +1481,6 @@ static void asus_acpi_exit(void) static int __init asus_acpi_init(void) { - struct backlight_properties props; int result; result = acpi_bus_register_driver(&asus_hotk_driver); @@ -1508,17 +1507,15 @@ static int __init asus_acpi_init(void) return -ENODEV; } - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = 15; asus_backlight_device = backlight_device_register("asus", NULL, NULL, - &asus_backlight_data, - &props); + &asus_backlight_data); if (IS_ERR(asus_backlight_device)) { printk(KERN_ERR "Could not register asus backlight device\n"); asus_backlight_device = NULL; asus_acpi_exit(); return -ENODEV; } + asus_backlight_device->props.max_brightness = 15; return 0; } diff --git a/trunk/drivers/platform/x86/classmate-laptop.c b/trunk/drivers/platform/x86/classmate-laptop.c index c696cf1c2616..035a7dd65a3f 100644 --- a/trunk/drivers/platform/x86/classmate-laptop.c +++ b/trunk/drivers/platform/x86/classmate-laptop.c @@ -455,22 +455,18 @@ static int cmpc_bl_update_status(struct backlight_device *bd) return -1; } -static const struct backlight_ops cmpc_bl_ops = { +static struct backlight_ops cmpc_bl_ops = { .get_brightness = cmpc_bl_get_brightness, .update_status = cmpc_bl_update_status }; static int cmpc_bl_add(struct acpi_device *acpi) { - struct backlight_properties props; struct backlight_device *bd; - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = 7; - bd = backlight_device_register("cmpc_bl", &acpi->dev, acpi->handle, - &cmpc_bl_ops, &props); - if (IS_ERR(bd)) - return PTR_ERR(bd); + bd = backlight_device_register("cmpc_bl", &acpi->dev, + acpi->handle, &cmpc_bl_ops); + bd->props.max_brightness = 7; dev_set_drvdata(&acpi->dev, bd); return 0; } diff --git a/trunk/drivers/platform/x86/compal-laptop.c b/trunk/drivers/platform/x86/compal-laptop.c index 71ff1545a93e..2740b40aad9b 100644 --- a/trunk/drivers/platform/x86/compal-laptop.c +++ b/trunk/drivers/platform/x86/compal-laptop.c @@ -291,15 +291,12 @@ static int __init compal_init(void) /* Register backlight stuff */ if (!acpi_video_backlight_support()) { - struct backlight_properties props; - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = COMPAL_LCD_LEVEL_MAX - 1; - compalbl_device = backlight_device_register("compal-laptop", - NULL, NULL, - &compalbl_ops, - &props); + compalbl_device = backlight_device_register("compal-laptop", NULL, NULL, + &compalbl_ops); if (IS_ERR(compalbl_device)) return PTR_ERR(compalbl_device); + + compalbl_device->props.max_brightness = COMPAL_LCD_LEVEL_MAX-1; } ret = platform_driver_register(&compal_driver); diff --git a/trunk/drivers/platform/x86/dell-laptop.c b/trunk/drivers/platform/x86/dell-laptop.c index 46435ac4684f..ef614979afe9 100644 --- a/trunk/drivers/platform/x86/dell-laptop.c +++ b/trunk/drivers/platform/x86/dell-laptop.c @@ -559,14 +559,10 @@ static int __init dell_init(void) release_buffer(); if (max_intensity) { - struct backlight_properties props; - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = max_intensity; - dell_backlight_device = backlight_device_register("dell_backlight", - &platform_device->dev, - NULL, - &dell_ops, - &props); + dell_backlight_device = backlight_device_register( + "dell_backlight", + &platform_device->dev, NULL, + &dell_ops); if (IS_ERR(dell_backlight_device)) { ret = PTR_ERR(dell_backlight_device); @@ -574,6 +570,7 @@ static int __init dell_init(void) goto fail_backlight; } + dell_backlight_device->props.max_brightness = max_intensity; dell_backlight_device->props.brightness = dell_get_intensity(dell_backlight_device); backlight_update_status(dell_backlight_device); diff --git a/trunk/drivers/platform/x86/eeepc-laptop.c b/trunk/drivers/platform/x86/eeepc-laptop.c index 3fdf21e0052e..9a844caa3756 100644 --- a/trunk/drivers/platform/x86/eeepc-laptop.c +++ b/trunk/drivers/platform/x86/eeepc-laptop.c @@ -1131,20 +1131,18 @@ static int eeepc_backlight_notify(struct eeepc_laptop *eeepc) static int eeepc_backlight_init(struct eeepc_laptop *eeepc) { - struct backlight_properties props; struct backlight_device *bd; - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = 15; bd = backlight_device_register(EEEPC_LAPTOP_FILE, - &eeepc->platform_device->dev, eeepc, - &eeepcbl_ops, &props); + &eeepc->platform_device->dev, + eeepc, &eeepcbl_ops); if (IS_ERR(bd)) { pr_err("Could not register eeepc backlight device\n"); eeepc->backlight_device = NULL; return PTR_ERR(bd); } eeepc->backlight_device = bd; + bd->props.max_brightness = 15; bd->props.brightness = read_brightness(bd); bd->props.power = FB_BLANK_UNBLANK; backlight_update_status(bd); diff --git a/trunk/drivers/platform/x86/fujitsu-laptop.c b/trunk/drivers/platform/x86/fujitsu-laptop.c index c1074b32490e..5f3320d468f6 100644 --- a/trunk/drivers/platform/x86/fujitsu-laptop.c +++ b/trunk/drivers/platform/x86/fujitsu-laptop.c @@ -1126,20 +1126,16 @@ static int __init fujitsu_init(void) /* Register backlight stuff */ if (!acpi_video_backlight_support()) { - struct backlight_properties props; - - memset(&props, 0, sizeof(struct backlight_properties)); - max_brightness = fujitsu->max_brightness; - props.max_brightness = max_brightness - 1; - fujitsu->bl_device = backlight_device_register("fujitsu-laptop", - NULL, NULL, - &fujitsubl_ops, - &props); + fujitsu->bl_device = + backlight_device_register("fujitsu-laptop", NULL, NULL, + &fujitsubl_ops); if (IS_ERR(fujitsu->bl_device)) { ret = PTR_ERR(fujitsu->bl_device); fujitsu->bl_device = NULL; goto fail_sysfs_group; } + max_brightness = fujitsu->max_brightness; + fujitsu->bl_device->props.max_brightness = max_brightness - 1; fujitsu->bl_device->props.brightness = fujitsu->brightness_level; } diff --git a/trunk/drivers/platform/x86/msi-laptop.c b/trunk/drivers/platform/x86/msi-laptop.c index 996223a7c009..c2b05da4289a 100644 --- a/trunk/drivers/platform/x86/msi-laptop.c +++ b/trunk/drivers/platform/x86/msi-laptop.c @@ -683,14 +683,11 @@ static int __init msi_init(void) printk(KERN_INFO "MSI: Brightness ignored, must be controlled " "by ACPI video driver\n"); } else { - struct backlight_properties props; - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = MSI_LCD_LEVEL_MAX - 1; msibl_device = backlight_device_register("msi-laptop-bl", NULL, - NULL, &msibl_ops, - &props); + NULL, &msibl_ops); if (IS_ERR(msibl_device)) return PTR_ERR(msibl_device); + msibl_device->props.max_brightness = MSI_LCD_LEVEL_MAX-1; } ret = platform_driver_register(&msipf_driver); diff --git a/trunk/drivers/platform/x86/msi-wmi.c b/trunk/drivers/platform/x86/msi-wmi.c index 367caaae2f3c..f5f70d4c6913 100644 --- a/trunk/drivers/platform/x86/msi-wmi.c +++ b/trunk/drivers/platform/x86/msi-wmi.c @@ -138,7 +138,7 @@ static int bl_set_status(struct backlight_device *bd) return msi_wmi_set_block(0, backlight_map[bright]); } -static const struct backlight_ops msi_backlight_ops = { +static struct backlight_ops msi_backlight_ops = { .get_brightness = bl_get, .update_status = bl_set_status, }; @@ -249,17 +249,12 @@ static int __init msi_wmi_init(void) goto err_uninstall_notifier; if (!acpi_video_backlight_support()) { - struct backlight_properties props; - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = ARRAY_SIZE(backlight_map) - 1; - backlight = backlight_device_register(DRV_NAME, NULL, NULL, - &msi_backlight_ops, - &props); - if (IS_ERR(backlight)) { - err = PTR_ERR(backlight); + backlight = backlight_device_register(DRV_NAME, + NULL, NULL, &msi_backlight_ops); + if (IS_ERR(backlight)) goto err_free_input; - } + backlight->props.max_brightness = ARRAY_SIZE(backlight_map) - 1; err = bl_get(NULL); if (err < 0) goto err_free_backlight; diff --git a/trunk/drivers/platform/x86/panasonic-laptop.c b/trunk/drivers/platform/x86/panasonic-laptop.c index 726f02affcb6..c9fc479fc290 100644 --- a/trunk/drivers/platform/x86/panasonic-laptop.c +++ b/trunk/drivers/platform/x86/panasonic-laptop.c @@ -352,7 +352,7 @@ static int bl_set_status(struct backlight_device *bd) return acpi_pcc_write_sset(pcc, SINF_DC_CUR_BRIGHT, bright); } -static const struct backlight_ops pcc_backlight_ops = { +static struct backlight_ops pcc_backlight_ops = { .get_brightness = bl_get, .update_status = bl_set_status, }; @@ -600,7 +600,6 @@ static int acpi_pcc_hotkey_resume(struct acpi_device *device) static int acpi_pcc_hotkey_add(struct acpi_device *device) { - struct backlight_properties props; struct pcc_acpi *pcc; int num_sifr, result; @@ -638,25 +637,24 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device) if (result) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error installing keyinput handler\n")); - goto out_hotkey; + goto out_sinf; } + /* initialize backlight */ + pcc->backlight = backlight_device_register("panasonic", NULL, pcc, + &pcc_backlight_ops); + if (IS_ERR(pcc->backlight)) + goto out_input; + if (!acpi_pcc_retrieve_biosdata(pcc, pcc->sinf)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Couldn't retrieve BIOS data\n")); - goto out_input; - } - /* initialize backlight */ - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = pcc->sinf[SINF_AC_MAX_BRIGHT]; - pcc->backlight = backlight_device_register("panasonic", NULL, pcc, - &pcc_backlight_ops, &props); - if (IS_ERR(pcc->backlight)) { - result = PTR_ERR(pcc->backlight); - goto out_sinf; + goto out_backlight; } /* read the initial brightness setting from the hardware */ + pcc->backlight->props.max_brightness = + pcc->sinf[SINF_AC_MAX_BRIGHT]; pcc->backlight->props.brightness = pcc->sinf[SINF_AC_CUR_BRIGHT]; /* read the initial sticky key mode from the hardware */ @@ -671,12 +669,12 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device) out_backlight: backlight_device_unregister(pcc->backlight); -out_sinf: - kfree(pcc->sinf); out_input: input_unregister_device(pcc->input_dev); /* no need to input_free_device() since core input API refcount and * free()s the device */ +out_sinf: + kfree(pcc->sinf); out_hotkey: kfree(pcc); diff --git a/trunk/drivers/platform/x86/sony-laptop.c b/trunk/drivers/platform/x86/sony-laptop.c index 6553b91caaa4..5a3d8514c66d 100644 --- a/trunk/drivers/platform/x86/sony-laptop.c +++ b/trunk/drivers/platform/x86/sony-laptop.c @@ -1291,13 +1291,9 @@ static int sony_nc_add(struct acpi_device *device) "controlled by ACPI video driver\n"); } else if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "GBRT", &handle))) { - struct backlight_properties props; - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = SONY_MAX_BRIGHTNESS - 1; sony_backlight_device = backlight_device_register("sony", NULL, NULL, - &sony_backlight_ops, - &props); + &sony_backlight_ops); if (IS_ERR(sony_backlight_device)) { printk(KERN_WARNING DRV_PFX "unable to register backlight device\n"); @@ -1306,6 +1302,8 @@ static int sony_nc_add(struct acpi_device *device) sony_backlight_device->props.brightness = sony_backlight_get_brightness (sony_backlight_device); + sony_backlight_device->props.max_brightness = + SONY_MAX_BRIGHTNESS - 1; } } diff --git a/trunk/drivers/platform/x86/thinkpad_acpi.c b/trunk/drivers/platform/x86/thinkpad_acpi.c index 770b85327f84..c64e3528889b 100644 --- a/trunk/drivers/platform/x86/thinkpad_acpi.c +++ b/trunk/drivers/platform/x86/thinkpad_acpi.c @@ -6170,7 +6170,6 @@ static const struct tpacpi_quirk brightness_quirk_table[] __initconst = { static int __init brightness_init(struct ibm_init_struct *iibm) { - struct backlight_properties props; int b; unsigned long quirks; @@ -6260,12 +6259,9 @@ static int __init brightness_init(struct ibm_init_struct *iibm) printk(TPACPI_INFO "detected a 16-level brightness capable ThinkPad\n"); - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = (tp_features.bright_16levels) ? 15 : 7; - ibm_backlight_device = backlight_device_register(TPACPI_BACKLIGHT_DEV_NAME, - NULL, NULL, - &ibm_backlight_data, - &props); + ibm_backlight_device = backlight_device_register( + TPACPI_BACKLIGHT_DEV_NAME, NULL, NULL, + &ibm_backlight_data); if (IS_ERR(ibm_backlight_device)) { int rc = PTR_ERR(ibm_backlight_device); ibm_backlight_device = NULL; @@ -6284,6 +6280,8 @@ static int __init brightness_init(struct ibm_init_struct *iibm) "or not on your ThinkPad\n", TPACPI_MAIL); } + ibm_backlight_device->props.max_brightness = + (tp_features.bright_16levels)? 15 : 7; ibm_backlight_device->props.brightness = b & TP_EC_BACKLIGHT_LVLMSK; backlight_update_status(ibm_backlight_device); diff --git a/trunk/drivers/platform/x86/toshiba_acpi.c b/trunk/drivers/platform/x86/toshiba_acpi.c index def4841183be..789240d1b577 100644 --- a/trunk/drivers/platform/x86/toshiba_acpi.c +++ b/trunk/drivers/platform/x86/toshiba_acpi.c @@ -924,7 +924,6 @@ static int __init toshiba_acpi_init(void) u32 hci_result; bool bt_present; int ret = 0; - struct backlight_properties props; if (acpi_disabled) return -ENODEV; @@ -975,12 +974,10 @@ static int __init toshiba_acpi_init(void) } } - props.max_brightness = HCI_LCD_BRIGHTNESS_LEVELS - 1; toshiba_backlight_device = backlight_device_register("toshiba", - &toshiba_acpi.p_dev->dev, - NULL, - &toshiba_backlight_data, - &props); + &toshiba_acpi.p_dev->dev, + NULL, + &toshiba_backlight_data); if (IS_ERR(toshiba_backlight_device)) { ret = PTR_ERR(toshiba_backlight_device); @@ -989,6 +986,7 @@ static int __init toshiba_acpi_init(void) toshiba_acpi_exit(); return ret; } + toshiba_backlight_device->props.max_brightness = HCI_LCD_BRIGHTNESS_LEVELS - 1; /* Register rfkill switch for Bluetooth */ if (hci_get_bt_present(&bt_present) == HCI_SUCCESS && bt_present) { diff --git a/trunk/drivers/s390/char/sclp_cmd.c b/trunk/drivers/s390/char/sclp_cmd.c index fc7ae05ce48a..b3beab610da4 100644 --- a/trunk/drivers/s390/char/sclp_cmd.c +++ b/trunk/drivers/s390/char/sclp_cmd.c @@ -704,13 +704,6 @@ int sclp_chp_deconfigure(struct chp_id chpid) return do_chp_configure(SCLP_CMDW_DECONFIGURE_CHPATH | chpid.id << 8); } -int arch_get_memory_phys_device(unsigned long start_pfn) -{ - if (!rzm) - return 0; - return PFN_PHYS(start_pfn) / rzm; -} - struct chp_info_sccb { struct sccb_header header; u8 recognized[SCLP_CHP_INFO_MASK_SIZE]; diff --git a/trunk/drivers/scsi/Kconfig b/trunk/drivers/scsi/Kconfig index 75f2336807cb..9191d1ea6451 100644 --- a/trunk/drivers/scsi/Kconfig +++ b/trunk/drivers/scsi/Kconfig @@ -1,15 +1,9 @@ menu "SCSI device support" -config SCSI_MOD - tristate - default y if SCSI=n || SCSI=y - default m if SCSI=m - config RAID_ATTRS tristate "RAID Transport Class" default n depends on BLOCK - depends on SCSI_MOD ---help--- Provides RAID diff --git a/trunk/drivers/scsi/be2iscsi/be_cmds.c b/trunk/drivers/scsi/be2iscsi/be_cmds.c index cda6642c7368..67098578fba4 100644 --- a/trunk/drivers/scsi/be2iscsi/be_cmds.c +++ b/trunk/drivers/scsi/be2iscsi/be_cmds.c @@ -32,11 +32,18 @@ void be_mcc_notify(struct beiscsi_hba *phba) unsigned int alloc_mcc_tag(struct beiscsi_hba *phba) { unsigned int tag = 0; + unsigned int num = 0; +mcc_tag_rdy: if (phba->ctrl.mcc_tag_available) { tag = phba->ctrl.mcc_tag[phba->ctrl.mcc_alloc_index]; phba->ctrl.mcc_tag[phba->ctrl.mcc_alloc_index] = 0; phba->ctrl.mcc_numtag[tag] = 0; + } else { + udelay(100); + num++; + if (num < mcc_timeout) + goto mcc_tag_rdy; } if (tag) { phba->ctrl.mcc_tag_available--; diff --git a/trunk/drivers/scsi/be2iscsi/be_iscsi.c b/trunk/drivers/scsi/be2iscsi/be_iscsi.c index c3928cb8b042..29a3aaf35f9f 100644 --- a/trunk/drivers/scsi/be2iscsi/be_iscsi.c +++ b/trunk/drivers/scsi/be2iscsi/be_iscsi.c @@ -482,7 +482,7 @@ static int beiscsi_open_conn(struct iscsi_endpoint *ep, tag = mgmt_open_connection(phba, dst_addr, beiscsi_ep); if (!tag) { SE_DEBUG(DBG_LVL_1, - "mgmt_open_connection Failed for cid=%d \n", + "mgmt_invalidate_connection Failed for cid=%d \n", beiscsi_ep->ep_cid); } else { wait_event_interruptible(phba->ctrl.mcc_wait[tag], @@ -701,7 +701,7 @@ void beiscsi_conn_stop(struct iscsi_cls_conn *cls_conn, int flag) if (!tag) { SE_DEBUG(DBG_LVL_1, "mgmt_invalidate_connection Failed for cid=%d \n", - beiscsi_ep->ep_cid); + beiscsi_ep->ep_cid); } else { wait_event_interruptible(phba->ctrl.mcc_wait[tag], phba->ctrl.mcc_numtag[tag]); diff --git a/trunk/drivers/scsi/be2iscsi/be_main.c b/trunk/drivers/scsi/be2iscsi/be_main.c index fcfb29e02d8a..7c22616ab141 100644 --- a/trunk/drivers/scsi/be2iscsi/be_main.c +++ b/trunk/drivers/scsi/be2iscsi/be_main.c @@ -58,123 +58,6 @@ static int beiscsi_slave_configure(struct scsi_device *sdev) return 0; } -static int beiscsi_eh_abort(struct scsi_cmnd *sc) -{ - struct iscsi_cls_session *cls_session; - struct iscsi_task *aborted_task = (struct iscsi_task *)sc->SCp.ptr; - struct beiscsi_io_task *aborted_io_task; - struct iscsi_conn *conn; - struct beiscsi_conn *beiscsi_conn; - struct beiscsi_hba *phba; - struct iscsi_session *session; - struct invalidate_command_table *inv_tbl; - unsigned int cid, tag, num_invalidate; - - cls_session = starget_to_session(scsi_target(sc->device)); - session = cls_session->dd_data; - - spin_lock_bh(&session->lock); - if (!aborted_task || !aborted_task->sc) { - /* we raced */ - spin_unlock_bh(&session->lock); - return SUCCESS; - } - - aborted_io_task = aborted_task->dd_data; - if (!aborted_io_task->scsi_cmnd) { - /* raced or invalid command */ - spin_unlock_bh(&session->lock); - return SUCCESS; - } - spin_unlock_bh(&session->lock); - conn = aborted_task->conn; - beiscsi_conn = conn->dd_data; - phba = beiscsi_conn->phba; - - /* invalidate iocb */ - cid = beiscsi_conn->beiscsi_conn_cid; - inv_tbl = phba->inv_tbl; - memset(inv_tbl, 0x0, sizeof(*inv_tbl)); - inv_tbl->cid = cid; - inv_tbl->icd = aborted_io_task->psgl_handle->sgl_index; - num_invalidate = 1; - tag = mgmt_invalidate_icds(phba, inv_tbl, num_invalidate, cid); - if (!tag) { - shost_printk(KERN_WARNING, phba->shost, - "mgmt_invalidate_icds could not be" - " submitted\n"); - return FAILED; - } else { - wait_event_interruptible(phba->ctrl.mcc_wait[tag], - phba->ctrl.mcc_numtag[tag]); - free_mcc_tag(&phba->ctrl, tag); - } - - return iscsi_eh_abort(sc); -} - -static int beiscsi_eh_device_reset(struct scsi_cmnd *sc) -{ - struct iscsi_task *abrt_task; - struct beiscsi_io_task *abrt_io_task; - struct iscsi_conn *conn; - struct beiscsi_conn *beiscsi_conn; - struct beiscsi_hba *phba; - struct iscsi_session *session; - struct iscsi_cls_session *cls_session; - struct invalidate_command_table *inv_tbl; - unsigned int cid, tag, i, num_invalidate; - int rc = FAILED; - - /* invalidate iocbs */ - cls_session = starget_to_session(scsi_target(sc->device)); - session = cls_session->dd_data; - spin_lock_bh(&session->lock); - if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN) - goto unlock; - - conn = session->leadconn; - beiscsi_conn = conn->dd_data; - phba = beiscsi_conn->phba; - cid = beiscsi_conn->beiscsi_conn_cid; - inv_tbl = phba->inv_tbl; - memset(inv_tbl, 0x0, sizeof(*inv_tbl) * BE2_CMDS_PER_CXN); - num_invalidate = 0; - for (i = 0; i < conn->session->cmds_max; i++) { - abrt_task = conn->session->cmds[i]; - abrt_io_task = abrt_task->dd_data; - if (!abrt_task->sc || abrt_task->state == ISCSI_TASK_FREE) - continue; - - if (abrt_task->sc->device->lun != abrt_task->sc->device->lun) - continue; - - inv_tbl->cid = cid; - inv_tbl->icd = abrt_io_task->psgl_handle->sgl_index; - num_invalidate++; - inv_tbl++; - } - spin_unlock_bh(&session->lock); - inv_tbl = phba->inv_tbl; - - tag = mgmt_invalidate_icds(phba, inv_tbl, num_invalidate, cid); - if (!tag) { - shost_printk(KERN_WARNING, phba->shost, - "mgmt_invalidate_icds could not be" - " submitted\n"); - return FAILED; - } else { - wait_event_interruptible(phba->ctrl.mcc_wait[tag], - phba->ctrl.mcc_numtag[tag]); - free_mcc_tag(&phba->ctrl, tag); - } - - return iscsi_eh_device_reset(sc); -unlock: - spin_unlock_bh(&session->lock); - return rc; -} - /*------------------- PCI Driver operations and data ----------------- */ static DEFINE_PCI_DEVICE_TABLE(beiscsi_pci_id_table) = { { PCI_DEVICE(BE_VENDOR_ID, BE_DEVICE_ID1) }, @@ -191,12 +74,12 @@ static struct scsi_host_template beiscsi_sht = { .name = "ServerEngines 10Gbe open-iscsi Initiator Driver", .proc_name = DRV_NAME, .queuecommand = iscsi_queuecommand, + .eh_abort_handler = iscsi_eh_abort, .change_queue_depth = iscsi_change_queue_depth, .slave_configure = beiscsi_slave_configure, .target_alloc = iscsi_target_alloc, - .eh_abort_handler = beiscsi_eh_abort, - .eh_device_reset_handler = beiscsi_eh_device_reset, - .eh_target_reset_handler = iscsi_eh_session_reset, + .eh_device_reset_handler = iscsi_eh_device_reset, + .eh_target_reset_handler = iscsi_eh_target_reset, .sg_tablesize = BEISCSI_SGLIST_ELEMENTS, .can_queue = BE2_IO_DEPTH, .this_id = -1, @@ -359,7 +242,7 @@ static void beiscsi_get_params(struct beiscsi_hba *phba) + BE2_TMFS + BE2_NOPOUT_REQ)); phba->params.cxns_per_ctrl = phba->fw_config.iscsi_cid_count; - phba->params.asyncpdus_per_ctrl = phba->fw_config.iscsi_cid_count * 2; + phba->params.asyncpdus_per_ctrl = phba->fw_config.iscsi_cid_count;; phba->params.icds_per_ctrl = phba->fw_config.iscsi_icd_count;; phba->params.num_sge_per_io = BE2_SGE; phba->params.defpdu_hdr_sz = BE2_DEFPDU_HDR_SZ; @@ -1063,18 +946,14 @@ static void hwi_complete_cmd(struct beiscsi_conn *beiscsi_conn, case HWH_TYPE_IO: case HWH_TYPE_IO_RD: if ((task->hdr->opcode & ISCSI_OPCODE_MASK) == - ISCSI_OP_NOOP_OUT) + ISCSI_OP_NOOP_OUT) { be_complete_nopin_resp(beiscsi_conn, task, psol); - else + } else be_complete_io(beiscsi_conn, task, psol); break; case HWH_TYPE_LOGOUT: - if ((task->hdr->opcode & ISCSI_OPCODE_MASK) == ISCSI_OP_LOGOUT) - be_complete_logout(beiscsi_conn, task, psol); - else - be_complete_tmf(beiscsi_conn, task, psol); - + be_complete_logout(beiscsi_conn, task, psol); break; case HWH_TYPE_LOGIN: @@ -1083,6 +962,10 @@ static void hwi_complete_cmd(struct beiscsi_conn *beiscsi_conn, "- Solicited path \n"); break; + case HWH_TYPE_TMF: + be_complete_tmf(beiscsi_conn, task, psol); + break; + case HWH_TYPE_NOP: be_complete_nopin_resp(beiscsi_conn, task, psol); break; @@ -2169,7 +2052,7 @@ static void beiscsi_init_wrb_handle(struct beiscsi_hba *phba) num_cxn_wrb = (mem_descr_wrb->mem_array[idx].size) / ((sizeof(struct iscsi_wrb) * phba->params.wrbs_per_cxn)); - for (index = 0; index < phba->params.cxns_per_ctrl * 2; index += 2) { + for (index = 0; index < phba->params.cxns_per_ctrl; index += 2) { pwrb_context = &phwi_ctrlr->wrb_context[index]; if (num_cxn_wrb) { for (j = 0; j < phba->params.wrbs_per_cxn; j++) { @@ -3190,18 +3073,14 @@ static unsigned char hwi_enable_intr(struct beiscsi_hba *phba) reg |= MEMBAR_CTRL_INT_CTRL_HOSTINTR_MASK; SE_DEBUG(DBG_LVL_8, "reg =x%08x addr=%p \n", reg, addr); iowrite32(reg, addr); - if (!phba->msix_enabled) { - eq = &phwi_context->be_eq[0].q; + for (i = 0; i <= phba->num_cpus; i++) { + eq = &phwi_context->be_eq[i].q; SE_DEBUG(DBG_LVL_8, "eq->id=%d \n", eq->id); hwi_ring_eq_db(phba, eq->id, 0, 0, 1, 1); - } else { - for (i = 0; i <= phba->num_cpus; i++) { - eq = &phwi_context->be_eq[i].q; - SE_DEBUG(DBG_LVL_8, "eq->id=%d \n", eq->id); - hwi_ring_eq_db(phba, eq->id, 0, 0, 1, 1); - } } - } + } else + shost_printk(KERN_WARNING, phba->shost, + "In hwi_enable_intr, Not Enabled \n"); return true; } @@ -3597,13 +3476,19 @@ static int beiscsi_iotask(struct iscsi_task *task, struct scatterlist *sg, static int beiscsi_mtask(struct iscsi_task *task) { - struct beiscsi_io_task *io_task = task->dd_data; + struct beiscsi_io_task *aborted_io_task, *io_task = task->dd_data; struct iscsi_conn *conn = task->conn; struct beiscsi_conn *beiscsi_conn = conn->dd_data; struct beiscsi_hba *phba = beiscsi_conn->phba; + struct iscsi_session *session; struct iscsi_wrb *pwrb = NULL; + struct hwi_controller *phwi_ctrlr; + struct hwi_wrb_context *pwrb_context; + struct wrb_handle *pwrb_handle; unsigned int doorbell = 0; - unsigned int cid; + unsigned int i, cid; + struct iscsi_task *aborted_task; + unsigned int tag; cid = beiscsi_conn->beiscsi_conn_cid; pwrb = io_task->pwrb_handle->pwrb; @@ -3614,7 +3499,6 @@ static int beiscsi_mtask(struct iscsi_task *task) io_task->pwrb_handle->wrb_index); AMAP_SET_BITS(struct amap_iscsi_wrb, sgl_icd_idx, pwrb, io_task->psgl_handle->sgl_index); - switch (task->hdr->opcode & ISCSI_OPCODE_MASK) { case ISCSI_OP_LOGIN: AMAP_SET_BITS(struct amap_iscsi_wrb, type, pwrb, @@ -3639,6 +3523,33 @@ static int beiscsi_mtask(struct iscsi_task *task) hwi_write_buffer(pwrb, task); break; case ISCSI_OP_SCSI_TMFUNC: + session = conn->session; + i = ((struct iscsi_tm *)task->hdr)->rtt; + phwi_ctrlr = phba->phwi_ctrlr; + pwrb_context = &phwi_ctrlr->wrb_context[cid - + phba->fw_config.iscsi_cid_start]; + pwrb_handle = pwrb_context->pwrb_handle_basestd[be32_to_cpu(i) + >> 16]; + aborted_task = pwrb_handle->pio_handle; + if (!aborted_task) + return 0; + + aborted_io_task = aborted_task->dd_data; + if (!aborted_io_task->scsi_cmnd) + return 0; + + tag = mgmt_invalidate_icds(phba, + aborted_io_task->psgl_handle->sgl_index, + cid); + if (!tag) { + shost_printk(KERN_WARNING, phba->shost, + "mgmt_invalidate_icds could not be" + " submitted\n"); + } else { + wait_event_interruptible(phba->ctrl.mcc_wait[tag], + phba->ctrl.mcc_numtag[tag]); + free_mcc_tag(&phba->ctrl, tag); + } AMAP_SET_BITS(struct amap_iscsi_wrb, type, pwrb, INI_TMF_CMD); AMAP_SET_BITS(struct amap_iscsi_wrb, dmsg, pwrb, 0); @@ -3647,7 +3558,7 @@ static int beiscsi_mtask(struct iscsi_task *task) case ISCSI_OP_LOGOUT: AMAP_SET_BITS(struct amap_iscsi_wrb, dmsg, pwrb, 0); AMAP_SET_BITS(struct amap_iscsi_wrb, type, pwrb, - HWH_TYPE_LOGOUT); + HWH_TYPE_LOGOUT); hwi_write_buffer(pwrb, task); break; @@ -3673,12 +3584,17 @@ static int beiscsi_mtask(struct iscsi_task *task) static int beiscsi_task_xmit(struct iscsi_task *task) { + struct iscsi_conn *conn = task->conn; struct beiscsi_io_task *io_task = task->dd_data; struct scsi_cmnd *sc = task->sc; + struct beiscsi_conn *beiscsi_conn = conn->dd_data; struct scatterlist *sg; int num_sg; unsigned int writedir = 0, xferlen = 0; + SE_DEBUG(DBG_LVL_4, "\n cid=%d In beiscsi_task_xmit task=%p conn=%p \t" + "beiscsi_conn=%p \n", beiscsi_conn->beiscsi_conn_cid, + task, conn, beiscsi_conn); if (!sc) return beiscsi_mtask(task); @@ -3783,6 +3699,7 @@ static int __devinit beiscsi_dev_probe(struct pci_dev *pcidev, " Failed in beiscsi_hba_alloc \n"); goto disable_pci; } + SE_DEBUG(DBG_LVL_8, " phba = %p \n", phba); switch (pcidev->device) { case BE_DEVICE_ID1: diff --git a/trunk/drivers/scsi/be2iscsi/be_main.h b/trunk/drivers/scsi/be2iscsi/be_main.h index 87ec21280a37..c53a80ab796c 100644 --- a/trunk/drivers/scsi/be2iscsi/be_main.h +++ b/trunk/drivers/scsi/be2iscsi/be_main.h @@ -257,11 +257,6 @@ struct hba_parameters { unsigned int num_sge; }; -struct invalidate_command_table { - unsigned short icd; - unsigned short cid; -} __packed; - struct beiscsi_hba { struct hba_parameters params; struct hwi_controller *phwi_ctrlr; @@ -334,8 +329,6 @@ struct beiscsi_hba { struct work_struct work_cqs; /* The work being queued */ struct be_ctrl_info ctrl; unsigned int generation; - struct invalidate_command_table inv_tbl[128]; - }; struct beiscsi_session { @@ -498,6 +491,8 @@ struct hwi_async_entry { struct list_head data_busy_list; }; +#define BE_MIN_ASYNC_ENTRIES 128 + struct hwi_async_pdu_context { struct { struct be_bus_address pa_base; @@ -538,7 +533,7 @@ struct hwi_async_pdu_context { * This is a varying size list! Do not add anything * after this entry!! */ - struct hwi_async_entry async_entry[BE2_MAX_SESSIONS * 2]; + struct hwi_async_entry async_entry[BE_MIN_ASYNC_ENTRIES]; }; #define PDUCQE_CODE_MASK 0x0000003F diff --git a/trunk/drivers/scsi/be2iscsi/be_mgmt.c b/trunk/drivers/scsi/be2iscsi/be_mgmt.c index 72617b650a7e..317bcd042ced 100644 --- a/trunk/drivers/scsi/be2iscsi/be_mgmt.c +++ b/trunk/drivers/scsi/be2iscsi/be_mgmt.c @@ -145,15 +145,14 @@ unsigned char mgmt_epfw_cleanup(struct beiscsi_hba *phba, unsigned short chute) } unsigned char mgmt_invalidate_icds(struct beiscsi_hba *phba, - struct invalidate_command_table *inv_tbl, - unsigned int num_invalidate, unsigned int cid) + unsigned int icd, unsigned int cid) { struct be_dma_mem nonemb_cmd; struct be_ctrl_info *ctrl = &phba->ctrl; struct be_mcc_wrb *wrb; struct be_sge *sge; struct invalidate_commands_params_in *req; - unsigned int i, tag = 0; + unsigned int tag = 0; spin_lock(&ctrl->mbox_lock); tag = alloc_mcc_tag(phba); @@ -184,12 +183,9 @@ unsigned char mgmt_invalidate_icds(struct beiscsi_hba *phba, sizeof(*req)); req->ref_handle = 0; req->cleanup_type = CMD_ISCSI_COMMAND_INVALIDATE; - for (i = 0; i < num_invalidate; i++) { - req->table[i].icd = inv_tbl->icd; - req->table[i].cid = inv_tbl->cid; - req->icd_count++; - inv_tbl++; - } + req->icd_count = 0; + req->table[req->icd_count].icd = icd; + req->table[req->icd_count].cid = cid; sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd.dma)); sge->pa_lo = cpu_to_le32(nonemb_cmd.dma & 0xFFFFFFFF); sge->len = cpu_to_le32(nonemb_cmd.size); diff --git a/trunk/drivers/scsi/be2iscsi/be_mgmt.h b/trunk/drivers/scsi/be2iscsi/be_mgmt.h index 3d316b82feb1..ecead6a5aa56 100644 --- a/trunk/drivers/scsi/be2iscsi/be_mgmt.h +++ b/trunk/drivers/scsi/be2iscsi/be_mgmt.h @@ -94,8 +94,7 @@ unsigned char mgmt_upload_connection(struct beiscsi_hba *phba, unsigned short cid, unsigned int upload_flag); unsigned char mgmt_invalidate_icds(struct beiscsi_hba *phba, - struct invalidate_command_table *inv_tbl, - unsigned int num_invalidate, unsigned int cid); + unsigned int icd, unsigned int cid); struct iscsi_invalidate_connection_params_in { struct be_cmd_req_hdr hdr; @@ -117,6 +116,11 @@ union iscsi_invalidate_connection_params { struct iscsi_invalidate_connection_params_out response; } __packed; +struct invalidate_command_table { + unsigned short icd; + unsigned short cid; +} __packed; + struct invalidate_commands_params_in { struct be_cmd_req_hdr hdr; unsigned int ref_handle; diff --git a/trunk/drivers/scsi/bfa/Makefile b/trunk/drivers/scsi/bfa/Makefile index 17e06cae71b2..1d6009490d1c 100644 --- a/trunk/drivers/scsi/bfa/Makefile +++ b/trunk/drivers/scsi/bfa/Makefile @@ -2,14 +2,14 @@ obj-$(CONFIG_SCSI_BFA_FC) := bfa.o bfa-y := bfad.o bfad_intr.o bfad_os.o bfad_im.o bfad_attr.o bfad_fwimg.o -bfa-y += bfa_core.o bfa_ioc.o bfa_ioc_ct.o bfa_ioc_cb.o bfa_iocfc.o bfa_fcxp.o -bfa-y += bfa_lps.o bfa_hw_cb.o bfa_hw_ct.o bfa_intr.o bfa_timer.o bfa_rport.o +bfa-y += bfa_core.o bfa_ioc.o bfa_iocfc.o bfa_fcxp.o bfa_lps.o +bfa-y += bfa_hw_cb.o bfa_hw_ct.o bfa_intr.o bfa_timer.o bfa_rport.o bfa-y += bfa_fcport.o bfa_port.o bfa_uf.o bfa_sgpg.o bfa_module.o bfa_ioim.o bfa-y += bfa_itnim.o bfa_fcpim.o bfa_tskim.o bfa_log.o bfa_log_module.o bfa-y += bfa_csdebug.o bfa_sm.o plog.o -bfa-y += fcbuild.o fabric.o fcpim.o vfapi.o fcptm.o bfa_fcs.o bfa_fcs_port.o +bfa-y += fcbuild.o fabric.o fcpim.o vfapi.o fcptm.o bfa_fcs.o bfa_fcs_port.o bfa-y += bfa_fcs_uf.o bfa_fcs_lport.o fab.o fdmi.o ms.o ns.o scn.o loop.o bfa-y += lport_api.o n2n.o rport.o rport_api.o rport_ftrs.o vport.o -ccflags-y := -I$(obj) -I$(obj)/include -I$(obj)/include/cna -DBFA_PERF_BUILD +ccflags-y := -I$(obj) -I$(obj)/include -I$(obj)/include/cna diff --git a/trunk/drivers/scsi/bfa/bfa_core.c b/trunk/drivers/scsi/bfa/bfa_core.c index 0c08e185a766..44e2d1155c51 100644 --- a/trunk/drivers/scsi/bfa/bfa_core.c +++ b/trunk/drivers/scsi/bfa/bfa_core.c @@ -384,15 +384,6 @@ bfa_debug_fwsave(struct bfa_s *bfa, void *trcdata, int *trclen) return bfa_ioc_debug_fwsave(&bfa->ioc, trcdata, trclen); } -/** - * Clear the saved firmware trace information of an IOC. - */ -void -bfa_debug_fwsave_clear(struct bfa_s *bfa) -{ - bfa_ioc_debug_fwsave_clear(&bfa->ioc); -} - /** * Fetch firmware trace data. * @@ -408,14 +399,4 @@ bfa_debug_fwtrc(struct bfa_s *bfa, void *trcdata, int *trclen) { return bfa_ioc_debug_fwtrc(&bfa->ioc, trcdata, trclen); } - -/** - * Reset hw semaphore & usage cnt regs and initialize. - */ -void -bfa_chip_reset(struct bfa_s *bfa) -{ - bfa_ioc_ownership_reset(&bfa->ioc); - bfa_ioc_pll_init(&bfa->ioc); -} #endif diff --git a/trunk/drivers/scsi/bfa/bfa_fcport.c b/trunk/drivers/scsi/bfa/bfa_fcport.c index c589488db0c1..aef648b55dfc 100644 --- a/trunk/drivers/scsi/bfa/bfa_fcport.c +++ b/trunk/drivers/scsi/bfa/bfa_fcport.c @@ -23,33 +23,40 @@ #include #include -BFA_TRC_FILE(HAL, FCPORT); -BFA_MODULE(fcport); +BFA_TRC_FILE(HAL, PPORT); +BFA_MODULE(pport); + +#define bfa_pport_callback(__pport, __event) do { \ + if ((__pport)->bfa->fcs) { \ + (__pport)->event_cbfn((__pport)->event_cbarg, (__event)); \ + } else { \ + (__pport)->hcb_event = (__event); \ + bfa_cb_queue((__pport)->bfa, &(__pport)->hcb_qe, \ + __bfa_cb_port_event, (__pport)); \ + } \ +} while (0) /* * The port is considered disabled if corresponding physical port or IOC are * disabled explicitly */ #define BFA_PORT_IS_DISABLED(bfa) \ - ((bfa_fcport_is_disabled(bfa) == BFA_TRUE) || \ + ((bfa_pport_is_disabled(bfa) == BFA_TRUE) || \ (bfa_ioc_is_disabled(&bfa->ioc) == BFA_TRUE)) /* * forward declarations */ -static bfa_boolean_t bfa_fcport_send_enable(struct bfa_fcport_s *fcport); -static bfa_boolean_t bfa_fcport_send_disable(struct bfa_fcport_s *fcport); -static void bfa_fcport_update_linkinfo(struct bfa_fcport_s *fcport); -static void bfa_fcport_reset_linkinfo(struct bfa_fcport_s *fcport); -static void bfa_fcport_set_wwns(struct bfa_fcport_s *fcport); -static void __bfa_cb_fcport_event(void *cbarg, bfa_boolean_t complete); -static void bfa_fcport_callback(struct bfa_fcport_s *fcport, - enum bfa_pport_linkstate event); -static void bfa_fcport_queue_cb(struct bfa_fcport_ln_s *ln, - enum bfa_pport_linkstate event); -static void __bfa_cb_fcport_stats_clr(void *cbarg, bfa_boolean_t complete); -static void bfa_fcport_stats_get_timeout(void *cbarg); -static void bfa_fcport_stats_clr_timeout(void *cbarg); +static bfa_boolean_t bfa_pport_send_enable(struct bfa_pport_s *port); +static bfa_boolean_t bfa_pport_send_disable(struct bfa_pport_s *port); +static void bfa_pport_update_linkinfo(struct bfa_pport_s *pport); +static void bfa_pport_reset_linkinfo(struct bfa_pport_s *pport); +static void bfa_pport_set_wwns(struct bfa_pport_s *port); +static void __bfa_cb_port_event(void *cbarg, bfa_boolean_t complete); +static void __bfa_cb_port_stats(void *cbarg, bfa_boolean_t complete); +static void __bfa_cb_port_stats_clr(void *cbarg, bfa_boolean_t complete); +static void bfa_port_stats_timeout(void *cbarg); +static void bfa_port_stats_clr_timeout(void *cbarg); /** * bfa_pport_private @@ -58,114 +65,111 @@ static void bfa_fcport_stats_clr_timeout(void *cbarg); /** * BFA port state machine events */ -enum bfa_fcport_sm_event { - BFA_FCPORT_SM_START = 1, /* start port state machine */ - BFA_FCPORT_SM_STOP = 2, /* stop port state machine */ - BFA_FCPORT_SM_ENABLE = 3, /* enable port */ - BFA_FCPORT_SM_DISABLE = 4, /* disable port state machine */ - BFA_FCPORT_SM_FWRSP = 5, /* firmware enable/disable rsp */ - BFA_FCPORT_SM_LINKUP = 6, /* firmware linkup event */ - BFA_FCPORT_SM_LINKDOWN = 7, /* firmware linkup down */ - BFA_FCPORT_SM_QRESUME = 8, /* CQ space available */ - BFA_FCPORT_SM_HWFAIL = 9, /* IOC h/w failure */ +enum bfa_pport_sm_event { + BFA_PPORT_SM_START = 1, /* start port state machine */ + BFA_PPORT_SM_STOP = 2, /* stop port state machine */ + BFA_PPORT_SM_ENABLE = 3, /* enable port */ + BFA_PPORT_SM_DISABLE = 4, /* disable port state machine */ + BFA_PPORT_SM_FWRSP = 5, /* firmware enable/disable rsp */ + BFA_PPORT_SM_LINKUP = 6, /* firmware linkup event */ + BFA_PPORT_SM_LINKDOWN = 7, /* firmware linkup down */ + BFA_PPORT_SM_QRESUME = 8, /* CQ space available */ + BFA_PPORT_SM_HWFAIL = 9, /* IOC h/w failure */ }; -/** - * BFA port link notification state machine events - */ - -enum bfa_fcport_ln_sm_event { - BFA_FCPORT_LN_SM_LINKUP = 1, /* linkup event */ - BFA_FCPORT_LN_SM_LINKDOWN = 2, /* linkdown event */ - BFA_FCPORT_LN_SM_NOTIFICATION = 3 /* done notification */ -}; - -static void bfa_fcport_sm_uninit(struct bfa_fcport_s *fcport, - enum bfa_fcport_sm_event event); -static void bfa_fcport_sm_enabling_qwait(struct bfa_fcport_s *fcport, - enum bfa_fcport_sm_event event); -static void bfa_fcport_sm_enabling(struct bfa_fcport_s *fcport, - enum bfa_fcport_sm_event event); -static void bfa_fcport_sm_linkdown(struct bfa_fcport_s *fcport, - enum bfa_fcport_sm_event event); -static void bfa_fcport_sm_linkup(struct bfa_fcport_s *fcport, - enum bfa_fcport_sm_event event); -static void bfa_fcport_sm_disabling(struct bfa_fcport_s *fcport, - enum bfa_fcport_sm_event event); -static void bfa_fcport_sm_disabling_qwait(struct bfa_fcport_s *fcport, - enum bfa_fcport_sm_event event); -static void bfa_fcport_sm_disabled(struct bfa_fcport_s *fcport, - enum bfa_fcport_sm_event event); -static void bfa_fcport_sm_stopped(struct bfa_fcport_s *fcport, - enum bfa_fcport_sm_event event); -static void bfa_fcport_sm_iocdown(struct bfa_fcport_s *fcport, - enum bfa_fcport_sm_event event); -static void bfa_fcport_sm_iocfail(struct bfa_fcport_s *fcport, - enum bfa_fcport_sm_event event); - -static void bfa_fcport_ln_sm_dn(struct bfa_fcport_ln_s *ln, - enum bfa_fcport_ln_sm_event event); -static void bfa_fcport_ln_sm_dn_nf(struct bfa_fcport_ln_s *ln, - enum bfa_fcport_ln_sm_event event); -static void bfa_fcport_ln_sm_dn_up_nf(struct bfa_fcport_ln_s *ln, - enum bfa_fcport_ln_sm_event event); -static void bfa_fcport_ln_sm_up(struct bfa_fcport_ln_s *ln, - enum bfa_fcport_ln_sm_event event); -static void bfa_fcport_ln_sm_up_nf(struct bfa_fcport_ln_s *ln, - enum bfa_fcport_ln_sm_event event); -static void bfa_fcport_ln_sm_up_dn_nf(struct bfa_fcport_ln_s *ln, - enum bfa_fcport_ln_sm_event event); -static void bfa_fcport_ln_sm_up_dn_up_nf(struct bfa_fcport_ln_s *ln, - enum bfa_fcport_ln_sm_event event); +static void bfa_pport_sm_uninit(struct bfa_pport_s *pport, + enum bfa_pport_sm_event event); +static void bfa_pport_sm_enabling_qwait(struct bfa_pport_s *pport, + enum bfa_pport_sm_event event); +static void bfa_pport_sm_enabling(struct bfa_pport_s *pport, + enum bfa_pport_sm_event event); +static void bfa_pport_sm_linkdown(struct bfa_pport_s *pport, + enum bfa_pport_sm_event event); +static void bfa_pport_sm_linkup(struct bfa_pport_s *pport, + enum bfa_pport_sm_event event); +static void bfa_pport_sm_disabling(struct bfa_pport_s *pport, + enum bfa_pport_sm_event event); +static void bfa_pport_sm_disabling_qwait(struct bfa_pport_s *pport, + enum bfa_pport_sm_event event); +static void bfa_pport_sm_disabled(struct bfa_pport_s *pport, + enum bfa_pport_sm_event event); +static void bfa_pport_sm_stopped(struct bfa_pport_s *pport, + enum bfa_pport_sm_event event); +static void bfa_pport_sm_iocdown(struct bfa_pport_s *pport, + enum bfa_pport_sm_event event); +static void bfa_pport_sm_iocfail(struct bfa_pport_s *pport, + enum bfa_pport_sm_event event); static struct bfa_sm_table_s hal_pport_sm_table[] = { - {BFA_SM(bfa_fcport_sm_uninit), BFA_PPORT_ST_UNINIT}, - {BFA_SM(bfa_fcport_sm_enabling_qwait), BFA_PPORT_ST_ENABLING_QWAIT}, - {BFA_SM(bfa_fcport_sm_enabling), BFA_PPORT_ST_ENABLING}, - {BFA_SM(bfa_fcport_sm_linkdown), BFA_PPORT_ST_LINKDOWN}, - {BFA_SM(bfa_fcport_sm_linkup), BFA_PPORT_ST_LINKUP}, - {BFA_SM(bfa_fcport_sm_disabling_qwait), BFA_PPORT_ST_DISABLING_QWAIT}, - {BFA_SM(bfa_fcport_sm_disabling), BFA_PPORT_ST_DISABLING}, - {BFA_SM(bfa_fcport_sm_disabled), BFA_PPORT_ST_DISABLED}, - {BFA_SM(bfa_fcport_sm_stopped), BFA_PPORT_ST_STOPPED}, - {BFA_SM(bfa_fcport_sm_iocdown), BFA_PPORT_ST_IOCDOWN}, - {BFA_SM(bfa_fcport_sm_iocfail), BFA_PPORT_ST_IOCDOWN}, + {BFA_SM(bfa_pport_sm_uninit), BFA_PPORT_ST_UNINIT}, + {BFA_SM(bfa_pport_sm_enabling_qwait), BFA_PPORT_ST_ENABLING_QWAIT}, + {BFA_SM(bfa_pport_sm_enabling), BFA_PPORT_ST_ENABLING}, + {BFA_SM(bfa_pport_sm_linkdown), BFA_PPORT_ST_LINKDOWN}, + {BFA_SM(bfa_pport_sm_linkup), BFA_PPORT_ST_LINKUP}, + {BFA_SM(bfa_pport_sm_disabling_qwait), + BFA_PPORT_ST_DISABLING_QWAIT}, + {BFA_SM(bfa_pport_sm_disabling), BFA_PPORT_ST_DISABLING}, + {BFA_SM(bfa_pport_sm_disabled), BFA_PPORT_ST_DISABLED}, + {BFA_SM(bfa_pport_sm_stopped), BFA_PPORT_ST_STOPPED}, + {BFA_SM(bfa_pport_sm_iocdown), BFA_PPORT_ST_IOCDOWN}, + {BFA_SM(bfa_pport_sm_iocfail), BFA_PPORT_ST_IOCDOWN}, }; static void -bfa_fcport_aen_post(struct bfa_fcport_s *fcport, enum bfa_port_aen_event event) +bfa_pport_aen_post(struct bfa_pport_s *pport, enum bfa_port_aen_event event) { union bfa_aen_data_u aen_data; - struct bfa_log_mod_s *logmod = fcport->bfa->logm; - wwn_t pwwn = fcport->pwwn; + struct bfa_log_mod_s *logmod = pport->bfa->logm; + wwn_t pwwn = pport->pwwn; char pwwn_ptr[BFA_STRING_32]; + struct bfa_ioc_attr_s ioc_attr; - memset(&aen_data, 0, sizeof(aen_data)); wwn2str(pwwn_ptr, pwwn); - bfa_log(logmod, BFA_LOG_CREATE_ID(BFA_AEN_CAT_PORT, event), pwwn_ptr); + switch (event) { + case BFA_PORT_AEN_ONLINE: + bfa_log(logmod, BFA_AEN_PORT_ONLINE, pwwn_ptr); + break; + case BFA_PORT_AEN_OFFLINE: + bfa_log(logmod, BFA_AEN_PORT_OFFLINE, pwwn_ptr); + break; + case BFA_PORT_AEN_ENABLE: + bfa_log(logmod, BFA_AEN_PORT_ENABLE, pwwn_ptr); + break; + case BFA_PORT_AEN_DISABLE: + bfa_log(logmod, BFA_AEN_PORT_DISABLE, pwwn_ptr); + break; + case BFA_PORT_AEN_DISCONNECT: + bfa_log(logmod, BFA_AEN_PORT_DISCONNECT, pwwn_ptr); + break; + case BFA_PORT_AEN_QOS_NEG: + bfa_log(logmod, BFA_AEN_PORT_QOS_NEG, pwwn_ptr); + break; + default: + break; + } - aen_data.port.ioc_type = bfa_get_type(fcport->bfa); + bfa_ioc_get_attr(&pport->bfa->ioc, &ioc_attr); + aen_data.port.ioc_type = ioc_attr.ioc_type; aen_data.port.pwwn = pwwn; } static void -bfa_fcport_sm_uninit(struct bfa_fcport_s *fcport, - enum bfa_fcport_sm_event event) +bfa_pport_sm_uninit(struct bfa_pport_s *pport, enum bfa_pport_sm_event event) { - bfa_trc(fcport->bfa, event); + bfa_trc(pport->bfa, event); switch (event) { - case BFA_FCPORT_SM_START: + case BFA_PPORT_SM_START: /** * Start event after IOC is configured and BFA is started. */ - if (bfa_fcport_send_enable(fcport)) - bfa_sm_set_state(fcport, bfa_fcport_sm_enabling); + if (bfa_pport_send_enable(pport)) + bfa_sm_set_state(pport, bfa_pport_sm_enabling); else - bfa_sm_set_state(fcport, bfa_fcport_sm_enabling_qwait); + bfa_sm_set_state(pport, bfa_pport_sm_enabling_qwait); break; - case BFA_FCPORT_SM_ENABLE: + case BFA_PPORT_SM_ENABLE: /** * Port is persistently configured to be in enabled state. Do * not change state. Port enabling is done when START event is @@ -173,412 +177,389 @@ bfa_fcport_sm_uninit(struct bfa_fcport_s *fcport, */ break; - case BFA_FCPORT_SM_DISABLE: + case BFA_PPORT_SM_DISABLE: /** * If a port is persistently configured to be disabled, the * first event will a port disable request. */ - bfa_sm_set_state(fcport, bfa_fcport_sm_disabled); + bfa_sm_set_state(pport, bfa_pport_sm_disabled); break; - case BFA_FCPORT_SM_HWFAIL: - bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown); + case BFA_PPORT_SM_HWFAIL: + bfa_sm_set_state(pport, bfa_pport_sm_iocdown); break; default: - bfa_sm_fault(fcport->bfa, event); + bfa_sm_fault(pport->bfa, event); } } static void -bfa_fcport_sm_enabling_qwait(struct bfa_fcport_s *fcport, - enum bfa_fcport_sm_event event) +bfa_pport_sm_enabling_qwait(struct bfa_pport_s *pport, + enum bfa_pport_sm_event event) { - bfa_trc(fcport->bfa, event); + bfa_trc(pport->bfa, event); switch (event) { - case BFA_FCPORT_SM_QRESUME: - bfa_sm_set_state(fcport, bfa_fcport_sm_enabling); - bfa_fcport_send_enable(fcport); + case BFA_PPORT_SM_QRESUME: + bfa_sm_set_state(pport, bfa_pport_sm_enabling); + bfa_pport_send_enable(pport); break; - case BFA_FCPORT_SM_STOP: - bfa_reqq_wcancel(&fcport->reqq_wait); - bfa_sm_set_state(fcport, bfa_fcport_sm_stopped); + case BFA_PPORT_SM_STOP: + bfa_reqq_wcancel(&pport->reqq_wait); + bfa_sm_set_state(pport, bfa_pport_sm_stopped); break; - case BFA_FCPORT_SM_ENABLE: + case BFA_PPORT_SM_ENABLE: /** * Already enable is in progress. */ break; - case BFA_FCPORT_SM_DISABLE: + case BFA_PPORT_SM_DISABLE: /** * Just send disable request to firmware when room becomes * available in request queue. */ - bfa_sm_set_state(fcport, bfa_fcport_sm_disabled); - bfa_reqq_wcancel(&fcport->reqq_wait); - bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL, + bfa_sm_set_state(pport, bfa_pport_sm_disabled); + bfa_reqq_wcancel(&pport->reqq_wait); + bfa_plog_str(pport->bfa->plog, BFA_PL_MID_HAL, BFA_PL_EID_PORT_DISABLE, 0, "Port Disable"); - bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISABLE); + bfa_pport_aen_post(pport, BFA_PORT_AEN_DISABLE); break; - case BFA_FCPORT_SM_LINKUP: - case BFA_FCPORT_SM_LINKDOWN: + case BFA_PPORT_SM_LINKUP: + case BFA_PPORT_SM_LINKDOWN: /** * Possible to get link events when doing back-to-back * enable/disables. */ break; - case BFA_FCPORT_SM_HWFAIL: - bfa_reqq_wcancel(&fcport->reqq_wait); - bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown); + case BFA_PPORT_SM_HWFAIL: + bfa_reqq_wcancel(&pport->reqq_wait); + bfa_sm_set_state(pport, bfa_pport_sm_iocdown); break; default: - bfa_sm_fault(fcport->bfa, event); + bfa_sm_fault(pport->bfa, event); } } static void -bfa_fcport_sm_enabling(struct bfa_fcport_s *fcport, - enum bfa_fcport_sm_event event) +bfa_pport_sm_enabling(struct bfa_pport_s *pport, enum bfa_pport_sm_event event) { - bfa_trc(fcport->bfa, event); + bfa_trc(pport->bfa, event); switch (event) { - case BFA_FCPORT_SM_FWRSP: - case BFA_FCPORT_SM_LINKDOWN: - bfa_sm_set_state(fcport, bfa_fcport_sm_linkdown); + case BFA_PPORT_SM_FWRSP: + case BFA_PPORT_SM_LINKDOWN: + bfa_sm_set_state(pport, bfa_pport_sm_linkdown); break; - case BFA_FCPORT_SM_LINKUP: - bfa_fcport_update_linkinfo(fcport); - bfa_sm_set_state(fcport, bfa_fcport_sm_linkup); + case BFA_PPORT_SM_LINKUP: + bfa_pport_update_linkinfo(pport); + bfa_sm_set_state(pport, bfa_pport_sm_linkup); - bfa_assert(fcport->event_cbfn); - bfa_fcport_callback(fcport, BFA_PPORT_LINKUP); + bfa_assert(pport->event_cbfn); + bfa_pport_callback(pport, BFA_PPORT_LINKUP); break; - case BFA_FCPORT_SM_ENABLE: + case BFA_PPORT_SM_ENABLE: /** * Already being enabled. */ break; - case BFA_FCPORT_SM_DISABLE: - if (bfa_fcport_send_disable(fcport)) - bfa_sm_set_state(fcport, bfa_fcport_sm_disabling); + case BFA_PPORT_SM_DISABLE: + if (bfa_pport_send_disable(pport)) + bfa_sm_set_state(pport, bfa_pport_sm_disabling); else - bfa_sm_set_state(fcport, bfa_fcport_sm_disabling_qwait); + bfa_sm_set_state(pport, bfa_pport_sm_disabling_qwait); - bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL, + bfa_plog_str(pport->bfa->plog, BFA_PL_MID_HAL, BFA_PL_EID_PORT_DISABLE, 0, "Port Disable"); - bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISABLE); + bfa_pport_aen_post(pport, BFA_PORT_AEN_DISABLE); break; - case BFA_FCPORT_SM_STOP: - bfa_sm_set_state(fcport, bfa_fcport_sm_stopped); + case BFA_PPORT_SM_STOP: + bfa_sm_set_state(pport, bfa_pport_sm_stopped); break; - case BFA_FCPORT_SM_HWFAIL: - bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown); + case BFA_PPORT_SM_HWFAIL: + bfa_sm_set_state(pport, bfa_pport_sm_iocdown); break; default: - bfa_sm_fault(fcport->bfa, event); + bfa_sm_fault(pport->bfa, event); } } static void -bfa_fcport_sm_linkdown(struct bfa_fcport_s *fcport, - enum bfa_fcport_sm_event event) +bfa_pport_sm_linkdown(struct bfa_pport_s *pport, enum bfa_pport_sm_event event) { - struct bfi_fcport_event_s *pevent = fcport->event_arg.i2hmsg.event; - bfa_trc(fcport->bfa, event); + bfa_trc(pport->bfa, event); switch (event) { - case BFA_FCPORT_SM_LINKUP: - bfa_fcport_update_linkinfo(fcport); - bfa_sm_set_state(fcport, bfa_fcport_sm_linkup); - bfa_assert(fcport->event_cbfn); - bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL, + case BFA_PPORT_SM_LINKUP: + bfa_pport_update_linkinfo(pport); + bfa_sm_set_state(pport, bfa_pport_sm_linkup); + bfa_assert(pport->event_cbfn); + bfa_plog_str(pport->bfa->plog, BFA_PL_MID_HAL, BFA_PL_EID_PORT_ST_CHANGE, 0, "Port Linkup"); - - if (!bfa_ioc_get_fcmode(&fcport->bfa->ioc)) { - - bfa_trc(fcport->bfa, pevent->link_state.fcf.fipenabled); - bfa_trc(fcport->bfa, pevent->link_state.fcf.fipfailed); - - if (pevent->link_state.fcf.fipfailed) - bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL, - BFA_PL_EID_FIP_FCF_DISC, 0, - "FIP FCF Discovery Failed"); - else - bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL, - BFA_PL_EID_FIP_FCF_DISC, 0, - "FIP FCF Discovered"); - } - - bfa_fcport_callback(fcport, BFA_PPORT_LINKUP); - bfa_fcport_aen_post(fcport, BFA_PORT_AEN_ONLINE); + bfa_pport_callback(pport, BFA_PPORT_LINKUP); + bfa_pport_aen_post(pport, BFA_PORT_AEN_ONLINE); /** * If QoS is enabled and it is not online, * Send a separate event. */ - if ((fcport->cfg.qos_enabled) - && (bfa_os_ntohl(fcport->qos_attr.state) != BFA_QOS_ONLINE)) - bfa_fcport_aen_post(fcport, BFA_PORT_AEN_QOS_NEG); + if ((pport->cfg.qos_enabled) + && (bfa_os_ntohl(pport->qos_attr.state) != BFA_QOS_ONLINE)) + bfa_pport_aen_post(pport, BFA_PORT_AEN_QOS_NEG); break; - case BFA_FCPORT_SM_LINKDOWN: + case BFA_PPORT_SM_LINKDOWN: /** * Possible to get link down event. */ break; - case BFA_FCPORT_SM_ENABLE: + case BFA_PPORT_SM_ENABLE: /** * Already enabled. */ break; - case BFA_FCPORT_SM_DISABLE: - if (bfa_fcport_send_disable(fcport)) - bfa_sm_set_state(fcport, bfa_fcport_sm_disabling); + case BFA_PPORT_SM_DISABLE: + if (bfa_pport_send_disable(pport)) + bfa_sm_set_state(pport, bfa_pport_sm_disabling); else - bfa_sm_set_state(fcport, bfa_fcport_sm_disabling_qwait); + bfa_sm_set_state(pport, bfa_pport_sm_disabling_qwait); - bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL, + bfa_plog_str(pport->bfa->plog, BFA_PL_MID_HAL, BFA_PL_EID_PORT_DISABLE, 0, "Port Disable"); - bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISABLE); + bfa_pport_aen_post(pport, BFA_PORT_AEN_DISABLE); break; - case BFA_FCPORT_SM_STOP: - bfa_sm_set_state(fcport, bfa_fcport_sm_stopped); + case BFA_PPORT_SM_STOP: + bfa_sm_set_state(pport, bfa_pport_sm_stopped); break; - case BFA_FCPORT_SM_HWFAIL: - bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown); + case BFA_PPORT_SM_HWFAIL: + bfa_sm_set_state(pport, bfa_pport_sm_iocdown); break; default: - bfa_sm_fault(fcport->bfa, event); + bfa_sm_fault(pport->bfa, event); } } static void -bfa_fcport_sm_linkup(struct bfa_fcport_s *fcport, - enum bfa_fcport_sm_event event) +bfa_pport_sm_linkup(struct bfa_pport_s *pport, enum bfa_pport_sm_event event) { - bfa_trc(fcport->bfa, event); + bfa_trc(pport->bfa, event); switch (event) { - case BFA_FCPORT_SM_ENABLE: + case BFA_PPORT_SM_ENABLE: /** * Already enabled. */ break; - case BFA_FCPORT_SM_DISABLE: - if (bfa_fcport_send_disable(fcport)) - bfa_sm_set_state(fcport, bfa_fcport_sm_disabling); + case BFA_PPORT_SM_DISABLE: + if (bfa_pport_send_disable(pport)) + bfa_sm_set_state(pport, bfa_pport_sm_disabling); else - bfa_sm_set_state(fcport, bfa_fcport_sm_disabling_qwait); + bfa_sm_set_state(pport, bfa_pport_sm_disabling_qwait); - bfa_fcport_reset_linkinfo(fcport); - bfa_fcport_callback(fcport, BFA_PPORT_LINKDOWN); - bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL, + bfa_pport_reset_linkinfo(pport); + bfa_pport_callback(pport, BFA_PPORT_LINKDOWN); + bfa_plog_str(pport->bfa->plog, BFA_PL_MID_HAL, BFA_PL_EID_PORT_DISABLE, 0, "Port Disable"); - bfa_fcport_aen_post(fcport, BFA_PORT_AEN_OFFLINE); - bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISABLE); + bfa_pport_aen_post(pport, BFA_PORT_AEN_OFFLINE); + bfa_pport_aen_post(pport, BFA_PORT_AEN_DISABLE); break; - case BFA_FCPORT_SM_LINKDOWN: - bfa_sm_set_state(fcport, bfa_fcport_sm_linkdown); - bfa_fcport_reset_linkinfo(fcport); - bfa_fcport_callback(fcport, BFA_PPORT_LINKDOWN); - bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL, + case BFA_PPORT_SM_LINKDOWN: + bfa_sm_set_state(pport, bfa_pport_sm_linkdown); + bfa_pport_reset_linkinfo(pport); + bfa_pport_callback(pport, BFA_PPORT_LINKDOWN); + bfa_plog_str(pport->bfa->plog, BFA_PL_MID_HAL, BFA_PL_EID_PORT_ST_CHANGE, 0, "Port Linkdown"); - if (BFA_PORT_IS_DISABLED(fcport->bfa)) - bfa_fcport_aen_post(fcport, BFA_PORT_AEN_OFFLINE); + if (BFA_PORT_IS_DISABLED(pport->bfa)) + bfa_pport_aen_post(pport, BFA_PORT_AEN_OFFLINE); else - bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISCONNECT); + bfa_pport_aen_post(pport, BFA_PORT_AEN_DISCONNECT); break; - case BFA_FCPORT_SM_STOP: - bfa_sm_set_state(fcport, bfa_fcport_sm_stopped); - bfa_fcport_reset_linkinfo(fcport); - if (BFA_PORT_IS_DISABLED(fcport->bfa)) - bfa_fcport_aen_post(fcport, BFA_PORT_AEN_OFFLINE); + case BFA_PPORT_SM_STOP: + bfa_sm_set_state(pport, bfa_pport_sm_stopped); + bfa_pport_reset_linkinfo(pport); + if (BFA_PORT_IS_DISABLED(pport->bfa)) + bfa_pport_aen_post(pport, BFA_PORT_AEN_OFFLINE); else - bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISCONNECT); + bfa_pport_aen_post(pport, BFA_PORT_AEN_DISCONNECT); break; - case BFA_FCPORT_SM_HWFAIL: - bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown); - bfa_fcport_reset_linkinfo(fcport); - bfa_fcport_callback(fcport, BFA_PPORT_LINKDOWN); - if (BFA_PORT_IS_DISABLED(fcport->bfa)) - bfa_fcport_aen_post(fcport, BFA_PORT_AEN_OFFLINE); + case BFA_PPORT_SM_HWFAIL: + bfa_sm_set_state(pport, bfa_pport_sm_iocdown); + bfa_pport_reset_linkinfo(pport); + bfa_pport_callback(pport, BFA_PPORT_LINKDOWN); + if (BFA_PORT_IS_DISABLED(pport->bfa)) + bfa_pport_aen_post(pport, BFA_PORT_AEN_OFFLINE); else - bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISCONNECT); + bfa_pport_aen_post(pport, BFA_PORT_AEN_DISCONNECT); break; default: - bfa_sm_fault(fcport->bfa, event); + bfa_sm_fault(pport->bfa, event); } } static void -bfa_fcport_sm_disabling_qwait(struct bfa_fcport_s *fcport, - enum bfa_fcport_sm_event event) +bfa_pport_sm_disabling_qwait(struct bfa_pport_s *pport, + enum bfa_pport_sm_event event) { - bfa_trc(fcport->bfa, event); + bfa_trc(pport->bfa, event); switch (event) { - case BFA_FCPORT_SM_QRESUME: - bfa_sm_set_state(fcport, bfa_fcport_sm_disabling); - bfa_fcport_send_disable(fcport); + case BFA_PPORT_SM_QRESUME: + bfa_sm_set_state(pport, bfa_pport_sm_disabling); + bfa_pport_send_disable(pport); break; - case BFA_FCPORT_SM_STOP: - bfa_sm_set_state(fcport, bfa_fcport_sm_stopped); - bfa_reqq_wcancel(&fcport->reqq_wait); + case BFA_PPORT_SM_STOP: + bfa_sm_set_state(pport, bfa_pport_sm_stopped); + bfa_reqq_wcancel(&pport->reqq_wait); break; - case BFA_FCPORT_SM_DISABLE: + case BFA_PPORT_SM_DISABLE: /** * Already being disabled. */ break; - case BFA_FCPORT_SM_LINKUP: - case BFA_FCPORT_SM_LINKDOWN: + case BFA_PPORT_SM_LINKUP: + case BFA_PPORT_SM_LINKDOWN: /** * Possible to get link events when doing back-to-back * enable/disables. */ break; - case BFA_FCPORT_SM_HWFAIL: - bfa_sm_set_state(fcport, bfa_fcport_sm_iocfail); - bfa_reqq_wcancel(&fcport->reqq_wait); + case BFA_PPORT_SM_HWFAIL: + bfa_sm_set_state(pport, bfa_pport_sm_iocfail); + bfa_reqq_wcancel(&pport->reqq_wait); break; default: - bfa_sm_fault(fcport->bfa, event); + bfa_sm_fault(pport->bfa, event); } } static void -bfa_fcport_sm_disabling(struct bfa_fcport_s *fcport, - enum bfa_fcport_sm_event event) +bfa_pport_sm_disabling(struct bfa_pport_s *pport, enum bfa_pport_sm_event event) { - bfa_trc(fcport->bfa, event); + bfa_trc(pport->bfa, event); switch (event) { - case BFA_FCPORT_SM_FWRSP: - bfa_sm_set_state(fcport, bfa_fcport_sm_disabled); + case BFA_PPORT_SM_FWRSP: + bfa_sm_set_state(pport, bfa_pport_sm_disabled); break; - case BFA_FCPORT_SM_DISABLE: + case BFA_PPORT_SM_DISABLE: /** * Already being disabled. */ break; - case BFA_FCPORT_SM_ENABLE: - if (bfa_fcport_send_enable(fcport)) - bfa_sm_set_state(fcport, bfa_fcport_sm_enabling); + case BFA_PPORT_SM_ENABLE: + if (bfa_pport_send_enable(pport)) + bfa_sm_set_state(pport, bfa_pport_sm_enabling); else - bfa_sm_set_state(fcport, bfa_fcport_sm_enabling_qwait); + bfa_sm_set_state(pport, bfa_pport_sm_enabling_qwait); - bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL, + bfa_plog_str(pport->bfa->plog, BFA_PL_MID_HAL, BFA_PL_EID_PORT_ENABLE, 0, "Port Enable"); - bfa_fcport_aen_post(fcport, BFA_PORT_AEN_ENABLE); + bfa_pport_aen_post(pport, BFA_PORT_AEN_ENABLE); break; - case BFA_FCPORT_SM_STOP: - bfa_sm_set_state(fcport, bfa_fcport_sm_stopped); + case BFA_PPORT_SM_STOP: + bfa_sm_set_state(pport, bfa_pport_sm_stopped); break; - case BFA_FCPORT_SM_LINKUP: - case BFA_FCPORT_SM_LINKDOWN: + case BFA_PPORT_SM_LINKUP: + case BFA_PPORT_SM_LINKDOWN: /** * Possible to get link events when doing back-to-back * enable/disables. */ break; - case BFA_FCPORT_SM_HWFAIL: - bfa_sm_set_state(fcport, bfa_fcport_sm_iocfail); + case BFA_PPORT_SM_HWFAIL: + bfa_sm_set_state(pport, bfa_pport_sm_iocfail); break; default: - bfa_sm_fault(fcport->bfa, event); + bfa_sm_fault(pport->bfa, event); } } static void -bfa_fcport_sm_disabled(struct bfa_fcport_s *fcport, - enum bfa_fcport_sm_event event) +bfa_pport_sm_disabled(struct bfa_pport_s *pport, enum bfa_pport_sm_event event) { - bfa_trc(fcport->bfa, event); + bfa_trc(pport->bfa, event); switch (event) { - case BFA_FCPORT_SM_START: + case BFA_PPORT_SM_START: /** * Ignore start event for a port that is disabled. */ break; - case BFA_FCPORT_SM_STOP: - bfa_sm_set_state(fcport, bfa_fcport_sm_stopped); + case BFA_PPORT_SM_STOP: + bfa_sm_set_state(pport, bfa_pport_sm_stopped); break; - case BFA_FCPORT_SM_ENABLE: - if (bfa_fcport_send_enable(fcport)) - bfa_sm_set_state(fcport, bfa_fcport_sm_enabling); + case BFA_PPORT_SM_ENABLE: + if (bfa_pport_send_enable(pport)) + bfa_sm_set_state(pport, bfa_pport_sm_enabling); else - bfa_sm_set_state(fcport, bfa_fcport_sm_enabling_qwait); + bfa_sm_set_state(pport, bfa_pport_sm_enabling_qwait); - bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL, + bfa_plog_str(pport->bfa->plog, BFA_PL_MID_HAL, BFA_PL_EID_PORT_ENABLE, 0, "Port Enable"); - bfa_fcport_aen_post(fcport, BFA_PORT_AEN_ENABLE); + bfa_pport_aen_post(pport, BFA_PORT_AEN_ENABLE); break; - case BFA_FCPORT_SM_DISABLE: + case BFA_PPORT_SM_DISABLE: /** * Already disabled. */ break; - case BFA_FCPORT_SM_HWFAIL: - bfa_sm_set_state(fcport, bfa_fcport_sm_iocfail); + case BFA_PPORT_SM_HWFAIL: + bfa_sm_set_state(pport, bfa_pport_sm_iocfail); break; default: - bfa_sm_fault(fcport->bfa, event); + bfa_sm_fault(pport->bfa, event); } } static void -bfa_fcport_sm_stopped(struct bfa_fcport_s *fcport, - enum bfa_fcport_sm_event event) +bfa_pport_sm_stopped(struct bfa_pport_s *pport, enum bfa_pport_sm_event event) { - bfa_trc(fcport->bfa, event); + bfa_trc(pport->bfa, event); switch (event) { - case BFA_FCPORT_SM_START: - if (bfa_fcport_send_enable(fcport)) - bfa_sm_set_state(fcport, bfa_fcport_sm_enabling); + case BFA_PPORT_SM_START: + if (bfa_pport_send_enable(pport)) + bfa_sm_set_state(pport, bfa_pport_sm_enabling); else - bfa_sm_set_state(fcport, bfa_fcport_sm_enabling_qwait); + bfa_sm_set_state(pport, bfa_pport_sm_enabling_qwait); break; default: @@ -593,17 +574,16 @@ bfa_fcport_sm_stopped(struct bfa_fcport_s *fcport, * Port is enabled. IOC is down/failed. */ static void -bfa_fcport_sm_iocdown(struct bfa_fcport_s *fcport, - enum bfa_fcport_sm_event event) +bfa_pport_sm_iocdown(struct bfa_pport_s *pport, enum bfa_pport_sm_event event) { - bfa_trc(fcport->bfa, event); + bfa_trc(pport->bfa, event); switch (event) { - case BFA_FCPORT_SM_START: - if (bfa_fcport_send_enable(fcport)) - bfa_sm_set_state(fcport, bfa_fcport_sm_enabling); + case BFA_PPORT_SM_START: + if (bfa_pport_send_enable(pport)) + bfa_sm_set_state(pport, bfa_pport_sm_enabling); else - bfa_sm_set_state(fcport, bfa_fcport_sm_enabling_qwait); + bfa_sm_set_state(pport, bfa_pport_sm_enabling_qwait); break; default: @@ -618,18 +598,17 @@ bfa_fcport_sm_iocdown(struct bfa_fcport_s *fcport, * Port is disabled. IOC is down/failed. */ static void -bfa_fcport_sm_iocfail(struct bfa_fcport_s *fcport, - enum bfa_fcport_sm_event event) +bfa_pport_sm_iocfail(struct bfa_pport_s *pport, enum bfa_pport_sm_event event) { - bfa_trc(fcport->bfa, event); + bfa_trc(pport->bfa, event); switch (event) { - case BFA_FCPORT_SM_START: - bfa_sm_set_state(fcport, bfa_fcport_sm_disabled); + case BFA_PPORT_SM_START: + bfa_sm_set_state(pport, bfa_pport_sm_disabled); break; - case BFA_FCPORT_SM_ENABLE: - bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown); + case BFA_PPORT_SM_ENABLE: + bfa_sm_set_state(pport, bfa_pport_sm_iocdown); break; default: @@ -640,226 +619,41 @@ bfa_fcport_sm_iocfail(struct bfa_fcport_s *fcport, } } -/** - * Link state is down - */ -static void -bfa_fcport_ln_sm_dn(struct bfa_fcport_ln_s *ln, - enum bfa_fcport_ln_sm_event event) -{ - bfa_trc(ln->fcport->bfa, event); - - switch (event) { - case BFA_FCPORT_LN_SM_LINKUP: - bfa_sm_set_state(ln, bfa_fcport_ln_sm_up_nf); - bfa_fcport_queue_cb(ln, BFA_PPORT_LINKUP); - break; - - default: - bfa_sm_fault(ln->fcport->bfa, event); - } -} - -/** - * Link state is waiting for down notification - */ -static void -bfa_fcport_ln_sm_dn_nf(struct bfa_fcport_ln_s *ln, - enum bfa_fcport_ln_sm_event event) -{ - bfa_trc(ln->fcport->bfa, event); - - switch (event) { - case BFA_FCPORT_LN_SM_LINKUP: - bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn_up_nf); - break; - - case BFA_FCPORT_LN_SM_NOTIFICATION: - bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn); - break; - - default: - bfa_sm_fault(ln->fcport->bfa, event); - } -} - -/** - * Link state is waiting for down notification and there is a pending up - */ -static void -bfa_fcport_ln_sm_dn_up_nf(struct bfa_fcport_ln_s *ln, - enum bfa_fcport_ln_sm_event event) -{ - bfa_trc(ln->fcport->bfa, event); - - switch (event) { - case BFA_FCPORT_LN_SM_LINKDOWN: - bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn_nf); - break; - - case BFA_FCPORT_LN_SM_NOTIFICATION: - bfa_sm_set_state(ln, bfa_fcport_ln_sm_up_nf); - bfa_fcport_queue_cb(ln, BFA_PPORT_LINKUP); - break; - - default: - bfa_sm_fault(ln->fcport->bfa, event); - } -} - -/** - * Link state is up - */ -static void -bfa_fcport_ln_sm_up(struct bfa_fcport_ln_s *ln, - enum bfa_fcport_ln_sm_event event) -{ - bfa_trc(ln->fcport->bfa, event); - - switch (event) { - case BFA_FCPORT_LN_SM_LINKDOWN: - bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn_nf); - bfa_fcport_queue_cb(ln, BFA_PPORT_LINKDOWN); - break; - default: - bfa_sm_fault(ln->fcport->bfa, event); - } -} - -/** - * Link state is waiting for up notification - */ -static void -bfa_fcport_ln_sm_up_nf(struct bfa_fcport_ln_s *ln, - enum bfa_fcport_ln_sm_event event) -{ - bfa_trc(ln->fcport->bfa, event); - - switch (event) { - case BFA_FCPORT_LN_SM_LINKDOWN: - bfa_sm_set_state(ln, bfa_fcport_ln_sm_up_dn_nf); - break; - - case BFA_FCPORT_LN_SM_NOTIFICATION: - bfa_sm_set_state(ln, bfa_fcport_ln_sm_up); - break; - - default: - bfa_sm_fault(ln->fcport->bfa, event); - } -} - -/** - * Link state is waiting for up notification and there is a pending down - */ -static void -bfa_fcport_ln_sm_up_dn_nf(struct bfa_fcport_ln_s *ln, - enum bfa_fcport_ln_sm_event event) -{ - bfa_trc(ln->fcport->bfa, event); - - switch (event) { - case BFA_FCPORT_LN_SM_LINKUP: - bfa_sm_set_state(ln, bfa_fcport_ln_sm_up_dn_up_nf); - break; - - case BFA_FCPORT_LN_SM_NOTIFICATION: - bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn_nf); - bfa_fcport_queue_cb(ln, BFA_PPORT_LINKDOWN); - break; - - default: - bfa_sm_fault(ln->fcport->bfa, event); - } -} - -/** - * Link state is waiting for up notification and there are pending down and up - */ -static void -bfa_fcport_ln_sm_up_dn_up_nf(struct bfa_fcport_ln_s *ln, - enum bfa_fcport_ln_sm_event event) -{ - bfa_trc(ln->fcport->bfa, event); - - switch (event) { - case BFA_FCPORT_LN_SM_LINKDOWN: - bfa_sm_set_state(ln, bfa_fcport_ln_sm_up_dn_nf); - break; - - case BFA_FCPORT_LN_SM_NOTIFICATION: - bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn_up_nf); - bfa_fcport_queue_cb(ln, BFA_PPORT_LINKDOWN); - break; - - default: - bfa_sm_fault(ln->fcport->bfa, event); - } -} /** * bfa_pport_private */ static void -__bfa_cb_fcport_event(void *cbarg, bfa_boolean_t complete) +__bfa_cb_port_event(void *cbarg, bfa_boolean_t complete) { - struct bfa_fcport_ln_s *ln = cbarg; + struct bfa_pport_s *pport = cbarg; if (complete) - ln->fcport->event_cbfn(ln->fcport->event_cbarg, ln->ln_event); - else - bfa_sm_send_event(ln, BFA_FCPORT_LN_SM_NOTIFICATION); + pport->event_cbfn(pport->event_cbarg, pport->hcb_event); } -static void -bfa_fcport_callback(struct bfa_fcport_s *fcport, enum bfa_pport_linkstate event) -{ - if (fcport->bfa->fcs) { - fcport->event_cbfn(fcport->event_cbarg, event); - return; - } - - switch (event) { - case BFA_PPORT_LINKUP: - bfa_sm_send_event(&fcport->ln, BFA_FCPORT_LN_SM_LINKUP); - break; - case BFA_PPORT_LINKDOWN: - bfa_sm_send_event(&fcport->ln, BFA_FCPORT_LN_SM_LINKDOWN); - break; - default: - bfa_assert(0); - } -} - -static void -bfa_fcport_queue_cb(struct bfa_fcport_ln_s *ln, enum bfa_pport_linkstate event) -{ - ln->ln_event = event; - bfa_cb_queue(ln->fcport->bfa, &ln->ln_qe, __bfa_cb_fcport_event, ln); -} - -#define FCPORT_STATS_DMA_SZ (BFA_ROUNDUP(sizeof(union bfa_fcport_stats_u), \ +#define PPORT_STATS_DMA_SZ (BFA_ROUNDUP(sizeof(union bfa_pport_stats_u), \ BFA_CACHELINE_SZ)) static void -bfa_fcport_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *ndm_len, +bfa_pport_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *ndm_len, u32 *dm_len) { - *dm_len += FCPORT_STATS_DMA_SZ; + *dm_len += PPORT_STATS_DMA_SZ; } static void -bfa_fcport_qresume(void *cbarg) +bfa_pport_qresume(void *cbarg) { - struct bfa_fcport_s *fcport = cbarg; + struct bfa_pport_s *port = cbarg; - bfa_sm_send_event(fcport, BFA_FCPORT_SM_QRESUME); + bfa_sm_send_event(port, BFA_PPORT_SM_QRESUME); } static void -bfa_fcport_mem_claim(struct bfa_fcport_s *fcport, struct bfa_meminfo_s *meminfo) +bfa_pport_mem_claim(struct bfa_pport_s *pport, struct bfa_meminfo_s *meminfo) { u8 *dm_kva; u64 dm_pa; @@ -867,12 +661,12 @@ bfa_fcport_mem_claim(struct bfa_fcport_s *fcport, struct bfa_meminfo_s *meminfo) dm_kva = bfa_meminfo_dma_virt(meminfo); dm_pa = bfa_meminfo_dma_phys(meminfo); - fcport->stats_kva = dm_kva; - fcport->stats_pa = dm_pa; - fcport->stats = (union bfa_fcport_stats_u *)dm_kva; + pport->stats_kva = dm_kva; + pport->stats_pa = dm_pa; + pport->stats = (union bfa_pport_stats_u *)dm_kva; - dm_kva += FCPORT_STATS_DMA_SZ; - dm_pa += FCPORT_STATS_DMA_SZ; + dm_kva += PPORT_STATS_DMA_SZ; + dm_pa += PPORT_STATS_DMA_SZ; bfa_meminfo_dma_virt(meminfo) = dm_kva; bfa_meminfo_dma_phys(meminfo) = dm_pa; @@ -882,21 +676,18 @@ bfa_fcport_mem_claim(struct bfa_fcport_s *fcport, struct bfa_meminfo_s *meminfo) * Memory initialization. */ static void -bfa_fcport_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, +bfa_pport_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); - struct bfa_pport_cfg_s *port_cfg = &fcport->cfg; - struct bfa_fcport_ln_s *ln = &fcport->ln; + struct bfa_pport_s *pport = BFA_PORT_MOD(bfa); + struct bfa_pport_cfg_s *port_cfg = &pport->cfg; - bfa_os_memset(fcport, 0, sizeof(struct bfa_fcport_s)); - fcport->bfa = bfa; - ln->fcport = fcport; + bfa_os_memset(pport, 0, sizeof(struct bfa_pport_s)); + pport->bfa = bfa; - bfa_fcport_mem_claim(fcport, meminfo); + bfa_pport_mem_claim(pport, meminfo); - bfa_sm_set_state(fcport, bfa_fcport_sm_uninit); - bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn); + bfa_sm_set_state(pport, bfa_pport_sm_uninit); /** * initialize and set default configuration @@ -908,30 +699,30 @@ bfa_fcport_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, port_cfg->trl_def_speed = BFA_PPORT_SPEED_1GBPS; - bfa_reqq_winit(&fcport->reqq_wait, bfa_fcport_qresume, fcport); + bfa_reqq_winit(&pport->reqq_wait, bfa_pport_qresume, pport); } static void -bfa_fcport_initdone(struct bfa_s *bfa) +bfa_pport_initdone(struct bfa_s *bfa) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); + struct bfa_pport_s *pport = BFA_PORT_MOD(bfa); /** * Initialize port attributes from IOC hardware data. */ - bfa_fcport_set_wwns(fcport); - if (fcport->cfg.maxfrsize == 0) - fcport->cfg.maxfrsize = bfa_ioc_maxfrsize(&bfa->ioc); - fcport->cfg.rx_bbcredit = bfa_ioc_rx_bbcredit(&bfa->ioc); - fcport->speed_sup = bfa_ioc_speed_sup(&bfa->ioc); + bfa_pport_set_wwns(pport); + if (pport->cfg.maxfrsize == 0) + pport->cfg.maxfrsize = bfa_ioc_maxfrsize(&bfa->ioc); + pport->cfg.rx_bbcredit = bfa_ioc_rx_bbcredit(&bfa->ioc); + pport->speed_sup = bfa_ioc_speed_sup(&bfa->ioc); - bfa_assert(fcport->cfg.maxfrsize); - bfa_assert(fcport->cfg.rx_bbcredit); - bfa_assert(fcport->speed_sup); + bfa_assert(pport->cfg.maxfrsize); + bfa_assert(pport->cfg.rx_bbcredit); + bfa_assert(pport->speed_sup); } static void -bfa_fcport_detach(struct bfa_s *bfa) +bfa_pport_detach(struct bfa_s *bfa) { } @@ -939,97 +730,95 @@ bfa_fcport_detach(struct bfa_s *bfa) * Called when IOC is ready. */ static void -bfa_fcport_start(struct bfa_s *bfa) +bfa_pport_start(struct bfa_s *bfa) { - bfa_sm_send_event(BFA_FCPORT_MOD(bfa), BFA_FCPORT_SM_START); + bfa_sm_send_event(BFA_PORT_MOD(bfa), BFA_PPORT_SM_START); } /** * Called before IOC is stopped. */ static void -bfa_fcport_stop(struct bfa_s *bfa) +bfa_pport_stop(struct bfa_s *bfa) { - bfa_sm_send_event(BFA_FCPORT_MOD(bfa), BFA_FCPORT_SM_STOP); + bfa_sm_send_event(BFA_PORT_MOD(bfa), BFA_PPORT_SM_STOP); } /** * Called when IOC failure is detected. */ static void -bfa_fcport_iocdisable(struct bfa_s *bfa) +bfa_pport_iocdisable(struct bfa_s *bfa) { - bfa_sm_send_event(BFA_FCPORT_MOD(bfa), BFA_FCPORT_SM_HWFAIL); + bfa_sm_send_event(BFA_PORT_MOD(bfa), BFA_PPORT_SM_HWFAIL); } static void -bfa_fcport_update_linkinfo(struct bfa_fcport_s *fcport) +bfa_pport_update_linkinfo(struct bfa_pport_s *pport) { - struct bfi_fcport_event_s *pevent = fcport->event_arg.i2hmsg.event; + struct bfi_pport_event_s *pevent = pport->event_arg.i2hmsg.event; - fcport->speed = pevent->link_state.speed; - fcport->topology = pevent->link_state.topology; + pport->speed = pevent->link_state.speed; + pport->topology = pevent->link_state.topology; - if (fcport->topology == BFA_PPORT_TOPOLOGY_LOOP) - fcport->myalpa = - pevent->link_state.tl.loop_info.myalpa; + if (pport->topology == BFA_PPORT_TOPOLOGY_LOOP) + pport->myalpa = pevent->link_state.tl.loop_info.myalpa; /* * QoS Details */ - bfa_os_assign(fcport->qos_attr, pevent->link_state.qos_attr); - bfa_os_assign(fcport->qos_vc_attr, pevent->link_state.qos_vc_attr); + bfa_os_assign(pport->qos_attr, pevent->link_state.qos_attr); + bfa_os_assign(pport->qos_vc_attr, pevent->link_state.qos_vc_attr); - bfa_trc(fcport->bfa, fcport->speed); - bfa_trc(fcport->bfa, fcport->topology); + bfa_trc(pport->bfa, pport->speed); + bfa_trc(pport->bfa, pport->topology); } static void -bfa_fcport_reset_linkinfo(struct bfa_fcport_s *fcport) +bfa_pport_reset_linkinfo(struct bfa_pport_s *pport) { - fcport->speed = BFA_PPORT_SPEED_UNKNOWN; - fcport->topology = BFA_PPORT_TOPOLOGY_NONE; + pport->speed = BFA_PPORT_SPEED_UNKNOWN; + pport->topology = BFA_PPORT_TOPOLOGY_NONE; } /** * Send port enable message to firmware. */ static bfa_boolean_t -bfa_fcport_send_enable(struct bfa_fcport_s *fcport) +bfa_pport_send_enable(struct bfa_pport_s *port) { - struct bfi_fcport_enable_req_s *m; + struct bfi_pport_enable_req_s *m; /** * Increment message tag before queue check, so that responses to old * requests are discarded. */ - fcport->msgtag++; + port->msgtag++; /** * check for room in queue to send request now */ - m = bfa_reqq_next(fcport->bfa, BFA_REQQ_PORT); + m = bfa_reqq_next(port->bfa, BFA_REQQ_PORT); if (!m) { - bfa_reqq_wait(fcport->bfa, BFA_REQQ_PORT, - &fcport->reqq_wait); + bfa_reqq_wait(port->bfa, BFA_REQQ_PORT, &port->reqq_wait); return BFA_FALSE; } - bfi_h2i_set(m->mh, BFI_MC_FCPORT, BFI_FCPORT_H2I_ENABLE_REQ, - bfa_lpuid(fcport->bfa)); - m->nwwn = fcport->nwwn; - m->pwwn = fcport->pwwn; - m->port_cfg = fcport->cfg; - m->msgtag = fcport->msgtag; - m->port_cfg.maxfrsize = bfa_os_htons(fcport->cfg.maxfrsize); - bfa_dma_be_addr_set(m->stats_dma_addr, fcport->stats_pa); - bfa_trc(fcport->bfa, m->stats_dma_addr.a32.addr_lo); - bfa_trc(fcport->bfa, m->stats_dma_addr.a32.addr_hi); + bfi_h2i_set(m->mh, BFI_MC_FC_PORT, BFI_PPORT_H2I_ENABLE_REQ, + bfa_lpuid(port->bfa)); + m->nwwn = port->nwwn; + m->pwwn = port->pwwn; + m->port_cfg = port->cfg; + m->msgtag = port->msgtag; + m->port_cfg.maxfrsize = bfa_os_htons(port->cfg.maxfrsize); + bfa_dma_be_addr_set(m->stats_dma_addr, port->stats_pa); + bfa_trc(port->bfa, m->stats_dma_addr.a32.addr_lo); + bfa_trc(port->bfa, m->stats_dma_addr.a32.addr_hi); /** * queue I/O message to firmware */ - bfa_reqq_produce(fcport->bfa, BFA_REQQ_PORT); + bfa_reqq_produce(port->bfa, BFA_REQQ_PORT); return BFA_TRUE; } @@ -1037,226 +826,74 @@ bfa_fcport_send_enable(struct bfa_fcport_s *fcport) * Send port disable message to firmware. */ static bfa_boolean_t -bfa_fcport_send_disable(struct bfa_fcport_s *fcport) +bfa_pport_send_disable(struct bfa_pport_s *port) { - struct bfi_fcport_req_s *m; + bfi_pport_disable_req_t *m; /** * Increment message tag before queue check, so that responses to old * requests are discarded. */ - fcport->msgtag++; + port->msgtag++; /** * check for room in queue to send request now */ - m = bfa_reqq_next(fcport->bfa, BFA_REQQ_PORT); + m = bfa_reqq_next(port->bfa, BFA_REQQ_PORT); if (!m) { - bfa_reqq_wait(fcport->bfa, BFA_REQQ_PORT, - &fcport->reqq_wait); + bfa_reqq_wait(port->bfa, BFA_REQQ_PORT, &port->reqq_wait); return BFA_FALSE; } - bfi_h2i_set(m->mh, BFI_MC_FCPORT, BFI_FCPORT_H2I_DISABLE_REQ, - bfa_lpuid(fcport->bfa)); - m->msgtag = fcport->msgtag; + bfi_h2i_set(m->mh, BFI_MC_FC_PORT, BFI_PPORT_H2I_DISABLE_REQ, + bfa_lpuid(port->bfa)); + m->msgtag = port->msgtag; /** * queue I/O message to firmware */ - bfa_reqq_produce(fcport->bfa, BFA_REQQ_PORT); + bfa_reqq_produce(port->bfa, BFA_REQQ_PORT); return BFA_TRUE; } static void -bfa_fcport_set_wwns(struct bfa_fcport_s *fcport) +bfa_pport_set_wwns(struct bfa_pport_s *port) { - fcport->pwwn = bfa_ioc_get_pwwn(&fcport->bfa->ioc); - fcport->nwwn = bfa_ioc_get_nwwn(&fcport->bfa->ioc); + port->pwwn = bfa_ioc_get_pwwn(&port->bfa->ioc); + port->nwwn = bfa_ioc_get_nwwn(&port->bfa->ioc); - bfa_trc(fcport->bfa, fcport->pwwn); - bfa_trc(fcport->bfa, fcport->nwwn); + bfa_trc(port->bfa, port->pwwn); + bfa_trc(port->bfa, port->nwwn); } static void -bfa_fcport_send_txcredit(void *port_cbarg) +bfa_port_send_txcredit(void *port_cbarg) { - struct bfa_fcport_s *fcport = port_cbarg; - struct bfi_fcport_set_svc_params_req_s *m; + struct bfa_pport_s *port = port_cbarg; + struct bfi_pport_set_svc_params_req_s *m; /** * check for room in queue to send request now */ - m = bfa_reqq_next(fcport->bfa, BFA_REQQ_PORT); + m = bfa_reqq_next(port->bfa, BFA_REQQ_PORT); if (!m) { - bfa_trc(fcport->bfa, fcport->cfg.tx_bbcredit); + bfa_trc(port->bfa, port->cfg.tx_bbcredit); return; } - bfi_h2i_set(m->mh, BFI_MC_FCPORT, BFI_FCPORT_H2I_SET_SVC_PARAMS_REQ, - bfa_lpuid(fcport->bfa)); - m->tx_bbcredit = bfa_os_htons((u16) fcport->cfg.tx_bbcredit); + bfi_h2i_set(m->mh, BFI_MC_FC_PORT, BFI_PPORT_H2I_SET_SVC_PARAMS_REQ, + bfa_lpuid(port->bfa)); + m->tx_bbcredit = bfa_os_htons((u16) port->cfg.tx_bbcredit); /** * queue I/O message to firmware */ - bfa_reqq_produce(fcport->bfa, BFA_REQQ_PORT); + bfa_reqq_produce(port->bfa, BFA_REQQ_PORT); } -static void -bfa_fcport_qos_stats_swap(struct bfa_qos_stats_s *d, - struct bfa_qos_stats_s *s) -{ - u32 *dip = (u32 *) d; - u32 *sip = (u32 *) s; - int i; - - /* Now swap the 32 bit fields */ - for (i = 0; i < (sizeof(struct bfa_qos_stats_s)/sizeof(u32)); ++i) - dip[i] = bfa_os_ntohl(sip[i]); -} -static void -bfa_fcport_fcoe_stats_swap(struct bfa_fcoe_stats_s *d, - struct bfa_fcoe_stats_s *s) -{ - u32 *dip = (u32 *) d; - u32 *sip = (u32 *) s; - int i; - - for (i = 0; i < ((sizeof(struct bfa_fcoe_stats_s))/sizeof(u32)); - i = i + 2) { -#ifdef __BIGENDIAN - dip[i] = bfa_os_ntohl(sip[i]); - dip[i + 1] = bfa_os_ntohl(sip[i + 1]); -#else - dip[i] = bfa_os_ntohl(sip[i + 1]); - dip[i + 1] = bfa_os_ntohl(sip[i]); -#endif - } -} - -static void -__bfa_cb_fcport_stats_get(void *cbarg, bfa_boolean_t complete) -{ - struct bfa_fcport_s *fcport = cbarg; - - if (complete) { - if (fcport->stats_status == BFA_STATUS_OK) { - - /* Swap FC QoS or FCoE stats */ - if (bfa_ioc_get_fcmode(&fcport->bfa->ioc)) - bfa_fcport_qos_stats_swap( - &fcport->stats_ret->fcqos, - &fcport->stats->fcqos); - else - bfa_fcport_fcoe_stats_swap( - &fcport->stats_ret->fcoe, - &fcport->stats->fcoe); - } - fcport->stats_cbfn(fcport->stats_cbarg, fcport->stats_status); - } else { - fcport->stats_busy = BFA_FALSE; - fcport->stats_status = BFA_STATUS_OK; - } -} - -static void -bfa_fcport_stats_get_timeout(void *cbarg) -{ - struct bfa_fcport_s *fcport = (struct bfa_fcport_s *) cbarg; - - bfa_trc(fcport->bfa, fcport->stats_qfull); - - if (fcport->stats_qfull) { - bfa_reqq_wcancel(&fcport->stats_reqq_wait); - fcport->stats_qfull = BFA_FALSE; - } - - fcport->stats_status = BFA_STATUS_ETIMER; - bfa_cb_queue(fcport->bfa, &fcport->hcb_qe, __bfa_cb_fcport_stats_get, - fcport); -} - -static void -bfa_fcport_send_stats_get(void *cbarg) -{ - struct bfa_fcport_s *fcport = (struct bfa_fcport_s *) cbarg; - struct bfi_fcport_req_s *msg; - - msg = bfa_reqq_next(fcport->bfa, BFA_REQQ_PORT); - - if (!msg) { - fcport->stats_qfull = BFA_TRUE; - bfa_reqq_winit(&fcport->stats_reqq_wait, - bfa_fcport_send_stats_get, fcport); - bfa_reqq_wait(fcport->bfa, BFA_REQQ_PORT, - &fcport->stats_reqq_wait); - return; - } - fcport->stats_qfull = BFA_FALSE; - - bfa_os_memset(msg, 0, sizeof(struct bfi_fcport_req_s)); - bfi_h2i_set(msg->mh, BFI_MC_FCPORT, BFI_FCPORT_H2I_STATS_GET_REQ, - bfa_lpuid(fcport->bfa)); - bfa_reqq_produce(fcport->bfa, BFA_REQQ_PORT); -} - -static void -__bfa_cb_fcport_stats_clr(void *cbarg, bfa_boolean_t complete) -{ - struct bfa_fcport_s *fcport = cbarg; - - if (complete) { - fcport->stats_cbfn(fcport->stats_cbarg, fcport->stats_status); - } else { - fcport->stats_busy = BFA_FALSE; - fcport->stats_status = BFA_STATUS_OK; - } -} - -static void -bfa_fcport_stats_clr_timeout(void *cbarg) -{ - struct bfa_fcport_s *fcport = (struct bfa_fcport_s *) cbarg; - - bfa_trc(fcport->bfa, fcport->stats_qfull); - - if (fcport->stats_qfull) { - bfa_reqq_wcancel(&fcport->stats_reqq_wait); - fcport->stats_qfull = BFA_FALSE; - } - - fcport->stats_status = BFA_STATUS_ETIMER; - bfa_cb_queue(fcport->bfa, &fcport->hcb_qe, - __bfa_cb_fcport_stats_clr, fcport); -} - -static void -bfa_fcport_send_stats_clear(void *cbarg) -{ - struct bfa_fcport_s *fcport = (struct bfa_fcport_s *) cbarg; - struct bfi_fcport_req_s *msg; - - msg = bfa_reqq_next(fcport->bfa, BFA_REQQ_PORT); - - if (!msg) { - fcport->stats_qfull = BFA_TRUE; - bfa_reqq_winit(&fcport->stats_reqq_wait, - bfa_fcport_send_stats_clear, fcport); - bfa_reqq_wait(fcport->bfa, BFA_REQQ_PORT, - &fcport->stats_reqq_wait); - return; - } - fcport->stats_qfull = BFA_FALSE; - - bfa_os_memset(msg, 0, sizeof(struct bfi_fcport_req_s)); - bfi_h2i_set(msg->mh, BFI_MC_FCPORT, BFI_FCPORT_H2I_STATS_CLEAR_REQ, - bfa_lpuid(fcport->bfa)); - bfa_reqq_produce(fcport->bfa, BFA_REQQ_PORT); -} /** * bfa_pport_public @@ -1266,32 +903,32 @@ bfa_fcport_send_stats_clear(void *cbarg) * Firmware message handler. */ void -bfa_fcport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg) +bfa_pport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); - union bfi_fcport_i2h_msg_u i2hmsg; + struct bfa_pport_s *pport = BFA_PORT_MOD(bfa); + union bfi_pport_i2h_msg_u i2hmsg; i2hmsg.msg = msg; - fcport->event_arg.i2hmsg = i2hmsg; + pport->event_arg.i2hmsg = i2hmsg; switch (msg->mhdr.msg_id) { - case BFI_FCPORT_I2H_ENABLE_RSP: - if (fcport->msgtag == i2hmsg.penable_rsp->msgtag) - bfa_sm_send_event(fcport, BFA_FCPORT_SM_FWRSP); + case BFI_PPORT_I2H_ENABLE_RSP: + if (pport->msgtag == i2hmsg.enable_rsp->msgtag) + bfa_sm_send_event(pport, BFA_PPORT_SM_FWRSP); break; - case BFI_FCPORT_I2H_DISABLE_RSP: - if (fcport->msgtag == i2hmsg.penable_rsp->msgtag) - bfa_sm_send_event(fcport, BFA_FCPORT_SM_FWRSP); + case BFI_PPORT_I2H_DISABLE_RSP: + if (pport->msgtag == i2hmsg.enable_rsp->msgtag) + bfa_sm_send_event(pport, BFA_PPORT_SM_FWRSP); break; - case BFI_FCPORT_I2H_EVENT: + case BFI_PPORT_I2H_EVENT: switch (i2hmsg.event->link_state.linkstate) { case BFA_PPORT_LINKUP: - bfa_sm_send_event(fcport, BFA_FCPORT_SM_LINKUP); + bfa_sm_send_event(pport, BFA_PPORT_SM_LINKUP); break; case BFA_PPORT_LINKDOWN: - bfa_sm_send_event(fcport, BFA_FCPORT_SM_LINKDOWN); + bfa_sm_send_event(pport, BFA_PPORT_SM_LINKDOWN); break; case BFA_PPORT_TRUNK_LINKDOWN: /** todo: event notification */ @@ -1299,40 +936,42 @@ bfa_fcport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg) } break; - case BFI_FCPORT_I2H_STATS_GET_RSP: + case BFI_PPORT_I2H_GET_STATS_RSP: + case BFI_PPORT_I2H_GET_QOS_STATS_RSP: /* * check for timer pop before processing the rsp */ - if (fcport->stats_busy == BFA_FALSE || - fcport->stats_status == BFA_STATUS_ETIMER) + if (pport->stats_busy == BFA_FALSE + || pport->stats_status == BFA_STATUS_ETIMER) break; - bfa_timer_stop(&fcport->timer); - fcport->stats_status = i2hmsg.pstatsget_rsp->status; - bfa_cb_queue(fcport->bfa, &fcport->hcb_qe, - __bfa_cb_fcport_stats_get, fcport); + bfa_timer_stop(&pport->timer); + pport->stats_status = i2hmsg.getstats_rsp->status; + bfa_cb_queue(pport->bfa, &pport->hcb_qe, __bfa_cb_port_stats, + pport); break; - - case BFI_FCPORT_I2H_STATS_CLEAR_RSP: + case BFI_PPORT_I2H_CLEAR_STATS_RSP: + case BFI_PPORT_I2H_CLEAR_QOS_STATS_RSP: /* * check for timer pop before processing the rsp */ - if (fcport->stats_busy == BFA_FALSE || - fcport->stats_status == BFA_STATUS_ETIMER) + if (pport->stats_busy == BFA_FALSE + || pport->stats_status == BFA_STATUS_ETIMER) break; - bfa_timer_stop(&fcport->timer); - fcport->stats_status = BFA_STATUS_OK; - bfa_cb_queue(fcport->bfa, &fcport->hcb_qe, - __bfa_cb_fcport_stats_clr, fcport); + bfa_timer_stop(&pport->timer); + pport->stats_status = BFA_STATUS_OK; + bfa_cb_queue(pport->bfa, &pport->hcb_qe, + __bfa_cb_port_stats_clr, pport); break; default: bfa_assert(0); - break; } } + + /** * bfa_pport_api */ @@ -1341,35 +980,35 @@ bfa_fcport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg) * Registered callback for port events. */ void -bfa_fcport_event_register(struct bfa_s *bfa, +bfa_pport_event_register(struct bfa_s *bfa, void (*cbfn) (void *cbarg, bfa_pport_event_t event), void *cbarg) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); + struct bfa_pport_s *pport = BFA_PORT_MOD(bfa); - fcport->event_cbfn = cbfn; - fcport->event_cbarg = cbarg; + pport->event_cbfn = cbfn; + pport->event_cbarg = cbarg; } bfa_status_t -bfa_fcport_enable(struct bfa_s *bfa) +bfa_pport_enable(struct bfa_s *bfa) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); + struct bfa_pport_s *pport = BFA_PORT_MOD(bfa); - if (fcport->diag_busy) + if (pport->diag_busy) return BFA_STATUS_DIAG_BUSY; else if (bfa_sm_cmp_state - (BFA_FCPORT_MOD(bfa), bfa_fcport_sm_disabling_qwait)) + (BFA_PORT_MOD(bfa), bfa_pport_sm_disabling_qwait)) return BFA_STATUS_DEVBUSY; - bfa_sm_send_event(BFA_FCPORT_MOD(bfa), BFA_FCPORT_SM_ENABLE); + bfa_sm_send_event(BFA_PORT_MOD(bfa), BFA_PPORT_SM_ENABLE); return BFA_STATUS_OK; } bfa_status_t -bfa_fcport_disable(struct bfa_s *bfa) +bfa_pport_disable(struct bfa_s *bfa) { - bfa_sm_send_event(BFA_FCPORT_MOD(bfa), BFA_FCPORT_SM_DISABLE); + bfa_sm_send_event(BFA_PORT_MOD(bfa), BFA_PPORT_SM_DISABLE); return BFA_STATUS_OK; } @@ -1377,18 +1016,18 @@ bfa_fcport_disable(struct bfa_s *bfa) * Configure port speed. */ bfa_status_t -bfa_fcport_cfg_speed(struct bfa_s *bfa, enum bfa_pport_speed speed) +bfa_pport_cfg_speed(struct bfa_s *bfa, enum bfa_pport_speed speed) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); + struct bfa_pport_s *pport = BFA_PORT_MOD(bfa); bfa_trc(bfa, speed); - if ((speed != BFA_PPORT_SPEED_AUTO) && (speed > fcport->speed_sup)) { - bfa_trc(bfa, fcport->speed_sup); + if ((speed != BFA_PPORT_SPEED_AUTO) && (speed > pport->speed_sup)) { + bfa_trc(bfa, pport->speed_sup); return BFA_STATUS_UNSUPP_SPEED; } - fcport->cfg.speed = speed; + pport->cfg.speed = speed; return BFA_STATUS_OK; } @@ -1397,23 +1036,23 @@ bfa_fcport_cfg_speed(struct bfa_s *bfa, enum bfa_pport_speed speed) * Get current speed. */ enum bfa_pport_speed -bfa_fcport_get_speed(struct bfa_s *bfa) +bfa_pport_get_speed(struct bfa_s *bfa) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); + struct bfa_pport_s *port = BFA_PORT_MOD(bfa); - return fcport->speed; + return port->speed; } /** * Configure port topology. */ bfa_status_t -bfa_fcport_cfg_topology(struct bfa_s *bfa, enum bfa_pport_topology topology) +bfa_pport_cfg_topology(struct bfa_s *bfa, enum bfa_pport_topology topology) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); + struct bfa_pport_s *pport = BFA_PORT_MOD(bfa); bfa_trc(bfa, topology); - bfa_trc(bfa, fcport->cfg.topology); + bfa_trc(bfa, pport->cfg.topology); switch (topology) { case BFA_PPORT_TOPOLOGY_P2P: @@ -1425,7 +1064,7 @@ bfa_fcport_cfg_topology(struct bfa_s *bfa, enum bfa_pport_topology topology) return BFA_STATUS_EINVAL; } - fcport->cfg.topology = topology; + pport->cfg.topology = topology; return BFA_STATUS_OK; } @@ -1433,64 +1072,64 @@ bfa_fcport_cfg_topology(struct bfa_s *bfa, enum bfa_pport_topology topology) * Get current topology. */ enum bfa_pport_topology -bfa_fcport_get_topology(struct bfa_s *bfa) +bfa_pport_get_topology(struct bfa_s *bfa) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); + struct bfa_pport_s *port = BFA_PORT_MOD(bfa); - return fcport->topology; + return port->topology; } bfa_status_t -bfa_fcport_cfg_hardalpa(struct bfa_s *bfa, u8 alpa) +bfa_pport_cfg_hardalpa(struct bfa_s *bfa, u8 alpa) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); + struct bfa_pport_s *pport = BFA_PORT_MOD(bfa); bfa_trc(bfa, alpa); - bfa_trc(bfa, fcport->cfg.cfg_hardalpa); - bfa_trc(bfa, fcport->cfg.hardalpa); + bfa_trc(bfa, pport->cfg.cfg_hardalpa); + bfa_trc(bfa, pport->cfg.hardalpa); - fcport->cfg.cfg_hardalpa = BFA_TRUE; - fcport->cfg.hardalpa = alpa; + pport->cfg.cfg_hardalpa = BFA_TRUE; + pport->cfg.hardalpa = alpa; return BFA_STATUS_OK; } bfa_status_t -bfa_fcport_clr_hardalpa(struct bfa_s *bfa) +bfa_pport_clr_hardalpa(struct bfa_s *bfa) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); + struct bfa_pport_s *pport = BFA_PORT_MOD(bfa); - bfa_trc(bfa, fcport->cfg.cfg_hardalpa); - bfa_trc(bfa, fcport->cfg.hardalpa); + bfa_trc(bfa, pport->cfg.cfg_hardalpa); + bfa_trc(bfa, pport->cfg.hardalpa); - fcport->cfg.cfg_hardalpa = BFA_FALSE; + pport->cfg.cfg_hardalpa = BFA_FALSE; return BFA_STATUS_OK; } bfa_boolean_t -bfa_fcport_get_hardalpa(struct bfa_s *bfa, u8 *alpa) +bfa_pport_get_hardalpa(struct bfa_s *bfa, u8 *alpa) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); + struct bfa_pport_s *port = BFA_PORT_MOD(bfa); - *alpa = fcport->cfg.hardalpa; - return fcport->cfg.cfg_hardalpa; + *alpa = port->cfg.hardalpa; + return port->cfg.cfg_hardalpa; } u8 -bfa_fcport_get_myalpa(struct bfa_s *bfa) +bfa_pport_get_myalpa(struct bfa_s *bfa) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); + struct bfa_pport_s *port = BFA_PORT_MOD(bfa); - return fcport->myalpa; + return port->myalpa; } bfa_status_t -bfa_fcport_cfg_maxfrsize(struct bfa_s *bfa, u16 maxfrsize) +bfa_pport_cfg_maxfrsize(struct bfa_s *bfa, u16 maxfrsize) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); + struct bfa_pport_s *pport = BFA_PORT_MOD(bfa); bfa_trc(bfa, maxfrsize); - bfa_trc(bfa, fcport->cfg.maxfrsize); + bfa_trc(bfa, pport->cfg.maxfrsize); /* * with in range @@ -1504,41 +1143,41 @@ bfa_fcport_cfg_maxfrsize(struct bfa_s *bfa, u16 maxfrsize) if ((maxfrsize != FC_MAX_PDUSZ) && (maxfrsize & (maxfrsize - 1))) return BFA_STATUS_INVLD_DFSZ; - fcport->cfg.maxfrsize = maxfrsize; + pport->cfg.maxfrsize = maxfrsize; return BFA_STATUS_OK; } u16 -bfa_fcport_get_maxfrsize(struct bfa_s *bfa) +bfa_pport_get_maxfrsize(struct bfa_s *bfa) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); + struct bfa_pport_s *port = BFA_PORT_MOD(bfa); - return fcport->cfg.maxfrsize; + return port->cfg.maxfrsize; } u32 -bfa_fcport_mypid(struct bfa_s *bfa) +bfa_pport_mypid(struct bfa_s *bfa) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); + struct bfa_pport_s *port = BFA_PORT_MOD(bfa); - return fcport->mypid; + return port->mypid; } u8 -bfa_fcport_get_rx_bbcredit(struct bfa_s *bfa) +bfa_pport_get_rx_bbcredit(struct bfa_s *bfa) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); + struct bfa_pport_s *port = BFA_PORT_MOD(bfa); - return fcport->cfg.rx_bbcredit; + return port->cfg.rx_bbcredit; } void -bfa_fcport_set_tx_bbcredit(struct bfa_s *bfa, u16 tx_bbcredit) +bfa_pport_set_tx_bbcredit(struct bfa_s *bfa, u16 tx_bbcredit) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); + struct bfa_pport_s *port = BFA_PORT_MOD(bfa); - fcport->cfg.tx_bbcredit = (u8) tx_bbcredit; - bfa_fcport_send_txcredit(fcport); + port->cfg.tx_bbcredit = (u8) tx_bbcredit; + bfa_port_send_txcredit(port); } /** @@ -1546,192 +1185,302 @@ bfa_fcport_set_tx_bbcredit(struct bfa_s *bfa, u16 tx_bbcredit) */ wwn_t -bfa_fcport_get_wwn(struct bfa_s *bfa, bfa_boolean_t node) +bfa_pport_get_wwn(struct bfa_s *bfa, bfa_boolean_t node) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); + struct bfa_pport_s *pport = BFA_PORT_MOD(bfa); if (node) - return fcport->nwwn; + return pport->nwwn; else - return fcport->pwwn; + return pport->pwwn; } void -bfa_fcport_get_attr(struct bfa_s *bfa, struct bfa_pport_attr_s *attr) +bfa_pport_get_attr(struct bfa_s *bfa, struct bfa_pport_attr_s *attr) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); + struct bfa_pport_s *pport = BFA_PORT_MOD(bfa); bfa_os_memset(attr, 0, sizeof(struct bfa_pport_attr_s)); - attr->nwwn = fcport->nwwn; - attr->pwwn = fcport->pwwn; + attr->nwwn = pport->nwwn; + attr->pwwn = pport->pwwn; - bfa_os_memcpy(&attr->pport_cfg, &fcport->cfg, + bfa_os_memcpy(&attr->pport_cfg, &pport->cfg, sizeof(struct bfa_pport_cfg_s)); /* * speed attributes */ - attr->pport_cfg.speed = fcport->cfg.speed; - attr->speed_supported = fcport->speed_sup; - attr->speed = fcport->speed; + attr->pport_cfg.speed = pport->cfg.speed; + attr->speed_supported = pport->speed_sup; + attr->speed = pport->speed; attr->cos_supported = FC_CLASS_3; /* * topology attributes */ - attr->pport_cfg.topology = fcport->cfg.topology; - attr->topology = fcport->topology; + attr->pport_cfg.topology = pport->cfg.topology; + attr->topology = pport->topology; /* * beacon attributes */ - attr->beacon = fcport->beacon; - attr->link_e2e_beacon = fcport->link_e2e_beacon; - attr->plog_enabled = bfa_plog_get_setting(fcport->bfa->plog); + attr->beacon = pport->beacon; + attr->link_e2e_beacon = pport->link_e2e_beacon; + attr->plog_enabled = bfa_plog_get_setting(pport->bfa->plog); attr->pport_cfg.path_tov = bfa_fcpim_path_tov_get(bfa); attr->pport_cfg.q_depth = bfa_fcpim_qdepth_get(bfa); - attr->port_state = bfa_sm_to_state(hal_pport_sm_table, fcport->sm); - if (bfa_ioc_is_disabled(&fcport->bfa->ioc)) + attr->port_state = bfa_sm_to_state(hal_pport_sm_table, pport->sm); + if (bfa_ioc_is_disabled(&pport->bfa->ioc)) attr->port_state = BFA_PPORT_ST_IOCDIS; - else if (bfa_ioc_fw_mismatch(&fcport->bfa->ioc)) + else if (bfa_ioc_fw_mismatch(&pport->bfa->ioc)) attr->port_state = BFA_PPORT_ST_FWMISMATCH; } -#define BFA_FCPORT_STATS_TOV 1000 +static void +bfa_port_stats_query(void *cbarg) +{ + struct bfa_pport_s *port = (struct bfa_pport_s *)cbarg; + bfi_pport_get_stats_req_t *msg; -/** - * Fetch port attributes (FCQoS or FCoE). - */ -bfa_status_t -bfa_fcport_get_stats(struct bfa_s *bfa, union bfa_fcport_stats_u *stats, - bfa_cb_pport_t cbfn, void *cbarg) + msg = bfa_reqq_next(port->bfa, BFA_REQQ_PORT); + + if (!msg) { + port->stats_qfull = BFA_TRUE; + bfa_reqq_winit(&port->stats_reqq_wait, bfa_port_stats_query, + port); + bfa_reqq_wait(port->bfa, BFA_REQQ_PORT, &port->stats_reqq_wait); + return; + } + port->stats_qfull = BFA_FALSE; + + bfa_os_memset(msg, 0, sizeof(bfi_pport_get_stats_req_t)); + bfi_h2i_set(msg->mh, BFI_MC_FC_PORT, BFI_PPORT_H2I_GET_STATS_REQ, + bfa_lpuid(port->bfa)); + bfa_reqq_produce(port->bfa, BFA_REQQ_PORT); + + return; +} + +static void +bfa_port_stats_clear(void *cbarg) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); + struct bfa_pport_s *port = (struct bfa_pport_s *)cbarg; + bfi_pport_clear_stats_req_t *msg; - if (fcport->stats_busy) { - bfa_trc(bfa, fcport->stats_busy); - return BFA_STATUS_DEVBUSY; + msg = bfa_reqq_next(port->bfa, BFA_REQQ_PORT); + + if (!msg) { + port->stats_qfull = BFA_TRUE; + bfa_reqq_winit(&port->stats_reqq_wait, bfa_port_stats_clear, + port); + bfa_reqq_wait(port->bfa, BFA_REQQ_PORT, &port->stats_reqq_wait); + return; } + port->stats_qfull = BFA_FALSE; - fcport->stats_busy = BFA_TRUE; - fcport->stats_ret = stats; - fcport->stats_cbfn = cbfn; - fcport->stats_cbarg = cbarg; + bfa_os_memset(msg, 0, sizeof(bfi_pport_clear_stats_req_t)); + bfi_h2i_set(msg->mh, BFI_MC_FC_PORT, BFI_PPORT_H2I_CLEAR_STATS_REQ, + bfa_lpuid(port->bfa)); + bfa_reqq_produce(port->bfa, BFA_REQQ_PORT); + return; +} - bfa_fcport_send_stats_get(fcport); +static void +bfa_port_qos_stats_clear(void *cbarg) +{ + struct bfa_pport_s *port = (struct bfa_pport_s *)cbarg; + bfi_pport_clear_qos_stats_req_t *msg; - bfa_timer_start(bfa, &fcport->timer, bfa_fcport_stats_get_timeout, - fcport, BFA_FCPORT_STATS_TOV); - return BFA_STATUS_OK; + msg = bfa_reqq_next(port->bfa, BFA_REQQ_PORT); + + if (!msg) { + port->stats_qfull = BFA_TRUE; + bfa_reqq_winit(&port->stats_reqq_wait, bfa_port_qos_stats_clear, + port); + bfa_reqq_wait(port->bfa, BFA_REQQ_PORT, &port->stats_reqq_wait); + return; + } + port->stats_qfull = BFA_FALSE; + + bfa_os_memset(msg, 0, sizeof(bfi_pport_clear_qos_stats_req_t)); + bfi_h2i_set(msg->mh, BFI_MC_FC_PORT, BFI_PPORT_H2I_CLEAR_QOS_STATS_REQ, + bfa_lpuid(port->bfa)); + bfa_reqq_produce(port->bfa, BFA_REQQ_PORT); + return; } -/** - * Reset port statistics (FCQoS or FCoE). - */ -bfa_status_t -bfa_fcport_clear_stats(struct bfa_s *bfa, bfa_cb_pport_t cbfn, void *cbarg) +static void +bfa_pport_stats_swap(union bfa_pport_stats_u *d, union bfa_pport_stats_u *s) +{ + u32 *dip = (u32 *) d; + u32 *sip = (u32 *) s; + int i; + + /* + * Do 64 bit fields swap first + */ + for (i = 0; + i < + ((sizeof(union bfa_pport_stats_u) - + sizeof(struct bfa_qos_stats_s)) / sizeof(u32)); i = i + 2) { +#ifdef __BIGENDIAN + dip[i] = bfa_os_ntohl(sip[i]); + dip[i + 1] = bfa_os_ntohl(sip[i + 1]); +#else + dip[i] = bfa_os_ntohl(sip[i + 1]); + dip[i + 1] = bfa_os_ntohl(sip[i]); +#endif + } + + /* + * Now swap the 32 bit fields + */ + for (; i < (sizeof(union bfa_pport_stats_u) / sizeof(u32)); ++i) + dip[i] = bfa_os_ntohl(sip[i]); +} + +static void +__bfa_cb_port_stats_clr(void *cbarg, bfa_boolean_t complete) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); + struct bfa_pport_s *port = cbarg; - if (fcport->stats_busy) { - bfa_trc(bfa, fcport->stats_busy); - return BFA_STATUS_DEVBUSY; + if (complete) { + port->stats_cbfn(port->stats_cbarg, port->stats_status); + } else { + port->stats_busy = BFA_FALSE; + port->stats_status = BFA_STATUS_OK; } +} + +static void +bfa_port_stats_clr_timeout(void *cbarg) +{ + struct bfa_pport_s *port = (struct bfa_pport_s *)cbarg; - fcport->stats_busy = BFA_TRUE; - fcport->stats_cbfn = cbfn; - fcport->stats_cbarg = cbarg; + bfa_trc(port->bfa, port->stats_qfull); - bfa_fcport_send_stats_clear(fcport); + if (port->stats_qfull) { + bfa_reqq_wcancel(&port->stats_reqq_wait); + port->stats_qfull = BFA_FALSE; + } - bfa_timer_start(bfa, &fcport->timer, bfa_fcport_stats_clr_timeout, - fcport, BFA_FCPORT_STATS_TOV); - return BFA_STATUS_OK; + port->stats_status = BFA_STATUS_ETIMER; + bfa_cb_queue(port->bfa, &port->hcb_qe, __bfa_cb_port_stats_clr, port); } -/** - * Fetch FCQoS port statistics - */ -bfa_status_t -bfa_fcport_get_qos_stats(struct bfa_s *bfa, union bfa_fcport_stats_u *stats, - bfa_cb_pport_t cbfn, void *cbarg) +static void +__bfa_cb_port_stats(void *cbarg, bfa_boolean_t complete) { - /* Meaningful only for FC mode */ - bfa_assert(bfa_ioc_get_fcmode(&bfa->ioc)); + struct bfa_pport_s *port = cbarg; - return bfa_fcport_get_stats(bfa, stats, cbfn, cbarg); + if (complete) { + if (port->stats_status == BFA_STATUS_OK) + bfa_pport_stats_swap(port->stats_ret, port->stats); + port->stats_cbfn(port->stats_cbarg, port->stats_status); + } else { + port->stats_busy = BFA_FALSE; + port->stats_status = BFA_STATUS_OK; + } } -/** - * Reset FCoE port statistics - */ -bfa_status_t -bfa_fcport_clear_qos_stats(struct bfa_s *bfa, bfa_cb_pport_t cbfn, void *cbarg) +static void +bfa_port_stats_timeout(void *cbarg) { - /* Meaningful only for FC mode */ - bfa_assert(bfa_ioc_get_fcmode(&bfa->ioc)); + struct bfa_pport_s *port = (struct bfa_pport_s *)cbarg; + + bfa_trc(port->bfa, port->stats_qfull); - return bfa_fcport_clear_stats(bfa, cbfn, cbarg); + if (port->stats_qfull) { + bfa_reqq_wcancel(&port->stats_reqq_wait); + port->stats_qfull = BFA_FALSE; + } + + port->stats_status = BFA_STATUS_ETIMER; + bfa_cb_queue(port->bfa, &port->hcb_qe, __bfa_cb_port_stats, port); } +#define BFA_PORT_STATS_TOV 1000 + /** - * Fetch FCQoS port statistics + * Fetch port attributes. */ bfa_status_t -bfa_fcport_get_fcoe_stats(struct bfa_s *bfa, union bfa_fcport_stats_u *stats, - bfa_cb_pport_t cbfn, void *cbarg) +bfa_pport_get_stats(struct bfa_s *bfa, union bfa_pport_stats_u *stats, + bfa_cb_pport_t cbfn, void *cbarg) { - /* Meaningful only for FCoE mode */ - bfa_assert(!bfa_ioc_get_fcmode(&bfa->ioc)); + struct bfa_pport_s *port = BFA_PORT_MOD(bfa); + + if (port->stats_busy) { + bfa_trc(bfa, port->stats_busy); + return BFA_STATUS_DEVBUSY; + } + + port->stats_busy = BFA_TRUE; + port->stats_ret = stats; + port->stats_cbfn = cbfn; + port->stats_cbarg = cbarg; + + bfa_port_stats_query(port); - return bfa_fcport_get_stats(bfa, stats, cbfn, cbarg); + bfa_timer_start(bfa, &port->timer, bfa_port_stats_timeout, port, + BFA_PORT_STATS_TOV); + return BFA_STATUS_OK; } -/** - * Reset FCoE port statistics - */ bfa_status_t -bfa_fcport_clear_fcoe_stats(struct bfa_s *bfa, bfa_cb_pport_t cbfn, void *cbarg) +bfa_pport_clear_stats(struct bfa_s *bfa, bfa_cb_pport_t cbfn, void *cbarg) { - /* Meaningful only for FCoE mode */ - bfa_assert(!bfa_ioc_get_fcmode(&bfa->ioc)); + struct bfa_pport_s *port = BFA_PORT_MOD(bfa); + + if (port->stats_busy) { + bfa_trc(bfa, port->stats_busy); + return BFA_STATUS_DEVBUSY; + } + + port->stats_busy = BFA_TRUE; + port->stats_cbfn = cbfn; + port->stats_cbarg = cbarg; + + bfa_port_stats_clear(port); - return bfa_fcport_clear_stats(bfa, cbfn, cbarg); + bfa_timer_start(bfa, &port->timer, bfa_port_stats_clr_timeout, port, + BFA_PORT_STATS_TOV); + return BFA_STATUS_OK; } bfa_status_t -bfa_fcport_trunk_enable(struct bfa_s *bfa, u8 bitmap) +bfa_pport_trunk_enable(struct bfa_s *bfa, u8 bitmap) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); + struct bfa_pport_s *pport = BFA_PORT_MOD(bfa); bfa_trc(bfa, bitmap); - bfa_trc(bfa, fcport->cfg.trunked); - bfa_trc(bfa, fcport->cfg.trunk_ports); + bfa_trc(bfa, pport->cfg.trunked); + bfa_trc(bfa, pport->cfg.trunk_ports); if (!bitmap || (bitmap & (bitmap - 1))) return BFA_STATUS_EINVAL; - fcport->cfg.trunked = BFA_TRUE; - fcport->cfg.trunk_ports = bitmap; + pport->cfg.trunked = BFA_TRUE; + pport->cfg.trunk_ports = bitmap; return BFA_STATUS_OK; } void -bfa_fcport_qos_get_attr(struct bfa_s *bfa, struct bfa_qos_attr_s *qos_attr) +bfa_pport_qos_get_attr(struct bfa_s *bfa, struct bfa_qos_attr_s *qos_attr) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); + struct bfa_pport_s *pport = BFA_PORT_MOD(bfa); - qos_attr->state = bfa_os_ntohl(fcport->qos_attr.state); - qos_attr->total_bb_cr = bfa_os_ntohl(fcport->qos_attr.total_bb_cr); + qos_attr->state = bfa_os_ntohl(pport->qos_attr.state); + qos_attr->total_bb_cr = bfa_os_ntohl(pport->qos_attr.total_bb_cr); } void -bfa_fcport_qos_get_vc_attr(struct bfa_s *bfa, +bfa_pport_qos_get_vc_attr(struct bfa_s *bfa, struct bfa_qos_vc_attr_s *qos_vc_attr) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); - struct bfa_qos_vc_attr_s *bfa_vc_attr = &fcport->qos_vc_attr; + struct bfa_pport_s *pport = BFA_PORT_MOD(bfa); + struct bfa_qos_vc_attr_s *bfa_vc_attr = &pport->qos_vc_attr; u32 i = 0; qos_vc_attr->total_vc_count = bfa_os_ntohs(bfa_vc_attr->total_vc_count); @@ -1753,90 +1502,120 @@ bfa_fcport_qos_get_vc_attr(struct bfa_s *bfa, } } +/** + * Fetch QoS Stats. + */ +bfa_status_t +bfa_pport_get_qos_stats(struct bfa_s *bfa, union bfa_pport_stats_u *stats, + bfa_cb_pport_t cbfn, void *cbarg) +{ + /* + * QoS stats is embedded in port stats + */ + return bfa_pport_get_stats(bfa, stats, cbfn, cbarg); +} + +bfa_status_t +bfa_pport_clear_qos_stats(struct bfa_s *bfa, bfa_cb_pport_t cbfn, void *cbarg) +{ + struct bfa_pport_s *port = BFA_PORT_MOD(bfa); + + if (port->stats_busy) { + bfa_trc(bfa, port->stats_busy); + return BFA_STATUS_DEVBUSY; + } + + port->stats_busy = BFA_TRUE; + port->stats_cbfn = cbfn; + port->stats_cbarg = cbarg; + + bfa_port_qos_stats_clear(port); + + bfa_timer_start(bfa, &port->timer, bfa_port_stats_clr_timeout, port, + BFA_PORT_STATS_TOV); + return BFA_STATUS_OK; +} + /** * Fetch port attributes. */ bfa_status_t -bfa_fcport_trunk_disable(struct bfa_s *bfa) +bfa_pport_trunk_disable(struct bfa_s *bfa) { return BFA_STATUS_OK; } bfa_boolean_t -bfa_fcport_trunk_query(struct bfa_s *bfa, u32 *bitmap) +bfa_pport_trunk_query(struct bfa_s *bfa, u32 *bitmap) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); + struct bfa_pport_s *port = BFA_PORT_MOD(bfa); - *bitmap = fcport->cfg.trunk_ports; - return fcport->cfg.trunked; + *bitmap = port->cfg.trunk_ports; + return port->cfg.trunked; } bfa_boolean_t -bfa_fcport_is_disabled(struct bfa_s *bfa) +bfa_pport_is_disabled(struct bfa_s *bfa) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); + struct bfa_pport_s *port = BFA_PORT_MOD(bfa); - return bfa_sm_to_state(hal_pport_sm_table, fcport->sm) == + return bfa_sm_to_state(hal_pport_sm_table, port->sm) == BFA_PPORT_ST_DISABLED; } bfa_boolean_t -bfa_fcport_is_ratelim(struct bfa_s *bfa) +bfa_pport_is_ratelim(struct bfa_s *bfa) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); + struct bfa_pport_s *pport = BFA_PORT_MOD(bfa); - return fcport->cfg.ratelimit ? BFA_TRUE : BFA_FALSE; + return pport->cfg.ratelimit ? BFA_TRUE : BFA_FALSE; } void -bfa_fcport_cfg_qos(struct bfa_s *bfa, bfa_boolean_t on_off) +bfa_pport_cfg_qos(struct bfa_s *bfa, bfa_boolean_t on_off) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); - enum bfa_ioc_type_e ioc_type = bfa_get_type(bfa); + struct bfa_pport_s *pport = BFA_PORT_MOD(bfa); bfa_trc(bfa, on_off); - bfa_trc(bfa, fcport->cfg.qos_enabled); - - bfa_trc(bfa, ioc_type); + bfa_trc(bfa, pport->cfg.qos_enabled); - if (ioc_type == BFA_IOC_TYPE_FC) - fcport->cfg.qos_enabled = on_off; + pport->cfg.qos_enabled = on_off; } void -bfa_fcport_cfg_ratelim(struct bfa_s *bfa, bfa_boolean_t on_off) +bfa_pport_cfg_ratelim(struct bfa_s *bfa, bfa_boolean_t on_off) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); + struct bfa_pport_s *pport = BFA_PORT_MOD(bfa); bfa_trc(bfa, on_off); - bfa_trc(bfa, fcport->cfg.ratelimit); + bfa_trc(bfa, pport->cfg.ratelimit); - fcport->cfg.ratelimit = on_off; - if (fcport->cfg.trl_def_speed == BFA_PPORT_SPEED_UNKNOWN) - fcport->cfg.trl_def_speed = BFA_PPORT_SPEED_1GBPS; + pport->cfg.ratelimit = on_off; + if (pport->cfg.trl_def_speed == BFA_PPORT_SPEED_UNKNOWN) + pport->cfg.trl_def_speed = BFA_PPORT_SPEED_1GBPS; } /** * Configure default minimum ratelim speed */ bfa_status_t -bfa_fcport_cfg_ratelim_speed(struct bfa_s *bfa, enum bfa_pport_speed speed) +bfa_pport_cfg_ratelim_speed(struct bfa_s *bfa, enum bfa_pport_speed speed) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); + struct bfa_pport_s *pport = BFA_PORT_MOD(bfa); bfa_trc(bfa, speed); /* * Auto and speeds greater than the supported speed, are invalid */ - if ((speed == BFA_PPORT_SPEED_AUTO) || (speed > fcport->speed_sup)) { - bfa_trc(bfa, fcport->speed_sup); + if ((speed == BFA_PPORT_SPEED_AUTO) || (speed > pport->speed_sup)) { + bfa_trc(bfa, pport->speed_sup); return BFA_STATUS_UNSUPP_SPEED; } - fcport->cfg.trl_def_speed = speed; + pport->cfg.trl_def_speed = speed; return BFA_STATUS_OK; } @@ -1845,45 +1624,45 @@ bfa_fcport_cfg_ratelim_speed(struct bfa_s *bfa, enum bfa_pport_speed speed) * Get default minimum ratelim speed */ enum bfa_pport_speed -bfa_fcport_get_ratelim_speed(struct bfa_s *bfa) +bfa_pport_get_ratelim_speed(struct bfa_s *bfa) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); + struct bfa_pport_s *pport = BFA_PORT_MOD(bfa); - bfa_trc(bfa, fcport->cfg.trl_def_speed); - return fcport->cfg.trl_def_speed; + bfa_trc(bfa, pport->cfg.trl_def_speed); + return pport->cfg.trl_def_speed; } void -bfa_fcport_busy(struct bfa_s *bfa, bfa_boolean_t status) +bfa_pport_busy(struct bfa_s *bfa, bfa_boolean_t status) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); + struct bfa_pport_s *pport = BFA_PORT_MOD(bfa); bfa_trc(bfa, status); - bfa_trc(bfa, fcport->diag_busy); + bfa_trc(bfa, pport->diag_busy); - fcport->diag_busy = status; + pport->diag_busy = status; } void -bfa_fcport_beacon(struct bfa_s *bfa, bfa_boolean_t beacon, +bfa_pport_beacon(struct bfa_s *bfa, bfa_boolean_t beacon, bfa_boolean_t link_e2e_beacon) { - struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); + struct bfa_pport_s *pport = BFA_PORT_MOD(bfa); bfa_trc(bfa, beacon); bfa_trc(bfa, link_e2e_beacon); - bfa_trc(bfa, fcport->beacon); - bfa_trc(bfa, fcport->link_e2e_beacon); + bfa_trc(bfa, pport->beacon); + bfa_trc(bfa, pport->link_e2e_beacon); - fcport->beacon = beacon; - fcport->link_e2e_beacon = link_e2e_beacon; + pport->beacon = beacon; + pport->link_e2e_beacon = link_e2e_beacon; } bfa_boolean_t -bfa_fcport_is_linkup(struct bfa_s *bfa) +bfa_pport_is_linkup(struct bfa_s *bfa) { - return bfa_sm_cmp_state(BFA_FCPORT_MOD(bfa), bfa_fcport_sm_linkup); + return bfa_sm_cmp_state(BFA_PORT_MOD(bfa), bfa_pport_sm_linkup); } diff --git a/trunk/drivers/scsi/bfa/bfa_fcs.c b/trunk/drivers/scsi/bfa/bfa_fcs.c index 3516172c597c..7cb39a306ea9 100644 --- a/trunk/drivers/scsi/bfa/bfa_fcs.c +++ b/trunk/drivers/scsi/bfa/bfa_fcs.c @@ -36,7 +36,6 @@ * FCS sub-modules */ struct bfa_fcs_mod_s { - void (*attach) (struct bfa_fcs_s *fcs); void (*modinit) (struct bfa_fcs_s *fcs); void (*modexit) (struct bfa_fcs_s *fcs); }; @@ -44,10 +43,12 @@ struct bfa_fcs_mod_s { #define BFA_FCS_MODULE(_mod) { _mod ## _modinit, _mod ## _modexit } static struct bfa_fcs_mod_s fcs_modules[] = { - { bfa_fcs_pport_attach, NULL, NULL }, - { bfa_fcs_uf_attach, NULL, NULL }, - { bfa_fcs_fabric_attach, bfa_fcs_fabric_modinit, - bfa_fcs_fabric_modexit }, + BFA_FCS_MODULE(bfa_fcs_pport), + BFA_FCS_MODULE(bfa_fcs_uf), + BFA_FCS_MODULE(bfa_fcs_fabric), + BFA_FCS_MODULE(bfa_fcs_vport), + BFA_FCS_MODULE(bfa_fcs_rport), + BFA_FCS_MODULE(bfa_fcs_fcpim), }; /** @@ -70,10 +71,16 @@ bfa_fcs_exit_comp(void *fcs_cbarg) */ /** - * fcs attach -- called once to initialize data structures at driver attach time + * FCS instance initialization. + * + * param[in] fcs FCS instance + * param[in] bfa BFA instance + * param[in] bfad BFA driver instance + * + * return None */ void -bfa_fcs_attach(struct bfa_fcs_s *fcs, struct bfa_s *bfa, struct bfad_s *bfad, +bfa_fcs_init(struct bfa_fcs_s *fcs, struct bfa_s *bfa, struct bfad_s *bfad, bfa_boolean_t min_cfg) { int i; @@ -88,24 +95,7 @@ bfa_fcs_attach(struct bfa_fcs_s *fcs, struct bfa_s *bfa, struct bfad_s *bfad, for (i = 0; i < sizeof(fcs_modules) / sizeof(fcs_modules[0]); i++) { mod = &fcs_modules[i]; - if (mod->attach) - mod->attach(fcs); - } -} - -/** - * fcs initialization, called once after bfa initialization is complete - */ -void -bfa_fcs_init(struct bfa_fcs_s *fcs) -{ - int i; - struct bfa_fcs_mod_s *mod; - - for (i = 0; i < sizeof(fcs_modules) / sizeof(fcs_modules[0]); i++) { - mod = &fcs_modules[i]; - if (mod->modinit) - mod->modinit(fcs); + mod->modinit(fcs); } } @@ -136,23 +126,6 @@ bfa_fcs_driver_info_init(struct bfa_fcs_s *fcs, bfa_fcs_fabric_psymb_init(&fcs->fabric); } -/** - * @brief - * FCS FDMI Driver Parameter Initialization - * - * @param[in] fcs FCS instance - * @param[in] fdmi_enable TRUE/FALSE - * - * @return None - */ -void -bfa_fcs_set_fdmi_param(struct bfa_fcs_s *fcs, bfa_boolean_t fdmi_enable) -{ - - fcs->fdmi_enabled = fdmi_enable; - -} - /** * FCS instance cleanup and exit. * @@ -170,12 +143,10 @@ bfa_fcs_exit(struct bfa_fcs_s *fcs) nmods = sizeof(fcs_modules) / sizeof(fcs_modules[0]); for (i = 0; i < nmods; i++) { + bfa_wc_up(&fcs->wc); mod = &fcs_modules[i]; - if (mod->modexit) { - bfa_wc_up(&fcs->wc); - mod->modexit(fcs); - } + mod->modexit(fcs); } bfa_wc_wait(&fcs->wc); diff --git a/trunk/drivers/scsi/bfa/bfa_fcs_lport.c b/trunk/drivers/scsi/bfa/bfa_fcs_lport.c index 7c1251c682d8..c7ab257f10a7 100644 --- a/trunk/drivers/scsi/bfa/bfa_fcs_lport.c +++ b/trunk/drivers/scsi/bfa/bfa_fcs_lport.c @@ -114,7 +114,7 @@ bfa_fcs_port_sm_uninit(struct bfa_fcs_port_s *port, break; default: - bfa_sm_fault(port->fcs, event); + bfa_assert(0); } } @@ -136,7 +136,7 @@ bfa_fcs_port_sm_init(struct bfa_fcs_port_s *port, enum bfa_fcs_port_event event) break; default: - bfa_sm_fault(port->fcs, event); + bfa_assert(0); } } @@ -176,7 +176,7 @@ bfa_fcs_port_sm_online(struct bfa_fcs_port_s *port, break; default: - bfa_sm_fault(port->fcs, event); + bfa_assert(0); } } @@ -214,7 +214,7 @@ bfa_fcs_port_sm_offline(struct bfa_fcs_port_s *port, break; default: - bfa_sm_fault(port->fcs, event); + bfa_assert(0); } } @@ -234,7 +234,7 @@ bfa_fcs_port_sm_deleting(struct bfa_fcs_port_s *port, break; default: - bfa_sm_fault(port->fcs, event); + bfa_assert(0); } } @@ -263,8 +263,30 @@ bfa_fcs_port_aen_post(struct bfa_fcs_port_s *port, bfa_assert(role <= BFA_PORT_ROLE_FCP_MAX); - bfa_log(logmod, BFA_LOG_CREATE_ID(BFA_AEN_CAT_LPORT, event), lpwwn_ptr, - role_str[role/2]); + switch (event) { + case BFA_LPORT_AEN_ONLINE: + bfa_log(logmod, BFA_AEN_LPORT_ONLINE, lpwwn_ptr, + role_str[role / 2]); + break; + case BFA_LPORT_AEN_OFFLINE: + bfa_log(logmod, BFA_AEN_LPORT_OFFLINE, lpwwn_ptr, + role_str[role / 2]); + break; + case BFA_LPORT_AEN_NEW: + bfa_log(logmod, BFA_AEN_LPORT_NEW, lpwwn_ptr, + role_str[role / 2]); + break; + case BFA_LPORT_AEN_DELETE: + bfa_log(logmod, BFA_AEN_LPORT_DELETE, lpwwn_ptr, + role_str[role / 2]); + break; + case BFA_LPORT_AEN_DISCONNECT: + bfa_log(logmod, BFA_AEN_LPORT_DISCONNECT, lpwwn_ptr, + role_str[role / 2]); + break; + default: + break; + } aen_data.lport.vf_id = port->fabric->vf_id; aen_data.lport.roles = role; @@ -851,46 +873,36 @@ bfa_fcs_port_is_online(struct bfa_fcs_port_s *port) } /** - * Attach time initialization of logical ports. + * Logical port initialization of base or virtual port. + * Called by fabric for base port or by vport for virtual ports. */ void -bfa_fcs_lport_attach(struct bfa_fcs_port_s *lport, struct bfa_fcs_s *fcs, - uint16_t vf_id, struct bfa_fcs_vport_s *vport) +bfa_fcs_lport_init(struct bfa_fcs_port_s *lport, struct bfa_fcs_s *fcs, + u16 vf_id, struct bfa_port_cfg_s *port_cfg, + struct bfa_fcs_vport_s *vport) { lport->fcs = fcs; lport->fabric = bfa_fcs_vf_lookup(fcs, vf_id); + bfa_os_assign(lport->port_cfg, *port_cfg); lport->vport = vport; lport->lp_tag = (vport) ? bfa_lps_get_tag(vport->lps) : bfa_lps_get_tag(lport->fabric->lps); INIT_LIST_HEAD(&lport->rport_q); lport->num_rports = 0; -} - -/** - * Logical port initialization of base or virtual port. - * Called by fabric for base port or by vport for virtual ports. - */ -void -bfa_fcs_lport_init(struct bfa_fcs_port_s *lport, - struct bfa_port_cfg_s *port_cfg) -{ - struct bfa_fcs_vport_s *vport = lport->vport; - - bfa_os_assign(lport->port_cfg, *port_cfg); - - lport->bfad_port = bfa_fcb_port_new(lport->fcs->bfad, lport, - lport->port_cfg.roles, + lport->bfad_port = + bfa_fcb_port_new(fcs->bfad, lport, lport->port_cfg.roles, lport->fabric->vf_drv, vport ? vport->vport_drv : NULL); - bfa_fcs_port_aen_post(lport, BFA_LPORT_AEN_NEW); bfa_sm_set_state(lport, bfa_fcs_port_sm_uninit); bfa_sm_send_event(lport, BFA_FCS_PORT_SM_CREATE); } + + /** * fcs_lport_api */ @@ -909,20 +921,13 @@ bfa_fcs_port_get_attr(struct bfa_fcs_port_s *port, if (port->fabric) { port_attr->port_type = bfa_fcs_fabric_port_type(port->fabric); port_attr->loopback = bfa_fcs_fabric_is_loopback(port->fabric); - port_attr->authfail = - bfa_fcs_fabric_is_auth_failed(port->fabric); port_attr->fabric_name = bfa_fcs_port_get_fabric_name(port); memcpy(port_attr->fabric_ip_addr, bfa_fcs_port_get_fabric_ipaddr(port), BFA_FCS_FABRIC_IPADDR_SZ); - if (port->vport != NULL) { + if (port->vport != NULL) port_attr->port_type = BFA_PPORT_TYPE_VPORT; - port_attr->fpma_mac = - bfa_lps_get_lp_mac(port->vport->lps); - } else - port_attr->fpma_mac = - bfa_lps_get_lp_mac(port->fabric->lps); } else { port_attr->port_type = BFA_PPORT_TYPE_UNKNOWN; diff --git a/trunk/drivers/scsi/bfa/bfa_fcs_port.c b/trunk/drivers/scsi/bfa/bfa_fcs_port.c index 3c27788cd527..9c4b24e62de1 100644 --- a/trunk/drivers/scsi/bfa/bfa_fcs_port.c +++ b/trunk/drivers/scsi/bfa/bfa_fcs_port.c @@ -55,7 +55,14 @@ bfa_fcs_pport_event_handler(void *cbarg, bfa_pport_event_t event) } void -bfa_fcs_pport_attach(struct bfa_fcs_s *fcs) +bfa_fcs_pport_modinit(struct bfa_fcs_s *fcs) { - bfa_fcport_event_register(fcs->bfa, bfa_fcs_pport_event_handler, fcs); + bfa_pport_event_register(fcs->bfa, bfa_fcs_pport_event_handler, + fcs); +} + +void +bfa_fcs_pport_modexit(struct bfa_fcs_s *fcs) +{ + bfa_fcs_modexit_comp(fcs); } diff --git a/trunk/drivers/scsi/bfa/bfa_fcs_uf.c b/trunk/drivers/scsi/bfa/bfa_fcs_uf.c index 3d57d48bbae4..ad01db6444b2 100644 --- a/trunk/drivers/scsi/bfa/bfa_fcs_uf.c +++ b/trunk/drivers/scsi/bfa/bfa_fcs_uf.c @@ -93,7 +93,13 @@ bfa_fcs_uf_recv(void *cbarg, struct bfa_uf_s *uf) } void -bfa_fcs_uf_attach(struct bfa_fcs_s *fcs) +bfa_fcs_uf_modinit(struct bfa_fcs_s *fcs) { bfa_uf_recv_register(fcs->bfa, bfa_fcs_uf_recv, fcs); } + +void +bfa_fcs_uf_modexit(struct bfa_fcs_s *fcs) +{ + bfa_fcs_modexit_comp(fcs); +} diff --git a/trunk/drivers/scsi/bfa/bfa_hw_cb.c b/trunk/drivers/scsi/bfa/bfa_hw_cb.c index 871a4e28575c..ede1438619e2 100644 --- a/trunk/drivers/scsi/bfa/bfa_hw_cb.c +++ b/trunk/drivers/scsi/bfa/bfa_hw_cb.c @@ -52,18 +52,6 @@ bfa_hwcb_reginit(struct bfa_s *bfa) } } -void -bfa_hwcb_reqq_ack(struct bfa_s *bfa, int reqq) -{ -} - -static void -bfa_hwcb_reqq_ack_msix(struct bfa_s *bfa, int reqq) -{ - bfa_reg_write(bfa->iocfc.bfa_regs.intr_status, - __HFN_INT_CPE_Q0 << CPE_Q_NUM(bfa_ioc_pcifn(&bfa->ioc), reqq)); -} - void bfa_hwcb_rspq_ack(struct bfa_s *bfa, int rspq) { @@ -148,7 +136,6 @@ bfa_hwcb_msix_uninstall(struct bfa_s *bfa) void bfa_hwcb_isr_mode_set(struct bfa_s *bfa, bfa_boolean_t msix) { - bfa->iocfc.hwif.hw_reqq_ack = bfa_hwcb_reqq_ack_msix; bfa->iocfc.hwif.hw_rspq_ack = bfa_hwcb_rspq_ack_msix; } diff --git a/trunk/drivers/scsi/bfa/bfa_hw_ct.c b/trunk/drivers/scsi/bfa/bfa_hw_ct.c index 76ceb9a4bf2f..51ae5740e6e9 100644 --- a/trunk/drivers/scsi/bfa/bfa_hw_ct.c +++ b/trunk/drivers/scsi/bfa/bfa_hw_ct.c @@ -84,15 +84,6 @@ bfa_hwct_reginit(struct bfa_s *bfa) } } -void -bfa_hwct_reqq_ack(struct bfa_s *bfa, int reqq) -{ - u32 r32; - - r32 = bfa_reg_read(bfa->iocfc.bfa_regs.cpe_q_ctrl[reqq]); - bfa_reg_write(bfa->iocfc.bfa_regs.cpe_q_ctrl[reqq], r32); -} - void bfa_hwct_rspq_ack(struct bfa_s *bfa, int rspq) { diff --git a/trunk/drivers/scsi/bfa/bfa_intr.c b/trunk/drivers/scsi/bfa/bfa_intr.c index 0eba3f930d5b..b36540e4ed76 100644 --- a/trunk/drivers/scsi/bfa/bfa_intr.c +++ b/trunk/drivers/scsi/bfa/bfa_intr.c @@ -15,7 +15,7 @@ * General Public License for more details. */ #include -#include +#include #include #include #include @@ -34,26 +34,6 @@ bfa_msix_lpu(struct bfa_s *bfa) bfa_ioc_mbox_isr(&bfa->ioc); } -static void -bfa_reqq_resume(struct bfa_s *bfa, int qid) -{ - struct list_head *waitq, *qe, *qen; - struct bfa_reqq_wait_s *wqe; - - waitq = bfa_reqq(bfa, qid); - list_for_each_safe(qe, qen, waitq) { - /** - * Callback only as long as there is room in request queue - */ - if (bfa_reqq_full(bfa, qid)) - break; - - list_del(qe); - wqe = (struct bfa_reqq_wait_s *) qe; - wqe->qresume(wqe->cbarg); - } -} - void bfa_msix_all(struct bfa_s *bfa, int vec) { @@ -116,8 +96,7 @@ bfa_isr_enable(struct bfa_s *bfa) bfa_msix_install(bfa); intr_unmask = (__HFN_INT_ERR_EMC | __HFN_INT_ERR_LPU0 | - __HFN_INT_ERR_LPU1 | __HFN_INT_ERR_PSS | - __HFN_INT_LL_HALT); + __HFN_INT_ERR_LPU1 | __HFN_INT_ERR_PSS); if (pci_func == 0) intr_unmask |= (__HFN_INT_CPE_Q0 | __HFN_INT_CPE_Q1 | @@ -148,18 +127,23 @@ bfa_isr_disable(struct bfa_s *bfa) void bfa_msix_reqq(struct bfa_s *bfa, int qid) { - struct list_head *waitq; + struct list_head *waitq, *qe, *qen; + struct bfa_reqq_wait_s *wqe; qid &= (BFI_IOC_MAX_CQS - 1); - bfa->iocfc.hwif.hw_reqq_ack(bfa, qid); - - /** - * Resume any pending requests in the corresponding reqq. - */ waitq = bfa_reqq(bfa, qid); - if (!list_empty(waitq)) - bfa_reqq_resume(bfa, qid); + list_for_each_safe(qe, qen, waitq) { + /** + * Callback only as long as there is room in request queue + */ + if (bfa_reqq_full(bfa, qid)) + break; + + list_del(qe); + wqe = (struct bfa_reqq_wait_s *) qe; + wqe->qresume(wqe->cbarg); + } } void @@ -173,27 +157,26 @@ bfa_isr_unhandled(struct bfa_s *bfa, struct bfi_msg_s *m) } void -bfa_msix_rspq(struct bfa_s *bfa, int qid) +bfa_msix_rspq(struct bfa_s *bfa, int rsp_qid) { - struct bfi_msg_s *m; - u32 pi, ci; - struct list_head *waitq; + struct bfi_msg_s *m; + u32 pi, ci; - bfa_trc_fp(bfa, qid); + bfa_trc_fp(bfa, rsp_qid); - qid &= (BFI_IOC_MAX_CQS - 1); + rsp_qid &= (BFI_IOC_MAX_CQS - 1); - bfa->iocfc.hwif.hw_rspq_ack(bfa, qid); + bfa->iocfc.hwif.hw_rspq_ack(bfa, rsp_qid); - ci = bfa_rspq_ci(bfa, qid); - pi = bfa_rspq_pi(bfa, qid); + ci = bfa_rspq_ci(bfa, rsp_qid); + pi = bfa_rspq_pi(bfa, rsp_qid); bfa_trc_fp(bfa, ci); bfa_trc_fp(bfa, pi); if (bfa->rme_process) { while (ci != pi) { - m = bfa_rspq_elem(bfa, qid, ci); + m = bfa_rspq_elem(bfa, rsp_qid, ci); bfa_assert_fp(m->mhdr.msg_class < BFI_MC_MAX); bfa_isrs[m->mhdr.msg_class] (bfa, m); @@ -205,59 +188,25 @@ bfa_msix_rspq(struct bfa_s *bfa, int qid) /** * update CI */ - bfa_rspq_ci(bfa, qid) = pi; - bfa_reg_write(bfa->iocfc.bfa_regs.rme_q_ci[qid], pi); + bfa_rspq_ci(bfa, rsp_qid) = pi; + bfa_reg_write(bfa->iocfc.bfa_regs.rme_q_ci[rsp_qid], pi); bfa_os_mmiowb(); - - /** - * Resume any pending requests in the corresponding reqq. - */ - waitq = bfa_reqq(bfa, qid); - if (!list_empty(waitq)) - bfa_reqq_resume(bfa, qid); } void bfa_msix_lpu_err(struct bfa_s *bfa, int vec) { - u32 intr, curr_value; + u32 intr; intr = bfa_reg_read(bfa->iocfc.bfa_regs.intr_status); if (intr & (__HFN_INT_MBOX_LPU0 | __HFN_INT_MBOX_LPU1)) bfa_msix_lpu(bfa); - intr &= (__HFN_INT_ERR_EMC | __HFN_INT_ERR_LPU0 | - __HFN_INT_ERR_LPU1 | __HFN_INT_ERR_PSS | __HFN_INT_LL_HALT); - - if (intr) { - if (intr & __HFN_INT_LL_HALT) { - /** - * If LL_HALT bit is set then FW Init Halt LL Port - * Register needs to be cleared as well so Interrupt - * Status Register will be cleared. - */ - curr_value = bfa_reg_read(bfa->ioc.ioc_regs.ll_halt); - curr_value &= ~__FW_INIT_HALT_P; - bfa_reg_write(bfa->ioc.ioc_regs.ll_halt, curr_value); - } - - if (intr & __HFN_INT_ERR_PSS) { - /** - * ERR_PSS bit needs to be cleared as well in case - * interrups are shared so driver's interrupt handler is - * still called eventhough it is already masked out. - */ - curr_value = bfa_reg_read( - bfa->ioc.ioc_regs.pss_err_status_reg); - curr_value &= __PSS_ERR_STATUS_SET; - bfa_reg_write(bfa->ioc.ioc_regs.pss_err_status_reg, - curr_value); - } - - bfa_reg_write(bfa->iocfc.bfa_regs.intr_status, intr); + if (intr & (__HFN_INT_ERR_EMC | + __HFN_INT_ERR_LPU0 | __HFN_INT_ERR_LPU1 | + __HFN_INT_ERR_PSS)) bfa_msix_errint(bfa, intr); - } } void diff --git a/trunk/drivers/scsi/bfa/bfa_ioc.c b/trunk/drivers/scsi/bfa/bfa_ioc.c index e038bc9769f6..397d7e9eade5 100644 --- a/trunk/drivers/scsi/bfa/bfa_ioc.c +++ b/trunk/drivers/scsi/bfa/bfa_ioc.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include #include @@ -27,17 +27,18 @@ #include #include -BFA_TRC_FILE(CNA, IOC); +BFA_TRC_FILE(HAL, IOC); /** * IOC local definitions */ #define BFA_IOC_TOV 2000 /* msecs */ -#define BFA_IOC_HWSEM_TOV 500 /* msecs */ -#define BFA_IOC_HB_TOV 500 /* msecs */ -#define BFA_IOC_HWINIT_MAX 2 +#define BFA_IOC_HB_TOV 1000 /* msecs */ +#define BFA_IOC_HB_FAIL_MAX 4 +#define BFA_IOC_HWINIT_MAX 2 #define BFA_IOC_FWIMG_MINSZ (16 * 1024) -#define BFA_IOC_TOV_RECOVER BFA_IOC_HB_TOV +#define BFA_IOC_TOV_RECOVER (BFA_IOC_HB_FAIL_MAX * BFA_IOC_HB_TOV \ + + BFA_IOC_TOV) #define bfa_ioc_timer_start(__ioc) \ bfa_timer_begin((__ioc)->timer_mod, &(__ioc)->ioc_timer, \ @@ -50,25 +51,12 @@ BFA_TRC_FILE(CNA, IOC); (sizeof(struct bfa_trc_mod_s) - \ BFA_TRC_MAX * sizeof(struct bfa_trc_s))) #define BFA_DBG_FWTRC_OFF(_fn) (BFI_IOC_TRC_OFF + BFA_DBG_FWTRC_LEN * (_fn)) +#define bfa_ioc_stats(_ioc, _stats) ((_ioc)->stats._stats++) -/** - * Asic specific macros : see bfa_hw_cb.c and bfa_hw_ct.c for details. - */ - -#define bfa_ioc_firmware_lock(__ioc) \ - ((__ioc)->ioc_hwif->ioc_firmware_lock(__ioc)) -#define bfa_ioc_firmware_unlock(__ioc) \ - ((__ioc)->ioc_hwif->ioc_firmware_unlock(__ioc)) -#define bfa_ioc_fwimg_get_chunk(__ioc, __off) \ - ((__ioc)->ioc_hwif->ioc_fwimg_get_chunk(__ioc, __off)) -#define bfa_ioc_fwimg_get_size(__ioc) \ - ((__ioc)->ioc_hwif->ioc_fwimg_get_size(__ioc)) -#define bfa_ioc_reg_init(__ioc) ((__ioc)->ioc_hwif->ioc_reg_init(__ioc)) -#define bfa_ioc_map_port(__ioc) ((__ioc)->ioc_hwif->ioc_map_port(__ioc)) -#define bfa_ioc_notify_hbfail(__ioc) \ - ((__ioc)->ioc_hwif->ioc_notify_hbfail(__ioc)) - -bfa_boolean_t bfa_auto_recover = BFA_TRUE; +#define BFA_FLASH_CHUNK_NO(off) (off / BFI_FLASH_CHUNK_SZ_WORDS) +#define BFA_FLASH_OFFSET_IN_CHUNK(off) (off % BFI_FLASH_CHUNK_SZ_WORDS) +#define BFA_FLASH_CHUNK_ADDR(chunkno) (chunkno * BFI_FLASH_CHUNK_SZ_WORDS) +bfa_boolean_t bfa_auto_recover = BFA_FALSE; /* * forward declarations @@ -76,6 +64,7 @@ bfa_boolean_t bfa_auto_recover = BFA_TRUE; static void bfa_ioc_aen_post(struct bfa_ioc_s *bfa, enum bfa_ioc_aen_event event); static void bfa_ioc_hw_sem_get(struct bfa_ioc_s *ioc); +static void bfa_ioc_hw_sem_release(struct bfa_ioc_s *ioc); static void bfa_ioc_hw_sem_get_cancel(struct bfa_ioc_s *ioc); static void bfa_ioc_hwinit(struct bfa_ioc_s *ioc, bfa_boolean_t force); static void bfa_ioc_timeout(void *ioc); @@ -88,6 +77,8 @@ static void bfa_ioc_reset(struct bfa_ioc_s *ioc, bfa_boolean_t force); static void bfa_ioc_mbox_poll(struct bfa_ioc_s *ioc); static void bfa_ioc_mbox_hbfail(struct bfa_ioc_s *ioc); static void bfa_ioc_recover(struct bfa_ioc_s *ioc); +static bfa_boolean_t bfa_ioc_firmware_lock(struct bfa_ioc_s *ioc); +static void bfa_ioc_firmware_unlock(struct bfa_ioc_s *ioc); static void bfa_ioc_disable_comp(struct bfa_ioc_s *ioc); static void bfa_ioc_lpu_stop(struct bfa_ioc_s *ioc); @@ -517,19 +508,14 @@ bfa_ioc_sm_disabling(struct bfa_ioc_s *ioc, enum ioc_event event) bfa_trc(ioc, event); switch (event) { - case IOC_E_FWRSP_DISABLE: - bfa_ioc_timer_stop(ioc); - bfa_fsm_set_state(ioc, bfa_ioc_sm_disabled); - break; - case IOC_E_HWERROR: + case IOC_E_FWRSP_DISABLE: bfa_ioc_timer_stop(ioc); /* * !!! fall through !!! */ case IOC_E_TIMEOUT: - bfa_reg_write(ioc->ioc_regs.ioc_fwstate, BFI_IOC_FAIL); bfa_fsm_set_state(ioc, bfa_ioc_sm_disabled); break; @@ -622,12 +608,15 @@ bfa_ioc_sm_hbfail_entry(struct bfa_ioc_s *ioc) * Mark IOC as failed in hardware and stop firmware. */ bfa_ioc_lpu_stop(ioc); - bfa_reg_write(ioc->ioc_regs.ioc_fwstate, BFI_IOC_FAIL); + bfa_reg_write(ioc->ioc_regs.ioc_fwstate, BFI_IOC_HBFAIL); - /** - * Notify other functions on HB failure. - */ - bfa_ioc_notify_hbfail(ioc); + if (ioc->pcidev.device_id == BFA_PCI_DEVICE_ID_CT) { + bfa_reg_write(ioc->ioc_regs.ll_halt, __FW_INIT_HALT_P); + /* + * Wait for halt to take effect + */ + bfa_reg_read(ioc->ioc_regs.ll_halt); + } /** * Notify driver and common modules registered for notification. @@ -683,12 +672,6 @@ bfa_ioc_sm_hbfail(struct bfa_ioc_s *ioc, enum ioc_event event) */ break; - case IOC_E_HWERROR: - /* - * HB failure notification, ignore. - */ - break; - default: bfa_sm_fault(ioc, event); } @@ -717,7 +700,7 @@ bfa_ioc_disable_comp(struct bfa_ioc_s *ioc) } } -void +static void bfa_ioc_sem_timeout(void *ioc_arg) { struct bfa_ioc_s *ioc = (struct bfa_ioc_s *)ioc_arg; @@ -725,32 +708,26 @@ bfa_ioc_sem_timeout(void *ioc_arg) bfa_ioc_hw_sem_get(ioc); } -bfa_boolean_t -bfa_ioc_sem_get(bfa_os_addr_t sem_reg) +static void +bfa_ioc_usage_sem_get(struct bfa_ioc_s *ioc) { - u32 r32; - int cnt = 0; -#define BFA_SEM_SPINCNT 3000 - - r32 = bfa_reg_read(sem_reg); + u32 r32; + int cnt = 0; +#define BFA_SEM_SPINCNT 1000 - while (r32 && (cnt < BFA_SEM_SPINCNT)) { + do { + r32 = bfa_reg_read(ioc->ioc_regs.ioc_usage_sem_reg); cnt++; - bfa_os_udelay(2); - r32 = bfa_reg_read(sem_reg); - } - - if (r32 == 0) - return BFA_TRUE; - + if (cnt > BFA_SEM_SPINCNT) + break; + } while (r32 != 0); bfa_assert(cnt < BFA_SEM_SPINCNT); - return BFA_FALSE; } -void -bfa_ioc_sem_release(bfa_os_addr_t sem_reg) +static void +bfa_ioc_usage_sem_release(struct bfa_ioc_s *ioc) { - bfa_reg_write(sem_reg, 1); + bfa_reg_write(ioc->ioc_regs.ioc_usage_sem_reg, 1); } static void @@ -760,7 +737,7 @@ bfa_ioc_hw_sem_get(struct bfa_ioc_s *ioc) /** * First read to the semaphore register will return 0, subsequent reads - * will return 1. Semaphore is released by writing 1 to the register + * will return 1. Semaphore is released by writing 0 to the register */ r32 = bfa_reg_read(ioc->ioc_regs.ioc_sem_reg); if (r32 == 0) { @@ -769,10 +746,10 @@ bfa_ioc_hw_sem_get(struct bfa_ioc_s *ioc) } bfa_timer_begin(ioc->timer_mod, &ioc->sem_timer, bfa_ioc_sem_timeout, - ioc, BFA_IOC_HWSEM_TOV); + ioc, BFA_IOC_TOV); } -void +static void bfa_ioc_hw_sem_release(struct bfa_ioc_s *ioc) { bfa_reg_write(ioc->ioc_regs.ioc_sem_reg, 1); @@ -851,7 +828,7 @@ bfa_ioc_lpu_stop(struct bfa_ioc_s *ioc) /** * Get driver and firmware versions. */ -void +static void bfa_ioc_fwver_get(struct bfa_ioc_s *ioc, struct bfi_ioc_image_hdr_s *fwhdr) { u32 pgnum, pgoff; @@ -870,10 +847,24 @@ bfa_ioc_fwver_get(struct bfa_ioc_s *ioc, struct bfi_ioc_image_hdr_s *fwhdr) } } +static u32 * +bfa_ioc_fwimg_get_chunk(struct bfa_ioc_s *ioc, u32 off) +{ + if (ioc->ctdev) + return bfi_image_ct_get_chunk(off); + return bfi_image_cb_get_chunk(off); +} + +static u32 +bfa_ioc_fwimg_get_size(struct bfa_ioc_s *ioc) +{ +return (ioc->ctdev) ? bfi_image_ct_size : bfi_image_cb_size; +} + /** * Returns TRUE if same. */ -bfa_boolean_t +static bfa_boolean_t bfa_ioc_fwver_cmp(struct bfa_ioc_s *ioc, struct bfi_ioc_image_hdr_s *fwhdr) { struct bfi_ioc_image_hdr_s *drv_fwhdr; @@ -929,6 +920,95 @@ bfa_ioc_fwver_valid(struct bfa_ioc_s *ioc) return bfa_ioc_fwver_cmp(ioc, &fwhdr); } +/** + * Return true if firmware of current driver matches the running firmware. + */ +static bfa_boolean_t +bfa_ioc_firmware_lock(struct bfa_ioc_s *ioc) +{ + enum bfi_ioc_state ioc_fwstate; + u32 usecnt; + struct bfi_ioc_image_hdr_s fwhdr; + + /** + * Firmware match check is relevant only for CNA. + */ + if (!ioc->cna) + return BFA_TRUE; + + /** + * If bios boot (flash based) -- do not increment usage count + */ + if (bfa_ioc_fwimg_get_size(ioc) < BFA_IOC_FWIMG_MINSZ) + return BFA_TRUE; + + bfa_ioc_usage_sem_get(ioc); + usecnt = bfa_reg_read(ioc->ioc_regs.ioc_usage_reg); + + /** + * If usage count is 0, always return TRUE. + */ + if (usecnt == 0) { + bfa_reg_write(ioc->ioc_regs.ioc_usage_reg, 1); + bfa_ioc_usage_sem_release(ioc); + bfa_trc(ioc, usecnt); + return BFA_TRUE; + } + + ioc_fwstate = bfa_reg_read(ioc->ioc_regs.ioc_fwstate); + bfa_trc(ioc, ioc_fwstate); + + /** + * Use count cannot be non-zero and chip in uninitialized state. + */ + bfa_assert(ioc_fwstate != BFI_IOC_UNINIT); + + /** + * Check if another driver with a different firmware is active + */ + bfa_ioc_fwver_get(ioc, &fwhdr); + if (!bfa_ioc_fwver_cmp(ioc, &fwhdr)) { + bfa_ioc_usage_sem_release(ioc); + bfa_trc(ioc, usecnt); + return BFA_FALSE; + } + + /** + * Same firmware version. Increment the reference count. + */ + usecnt++; + bfa_reg_write(ioc->ioc_regs.ioc_usage_reg, usecnt); + bfa_ioc_usage_sem_release(ioc); + bfa_trc(ioc, usecnt); + return BFA_TRUE; +} + +static void +bfa_ioc_firmware_unlock(struct bfa_ioc_s *ioc) +{ + u32 usecnt; + + /** + * Firmware lock is relevant only for CNA. + * If bios boot (flash based) -- do not decrement usage count + */ + if (!ioc->cna || (bfa_ioc_fwimg_get_size(ioc) < BFA_IOC_FWIMG_MINSZ)) + return; + + /** + * decrement usage count + */ + bfa_ioc_usage_sem_get(ioc); + usecnt = bfa_reg_read(ioc->ioc_regs.ioc_usage_reg); + bfa_assert(usecnt > 0); + + usecnt--; + bfa_reg_write(ioc->ioc_regs.ioc_usage_reg, usecnt); + bfa_trc(ioc, usecnt); + + bfa_ioc_usage_sem_release(ioc); +} + /** * Conditionally flush any pending message from firmware at start. */ @@ -1072,27 +1152,33 @@ bfa_ioc_send_getattr(struct bfa_ioc_s *ioc) static void bfa_ioc_hb_check(void *cbarg) { - struct bfa_ioc_s *ioc = cbarg; - u32 hb_count; + struct bfa_ioc_s *ioc = cbarg; + u32 hb_count; hb_count = bfa_reg_read(ioc->ioc_regs.heartbeat); if (ioc->hb_count == hb_count) { - bfa_log(ioc->logm, BFA_LOG_HAL_HEARTBEAT_FAILURE, - hb_count); - bfa_ioc_recover(ioc); - return; + ioc->hb_fail++; } else { ioc->hb_count = hb_count; + ioc->hb_fail = 0; + } + + if (ioc->hb_fail >= BFA_IOC_HB_FAIL_MAX) { + bfa_log(ioc->logm, BFA_LOG_HAL_HEARTBEAT_FAILURE, hb_count); + ioc->hb_fail = 0; + bfa_ioc_recover(ioc); + return; } bfa_ioc_mbox_poll(ioc); - bfa_timer_begin(ioc->timer_mod, &ioc->ioc_timer, bfa_ioc_hb_check, - ioc, BFA_IOC_HB_TOV); + bfa_timer_begin(ioc->timer_mod, &ioc->ioc_timer, bfa_ioc_hb_check, ioc, + BFA_IOC_HB_TOV); } static void bfa_ioc_hb_monitor(struct bfa_ioc_s *ioc) { + ioc->hb_fail = 0; ioc->hb_count = bfa_reg_read(ioc->ioc_regs.heartbeat); bfa_timer_begin(ioc->timer_mod, &ioc->ioc_timer, bfa_ioc_hb_check, ioc, BFA_IOC_HB_TOV); @@ -1104,6 +1190,112 @@ bfa_ioc_hb_stop(struct bfa_ioc_s *ioc) bfa_timer_stop(&ioc->ioc_timer); } +/** + * Host to LPU mailbox message addresses + */ +static struct { + u32 hfn_mbox, lpu_mbox, hfn_pgn; +} iocreg_fnreg[] = { + { + HOSTFN0_LPU_MBOX0_0, LPU_HOSTFN0_MBOX0_0, HOST_PAGE_NUM_FN0}, { + HOSTFN1_LPU_MBOX0_8, LPU_HOSTFN1_MBOX0_8, HOST_PAGE_NUM_FN1}, { + HOSTFN2_LPU_MBOX0_0, LPU_HOSTFN2_MBOX0_0, HOST_PAGE_NUM_FN2}, { + HOSTFN3_LPU_MBOX0_8, LPU_HOSTFN3_MBOX0_8, HOST_PAGE_NUM_FN3} +}; + +/** + * Host <-> LPU mailbox command/status registers - port 0 + */ +static struct { + u32 hfn, lpu; +} iocreg_mbcmd_p0[] = { + { + HOSTFN0_LPU0_MBOX0_CMD_STAT, LPU0_HOSTFN0_MBOX0_CMD_STAT}, { + HOSTFN1_LPU0_MBOX0_CMD_STAT, LPU0_HOSTFN1_MBOX0_CMD_STAT}, { + HOSTFN2_LPU0_MBOX0_CMD_STAT, LPU0_HOSTFN2_MBOX0_CMD_STAT}, { + HOSTFN3_LPU0_MBOX0_CMD_STAT, LPU0_HOSTFN3_MBOX0_CMD_STAT} +}; + +/** + * Host <-> LPU mailbox command/status registers - port 1 + */ +static struct { + u32 hfn, lpu; +} iocreg_mbcmd_p1[] = { + { + HOSTFN0_LPU1_MBOX0_CMD_STAT, LPU1_HOSTFN0_MBOX0_CMD_STAT}, { + HOSTFN1_LPU1_MBOX0_CMD_STAT, LPU1_HOSTFN1_MBOX0_CMD_STAT}, { + HOSTFN2_LPU1_MBOX0_CMD_STAT, LPU1_HOSTFN2_MBOX0_CMD_STAT}, { + HOSTFN3_LPU1_MBOX0_CMD_STAT, LPU1_HOSTFN3_MBOX0_CMD_STAT} +}; + +/** + * Shared IRQ handling in INTX mode + */ +static struct { + u32 isr, msk; +} iocreg_shirq_next[] = { + { + HOSTFN1_INT_STATUS, HOSTFN1_INT_MSK}, { + HOSTFN2_INT_STATUS, HOSTFN2_INT_MSK}, { + HOSTFN3_INT_STATUS, HOSTFN3_INT_MSK}, { +HOSTFN0_INT_STATUS, HOSTFN0_INT_MSK},}; + +static void +bfa_ioc_reg_init(struct bfa_ioc_s *ioc) +{ + bfa_os_addr_t rb; + int pcifn = bfa_ioc_pcifn(ioc); + + rb = bfa_ioc_bar0(ioc); + + ioc->ioc_regs.hfn_mbox = rb + iocreg_fnreg[pcifn].hfn_mbox; + ioc->ioc_regs.lpu_mbox = rb + iocreg_fnreg[pcifn].lpu_mbox; + ioc->ioc_regs.host_page_num_fn = rb + iocreg_fnreg[pcifn].hfn_pgn; + + if (ioc->port_id == 0) { + ioc->ioc_regs.heartbeat = rb + BFA_IOC0_HBEAT_REG; + ioc->ioc_regs.ioc_fwstate = rb + BFA_IOC0_STATE_REG; + ioc->ioc_regs.hfn_mbox_cmd = rb + iocreg_mbcmd_p0[pcifn].hfn; + ioc->ioc_regs.lpu_mbox_cmd = rb + iocreg_mbcmd_p0[pcifn].lpu; + ioc->ioc_regs.ll_halt = rb + FW_INIT_HALT_P0; + } else { + ioc->ioc_regs.heartbeat = (rb + BFA_IOC1_HBEAT_REG); + ioc->ioc_regs.ioc_fwstate = (rb + BFA_IOC1_STATE_REG); + ioc->ioc_regs.hfn_mbox_cmd = rb + iocreg_mbcmd_p1[pcifn].hfn; + ioc->ioc_regs.lpu_mbox_cmd = rb + iocreg_mbcmd_p1[pcifn].lpu; + ioc->ioc_regs.ll_halt = rb + FW_INIT_HALT_P1; + } + + /** + * Shared IRQ handling in INTX mode + */ + ioc->ioc_regs.shirq_isr_next = rb + iocreg_shirq_next[pcifn].isr; + ioc->ioc_regs.shirq_msk_next = rb + iocreg_shirq_next[pcifn].msk; + + /* + * PSS control registers + */ + ioc->ioc_regs.pss_ctl_reg = (rb + PSS_CTL_REG); + ioc->ioc_regs.app_pll_fast_ctl_reg = (rb + APP_PLL_425_CTL_REG); + ioc->ioc_regs.app_pll_slow_ctl_reg = (rb + APP_PLL_312_CTL_REG); + + /* + * IOC semaphore registers and serialization + */ + ioc->ioc_regs.ioc_sem_reg = (rb + HOST_SEM0_REG); + ioc->ioc_regs.ioc_usage_sem_reg = (rb + HOST_SEM1_REG); + ioc->ioc_regs.ioc_usage_reg = (rb + BFA_FW_USE_COUNT); + + /** + * sram memory access + */ + ioc->ioc_regs.smem_page_start = (rb + PSS_SMEM_PAGE_START); + ioc->ioc_regs.smem_pg0 = BFI_IOC_SMEM_PG0_CB; + if (ioc->pcidev.device_id == BFA_PCI_DEVICE_ID_CT) + ioc->ioc_regs.smem_pg0 = BFI_IOC_SMEM_PG0_CT; +} + /** * Initiate a full firmware download. */ @@ -1129,6 +1321,9 @@ bfa_ioc_download_fw(struct bfa_ioc_s *ioc, u32 boot_type, if (bfa_ioc_fwimg_get_size(ioc) < BFA_IOC_FWIMG_MINSZ) boot_type = BFI_BOOT_TYPE_FLASH; fwimg = bfa_ioc_fwimg_get_chunk(ioc, chunkno); + fwimg[BFI_BOOT_TYPE_OFF / sizeof(u32)] = bfa_os_swap32(boot_type); + fwimg[BFI_BOOT_PARAM_OFF / sizeof(u32)] = + bfa_os_swap32(boot_param); pgnum = bfa_ioc_smem_pgnum(ioc, loff); pgoff = bfa_ioc_smem_pgoff(ioc, loff); @@ -1137,17 +1332,17 @@ bfa_ioc_download_fw(struct bfa_ioc_s *ioc, u32 boot_type, for (i = 0; i < bfa_ioc_fwimg_get_size(ioc); i++) { - if (BFA_IOC_FLASH_CHUNK_NO(i) != chunkno) { - chunkno = BFA_IOC_FLASH_CHUNK_NO(i); + if (BFA_FLASH_CHUNK_NO(i) != chunkno) { + chunkno = BFA_FLASH_CHUNK_NO(i); fwimg = bfa_ioc_fwimg_get_chunk(ioc, - BFA_IOC_FLASH_CHUNK_ADDR(chunkno)); + BFA_FLASH_CHUNK_ADDR(chunkno)); } /** * write smem */ bfa_mem_write(ioc->ioc_regs.smem_page_start, loff, - fwimg[BFA_IOC_FLASH_OFFSET_IN_CHUNK(i)]); + fwimg[BFA_FLASH_OFFSET_IN_CHUNK(i)]); loff += sizeof(u32); @@ -1163,14 +1358,6 @@ bfa_ioc_download_fw(struct bfa_ioc_s *ioc, u32 boot_type, bfa_reg_write(ioc->ioc_regs.host_page_num_fn, bfa_ioc_smem_pgnum(ioc, 0)); - - /* - * Set boot type and boot param at the end. - */ - bfa_mem_write(ioc->ioc_regs.smem_page_start, BFI_BOOT_TYPE_OFF, - bfa_os_swap32(boot_type)); - bfa_mem_write(ioc->ioc_regs.smem_page_start, BFI_BOOT_PARAM_OFF, - bfa_os_swap32(boot_param)); } static void @@ -1252,10 +1439,168 @@ bfa_ioc_mbox_hbfail(struct bfa_ioc_s *ioc) bfa_q_deq(&mod->cmd_q, &cmd); } +/** + * Initialize IOC to port mapping. + */ + +#define FNC_PERS_FN_SHIFT(__fn) ((__fn) * 8) +static void +bfa_ioc_map_port(struct bfa_ioc_s *ioc) +{ + bfa_os_addr_t rb = ioc->pcidev.pci_bar_kva; + u32 r32; + + /** + * For crossbow, port id is same as pci function. + */ + if (ioc->pcidev.device_id != BFA_PCI_DEVICE_ID_CT) { + ioc->port_id = bfa_ioc_pcifn(ioc); + return; + } + + /** + * For catapult, base port id on personality register and IOC type + */ + r32 = bfa_reg_read(rb + FNC_PERS_REG); + r32 >>= FNC_PERS_FN_SHIFT(bfa_ioc_pcifn(ioc)); + ioc->port_id = (r32 & __F0_PORT_MAP_MK) >> __F0_PORT_MAP_SH; + + bfa_trc(ioc, bfa_ioc_pcifn(ioc)); + bfa_trc(ioc, ioc->port_id); +} + + + /** * bfa_ioc_public */ +/** +* Set interrupt mode for a function: INTX or MSIX + */ +void +bfa_ioc_isr_mode_set(struct bfa_ioc_s *ioc, bfa_boolean_t msix) +{ + bfa_os_addr_t rb = ioc->pcidev.pci_bar_kva; + u32 r32, mode; + + r32 = bfa_reg_read(rb + FNC_PERS_REG); + bfa_trc(ioc, r32); + + mode = (r32 >> FNC_PERS_FN_SHIFT(bfa_ioc_pcifn(ioc))) & + __F0_INTX_STATUS; + + /** + * If already in desired mode, do not change anything + */ + if (!msix && mode) + return; + + if (msix) + mode = __F0_INTX_STATUS_MSIX; + else + mode = __F0_INTX_STATUS_INTA; + + r32 &= ~(__F0_INTX_STATUS << FNC_PERS_FN_SHIFT(bfa_ioc_pcifn(ioc))); + r32 |= (mode << FNC_PERS_FN_SHIFT(bfa_ioc_pcifn(ioc))); + bfa_trc(ioc, r32); + + bfa_reg_write(rb + FNC_PERS_REG, r32); +} + +bfa_status_t +bfa_ioc_pll_init(struct bfa_ioc_s *ioc) +{ + bfa_os_addr_t rb = ioc->pcidev.pci_bar_kva; + u32 pll_sclk, pll_fclk, r32; + + if (ioc->pcidev.device_id == BFA_PCI_DEVICE_ID_CT) { + pll_sclk = + __APP_PLL_312_ENABLE | __APP_PLL_312_LRESETN | + __APP_PLL_312_RSEL200500 | __APP_PLL_312_P0_1(0U) | + __APP_PLL_312_JITLMT0_1(3U) | + __APP_PLL_312_CNTLMT0_1(1U); + pll_fclk = + __APP_PLL_425_ENABLE | __APP_PLL_425_LRESETN | + __APP_PLL_425_RSEL200500 | __APP_PLL_425_P0_1(0U) | + __APP_PLL_425_JITLMT0_1(3U) | + __APP_PLL_425_CNTLMT0_1(1U); + + /** + * For catapult, choose operational mode FC/FCoE + */ + if (ioc->fcmode) { + bfa_reg_write((rb + OP_MODE), 0); + bfa_reg_write((rb + ETH_MAC_SER_REG), + __APP_EMS_CMLCKSEL | __APP_EMS_REFCKBUFEN2 + | __APP_EMS_CHANNEL_SEL); + } else { + ioc->pllinit = BFA_TRUE; + bfa_reg_write((rb + OP_MODE), __GLOBAL_FCOE_MODE); + bfa_reg_write((rb + ETH_MAC_SER_REG), + __APP_EMS_REFCKBUFEN1); + } + } else { + pll_sclk = + __APP_PLL_312_ENABLE | __APP_PLL_312_LRESETN | + __APP_PLL_312_P0_1(3U) | __APP_PLL_312_JITLMT0_1(3U) | + __APP_PLL_312_CNTLMT0_1(3U); + pll_fclk = + __APP_PLL_425_ENABLE | __APP_PLL_425_LRESETN | + __APP_PLL_425_RSEL200500 | __APP_PLL_425_P0_1(3U) | + __APP_PLL_425_JITLMT0_1(3U) | + __APP_PLL_425_CNTLMT0_1(3U); + } + + bfa_reg_write((rb + BFA_IOC0_STATE_REG), BFI_IOC_UNINIT); + bfa_reg_write((rb + BFA_IOC1_STATE_REG), BFI_IOC_UNINIT); + + bfa_reg_write((rb + HOSTFN0_INT_MSK), 0xffffffffU); + bfa_reg_write((rb + HOSTFN1_INT_MSK), 0xffffffffU); + bfa_reg_write((rb + HOSTFN0_INT_STATUS), 0xffffffffU); + bfa_reg_write((rb + HOSTFN1_INT_STATUS), 0xffffffffU); + bfa_reg_write((rb + HOSTFN0_INT_MSK), 0xffffffffU); + bfa_reg_write((rb + HOSTFN1_INT_MSK), 0xffffffffU); + + bfa_reg_write(ioc->ioc_regs.app_pll_slow_ctl_reg, + __APP_PLL_312_LOGIC_SOFT_RESET); + bfa_reg_write(ioc->ioc_regs.app_pll_slow_ctl_reg, + __APP_PLL_312_BYPASS | __APP_PLL_312_LOGIC_SOFT_RESET); + bfa_reg_write(ioc->ioc_regs.app_pll_fast_ctl_reg, + __APP_PLL_425_LOGIC_SOFT_RESET); + bfa_reg_write(ioc->ioc_regs.app_pll_fast_ctl_reg, + __APP_PLL_425_BYPASS | __APP_PLL_425_LOGIC_SOFT_RESET); + bfa_os_udelay(2); + bfa_reg_write(ioc->ioc_regs.app_pll_slow_ctl_reg, + __APP_PLL_312_LOGIC_SOFT_RESET); + bfa_reg_write(ioc->ioc_regs.app_pll_fast_ctl_reg, + __APP_PLL_425_LOGIC_SOFT_RESET); + + bfa_reg_write(ioc->ioc_regs.app_pll_slow_ctl_reg, + pll_sclk | __APP_PLL_312_LOGIC_SOFT_RESET); + bfa_reg_write(ioc->ioc_regs.app_pll_fast_ctl_reg, + pll_fclk | __APP_PLL_425_LOGIC_SOFT_RESET); + + /** + * Wait for PLLs to lock. + */ + bfa_os_udelay(2000); + bfa_reg_write((rb + HOSTFN0_INT_STATUS), 0xffffffffU); + bfa_reg_write((rb + HOSTFN1_INT_STATUS), 0xffffffffU); + + bfa_reg_write(ioc->ioc_regs.app_pll_slow_ctl_reg, pll_sclk); + bfa_reg_write(ioc->ioc_regs.app_pll_fast_ctl_reg, pll_fclk); + + if (ioc->pcidev.device_id == BFA_PCI_DEVICE_ID_CT) { + bfa_reg_write((rb + MBIST_CTL_REG), __EDRAM_BISTR_START); + bfa_os_udelay(1000); + r32 = bfa_reg_read((rb + MBIST_STAT_REG)); + bfa_trc(ioc, r32); + } + + return BFA_STATUS_OK; +} + /** * Interface used by diag module to do firmware boot with memory test * as the entry vector. @@ -1297,7 +1642,7 @@ bfa_ioc_boot(struct bfa_ioc_s *ioc, u32 boot_type, u32 boot_param) void bfa_ioc_auto_recover(bfa_boolean_t auto_recover) { - bfa_auto_recover = auto_recover; + bfa_auto_recover = BFA_FALSE; } @@ -1419,14 +1764,6 @@ bfa_ioc_pci_init(struct bfa_ioc_s *ioc, struct bfa_pcidev_s *pcidev, ioc->ctdev = (ioc->pcidev.device_id == BFA_PCI_DEVICE_ID_CT); ioc->cna = ioc->ctdev && !ioc->fcmode; - /** - * Set asic specific interfaces. See bfa_ioc_cb.c and bfa_ioc_ct.c - */ - if (ioc->ctdev) - bfa_ioc_set_ct_hwif(ioc); - else - bfa_ioc_set_cb_hwif(ioc); - bfa_ioc_map_port(ioc); bfa_ioc_reg_init(ioc); } @@ -1493,6 +1830,7 @@ return (auto_recover) ? BFA_DBG_FWTRC_LEN : 0; void bfa_ioc_debug_memclaim(struct bfa_ioc_s *ioc, void *dbg_fwsave) { + bfa_assert(ioc->auto_recover); ioc->dbg_fwsave = dbg_fwsave; ioc->dbg_fwsave_len = bfa_ioc_debug_trcsz(ioc->auto_recover); } @@ -1635,7 +1973,7 @@ bfa_ioc_fw_mismatch(struct bfa_ioc_s *ioc) ((__sm) == BFI_IOC_INITING) || \ ((__sm) == BFI_IOC_HWINIT) || \ ((__sm) == BFI_IOC_DISABLED) || \ - ((__sm) == BFI_IOC_FAIL) || \ + ((__sm) == BFI_IOC_HBFAIL) || \ ((__sm) == BFI_IOC_CFG_DISABLED)) /** @@ -1679,28 +2017,46 @@ bfa_ioc_get_adapter_attr(struct bfa_ioc_s *ioc, struct bfa_adapter_attr_s *ad_attr) { struct bfi_ioc_attr_s *ioc_attr; + char model[BFA_ADAPTER_MODEL_NAME_LEN]; ioc_attr = ioc->attr; - - bfa_ioc_get_adapter_serial_num(ioc, ad_attr->serial_num); - bfa_ioc_get_adapter_fw_ver(ioc, ad_attr->fw_ver); - bfa_ioc_get_adapter_optrom_ver(ioc, ad_attr->optrom_ver); - bfa_ioc_get_adapter_manufacturer(ioc, ad_attr->manufacturer); + bfa_os_memcpy((void *)&ad_attr->serial_num, + (void *)ioc_attr->brcd_serialnum, + BFA_ADAPTER_SERIAL_NUM_LEN); + + bfa_os_memcpy(&ad_attr->fw_ver, ioc_attr->fw_version, BFA_VERSION_LEN); + bfa_os_memcpy(&ad_attr->optrom_ver, ioc_attr->optrom_version, + BFA_VERSION_LEN); + bfa_os_memcpy(&ad_attr->manufacturer, BFA_MFG_NAME, + BFA_ADAPTER_MFG_NAME_LEN); bfa_os_memcpy(&ad_attr->vpd, &ioc_attr->vpd, sizeof(struct bfa_mfg_vpd_s)); - ad_attr->nports = bfa_ioc_get_nports(ioc); - ad_attr->max_speed = bfa_ioc_speed_sup(ioc); + ad_attr->nports = BFI_ADAPTER_GETP(NPORTS, ioc_attr->adapter_prop); + ad_attr->max_speed = BFI_ADAPTER_GETP(SPEED, ioc_attr->adapter_prop); - bfa_ioc_get_adapter_model(ioc, ad_attr->model); - /* For now, model descr uses same model string */ - bfa_ioc_get_adapter_model(ioc, ad_attr->model_descr); + /** + * model name + */ + if (BFI_ADAPTER_GETP(SPEED, ioc_attr->adapter_prop) == 10) { + strcpy(model, "BR-10?0"); + model[5] = '0' + ad_attr->nports; + } else { + strcpy(model, "Brocade-??5"); + model[8] = + '0' + BFI_ADAPTER_GETP(SPEED, ioc_attr->adapter_prop); + model[9] = '0' + ad_attr->nports; + } if (BFI_ADAPTER_IS_SPECIAL(ioc_attr->adapter_prop)) ad_attr->prototype = 1; else ad_attr->prototype = 0; + bfa_os_memcpy(&ad_attr->model, model, BFA_ADAPTER_MODEL_NAME_LEN); + bfa_os_memcpy(&ad_attr->model_descr, &ad_attr->model, + BFA_ADAPTER_MODEL_NAME_LEN); + ad_attr->pwwn = bfa_ioc_get_pwwn(ioc); ad_attr->mac = bfa_ioc_get_mac(ioc); @@ -1708,122 +2064,41 @@ bfa_ioc_get_adapter_attr(struct bfa_ioc_s *ioc, ad_attr->pcie_lanes = ioc_attr->pcie_lanes; ad_attr->pcie_lanes_orig = ioc_attr->pcie_lanes_orig; ad_attr->asic_rev = ioc_attr->asic_rev; - - bfa_ioc_get_pci_chip_rev(ioc, ad_attr->hw_ver); + ad_attr->hw_ver[0] = 'R'; + ad_attr->hw_ver[1] = 'e'; + ad_attr->hw_ver[2] = 'v'; + ad_attr->hw_ver[3] = '-'; + ad_attr->hw_ver[4] = ioc_attr->asic_rev; + ad_attr->hw_ver[5] = '\0'; ad_attr->cna_capable = ioc->cna; } -enum bfa_ioc_type_e -bfa_ioc_get_type(struct bfa_ioc_s *ioc) -{ - if (!ioc->ctdev || ioc->fcmode) - return BFA_IOC_TYPE_FC; - else if (ioc->ioc_mc == BFI_MC_IOCFC) - return BFA_IOC_TYPE_FCoE; - else if (ioc->ioc_mc == BFI_MC_LL) - return BFA_IOC_TYPE_LL; - else { - bfa_assert(ioc->ioc_mc == BFI_MC_LL); - return BFA_IOC_TYPE_LL; - } -} - -void -bfa_ioc_get_adapter_serial_num(struct bfa_ioc_s *ioc, char *serial_num) -{ - bfa_os_memset((void *)serial_num, 0, BFA_ADAPTER_SERIAL_NUM_LEN); - bfa_os_memcpy((void *)serial_num, - (void *)ioc->attr->brcd_serialnum, - BFA_ADAPTER_SERIAL_NUM_LEN); -} - -void -bfa_ioc_get_adapter_fw_ver(struct bfa_ioc_s *ioc, char *fw_ver) -{ - bfa_os_memset((void *)fw_ver, 0, BFA_VERSION_LEN); - bfa_os_memcpy(fw_ver, ioc->attr->fw_version, BFA_VERSION_LEN); -} - -void -bfa_ioc_get_pci_chip_rev(struct bfa_ioc_s *ioc, char *chip_rev) -{ - bfa_assert(chip_rev); - - bfa_os_memset((void *)chip_rev, 0, BFA_IOC_CHIP_REV_LEN); - - chip_rev[0] = 'R'; - chip_rev[1] = 'e'; - chip_rev[2] = 'v'; - chip_rev[3] = '-'; - chip_rev[4] = ioc->attr->asic_rev; - chip_rev[5] = '\0'; -} - -void -bfa_ioc_get_adapter_optrom_ver(struct bfa_ioc_s *ioc, char *optrom_ver) -{ - bfa_os_memset((void *)optrom_ver, 0, BFA_VERSION_LEN); - bfa_os_memcpy(optrom_ver, ioc->attr->optrom_version, - BFA_VERSION_LEN); -} - -void -bfa_ioc_get_adapter_manufacturer(struct bfa_ioc_s *ioc, char *manufacturer) -{ - bfa_os_memset((void *)manufacturer, 0, BFA_ADAPTER_MFG_NAME_LEN); - bfa_os_memcpy(manufacturer, BFA_MFG_NAME, BFA_ADAPTER_MFG_NAME_LEN); -} - -void -bfa_ioc_get_adapter_model(struct bfa_ioc_s *ioc, char *model) -{ - struct bfi_ioc_attr_s *ioc_attr; - u8 nports; - u8 max_speed; - - bfa_assert(model); - bfa_os_memset((void *)model, 0, BFA_ADAPTER_MODEL_NAME_LEN); - - ioc_attr = ioc->attr; - - nports = bfa_ioc_get_nports(ioc); - max_speed = bfa_ioc_speed_sup(ioc); - - /** - * model name - */ - if (max_speed == 10) { - strcpy(model, "BR-10?0"); - model[5] = '0' + nports; - } else { - strcpy(model, "Brocade-??5"); - model[8] = '0' + max_speed; - model[9] = '0' + nports; - } -} - -enum bfa_ioc_state -bfa_ioc_get_state(struct bfa_ioc_s *ioc) -{ - return bfa_sm_to_state(ioc_sm_table, ioc->fsm); -} - void bfa_ioc_get_attr(struct bfa_ioc_s *ioc, struct bfa_ioc_attr_s *ioc_attr) { bfa_os_memset((void *)ioc_attr, 0, sizeof(struct bfa_ioc_attr_s)); - ioc_attr->state = bfa_ioc_get_state(ioc); + ioc_attr->state = bfa_sm_to_state(ioc_sm_table, ioc->fsm); ioc_attr->port_id = ioc->port_id; - ioc_attr->ioc_type = bfa_ioc_get_type(ioc); + if (!ioc->ctdev) + ioc_attr->ioc_type = BFA_IOC_TYPE_FC; + else if (ioc->ioc_mc == BFI_MC_IOCFC) + ioc_attr->ioc_type = BFA_IOC_TYPE_FCoE; + else if (ioc->ioc_mc == BFI_MC_LL) + ioc_attr->ioc_type = BFA_IOC_TYPE_LL; bfa_ioc_get_adapter_attr(ioc, &ioc_attr->adapter_attr); ioc_attr->pci_attr.device_id = ioc->pcidev.device_id; ioc_attr->pci_attr.pcifn = ioc->pcidev.pci_func; - bfa_ioc_get_pci_chip_rev(ioc, ioc_attr->pci_attr.chip_rev); + ioc_attr->pci_attr.chip_rev[0] = 'R'; + ioc_attr->pci_attr.chip_rev[1] = 'e'; + ioc_attr->pci_attr.chip_rev[2] = 'v'; + ioc_attr->pci_attr.chip_rev[3] = '-'; + ioc_attr->pci_attr.chip_rev[4] = ioc_attr->adapter_attr.asic_rev; + ioc_attr->pci_attr.chip_rev[5] = '\0'; } /** @@ -1919,6 +2194,29 @@ bfa_ioc_get_fcmode(struct bfa_ioc_s *ioc) return ioc->fcmode || (ioc->pcidev.device_id != BFA_PCI_DEVICE_ID_CT); } +/** + * Return true if interrupt should be claimed. + */ +bfa_boolean_t +bfa_ioc_intx_claim(struct bfa_ioc_s *ioc) +{ + u32 isr, msk; + + /** + * Always claim if not catapult. + */ + if (!ioc->ctdev) + return BFA_TRUE; + + /** + * FALSE if next device is claiming interrupt. + * TRUE if next device is not interrupting or not present. + */ + msk = bfa_reg_read(ioc->ioc_regs.shirq_msk_next); + isr = bfa_reg_read(ioc->ioc_regs.shirq_isr_next); + return !(isr & ~msk); +} + /** * Send AEN notification */ @@ -1928,14 +2226,32 @@ bfa_ioc_aen_post(struct bfa_ioc_s *ioc, enum bfa_ioc_aen_event event) union bfa_aen_data_u aen_data; struct bfa_log_mod_s *logmod = ioc->logm; s32 inst_num = 0; - enum bfa_ioc_type_e ioc_type; + struct bfa_ioc_attr_s ioc_attr; - bfa_log(logmod, BFA_LOG_CREATE_ID(BFA_AEN_CAT_IOC, event), inst_num); + switch (event) { + case BFA_IOC_AEN_HBGOOD: + bfa_log(logmod, BFA_AEN_IOC_HBGOOD, inst_num); + break; + case BFA_IOC_AEN_HBFAIL: + bfa_log(logmod, BFA_AEN_IOC_HBFAIL, inst_num); + break; + case BFA_IOC_AEN_ENABLE: + bfa_log(logmod, BFA_AEN_IOC_ENABLE, inst_num); + break; + case BFA_IOC_AEN_DISABLE: + bfa_log(logmod, BFA_AEN_IOC_DISABLE, inst_num); + break; + case BFA_IOC_AEN_FWMISMATCH: + bfa_log(logmod, BFA_AEN_IOC_FWMISMATCH, inst_num); + break; + default: + break; + } memset(&aen_data.ioc.pwwn, 0, sizeof(aen_data.ioc.pwwn)); memset(&aen_data.ioc.mac, 0, sizeof(aen_data.ioc.mac)); - ioc_type = bfa_ioc_get_type(ioc); - switch (ioc_type) { + bfa_ioc_get_attr(ioc, &ioc_attr); + switch (ioc_attr.ioc_type) { case BFA_IOC_TYPE_FC: aen_data.ioc.pwwn = bfa_ioc_get_pwwn(ioc); break; @@ -1947,10 +2263,10 @@ bfa_ioc_aen_post(struct bfa_ioc_s *ioc, enum bfa_ioc_aen_event event) aen_data.ioc.mac = bfa_ioc_get_mac(ioc); break; default: - bfa_assert(ioc_type == BFA_IOC_TYPE_FC); + bfa_assert(ioc_attr.ioc_type == BFA_IOC_TYPE_FC); break; } - aen_data.ioc.ioc_type = ioc_type; + aen_data.ioc.ioc_type = ioc_attr.ioc_type; } /** @@ -1973,15 +2289,6 @@ bfa_ioc_debug_fwsave(struct bfa_ioc_s *ioc, void *trcdata, int *trclen) return BFA_STATUS_OK; } -/** - * Clear saved firmware trace - */ -void -bfa_ioc_debug_fwsave_clear(struct bfa_ioc_s *ioc) -{ - ioc->dbg_fwsave_once = BFA_TRUE; -} - /** * Retrieve saved firmware trace from a prior IOC failure. */ @@ -1997,13 +2304,6 @@ bfa_ioc_debug_fwtrc(struct bfa_ioc_s *ioc, void *trcdata, int *trclen) pgnum = bfa_ioc_smem_pgnum(ioc, loff); loff = bfa_ioc_smem_pgoff(ioc, loff); - - /* - * Hold semaphore to serialize pll init and fwtrc. - */ - if (BFA_FALSE == bfa_ioc_sem_get(ioc->ioc_regs.ioc_init_sem_reg)) - return BFA_STATUS_FAILED; - bfa_reg_write(ioc->ioc_regs.host_page_num_fn, pgnum); tlen = *trclen; @@ -2029,12 +2329,6 @@ bfa_ioc_debug_fwtrc(struct bfa_ioc_s *ioc, void *trcdata, int *trclen) } bfa_reg_write(ioc->ioc_regs.host_page_num_fn, bfa_ioc_smem_pgnum(ioc, 0)); - - /* - * release semaphore. - */ - bfa_ioc_sem_release(ioc->ioc_regs.ioc_init_sem_reg); - bfa_trc(ioc, pgnum); *trclen = tlen * sizeof(u32); diff --git a/trunk/drivers/scsi/bfa/bfa_ioc.h b/trunk/drivers/scsi/bfa/bfa_ioc.h index d0804406ea1a..7c30f05ab137 100644 --- a/trunk/drivers/scsi/bfa/bfa_ioc.h +++ b/trunk/drivers/scsi/bfa/bfa_ioc.h @@ -74,18 +74,15 @@ struct bfa_ioc_regs_s { bfa_os_addr_t lpu_mbox_cmd; bfa_os_addr_t lpu_mbox; bfa_os_addr_t pss_ctl_reg; - bfa_os_addr_t pss_err_status_reg; bfa_os_addr_t app_pll_fast_ctl_reg; bfa_os_addr_t app_pll_slow_ctl_reg; bfa_os_addr_t ioc_sem_reg; bfa_os_addr_t ioc_usage_sem_reg; - bfa_os_addr_t ioc_init_sem_reg; bfa_os_addr_t ioc_usage_reg; bfa_os_addr_t host_page_num_fn; bfa_os_addr_t heartbeat; bfa_os_addr_t ioc_fwstate; bfa_os_addr_t ll_halt; - bfa_os_addr_t err_set; bfa_os_addr_t shirq_isr_next; bfa_os_addr_t shirq_msk_next; bfa_os_addr_t smem_page_start; @@ -157,6 +154,7 @@ struct bfa_ioc_s { struct bfa_timer_s ioc_timer; struct bfa_timer_s sem_timer; u32 hb_count; + u32 hb_fail; u32 retry_count; struct list_head hb_notify_q; void *dbg_fwsave; @@ -179,22 +177,6 @@ struct bfa_ioc_s { struct bfi_ioc_attr_s *attr; struct bfa_ioc_cbfn_s *cbfn; struct bfa_ioc_mbox_mod_s mbox_mod; - struct bfa_ioc_hwif_s *ioc_hwif; -}; - -struct bfa_ioc_hwif_s { - bfa_status_t (*ioc_pll_init) (struct bfa_ioc_s *ioc); - bfa_boolean_t (*ioc_firmware_lock) (struct bfa_ioc_s *ioc); - void (*ioc_firmware_unlock) (struct bfa_ioc_s *ioc); - u32 * (*ioc_fwimg_get_chunk) (struct bfa_ioc_s *ioc, - u32 off); - u32 (*ioc_fwimg_get_size) (struct bfa_ioc_s *ioc); - void (*ioc_reg_init) (struct bfa_ioc_s *ioc); - void (*ioc_map_port) (struct bfa_ioc_s *ioc); - void (*ioc_isr_mode_set) (struct bfa_ioc_s *ioc, - bfa_boolean_t msix); - void (*ioc_notify_hbfail) (struct bfa_ioc_s *ioc); - void (*ioc_ownership_reset) (struct bfa_ioc_s *ioc); }; #define bfa_ioc_pcifn(__ioc) ((__ioc)->pcidev.pci_func) @@ -209,15 +191,6 @@ struct bfa_ioc_hwif_s { #define bfa_ioc_rx_bbcredit(__ioc) ((__ioc)->attr->rx_bbcredit) #define bfa_ioc_speed_sup(__ioc) \ BFI_ADAPTER_GETP(SPEED, (__ioc)->attr->adapter_prop) -#define bfa_ioc_get_nports(__ioc) \ - BFI_ADAPTER_GETP(NPORTS, (__ioc)->attr->adapter_prop) - -#define bfa_ioc_stats(_ioc, _stats) ((_ioc)->stats._stats++) -#define BFA_IOC_FWIMG_MINSZ (16 * 1024) - -#define BFA_IOC_FLASH_CHUNK_NO(off) (off / BFI_FLASH_CHUNK_SZ_WORDS) -#define BFA_IOC_FLASH_OFFSET_IN_CHUNK(off) (off % BFI_FLASH_CHUNK_SZ_WORDS) -#define BFA_IOC_FLASH_CHUNK_ADDR(chunkno) (chunkno * BFI_FLASH_CHUNK_SZ_WORDS) /** * IOC mailbox interface @@ -234,14 +207,6 @@ void bfa_ioc_mbox_regisr(struct bfa_ioc_s *ioc, enum bfi_mclass mc, /** * IOC interfaces */ -#define bfa_ioc_pll_init(__ioc) ((__ioc)->ioc_hwif->ioc_pll_init(__ioc)) -#define bfa_ioc_isr_mode_set(__ioc, __msix) \ - ((__ioc)->ioc_hwif->ioc_isr_mode_set(__ioc, __msix)) -#define bfa_ioc_ownership_reset(__ioc) \ - ((__ioc)->ioc_hwif->ioc_ownership_reset(__ioc)) - -void bfa_ioc_set_ct_hwif(struct bfa_ioc_s *ioc); -void bfa_ioc_set_cb_hwif(struct bfa_ioc_s *ioc); void bfa_ioc_attach(struct bfa_ioc_s *ioc, void *bfa, struct bfa_ioc_cbfn_s *cbfn, struct bfa_timer_mod_s *timer_mod, struct bfa_trc_mod_s *trcmod, @@ -258,21 +223,13 @@ bfa_boolean_t bfa_ioc_intx_claim(struct bfa_ioc_s *ioc); void bfa_ioc_boot(struct bfa_ioc_s *ioc, u32 boot_type, u32 boot_param); void bfa_ioc_isr(struct bfa_ioc_s *ioc, struct bfi_mbmsg_s *msg); void bfa_ioc_error_isr(struct bfa_ioc_s *ioc); +void bfa_ioc_isr_mode_set(struct bfa_ioc_s *ioc, bfa_boolean_t intx); +bfa_status_t bfa_ioc_pll_init(struct bfa_ioc_s *ioc); bfa_boolean_t bfa_ioc_is_operational(struct bfa_ioc_s *ioc); bfa_boolean_t bfa_ioc_is_disabled(struct bfa_ioc_s *ioc); bfa_boolean_t bfa_ioc_fw_mismatch(struct bfa_ioc_s *ioc); bfa_boolean_t bfa_ioc_adapter_is_disabled(struct bfa_ioc_s *ioc); void bfa_ioc_cfg_complete(struct bfa_ioc_s *ioc); -enum bfa_ioc_type_e bfa_ioc_get_type(struct bfa_ioc_s *ioc); -void bfa_ioc_get_adapter_serial_num(struct bfa_ioc_s *ioc, char *serial_num); -void bfa_ioc_get_adapter_fw_ver(struct bfa_ioc_s *ioc, char *fw_ver); -void bfa_ioc_get_adapter_optrom_ver(struct bfa_ioc_s *ioc, char *optrom_ver); -void bfa_ioc_get_adapter_model(struct bfa_ioc_s *ioc, char *model); -void bfa_ioc_get_adapter_manufacturer(struct bfa_ioc_s *ioc, - char *manufacturer); -void bfa_ioc_get_pci_chip_rev(struct bfa_ioc_s *ioc, char *chip_rev); -enum bfa_ioc_state bfa_ioc_get_state(struct bfa_ioc_s *ioc); - void bfa_ioc_get_attr(struct bfa_ioc_s *ioc, struct bfa_ioc_attr_s *ioc_attr); void bfa_ioc_get_adapter_attr(struct bfa_ioc_s *ioc, struct bfa_adapter_attr_s *ad_attr); @@ -280,7 +237,6 @@ int bfa_ioc_debug_trcsz(bfa_boolean_t auto_recover); void bfa_ioc_debug_memclaim(struct bfa_ioc_s *ioc, void *dbg_fwsave); bfa_status_t bfa_ioc_debug_fwsave(struct bfa_ioc_s *ioc, void *trcdata, int *trclen); -void bfa_ioc_debug_fwsave_clear(struct bfa_ioc_s *ioc); bfa_status_t bfa_ioc_debug_fwtrc(struct bfa_ioc_s *ioc, void *trcdata, int *trclen); u32 bfa_ioc_smem_pgnum(struct bfa_ioc_s *ioc, u32 fmaddr); @@ -289,13 +245,6 @@ void bfa_ioc_set_fcmode(struct bfa_ioc_s *ioc); bfa_boolean_t bfa_ioc_get_fcmode(struct bfa_ioc_s *ioc); void bfa_ioc_hbfail_register(struct bfa_ioc_s *ioc, struct bfa_ioc_hbfail_notify_s *notify); -bfa_boolean_t bfa_ioc_sem_get(bfa_os_addr_t sem_reg); -void bfa_ioc_sem_release(bfa_os_addr_t sem_reg); -void bfa_ioc_hw_sem_release(struct bfa_ioc_s *ioc); -void bfa_ioc_fwver_get(struct bfa_ioc_s *ioc, - struct bfi_ioc_image_hdr_s *fwhdr); -bfa_boolean_t bfa_ioc_fwver_cmp(struct bfa_ioc_s *ioc, - struct bfi_ioc_image_hdr_s *fwhdr); /* * bfa mfg wwn API functions diff --git a/trunk/drivers/scsi/bfa/bfa_ioc_cb.c b/trunk/drivers/scsi/bfa/bfa_ioc_cb.c deleted file mode 100644 index 3ce85319f739..000000000000 --- a/trunk/drivers/scsi/bfa/bfa_ioc_cb.c +++ /dev/null @@ -1,274 +0,0 @@ -/* - * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. - * All rights reserved - * www.brocade.com - * - * Linux driver for Brocade Fibre Channel Host Bus Adapter. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License (GPL) Version 2 as - * published by the Free Software Foundation - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -BFA_TRC_FILE(CNA, IOC_CB); - -/* - * forward declarations - */ -static bfa_status_t bfa_ioc_cb_pll_init(struct bfa_ioc_s *ioc); -static bfa_boolean_t bfa_ioc_cb_firmware_lock(struct bfa_ioc_s *ioc); -static void bfa_ioc_cb_firmware_unlock(struct bfa_ioc_s *ioc); -static u32 *bfa_ioc_cb_fwimg_get_chunk(struct bfa_ioc_s *ioc, u32 off); -static u32 bfa_ioc_cb_fwimg_get_size(struct bfa_ioc_s *ioc); -static void bfa_ioc_cb_reg_init(struct bfa_ioc_s *ioc); -static void bfa_ioc_cb_map_port(struct bfa_ioc_s *ioc); -static void bfa_ioc_cb_isr_mode_set(struct bfa_ioc_s *ioc, bfa_boolean_t msix); -static void bfa_ioc_cb_notify_hbfail(struct bfa_ioc_s *ioc); -static void bfa_ioc_cb_ownership_reset(struct bfa_ioc_s *ioc); - -struct bfa_ioc_hwif_s hwif_cb = { - bfa_ioc_cb_pll_init, - bfa_ioc_cb_firmware_lock, - bfa_ioc_cb_firmware_unlock, - bfa_ioc_cb_fwimg_get_chunk, - bfa_ioc_cb_fwimg_get_size, - bfa_ioc_cb_reg_init, - bfa_ioc_cb_map_port, - bfa_ioc_cb_isr_mode_set, - bfa_ioc_cb_notify_hbfail, - bfa_ioc_cb_ownership_reset, -}; - -/** - * Called from bfa_ioc_attach() to map asic specific calls. - */ -void -bfa_ioc_set_cb_hwif(struct bfa_ioc_s *ioc) -{ - ioc->ioc_hwif = &hwif_cb; -} - -static u32 * -bfa_ioc_cb_fwimg_get_chunk(struct bfa_ioc_s *ioc, u32 off) -{ - return bfi_image_cb_get_chunk(off); -} - -static u32 -bfa_ioc_cb_fwimg_get_size(struct bfa_ioc_s *ioc) -{ - return bfi_image_cb_size; -} - -/** - * Return true if firmware of current driver matches the running firmware. - */ -static bfa_boolean_t -bfa_ioc_cb_firmware_lock(struct bfa_ioc_s *ioc) -{ - return BFA_TRUE; -} - -static void -bfa_ioc_cb_firmware_unlock(struct bfa_ioc_s *ioc) -{ -} - -/** - * Notify other functions on HB failure. - */ -static void -bfa_ioc_cb_notify_hbfail(struct bfa_ioc_s *ioc) -{ - bfa_reg_write(ioc->ioc_regs.err_set, __PSS_ERR_STATUS_SET); - bfa_reg_read(ioc->ioc_regs.err_set); -} - -/** - * Host to LPU mailbox message addresses - */ -static struct { u32 hfn_mbox, lpu_mbox, hfn_pgn; } iocreg_fnreg[] = { - { HOSTFN0_LPU_MBOX0_0, LPU_HOSTFN0_MBOX0_0, HOST_PAGE_NUM_FN0 }, - { HOSTFN1_LPU_MBOX0_8, LPU_HOSTFN1_MBOX0_8, HOST_PAGE_NUM_FN1 } -}; - -/** - * Host <-> LPU mailbox command/status registers - */ -static struct { u32 hfn, lpu; } iocreg_mbcmd[] = { - { HOSTFN0_LPU0_CMD_STAT, LPU0_HOSTFN0_CMD_STAT }, - { HOSTFN1_LPU1_CMD_STAT, LPU1_HOSTFN1_CMD_STAT } -}; - -static void -bfa_ioc_cb_reg_init(struct bfa_ioc_s *ioc) -{ - bfa_os_addr_t rb; - int pcifn = bfa_ioc_pcifn(ioc); - - rb = bfa_ioc_bar0(ioc); - - ioc->ioc_regs.hfn_mbox = rb + iocreg_fnreg[pcifn].hfn_mbox; - ioc->ioc_regs.lpu_mbox = rb + iocreg_fnreg[pcifn].lpu_mbox; - ioc->ioc_regs.host_page_num_fn = rb + iocreg_fnreg[pcifn].hfn_pgn; - - if (ioc->port_id == 0) { - ioc->ioc_regs.heartbeat = rb + BFA_IOC0_HBEAT_REG; - ioc->ioc_regs.ioc_fwstate = rb + BFA_IOC0_STATE_REG; - } else { - ioc->ioc_regs.heartbeat = (rb + BFA_IOC1_HBEAT_REG); - ioc->ioc_regs.ioc_fwstate = (rb + BFA_IOC1_STATE_REG); - } - - /** - * Host <-> LPU mailbox command/status registers - */ - ioc->ioc_regs.hfn_mbox_cmd = rb + iocreg_mbcmd[pcifn].hfn; - ioc->ioc_regs.lpu_mbox_cmd = rb + iocreg_mbcmd[pcifn].lpu; - - /* - * PSS control registers - */ - ioc->ioc_regs.pss_ctl_reg = (rb + PSS_CTL_REG); - ioc->ioc_regs.pss_err_status_reg = (rb + PSS_ERR_STATUS_REG); - ioc->ioc_regs.app_pll_fast_ctl_reg = (rb + APP_PLL_400_CTL_REG); - ioc->ioc_regs.app_pll_slow_ctl_reg = (rb + APP_PLL_212_CTL_REG); - - /* - * IOC semaphore registers and serialization - */ - ioc->ioc_regs.ioc_sem_reg = (rb + HOST_SEM0_REG); - ioc->ioc_regs.ioc_init_sem_reg = (rb + HOST_SEM2_REG); - - /** - * sram memory access - */ - ioc->ioc_regs.smem_page_start = (rb + PSS_SMEM_PAGE_START); - ioc->ioc_regs.smem_pg0 = BFI_IOC_SMEM_PG0_CB; - - /* - * err set reg : for notification of hb failure - */ - ioc->ioc_regs.err_set = (rb + ERR_SET_REG); -} - -/** - * Initialize IOC to port mapping. - */ -static void -bfa_ioc_cb_map_port(struct bfa_ioc_s *ioc) -{ - /** - * For crossbow, port id is same as pci function. - */ - ioc->port_id = bfa_ioc_pcifn(ioc); - bfa_trc(ioc, ioc->port_id); -} - -/** - * Set interrupt mode for a function: INTX or MSIX - */ -static void -bfa_ioc_cb_isr_mode_set(struct bfa_ioc_s *ioc, bfa_boolean_t msix) -{ -} - -static bfa_status_t -bfa_ioc_cb_pll_init(struct bfa_ioc_s *ioc) -{ - bfa_os_addr_t rb = ioc->pcidev.pci_bar_kva; - u32 pll_sclk, pll_fclk; - - /* - * Hold semaphore so that nobody can access the chip during init. - */ - bfa_ioc_sem_get(ioc->ioc_regs.ioc_init_sem_reg); - - pll_sclk = __APP_PLL_212_ENABLE | __APP_PLL_212_LRESETN | - __APP_PLL_212_P0_1(3U) | - __APP_PLL_212_JITLMT0_1(3U) | - __APP_PLL_212_CNTLMT0_1(3U); - pll_fclk = __APP_PLL_400_ENABLE | __APP_PLL_400_LRESETN | - __APP_PLL_400_RSEL200500 | __APP_PLL_400_P0_1(3U) | - __APP_PLL_400_JITLMT0_1(3U) | - __APP_PLL_400_CNTLMT0_1(3U); - - bfa_reg_write((rb + BFA_IOC0_STATE_REG), BFI_IOC_UNINIT); - bfa_reg_write((rb + BFA_IOC1_STATE_REG), BFI_IOC_UNINIT); - - bfa_reg_write((rb + HOSTFN0_INT_MSK), 0xffffffffU); - bfa_reg_write((rb + HOSTFN1_INT_MSK), 0xffffffffU); - bfa_reg_write((rb + HOSTFN0_INT_STATUS), 0xffffffffU); - bfa_reg_write((rb + HOSTFN1_INT_STATUS), 0xffffffffU); - bfa_reg_write((rb + HOSTFN0_INT_MSK), 0xffffffffU); - bfa_reg_write((rb + HOSTFN1_INT_MSK), 0xffffffffU); - - bfa_reg_write(ioc->ioc_regs.app_pll_slow_ctl_reg, - __APP_PLL_212_LOGIC_SOFT_RESET); - bfa_reg_write(ioc->ioc_regs.app_pll_slow_ctl_reg, - __APP_PLL_212_BYPASS | - __APP_PLL_212_LOGIC_SOFT_RESET); - bfa_reg_write(ioc->ioc_regs.app_pll_fast_ctl_reg, - __APP_PLL_400_LOGIC_SOFT_RESET); - bfa_reg_write(ioc->ioc_regs.app_pll_fast_ctl_reg, - __APP_PLL_400_BYPASS | - __APP_PLL_400_LOGIC_SOFT_RESET); - bfa_os_udelay(2); - bfa_reg_write(ioc->ioc_regs.app_pll_slow_ctl_reg, - __APP_PLL_212_LOGIC_SOFT_RESET); - bfa_reg_write(ioc->ioc_regs.app_pll_fast_ctl_reg, - __APP_PLL_400_LOGIC_SOFT_RESET); - - bfa_reg_write(ioc->ioc_regs.app_pll_slow_ctl_reg, - pll_sclk | __APP_PLL_212_LOGIC_SOFT_RESET); - bfa_reg_write(ioc->ioc_regs.app_pll_fast_ctl_reg, - pll_fclk | __APP_PLL_400_LOGIC_SOFT_RESET); - - /** - * Wait for PLLs to lock. - */ - bfa_os_udelay(2000); - bfa_reg_write((rb + HOSTFN0_INT_STATUS), 0xffffffffU); - bfa_reg_write((rb + HOSTFN1_INT_STATUS), 0xffffffffU); - - bfa_reg_write(ioc->ioc_regs.app_pll_slow_ctl_reg, pll_sclk); - bfa_reg_write(ioc->ioc_regs.app_pll_fast_ctl_reg, pll_fclk); - - /* - * release semaphore. - */ - bfa_ioc_sem_release(ioc->ioc_regs.ioc_init_sem_reg); - - return BFA_STATUS_OK; -} - -/** - * Cleanup hw semaphore and usecnt registers - */ -static void -bfa_ioc_cb_ownership_reset(struct bfa_ioc_s *ioc) -{ - - /* - * Read the hw sem reg to make sure that it is locked - * before we clear it. If it is not locked, writing 1 - * will lock it instead of clearing it. - */ - bfa_reg_read(ioc->ioc_regs.ioc_sem_reg); - bfa_ioc_hw_sem_release(ioc); -} diff --git a/trunk/drivers/scsi/bfa/bfa_ioc_ct.c b/trunk/drivers/scsi/bfa/bfa_ioc_ct.c deleted file mode 100644 index 20b58ad5f95c..000000000000 --- a/trunk/drivers/scsi/bfa/bfa_ioc_ct.c +++ /dev/null @@ -1,423 +0,0 @@ -/* - * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. - * All rights reserved - * www.brocade.com - * - * Linux driver for Brocade Fibre Channel Host Bus Adapter. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License (GPL) Version 2 as - * published by the Free Software Foundation - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -BFA_TRC_FILE(CNA, IOC_CT); - -/* - * forward declarations - */ -static bfa_status_t bfa_ioc_ct_pll_init(struct bfa_ioc_s *ioc); -static bfa_boolean_t bfa_ioc_ct_firmware_lock(struct bfa_ioc_s *ioc); -static void bfa_ioc_ct_firmware_unlock(struct bfa_ioc_s *ioc); -static u32* bfa_ioc_ct_fwimg_get_chunk(struct bfa_ioc_s *ioc, - u32 off); -static u32 bfa_ioc_ct_fwimg_get_size(struct bfa_ioc_s *ioc); -static void bfa_ioc_ct_reg_init(struct bfa_ioc_s *ioc); -static void bfa_ioc_ct_map_port(struct bfa_ioc_s *ioc); -static void bfa_ioc_ct_isr_mode_set(struct bfa_ioc_s *ioc, bfa_boolean_t msix); -static void bfa_ioc_ct_notify_hbfail(struct bfa_ioc_s *ioc); -static void bfa_ioc_ct_ownership_reset(struct bfa_ioc_s *ioc); - -struct bfa_ioc_hwif_s hwif_ct = { - bfa_ioc_ct_pll_init, - bfa_ioc_ct_firmware_lock, - bfa_ioc_ct_firmware_unlock, - bfa_ioc_ct_fwimg_get_chunk, - bfa_ioc_ct_fwimg_get_size, - bfa_ioc_ct_reg_init, - bfa_ioc_ct_map_port, - bfa_ioc_ct_isr_mode_set, - bfa_ioc_ct_notify_hbfail, - bfa_ioc_ct_ownership_reset, -}; - -/** - * Called from bfa_ioc_attach() to map asic specific calls. - */ -void -bfa_ioc_set_ct_hwif(struct bfa_ioc_s *ioc) -{ - ioc->ioc_hwif = &hwif_ct; -} - -static u32* -bfa_ioc_ct_fwimg_get_chunk(struct bfa_ioc_s *ioc, u32 off) -{ - return bfi_image_ct_get_chunk(off); -} - -static u32 -bfa_ioc_ct_fwimg_get_size(struct bfa_ioc_s *ioc) -{ - return bfi_image_ct_size; -} - -/** - * Return true if firmware of current driver matches the running firmware. - */ -static bfa_boolean_t -bfa_ioc_ct_firmware_lock(struct bfa_ioc_s *ioc) -{ - enum bfi_ioc_state ioc_fwstate; - u32 usecnt; - struct bfi_ioc_image_hdr_s fwhdr; - - /** - * Firmware match check is relevant only for CNA. - */ - if (!ioc->cna) - return BFA_TRUE; - - /** - * If bios boot (flash based) -- do not increment usage count - */ - if (bfa_ioc_ct_fwimg_get_size(ioc) < BFA_IOC_FWIMG_MINSZ) - return BFA_TRUE; - - bfa_ioc_sem_get(ioc->ioc_regs.ioc_usage_sem_reg); - usecnt = bfa_reg_read(ioc->ioc_regs.ioc_usage_reg); - - /** - * If usage count is 0, always return TRUE. - */ - if (usecnt == 0) { - bfa_reg_write(ioc->ioc_regs.ioc_usage_reg, 1); - bfa_ioc_sem_release(ioc->ioc_regs.ioc_usage_sem_reg); - bfa_trc(ioc, usecnt); - return BFA_TRUE; - } - - ioc_fwstate = bfa_reg_read(ioc->ioc_regs.ioc_fwstate); - bfa_trc(ioc, ioc_fwstate); - - /** - * Use count cannot be non-zero and chip in uninitialized state. - */ - bfa_assert(ioc_fwstate != BFI_IOC_UNINIT); - - /** - * Check if another driver with a different firmware is active - */ - bfa_ioc_fwver_get(ioc, &fwhdr); - if (!bfa_ioc_fwver_cmp(ioc, &fwhdr)) { - bfa_ioc_sem_release(ioc->ioc_regs.ioc_usage_sem_reg); - bfa_trc(ioc, usecnt); - return BFA_FALSE; - } - - /** - * Same firmware version. Increment the reference count. - */ - usecnt++; - bfa_reg_write(ioc->ioc_regs.ioc_usage_reg, usecnt); - bfa_ioc_sem_release(ioc->ioc_regs.ioc_usage_sem_reg); - bfa_trc(ioc, usecnt); - return BFA_TRUE; -} - -static void -bfa_ioc_ct_firmware_unlock(struct bfa_ioc_s *ioc) -{ - u32 usecnt; - - /** - * Firmware lock is relevant only for CNA. - * If bios boot (flash based) -- do not decrement usage count - */ - if (!ioc->cna || bfa_ioc_ct_fwimg_get_size(ioc) < BFA_IOC_FWIMG_MINSZ) - return; - - /** - * decrement usage count - */ - bfa_ioc_sem_get(ioc->ioc_regs.ioc_usage_sem_reg); - usecnt = bfa_reg_read(ioc->ioc_regs.ioc_usage_reg); - bfa_assert(usecnt > 0); - - usecnt--; - bfa_reg_write(ioc->ioc_regs.ioc_usage_reg, usecnt); - bfa_trc(ioc, usecnt); - - bfa_ioc_sem_release(ioc->ioc_regs.ioc_usage_sem_reg); -} - -/** - * Notify other functions on HB failure. - */ -static void -bfa_ioc_ct_notify_hbfail(struct bfa_ioc_s *ioc) -{ - if (ioc->cna) { - bfa_reg_write(ioc->ioc_regs.ll_halt, __FW_INIT_HALT_P); - /* Wait for halt to take effect */ - bfa_reg_read(ioc->ioc_regs.ll_halt); - } else { - bfa_reg_write(ioc->ioc_regs.err_set, __PSS_ERR_STATUS_SET); - bfa_reg_read(ioc->ioc_regs.err_set); - } -} - -/** - * Host to LPU mailbox message addresses - */ -static struct { u32 hfn_mbox, lpu_mbox, hfn_pgn; } iocreg_fnreg[] = { - { HOSTFN0_LPU_MBOX0_0, LPU_HOSTFN0_MBOX0_0, HOST_PAGE_NUM_FN0 }, - { HOSTFN1_LPU_MBOX0_8, LPU_HOSTFN1_MBOX0_8, HOST_PAGE_NUM_FN1 }, - { HOSTFN2_LPU_MBOX0_0, LPU_HOSTFN2_MBOX0_0, HOST_PAGE_NUM_FN2 }, - { HOSTFN3_LPU_MBOX0_8, LPU_HOSTFN3_MBOX0_8, HOST_PAGE_NUM_FN3 } -}; - -/** - * Host <-> LPU mailbox command/status registers - port 0 - */ -static struct { u32 hfn, lpu; } iocreg_mbcmd_p0[] = { - { HOSTFN0_LPU0_MBOX0_CMD_STAT, LPU0_HOSTFN0_MBOX0_CMD_STAT }, - { HOSTFN1_LPU0_MBOX0_CMD_STAT, LPU0_HOSTFN1_MBOX0_CMD_STAT }, - { HOSTFN2_LPU0_MBOX0_CMD_STAT, LPU0_HOSTFN2_MBOX0_CMD_STAT }, - { HOSTFN3_LPU0_MBOX0_CMD_STAT, LPU0_HOSTFN3_MBOX0_CMD_STAT } -}; - -/** - * Host <-> LPU mailbox command/status registers - port 1 - */ -static struct { u32 hfn, lpu; } iocreg_mbcmd_p1[] = { - { HOSTFN0_LPU1_MBOX0_CMD_STAT, LPU1_HOSTFN0_MBOX0_CMD_STAT }, - { HOSTFN1_LPU1_MBOX0_CMD_STAT, LPU1_HOSTFN1_MBOX0_CMD_STAT }, - { HOSTFN2_LPU1_MBOX0_CMD_STAT, LPU1_HOSTFN2_MBOX0_CMD_STAT }, - { HOSTFN3_LPU1_MBOX0_CMD_STAT, LPU1_HOSTFN3_MBOX0_CMD_STAT } -}; - -static void -bfa_ioc_ct_reg_init(struct bfa_ioc_s *ioc) -{ - bfa_os_addr_t rb; - int pcifn = bfa_ioc_pcifn(ioc); - - rb = bfa_ioc_bar0(ioc); - - ioc->ioc_regs.hfn_mbox = rb + iocreg_fnreg[pcifn].hfn_mbox; - ioc->ioc_regs.lpu_mbox = rb + iocreg_fnreg[pcifn].lpu_mbox; - ioc->ioc_regs.host_page_num_fn = rb + iocreg_fnreg[pcifn].hfn_pgn; - - if (ioc->port_id == 0) { - ioc->ioc_regs.heartbeat = rb + BFA_IOC0_HBEAT_REG; - ioc->ioc_regs.ioc_fwstate = rb + BFA_IOC0_STATE_REG; - ioc->ioc_regs.hfn_mbox_cmd = rb + iocreg_mbcmd_p0[pcifn].hfn; - ioc->ioc_regs.lpu_mbox_cmd = rb + iocreg_mbcmd_p0[pcifn].lpu; - ioc->ioc_regs.ll_halt = rb + FW_INIT_HALT_P0; - } else { - ioc->ioc_regs.heartbeat = (rb + BFA_IOC1_HBEAT_REG); - ioc->ioc_regs.ioc_fwstate = (rb + BFA_IOC1_STATE_REG); - ioc->ioc_regs.hfn_mbox_cmd = rb + iocreg_mbcmd_p1[pcifn].hfn; - ioc->ioc_regs.lpu_mbox_cmd = rb + iocreg_mbcmd_p1[pcifn].lpu; - ioc->ioc_regs.ll_halt = rb + FW_INIT_HALT_P1; - } - - /* - * PSS control registers - */ - ioc->ioc_regs.pss_ctl_reg = (rb + PSS_CTL_REG); - ioc->ioc_regs.pss_err_status_reg = (rb + PSS_ERR_STATUS_REG); - ioc->ioc_regs.app_pll_fast_ctl_reg = (rb + APP_PLL_425_CTL_REG); - ioc->ioc_regs.app_pll_slow_ctl_reg = (rb + APP_PLL_312_CTL_REG); - - /* - * IOC semaphore registers and serialization - */ - ioc->ioc_regs.ioc_sem_reg = (rb + HOST_SEM0_REG); - ioc->ioc_regs.ioc_usage_sem_reg = (rb + HOST_SEM1_REG); - ioc->ioc_regs.ioc_init_sem_reg = (rb + HOST_SEM2_REG); - ioc->ioc_regs.ioc_usage_reg = (rb + BFA_FW_USE_COUNT); - - /** - * sram memory access - */ - ioc->ioc_regs.smem_page_start = (rb + PSS_SMEM_PAGE_START); - ioc->ioc_regs.smem_pg0 = BFI_IOC_SMEM_PG0_CT; - - /* - * err set reg : for notification of hb failure in fcmode - */ - ioc->ioc_regs.err_set = (rb + ERR_SET_REG); -} - -/** - * Initialize IOC to port mapping. - */ - -#define FNC_PERS_FN_SHIFT(__fn) ((__fn) * 8) -static void -bfa_ioc_ct_map_port(struct bfa_ioc_s *ioc) -{ - bfa_os_addr_t rb = ioc->pcidev.pci_bar_kva; - u32 r32; - - /** - * For catapult, base port id on personality register and IOC type - */ - r32 = bfa_reg_read(rb + FNC_PERS_REG); - r32 >>= FNC_PERS_FN_SHIFT(bfa_ioc_pcifn(ioc)); - ioc->port_id = (r32 & __F0_PORT_MAP_MK) >> __F0_PORT_MAP_SH; - - bfa_trc(ioc, bfa_ioc_pcifn(ioc)); - bfa_trc(ioc, ioc->port_id); -} - -/** - * Set interrupt mode for a function: INTX or MSIX - */ -static void -bfa_ioc_ct_isr_mode_set(struct bfa_ioc_s *ioc, bfa_boolean_t msix) -{ - bfa_os_addr_t rb = ioc->pcidev.pci_bar_kva; - u32 r32, mode; - - r32 = bfa_reg_read(rb + FNC_PERS_REG); - bfa_trc(ioc, r32); - - mode = (r32 >> FNC_PERS_FN_SHIFT(bfa_ioc_pcifn(ioc))) & - __F0_INTX_STATUS; - - /** - * If already in desired mode, do not change anything - */ - if (!msix && mode) - return; - - if (msix) - mode = __F0_INTX_STATUS_MSIX; - else - mode = __F0_INTX_STATUS_INTA; - - r32 &= ~(__F0_INTX_STATUS << FNC_PERS_FN_SHIFT(bfa_ioc_pcifn(ioc))); - r32 |= (mode << FNC_PERS_FN_SHIFT(bfa_ioc_pcifn(ioc))); - bfa_trc(ioc, r32); - - bfa_reg_write(rb + FNC_PERS_REG, r32); -} - -static bfa_status_t -bfa_ioc_ct_pll_init(struct bfa_ioc_s *ioc) -{ - bfa_os_addr_t rb = ioc->pcidev.pci_bar_kva; - u32 pll_sclk, pll_fclk, r32; - - /* - * Hold semaphore so that nobody can access the chip during init. - */ - bfa_ioc_sem_get(ioc->ioc_regs.ioc_init_sem_reg); - - pll_sclk = __APP_PLL_312_LRESETN | __APP_PLL_312_ENARST | - __APP_PLL_312_RSEL200500 | __APP_PLL_312_P0_1(3U) | - __APP_PLL_312_JITLMT0_1(3U) | - __APP_PLL_312_CNTLMT0_1(1U); - pll_fclk = __APP_PLL_425_LRESETN | __APP_PLL_425_ENARST | - __APP_PLL_425_RSEL200500 | __APP_PLL_425_P0_1(3U) | - __APP_PLL_425_JITLMT0_1(3U) | - __APP_PLL_425_CNTLMT0_1(1U); - - /** - * For catapult, choose operational mode FC/FCoE - */ - if (ioc->fcmode) { - bfa_reg_write((rb + OP_MODE), 0); - bfa_reg_write((rb + ETH_MAC_SER_REG), - __APP_EMS_CMLCKSEL | - __APP_EMS_REFCKBUFEN2 | - __APP_EMS_CHANNEL_SEL); - } else { - ioc->pllinit = BFA_TRUE; - bfa_reg_write((rb + OP_MODE), __GLOBAL_FCOE_MODE); - bfa_reg_write((rb + ETH_MAC_SER_REG), - __APP_EMS_REFCKBUFEN1); - } - - bfa_reg_write((rb + BFA_IOC0_STATE_REG), BFI_IOC_UNINIT); - bfa_reg_write((rb + BFA_IOC1_STATE_REG), BFI_IOC_UNINIT); - - bfa_reg_write((rb + HOSTFN0_INT_MSK), 0xffffffffU); - bfa_reg_write((rb + HOSTFN1_INT_MSK), 0xffffffffU); - bfa_reg_write((rb + HOSTFN0_INT_STATUS), 0xffffffffU); - bfa_reg_write((rb + HOSTFN1_INT_STATUS), 0xffffffffU); - bfa_reg_write((rb + HOSTFN0_INT_MSK), 0xffffffffU); - bfa_reg_write((rb + HOSTFN1_INT_MSK), 0xffffffffU); - - bfa_reg_write(ioc->ioc_regs.app_pll_slow_ctl_reg, pll_sclk | - __APP_PLL_312_LOGIC_SOFT_RESET); - bfa_reg_write(ioc->ioc_regs.app_pll_fast_ctl_reg, pll_fclk | - __APP_PLL_425_LOGIC_SOFT_RESET); - bfa_reg_write(ioc->ioc_regs.app_pll_slow_ctl_reg, pll_sclk | - __APP_PLL_312_LOGIC_SOFT_RESET | __APP_PLL_312_ENABLE); - bfa_reg_write(ioc->ioc_regs.app_pll_fast_ctl_reg, pll_fclk | - __APP_PLL_425_LOGIC_SOFT_RESET | __APP_PLL_425_ENABLE); - - /** - * Wait for PLLs to lock. - */ - bfa_reg_read(rb + HOSTFN0_INT_MSK); - bfa_os_udelay(2000); - bfa_reg_write((rb + HOSTFN0_INT_STATUS), 0xffffffffU); - bfa_reg_write((rb + HOSTFN1_INT_STATUS), 0xffffffffU); - - bfa_reg_write(ioc->ioc_regs.app_pll_slow_ctl_reg, pll_sclk | - __APP_PLL_312_ENABLE); - bfa_reg_write(ioc->ioc_regs.app_pll_fast_ctl_reg, pll_fclk | - __APP_PLL_425_ENABLE); - - bfa_reg_write((rb + MBIST_CTL_REG), __EDRAM_BISTR_START); - bfa_os_udelay(1000); - r32 = bfa_reg_read((rb + MBIST_STAT_REG)); - bfa_trc(ioc, r32); - /* - * release semaphore. - */ - bfa_ioc_sem_release(ioc->ioc_regs.ioc_init_sem_reg); - - return BFA_STATUS_OK; -} - -/** - * Cleanup hw semaphore and usecnt registers - */ -static void -bfa_ioc_ct_ownership_reset(struct bfa_ioc_s *ioc) -{ - - if (ioc->cna) { - bfa_ioc_sem_get(ioc->ioc_regs.ioc_usage_sem_reg); - bfa_reg_write(ioc->ioc_regs.ioc_usage_reg, 0); - bfa_ioc_sem_release(ioc->ioc_regs.ioc_usage_sem_reg); - } - - /* - * Read the hw sem reg to make sure that it is locked - * before we clear it. If it is not locked, writing 1 - * will lock it instead of clearing it. - */ - bfa_reg_read(ioc->ioc_regs.ioc_sem_reg); - bfa_ioc_hw_sem_release(ioc); -} diff --git a/trunk/drivers/scsi/bfa/bfa_iocfc.c b/trunk/drivers/scsi/bfa/bfa_iocfc.c index a76de2669bfc..d7ab792a9e54 100644 --- a/trunk/drivers/scsi/bfa/bfa_iocfc.c +++ b/trunk/drivers/scsi/bfa/bfa_iocfc.c @@ -172,7 +172,6 @@ bfa_iocfc_init_mem(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, */ if (bfa_ioc_devid(&bfa->ioc) == BFA_PCI_DEVICE_ID_CT) { iocfc->hwif.hw_reginit = bfa_hwct_reginit; - iocfc->hwif.hw_reqq_ack = bfa_hwct_reqq_ack; iocfc->hwif.hw_rspq_ack = bfa_hwct_rspq_ack; iocfc->hwif.hw_msix_init = bfa_hwct_msix_init; iocfc->hwif.hw_msix_install = bfa_hwct_msix_install; @@ -181,7 +180,6 @@ bfa_iocfc_init_mem(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, iocfc->hwif.hw_msix_getvecs = bfa_hwct_msix_getvecs; } else { iocfc->hwif.hw_reginit = bfa_hwcb_reginit; - iocfc->hwif.hw_reqq_ack = bfa_hwcb_reqq_ack; iocfc->hwif.hw_rspq_ack = bfa_hwcb_rspq_ack; iocfc->hwif.hw_msix_init = bfa_hwcb_msix_init; iocfc->hwif.hw_msix_install = bfa_hwcb_msix_install; @@ -338,10 +336,8 @@ bfa_iocfc_init_cb(void *bfa_arg, bfa_boolean_t complete) bfa_cb_init(bfa->bfad, BFA_STATUS_OK); else bfa_cb_init(bfa->bfad, BFA_STATUS_FAILED); - } else { - if (bfa->iocfc.cfgdone) - bfa->iocfc.action = BFA_IOCFC_ACT_NONE; - } + } else + bfa->iocfc.action = BFA_IOCFC_ACT_NONE; } static void @@ -623,6 +619,8 @@ bfa_iocfc_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, bfa_ioc_attach(&bfa->ioc, bfa, &bfa_iocfc_cbfn, &bfa->timer_mod, bfa->trcmod, bfa->aen, bfa->logm); + bfa_ioc_pci_init(&bfa->ioc, pcidev, BFI_MC_IOCFC); + bfa_ioc_mbox_register(&bfa->ioc, bfa_mbox_isrs); /** * Choose FC (ssid: 0x1C) v/s FCoE (ssid: 0x14) mode. @@ -630,9 +628,6 @@ bfa_iocfc_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, if (0) bfa_ioc_set_fcmode(&bfa->ioc); - bfa_ioc_pci_init(&bfa->ioc, pcidev, BFI_MC_IOCFC); - bfa_ioc_mbox_register(&bfa->ioc, bfa_mbox_isrs); - bfa_iocfc_init_mem(bfa, bfad, cfg, pcidev); bfa_iocfc_mem_claim(bfa, cfg, meminfo); bfa_timer_init(&bfa->timer_mod); @@ -659,6 +654,7 @@ bfa_iocfc_init(struct bfa_s *bfa) { bfa->iocfc.action = BFA_IOCFC_ACT_INIT; bfa_ioc_enable(&bfa->ioc); + bfa_msix_install(bfa); } /** @@ -801,11 +797,6 @@ bfa_iocfc_get_stats(struct bfa_s *bfa, struct bfa_iocfc_stats_s *stats, return BFA_STATUS_DEVBUSY; } - if (!bfa_iocfc_is_operational(bfa)) { - bfa_trc(bfa, 0); - return BFA_STATUS_IOC_NON_OP; - } - iocfc->stats_busy = BFA_TRUE; iocfc->stats_ret = stats; iocfc->stats_cbfn = cbfn; @@ -826,11 +817,6 @@ bfa_iocfc_clear_stats(struct bfa_s *bfa, bfa_cb_ioc_t cbfn, void *cbarg) return BFA_STATUS_DEVBUSY; } - if (!bfa_iocfc_is_operational(bfa)) { - bfa_trc(bfa, 0); - return BFA_STATUS_IOC_NON_OP; - } - iocfc->stats_busy = BFA_TRUE; iocfc->stats_cbfn = cbfn; iocfc->stats_cbarg = cbarg; diff --git a/trunk/drivers/scsi/bfa/bfa_iocfc.h b/trunk/drivers/scsi/bfa/bfa_iocfc.h index fbb4bdc9d600..ce9a830a4207 100644 --- a/trunk/drivers/scsi/bfa/bfa_iocfc.h +++ b/trunk/drivers/scsi/bfa/bfa_iocfc.h @@ -54,7 +54,6 @@ struct bfa_msix_s { */ struct bfa_hwif_s { void (*hw_reginit)(struct bfa_s *bfa); - void (*hw_reqq_ack)(struct bfa_s *bfa, int reqq); void (*hw_rspq_ack)(struct bfa_s *bfa, int rspq); void (*hw_msix_init)(struct bfa_s *bfa, int nvecs); void (*hw_msix_install)(struct bfa_s *bfa); @@ -144,7 +143,6 @@ void bfa_msix_rspq(struct bfa_s *bfa, int vec); void bfa_msix_lpu_err(struct bfa_s *bfa, int vec); void bfa_hwcb_reginit(struct bfa_s *bfa); -void bfa_hwcb_reqq_ack(struct bfa_s *bfa, int rspq); void bfa_hwcb_rspq_ack(struct bfa_s *bfa, int rspq); void bfa_hwcb_msix_init(struct bfa_s *bfa, int nvecs); void bfa_hwcb_msix_install(struct bfa_s *bfa); @@ -153,7 +151,6 @@ void bfa_hwcb_isr_mode_set(struct bfa_s *bfa, bfa_boolean_t msix); void bfa_hwcb_msix_getvecs(struct bfa_s *bfa, u32 *vecmap, u32 *nvecs, u32 *maxvec); void bfa_hwct_reginit(struct bfa_s *bfa); -void bfa_hwct_reqq_ack(struct bfa_s *bfa, int rspq); void bfa_hwct_rspq_ack(struct bfa_s *bfa, int rspq); void bfa_hwct_msix_init(struct bfa_s *bfa, int nvecs); void bfa_hwct_msix_install(struct bfa_s *bfa); diff --git a/trunk/drivers/scsi/bfa/bfa_ioim.c b/trunk/drivers/scsi/bfa/bfa_ioim.c index 5b107abe46e5..f81d359b7089 100644 --- a/trunk/drivers/scsi/bfa/bfa_ioim.c +++ b/trunk/drivers/scsi/bfa/bfa_ioim.c @@ -149,7 +149,7 @@ bfa_ioim_sm_uninit(struct bfa_ioim_s *ioim, enum bfa_ioim_event event) break; default: - bfa_sm_fault(ioim->bfa, event); + bfa_assert(0); } } @@ -194,7 +194,7 @@ bfa_ioim_sm_sgalloc(struct bfa_ioim_s *ioim, enum bfa_ioim_event event) break; default: - bfa_sm_fault(ioim->bfa, event); + bfa_assert(0); } } @@ -259,7 +259,7 @@ bfa_ioim_sm_active(struct bfa_ioim_s *ioim, enum bfa_ioim_event event) break; default: - bfa_sm_fault(ioim->bfa, event); + bfa_assert(0); } } @@ -317,7 +317,7 @@ bfa_ioim_sm_abort(struct bfa_ioim_s *ioim, enum bfa_ioim_event event) break; default: - bfa_sm_fault(ioim->bfa, event); + bfa_assert(0); } } @@ -377,7 +377,7 @@ bfa_ioim_sm_cleanup(struct bfa_ioim_s *ioim, enum bfa_ioim_event event) break; default: - bfa_sm_fault(ioim->bfa, event); + bfa_assert(0); } } @@ -419,7 +419,7 @@ bfa_ioim_sm_qfull(struct bfa_ioim_s *ioim, enum bfa_ioim_event event) break; default: - bfa_sm_fault(ioim->bfa, event); + bfa_assert(0); } } @@ -467,7 +467,7 @@ bfa_ioim_sm_abort_qfull(struct bfa_ioim_s *ioim, enum bfa_ioim_event event) break; default: - bfa_sm_fault(ioim->bfa, event); + bfa_assert(0); } } @@ -516,7 +516,7 @@ bfa_ioim_sm_cleanup_qfull(struct bfa_ioim_s *ioim, enum bfa_ioim_event event) break; default: - bfa_sm_fault(ioim->bfa, event); + bfa_assert(0); } } @@ -544,7 +544,7 @@ bfa_ioim_sm_hcb(struct bfa_ioim_s *ioim, enum bfa_ioim_event event) break; default: - bfa_sm_fault(ioim->bfa, event); + bfa_assert(0); } } @@ -577,7 +577,7 @@ bfa_ioim_sm_hcb_free(struct bfa_ioim_s *ioim, enum bfa_ioim_event event) break; default: - bfa_sm_fault(ioim->bfa, event); + bfa_assert(0); } } @@ -605,7 +605,7 @@ bfa_ioim_sm_resfree(struct bfa_ioim_s *ioim, enum bfa_ioim_event event) break; default: - bfa_sm_fault(ioim->bfa, event); + bfa_assert(0); } } diff --git a/trunk/drivers/scsi/bfa/bfa_itnim.c b/trunk/drivers/scsi/bfa/bfa_itnim.c index a914ff255135..eabf7d38bd09 100644 --- a/trunk/drivers/scsi/bfa/bfa_itnim.c +++ b/trunk/drivers/scsi/bfa/bfa_itnim.c @@ -144,7 +144,7 @@ bfa_itnim_sm_uninit(struct bfa_itnim_s *itnim, enum bfa_itnim_event event) break; default: - bfa_sm_fault(itnim->bfa, event); + bfa_assert(0); } } @@ -175,7 +175,7 @@ bfa_itnim_sm_created(struct bfa_itnim_s *itnim, enum bfa_itnim_event event) break; default: - bfa_sm_fault(itnim->bfa, event); + bfa_assert(0); } } @@ -212,7 +212,7 @@ bfa_itnim_sm_fwcreate(struct bfa_itnim_s *itnim, enum bfa_itnim_event event) break; default: - bfa_sm_fault(itnim->bfa, event); + bfa_assert(0); } } @@ -247,7 +247,7 @@ bfa_itnim_sm_fwcreate_qfull(struct bfa_itnim_s *itnim, break; default: - bfa_sm_fault(itnim->bfa, event); + bfa_assert(0); } } @@ -275,7 +275,7 @@ bfa_itnim_sm_delete_pending(struct bfa_itnim_s *itnim, break; default: - bfa_sm_fault(itnim->bfa, event); + bfa_assert(0); } } @@ -317,7 +317,7 @@ bfa_itnim_sm_online(struct bfa_itnim_s *itnim, enum bfa_itnim_event event) break; default: - bfa_sm_fault(itnim->bfa, event); + bfa_assert(0); } } @@ -348,7 +348,7 @@ bfa_itnim_sm_sler(struct bfa_itnim_s *itnim, enum bfa_itnim_event event) break; default: - bfa_sm_fault(itnim->bfa, event); + bfa_assert(0); } } @@ -385,7 +385,7 @@ bfa_itnim_sm_cleanup_offline(struct bfa_itnim_s *itnim, break; default: - bfa_sm_fault(itnim->bfa, event); + bfa_assert(0); } } @@ -413,7 +413,7 @@ bfa_itnim_sm_cleanup_delete(struct bfa_itnim_s *itnim, break; default: - bfa_sm_fault(itnim->bfa, event); + bfa_assert(0); } } @@ -442,7 +442,7 @@ bfa_itnim_sm_fwdelete(struct bfa_itnim_s *itnim, enum bfa_itnim_event event) break; default: - bfa_sm_fault(itnim->bfa, event); + bfa_assert(0); } } @@ -470,7 +470,7 @@ bfa_itnim_sm_fwdelete_qfull(struct bfa_itnim_s *itnim, break; default: - bfa_sm_fault(itnim->bfa, event); + bfa_assert(0); } } @@ -502,7 +502,7 @@ bfa_itnim_sm_offline(struct bfa_itnim_s *itnim, enum bfa_itnim_event event) break; default: - bfa_sm_fault(itnim->bfa, event); + bfa_assert(0); } } @@ -538,7 +538,7 @@ bfa_itnim_sm_iocdisable(struct bfa_itnim_s *itnim, break; default: - bfa_sm_fault(itnim->bfa, event); + bfa_assert(0); } } @@ -559,7 +559,7 @@ bfa_itnim_sm_deleting(struct bfa_itnim_s *itnim, enum bfa_itnim_event event) break; default: - bfa_sm_fault(itnim->bfa, event); + bfa_assert(0); } } @@ -583,7 +583,7 @@ bfa_itnim_sm_deleting_qfull(struct bfa_itnim_s *itnim, break; default: - bfa_sm_fault(itnim->bfa, event); + bfa_assert(0); } } diff --git a/trunk/drivers/scsi/bfa/bfa_lps.c b/trunk/drivers/scsi/bfa/bfa_lps.c index ad06f6189092..9844b45412b6 100644 --- a/trunk/drivers/scsi/bfa/bfa_lps.c +++ b/trunk/drivers/scsi/bfa/bfa_lps.c @@ -18,7 +18,6 @@ #include #include #include -#include BFA_TRC_FILE(HAL, LPS); BFA_MODULE(lps); @@ -26,12 +25,6 @@ BFA_MODULE(lps); #define BFA_LPS_MIN_LPORTS (1) #define BFA_LPS_MAX_LPORTS (256) -/* - * Maximum Vports supported per physical port or vf. - */ -#define BFA_LPS_MAX_VPORTS_SUPP_CB 255 -#define BFA_LPS_MAX_VPORTS_SUPP_CT 190 - /** * forward declarations */ @@ -56,7 +49,7 @@ static void bfa_lps_send_login(struct bfa_lps_s *lps); static void bfa_lps_send_logout(struct bfa_lps_s *lps); static void bfa_lps_login_comp(struct bfa_lps_s *lps); static void bfa_lps_logout_comp(struct bfa_lps_s *lps); -static void bfa_lps_cvl_event(struct bfa_lps_s *lps); + /** * lps_pvt BFA LPS private functions @@ -69,7 +62,6 @@ enum bfa_lps_event { BFA_LPS_SM_RESUME = 4, /* space present in reqq queue */ BFA_LPS_SM_DELETE = 5, /* lps delete from user */ BFA_LPS_SM_OFFLINE = 6, /* Link is offline */ - BFA_LPS_SM_RX_CVL = 7, /* Rx clear virtual link */ }; static void bfa_lps_sm_init(struct bfa_lps_s *lps, enum bfa_lps_event event); @@ -99,12 +91,6 @@ bfa_lps_sm_init(struct bfa_lps_s *lps, enum bfa_lps_event event) bfa_sm_set_state(lps, bfa_lps_sm_login); bfa_lps_send_login(lps); } - if (lps->fdisc) - bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS, - BFA_PL_EID_LOGIN, 0, "FDISC Request"); - else - bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS, - BFA_PL_EID_LOGIN, 0, "FLOGI Request"); break; case BFA_LPS_SM_LOGOUT: @@ -115,7 +101,6 @@ bfa_lps_sm_init(struct bfa_lps_s *lps, enum bfa_lps_event event) bfa_lps_free(lps); break; - case BFA_LPS_SM_RX_CVL: case BFA_LPS_SM_OFFLINE: break; @@ -127,7 +112,7 @@ bfa_lps_sm_init(struct bfa_lps_s *lps, enum bfa_lps_event event) break; default: - bfa_sm_fault(lps->bfa, event); + bfa_assert(0); } } @@ -142,25 +127,10 @@ bfa_lps_sm_login(struct bfa_lps_s *lps, enum bfa_lps_event event) switch (event) { case BFA_LPS_SM_FWRSP: - if (lps->status == BFA_STATUS_OK) { + if (lps->status == BFA_STATUS_OK) bfa_sm_set_state(lps, bfa_lps_sm_online); - if (lps->fdisc) - bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS, - BFA_PL_EID_LOGIN, 0, "FDISC Accept"); - else - bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS, - BFA_PL_EID_LOGIN, 0, "FLOGI Accept"); - } else { + else bfa_sm_set_state(lps, bfa_lps_sm_init); - if (lps->fdisc) - bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS, - BFA_PL_EID_LOGIN, 0, - "FDISC Fail (RJT or timeout)"); - else - bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS, - BFA_PL_EID_LOGIN, 0, - "FLOGI Fail (RJT or timeout)"); - } bfa_lps_login_comp(lps); break; @@ -169,7 +139,7 @@ bfa_lps_sm_login(struct bfa_lps_s *lps, enum bfa_lps_event event) break; default: - bfa_sm_fault(lps->bfa, event); + bfa_assert(0); } } @@ -192,16 +162,8 @@ bfa_lps_sm_loginwait(struct bfa_lps_s *lps, enum bfa_lps_event event) bfa_reqq_wcancel(&lps->wqe); break; - case BFA_LPS_SM_RX_CVL: - /* - * Login was not even sent out; so when getting out - * of this state, it will appear like a login retry - * after Clear virtual link - */ - break; - default: - bfa_sm_fault(lps->bfa, event); + bfa_assert(0); } } @@ -223,17 +185,6 @@ bfa_lps_sm_online(struct bfa_lps_s *lps, enum bfa_lps_event event) bfa_sm_set_state(lps, bfa_lps_sm_logout); bfa_lps_send_logout(lps); } - bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS, - BFA_PL_EID_LOGO, 0, "Logout"); - break; - - case BFA_LPS_SM_RX_CVL: - bfa_sm_set_state(lps, bfa_lps_sm_init); - - /* Let the vport module know about this event */ - bfa_lps_cvl_event(lps); - bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS, - BFA_PL_EID_FIP_FCF_CVL, 0, "FCF Clear Virt. Link Rx"); break; case BFA_LPS_SM_OFFLINE: @@ -242,7 +193,7 @@ bfa_lps_sm_online(struct bfa_lps_s *lps, enum bfa_lps_event event) break; default: - bfa_sm_fault(lps->bfa, event); + bfa_assert(0); } } @@ -266,7 +217,7 @@ bfa_lps_sm_logout(struct bfa_lps_s *lps, enum bfa_lps_event event) break; default: - bfa_sm_fault(lps->bfa, event); + bfa_assert(0); } } @@ -291,7 +242,7 @@ bfa_lps_sm_logowait(struct bfa_lps_s *lps, enum bfa_lps_event event) break; default: - bfa_sm_fault(lps->bfa, event); + bfa_assert(0); } } @@ -444,20 +395,6 @@ bfa_lps_logout_rsp(struct bfa_s *bfa, struct bfi_lps_logout_rsp_s *rsp) bfa_sm_send_event(lps, BFA_LPS_SM_FWRSP); } -/** - * Firmware received a Clear virtual link request (for FCoE) - */ -static void -bfa_lps_rx_cvl_event(struct bfa_s *bfa, struct bfi_lps_cvl_event_s *cvl) -{ - struct bfa_lps_mod_s *mod = BFA_LPS_MOD(bfa); - struct bfa_lps_s *lps; - - lps = BFA_LPS_FROM_TAG(mod, cvl->lp_tag); - - bfa_sm_send_event(lps, BFA_LPS_SM_RX_CVL); -} - /** * Space is available in request queue, resume queueing request to firmware. */ @@ -594,48 +531,7 @@ bfa_lps_logout_comp(struct bfa_lps_s *lps) bfa_cb_lps_flogo_comp(lps->bfa->bfad, lps->uarg); } -/** - * Clear virtual link completion handler for non-fcs - */ -static void -bfa_lps_cvl_event_cb(void *arg, bfa_boolean_t complete) -{ - struct bfa_lps_s *lps = arg; - - if (!complete) - return; - - /* Clear virtual link to base port will result in link down */ - if (lps->fdisc) - bfa_cb_lps_cvl_event(lps->bfa->bfad, lps->uarg); -} - -/** - * Received Clear virtual link event --direct call for fcs, - * queue for others - */ -static void -bfa_lps_cvl_event(struct bfa_lps_s *lps) -{ - if (!lps->bfa->fcs) { - bfa_cb_queue(lps->bfa, &lps->hcb_qe, bfa_lps_cvl_event_cb, - lps); - return; - } - - /* Clear virtual link to base port will result in link down */ - if (lps->fdisc) - bfa_cb_lps_cvl_event(lps->bfa->bfad, lps->uarg); -} -u32 -bfa_lps_get_max_vport(struct bfa_s *bfa) -{ - if (bfa_ioc_devid(&bfa->ioc) == BFA_PCI_DEVICE_ID_CT) - return BFA_LPS_MAX_VPORTS_SUPP_CT; - else - return BFA_LPS_MAX_VPORTS_SUPP_CB; -} /** * lps_public BFA LPS public functions @@ -856,14 +752,6 @@ bfa_lps_get_lsrjt_expl(struct bfa_lps_s *lps) return lps->lsrjt_expl; } -/** - * Return fpma/spma MAC for lport - */ -struct mac_s -bfa_lps_get_lp_mac(struct bfa_lps_s *lps) -{ - return lps->lp_mac; -} /** * LPS firmware message class handler. @@ -885,10 +773,6 @@ bfa_lps_isr(struct bfa_s *bfa, struct bfi_msg_s *m) bfa_lps_logout_rsp(bfa, msg.logout_rsp); break; - case BFI_LPS_H2I_CVL_EVENT: - bfa_lps_rx_cvl_event(bfa, msg.cvl_event); - break; - default: bfa_trc(bfa, m->mhdr.msg_id); bfa_assert(0); diff --git a/trunk/drivers/scsi/bfa/bfa_module.c b/trunk/drivers/scsi/bfa/bfa_module.c index a7fcc80c177e..32eda8e1ec65 100644 --- a/trunk/drivers/scsi/bfa/bfa_module.c +++ b/trunk/drivers/scsi/bfa/bfa_module.c @@ -24,7 +24,7 @@ */ struct bfa_module_s *hal_mods[] = { &hal_mod_sgpg, - &hal_mod_fcport, + &hal_mod_pport, &hal_mod_fcxp, &hal_mod_lps, &hal_mod_uf, @@ -45,7 +45,7 @@ bfa_isr_func_t bfa_isrs[BFI_MC_MAX] = { bfa_isr_unhandled, /* BFI_MC_DIAG */ bfa_isr_unhandled, /* BFI_MC_FLASH */ bfa_isr_unhandled, /* BFI_MC_CEE */ - bfa_fcport_isr, /* BFI_MC_FCPORT */ + bfa_pport_isr, /* BFI_MC_PORT */ bfa_isr_unhandled, /* BFI_MC_IOCFC */ bfa_isr_unhandled, /* BFI_MC_LL */ bfa_uf_isr, /* BFI_MC_UF */ diff --git a/trunk/drivers/scsi/bfa/bfa_modules_priv.h b/trunk/drivers/scsi/bfa/bfa_modules_priv.h index f554c2fad6a9..96f70534593c 100644 --- a/trunk/drivers/scsi/bfa/bfa_modules_priv.h +++ b/trunk/drivers/scsi/bfa/bfa_modules_priv.h @@ -29,7 +29,7 @@ struct bfa_modules_s { - struct bfa_fcport_s fcport; /* fc port module */ + struct bfa_pport_s pport; /* physical port module */ struct bfa_fcxp_mod_s fcxp_mod; /* fcxp module */ struct bfa_lps_mod_s lps_mod; /* fcxp module */ struct bfa_uf_mod_s uf_mod; /* unsolicited frame module */ diff --git a/trunk/drivers/scsi/bfa/bfa_port_priv.h b/trunk/drivers/scsi/bfa/bfa_port_priv.h index 40e256ec67ff..51f698a06b6d 100644 --- a/trunk/drivers/scsi/bfa/bfa_port_priv.h +++ b/trunk/drivers/scsi/bfa/bfa_port_priv.h @@ -23,19 +23,9 @@ #include "bfa_intr_priv.h" /** - * Link notification data structure + * BFA physical port data structure */ -struct bfa_fcport_ln_s { - struct bfa_fcport_s *fcport; - bfa_sm_t sm; - struct bfa_cb_qe_s ln_qe; /* BFA callback queue elem for ln */ - enum bfa_pport_linkstate ln_event; /* ln event for callback */ -}; - -/** - * BFA FC port data structure - */ -struct bfa_fcport_s { +struct bfa_pport_s { struct bfa_s *bfa; /* parent BFA instance */ bfa_sm_t sm; /* port state machine */ wwn_t nwwn; /* node wwn of physical port */ @@ -46,8 +36,6 @@ struct bfa_fcport_s { enum bfa_pport_topology topology; /* current topology */ u8 myalpa; /* my ALPA in LOOP topology */ u8 rsvd[3]; - u32 mypid:24; - u32 rsvd_b:8; struct bfa_pport_cfg_s cfg; /* current port configuration */ struct bfa_qos_attr_s qos_attr; /* QoS Attributes */ struct bfa_qos_vc_attr_s qos_vc_attr; /* VC info from ELP */ @@ -61,31 +49,42 @@ struct bfa_fcport_s { void (*event_cbfn) (void *cbarg, bfa_pport_event_t event); union { - union bfi_fcport_i2h_msg_u i2hmsg; + union bfi_pport_i2h_msg_u i2hmsg; } event_arg; void *bfad; /* BFA driver handle */ - struct bfa_fcport_ln_s ln; /* Link Notification */ struct bfa_cb_qe_s hcb_qe; /* BFA callback queue elem */ - struct bfa_timer_s timer; /* timer */ + enum bfa_pport_linkstate hcb_event; + /* link event for callback */ u32 msgtag; /* fimrware msg tag for reply */ u8 *stats_kva; u64 stats_pa; - union bfa_fcport_stats_u *stats; - union bfa_fcport_stats_u *stats_ret; /* driver stats location */ - bfa_status_t stats_status; /* stats/statsclr status */ - bfa_boolean_t stats_busy; /* outstanding stats/statsclr */ - bfa_boolean_t stats_qfull; - bfa_cb_pport_t stats_cbfn; /* driver callback function */ - void *stats_cbarg; /* *!< user callback arg */ - bfa_boolean_t diag_busy; /* diag busy status */ - bfa_boolean_t beacon; /* port beacon status */ - bfa_boolean_t link_e2e_beacon; /* link beacon status */ + union bfa_pport_stats_u *stats; /* pport stats */ + u32 mypid:24; + u32 rsvd_b:8; + struct bfa_timer_s timer; /* timer */ + union bfa_pport_stats_u *stats_ret; + /* driver stats location */ + bfa_status_t stats_status; + /* stats/statsclr status */ + bfa_boolean_t stats_busy; + /* outstanding stats/statsclr */ + bfa_boolean_t stats_qfull; + bfa_boolean_t diag_busy; + /* diag busy status */ + bfa_boolean_t beacon; + /* port beacon status */ + bfa_boolean_t link_e2e_beacon; + /* link beacon status */ + bfa_cb_pport_t stats_cbfn; + /* driver callback function */ + void *stats_cbarg; + /* *!< user callback arg */ }; -#define BFA_FCPORT_MOD(__bfa) (&(__bfa)->modules.fcport) +#define BFA_PORT_MOD(__bfa) (&(__bfa)->modules.pport) /* * public functions */ -void bfa_fcport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg); +void bfa_pport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg); #endif /* __BFA_PORT_PRIV_H__ */ diff --git a/trunk/drivers/scsi/bfa/bfa_priv.h b/trunk/drivers/scsi/bfa/bfa_priv.h index be80fc7e1b0e..0747a6b26f7b 100644 --- a/trunk/drivers/scsi/bfa/bfa_priv.h +++ b/trunk/drivers/scsi/bfa/bfa_priv.h @@ -101,7 +101,7 @@ extern bfa_boolean_t bfa_auto_recover; extern struct bfa_module_s hal_mod_flash; extern struct bfa_module_s hal_mod_fcdiag; extern struct bfa_module_s hal_mod_sgpg; -extern struct bfa_module_s hal_mod_fcport; +extern struct bfa_module_s hal_mod_pport; extern struct bfa_module_s hal_mod_fcxp; extern struct bfa_module_s hal_mod_lps; extern struct bfa_module_s hal_mod_uf; diff --git a/trunk/drivers/scsi/bfa/bfa_rport.c b/trunk/drivers/scsi/bfa/bfa_rport.c index 7c509fa244e4..3e1990a74258 100644 --- a/trunk/drivers/scsi/bfa/bfa_rport.c +++ b/trunk/drivers/scsi/bfa/bfa_rport.c @@ -114,7 +114,7 @@ bfa_rport_sm_uninit(struct bfa_rport_s *rp, enum bfa_rport_event event) default: bfa_stats(rp, sm_un_unexp); - bfa_sm_fault(rp->bfa, event); + bfa_assert(0); } } @@ -146,7 +146,7 @@ bfa_rport_sm_created(struct bfa_rport_s *rp, enum bfa_rport_event event) default: bfa_stats(rp, sm_cr_unexp); - bfa_sm_fault(rp->bfa, event); + bfa_assert(0); } } @@ -183,7 +183,7 @@ bfa_rport_sm_fwcreate(struct bfa_rport_s *rp, enum bfa_rport_event event) default: bfa_stats(rp, sm_fwc_unexp); - bfa_sm_fault(rp->bfa, event); + bfa_assert(0); } } @@ -224,7 +224,7 @@ bfa_rport_sm_fwcreate_qfull(struct bfa_rport_s *rp, enum bfa_rport_event event) default: bfa_stats(rp, sm_fwc_unexp); - bfa_sm_fault(rp->bfa, event); + bfa_assert(0); } } @@ -296,7 +296,7 @@ bfa_rport_sm_online(struct bfa_rport_s *rp, enum bfa_rport_event event) default: bfa_stats(rp, sm_on_unexp); - bfa_sm_fault(rp->bfa, event); + bfa_assert(0); } } @@ -329,7 +329,7 @@ bfa_rport_sm_fwdelete(struct bfa_rport_s *rp, enum bfa_rport_event event) default: bfa_stats(rp, sm_fwd_unexp); - bfa_sm_fault(rp->bfa, event); + bfa_assert(0); } } @@ -359,7 +359,7 @@ bfa_rport_sm_fwdelete_qfull(struct bfa_rport_s *rp, enum bfa_rport_event event) default: bfa_stats(rp, sm_fwd_unexp); - bfa_sm_fault(rp->bfa, event); + bfa_assert(0); } } @@ -394,7 +394,7 @@ bfa_rport_sm_offline(struct bfa_rport_s *rp, enum bfa_rport_event event) default: bfa_stats(rp, sm_off_unexp); - bfa_sm_fault(rp->bfa, event); + bfa_assert(0); } } @@ -421,7 +421,7 @@ bfa_rport_sm_deleting(struct bfa_rport_s *rp, enum bfa_rport_event event) break; default: - bfa_sm_fault(rp->bfa, event); + bfa_assert(0); } } @@ -446,7 +446,7 @@ bfa_rport_sm_deleting_qfull(struct bfa_rport_s *rp, enum bfa_rport_event event) break; default: - bfa_sm_fault(rp->bfa, event); + bfa_assert(0); } } @@ -477,7 +477,7 @@ bfa_rport_sm_delete_pending(struct bfa_rport_s *rp, default: bfa_stats(rp, sm_delp_unexp); - bfa_sm_fault(rp->bfa, event); + bfa_assert(0); } } @@ -512,7 +512,7 @@ bfa_rport_sm_offline_pending(struct bfa_rport_s *rp, default: bfa_stats(rp, sm_offp_unexp); - bfa_sm_fault(rp->bfa, event); + bfa_assert(0); } } @@ -550,7 +550,7 @@ bfa_rport_sm_iocdisable(struct bfa_rport_s *rp, enum bfa_rport_event event) default: bfa_stats(rp, sm_iocd_unexp); - bfa_sm_fault(rp->bfa, event); + bfa_assert(0); } } diff --git a/trunk/drivers/scsi/bfa/bfa_trcmod_priv.h b/trunk/drivers/scsi/bfa/bfa_trcmod_priv.h index a7a82610db85..b3562dce7e9f 100644 --- a/trunk/drivers/scsi/bfa/bfa_trcmod_priv.h +++ b/trunk/drivers/scsi/bfa/bfa_trcmod_priv.h @@ -29,36 +29,38 @@ * !!! needed between trace utility and driver version */ enum { - BFA_TRC_HAL_INTR = 1, - BFA_TRC_HAL_FCXP = 2, - BFA_TRC_HAL_UF = 3, - BFA_TRC_HAL_RPORT = 4, - BFA_TRC_HAL_FCPIM = 5, - BFA_TRC_HAL_IOIM = 6, - BFA_TRC_HAL_TSKIM = 7, - BFA_TRC_HAL_ITNIM = 8, - BFA_TRC_HAL_FCPORT = 9, - BFA_TRC_HAL_SGPG = 10, - BFA_TRC_HAL_FLASH = 11, - BFA_TRC_HAL_DEBUG = 12, - BFA_TRC_HAL_WWN = 13, - BFA_TRC_HAL_FLASH_RAW = 14, - BFA_TRC_HAL_SBOOT = 15, - BFA_TRC_HAL_SBOOT_IO = 16, - BFA_TRC_HAL_SBOOT_INTR = 17, - BFA_TRC_HAL_SBTEST = 18, - BFA_TRC_HAL_IPFC = 19, - BFA_TRC_HAL_IOCFC = 20, - BFA_TRC_HAL_FCPTM = 21, - BFA_TRC_HAL_IOTM = 22, - BFA_TRC_HAL_TSKTM = 23, - BFA_TRC_HAL_TIN = 24, - BFA_TRC_HAL_LPS = 25, - BFA_TRC_HAL_FCDIAG = 26, - BFA_TRC_HAL_PBIND = 27, - BFA_TRC_HAL_IOCFC_CT = 28, - BFA_TRC_HAL_IOCFC_CB = 29, - BFA_TRC_HAL_IOCFC_Q = 30, + BFA_TRC_HAL_IOC = 1, + BFA_TRC_HAL_INTR = 2, + BFA_TRC_HAL_FCXP = 3, + BFA_TRC_HAL_UF = 4, + BFA_TRC_HAL_DIAG = 5, + BFA_TRC_HAL_RPORT = 6, + BFA_TRC_HAL_FCPIM = 7, + BFA_TRC_HAL_IOIM = 8, + BFA_TRC_HAL_TSKIM = 9, + BFA_TRC_HAL_ITNIM = 10, + BFA_TRC_HAL_PPORT = 11, + BFA_TRC_HAL_SGPG = 12, + BFA_TRC_HAL_FLASH = 13, + BFA_TRC_HAL_DEBUG = 14, + BFA_TRC_HAL_WWN = 15, + BFA_TRC_HAL_FLASH_RAW = 16, + BFA_TRC_HAL_SBOOT = 17, + BFA_TRC_HAL_SBOOT_IO = 18, + BFA_TRC_HAL_SBOOT_INTR = 19, + BFA_TRC_HAL_SBTEST = 20, + BFA_TRC_HAL_IPFC = 21, + BFA_TRC_HAL_IOCFC = 22, + BFA_TRC_HAL_FCPTM = 23, + BFA_TRC_HAL_IOTM = 24, + BFA_TRC_HAL_TSKTM = 25, + BFA_TRC_HAL_TIN = 26, + BFA_TRC_HAL_LPS = 27, + BFA_TRC_HAL_FCDIAG = 28, + BFA_TRC_HAL_PBIND = 29, + BFA_TRC_HAL_IOCFC_CT = 30, + BFA_TRC_HAL_IOCFC_CB = 31, + BFA_TRC_HAL_IOCFC_Q = 32, }; #endif /* __BFA_TRCMOD_PRIV_H__ */ diff --git a/trunk/drivers/scsi/bfa/bfa_tskim.c b/trunk/drivers/scsi/bfa/bfa_tskim.c index ad9aaaedd3f1..ff7a4dc0bf3c 100644 --- a/trunk/drivers/scsi/bfa/bfa_tskim.c +++ b/trunk/drivers/scsi/bfa/bfa_tskim.c @@ -110,7 +110,7 @@ bfa_tskim_sm_uninit(struct bfa_tskim_s *tskim, enum bfa_tskim_event event) break; default: - bfa_sm_fault(tskim->bfa, event); + bfa_assert(0); } } @@ -146,7 +146,7 @@ bfa_tskim_sm_active(struct bfa_tskim_s *tskim, enum bfa_tskim_event event) break; default: - bfa_sm_fault(tskim->bfa, event); + bfa_assert(0); } } @@ -178,7 +178,7 @@ bfa_tskim_sm_cleanup(struct bfa_tskim_s *tskim, enum bfa_tskim_event event) break; default: - bfa_sm_fault(tskim->bfa, event); + bfa_assert(0); } } @@ -207,7 +207,7 @@ bfa_tskim_sm_iocleanup(struct bfa_tskim_s *tskim, enum bfa_tskim_event event) break; default: - bfa_sm_fault(tskim->bfa, event); + bfa_assert(0); } } @@ -242,7 +242,7 @@ bfa_tskim_sm_qfull(struct bfa_tskim_s *tskim, enum bfa_tskim_event event) break; default: - bfa_sm_fault(tskim->bfa, event); + bfa_assert(0); } } @@ -277,7 +277,7 @@ bfa_tskim_sm_cleanup_qfull(struct bfa_tskim_s *tskim, break; default: - bfa_sm_fault(tskim->bfa, event); + bfa_assert(0); } } @@ -303,7 +303,7 @@ bfa_tskim_sm_hcb(struct bfa_tskim_s *tskim, enum bfa_tskim_event event) break; default: - bfa_sm_fault(tskim->bfa, event); + bfa_assert(0); } } diff --git a/trunk/drivers/scsi/bfa/bfad.c b/trunk/drivers/scsi/bfa/bfad.c index 6bff08ea4029..b52b773d49d9 100644 --- a/trunk/drivers/scsi/bfa/bfad.c +++ b/trunk/drivers/scsi/bfa/bfad.c @@ -20,7 +20,6 @@ */ #include -#include #include "bfad_drv.h" #include "bfad_im.h" #include "bfad_tm.h" @@ -54,7 +53,6 @@ static int log_level = BFA_LOG_WARNING; static int ioc_auto_recover = BFA_TRUE; static int ipfc_enable = BFA_FALSE; static int ipfc_mtu = -1; -static int fdmi_enable = BFA_TRUE; int bfa_lun_queue_depth = BFAD_LUN_QUEUE_DEPTH; int bfa_linkup_delay = -1; @@ -76,7 +74,6 @@ module_param(log_level, int, S_IRUGO | S_IWUSR); module_param(ioc_auto_recover, int, S_IRUGO | S_IWUSR); module_param(ipfc_enable, int, S_IRUGO | S_IWUSR); module_param(ipfc_mtu, int, S_IRUGO | S_IWUSR); -module_param(fdmi_enable, int, S_IRUGO | S_IWUSR); module_param(bfa_linkup_delay, int, S_IRUGO | S_IWUSR); /* @@ -98,8 +95,6 @@ bfad_fc4_probe(struct bfad_s *bfad) if (ipfc_enable) bfad_ipfc_probe(bfad); - - bfad->bfad_flags |= BFAD_FC4_PROBE_DONE; ext: return rc; } @@ -111,7 +106,6 @@ bfad_fc4_probe_undo(struct bfad_s *bfad) bfad_tm_probe_undo(bfad); if (ipfc_enable) bfad_ipfc_probe_undo(bfad); - bfad->bfad_flags &= ~BFAD_FC4_PROBE_DONE; } static void @@ -179,19 +173,9 @@ bfa_cb_init(void *drv, bfa_status_t init_status) { struct bfad_s *bfad = drv; - if (init_status == BFA_STATUS_OK) { + if (init_status == BFA_STATUS_OK) bfad->bfad_flags |= BFAD_HAL_INIT_DONE; - /* If BFAD_HAL_INIT_FAIL flag is set: - * Wake up the kernel thread to start - * the bfad operations after HAL init done - */ - if ((bfad->bfad_flags & BFAD_HAL_INIT_FAIL)) { - bfad->bfad_flags &= ~BFAD_HAL_INIT_FAIL; - wake_up_process(bfad->bfad_tsk); - } - } - complete(&bfad->comp); } @@ -664,7 +648,7 @@ bfad_fcs_port_cfg(struct bfad_s *bfad) sprintf(symname, "%s-%d", BFAD_DRIVER_NAME, bfad->inst_no); memcpy(port_cfg.sym_name.symname, symname, strlen(symname)); - bfa_fcport_get_attr(&bfad->bfa, &attr); + bfa_pport_get_attr(&bfad->bfa, &attr); port_cfg.nwwn = attr.nwwn; port_cfg.pwwn = attr.pwwn; @@ -677,6 +661,7 @@ bfad_drv_init(struct bfad_s *bfad) bfa_status_t rc; unsigned long flags; struct bfa_fcs_driver_info_s driver_info; + int i; bfad->cfg_data.rport_del_timeout = rport_del_timeout; bfad->cfg_data.lun_queue_depth = bfa_lun_queue_depth; @@ -696,7 +681,12 @@ bfad_drv_init(struct bfad_s *bfad) bfa_init_log(&bfad->bfa, bfad->logmod); bfa_init_trc(&bfad->bfa, bfad->trcmod); bfa_init_aen(&bfad->bfa, bfad->aen); - memset(bfad->file_map, 0, sizeof(bfad->file_map)); + INIT_LIST_HEAD(&bfad->file_q); + INIT_LIST_HEAD(&bfad->file_free_q); + for (i = 0; i < BFAD_AEN_MAX_APPS; i++) { + bfa_q_qe_init(&bfad->file_buf[i].qe); + list_add_tail(&bfad->file_buf[i].qe, &bfad->file_free_q); + } bfa_init_plog(&bfad->bfa, &bfad->plog_buf); bfa_plog_init(&bfad->plog_buf); bfa_plog_str(&bfad->plog_buf, BFA_PL_MID_DRVR, BFA_PL_EID_DRIVER_START, @@ -756,16 +746,8 @@ bfad_drv_init(struct bfad_s *bfad) bfa_fcs_log_init(&bfad->bfa_fcs, bfad->logmod); bfa_fcs_trc_init(&bfad->bfa_fcs, bfad->trcmod); bfa_fcs_aen_init(&bfad->bfa_fcs, bfad->aen); - bfa_fcs_attach(&bfad->bfa_fcs, &bfad->bfa, bfad, BFA_FALSE); - - /* Do FCS init only when HAL init is done */ - if ((bfad->bfad_flags & BFAD_HAL_INIT_DONE)) { - bfa_fcs_init(&bfad->bfa_fcs); - bfad->bfad_flags |= BFAD_FCS_INIT_DONE; - } - + bfa_fcs_init(&bfad->bfa_fcs, &bfad->bfa, bfad, BFA_FALSE); bfa_fcs_driver_info_init(&bfad->bfa_fcs, &driver_info); - bfa_fcs_set_fdmi_param(&bfad->bfa_fcs, fdmi_enable); spin_unlock_irqrestore(&bfad->bfad_lock, flags); bfad->bfad_flags |= BFAD_DRV_INIT_DONE; @@ -781,21 +763,12 @@ bfad_drv_init(struct bfad_s *bfad) void bfad_drv_uninit(struct bfad_s *bfad) { - unsigned long flags; - - spin_lock_irqsave(&bfad->bfad_lock, flags); - init_completion(&bfad->comp); - bfa_stop(&bfad->bfa); - spin_unlock_irqrestore(&bfad->bfad_lock, flags); - wait_for_completion(&bfad->comp); - del_timer_sync(&bfad->hal_tmo); bfa_isr_disable(&bfad->bfa); bfa_detach(&bfad->bfa); bfad_remove_intr(bfad); + bfa_assert(list_empty(&bfad->file_q)); bfad_hal_mem_release(bfad); - - bfad->bfad_flags &= ~BFAD_DRV_INIT_DONE; } void @@ -886,86 +859,6 @@ bfad_drv_log_level_set(struct bfad_s *bfad) bfa_log_set_level_all(&bfad->log_data, log_level); } -bfa_status_t -bfad_start_ops(struct bfad_s *bfad) -{ - int retval; - - /* PPORT FCS config */ - bfad_fcs_port_cfg(bfad); - - retval = bfad_cfg_pport(bfad, BFA_PORT_ROLE_FCP_IM); - if (retval != BFA_STATUS_OK) - goto out_cfg_pport_failure; - - /* BFAD level FC4 (IM/TM/IPFC) specific resource allocation */ - retval = bfad_fc4_probe(bfad); - if (retval != BFA_STATUS_OK) { - printk(KERN_WARNING "bfad_fc4_probe failed\n"); - goto out_fc4_probe_failure; - } - - bfad_drv_start(bfad); - - /* - * If bfa_linkup_delay is set to -1 default; try to retrive the - * value using the bfad_os_get_linkup_delay(); else use the - * passed in module param value as the bfa_linkup_delay. - */ - if (bfa_linkup_delay < 0) { - - bfa_linkup_delay = bfad_os_get_linkup_delay(bfad); - bfad_os_rport_online_wait(bfad); - bfa_linkup_delay = -1; - - } else { - bfad_os_rport_online_wait(bfad); - } - - bfa_log(bfad->logmod, BFA_LOG_LINUX_DEVICE_CLAIMED, bfad->pci_name); - - return BFA_STATUS_OK; - -out_fc4_probe_failure: - bfad_fc4_probe_undo(bfad); - bfad_uncfg_pport(bfad); -out_cfg_pport_failure: - return BFA_STATUS_FAILED; -} - -int -bfad_worker (void *ptr) -{ - struct bfad_s *bfad; - unsigned long flags; - - bfad = (struct bfad_s *)ptr; - - while (!kthread_should_stop()) { - - /* Check if the FCS init is done from bfad_drv_init; - * if not done do FCS init and set the flag. - */ - if (!(bfad->bfad_flags & BFAD_FCS_INIT_DONE)) { - spin_lock_irqsave(&bfad->bfad_lock, flags); - bfa_fcs_init(&bfad->bfa_fcs); - bfad->bfad_flags |= BFAD_FCS_INIT_DONE; - spin_unlock_irqrestore(&bfad->bfad_lock, flags); - } - - /* Start the bfad operations after HAL init done */ - bfad_start_ops(bfad); - - spin_lock_irqsave(&bfad->bfad_lock, flags); - bfad->bfad_tsk = NULL; - spin_unlock_irqrestore(&bfad->bfad_lock, flags); - - break; - } - - return 0; -} - /* * PCI_entry PCI driver entries * { */ @@ -978,6 +871,7 @@ bfad_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid) { struct bfad_s *bfad; int error = -ENODEV, retval; + char buf[16]; /* * For single port cards - only claim function 0 @@ -1008,7 +902,8 @@ bfad_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid) bfa_trc(bfad, bfad_inst); bfad->logmod = &bfad->log_data; - bfa_log_init(bfad->logmod, (char *)pci_name(pdev), bfa_os_printf); + sprintf(buf, "%d", bfad_inst); + bfa_log_init(bfad->logmod, buf, bfa_os_printf); bfad_drv_log_level_set(bfad); @@ -1038,39 +933,57 @@ bfad_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid) bfad->ref_count = 0; bfad->pport.bfad = bfad; - bfad->bfad_tsk = kthread_create(bfad_worker, (void *) bfad, "%s", - "bfad_worker"); - if (IS_ERR(bfad->bfad_tsk)) { - printk(KERN_INFO "bfad[%d]: Kernel thread" - " creation failed!\n", - bfad->inst_no); - goto out_kthread_create_failure; - } - retval = bfad_drv_init(bfad); if (retval != BFA_STATUS_OK) goto out_drv_init_failure; if (!(bfad->bfad_flags & BFAD_HAL_INIT_DONE)) { - bfad->bfad_flags |= BFAD_HAL_INIT_FAIL; printk(KERN_WARNING "bfad%d: hal init failed\n", bfad->inst_no); goto ok; } - retval = bfad_start_ops(bfad); + /* + * PPORT FCS config + */ + bfad_fcs_port_cfg(bfad); + + retval = bfad_cfg_pport(bfad, BFA_PORT_ROLE_FCP_IM); if (retval != BFA_STATUS_OK) - goto out_start_ops_failure; + goto out_cfg_pport_failure; + + /* + * BFAD level FC4 (IM/TM/IPFC) specific resource allocation + */ + retval = bfad_fc4_probe(bfad); + if (retval != BFA_STATUS_OK) { + printk(KERN_WARNING "bfad_fc4_probe failed\n"); + goto out_fc4_probe_failure; + } - kthread_stop(bfad->bfad_tsk); - bfad->bfad_tsk = NULL; + bfad_drv_start(bfad); + + /* + * If bfa_linkup_delay is set to -1 default; try to retrive the + * value using the bfad_os_get_linkup_delay(); else use the + * passed in module param value as the bfa_linkup_delay. + */ + if (bfa_linkup_delay < 0) { + bfa_linkup_delay = bfad_os_get_linkup_delay(bfad); + bfad_os_rport_online_wait(bfad); + bfa_linkup_delay = -1; + } else { + bfad_os_rport_online_wait(bfad); + } + bfa_log(bfad->logmod, BFA_LOG_LINUX_DEVICE_CLAIMED, bfad->pci_name); ok: return 0; -out_start_ops_failure: +out_fc4_probe_failure: + bfad_fc4_probe_undo(bfad); + bfad_uncfg_pport(bfad); +out_cfg_pport_failure: bfad_drv_uninit(bfad); out_drv_init_failure: - kthread_stop(bfad->bfad_tsk); -out_kthread_create_failure: mutex_lock(&bfad_mutex); bfad_inst--; list_del(&bfad->list_entry); @@ -1095,11 +1008,6 @@ bfad_pci_remove(struct pci_dev *pdev) bfa_trc(bfad, bfad->inst_no); - spin_lock_irqsave(&bfad->bfad_lock, flags); - if (bfad->bfad_tsk != NULL) - kthread_stop(bfad->bfad_tsk); - spin_unlock_irqrestore(&bfad->bfad_lock, flags); - if ((bfad->bfad_flags & BFAD_DRV_INIT_DONE) && !(bfad->bfad_flags & BFAD_HAL_INIT_DONE)) { @@ -1116,25 +1024,13 @@ bfad_pci_remove(struct pci_dev *pdev) goto remove_sysfs; } - if (bfad->bfad_flags & BFAD_HAL_START_DONE) { + if (bfad->bfad_flags & BFAD_HAL_START_DONE) bfad_drv_stop(bfad); - } else if (bfad->bfad_flags & BFAD_DRV_INIT_DONE) { - /* Invoking bfa_stop() before bfa_detach - * when HAL and DRV init are success - * but HAL start did not occur. - */ - spin_lock_irqsave(&bfad->bfad_lock, flags); - init_completion(&bfad->comp); - bfa_stop(&bfad->bfa); - spin_unlock_irqrestore(&bfad->bfad_lock, flags); - wait_for_completion(&bfad->comp); - } bfad_remove_intr(bfad); - del_timer_sync(&bfad->hal_tmo); - if (bfad->bfad_flags & BFAD_FC4_PROBE_DONE) - bfad_fc4_probe_undo(bfad); + del_timer_sync(&bfad->hal_tmo); + bfad_fc4_probe_undo(bfad); if (bfad->bfad_flags & BFAD_CFG_PPORT_DONE) bfad_uncfg_pport(bfad); diff --git a/trunk/drivers/scsi/bfa/bfad_attr.c b/trunk/drivers/scsi/bfa/bfad_attr.c index d97f69191838..9129ae3040ff 100644 --- a/trunk/drivers/scsi/bfa/bfad_attr.c +++ b/trunk/drivers/scsi/bfa/bfad_attr.c @@ -141,7 +141,7 @@ bfad_im_get_host_port_type(struct Scsi_Host *shost) struct bfad_s *bfad = im_port->bfad; struct bfa_pport_attr_s attr; - bfa_fcport_get_attr(&bfad->bfa, &attr); + bfa_pport_get_attr(&bfad->bfa, &attr); switch (attr.port_type) { case BFA_PPORT_TYPE_NPORT: @@ -173,7 +173,7 @@ bfad_im_get_host_port_state(struct Scsi_Host *shost) struct bfad_s *bfad = im_port->bfad; struct bfa_pport_attr_s attr; - bfa_fcport_get_attr(&bfad->bfa, &attr); + bfa_pport_get_attr(&bfad->bfa, &attr); switch (attr.port_state) { case BFA_PPORT_ST_LINKDOWN: @@ -229,10 +229,8 @@ bfad_im_get_host_speed(struct Scsi_Host *shost) (struct bfad_im_port_s *) shost->hostdata[0]; struct bfad_s *bfad = im_port->bfad; struct bfa_pport_attr_s attr; - unsigned long flags; - spin_lock_irqsave(shost->host_lock, flags); - bfa_fcport_get_attr(&bfad->bfa, &attr); + bfa_pport_get_attr(&bfad->bfa, &attr); switch (attr.speed) { case BFA_PPORT_SPEED_8GBPS: fc_host_speed(shost) = FC_PORTSPEED_8GBIT; @@ -250,7 +248,6 @@ bfad_im_get_host_speed(struct Scsi_Host *shost) fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; break; } - spin_unlock_irqrestore(shost->host_lock, flags); } /** @@ -288,7 +285,7 @@ bfad_im_get_stats(struct Scsi_Host *shost) init_completion(&fcomp.comp); spin_lock_irqsave(&bfad->bfad_lock, flags); memset(hstats, 0, sizeof(struct fc_host_statistics)); - rc = bfa_port_get_stats(BFA_FCPORT(&bfad->bfa), + rc = bfa_pport_get_stats(&bfad->bfa, (union bfa_pport_stats_u *) hstats, bfad_hcb_comp, &fcomp); spin_unlock_irqrestore(&bfad->bfad_lock, flags); @@ -315,8 +312,7 @@ bfad_im_reset_stats(struct Scsi_Host *shost) init_completion(&fcomp.comp); spin_lock_irqsave(&bfad->bfad_lock, flags); - rc = bfa_port_clear_stats(BFA_FCPORT(&bfad->bfa), bfad_hcb_comp, - &fcomp); + rc = bfa_pport_clear_stats(&bfad->bfa, bfad_hcb_comp, &fcomp); spin_unlock_irqrestore(&bfad->bfad_lock, flags); if (rc != BFA_STATUS_OK) @@ -425,10 +421,12 @@ bfad_im_serial_num_show(struct device *dev, struct device_attribute *attr, struct bfad_im_port_s *im_port = (struct bfad_im_port_s *) shost->hostdata[0]; struct bfad_s *bfad = im_port->bfad; - char serial_num[BFA_ADAPTER_SERIAL_NUM_LEN]; + struct bfa_ioc_attr_s ioc_attr; - bfa_get_adapter_serial_num(&bfad->bfa, serial_num); - return snprintf(buf, PAGE_SIZE, "%s\n", serial_num); + memset(&ioc_attr, 0, sizeof(ioc_attr)); + bfa_get_attr(&bfad->bfa, &ioc_attr); + return snprintf(buf, PAGE_SIZE, "%s\n", + ioc_attr.adapter_attr.serial_num); } static ssize_t @@ -439,10 +437,11 @@ bfad_im_model_show(struct device *dev, struct device_attribute *attr, struct bfad_im_port_s *im_port = (struct bfad_im_port_s *) shost->hostdata[0]; struct bfad_s *bfad = im_port->bfad; - char model[BFA_ADAPTER_MODEL_NAME_LEN]; + struct bfa_ioc_attr_s ioc_attr; - bfa_get_adapter_model(&bfad->bfa, model); - return snprintf(buf, PAGE_SIZE, "%s\n", model); + memset(&ioc_attr, 0, sizeof(ioc_attr)); + bfa_get_attr(&bfad->bfa, &ioc_attr); + return snprintf(buf, PAGE_SIZE, "%s\n", ioc_attr.adapter_attr.model); } static ssize_t @@ -453,10 +452,12 @@ bfad_im_model_desc_show(struct device *dev, struct device_attribute *attr, struct bfad_im_port_s *im_port = (struct bfad_im_port_s *) shost->hostdata[0]; struct bfad_s *bfad = im_port->bfad; - char model_descr[BFA_ADAPTER_MODEL_DESCR_LEN]; + struct bfa_ioc_attr_s ioc_attr; - bfa_get_adapter_model(&bfad->bfa, model_descr); - return snprintf(buf, PAGE_SIZE, "%s\n", model_descr); + memset(&ioc_attr, 0, sizeof(ioc_attr)); + bfa_get_attr(&bfad->bfa, &ioc_attr); + return snprintf(buf, PAGE_SIZE, "%s\n", + ioc_attr.adapter_attr.model_descr); } static ssize_t @@ -481,13 +482,14 @@ bfad_im_symbolic_name_show(struct device *dev, struct device_attribute *attr, struct bfad_im_port_s *im_port = (struct bfad_im_port_s *) shost->hostdata[0]; struct bfad_s *bfad = im_port->bfad; - char model[BFA_ADAPTER_MODEL_NAME_LEN]; - char fw_ver[BFA_VERSION_LEN]; + struct bfa_ioc_attr_s ioc_attr; + + memset(&ioc_attr, 0, sizeof(ioc_attr)); + bfa_get_attr(&bfad->bfa, &ioc_attr); - bfa_get_adapter_model(&bfad->bfa, model); - bfa_get_adapter_fw_ver(&bfad->bfa, fw_ver); return snprintf(buf, PAGE_SIZE, "Brocade %s FV%s DV%s\n", - model, fw_ver, BFAD_DRIVER_VERSION); + ioc_attr.adapter_attr.model, + ioc_attr.adapter_attr.fw_ver, BFAD_DRIVER_VERSION); } static ssize_t @@ -498,10 +500,11 @@ bfad_im_hw_version_show(struct device *dev, struct device_attribute *attr, struct bfad_im_port_s *im_port = (struct bfad_im_port_s *) shost->hostdata[0]; struct bfad_s *bfad = im_port->bfad; - char hw_ver[BFA_VERSION_LEN]; + struct bfa_ioc_attr_s ioc_attr; - bfa_get_pci_chip_rev(&bfad->bfa, hw_ver); - return snprintf(buf, PAGE_SIZE, "%s\n", hw_ver); + memset(&ioc_attr, 0, sizeof(ioc_attr)); + bfa_get_attr(&bfad->bfa, &ioc_attr); + return snprintf(buf, PAGE_SIZE, "%s\n", ioc_attr.adapter_attr.hw_ver); } static ssize_t @@ -519,10 +522,12 @@ bfad_im_optionrom_version_show(struct device *dev, struct bfad_im_port_s *im_port = (struct bfad_im_port_s *) shost->hostdata[0]; struct bfad_s *bfad = im_port->bfad; - char optrom_ver[BFA_VERSION_LEN]; + struct bfa_ioc_attr_s ioc_attr; - bfa_get_adapter_optrom_ver(&bfad->bfa, optrom_ver); - return snprintf(buf, PAGE_SIZE, "%s\n", optrom_ver); + memset(&ioc_attr, 0, sizeof(ioc_attr)); + bfa_get_attr(&bfad->bfa, &ioc_attr); + return snprintf(buf, PAGE_SIZE, "%s\n", + ioc_attr.adapter_attr.optrom_ver); } static ssize_t @@ -533,10 +538,11 @@ bfad_im_fw_version_show(struct device *dev, struct device_attribute *attr, struct bfad_im_port_s *im_port = (struct bfad_im_port_s *) shost->hostdata[0]; struct bfad_s *bfad = im_port->bfad; - char fw_ver[BFA_VERSION_LEN]; + struct bfa_ioc_attr_s ioc_attr; - bfa_get_adapter_fw_ver(&bfad->bfa, fw_ver); - return snprintf(buf, PAGE_SIZE, "%s\n", fw_ver); + memset(&ioc_attr, 0, sizeof(ioc_attr)); + bfa_get_attr(&bfad->bfa, &ioc_attr); + return snprintf(buf, PAGE_SIZE, "%s\n", ioc_attr.adapter_attr.fw_ver); } static ssize_t @@ -547,9 +553,11 @@ bfad_im_num_of_ports_show(struct device *dev, struct device_attribute *attr, struct bfad_im_port_s *im_port = (struct bfad_im_port_s *) shost->hostdata[0]; struct bfad_s *bfad = im_port->bfad; + struct bfa_ioc_attr_s ioc_attr; - return snprintf(buf, PAGE_SIZE, "%d\n", - bfa_get_nports(&bfad->bfa)); + memset(&ioc_attr, 0, sizeof(ioc_attr)); + bfa_get_attr(&bfad->bfa, &ioc_attr); + return snprintf(buf, PAGE_SIZE, "%d\n", ioc_attr.adapter_attr.nports); } static ssize_t diff --git a/trunk/drivers/scsi/bfa/bfad_attr.h b/trunk/drivers/scsi/bfa/bfad_attr.h index bf0102076508..4d3312da6a81 100644 --- a/trunk/drivers/scsi/bfa/bfad_attr.h +++ b/trunk/drivers/scsi/bfa/bfad_attr.h @@ -17,6 +17,9 @@ #ifndef __BFAD_ATTR_H__ #define __BFAD_ATTR_H__ +/** + * bfad_attr.h VMware driver configuration interface module. + */ /** * FC_transport_template FC transport template @@ -49,6 +52,12 @@ bfad_im_get_starget_port_name(struct scsi_target *starget); void bfad_im_get_host_port_id(struct Scsi_Host *shost); +/** + * FC transport template entry, issue a LIP. + */ +int +bfad_im_issue_fc_host_lip(struct Scsi_Host *shost); + struct Scsi_Host* bfad_os_starget_to_shost(struct scsi_target *starget); diff --git a/trunk/drivers/scsi/bfa/bfad_drv.h b/trunk/drivers/scsi/bfa/bfad_drv.h index 107848cd3b6d..172c81e25c1c 100644 --- a/trunk/drivers/scsi/bfa/bfad_drv.h +++ b/trunk/drivers/scsi/bfa/bfad_drv.h @@ -46,7 +46,7 @@ #ifdef BFA_DRIVER_VERSION #define BFAD_DRIVER_VERSION BFA_DRIVER_VERSION #else -#define BFAD_DRIVER_VERSION "2.1.2.1" +#define BFAD_DRIVER_VERSION "2.0.0.0" #endif @@ -62,9 +62,7 @@ #define BFAD_HAL_START_DONE 0x00000010 #define BFAD_PORT_ONLINE 0x00000020 #define BFAD_RPORT_ONLINE 0x00000040 -#define BFAD_FCS_INIT_DONE 0x00000080 -#define BFAD_HAL_INIT_FAIL 0x00000100 -#define BFAD_FC4_PROBE_DONE 0x00000200 + #define BFAD_PORT_DELETE 0x00000001 /* @@ -139,16 +137,12 @@ struct bfad_cfg_param_s { u32 binding_method; }; -union bfad_tmp_buf { - /* From struct bfa_adapter_attr_s */ - char manufacturer[BFA_ADAPTER_MFG_NAME_LEN]; - char serial_num[BFA_ADAPTER_SERIAL_NUM_LEN]; - char model[BFA_ADAPTER_MODEL_NAME_LEN]; - char fw_ver[BFA_VERSION_LEN]; - char optrom_ver[BFA_VERSION_LEN]; - - /* From struct bfa_ioc_pci_attr_s */ - u8 chip_rev[BFA_IOC_CHIP_REV_LEN]; /* chip revision */ +#define BFAD_AEN_MAX_APPS 8 +struct bfad_aen_file_s { + struct list_head qe; + struct bfad_s *bfad; + s32 ri; + s32 app_id; }; /* @@ -174,7 +168,6 @@ struct bfad_s { u32 inst_no; /* BFAD instance number */ u32 bfad_flags; spinlock_t bfad_lock; - struct task_struct *bfad_tsk; struct bfad_cfg_param_s cfg_data; struct bfad_msix_s msix_tab[MAX_MSIX_ENTRY]; int nvec; @@ -190,12 +183,18 @@ struct bfad_s { struct bfa_log_mod_s *logmod; struct bfa_aen_s *aen; struct bfa_aen_s aen_buf; - void *file_map[BFA_AEN_MAX_APP]; + struct bfad_aen_file_s file_buf[BFAD_AEN_MAX_APPS]; + struct list_head file_q; + struct list_head file_free_q; struct bfa_plog_s plog_buf; int ref_count; bfa_boolean_t ipfc_enabled; - union bfad_tmp_buf tmp_buf; struct fc_host_statistics link_stats; + + struct kobject *bfa_kobj; + struct kobject *ioc_kobj; + struct kobject *pport_kobj; + struct kobject *lport_kobj; }; /* @@ -259,7 +258,6 @@ bfa_status_t bfad_vf_create(struct bfad_s *bfad, u16 vf_id, struct bfa_port_cfg_s *port_cfg); bfa_status_t bfad_cfg_pport(struct bfad_s *bfad, enum bfa_port_role role); bfa_status_t bfad_drv_init(struct bfad_s *bfad); -bfa_status_t bfad_start_ops(struct bfad_s *bfad); void bfad_drv_start(struct bfad_s *bfad); void bfad_uncfg_pport(struct bfad_s *bfad); void bfad_drv_stop(struct bfad_s *bfad); @@ -281,7 +279,6 @@ void bfad_drv_uninit(struct bfad_s *bfad); void bfad_drv_log_level_set(struct bfad_s *bfad); bfa_status_t bfad_fc4_module_init(void); void bfad_fc4_module_exit(void); -int bfad_worker (void *ptr); void bfad_pci_remove(struct pci_dev *pdev); int bfad_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid); diff --git a/trunk/drivers/scsi/bfa/bfad_im.c b/trunk/drivers/scsi/bfa/bfad_im.c index f9fc67a25bf2..f788c2a0ab07 100644 --- a/trunk/drivers/scsi/bfa/bfad_im.c +++ b/trunk/drivers/scsi/bfa/bfad_im.c @@ -43,11 +43,11 @@ bfa_cb_ioim_done(void *drv, struct bfad_ioim_s *dio, struct bfad_s *bfad = drv; struct bfad_itnim_data_s *itnim_data; struct bfad_itnim_s *itnim; - u8 host_status = DID_OK; switch (io_status) { case BFI_IOIM_STS_OK: bfa_trc(bfad, scsi_status); + cmnd->result = ScsiResult(DID_OK, scsi_status); scsi_set_resid(cmnd, 0); if (sns_len > 0) { @@ -56,18 +56,8 @@ bfa_cb_ioim_done(void *drv, struct bfad_ioim_s *dio, sns_len = SCSI_SENSE_BUFFERSIZE; memcpy(cmnd->sense_buffer, sns_info, sns_len); } - if (residue > 0) { - bfa_trc(bfad, residue); + if (residue > 0) scsi_set_resid(cmnd, residue); - if (!sns_len && (scsi_status == SAM_STAT_GOOD) && - (scsi_bufflen(cmnd) - residue) < - cmnd->underflow) { - bfa_trc(bfad, 0); - host_status = DID_ERROR; - } - } - cmnd->result = ScsiResult(host_status, scsi_status); - break; case BFI_IOIM_STS_ABORTED: @@ -177,15 +167,17 @@ bfad_im_info(struct Scsi_Host *shost) static char bfa_buf[256]; struct bfad_im_port_s *im_port = (struct bfad_im_port_s *) shost->hostdata[0]; + struct bfa_ioc_attr_s ioc_attr; struct bfad_s *bfad = im_port->bfad; - char model[BFA_ADAPTER_MODEL_NAME_LEN]; - bfa_get_adapter_model(&bfad->bfa, model); + memset(&ioc_attr, 0, sizeof(ioc_attr)); + bfa_get_attr(&bfad->bfa, &ioc_attr); memset(bfa_buf, 0, sizeof(bfa_buf)); snprintf(bfa_buf, sizeof(bfa_buf), - "Brocade FC/FCOE Adapter, " "model: %s hwpath: %s driver: %s", - model, bfad->pci_name, BFAD_DRIVER_VERSION); + "Brocade FC/FCOE Adapter, " "model: %s hwpath: %s driver: %s", + ioc_attr.adapter_attr.model, bfad->pci_name, + BFAD_DRIVER_VERSION); return bfa_buf; } @@ -508,6 +500,16 @@ void bfa_fcb_itnim_tov(struct bfad_itnim_s *itnim) itnim->state = ITNIM_STATE_TIMEOUT; } +/** + * Path TOV processing begin notification -- dummy for linux + */ +void +bfa_fcb_itnim_tov_begin(struct bfad_itnim_s *itnim) +{ +} + + + /** * Allocate a Scsi_Host for a port. */ @@ -929,9 +931,10 @@ bfad_os_fc_host_init(struct bfad_im_port_s *im_port) struct Scsi_Host *host = im_port->shost; struct bfad_s *bfad = im_port->bfad; struct bfad_port_s *port = im_port->port; - struct bfa_pport_attr_s pattr; - char model[BFA_ADAPTER_MODEL_NAME_LEN]; - char fw_ver[BFA_VERSION_LEN]; + union attr { + struct bfa_pport_attr_s pattr; + struct bfa_ioc_attr_s ioc_attr; + } attr; fc_host_node_name(host) = bfa_os_htonll((bfa_fcs_port_get_nwwn(port->fcs_port))); @@ -951,18 +954,20 @@ bfad_os_fc_host_init(struct bfad_im_port_s *im_port) /* For fibre channel services type 0x20 */ fc_host_supported_fc4s(host)[7] = 1; - bfa_get_adapter_model(&bfad->bfa, model); - bfa_get_adapter_fw_ver(&bfad->bfa, fw_ver); + memset(&attr.ioc_attr, 0, sizeof(attr.ioc_attr)); + bfa_get_attr(&bfad->bfa, &attr.ioc_attr); sprintf(fc_host_symbolic_name(host), "Brocade %s FV%s DV%s", - model, fw_ver, BFAD_DRIVER_VERSION); + attr.ioc_attr.adapter_attr.model, + attr.ioc_attr.adapter_attr.fw_ver, BFAD_DRIVER_VERSION); fc_host_supported_speeds(host) = 0; fc_host_supported_speeds(host) |= FC_PORTSPEED_8GBIT | FC_PORTSPEED_4GBIT | FC_PORTSPEED_2GBIT | FC_PORTSPEED_1GBIT; - bfa_fcport_get_attr(&bfad->bfa, &pattr); - fc_host_maxframe_size(host) = pattr.pport_cfg.maxfrsize; + memset(&attr.pattr, 0, sizeof(attr.pattr)); + bfa_pport_get_attr(&bfad->bfa, &attr.pattr); + fc_host_maxframe_size(host) = attr.pattr.pport_cfg.maxfrsize; } static void diff --git a/trunk/drivers/scsi/bfa/bfad_im.h b/trunk/drivers/scsi/bfa/bfad_im.h index 85ab2da21321..189a5b29e21a 100644 --- a/trunk/drivers/scsi/bfa/bfad_im.h +++ b/trunk/drivers/scsi/bfa/bfad_im.h @@ -23,6 +23,7 @@ #define FCPI_NAME " fcpim" +void bfad_flags_set(struct bfad_s *bfad, u32 flags); bfa_status_t bfad_im_module_init(void); void bfad_im_module_exit(void); bfa_status_t bfad_im_probe(struct bfad_s *bfad); @@ -125,6 +126,7 @@ bfa_status_t bfad_os_thread_workq(struct bfad_s *bfad); void bfad_os_destroy_workq(struct bfad_im_s *im); void bfad_os_itnim_process(struct bfad_itnim_s *itnim_drv); void bfad_os_fc_host_init(struct bfad_im_port_s *im_port); +void bfad_os_init_work(struct bfad_im_port_s *im_port); void bfad_os_scsi_host_free(struct bfad_s *bfad, struct bfad_im_port_s *im_port); void bfad_os_ramp_up_qdepth(struct bfad_itnim_s *itnim, @@ -134,6 +136,9 @@ struct bfad_itnim_s *bfad_os_get_itnim(struct bfad_im_port_s *im_port, int id); int bfad_os_scsi_add_host(struct Scsi_Host *shost, struct bfad_im_port_s *im_port, struct bfad_s *bfad); +/* + * scsi_host_template entries + */ void bfad_im_itnim_unmap(struct bfad_im_port_s *im_port, struct bfad_itnim_s *itnim); diff --git a/trunk/drivers/scsi/bfa/bfad_intr.c b/trunk/drivers/scsi/bfa/bfad_intr.c index 2b7dbecbebca..7de8832f6fee 100644 --- a/trunk/drivers/scsi/bfa/bfad_intr.c +++ b/trunk/drivers/scsi/bfa/bfad_intr.c @@ -23,10 +23,8 @@ BFA_TRC_FILE(LDRV, INTR); /** * bfa_isr BFA driver interrupt functions */ -static int msix_disable_cb; -static int msix_disable_ct; -module_param(msix_disable_cb, int, S_IRUGO | S_IWUSR); -module_param(msix_disable_ct, int, S_IRUGO | S_IWUSR); +static int msix_disable; +module_param(msix_disable, int, S_IRUGO | S_IWUSR); /** * Line based interrupt handler. */ @@ -143,7 +141,6 @@ bfad_setup_intr(struct bfad_s *bfad) int error = 0; u32 mask = 0, i, num_bit = 0, max_bit = 0; struct msix_entry msix_entries[MAX_MSIX_ENTRY]; - struct pci_dev *pdev = bfad->pcidev; /* Call BFA to get the msix map for this PCI function. */ bfa_msix_getvecs(&bfad->bfa, &mask, &num_bit, &max_bit); @@ -151,9 +148,7 @@ bfad_setup_intr(struct bfad_s *bfad) /* Set up the msix entry table */ bfad_init_msix_entry(bfad, msix_entries, mask, max_bit); - if ((pdev->device == BFA_PCI_DEVICE_ID_CT && !msix_disable_ct) || - (pdev->device != BFA_PCI_DEVICE_ID_CT && !msix_disable_cb)) { - + if (!msix_disable) { error = pci_enable_msix(bfad->pcidev, msix_entries, bfad->nvec); if (error) { /* diff --git a/trunk/drivers/scsi/bfa/fabric.c b/trunk/drivers/scsi/bfa/fabric.c index 8166e9745ec0..a4b5dd449573 100644 --- a/trunk/drivers/scsi/bfa/fabric.c +++ b/trunk/drivers/scsi/bfa/fabric.c @@ -37,7 +37,7 @@ BFA_TRC_FILE(FCS, FABRIC); #define BFA_FCS_FABRIC_CLEANUP_DELAY (10000) /* Milliseconds */ #define bfa_fcs_fabric_set_opertype(__fabric) do { \ - if (bfa_fcport_get_topology((__fabric)->fcs->bfa) \ + if (bfa_pport_get_topology((__fabric)->fcs->bfa) \ == BFA_PPORT_TOPOLOGY_P2P) \ (__fabric)->oper_type = BFA_PPORT_TYPE_NPORT; \ else \ @@ -136,7 +136,8 @@ bfa_fcs_fabric_sm_uninit(struct bfa_fcs_fabric_s *fabric, case BFA_FCS_FABRIC_SM_CREATE: bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_created); bfa_fcs_fabric_init(fabric); - bfa_fcs_lport_init(&fabric->bport, &fabric->bport.port_cfg); + bfa_fcs_lport_init(&fabric->bport, fabric->fcs, FC_VF_ID_NULL, + &fabric->bport.port_cfg, NULL); break; case BFA_FCS_FABRIC_SM_LINK_UP: @@ -160,7 +161,7 @@ bfa_fcs_fabric_sm_created(struct bfa_fcs_fabric_s *fabric, switch (event) { case BFA_FCS_FABRIC_SM_START: - if (bfa_fcport_is_linkup(fabric->fcs->bfa)) { + if (bfa_pport_is_linkup(fabric->fcs->bfa)) { bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_flogi); bfa_fcs_fabric_login(fabric); } else @@ -224,7 +225,7 @@ bfa_fcs_fabric_sm_flogi(struct bfa_fcs_fabric_s *fabric, switch (event) { case BFA_FCS_FABRIC_SM_CONT_OP: - bfa_fcport_set_tx_bbcredit(fabric->fcs->bfa, fabric->bb_credit); + bfa_pport_set_tx_bbcredit(fabric->fcs->bfa, fabric->bb_credit); fabric->fab_type = BFA_FCS_FABRIC_SWITCHED; if (fabric->auth_reqd && fabric->is_auth) { @@ -251,7 +252,7 @@ bfa_fcs_fabric_sm_flogi(struct bfa_fcs_fabric_s *fabric, case BFA_FCS_FABRIC_SM_NO_FABRIC: fabric->fab_type = BFA_FCS_FABRIC_N2N; - bfa_fcport_set_tx_bbcredit(fabric->fcs->bfa, fabric->bb_credit); + bfa_pport_set_tx_bbcredit(fabric->fcs->bfa, fabric->bb_credit); bfa_fcs_fabric_notify_online(fabric); bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_nofabric); break; @@ -418,7 +419,7 @@ bfa_fcs_fabric_sm_nofabric(struct bfa_fcs_fabric_s *fabric, case BFA_FCS_FABRIC_SM_NO_FABRIC: bfa_trc(fabric->fcs, fabric->bb_credit); - bfa_fcport_set_tx_bbcredit(fabric->fcs->bfa, fabric->bb_credit); + bfa_pport_set_tx_bbcredit(fabric->fcs->bfa, fabric->bb_credit); break; default: @@ -562,15 +563,17 @@ void bfa_fcs_fabric_psymb_init(struct bfa_fcs_fabric_s *fabric) { struct bfa_port_cfg_s *port_cfg = &fabric->bport.port_cfg; - char model[BFA_ADAPTER_MODEL_NAME_LEN] = {0}; + struct bfa_adapter_attr_s adapter_attr; struct bfa_fcs_driver_info_s *driver_info = &fabric->fcs->driver_info; - bfa_ioc_get_adapter_model(&fabric->fcs->bfa->ioc, model); + bfa_os_memset((void *)&adapter_attr, 0, + sizeof(struct bfa_adapter_attr_s)); + bfa_ioc_get_adapter_attr(&fabric->fcs->bfa->ioc, &adapter_attr); /* * Model name/number */ - strncpy((char *)&port_cfg->sym_name, model, + strncpy((char *)&port_cfg->sym_name, adapter_attr.model, BFA_FCS_PORT_SYMBNAME_MODEL_SZ); strncat((char *)&port_cfg->sym_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR, sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR)); @@ -716,10 +719,10 @@ bfa_fcs_fabric_login(struct bfa_fcs_fabric_s *fabric) struct bfa_port_cfg_s *pcfg = &fabric->bport.port_cfg; u8 alpa = 0; - if (bfa_fcport_get_topology(bfa) == BFA_PPORT_TOPOLOGY_LOOP) - alpa = bfa_fcport_get_myalpa(bfa); + if (bfa_pport_get_topology(bfa) == BFA_PPORT_TOPOLOGY_LOOP) + alpa = bfa_pport_get_myalpa(bfa); - bfa_lps_flogi(fabric->lps, fabric, alpa, bfa_fcport_get_maxfrsize(bfa), + bfa_lps_flogi(fabric->lps, fabric, alpa, bfa_pport_get_maxfrsize(bfa), pcfg->pwwn, pcfg->nwwn, fabric->auth_reqd); fabric->stats.flogi_sent++; @@ -811,10 +814,10 @@ bfa_fcs_fabric_delete_comp(void *cbarg) */ /** - * Attach time initialization + * Module initialization */ void -bfa_fcs_fabric_attach(struct bfa_fcs_s *fcs) +bfa_fcs_fabric_modinit(struct bfa_fcs_s *fcs) { struct bfa_fcs_fabric_s *fabric; @@ -838,13 +841,7 @@ bfa_fcs_fabric_attach(struct bfa_fcs_s *fcs) bfa_wc_up(&fabric->wc); /* For the base port */ bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_uninit); - bfa_fcs_lport_attach(&fabric->bport, fabric->fcs, FC_VF_ID_NULL, NULL); -} - -void -bfa_fcs_fabric_modinit(struct bfa_fcs_s *fcs) -{ - bfa_sm_send_event(&fcs->fabric, BFA_FCS_FABRIC_SM_CREATE); + bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_CREATE); bfa_trc(fcs, 0); } @@ -893,12 +890,6 @@ bfa_fcs_fabric_is_loopback(struct bfa_fcs_fabric_s *fabric) return bfa_sm_cmp_state(fabric, bfa_fcs_fabric_sm_loopback); } -bfa_boolean_t -bfa_fcs_fabric_is_auth_failed(struct bfa_fcs_fabric_s *fabric) -{ - return bfa_sm_cmp_state(fabric, bfa_fcs_fabric_sm_auth_failed); -} - enum bfa_pport_type bfa_fcs_fabric_port_type(struct bfa_fcs_fabric_s *fabric) { @@ -1174,8 +1165,8 @@ bfa_fcs_fabric_send_flogi_acc(struct bfa_fcs_fabric_s *fabric) reqlen = fc_flogi_acc_build(&fchs, bfa_fcxp_get_reqbuf(fcxp), bfa_os_hton3b(FC_FABRIC_PORT), n2n_port->reply_oxid, pcfg->pwwn, - pcfg->nwwn, bfa_fcport_get_maxfrsize(bfa), - bfa_fcport_get_rx_bbcredit(bfa)); + pcfg->nwwn, bfa_pport_get_maxfrsize(bfa), + bfa_pport_get_rx_bbcredit(bfa)); bfa_fcxp_send(fcxp, NULL, fabric->vf_id, bfa_lps_get_tag(fabric->lps), BFA_FALSE, FC_CLASS_3, reqlen, &fchs, @@ -1233,8 +1224,14 @@ bfa_fcs_fabric_aen_post(struct bfa_fcs_port_s *port, wwn2str(pwwn_ptr, pwwn); wwn2str(fwwn_ptr, fwwn); - bfa_log(logmod, BFA_LOG_CREATE_ID(BFA_AEN_CAT_PORT, event), - pwwn_ptr, fwwn_ptr); + switch (event) { + case BFA_PORT_AEN_FABRIC_NAME_CHANGE: + bfa_log(logmod, BFA_AEN_PORT_FABRIC_NAME_CHANGE, pwwn_ptr, + fwwn_ptr); + break; + default: + break; + } aen_data.port.pwwn = pwwn; aen_data.port.fwwn = fwwn; diff --git a/trunk/drivers/scsi/bfa/fcbuild.h b/trunk/drivers/scsi/bfa/fcbuild.h index 981d98d542b9..8fa7f270ef7b 100644 --- a/trunk/drivers/scsi/bfa/fcbuild.h +++ b/trunk/drivers/scsi/bfa/fcbuild.h @@ -72,9 +72,6 @@ fc_rpsc_operspeed_to_bfa_speed(enum fc_rpsc_op_speed_s speed) case RPSC_OP_SPEED_8G: return BFA_PPORT_SPEED_8GBPS; - case RPSC_OP_SPEED_10G: - return BFA_PPORT_SPEED_10GBPS; - default: return BFA_PPORT_SPEED_UNKNOWN; } @@ -100,9 +97,6 @@ fc_bfa_speed_to_rpsc_operspeed(enum bfa_pport_speed op_speed) case BFA_PPORT_SPEED_8GBPS: return RPSC_OP_SPEED_8G; - case BFA_PPORT_SPEED_10GBPS: - return RPSC_OP_SPEED_10G; - default: return RPSC_OP_SPEED_NOT_EST; } diff --git a/trunk/drivers/scsi/bfa/fcpim.c b/trunk/drivers/scsi/bfa/fcpim.c index 8ae4a2cfa85b..1f3c06efaa9e 100644 --- a/trunk/drivers/scsi/bfa/fcpim.c +++ b/trunk/drivers/scsi/bfa/fcpim.c @@ -126,7 +126,7 @@ bfa_fcs_itnim_sm_offline(struct bfa_fcs_itnim_s *itnim, break; default: - bfa_sm_fault(itnim->fcs, event); + bfa_assert(0); } } @@ -161,7 +161,7 @@ bfa_fcs_itnim_sm_prli_send(struct bfa_fcs_itnim_s *itnim, break; default: - bfa_sm_fault(itnim->fcs, event); + bfa_assert(0); } } @@ -205,7 +205,7 @@ bfa_fcs_itnim_sm_prli(struct bfa_fcs_itnim_s *itnim, break; default: - bfa_sm_fault(itnim->fcs, event); + bfa_assert(0); } } @@ -240,7 +240,7 @@ bfa_fcs_itnim_sm_prli_retry(struct bfa_fcs_itnim_s *itnim, break; default: - bfa_sm_fault(itnim->fcs, event); + bfa_assert(0); } } @@ -270,7 +270,7 @@ bfa_fcs_itnim_sm_hcb_online(struct bfa_fcs_itnim_s *itnim, break; default: - bfa_sm_fault(itnim->fcs, event); + bfa_assert(0); } } @@ -298,7 +298,7 @@ bfa_fcs_itnim_sm_online(struct bfa_fcs_itnim_s *itnim, break; default: - bfa_sm_fault(itnim->fcs, event); + bfa_assert(0); } } @@ -321,7 +321,7 @@ bfa_fcs_itnim_sm_hcb_offline(struct bfa_fcs_itnim_s *itnim, break; default: - bfa_sm_fault(itnim->fcs, event); + bfa_assert(0); } } @@ -354,7 +354,7 @@ bfa_fcs_itnim_sm_initiator(struct bfa_fcs_itnim_s *itnim, break; default: - bfa_sm_fault(itnim->fcs, event); + bfa_assert(0); } } @@ -385,8 +385,19 @@ bfa_fcs_itnim_aen_post(struct bfa_fcs_itnim_s *itnim, wwn2str(lpwwn_ptr, lpwwn); wwn2str(rpwwn_ptr, rpwwn); - bfa_log(logmod, BFA_LOG_CREATE_ID(BFA_AEN_CAT_ITNIM, event), - rpwwn_ptr, lpwwn_ptr); + switch (event) { + case BFA_ITNIM_AEN_ONLINE: + bfa_log(logmod, BFA_AEN_ITNIM_ONLINE, rpwwn_ptr, lpwwn_ptr); + break; + case BFA_ITNIM_AEN_OFFLINE: + bfa_log(logmod, BFA_AEN_ITNIM_OFFLINE, rpwwn_ptr, lpwwn_ptr); + break; + case BFA_ITNIM_AEN_DISCONNECT: + bfa_log(logmod, BFA_AEN_ITNIM_DISCONNECT, rpwwn_ptr, lpwwn_ptr); + break; + default: + break; + } aen_data.itnim.vf_id = rport->port->fabric->vf_id; aen_data.itnim.ppwwn = @@ -678,6 +689,7 @@ bfa_cb_itnim_tov_begin(void *cb_arg) struct bfa_fcs_itnim_s *itnim = (struct bfa_fcs_itnim_s *)cb_arg; bfa_trc(itnim->fcs, itnim->rport->pwwn); + bfa_fcb_itnim_tov_begin(itnim->itnim_drv); } /** @@ -810,3 +822,22 @@ void bfa_fcs_itnim_resume(struct bfa_fcs_itnim_s *itnim) { } + +/** + * Module initialization + */ +void +bfa_fcs_fcpim_modinit(struct bfa_fcs_s *fcs) +{ +} + +/** + * Module cleanup + */ +void +bfa_fcs_fcpim_modexit(struct bfa_fcs_s *fcs) +{ + bfa_fcs_modexit_comp(fcs); +} + + diff --git a/trunk/drivers/scsi/bfa/fcs_fabric.h b/trunk/drivers/scsi/bfa/fcs_fabric.h index 244c3f00c50c..eee960820f86 100644 --- a/trunk/drivers/scsi/bfa/fcs_fabric.h +++ b/trunk/drivers/scsi/bfa/fcs_fabric.h @@ -29,7 +29,6 @@ /* * fcs friend functions: only between fcs modules */ -void bfa_fcs_fabric_attach(struct bfa_fcs_s *fcs); void bfa_fcs_fabric_modinit(struct bfa_fcs_s *fcs); void bfa_fcs_fabric_modexit(struct bfa_fcs_s *fcs); void bfa_fcs_fabric_modsusp(struct bfa_fcs_s *fcs); @@ -47,7 +46,6 @@ void bfa_fcs_fabric_uf_recv(struct bfa_fcs_fabric_s *fabric, struct fchs_s *fchs, u16 len); u16 bfa_fcs_fabric_vport_count(struct bfa_fcs_fabric_s *fabric); bfa_boolean_t bfa_fcs_fabric_is_loopback(struct bfa_fcs_fabric_s *fabric); -bfa_boolean_t bfa_fcs_fabric_is_auth_failed(struct bfa_fcs_fabric_s *fabric); enum bfa_pport_type bfa_fcs_fabric_port_type(struct bfa_fcs_fabric_s *fabric); void bfa_fcs_fabric_psymb_init(struct bfa_fcs_fabric_s *fabric); void bfa_fcs_fabric_port_delete_comp(struct bfa_fcs_fabric_s *fabric); diff --git a/trunk/drivers/scsi/bfa/fcs_fcpim.h b/trunk/drivers/scsi/bfa/fcs_fcpim.h index 11e6e7bce9f6..61e9e2687de3 100644 --- a/trunk/drivers/scsi/bfa/fcs_fcpim.h +++ b/trunk/drivers/scsi/bfa/fcs_fcpim.h @@ -34,6 +34,11 @@ void bfa_fcs_itnim_is_initiator(struct bfa_fcs_itnim_s *itnim); void bfa_fcs_itnim_pause(struct bfa_fcs_itnim_s *itnim); void bfa_fcs_itnim_resume(struct bfa_fcs_itnim_s *itnim); +/* + * Modudle init/cleanup routines. + */ +void bfa_fcs_fcpim_modinit(struct bfa_fcs_s *fcs); +void bfa_fcs_fcpim_modexit(struct bfa_fcs_s *fcs); void bfa_fcs_fcpim_uf_recv(struct bfa_fcs_itnim_s *itnim, struct fchs_s *fchs, u16 len); #endif /* __FCS_FCPIM_H__ */ diff --git a/trunk/drivers/scsi/bfa/fcs_lport.h b/trunk/drivers/scsi/bfa/fcs_lport.h index a6508c8ab184..ae744ba35671 100644 --- a/trunk/drivers/scsi/bfa/fcs_lport.h +++ b/trunk/drivers/scsi/bfa/fcs_lport.h @@ -84,10 +84,9 @@ void bfa_fcs_port_uf_recv(struct bfa_fcs_port_s *lport, struct fchs_s *fchs, * Following routines will be called by Fabric to indicate port * online/offline to vport. */ -void bfa_fcs_lport_attach(struct bfa_fcs_port_s *lport, struct bfa_fcs_s *fcs, - uint16_t vf_id, struct bfa_fcs_vport_s *vport); -void bfa_fcs_lport_init(struct bfa_fcs_port_s *lport, - struct bfa_port_cfg_s *port_cfg); +void bfa_fcs_lport_init(struct bfa_fcs_port_s *lport, struct bfa_fcs_s *fcs, + u16 vf_id, struct bfa_port_cfg_s *port_cfg, + struct bfa_fcs_vport_s *vport); void bfa_fcs_port_online(struct bfa_fcs_port_s *port); void bfa_fcs_port_offline(struct bfa_fcs_port_s *port); void bfa_fcs_port_delete(struct bfa_fcs_port_s *port); diff --git a/trunk/drivers/scsi/bfa/fcs_port.h b/trunk/drivers/scsi/bfa/fcs_port.h index 408c06a7d164..abb65191dd27 100644 --- a/trunk/drivers/scsi/bfa/fcs_port.h +++ b/trunk/drivers/scsi/bfa/fcs_port.h @@ -26,6 +26,7 @@ /* * fcs friend functions: only between fcs modules */ -void bfa_fcs_pport_attach(struct bfa_fcs_s *fcs); +void bfa_fcs_pport_modinit(struct bfa_fcs_s *fcs); +void bfa_fcs_pport_modexit(struct bfa_fcs_s *fcs); #endif /* __FCS_PPORT_H__ */ diff --git a/trunk/drivers/scsi/bfa/fcs_rport.h b/trunk/drivers/scsi/bfa/fcs_rport.h index 9c8d1d292380..f601e9d74236 100644 --- a/trunk/drivers/scsi/bfa/fcs_rport.h +++ b/trunk/drivers/scsi/bfa/fcs_rport.h @@ -24,6 +24,9 @@ #include +void bfa_fcs_rport_modinit(struct bfa_fcs_s *fcs); +void bfa_fcs_rport_modexit(struct bfa_fcs_s *fcs); + void bfa_fcs_rport_uf_recv(struct bfa_fcs_rport_s *rport, struct fchs_s *fchs, u16 len); void bfa_fcs_rport_scn(struct bfa_fcs_rport_s *rport); diff --git a/trunk/drivers/scsi/bfa/fcs_uf.h b/trunk/drivers/scsi/bfa/fcs_uf.h index f591072214fe..96f1bdcb31ed 100644 --- a/trunk/drivers/scsi/bfa/fcs_uf.h +++ b/trunk/drivers/scsi/bfa/fcs_uf.h @@ -26,6 +26,7 @@ /* * fcs friend functions: only between fcs modules */ -void bfa_fcs_uf_attach(struct bfa_fcs_s *fcs); +void bfa_fcs_uf_modinit(struct bfa_fcs_s *fcs); +void bfa_fcs_uf_modexit(struct bfa_fcs_s *fcs); #endif /* __FCS_UF_H__ */ diff --git a/trunk/drivers/scsi/bfa/fcs_vport.h b/trunk/drivers/scsi/bfa/fcs_vport.h index 13c32ebf946c..9e80b6a97b7f 100644 --- a/trunk/drivers/scsi/bfa/fcs_vport.h +++ b/trunk/drivers/scsi/bfa/fcs_vport.h @@ -22,10 +22,18 @@ #include #include +/* + * Modudle init/cleanup routines. + */ + +void bfa_fcs_vport_modinit(struct bfa_fcs_s *fcs); +void bfa_fcs_vport_modexit(struct bfa_fcs_s *fcs); + void bfa_fcs_vport_cleanup(struct bfa_fcs_vport_s *vport); void bfa_fcs_vport_online(struct bfa_fcs_vport_s *vport); void bfa_fcs_vport_offline(struct bfa_fcs_vport_s *vport); void bfa_fcs_vport_delete_comp(struct bfa_fcs_vport_s *vport); +u32 bfa_fcs_vport_get_max(struct bfa_fcs_s *fcs); #endif /* __FCS_VPORT_H__ */ diff --git a/trunk/drivers/scsi/bfa/fdmi.c b/trunk/drivers/scsi/bfa/fdmi.c index 8f17076d1a87..df2a1e54e16b 100644 --- a/trunk/drivers/scsi/bfa/fdmi.c +++ b/trunk/drivers/scsi/bfa/fdmi.c @@ -116,9 +116,6 @@ static void bfa_fcs_port_fdmi_sm_rpa_retry(struct bfa_fcs_port_fdmi_s *fdmi, enum port_fdmi_event event); static void bfa_fcs_port_fdmi_sm_online(struct bfa_fcs_port_fdmi_s *fdmi, enum port_fdmi_event event); -static void bfa_fcs_port_fdmi_sm_disabled(struct bfa_fcs_port_fdmi_s *fdmi, - enum port_fdmi_event event); - /** * Start in offline state - awaiting MS to send start. */ @@ -158,7 +155,7 @@ bfa_fcs_port_fdmi_sm_offline(struct bfa_fcs_port_fdmi_s *fdmi, break; default: - bfa_sm_fault(port->fcs, event); + bfa_assert(0); } } @@ -183,7 +180,7 @@ bfa_fcs_port_fdmi_sm_sending_rhba(struct bfa_fcs_port_fdmi_s *fdmi, break; default: - bfa_sm_fault(port->fcs, event); + bfa_assert(0); } } @@ -230,7 +227,7 @@ bfa_fcs_port_fdmi_sm_rhba(struct bfa_fcs_port_fdmi_s *fdmi, break; default: - bfa_sm_fault(port->fcs, event); + bfa_assert(0); } } @@ -258,7 +255,7 @@ bfa_fcs_port_fdmi_sm_rhba_retry(struct bfa_fcs_port_fdmi_s *fdmi, break; default: - bfa_sm_fault(port->fcs, event); + bfa_assert(0); } } @@ -286,7 +283,7 @@ bfa_fcs_port_fdmi_sm_sending_rprt(struct bfa_fcs_port_fdmi_s *fdmi, break; default: - bfa_sm_fault(port->fcs, event); + bfa_assert(0); } } @@ -331,7 +328,7 @@ bfa_fcs_port_fdmi_sm_rprt(struct bfa_fcs_port_fdmi_s *fdmi, break; default: - bfa_sm_fault(port->fcs, event); + bfa_assert(0); } } @@ -359,7 +356,7 @@ bfa_fcs_port_fdmi_sm_rprt_retry(struct bfa_fcs_port_fdmi_s *fdmi, break; default: - bfa_sm_fault(port->fcs, event); + bfa_assert(0); } } @@ -387,7 +384,7 @@ bfa_fcs_port_fdmi_sm_sending_rpa(struct bfa_fcs_port_fdmi_s *fdmi, break; default: - bfa_sm_fault(port->fcs, event); + bfa_assert(0); } } @@ -431,7 +428,7 @@ bfa_fcs_port_fdmi_sm_rpa(struct bfa_fcs_port_fdmi_s *fdmi, break; default: - bfa_sm_fault(port->fcs, event); + bfa_assert(0); } } @@ -459,7 +456,7 @@ bfa_fcs_port_fdmi_sm_rpa_retry(struct bfa_fcs_port_fdmi_s *fdmi, break; default: - bfa_sm_fault(port->fcs, event); + bfa_assert(0); } } @@ -478,24 +475,10 @@ bfa_fcs_port_fdmi_sm_online(struct bfa_fcs_port_fdmi_s *fdmi, break; default: - bfa_sm_fault(port->fcs, event); + bfa_assert(0); } } -/** - * FDMI is disabled state. - */ -static void -bfa_fcs_port_fdmi_sm_disabled(struct bfa_fcs_port_fdmi_s *fdmi, - enum port_fdmi_event event) -{ - struct bfa_fcs_port_s *port = fdmi->ms->port; - - bfa_trc(port->fcs, port->port_cfg.pwwn); - bfa_trc(port->fcs, event); - - /* No op State. It can only be enabled at Driver Init. */ -} /** * RHBA : Register HBA Attributes. @@ -1114,23 +1097,36 @@ bfa_fcs_fdmi_get_hbaattr(struct bfa_fcs_port_fdmi_s *fdmi, { struct bfa_fcs_port_s *port = fdmi->ms->port; struct bfa_fcs_driver_info_s *driver_info = &port->fcs->driver_info; + struct bfa_adapter_attr_s adapter_attr; bfa_os_memset(hba_attr, 0, sizeof(struct bfa_fcs_fdmi_hba_attr_s)); + bfa_os_memset(&adapter_attr, 0, sizeof(struct bfa_adapter_attr_s)); + + bfa_ioc_get_adapter_attr(&port->fcs->bfa->ioc, &adapter_attr); + + strncpy(hba_attr->manufacturer, adapter_attr.manufacturer, + sizeof(adapter_attr.manufacturer)); + + strncpy(hba_attr->serial_num, adapter_attr.serial_num, + sizeof(adapter_attr.serial_num)); - bfa_ioc_get_adapter_manufacturer(&port->fcs->bfa->ioc, - hba_attr->manufacturer); - bfa_ioc_get_adapter_serial_num(&port->fcs->bfa->ioc, - hba_attr->serial_num); - bfa_ioc_get_adapter_model(&port->fcs->bfa->ioc, hba_attr->model); - bfa_ioc_get_adapter_model(&port->fcs->bfa->ioc, hba_attr->model_desc); - bfa_ioc_get_pci_chip_rev(&port->fcs->bfa->ioc, hba_attr->hw_version); - bfa_ioc_get_adapter_optrom_ver(&port->fcs->bfa->ioc, - hba_attr->option_rom_ver); - bfa_ioc_get_adapter_fw_ver(&port->fcs->bfa->ioc, hba_attr->fw_version); + strncpy(hba_attr->model, adapter_attr.model, sizeof(hba_attr->model)); + + strncpy(hba_attr->model_desc, adapter_attr.model_descr, + sizeof(hba_attr->model_desc)); + + strncpy(hba_attr->hw_version, adapter_attr.hw_ver, + sizeof(hba_attr->hw_version)); strncpy(hba_attr->driver_version, (char *)driver_info->version, sizeof(hba_attr->driver_version)); + strncpy(hba_attr->option_rom_ver, adapter_attr.optrom_ver, + sizeof(hba_attr->option_rom_ver)); + + strncpy(hba_attr->fw_version, adapter_attr.fw_ver, + sizeof(hba_attr->fw_version)); + strncpy(hba_attr->os_name, driver_info->host_os_name, sizeof(hba_attr->os_name)); @@ -1162,7 +1158,7 @@ bfa_fcs_fdmi_get_portattr(struct bfa_fcs_port_fdmi_s *fdmi, /* * get pport attributes from hal */ - bfa_fcport_get_attr(port->fcs->bfa, &pport_attr); + bfa_pport_get_attr(port->fcs->bfa, &pport_attr); /* * get FC4 type Bitmask @@ -1205,10 +1201,7 @@ bfa_fcs_port_fdmi_init(struct bfa_fcs_port_ms_s *ms) struct bfa_fcs_port_fdmi_s *fdmi = &ms->fdmi; fdmi->ms = ms; - if (ms->port->fcs->fdmi_enabled) - bfa_sm_set_state(fdmi, bfa_fcs_port_fdmi_sm_offline); - else - bfa_sm_set_state(fdmi, bfa_fcs_port_fdmi_sm_disabled); + bfa_sm_set_state(fdmi, bfa_fcs_port_fdmi_sm_offline); } void diff --git a/trunk/drivers/scsi/bfa/include/aen/bfa_aen.h b/trunk/drivers/scsi/bfa/include/aen/bfa_aen.h index 6abbab005db6..d9cbc2a783d4 100644 --- a/trunk/drivers/scsi/bfa/include/aen/bfa_aen.h +++ b/trunk/drivers/scsi/bfa/include/aen/bfa_aen.h @@ -18,24 +18,21 @@ #define __BFA_AEN_H__ #include "defs/bfa_defs_aen.h" -#include "defs/bfa_defs_status.h" -#include "cs/bfa_debug.h" -#define BFA_AEN_MAX_ENTRY 512 +#define BFA_AEN_MAX_ENTRY 512 -extern int bfa_aen_max_cfg_entry; +extern s32 bfa_aen_max_cfg_entry; struct bfa_aen_s { void *bfad; - int max_entry; - int write_index; - int read_index; - int bfad_num; - int seq_num; + s32 max_entry; + s32 write_index; + s32 read_index; + u32 bfad_num; + u32 seq_num; void (*aen_cb_notify)(void *bfad); void (*gettimeofday)(struct bfa_timeval_s *tv); - struct bfa_trc_mod_s *trcmod; - int app_ri[BFA_AEN_MAX_APP]; /* For multiclient support */ - struct bfa_aen_entry_s list[BFA_AEN_MAX_ENTRY]; /* Must be the last */ + struct bfa_trc_mod_s *trcmod; + struct bfa_aen_entry_s list[BFA_AEN_MAX_ENTRY]; /* Must be the last */ }; @@ -48,49 +45,48 @@ bfa_aen_set_max_cfg_entry(int max_entry) bfa_aen_max_cfg_entry = max_entry; } -static inline int +static inline s32 bfa_aen_get_max_cfg_entry(void) { return bfa_aen_max_cfg_entry; } -static inline int +static inline s32 bfa_aen_get_meminfo(void) { return sizeof(struct bfa_aen_entry_s) * bfa_aen_get_max_cfg_entry(); } -static inline int +static inline s32 bfa_aen_get_wi(struct bfa_aen_s *aen) { return aen->write_index; } -static inline int +static inline s32 bfa_aen_get_ri(struct bfa_aen_s *aen) { return aen->read_index; } -static inline int -bfa_aen_fetch_count(struct bfa_aen_s *aen, enum bfa_aen_app app_id) +static inline s32 +bfa_aen_fetch_count(struct bfa_aen_s *aen, s32 read_index) { - bfa_assert((app_id < BFA_AEN_MAX_APP) && (app_id >= bfa_aen_app_bcu)); - return ((aen->write_index + aen->max_entry) - aen->app_ri[app_id]) + return ((aen->write_index + aen->max_entry) - read_index) % aen->max_entry; } -int bfa_aen_init(struct bfa_aen_s *aen, struct bfa_trc_mod_s *trcmod, - void *bfad, int bfad_num, void (*aen_cb_notify)(void *), +s32 bfa_aen_init(struct bfa_aen_s *aen, struct bfa_trc_mod_s *trcmod, + void *bfad, u32 inst_id, void (*aen_cb_notify)(void *), void (*gettimeofday)(struct bfa_timeval_s *)); -void bfa_aen_post(struct bfa_aen_s *aen, enum bfa_aen_category aen_category, +s32 bfa_aen_post(struct bfa_aen_s *aen, enum bfa_aen_category aen_category, int aen_type, union bfa_aen_data_u *aen_data); -bfa_status_t bfa_aen_fetch(struct bfa_aen_s *aen, - struct bfa_aen_entry_s *aen_entry, - int entry_req, enum bfa_aen_app app_id, int *entry_ret); +s32 bfa_aen_fetch(struct bfa_aen_s *aen, struct bfa_aen_entry_s *aen_entry, + s32 entry_space, s32 rii, s32 *ri_arr, + s32 ri_arr_cnt); -int bfa_aen_get_inst(struct bfa_aen_s *aen); +s32 bfa_aen_get_inst(struct bfa_aen_s *aen); #endif /* __BFA_AEN_H__ */ diff --git a/trunk/drivers/scsi/bfa/include/bfa.h b/trunk/drivers/scsi/bfa/include/bfa.h index 1f5966cfbd16..d4bc0d9fa42c 100644 --- a/trunk/drivers/scsi/bfa/include/bfa.h +++ b/trunk/drivers/scsi/bfa/include/bfa.h @@ -106,26 +106,6 @@ struct bfa_sge_s { bfa_ioc_fetch_stats(&(__bfa)->ioc, __ioc_stats) #define bfa_ioc_clear_stats(__bfa) \ bfa_ioc_clr_stats(&(__bfa)->ioc) -#define bfa_get_nports(__bfa) \ - bfa_ioc_get_nports(&(__bfa)->ioc) -#define bfa_get_adapter_manufacturer(__bfa, __manufacturer) \ - bfa_ioc_get_adapter_manufacturer(&(__bfa)->ioc, __manufacturer) -#define bfa_get_adapter_model(__bfa, __model) \ - bfa_ioc_get_adapter_model(&(__bfa)->ioc, __model) -#define bfa_get_adapter_serial_num(__bfa, __serial_num) \ - bfa_ioc_get_adapter_serial_num(&(__bfa)->ioc, __serial_num) -#define bfa_get_adapter_fw_ver(__bfa, __fw_ver) \ - bfa_ioc_get_adapter_fw_ver(&(__bfa)->ioc, __fw_ver) -#define bfa_get_adapter_optrom_ver(__bfa, __optrom_ver) \ - bfa_ioc_get_adapter_optrom_ver(&(__bfa)->ioc, __optrom_ver) -#define bfa_get_pci_chip_rev(__bfa, __chip_rev) \ - bfa_ioc_get_pci_chip_rev(&(__bfa)->ioc, __chip_rev) -#define bfa_get_ioc_state(__bfa) \ - bfa_ioc_get_state(&(__bfa)->ioc) -#define bfa_get_type(__bfa) \ - bfa_ioc_get_type(&(__bfa)->ioc) -#define bfa_get_mac(__bfa) \ - bfa_ioc_get_mac(&(__bfa)->ioc) /* * bfa API functions @@ -181,7 +161,6 @@ bfa_status_t bfa_iocfc_israttr_set(struct bfa_s *bfa, void bfa_iocfc_enable(struct bfa_s *bfa); void bfa_iocfc_disable(struct bfa_s *bfa); void bfa_ioc_auto_recover(bfa_boolean_t auto_recover); -void bfa_chip_reset(struct bfa_s *bfa); void bfa_cb_ioc_disable(void *bfad); void bfa_timer_tick(struct bfa_s *bfa); #define bfa_timer_start(_bfa, _timer, _timercb, _arg, _timeout) \ @@ -192,7 +171,6 @@ void bfa_timer_tick(struct bfa_s *bfa); */ bfa_status_t bfa_debug_fwtrc(struct bfa_s *bfa, void *trcdata, int *trclen); bfa_status_t bfa_debug_fwsave(struct bfa_s *bfa, void *trcdata, int *trclen); -void bfa_debug_fwsave_clear(struct bfa_s *bfa); #include "bfa_priv.h" diff --git a/trunk/drivers/scsi/bfa/include/bfa_svc.h b/trunk/drivers/scsi/bfa/include/bfa_svc.h index 1349b99a3c6d..268d956bad89 100644 --- a/trunk/drivers/scsi/bfa/include/bfa_svc.h +++ b/trunk/drivers/scsi/bfa/include/bfa_svc.h @@ -26,7 +26,6 @@ struct bfa_fcxp_s; #include #include #include -#include #include #include @@ -36,7 +35,7 @@ struct bfa_fcxp_s; struct bfa_rport_info_s { u16 max_frmsz; /* max rcv pdu size */ u32 pid:24, /* remote port ID */ - lp_tag:8; /* tag */ + lp_tag:8; u32 local_pid:24, /* local port ID */ cisc:8; /* CIRO supported */ u8 fc_class; /* supported FC classes. enum fc_cos */ @@ -55,7 +54,7 @@ struct bfa_rport_s { void *rport_drv; /* fcs/driver rport object */ u16 fw_handle; /* firmware rport handle */ u16 rport_tag; /* BFA rport tag */ - struct bfa_rport_info_s rport_info; /* rport info from fcs/driver */ + struct bfa_rport_info_s rport_info; /* rport info from *fcs/driver */ struct bfa_reqq_wait_s reqq_wait; /* to wait for room in reqq */ struct bfa_cb_qe_s hcb_qe; /* BFA callback qelem */ struct bfa_rport_hal_stats_s stats; /* BFA rport statistics */ @@ -102,7 +101,7 @@ struct bfa_uf_buf_s { struct bfa_uf_s { struct list_head qe; /* queue element */ struct bfa_s *bfa; /* bfa instance */ - u16 uf_tag; /* identifying tag fw msgs */ + u16 uf_tag; /* identifying tag f/w messages */ u16 vf_id; u16 src_rport_handle; u16 rsvd; @@ -128,7 +127,7 @@ struct bfa_lps_s { u8 reqq; /* lport request queue */ u8 alpa; /* ALPA for loop topologies */ u32 lp_pid; /* lport port ID */ - bfa_boolean_t fdisc; /* send FDISC instead of FLOGI */ + bfa_boolean_t fdisc; /* send FDISC instead of FLOGI*/ bfa_boolean_t auth_en; /* enable authentication */ bfa_boolean_t auth_req; /* authentication required */ bfa_boolean_t npiv_en; /* NPIV is allowed by peer */ @@ -152,69 +151,60 @@ struct bfa_lps_s { bfa_eproto_status_t ext_status; }; -#define BFA_FCPORT(_bfa) (&((_bfa)->modules.port)) - /* * bfa pport API functions */ -bfa_status_t bfa_fcport_enable(struct bfa_s *bfa); -bfa_status_t bfa_fcport_disable(struct bfa_s *bfa); -bfa_status_t bfa_fcport_cfg_speed(struct bfa_s *bfa, +bfa_status_t bfa_pport_enable(struct bfa_s *bfa); +bfa_status_t bfa_pport_disable(struct bfa_s *bfa); +bfa_status_t bfa_pport_cfg_speed(struct bfa_s *bfa, enum bfa_pport_speed speed); -enum bfa_pport_speed bfa_fcport_get_speed(struct bfa_s *bfa); -bfa_status_t bfa_fcport_cfg_topology(struct bfa_s *bfa, +enum bfa_pport_speed bfa_pport_get_speed(struct bfa_s *bfa); +bfa_status_t bfa_pport_cfg_topology(struct bfa_s *bfa, enum bfa_pport_topology topo); -enum bfa_pport_topology bfa_fcport_get_topology(struct bfa_s *bfa); -bfa_status_t bfa_fcport_cfg_hardalpa(struct bfa_s *bfa, u8 alpa); -bfa_boolean_t bfa_fcport_get_hardalpa(struct bfa_s *bfa, u8 *alpa); -u8 bfa_fcport_get_myalpa(struct bfa_s *bfa); -bfa_status_t bfa_fcport_clr_hardalpa(struct bfa_s *bfa); -bfa_status_t bfa_fcport_cfg_maxfrsize(struct bfa_s *bfa, u16 maxsize); -u16 bfa_fcport_get_maxfrsize(struct bfa_s *bfa); -u32 bfa_fcport_mypid(struct bfa_s *bfa); -u8 bfa_fcport_get_rx_bbcredit(struct bfa_s *bfa); -bfa_status_t bfa_fcport_trunk_enable(struct bfa_s *bfa, u8 bitmap); -bfa_status_t bfa_fcport_trunk_disable(struct bfa_s *bfa); -bfa_boolean_t bfa_fcport_trunk_query(struct bfa_s *bfa, u32 *bitmap); -void bfa_fcport_get_attr(struct bfa_s *bfa, struct bfa_pport_attr_s *attr); -wwn_t bfa_fcport_get_wwn(struct bfa_s *bfa, bfa_boolean_t node); -void bfa_fcport_event_register(struct bfa_s *bfa, +enum bfa_pport_topology bfa_pport_get_topology(struct bfa_s *bfa); +bfa_status_t bfa_pport_cfg_hardalpa(struct bfa_s *bfa, u8 alpa); +bfa_boolean_t bfa_pport_get_hardalpa(struct bfa_s *bfa, u8 *alpa); +u8 bfa_pport_get_myalpa(struct bfa_s *bfa); +bfa_status_t bfa_pport_clr_hardalpa(struct bfa_s *bfa); +bfa_status_t bfa_pport_cfg_maxfrsize(struct bfa_s *bfa, u16 maxsize); +u16 bfa_pport_get_maxfrsize(struct bfa_s *bfa); +u32 bfa_pport_mypid(struct bfa_s *bfa); +u8 bfa_pport_get_rx_bbcredit(struct bfa_s *bfa); +bfa_status_t bfa_pport_trunk_enable(struct bfa_s *bfa, u8 bitmap); +bfa_status_t bfa_pport_trunk_disable(struct bfa_s *bfa); +bfa_boolean_t bfa_pport_trunk_query(struct bfa_s *bfa, u32 *bitmap); +void bfa_pport_get_attr(struct bfa_s *bfa, struct bfa_pport_attr_s *attr); +wwn_t bfa_pport_get_wwn(struct bfa_s *bfa, bfa_boolean_t node); +bfa_status_t bfa_pport_get_stats(struct bfa_s *bfa, + union bfa_pport_stats_u *stats, + bfa_cb_pport_t cbfn, void *cbarg); +bfa_status_t bfa_pport_clear_stats(struct bfa_s *bfa, bfa_cb_pport_t cbfn, + void *cbarg); +void bfa_pport_event_register(struct bfa_s *bfa, void (*event_cbfn) (void *cbarg, bfa_pport_event_t event), void *event_cbarg); -bfa_boolean_t bfa_fcport_is_disabled(struct bfa_s *bfa); -void bfa_fcport_cfg_qos(struct bfa_s *bfa, bfa_boolean_t on_off); -void bfa_fcport_cfg_ratelim(struct bfa_s *bfa, bfa_boolean_t on_off); -bfa_status_t bfa_fcport_cfg_ratelim_speed(struct bfa_s *bfa, +bfa_boolean_t bfa_pport_is_disabled(struct bfa_s *bfa); +void bfa_pport_cfg_qos(struct bfa_s *bfa, bfa_boolean_t on_off); +void bfa_pport_cfg_ratelim(struct bfa_s *bfa, bfa_boolean_t on_off); +bfa_status_t bfa_pport_cfg_ratelim_speed(struct bfa_s *bfa, enum bfa_pport_speed speed); -enum bfa_pport_speed bfa_fcport_get_ratelim_speed(struct bfa_s *bfa); +enum bfa_pport_speed bfa_pport_get_ratelim_speed(struct bfa_s *bfa); -void bfa_fcport_set_tx_bbcredit(struct bfa_s *bfa, u16 tx_bbcredit); -void bfa_fcport_busy(struct bfa_s *bfa, bfa_boolean_t status); -void bfa_fcport_beacon(struct bfa_s *bfa, bfa_boolean_t beacon, +void bfa_pport_set_tx_bbcredit(struct bfa_s *bfa, u16 tx_bbcredit); +void bfa_pport_busy(struct bfa_s *bfa, bfa_boolean_t status); +void bfa_pport_beacon(struct bfa_s *bfa, bfa_boolean_t beacon, bfa_boolean_t link_e2e_beacon); void bfa_cb_pport_event(void *cbarg, bfa_pport_event_t event); -void bfa_fcport_qos_get_attr(struct bfa_s *bfa, - struct bfa_qos_attr_s *qos_attr); -void bfa_fcport_qos_get_vc_attr(struct bfa_s *bfa, +void bfa_pport_qos_get_attr(struct bfa_s *bfa, struct bfa_qos_attr_s *qos_attr); +void bfa_pport_qos_get_vc_attr(struct bfa_s *bfa, struct bfa_qos_vc_attr_s *qos_vc_attr); -bfa_status_t bfa_fcport_get_qos_stats(struct bfa_s *bfa, - union bfa_fcport_stats_u *stats, +bfa_status_t bfa_pport_get_qos_stats(struct bfa_s *bfa, + union bfa_pport_stats_u *stats, bfa_cb_pport_t cbfn, void *cbarg); -bfa_status_t bfa_fcport_clear_qos_stats(struct bfa_s *bfa, bfa_cb_pport_t cbfn, +bfa_status_t bfa_pport_clear_qos_stats(struct bfa_s *bfa, bfa_cb_pport_t cbfn, void *cbarg); -bfa_status_t bfa_fcport_get_fcoe_stats(struct bfa_s *bfa, - union bfa_fcport_stats_u *stats, - bfa_cb_pport_t cbfn, void *cbarg); -bfa_status_t bfa_fcport_clear_fcoe_stats(struct bfa_s *bfa, bfa_cb_pport_t cbfn, - void *cbarg); - -bfa_boolean_t bfa_fcport_is_ratelim(struct bfa_s *bfa); -bfa_boolean_t bfa_fcport_is_linkup(struct bfa_s *bfa); -bfa_status_t bfa_fcport_get_stats(struct bfa_s *bfa, - union bfa_fcport_stats_u *stats, - bfa_cb_pport_t cbfn, void *cbarg); -bfa_status_t bfa_fcport_clear_stats(struct bfa_s *bfa, bfa_cb_pport_t cbfn, - void *cbarg); +bfa_boolean_t bfa_pport_is_ratelim(struct bfa_s *bfa); +bfa_boolean_t bfa_pport_is_linkup(struct bfa_s *bfa); /* * bfa rport API functions @@ -303,7 +293,6 @@ void bfa_uf_free(struct bfa_uf_s *uf); * bfa lport service api */ -u32 bfa_lps_get_max_vport(struct bfa_s *bfa); struct bfa_lps_s *bfa_lps_alloc(struct bfa_s *bfa); void bfa_lps_delete(struct bfa_lps_s *lps); void bfa_lps_discard(struct bfa_lps_s *lps); @@ -326,12 +315,10 @@ wwn_t bfa_lps_get_peer_pwwn(struct bfa_lps_s *lps); wwn_t bfa_lps_get_peer_nwwn(struct bfa_lps_s *lps); u8 bfa_lps_get_lsrjt_rsn(struct bfa_lps_s *lps); u8 bfa_lps_get_lsrjt_expl(struct bfa_lps_s *lps); -mac_t bfa_lps_get_lp_mac(struct bfa_lps_s *lps); void bfa_cb_lps_flogi_comp(void *bfad, void *uarg, bfa_status_t status); void bfa_cb_lps_flogo_comp(void *bfad, void *uarg); void bfa_cb_lps_fdisc_comp(void *bfad, void *uarg, bfa_status_t status); void bfa_cb_lps_fdisclogo_comp(void *bfad, void *uarg); -void bfa_cb_lps_cvl_event(void *bfad, void *uarg); #endif /* __BFA_SVC_H__ */ diff --git a/trunk/drivers/scsi/bfa/include/bfa_timer.h b/trunk/drivers/scsi/bfa/include/bfa_timer.h index f71087448222..e407103fa565 100644 --- a/trunk/drivers/scsi/bfa/include/bfa_timer.h +++ b/trunk/drivers/scsi/bfa/include/bfa_timer.h @@ -41,7 +41,7 @@ struct bfa_timer_mod_s { struct list_head timer_q; }; -#define BFA_TIMER_FREQ 200 /**< specified in millisecs */ +#define BFA_TIMER_FREQ 500 /**< specified in millisecs */ void bfa_timer_beat(struct bfa_timer_mod_s *mod); void bfa_timer_init(struct bfa_timer_mod_s *mod); diff --git a/trunk/drivers/scsi/bfa/include/bfi/bfi.h b/trunk/drivers/scsi/bfa/include/bfi/bfi.h index a550e80cabd2..7042c18e542d 100644 --- a/trunk/drivers/scsi/bfa/include/bfi/bfi.h +++ b/trunk/drivers/scsi/bfa/include/bfi/bfi.h @@ -143,8 +143,8 @@ enum bfi_mclass { BFI_MC_IOC = 1, /* IO Controller (IOC) */ BFI_MC_DIAG = 2, /* Diagnostic Msgs */ BFI_MC_FLASH = 3, /* Flash message class */ - BFI_MC_CEE = 4, /* CEE */ - BFI_MC_FCPORT = 5, /* FC port */ + BFI_MC_CEE = 4, + BFI_MC_FC_PORT = 5, /* FC port */ BFI_MC_IOCFC = 6, /* FC - IO Controller (IOC) */ BFI_MC_LL = 7, /* Link Layer */ BFI_MC_UF = 8, /* Unsolicited frame receive */ diff --git a/trunk/drivers/scsi/bfa/include/bfi/bfi_cbreg.h b/trunk/drivers/scsi/bfa/include/bfi/bfi_cbreg.h index a51ee61ddb19..b3bb52b565b1 100644 --- a/trunk/drivers/scsi/bfa/include/bfi/bfi_cbreg.h +++ b/trunk/drivers/scsi/bfa/include/bfi/bfi_cbreg.h @@ -177,21 +177,7 @@ #define __PSS_LMEM_INIT_EN 0x00000100 #define __PSS_LPU1_RESET 0x00000002 #define __PSS_LPU0_RESET 0x00000001 -#define PSS_ERR_STATUS_REG 0x00018810 -#define __PSS_LMEM1_CORR_ERR 0x00000800 -#define __PSS_LMEM0_CORR_ERR 0x00000400 -#define __PSS_LMEM1_UNCORR_ERR 0x00000200 -#define __PSS_LMEM0_UNCORR_ERR 0x00000100 -#define __PSS_BAL_PERR 0x00000080 -#define __PSS_DIP_IF_ERR 0x00000040 -#define __PSS_IOH_IF_ERR 0x00000020 -#define __PSS_TDS_IF_ERR 0x00000010 -#define __PSS_RDS_IF_ERR 0x00000008 -#define __PSS_SGM_IF_ERR 0x00000004 -#define __PSS_LPU1_RAM_ERR 0x00000002 -#define __PSS_LPU0_RAM_ERR 0x00000001 -#define ERR_SET_REG 0x00018818 -#define __PSS_ERR_STATUS_SET 0x00000fff + /* * These definitions are either in error/missing in spec. Its auto-generated diff --git a/trunk/drivers/scsi/bfa/include/bfi/bfi_ctreg.h b/trunk/drivers/scsi/bfa/include/bfi/bfi_ctreg.h index 57a8497105af..d3caa58c0a0a 100644 --- a/trunk/drivers/scsi/bfa/include/bfi/bfi_ctreg.h +++ b/trunk/drivers/scsi/bfa/include/bfi/bfi_ctreg.h @@ -430,31 +430,6 @@ enum { #define __PSS_LMEM_INIT_EN 0x00000100 #define __PSS_LPU1_RESET 0x00000002 #define __PSS_LPU0_RESET 0x00000001 -#define PSS_ERR_STATUS_REG 0x00018810 -#define __PSS_LPU1_TCM_READ_ERR 0x00200000 -#define __PSS_LPU0_TCM_READ_ERR 0x00100000 -#define __PSS_LMEM5_CORR_ERR 0x00080000 -#define __PSS_LMEM4_CORR_ERR 0x00040000 -#define __PSS_LMEM3_CORR_ERR 0x00020000 -#define __PSS_LMEM2_CORR_ERR 0x00010000 -#define __PSS_LMEM1_CORR_ERR 0x00008000 -#define __PSS_LMEM0_CORR_ERR 0x00004000 -#define __PSS_LMEM5_UNCORR_ERR 0x00002000 -#define __PSS_LMEM4_UNCORR_ERR 0x00001000 -#define __PSS_LMEM3_UNCORR_ERR 0x00000800 -#define __PSS_LMEM2_UNCORR_ERR 0x00000400 -#define __PSS_LMEM1_UNCORR_ERR 0x00000200 -#define __PSS_LMEM0_UNCORR_ERR 0x00000100 -#define __PSS_BAL_PERR 0x00000080 -#define __PSS_DIP_IF_ERR 0x00000040 -#define __PSS_IOH_IF_ERR 0x00000020 -#define __PSS_TDS_IF_ERR 0x00000010 -#define __PSS_RDS_IF_ERR 0x00000008 -#define __PSS_SGM_IF_ERR 0x00000004 -#define __PSS_LPU1_RAM_ERR 0x00000002 -#define __PSS_LPU0_RAM_ERR 0x00000001 -#define ERR_SET_REG 0x00018818 -#define __PSS_ERR_STATUS_SET 0x003fffff #define HQM_QSET0_RXQ_DRBL_P0 0x00038000 #define __RXQ0_ADD_VECTORS_P 0x80000000 #define __RXQ0_STOP_P 0x40000000 @@ -614,7 +589,6 @@ enum { #define __HFN_INT_MBOX_LPU1 0x00200000U #define __HFN_INT_MBOX1_LPU0 0x00400000U #define __HFN_INT_MBOX1_LPU1 0x00800000U -#define __HFN_INT_LL_HALT 0x01000000U #define __HFN_INT_CPE_MASK 0x000000ffU #define __HFN_INT_RME_MASK 0x0000ff00U diff --git a/trunk/drivers/scsi/bfa/include/bfi/bfi_ioc.h b/trunk/drivers/scsi/bfa/include/bfi/bfi_ioc.h index a0158aac0024..96ef05670659 100644 --- a/trunk/drivers/scsi/bfa/include/bfi/bfi_ioc.h +++ b/trunk/drivers/scsi/bfa/include/bfi/bfi_ioc.h @@ -123,7 +123,7 @@ enum bfi_ioc_state { BFI_IOC_DISABLING = 5, /* IOC is being disabled */ BFI_IOC_DISABLED = 6, /* IOC is disabled */ BFI_IOC_CFG_DISABLED = 7, /* IOC is being disabled;transient */ - BFI_IOC_FAIL = 8, /* IOC heart-beat failure */ + BFI_IOC_HBFAIL = 8, /* IOC heart-beat failure */ BFI_IOC_MEMTEST = 9, /* IOC is doing memtest */ }; diff --git a/trunk/drivers/scsi/bfa/include/bfi/bfi_lps.h b/trunk/drivers/scsi/bfa/include/bfi/bfi_lps.h index 7ed31bbb8696..c59d47badb4b 100644 --- a/trunk/drivers/scsi/bfa/include/bfi/bfi_lps.h +++ b/trunk/drivers/scsi/bfa/include/bfi/bfi_lps.h @@ -30,7 +30,6 @@ enum bfi_lps_h2i_msgs { enum bfi_lps_i2h_msgs { BFI_LPS_H2I_LOGIN_RSP = BFA_I2HM(1), BFI_LPS_H2I_LOGOUT_RSP = BFA_I2HM(2), - BFI_LPS_H2I_CVL_EVENT = BFA_I2HM(3), }; struct bfi_lps_login_req_s { @@ -78,12 +77,6 @@ struct bfi_lps_logout_rsp_s { u8 rsvd[2]; }; -struct bfi_lps_cvl_event_s { - struct bfi_mhdr_s mh; /* common msg header */ - u8 lp_tag; - u8 rsvd[3]; -}; - union bfi_lps_h2i_msg_u { struct bfi_mhdr_s *msg; struct bfi_lps_login_req_s *login_req; @@ -94,7 +87,6 @@ union bfi_lps_i2h_msg_u { struct bfi_msg_s *msg; struct bfi_lps_login_rsp_s *login_rsp; struct bfi_lps_logout_rsp_s *logout_rsp; - struct bfi_lps_cvl_event_s *cvl_event; }; #pragma pack() diff --git a/trunk/drivers/scsi/bfa/include/bfi/bfi_pport.h b/trunk/drivers/scsi/bfa/include/bfi/bfi_pport.h index 50dcf45c7470..c96d246851af 100644 --- a/trunk/drivers/scsi/bfa/include/bfi/bfi_pport.h +++ b/trunk/drivers/scsi/bfa/include/bfi/bfi_pport.h @@ -22,97 +22,163 @@ #pragma pack(1) -enum bfi_fcport_h2i { - BFI_FCPORT_H2I_ENABLE_REQ = (1), - BFI_FCPORT_H2I_DISABLE_REQ = (2), - BFI_FCPORT_H2I_SET_SVC_PARAMS_REQ = (3), - BFI_FCPORT_H2I_STATS_GET_REQ = (4), - BFI_FCPORT_H2I_STATS_CLEAR_REQ = (5), +enum bfi_pport_h2i { + BFI_PPORT_H2I_ENABLE_REQ = (1), + BFI_PPORT_H2I_DISABLE_REQ = (2), + BFI_PPORT_H2I_GET_STATS_REQ = (3), + BFI_PPORT_H2I_CLEAR_STATS_REQ = (4), + BFI_PPORT_H2I_SET_SVC_PARAMS_REQ = (5), + BFI_PPORT_H2I_ENABLE_RX_VF_TAG_REQ = (6), + BFI_PPORT_H2I_ENABLE_TX_VF_TAG_REQ = (7), + BFI_PPORT_H2I_GET_QOS_STATS_REQ = (8), + BFI_PPORT_H2I_CLEAR_QOS_STATS_REQ = (9), }; -enum bfi_fcport_i2h { - BFI_FCPORT_I2H_ENABLE_RSP = BFA_I2HM(1), - BFI_FCPORT_I2H_DISABLE_RSP = BFA_I2HM(2), - BFI_FCPORT_I2H_SET_SVC_PARAMS_RSP = BFA_I2HM(3), - BFI_FCPORT_I2H_STATS_GET_RSP = BFA_I2HM(4), - BFI_FCPORT_I2H_STATS_CLEAR_RSP = BFA_I2HM(5), - BFI_FCPORT_I2H_EVENT = BFA_I2HM(6), +enum bfi_pport_i2h { + BFI_PPORT_I2H_ENABLE_RSP = BFA_I2HM(1), + BFI_PPORT_I2H_DISABLE_RSP = BFA_I2HM(2), + BFI_PPORT_I2H_GET_STATS_RSP = BFA_I2HM(3), + BFI_PPORT_I2H_CLEAR_STATS_RSP = BFA_I2HM(4), + BFI_PPORT_I2H_SET_SVC_PARAMS_RSP = BFA_I2HM(5), + BFI_PPORT_I2H_ENABLE_RX_VF_TAG_RSP = BFA_I2HM(6), + BFI_PPORT_I2H_ENABLE_TX_VF_TAG_RSP = BFA_I2HM(7), + BFI_PPORT_I2H_EVENT = BFA_I2HM(8), + BFI_PPORT_I2H_GET_QOS_STATS_RSP = BFA_I2HM(9), + BFI_PPORT_I2H_CLEAR_QOS_STATS_RSP = BFA_I2HM(10), }; /** * Generic REQ type */ -struct bfi_fcport_req_s { +struct bfi_pport_generic_req_s { struct bfi_mhdr_s mh; /* msg header */ - u32 msgtag; /* msgtag for reply */ + u32 msgtag; /* msgtag for reply */ }; /** * Generic RSP type */ -struct bfi_fcport_rsp_s { +struct bfi_pport_generic_rsp_s { struct bfi_mhdr_s mh; /* common msg header */ - u8 status; /* port enable status */ - u8 rsvd[3]; - u32 msgtag; /* msgtag for reply */ + u8 status; /* port enable status */ + u8 rsvd[3]; + u32 msgtag; /* msgtag for reply */ }; /** - * BFI_FCPORT_H2I_ENABLE_REQ + * BFI_PPORT_H2I_ENABLE_REQ */ -struct bfi_fcport_enable_req_s { +struct bfi_pport_enable_req_s { struct bfi_mhdr_s mh; /* msg header */ - u32 rsvd1; - wwn_t nwwn; /* node wwn of physical port */ - wwn_t pwwn; /* port wwn of physical port */ - struct bfa_pport_cfg_s port_cfg; /* port configuration */ - union bfi_addr_u stats_dma_addr; /* DMA address for stats */ - u32 msgtag; /* msgtag for reply */ - u32 rsvd2; + u32 rsvd1; + wwn_t nwwn; /* node wwn of physical port */ + wwn_t pwwn; /* port wwn of physical port */ + struct bfa_pport_cfg_s port_cfg; /* port configuration */ + union bfi_addr_u stats_dma_addr; /* DMA address for stats */ + u32 msgtag; /* msgtag for reply */ + u32 rsvd2; }; /** - * BFI_FCPORT_H2I_SET_SVC_PARAMS_REQ + * BFI_PPORT_I2H_ENABLE_RSP */ -struct bfi_fcport_set_svc_params_req_s { +#define bfi_pport_enable_rsp_t struct bfi_pport_generic_rsp_s + +/** + * BFI_PPORT_H2I_DISABLE_REQ + */ +#define bfi_pport_disable_req_t struct bfi_pport_generic_req_s + +/** + * BFI_PPORT_I2H_DISABLE_RSP + */ +#define bfi_pport_disable_rsp_t struct bfi_pport_generic_rsp_s + +/** + * BFI_PPORT_H2I_GET_STATS_REQ + */ +#define bfi_pport_get_stats_req_t struct bfi_pport_generic_req_s + +/** + * BFI_PPORT_I2H_GET_STATS_RSP + */ +#define bfi_pport_get_stats_rsp_t struct bfi_pport_generic_rsp_s + +/** + * BFI_PPORT_H2I_CLEAR_STATS_REQ + */ +#define bfi_pport_clear_stats_req_t struct bfi_pport_generic_req_s + +/** + * BFI_PPORT_I2H_CLEAR_STATS_RSP + */ +#define bfi_pport_clear_stats_rsp_t struct bfi_pport_generic_rsp_s + +/** + * BFI_PPORT_H2I_GET_QOS_STATS_REQ + */ +#define bfi_pport_get_qos_stats_req_t struct bfi_pport_generic_req_s + +/** + * BFI_PPORT_H2I_GET_QOS_STATS_RSP + */ +#define bfi_pport_get_qos_stats_rsp_t struct bfi_pport_generic_rsp_s + +/** + * BFI_PPORT_H2I_CLEAR_QOS_STATS_REQ + */ +#define bfi_pport_clear_qos_stats_req_t struct bfi_pport_generic_req_s + +/** + * BFI_PPORT_H2I_CLEAR_QOS_STATS_RSP + */ +#define bfi_pport_clear_qos_stats_rsp_t struct bfi_pport_generic_rsp_s + +/** + * BFI_PPORT_H2I_SET_SVC_PARAMS_REQ + */ +struct bfi_pport_set_svc_params_req_s { struct bfi_mhdr_s mh; /* msg header */ - u16 tx_bbcredit; /* Tx credits */ - u16 rsvd; + u16 tx_bbcredit; /* Tx credits */ + u16 rsvd; }; /** - * BFI_FCPORT_I2H_EVENT + * BFI_PPORT_I2H_SET_SVC_PARAMS_RSP + */ + +/** + * BFI_PPORT_I2H_EVENT */ -struct bfi_fcport_event_s { +struct bfi_pport_event_s { struct bfi_mhdr_s mh; /* common msg header */ struct bfa_pport_link_s link_state; }; -/** - * fcport H2I message - */ -union bfi_fcport_h2i_msg_u { +union bfi_pport_h2i_msg_u { struct bfi_mhdr_s *mhdr; - struct bfi_fcport_enable_req_s *penable; - struct bfi_fcport_req_s *pdisable; - struct bfi_fcport_set_svc_params_req_s *psetsvcparams; - struct bfi_fcport_req_s *pstatsget; - struct bfi_fcport_req_s *pstatsclear; + struct bfi_pport_enable_req_s *penable; + struct bfi_pport_generic_req_s *pdisable; + struct bfi_pport_generic_req_s *pgetstats; + struct bfi_pport_generic_req_s *pclearstats; + struct bfi_pport_set_svc_params_req_s *psetsvcparams; + struct bfi_pport_get_qos_stats_req_s *pgetqosstats; + struct bfi_pport_generic_req_s *pclearqosstats; }; -/** - * fcport I2H message - */ -union bfi_fcport_i2h_msg_u { +union bfi_pport_i2h_msg_u { struct bfi_msg_s *msg; - struct bfi_fcport_rsp_s *penable_rsp; - struct bfi_fcport_rsp_s *pdisable_rsp; - struct bfi_fcport_rsp_s *psetsvcparams_rsp; - struct bfi_fcport_rsp_s *pstatsget_rsp; - struct bfi_fcport_rsp_s *pstatsclear_rsp; - struct bfi_fcport_event_s *event; + struct bfi_pport_generic_rsp_s *enable_rsp; + struct bfi_pport_disable_rsp_s *disable_rsp; + struct bfi_pport_generic_rsp_s *getstats_rsp; + struct bfi_pport_clear_stats_rsp_s *clearstats_rsp; + struct bfi_pport_set_svc_params_rsp_s *setsvcparasm_rsp; + struct bfi_pport_get_qos_stats_rsp_s *getqosstats_rsp; + struct bfi_pport_clear_qos_stats_rsp_s *clearqosstats_rsp; + struct bfi_pport_event_s *event; }; #pragma pack() #endif /* __BFI_PPORT_H__ */ + diff --git a/trunk/drivers/scsi/bfa/include/cna/bfa_cna_trcmod.h b/trunk/drivers/scsi/bfa/include/cna/bfa_cna_trcmod.h index a75a1f3be315..43ba7064e81a 100644 --- a/trunk/drivers/scsi/bfa/include/cna/bfa_cna_trcmod.h +++ b/trunk/drivers/scsi/bfa/include/cna/bfa_cna_trcmod.h @@ -31,10 +31,6 @@ enum { BFA_TRC_CNA_CEE = 1, BFA_TRC_CNA_PORT = 2, - BFA_TRC_CNA_IOC = 3, - BFA_TRC_CNA_DIAG = 4, - BFA_TRC_CNA_IOC_CB = 5, - BFA_TRC_CNA_IOC_CT = 6, }; #endif /* __BFA_CNA_TRCMOD_H__ */ diff --git a/trunk/drivers/scsi/bfa/include/cs/bfa_log.h b/trunk/drivers/scsi/bfa/include/cs/bfa_log.h index bc334e0a93fa..761cbe22130a 100644 --- a/trunk/drivers/scsi/bfa/include/cs/bfa_log.h +++ b/trunk/drivers/scsi/bfa/include/cs/bfa_log.h @@ -157,7 +157,7 @@ typedef void (*bfa_log_cb_t)(struct bfa_log_mod_s *log_mod, u32 msg_id, struct bfa_log_mod_s { - char instance_info[BFA_STRING_32]; /* instance info */ + char instance_info[16]; /* instance info */ int log_level[BFA_LOG_MODULE_ID_MAX + 1]; /* log level for modules */ bfa_log_cb_t cbfn; /* callback function */ diff --git a/trunk/drivers/scsi/bfa/include/cs/bfa_plog.h b/trunk/drivers/scsi/bfa/include/cs/bfa_plog.h index f5bef63b5877..670f86e5fc6e 100644 --- a/trunk/drivers/scsi/bfa/include/cs/bfa_plog.h +++ b/trunk/drivers/scsi/bfa/include/cs/bfa_plog.h @@ -80,8 +80,7 @@ enum bfa_plog_mid { BFA_PL_MID_HAL_FCXP = 4, BFA_PL_MID_HAL_UF = 5, BFA_PL_MID_FCS = 6, - BFA_PL_MID_LPS = 7, - BFA_PL_MID_MAX = 8 + BFA_PL_MID_MAX = 7 }; #define BFA_PL_MID_STRLEN 8 @@ -119,11 +118,7 @@ enum bfa_plog_eid { BFA_PL_EID_RSCN = 17, BFA_PL_EID_DEBUG = 18, BFA_PL_EID_MISC = 19, - BFA_PL_EID_FIP_FCF_DISC = 20, - BFA_PL_EID_FIP_FCF_CVL = 21, - BFA_PL_EID_LOGIN = 22, - BFA_PL_EID_LOGO = 23, - BFA_PL_EID_MAX = 24 + BFA_PL_EID_MAX = 20 }; #define BFA_PL_ENAME_STRLEN 8 diff --git a/trunk/drivers/scsi/bfa/include/cs/bfa_sm.h b/trunk/drivers/scsi/bfa/include/cs/bfa_sm.h index 11fba9082f05..b0a92baf6657 100644 --- a/trunk/drivers/scsi/bfa/include/cs/bfa_sm.h +++ b/trunk/drivers/scsi/bfa/include/cs/bfa_sm.h @@ -23,14 +23,6 @@ #define __BFA_SM_H__ typedef void (*bfa_sm_t)(void *sm, int event); -/** - * oc - object class eg. bfa_ioc - * st - state, eg. reset - * otype - object type, eg. struct bfa_ioc_s - * etype - object type, eg. enum ioc_event - */ -#define bfa_sm_state_decl(oc, st, otype, etype) \ - static void oc ## _sm_ ## st(otype * fsm, etype event) #define bfa_sm_set_state(_sm, _state) ((_sm)->sm = (bfa_sm_t)(_state)) #define bfa_sm_send_event(_sm, _event) ((_sm)->sm((_sm), (_event))) diff --git a/trunk/drivers/scsi/bfa/include/defs/bfa_defs_aen.h b/trunk/drivers/scsi/bfa/include/defs/bfa_defs_aen.h index 35244698fcdc..4c81a613db3d 100644 --- a/trunk/drivers/scsi/bfa/include/defs/bfa_defs_aen.h +++ b/trunk/drivers/scsi/bfa/include/defs/bfa_defs_aen.h @@ -30,16 +30,6 @@ #include #include -#define BFA_AEN_MAX_APP 5 - -enum bfa_aen_app { - bfa_aen_app_bcu = 0, /* No thread for bcu */ - bfa_aen_app_hcm = 1, - bfa_aen_app_cim = 2, - bfa_aen_app_snia = 3, - bfa_aen_app_test = 4, /* To be removed after unit test */ -}; - enum bfa_aen_category { BFA_AEN_CAT_ADAPTER = 1, BFA_AEN_CAT_PORT = 2, diff --git a/trunk/drivers/scsi/bfa/include/defs/bfa_defs_auth.h b/trunk/drivers/scsi/bfa/include/defs/bfa_defs_auth.h index 45df32820911..dd19c83aba58 100644 --- a/trunk/drivers/scsi/bfa/include/defs/bfa_defs_auth.h +++ b/trunk/drivers/scsi/bfa/include/defs/bfa_defs_auth.h @@ -23,7 +23,6 @@ #define PRIVATE_KEY 19009 #define KEY_LEN 32399 #define BFA_AUTH_SECRET_STRING_LEN 256 -#define BFA_AUTH_FAIL_NO_PASSWORD 0xFE #define BFA_AUTH_FAIL_TIMEOUT 0xFF /** @@ -42,27 +41,6 @@ enum bfa_auth_status { BFA_AUTH_STATUS_UNKNOWN = 9, /* authentication status unknown */ }; -enum bfa_auth_rej_code { - BFA_AUTH_RJT_CODE_AUTH_FAILURE = 1, /* auth failure */ - BFA_AUTH_RJT_CODE_LOGICAL_ERR = 2, /* logical error */ -}; - -/** - * Authentication reject codes - */ -enum bfa_auth_rej_code_exp { - BFA_AUTH_MECH_NOT_USABLE = 1, /* auth. mechanism not usable */ - BFA_AUTH_DH_GROUP_NOT_USABLE = 2, /* DH Group not usable */ - BFA_AUTH_HASH_FUNC_NOT_USABLE = 3, /* hash Function not usable */ - BFA_AUTH_AUTH_XACT_STARTED = 4, /* auth xact started */ - BFA_AUTH_AUTH_FAILED = 5, /* auth failed */ - BFA_AUTH_INCORRECT_PLD = 6, /* incorrect payload */ - BFA_AUTH_INCORRECT_PROTO_MSG = 7, /* incorrect proto msg */ - BFA_AUTH_RESTART_AUTH_PROTO = 8, /* restart auth protocol */ - BFA_AUTH_AUTH_CONCAT_NOT_SUPP = 9, /* auth concat not supported */ - BFA_AUTH_PROTO_VER_NOT_SUPP = 10,/* proto version not supported */ -}; - struct auth_proto_stats_s { u32 auth_rjts; u32 auth_negs; diff --git a/trunk/drivers/scsi/bfa/include/defs/bfa_defs_cee.h b/trunk/drivers/scsi/bfa/include/defs/bfa_defs_cee.h index b0ac9ac15c5d..520a22f52dd1 100644 --- a/trunk/drivers/scsi/bfa/include/defs/bfa_defs_cee.h +++ b/trunk/drivers/scsi/bfa/include/defs/bfa_defs_cee.h @@ -28,6 +28,10 @@ #define BFA_CEE_LLDP_MAX_STRING_LEN (128) + +/* FIXME: this is coming from the protocol spec. Can the host & apps share the + protocol .h files ? + */ #define BFA_CEE_LLDP_SYS_CAP_OTHER 0x0001 #define BFA_CEE_LLDP_SYS_CAP_REPEATER 0x0002 #define BFA_CEE_LLDP_SYS_CAP_MAC_BRIDGE 0x0004 @@ -90,10 +94,9 @@ struct bfa_cee_dcbx_cfg_s { /* CEE status */ /* Making this to tri-state for the benefit of port list command */ enum bfa_cee_status_e { - CEE_UP = 0, - CEE_PHY_UP = 1, - CEE_LOOPBACK = 2, - CEE_PHY_DOWN = 3, + CEE_PHY_DOWN = 0, + CEE_PHY_UP = 1, + CEE_UP = 2, }; /* CEE Query */ @@ -104,8 +107,7 @@ struct bfa_cee_attr_s { struct bfa_cee_dcbx_cfg_s dcbx_remote; mac_t src_mac; u8 link_speed; - u8 nw_priority; - u8 filler[2]; + u8 filler[3]; }; diff --git a/trunk/drivers/scsi/bfa/include/defs/bfa_defs_driver.h b/trunk/drivers/scsi/bfa/include/defs/bfa_defs_driver.h index 50382dd2ab41..57049805762b 100644 --- a/trunk/drivers/scsi/bfa/include/defs/bfa_defs_driver.h +++ b/trunk/drivers/scsi/bfa/include/defs/bfa_defs_driver.h @@ -21,7 +21,6 @@ /** * Driver statistics */ -struct bfa_driver_stats_s { u16 tm_io_abort; u16 tm_io_abort_comp; u16 tm_lun_reset; @@ -35,7 +34,7 @@ struct bfa_driver_stats_s { u64 output_req; u64 input_words; u64 output_words; -}; +} bfa_driver_stats_t; #endif /* __BFA_DEFS_DRIVER_H__ */ diff --git a/trunk/drivers/scsi/bfa/include/defs/bfa_defs_ethport.h b/trunk/drivers/scsi/bfa/include/defs/bfa_defs_ethport.h index b4fa0923aa89..79f9b3e146f7 100644 --- a/trunk/drivers/scsi/bfa/include/defs/bfa_defs_ethport.h +++ b/trunk/drivers/scsi/bfa/include/defs/bfa_defs_ethport.h @@ -19,7 +19,6 @@ #define __BFA_DEFS_ETHPORT_H__ #include -#include #include #include #include diff --git a/trunk/drivers/scsi/bfa/include/defs/bfa_defs_fcport.h b/trunk/drivers/scsi/bfa/include/defs/bfa_defs_fcport.h deleted file mode 100644 index a07ef4a3cd78..000000000000 --- a/trunk/drivers/scsi/bfa/include/defs/bfa_defs_fcport.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. - * All rights reserved - * www.brocade.com - * - * bfa_defs_fcport.h - * - * Linux driver for Brocade Fibre Channel Host Bus Adapter. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License (GPL) Version 2 as - * published by the Free Software Foundation - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - */ -#ifndef __BFA_DEFS_FCPORT_H__ -#define __BFA_DEFS_FCPORT_H__ - -#include -#include - -#pragma pack(1) - -/** - * FCoE statistics - */ -struct bfa_fcoe_stats_s { - u64 secs_reset; /* Seconds since stats reset */ - u64 cee_linkups; /* CEE link up */ - u64 cee_linkdns; /* CEE link down */ - u64 fip_linkups; /* FIP link up */ - u64 fip_linkdns; /* FIP link down */ - u64 fip_fails; /* FIP failures */ - u64 mac_invalids; /* Invalid mac assignments */ - u64 vlan_req; /* Vlan requests */ - u64 vlan_notify; /* Vlan notifications */ - u64 vlan_err; /* Vlan notification errors */ - u64 vlan_timeouts; /* Vlan request timeouts */ - u64 vlan_invalids; /* Vlan invalids */ - u64 disc_req; /* Discovery requests */ - u64 disc_rsp; /* Discovery responses */ - u64 disc_err; /* Discovery error frames */ - u64 disc_unsol; /* Discovery unsolicited */ - u64 disc_timeouts; /* Discovery timeouts */ - u64 disc_fcf_unavail; /* Discovery FCF not avail */ - u64 linksvc_unsupp; /* FIP link service req unsupp. */ - u64 linksvc_err; /* FIP link service req errors */ - u64 logo_req; /* FIP logo */ - u64 clrvlink_req; /* Clear virtual link requests */ - u64 op_unsupp; /* FIP operation unsupp. */ - u64 untagged; /* FIP untagged frames */ - u64 txf_ucast; /* Tx FCoE unicast frames */ - u64 txf_ucast_vlan; /* Tx FCoE unicast vlan frames */ - u64 txf_ucast_octets; /* Tx FCoE unicast octets */ - u64 txf_mcast; /* Tx FCoE mutlicast frames */ - u64 txf_mcast_vlan; /* Tx FCoE mutlicast vlan frames */ - u64 txf_mcast_octets; /* Tx FCoE multicast octets */ - u64 txf_bcast; /* Tx FCoE broadcast frames */ - u64 txf_bcast_vlan; /* Tx FCoE broadcast vlan frames */ - u64 txf_bcast_octets; /* Tx FCoE broadcast octets */ - u64 txf_timeout; /* Tx timeouts */ - u64 txf_parity_errors; /* Transmit parity err */ - u64 txf_fid_parity_errors; /* Transmit FID parity err */ - u64 tx_pause; /* Tx pause frames */ - u64 tx_zero_pause; /* Tx zero pause frames */ - u64 tx_first_pause; /* Tx first pause frames */ - u64 rx_pause; /* Rx pause frames */ - u64 rx_zero_pause; /* Rx zero pause frames */ - u64 rx_first_pause; /* Rx first pause frames */ - u64 rxf_ucast_octets; /* Rx unicast octets */ - u64 rxf_ucast; /* Rx unicast frames */ - u64 rxf_ucast_vlan; /* Rx unicast vlan frames */ - u64 rxf_mcast_octets; /* Rx multicast octets */ - u64 rxf_mcast; /* Rx multicast frames */ - u64 rxf_mcast_vlan; /* Rx multicast vlan frames */ - u64 rxf_bcast_octets; /* Rx broadcast octests */ - u64 rxf_bcast; /* Rx broadcast frames */ - u64 rxf_bcast_vlan; /* Rx broadcast vlan frames */ -}; - -/** - * QoS or FCoE stats (fcport stats excluding physical FC port stats) - */ -union bfa_fcport_stats_u { - struct bfa_qos_stats_s fcqos; - struct bfa_fcoe_stats_s fcoe; -}; - -#pragma pack() - -#endif /* __BFA_DEFS_FCPORT_H__ */ diff --git a/trunk/drivers/scsi/bfa/include/defs/bfa_defs_im_common.h b/trunk/drivers/scsi/bfa/include/defs/bfa_defs_im_common.h new file mode 100644 index 000000000000..9ccf53bef65a --- /dev/null +++ b/trunk/drivers/scsi/bfa/include/defs/bfa_defs_im_common.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. + * All rights reserved + * www.brocade.com + * + * Linux driver for Brocade Fibre Channel Host Bus Adapter. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License (GPL) Version 2 as + * published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + +#ifndef __BFA_DEFS_IM_COMMON_H__ +#define __BFA_DEFS_IM_COMMON_H__ + +#define BFA_ADAPTER_NAME_LEN 256 +#define BFA_ADAPTER_GUID_LEN 256 +#define RESERVED_VLAN_NAME L"PORT VLAN" +#define PASSTHRU_VLAN_NAME L"PASSTHRU VLAN" + + u64 tx_pkt_cnt; + u64 rx_pkt_cnt; + u32 duration; + u8 status; +} bfa_im_stats_t, *pbfa_im_stats_t; + +#endif /* __BFA_DEFS_IM_COMMON_H__ */ diff --git a/trunk/drivers/scsi/bfa/include/defs/bfa_defs_im_team.h b/trunk/drivers/scsi/bfa/include/defs/bfa_defs_im_team.h new file mode 100644 index 000000000000..a486a7eb81d6 --- /dev/null +++ b/trunk/drivers/scsi/bfa/include/defs/bfa_defs_im_team.h @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. + * All rights reserved + * www.brocade.com + * + * Linux driver for Brocade Fibre Channel Host Bus Adapter. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License (GPL) Version 2 as + * published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + +#ifndef __BFA_DEFS_IM_TEAM_H__ +#define __BFA_DEFS_IM_TEAM_H__ + +#include + +#define BFA_TEAM_MAX_PORTS 8 +#define BFA_TEAM_NAME_LEN 256 +#define BFA_MAX_NUM_TEAMS 16 +#define BFA_TEAM_INVALID_DELAY -1 + + BFA_LACP_RATE_SLOW = 1, + BFA_LACP_RATE_FAST +} bfa_im_lacp_rate_t; + + BFA_TEAM_MODE_FAIL_OVER = 1, + BFA_TEAM_MODE_FAIL_BACK, + BFA_TEAM_MODE_LACP, + BFA_TEAM_MODE_NONE +} bfa_im_team_mode_t; + + BFA_XMIT_POLICY_L2 = 1, + BFA_XMIT_POLICY_L3_L4 +} bfa_im_xmit_policy_t; + + bfa_im_team_mode_t team_mode; + bfa_im_lacp_rate_t lacp_rate; + bfa_im_xmit_policy_t xmit_policy; + int delay; + wchar_t primary[BFA_ADAPTER_NAME_LEN]; + wchar_t preferred_primary[BFA_ADAPTER_NAME_LEN]; + mac_t mac; + u16 num_ports; + u16 num_vlans; + u16 vlan_list[BFA_MAX_VLANS_PER_PORT]; + wchar_t team_guid_list[BFA_TEAM_MAX_PORTS][BFA_ADAPTER_GUID_LEN]; + wchar_t ioc_name_list[BFA_TEAM_MAX_PORTS][BFA_ADAPTER_NAME_LEN]; +} bfa_im_team_attr_t; + + wchar_t team_name[BFA_TEAM_NAME_LEN]; + bfa_im_xmit_policy_t xmit_policy; + int delay; + wchar_t primary[BFA_ADAPTER_NAME_LEN]; + wchar_t preferred_primary[BFA_ADAPTER_NAME_LEN]; +} bfa_im_team_edit_t, *pbfa_im_team_edit_t; + + wchar_t team_name[BFA_TEAM_NAME_LEN]; + bfa_im_team_mode_t team_mode; + mac_t mac; +} bfa_im_team_info_t; + + bfa_im_team_info_t team_info[BFA_MAX_NUM_TEAMS]; + u16 num_teams; +} bfa_im_team_list_t, *pbfa_im_team_list_t; + +#endif /* __BFA_DEFS_IM_TEAM_H__ */ diff --git a/trunk/drivers/scsi/bfa/include/defs/bfa_defs_ioc.h b/trunk/drivers/scsi/bfa/include/defs/bfa_defs_ioc.h index 8d8e6a966537..b1d532da3a9d 100644 --- a/trunk/drivers/scsi/bfa/include/defs/bfa_defs_ioc.h +++ b/trunk/drivers/scsi/bfa/include/defs/bfa_defs_ioc.h @@ -126,7 +126,6 @@ struct bfa_ioc_attr_s { struct bfa_ioc_driver_attr_s driver_attr; /* driver attr */ struct bfa_ioc_pci_attr_s pci_attr; u8 port_id; /* port number */ - u8 rsvd[7]; /*!< 64bit align */ }; /** @@ -144,8 +143,8 @@ enum bfa_ioc_aen_event { * BFA IOC level event data, now just a place holder */ struct bfa_ioc_aen_data_s { + enum bfa_ioc_type_e ioc_type; wwn_t pwwn; - s16 ioc_type; mac_t mac; }; diff --git a/trunk/drivers/scsi/bfa/include/defs/bfa_defs_iocfc.h b/trunk/drivers/scsi/bfa/include/defs/bfa_defs_iocfc.h index c290fb13d2d1..d76bcbd9820f 100644 --- a/trunk/drivers/scsi/bfa/include/defs/bfa_defs_iocfc.h +++ b/trunk/drivers/scsi/bfa/include/defs/bfa_defs_iocfc.h @@ -26,8 +26,6 @@ #define BFA_IOCFC_INTR_DELAY 1125 #define BFA_IOCFC_INTR_LATENCY 225 -#define BFA_IOCFCOE_INTR_DELAY 25 -#define BFA_IOCFCOE_INTR_LATENCY 5 /** * Interrupt coalescing configuration. @@ -52,7 +50,7 @@ struct bfa_iocfc_fwcfg_s { u16 num_fcxp_reqs; /* unassisted FC exchanges */ u16 num_uf_bufs; /* unsolicited recv buffers */ u8 num_cqs; - u8 rsvd[5]; + u8 rsvd; }; struct bfa_iocfc_drvcfg_s { @@ -226,24 +224,18 @@ struct bfa_fw_port_physm_stats_s { struct bfa_fw_fip_stats_s { - u32 vlan_req; /* vlan discovery requests */ - u32 vlan_notify; /* vlan notifications */ - u32 vlan_err; /* vlan response error */ - u32 vlan_timeouts; /* vlan disvoery timeouts */ - u32 vlan_invalids; /* invalid vlan in discovery advert. */ u32 disc_req; /* Discovery solicit requests */ u32 disc_rsp; /* Discovery solicit response */ u32 disc_err; /* Discovery advt. parse errors */ u32 disc_unsol; /* Discovery unsolicited */ u32 disc_timeouts; /* Discovery timeouts */ - u32 disc_fcf_unavail; /* Discovery FCF Not Avail. */ u32 linksvc_unsupp; /* Unsupported link service req */ u32 linksvc_err; /* Parse error in link service req */ u32 logo_req; /* Number of FIP logos received */ u32 clrvlink_req; /* Clear virtual link req */ u32 op_unsupp; /* Unsupported FIP operation */ u32 untagged; /* Untagged frames (ignored) */ - u32 invalid_version; /*!< Invalid FIP version */ + u32 rsvd; }; diff --git a/trunk/drivers/scsi/bfa/include/defs/bfa_defs_lport.h b/trunk/drivers/scsi/bfa/include/defs/bfa_defs_lport.h index 0952a139c47c..7359f82aacfc 100644 --- a/trunk/drivers/scsi/bfa/include/defs/bfa_defs_lport.h +++ b/trunk/drivers/scsi/bfa/include/defs/bfa_defs_lport.h @@ -59,8 +59,8 @@ enum bfa_lport_aen_event { */ struct bfa_lport_aen_data_s { u16 vf_id; /* vf_id of this logical port */ - s16 roles; /* Logical port mode,IM/TM/IP etc */ - u32 rsvd; + u16 rsvd; + enum bfa_port_role roles; /* Logical port mode,IM/TM/IP etc */ wwn_t ppwwn; /* WWN of its physical port */ wwn_t lpwwn; /* WWN of this logical port */ }; diff --git a/trunk/drivers/scsi/bfa/include/defs/bfa_defs_mfg.h b/trunk/drivers/scsi/bfa/include/defs/bfa_defs_mfg.h index c5bd9c36ad4d..13fd4ab6aae2 100644 --- a/trunk/drivers/scsi/bfa/include/defs/bfa_defs_mfg.h +++ b/trunk/drivers/scsi/bfa/include/defs/bfa_defs_mfg.h @@ -22,47 +22,7 @@ /** * Manufacturing block version */ -#define BFA_MFG_VERSION 2 - -/** - * Manufacturing block encrypted version - */ -#define BFA_MFG_ENC_VER 2 - -/** - * Manufacturing block version 1 length - */ -#define BFA_MFG_VER1_LEN 128 - -/** - * Manufacturing block header length - */ -#define BFA_MFG_HDR_LEN 4 - -/** - * Checksum size - */ -#define BFA_MFG_CHKSUM_SIZE 16 - -/** - * Manufacturing block encrypted version - */ -#define BFA_MFG_ENC_VER 2 - -/** - * Manufacturing block version 1 length - */ -#define BFA_MFG_VER1_LEN 128 - -/** - * Manufacturing block header length - */ -#define BFA_MFG_HDR_LEN 4 - -/** - * Checksum size - */ -#define BFA_MFG_CHKSUM_SIZE 16 +#define BFA_MFG_VERSION 1 /** * Manufacturing block format @@ -70,74 +30,29 @@ #define BFA_MFG_SERIALNUM_SIZE 11 #define BFA_MFG_PARTNUM_SIZE 14 #define BFA_MFG_SUPPLIER_ID_SIZE 10 -#define BFA_MFG_SUPPLIER_PARTNUM_SIZE 20 -#define BFA_MFG_SUPPLIER_SERIALNUM_SIZE 20 -#define BFA_MFG_SUPPLIER_REVISION_SIZE 4 +#define BFA_MFG_SUPPLIER_PARTNUM_SIZE 20 +#define BFA_MFG_SUPPLIER_SERIALNUM_SIZE 20 +#define BFA_MFG_SUPPLIER_REVISION_SIZE 4 #define STRSZ(_n) (((_n) + 4) & ~3) -/** - * Manufacturing card type - */ -enum { - BFA_MFG_TYPE_CB_MAX = 825, /* Crossbow card type max */ - BFA_MFG_TYPE_FC8P2 = 825, /* 8G 2port FC card */ - BFA_MFG_TYPE_FC8P1 = 815, /* 8G 1port FC card */ - BFA_MFG_TYPE_FC4P2 = 425, /* 4G 2port FC card */ - BFA_MFG_TYPE_FC4P1 = 415, /* 4G 1port FC card */ - BFA_MFG_TYPE_CNA10P2 = 1020, /* 10G 2port CNA card */ - BFA_MFG_TYPE_CNA10P1 = 1010, /* 10G 1port CNA card */ -}; - -#pragma pack(1) - -/** - * Card type to port number conversion - */ -#define bfa_mfg_type2port_num(card_type) (((card_type) / 10) % 10) - - -/** - * All numerical fields are in big-endian format. - */ -struct bfa_mfg_block_s { -}; - /** * VPD data length */ -#define BFA_MFG_VPD_LEN 512 - -#define BFA_MFG_VPD_PCI_HDR_OFF 137 -#define BFA_MFG_VPD_PCI_VER_MASK 0x07 /* version mask 3 bits */ -#define BFA_MFG_VPD_PCI_VDR_MASK 0xf8 /* vendor mask 5 bits */ - -/** - * VPD vendor tag - */ -enum { - BFA_MFG_VPD_UNKNOWN = 0, /* vendor unknown */ - BFA_MFG_VPD_IBM = 1, /* vendor IBM */ - BFA_MFG_VPD_HP = 2, /* vendor HP */ - BFA_MFG_VPD_DELL = 3, /* vendor DELL */ - BFA_MFG_VPD_PCI_IBM = 0x08, /* PCI VPD IBM */ - BFA_MFG_VPD_PCI_HP = 0x10, /* PCI VPD HP */ - BFA_MFG_VPD_PCI_DELL = 0x20, /* PCI VPD DELL */ - BFA_MFG_VPD_PCI_BRCD = 0xf8, /* PCI VPD Brocade */ -}; +#define BFA_MFG_VPD_LEN 256 /** * All numerical fields are in big-endian format. */ struct bfa_mfg_vpd_s { - u8 version; /* vpd data version */ - u8 vpd_sig[3]; /* characters 'V', 'P', 'D' */ - u8 chksum; /* u8 checksum */ - u8 vendor; /* vendor */ - u8 len; /* vpd data length excluding header */ - u8 rsv; - u8 data[BFA_MFG_VPD_LEN]; /* vpd data */ + u8 version; /* vpd data version */ + u8 vpd_sig[3]; /* characters 'V', 'P', 'D' */ + u8 chksum; /* u8 checksum */ + u8 vendor; /* vendor */ + u8 len; /* vpd data length excluding header */ + u8 rsv; + u8 data[BFA_MFG_VPD_LEN]; /* vpd data */ }; -#pragma pack() +#pragma pack(1) #endif /* __BFA_DEFS_MFG_H__ */ diff --git a/trunk/drivers/scsi/bfa/include/defs/bfa_defs_port.h b/trunk/drivers/scsi/bfa/include/defs/bfa_defs_port.h index 501bc9739d9d..de0696c81bc4 100644 --- a/trunk/drivers/scsi/bfa/include/defs/bfa_defs_port.h +++ b/trunk/drivers/scsi/bfa/include/defs/bfa_defs_port.h @@ -185,8 +185,6 @@ struct bfa_port_attr_s { wwn_t fabric_name; /* attached switch's nwwn */ u8 fabric_ip_addr[BFA_FCS_FABRIC_IPADDR_SZ]; /* attached * fabric's ip addr */ - struct mac_s fpma_mac; /* Lport's FPMA Mac address */ - u16 authfail; /* auth failed state */ }; /** @@ -234,15 +232,14 @@ enum bfa_port_aen_sfp_pom { }; struct bfa_port_aen_data_s { - wwn_t pwwn; /* WWN of the physical port */ - wwn_t fwwn; /* WWN of the fabric port */ - s32 phy_port_num; /*! For SFP related events */ - s16 ioc_type; - s16 level; /* Only transitions will - * be informed */ - struct mac_s mac; /* MAC address of the ethernet port, - * applicable to CNA port only */ - s16 rsvd; + enum bfa_ioc_type_e ioc_type; + wwn_t pwwn; /* WWN of the physical port */ + wwn_t fwwn; /* WWN of the fabric port */ + mac_t mac; /* MAC addres of the ethernet port, + * applicable to CNA port only */ + int phy_port_num; /*! For SFP related events */ + enum bfa_port_aen_sfp_pom level; /* Only transitions will + * be informed */ }; #endif /* __BFA_DEFS_PORT_H__ */ diff --git a/trunk/drivers/scsi/bfa/include/defs/bfa_defs_pport.h b/trunk/drivers/scsi/bfa/include/defs/bfa_defs_pport.h index 26e5cc78095d..bf320412ee24 100644 --- a/trunk/drivers/scsi/bfa/include/defs/bfa_defs_pport.h +++ b/trunk/drivers/scsi/bfa/include/defs/bfa_defs_pport.h @@ -232,7 +232,7 @@ struct bfa_pport_attr_s { u32 pid; /* port ID */ enum bfa_pport_type port_type; /* current topology */ u32 loopback; /* external loopback */ - u32 authfail; /* auth fail state */ + u32 rsvd1; u32 rsvd2; /* padding for 64 bit */ }; @@ -240,79 +240,73 @@ struct bfa_pport_attr_s { * FC Port statistics. */ struct bfa_pport_fc_stats_s { - u64 secs_reset; /* Seconds since stats is reset */ - u64 tx_frames; /* Tx frames */ - u64 tx_words; /* Tx words */ - u64 tx_lip; /* TX LIP */ - u64 tx_nos; /* Tx NOS */ - u64 tx_ols; /* Tx OLS */ - u64 tx_lr; /* Tx LR */ - u64 tx_lrr; /* Tx LRR */ - u64 rx_frames; /* Rx frames */ - u64 rx_words; /* Rx words */ - u64 lip_count; /* Rx LIP */ - u64 nos_count; /* Rx NOS */ - u64 ols_count; /* Rx OLS */ - u64 lr_count; /* Rx LR */ - u64 lrr_count; /* Rx LRR */ - u64 invalid_crcs; /* Rx CRC err frames */ - u64 invalid_crc_gd_eof; /* Rx CRC err good EOF frames */ - u64 undersized_frm; /* Rx undersized frames */ - u64 oversized_frm; /* Rx oversized frames */ - u64 bad_eof_frm; /* Rx frames with bad EOF */ - u64 error_frames; /* Errored frames */ - u64 dropped_frames; /* Dropped frames */ - u64 link_failures; /* Link Failure (LF) count */ - u64 loss_of_syncs; /* Loss of sync count */ - u64 loss_of_signals;/* Loss of signal count */ - u64 primseq_errs; /* Primitive sequence protocol err. */ - u64 bad_os_count; /* Invalid ordered sets */ - u64 err_enc_out; /* Encoding err nonframe_8b10b */ - u64 err_enc; /* Encoding err frame_8b10b */ + u64 secs_reset; /* seconds since stats is reset */ + u64 tx_frames; /* transmitted frames */ + u64 tx_words; /* transmitted words */ + u64 rx_frames; /* received frames */ + u64 rx_words; /* received words */ + u64 lip_count; /* LIPs seen */ + u64 nos_count; /* NOS count */ + u64 error_frames; /* errored frames (sent?) */ + u64 dropped_frames; /* dropped frames */ + u64 link_failures; /* link failure count */ + u64 loss_of_syncs; /* loss of sync count */ + u64 loss_of_signals;/* loss of signal count */ + u64 primseq_errs; /* primitive sequence protocol */ + u64 bad_os_count; /* invalid ordered set */ + u64 err_enc_out; /* Encoding error outside frame */ + u64 invalid_crcs; /* frames received with invalid CRC*/ + u64 undersized_frm; /* undersized frames */ + u64 oversized_frm; /* oversized frames */ + u64 bad_eof_frm; /* frames with bad EOF */ + struct bfa_qos_stats_s qos_stats; /* QoS statistics */ }; /** * Eth Port statistics. */ struct bfa_pport_eth_stats_s { - u64 secs_reset; /* Seconds since stats is reset */ - u64 frame_64; /* Frames 64 bytes */ - u64 frame_65_127; /* Frames 65-127 bytes */ - u64 frame_128_255; /* Frames 128-255 bytes */ - u64 frame_256_511; /* Frames 256-511 bytes */ - u64 frame_512_1023; /* Frames 512-1023 bytes */ - u64 frame_1024_1518; /* Frames 1024-1518 bytes */ - u64 frame_1519_1522; /* Frames 1519-1522 bytes */ - u64 tx_bytes; /* Tx bytes */ - u64 tx_packets; /* Tx packets */ - u64 tx_mcast_packets; /* Tx multicast packets */ - u64 tx_bcast_packets; /* Tx broadcast packets */ - u64 tx_control_frame; /* Tx control frame */ - u64 tx_drop; /* Tx drops */ - u64 tx_jabber; /* Tx jabber */ - u64 tx_fcs_error; /* Tx FCS error */ - u64 tx_fragments; /* Tx fragments */ - u64 rx_bytes; /* Rx bytes */ - u64 rx_packets; /* Rx packets */ - u64 rx_mcast_packets; /* Rx multicast packets */ - u64 rx_bcast_packets; /* Rx broadcast packets */ - u64 rx_control_frames; /* Rx control frames */ - u64 rx_unknown_opcode; /* Rx unknown opcode */ - u64 rx_drop; /* Rx drops */ - u64 rx_jabber; /* Rx jabber */ - u64 rx_fcs_error; /* Rx FCS errors */ - u64 rx_alignment_error; /* Rx alignment errors */ - u64 rx_frame_length_error; /* Rx frame len errors */ - u64 rx_code_error; /* Rx code errors */ - u64 rx_fragments; /* Rx fragments */ - u64 rx_pause; /* Rx pause */ - u64 rx_zero_pause; /* Rx zero pause */ - u64 tx_pause; /* Tx pause */ - u64 tx_zero_pause; /* Tx zero pause */ - u64 rx_fcoe_pause; /* Rx fcoe pause */ - u64 rx_fcoe_zero_pause; /* Rx FCoE zero pause */ - u64 tx_fcoe_pause; /* Tx FCoE pause */ - u64 tx_fcoe_zero_pause; /* Tx FCoE zero pause */ + u64 secs_reset; /* seconds since stats is reset */ + u64 frame_64; /* both rx and tx counter */ + u64 frame_65_127; /* both rx and tx counter */ + u64 frame_128_255; /* both rx and tx counter */ + u64 frame_256_511; /* both rx and tx counter */ + u64 frame_512_1023; /* both rx and tx counter */ + u64 frame_1024_1518; /* both rx and tx counter */ + u64 frame_1519_1522; /* both rx and tx counter */ + + u64 tx_bytes; + u64 tx_packets; + u64 tx_mcast_packets; + u64 tx_bcast_packets; + u64 tx_control_frame; + u64 tx_drop; + u64 tx_jabber; + u64 tx_fcs_error; + u64 tx_fragments; + + u64 rx_bytes; + u64 rx_packets; + u64 rx_mcast_packets; + u64 rx_bcast_packets; + u64 rx_control_frames; + u64 rx_unknown_opcode; + u64 rx_drop; + u64 rx_jabber; + u64 rx_fcs_error; + u64 rx_alignment_error; + u64 rx_frame_length_error; + u64 rx_code_error; + u64 rx_fragments; + + u64 rx_pause; /* BPC */ + u64 rx_zero_pause; /* BPC Pause cancellation */ + u64 tx_pause; /* BPC */ + u64 tx_zero_pause; /* BPC Pause cancellation */ + u64 rx_fcoe_pause; /* BPC */ + u64 rx_fcoe_zero_pause; /* BPC Pause cancellation */ + u64 tx_fcoe_pause; /* BPC */ + u64 tx_fcoe_zero_pause; /* BPC Pause cancellation */ }; /** @@ -339,7 +333,8 @@ struct bfa_pport_fcpmap_s { }; /** - * Port RNI */ + * Port RNID info. + */ struct bfa_pport_rnid_s { wwn_t wwn; u32 unittype; @@ -352,23 +347,6 @@ struct bfa_pport_rnid_s { u16 topologydiscoveryflags; }; -struct bfa_fcport_fcf_s { - wwn_t name; /* FCF name */ - wwn_t fabric_name; /* Fabric Name */ - u8 fipenabled; /* FIP enabled or not */ - u8 fipfailed; /* FIP failed or not */ - u8 resv[2]; - u8 pri; /* FCF priority */ - u8 version; /* FIP version used */ - u8 available; /* Available for login */ - u8 fka_disabled; /* FKA is disabled */ - u8 maxsz_verified; /* FCoE max size verified */ - u8 fc_map[3]; /* FC map */ - u16 vlan; /* FCoE vlan tag/priority */ - u32 fka_adv_per; /* FIP ka advert. period */ - struct mac_s mac; /* FCF mac */ -}; - /** * Link state information */ @@ -400,7 +378,6 @@ struct bfa_pport_link_s { struct fc_alpabm_s alpabm; /* alpa bitmap */ } loop_info; } tl; - struct bfa_fcport_fcf_s fcf; /*!< FCF information (for FCoE) */ }; #endif /* __BFA_DEFS_PPORT_H__ */ diff --git a/trunk/drivers/scsi/bfa/include/defs/bfa_defs_status.h b/trunk/drivers/scsi/bfa/include/defs/bfa_defs_status.h index 4374494bd566..cdceaeb9f4b8 100644 --- a/trunk/drivers/scsi/bfa/include/defs/bfa_defs_status.h +++ b/trunk/drivers/scsi/bfa/include/defs/bfa_defs_status.h @@ -180,8 +180,8 @@ enum bfa_status { BFA_STATUS_IM_ADAPT_ALREADY_IN_TEAM = 114, /* Given adapter is part * of another team */ BFA_STATUS_IM_ADAPT_HAS_VLANS = 115, /* Adapter has VLANs configured. - * Delete all VLANs to become - * part of the team */ + * Delete all VLANs before + * creating team */ BFA_STATUS_IM_PVID_MISMATCH = 116, /* Mismatching PVIDs configured * for adapters */ BFA_STATUS_IM_LINK_SPEED_MISMATCH = 117, /* Mismatching link speeds @@ -213,7 +213,7 @@ enum bfa_status { * loaded */ BFA_STATUS_CARD_TYPE_MISMATCH = 131, /* Card type mismatch */ BFA_STATUS_BAD_ASICBLK = 132, /* Bad ASIC block */ - BFA_STATUS_NO_DRIVER = 133, /* Brocade adapter/driver not installed or loaded */ + BFA_STATUS_NO_DRIVER = 133, /* Storage/Ethernet driver not loaded */ BFA_STATUS_INVALID_MAC = 134, /* Invalid mac address */ BFA_STATUS_IM_NO_VLAN = 135, /* No VLANs configured on the adapter */ BFA_STATUS_IM_ETH_LB_FAILED = 136, /* Ethernet loopback test failed */ @@ -228,7 +228,8 @@ enum bfa_status { BFA_STATUS_IM_GET_INETCFG_FAILED = 142, /* Acquiring Network Subsytem * handle Failed. Please try * after some time */ - BFA_STATUS_IM_NOT_BOUND = 143, /* IM driver is not active */ + BFA_STATUS_IM_NOT_BOUND = 143, /* Brocade 10G Ethernet Service is not + * Enabled on this port */ BFA_STATUS_INSUFFICIENT_PERMS = 144, /* User doesn't have sufficient * permissions to execute the BCU * application */ @@ -241,14 +242,6 @@ enum bfa_status { * failed */ BFA_STATUS_IM_UNBIND_FAILED = 149, /* ! < IM Driver unbind operation * failed */ - BFA_STATUS_IM_PORT_IN_TEAM = 150, /* Port is already part of the - * team */ - BFA_STATUS_IM_VLAN_NOT_FOUND = 151, /* VLAN ID doesn't exists */ - BFA_STATUS_IM_TEAM_NOT_FOUND = 152, /* Teaming configuration doesn't - * exists */ - BFA_STATUS_IM_TEAM_CFG_NOT_ALLOWED = 153, /* Given settings are not - * allowed for the current - * Teaming mode */ BFA_STATUS_MAX_VAL /* Unknown error code */ }; #define bfa_status_t enum bfa_status diff --git a/trunk/drivers/scsi/bfa/include/fcb/bfa_fcb_fcpim.h b/trunk/drivers/scsi/bfa/include/fcb/bfa_fcb_fcpim.h index 52585d3dd891..a6c70aee0aa3 100644 --- a/trunk/drivers/scsi/bfa/include/fcb/bfa_fcb_fcpim.h +++ b/trunk/drivers/scsi/bfa/include/fcb/bfa_fcb_fcpim.h @@ -70,6 +70,7 @@ void bfa_fcb_itnim_online(struct bfad_itnim_s *itnim_drv); */ void bfa_fcb_itnim_offline(struct bfad_itnim_s *itnim_drv); +void bfa_fcb_itnim_tov_begin(struct bfad_itnim_s *itnim_drv); void bfa_fcb_itnim_tov(struct bfad_itnim_s *itnim_drv); #endif /* __BFAD_FCB_FCPIM_H__ */ diff --git a/trunk/drivers/scsi/bfa/include/fcs/bfa_fcs.h b/trunk/drivers/scsi/bfa/include/fcs/bfa_fcs.h index f2fd35fdee28..627669c65546 100644 --- a/trunk/drivers/scsi/bfa/include/fcs/bfa_fcs.h +++ b/trunk/drivers/scsi/bfa/include/fcs/bfa_fcs.h @@ -49,7 +49,6 @@ struct bfa_fcs_s { struct bfa_trc_mod_s *trcmod; /* tracing module */ struct bfa_aen_s *aen; /* aen component */ bfa_boolean_t vf_enabled; /* VF mode is enabled */ - bfa_boolean_t fdmi_enabled; /*!< FDMI is enabled */ bfa_boolean_t min_cfg; /* min cfg enabled/disabled */ u16 port_vfid; /* port default VF ID */ struct bfa_fcs_driver_info_s driver_info; @@ -61,12 +60,10 @@ struct bfa_fcs_s { /* * bfa fcs API functions */ -void bfa_fcs_attach(struct bfa_fcs_s *fcs, struct bfa_s *bfa, struct bfad_s *bfad, +void bfa_fcs_init(struct bfa_fcs_s *fcs, struct bfa_s *bfa, struct bfad_s *bfad, bfa_boolean_t min_cfg); -void bfa_fcs_init(struct bfa_fcs_s *fcs); void bfa_fcs_driver_info_init(struct bfa_fcs_s *fcs, struct bfa_fcs_driver_info_s *driver_info); -void bfa_fcs_set_fdmi_param(struct bfa_fcs_s *fcs, bfa_boolean_t fdmi_enable); void bfa_fcs_exit(struct bfa_fcs_s *fcs); void bfa_fcs_trc_init(struct bfa_fcs_s *fcs, struct bfa_trc_mod_s *trcmod); void bfa_fcs_log_init(struct bfa_fcs_s *fcs, struct bfa_log_mod_s *logmod); diff --git a/trunk/drivers/scsi/bfa/include/fcs/bfa_fcs_lport.h b/trunk/drivers/scsi/bfa/include/fcs/bfa_fcs_lport.h index ceaefd3060f4..967ceb0eb074 100644 --- a/trunk/drivers/scsi/bfa/include/fcs/bfa_fcs_lport.h +++ b/trunk/drivers/scsi/bfa/include/fcs/bfa_fcs_lport.h @@ -34,6 +34,14 @@ struct bfa_fcs_s; struct bfa_fcs_fabric_s; /* +* @todo : need to move to a global config file. + * Maximum Vports supported per physical port or vf. + */ +#define BFA_FCS_MAX_VPORTS_SUPP_CB 255 +#define BFA_FCS_MAX_VPORTS_SUPP_CT 191 + +/* +* @todo : need to move to a global config file. * Maximum Rports supported per port (physical/logical). */ #define BFA_FCS_MAX_RPORTS_SUPP 256 /* @todo : tentative value */ diff --git a/trunk/drivers/scsi/bfa/include/log/bfa_log_hal.h b/trunk/drivers/scsi/bfa/include/log/bfa_log_hal.h index 5f8f5e30b9e8..0412aea2ec30 100644 --- a/trunk/drivers/scsi/bfa/include/log/bfa_log_hal.h +++ b/trunk/drivers/scsi/bfa/include/log/bfa_log_hal.h @@ -27,10 +27,4 @@ (((u32) BFA_LOG_HAL_ID << BFA_LOG_MODID_OFFSET) | 3) #define BFA_LOG_HAL_SM_ASSERT \ (((u32) BFA_LOG_HAL_ID << BFA_LOG_MODID_OFFSET) | 4) -#define BFA_LOG_HAL_DRIVER_ERROR \ - (((u32) BFA_LOG_HAL_ID << BFA_LOG_MODID_OFFSET) | 5) -#define BFA_LOG_HAL_DRIVER_CONFIG_ERROR \ - (((u32) BFA_LOG_HAL_ID << BFA_LOG_MODID_OFFSET) | 6) -#define BFA_LOG_HAL_MBOX_ERROR \ - (((u32) BFA_LOG_HAL_ID << BFA_LOG_MODID_OFFSET) | 7) #endif diff --git a/trunk/drivers/scsi/bfa/include/log/bfa_log_linux.h b/trunk/drivers/scsi/bfa/include/log/bfa_log_linux.h index bd451db4c30a..317c0547ee16 100644 --- a/trunk/drivers/scsi/bfa/include/log/bfa_log_linux.h +++ b/trunk/drivers/scsi/bfa/include/log/bfa_log_linux.h @@ -41,20 +41,4 @@ (((u32) BFA_LOG_LINUX_ID << BFA_LOG_MODID_OFFSET) | 10) #define BFA_LOG_LINUX_SCSI_ABORT_COMP \ (((u32) BFA_LOG_LINUX_ID << BFA_LOG_MODID_OFFSET) | 11) -#define BFA_LOG_LINUX_DRIVER_CONFIG_ERROR \ - (((u32) BFA_LOG_LINUX_ID << BFA_LOG_MODID_OFFSET) | 12) -#define BFA_LOG_LINUX_BNA_STATE_MACHINE \ - (((u32) BFA_LOG_LINUX_ID << BFA_LOG_MODID_OFFSET) | 13) -#define BFA_LOG_LINUX_IOC_ERROR \ - (((u32) BFA_LOG_LINUX_ID << BFA_LOG_MODID_OFFSET) | 14) -#define BFA_LOG_LINUX_RESOURCE_ALLOC_ERROR \ - (((u32) BFA_LOG_LINUX_ID << BFA_LOG_MODID_OFFSET) | 15) -#define BFA_LOG_LINUX_RING_BUFFER_ERROR \ - (((u32) BFA_LOG_LINUX_ID << BFA_LOG_MODID_OFFSET) | 16) -#define BFA_LOG_LINUX_DRIVER_ERROR \ - (((u32) BFA_LOG_LINUX_ID << BFA_LOG_MODID_OFFSET) | 17) -#define BFA_LOG_LINUX_DRIVER_DIAG \ - (((u32) BFA_LOG_LINUX_ID << BFA_LOG_MODID_OFFSET) | 18) -#define BFA_LOG_LINUX_DRIVER_AEN \ - (((u32) BFA_LOG_LINUX_ID << BFA_LOG_MODID_OFFSET) | 19) #endif diff --git a/trunk/drivers/scsi/bfa/include/protocol/fc.h b/trunk/drivers/scsi/bfa/include/protocol/fc.h index 8d1038035a76..14969eecf6a9 100644 --- a/trunk/drivers/scsi/bfa/include/protocol/fc.h +++ b/trunk/drivers/scsi/bfa/include/protocol/fc.h @@ -50,11 +50,6 @@ struct fchs_s { u32 ro; /* relative offset */ }; - -#define FC_SOF_LEN 4 -#define FC_EOF_LEN 4 -#define FC_CRC_LEN 4 - /* * Fibre Channel BB_E Header Structure */ diff --git a/trunk/drivers/scsi/bfa/include/protocol/pcifw.h b/trunk/drivers/scsi/bfa/include/protocol/pcifw.h new file mode 100644 index 000000000000..6830dc3ee58a --- /dev/null +++ b/trunk/drivers/scsi/bfa/include/protocol/pcifw.h @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. + * All rights reserved + * www.brocade.com + * + * Linux driver for Brocade Fibre Channel Host Bus Adapter. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License (GPL) Version 2 as + * published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + +/** + * pcifw.h PCI FW related headers + */ + +#ifndef __PCIFW_H__ +#define __PCIFW_H__ + +#pragma pack(1) + +struct pnp_hdr_s{ + u32 signature; /* "$PnP" */ + u8 rev; /* Struct revision */ + u8 len; /* Header structure len in multiples + * of 16 bytes */ + u16 off; /* Offset to next header 00 if none */ + u8 rsvd; /* Reserved byte */ + u8 cksum; /* 8-bit checksum for this header */ + u32 pnp_dev_id; /* PnP Device Id */ + u16 mfstr; /* Pointer to manufacturer string */ + u16 prstr; /* Pointer to product string */ + u8 devtype[3]; /* Device Type Code */ + u8 devind; /* Device Indicator */ + u16 bcventr; /* Bootstrap entry vector */ + u16 rsvd2; /* Reserved */ + u16 sriv; /* Static resource information vector */ +}; + +struct pci_3_0_ds_s{ + u32 sig; /* Signature "PCIR" */ + u16 vendid; /* Vendor ID */ + u16 devid; /* Device ID */ + u16 devlistoff; /* Device List Offset */ + u16 len; /* PCI Data Structure Length */ + u8 rev; /* PCI Data Structure Revision */ + u8 clcode[3]; /* Class Code */ + u16 imglen; /* Code image length in multiples of + * 512 bytes */ + u16 coderev; /* Revision level of code/data */ + u8 codetype; /* Code type 0x00 - BIOS */ + u8 indr; /* Last image indicator */ + u16 mrtimglen; /* Max Run Time Image Length */ + u16 cuoff; /* Config Utility Code Header Offset */ + u16 dmtfclp; /* DMTF CLP entry point offset */ +}; + +struct pci_optrom_hdr_s{ + u16 sig; /* Signature 0x55AA */ + u8 len; /* Option ROM length in units of 512 bytes */ + u8 inivec[3]; /* Initialization vector */ + u8 rsvd[16]; /* Reserved field */ + u16 verptr; /* Pointer to version string - private */ + u16 pcids; /* Pointer to PCI data structure */ + u16 pnphdr; /* Pointer to PnP expansion header */ +}; + +#pragma pack() + +#endif diff --git a/trunk/drivers/scsi/bfa/loop.c b/trunk/drivers/scsi/bfa/loop.c index f6342efb6a90..f7c7f4f3c640 100644 --- a/trunk/drivers/scsi/bfa/loop.c +++ b/trunk/drivers/scsi/bfa/loop.c @@ -162,7 +162,7 @@ bfa_fcs_port_loop_send_plogi(struct bfa_fcs_port_s *port, u8 alpa) len = fc_plogi_build(&fchs, bfa_fcxp_get_reqbuf(fcxp), alpa, bfa_fcs_port_get_fcid(port), 0, port->port_cfg.pwwn, port->port_cfg.nwwn, - bfa_fcport_get_maxfrsize(port->fcs->bfa)); + bfa_pport_get_maxfrsize(port->fcs->bfa)); bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE, FC_CLASS_3, len, &fchs, diff --git a/trunk/drivers/scsi/bfa/lport_api.c b/trunk/drivers/scsi/bfa/lport_api.c index d3907d184e2b..1e06792cd4c2 100644 --- a/trunk/drivers/scsi/bfa/lport_api.c +++ b/trunk/drivers/scsi/bfa/lport_api.c @@ -156,7 +156,7 @@ bfa_fcs_port_get_rport_max_speed(struct bfa_fcs_port_s *port) /* * Get Physical port's current speed */ - bfa_fcport_get_attr(port->fcs->bfa, &pport_attr); + bfa_pport_get_attr(port->fcs->bfa, &pport_attr); pport_speed = pport_attr.speed; bfa_trc(fcs, pport_speed); @@ -235,8 +235,7 @@ bfa_fcs_port_get_info(struct bfa_fcs_port_s *port, port_info->port_wwn = bfa_fcs_port_get_pwwn(port); port_info->node_wwn = bfa_fcs_port_get_nwwn(port); - port_info->max_vports_supp = - bfa_lps_get_max_vport(port->fcs->bfa); + port_info->max_vports_supp = bfa_fcs_vport_get_max(port->fcs); port_info->num_vports_inuse = bfa_fcs_fabric_vport_count(port->fabric); port_info->max_rports_supp = BFA_FCS_MAX_RPORTS_SUPP; diff --git a/trunk/drivers/scsi/bfa/ms.c b/trunk/drivers/scsi/bfa/ms.c index 5e8c8dee6c97..c96b3ca007ae 100644 --- a/trunk/drivers/scsi/bfa/ms.c +++ b/trunk/drivers/scsi/bfa/ms.c @@ -118,7 +118,7 @@ bfa_fcs_port_ms_sm_offline(struct bfa_fcs_port_ms_s *ms, break; default: - bfa_sm_fault(ms->port->fcs, event); + bfa_assert(0); } } @@ -141,7 +141,7 @@ bfa_fcs_port_ms_sm_plogi_sending(struct bfa_fcs_port_ms_s *ms, break; default: - bfa_sm_fault(ms->port->fcs, event); + bfa_assert(0); } } @@ -190,7 +190,7 @@ bfa_fcs_port_ms_sm_plogi(struct bfa_fcs_port_ms_s *ms, enum port_ms_event event) break; default: - bfa_sm_fault(ms->port->fcs, event); + bfa_assert(0); } } @@ -216,7 +216,7 @@ bfa_fcs_port_ms_sm_plogi_retry(struct bfa_fcs_port_ms_s *ms, break; default: - bfa_sm_fault(ms->port->fcs, event); + bfa_assert(0); } } @@ -230,6 +230,10 @@ bfa_fcs_port_ms_sm_online(struct bfa_fcs_port_ms_s *ms, switch (event) { case MSSM_EVENT_PORT_OFFLINE: bfa_sm_set_state(ms, bfa_fcs_port_ms_sm_offline); + /* + * now invoke MS related sub-modules + */ + bfa_fcs_port_fdmi_offline(ms); break; case MSSM_EVENT_PORT_FABRIC_RSCN: @@ -239,7 +243,7 @@ bfa_fcs_port_ms_sm_online(struct bfa_fcs_port_ms_s *ms, break; default: - bfa_sm_fault(ms->port->fcs, event); + bfa_assert(0); } } @@ -262,7 +266,7 @@ bfa_fcs_port_ms_sm_gmal_sending(struct bfa_fcs_port_ms_s *ms, break; default: - bfa_sm_fault(ms->port->fcs, event); + bfa_assert(0); } } @@ -300,7 +304,7 @@ bfa_fcs_port_ms_sm_gmal(struct bfa_fcs_port_ms_s *ms, enum port_ms_event event) break; default: - bfa_sm_fault(ms->port->fcs, event); + bfa_assert(0); } } @@ -326,7 +330,7 @@ bfa_fcs_port_ms_sm_gmal_retry(struct bfa_fcs_port_ms_s *ms, break; default: - bfa_sm_fault(ms->port->fcs, event); + bfa_assert(0); } } @@ -462,7 +466,7 @@ bfa_fcs_port_ms_sm_gfn_sending(struct bfa_fcs_port_ms_s *ms, break; default: - bfa_sm_fault(ms->port->fcs, event); + bfa_assert(0); } } @@ -498,7 +502,7 @@ bfa_fcs_port_ms_sm_gfn(struct bfa_fcs_port_ms_s *ms, enum port_ms_event event) break; default: - bfa_sm_fault(ms->port->fcs, event); + bfa_assert(0); } } @@ -524,7 +528,7 @@ bfa_fcs_port_ms_sm_gfn_retry(struct bfa_fcs_port_ms_s *ms, break; default: - bfa_sm_fault(ms->port->fcs, event); + bfa_assert(0); } } @@ -633,7 +637,7 @@ bfa_fcs_port_ms_send_plogi(void *ms_cbarg, struct bfa_fcxp_s *fcxp_alloced) bfa_os_hton3b(FC_MGMT_SERVER), bfa_fcs_port_get_fcid(port), 0, port->port_cfg.pwwn, port->port_cfg.nwwn, - bfa_fcport_get_maxfrsize(port->fcs->bfa)); + bfa_pport_get_maxfrsize(port->fcs->bfa)); bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE, FC_CLASS_3, len, &fchs, bfa_fcs_port_ms_plogi_response, @@ -731,7 +735,6 @@ bfa_fcs_port_ms_offline(struct bfa_fcs_port_s *port) ms->port = port; bfa_sm_send_event(ms, MSSM_EVENT_PORT_OFFLINE); - bfa_fcs_port_fdmi_offline(ms); } void diff --git a/trunk/drivers/scsi/bfa/ns.c b/trunk/drivers/scsi/bfa/ns.c index d20dd7e15742..2f8b880060bb 100644 --- a/trunk/drivers/scsi/bfa/ns.c +++ b/trunk/drivers/scsi/bfa/ns.c @@ -164,7 +164,7 @@ bfa_fcs_port_ns_sm_offline(struct bfa_fcs_port_ns_s *ns, break; default: - bfa_sm_fault(ns->port->fcs, event); + bfa_assert(0); } } @@ -187,7 +187,7 @@ bfa_fcs_port_ns_sm_plogi_sending(struct bfa_fcs_port_ns_s *ns, break; default: - bfa_sm_fault(ns->port->fcs, event); + bfa_assert(0); } } @@ -221,7 +221,7 @@ bfa_fcs_port_ns_sm_plogi(struct bfa_fcs_port_ns_s *ns, break; default: - bfa_sm_fault(ns->port->fcs, event); + bfa_assert(0); } } @@ -247,7 +247,7 @@ bfa_fcs_port_ns_sm_plogi_retry(struct bfa_fcs_port_ns_s *ns, break; default: - bfa_sm_fault(ns->port->fcs, event); + bfa_assert(0); } } @@ -270,7 +270,7 @@ bfa_fcs_port_ns_sm_sending_rspn_id(struct bfa_fcs_port_ns_s *ns, break; default: - bfa_sm_fault(ns->port->fcs, event); + bfa_assert(0); } } @@ -304,7 +304,7 @@ bfa_fcs_port_ns_sm_rspn_id(struct bfa_fcs_port_ns_s *ns, break; default: - bfa_sm_fault(ns->port->fcs, event); + bfa_assert(0); } } @@ -330,7 +330,7 @@ bfa_fcs_port_ns_sm_rspn_id_retry(struct bfa_fcs_port_ns_s *ns, break; default: - bfa_sm_fault(ns->port->fcs, event); + bfa_assert(0); } } @@ -353,7 +353,7 @@ bfa_fcs_port_ns_sm_sending_rft_id(struct bfa_fcs_port_ns_s *ns, break; default: - bfa_sm_fault(ns->port->fcs, event); + bfa_assert(0); } } @@ -390,7 +390,7 @@ bfa_fcs_port_ns_sm_rft_id(struct bfa_fcs_port_ns_s *ns, break; default: - bfa_sm_fault(ns->port->fcs, event); + bfa_assert(0); } } @@ -413,7 +413,7 @@ bfa_fcs_port_ns_sm_rft_id_retry(struct bfa_fcs_port_ns_s *ns, break; default: - bfa_sm_fault(ns->port->fcs, event); + bfa_assert(0); } } @@ -436,7 +436,7 @@ bfa_fcs_port_ns_sm_sending_rff_id(struct bfa_fcs_port_ns_s *ns, break; default: - bfa_sm_fault(ns->port->fcs, event); + bfa_assert(0); } } @@ -494,7 +494,7 @@ bfa_fcs_port_ns_sm_rff_id(struct bfa_fcs_port_ns_s *ns, break; default: - bfa_sm_fault(ns->port->fcs, event); + bfa_assert(0); } } @@ -517,7 +517,7 @@ bfa_fcs_port_ns_sm_rff_id_retry(struct bfa_fcs_port_ns_s *ns, break; default: - bfa_sm_fault(ns->port->fcs, event); + bfa_assert(0); } } static void @@ -539,7 +539,7 @@ bfa_fcs_port_ns_sm_sending_gid_ft(struct bfa_fcs_port_ns_s *ns, break; default: - bfa_sm_fault(ns->port->fcs, event); + bfa_assert(0); } } @@ -575,7 +575,7 @@ bfa_fcs_port_ns_sm_gid_ft(struct bfa_fcs_port_ns_s *ns, break; default: - bfa_sm_fault(ns->port->fcs, event); + bfa_assert(0); } } @@ -598,7 +598,7 @@ bfa_fcs_port_ns_sm_gid_ft_retry(struct bfa_fcs_port_ns_s *ns, break; default: - bfa_sm_fault(ns->port->fcs, event); + bfa_assert(0); } } @@ -626,7 +626,7 @@ bfa_fcs_port_ns_sm_online(struct bfa_fcs_port_ns_s *ns, break; default: - bfa_sm_fault(ns->port->fcs, event); + bfa_assert(0); } } @@ -660,7 +660,7 @@ bfa_fcs_port_ns_send_plogi(void *ns_cbarg, struct bfa_fcxp_s *fcxp_alloced) bfa_os_hton3b(FC_NAME_SERVER), bfa_fcs_port_get_fcid(port), 0, port->port_cfg.pwwn, port->port_cfg.nwwn, - bfa_fcport_get_maxfrsize(port->fcs->bfa)); + bfa_pport_get_maxfrsize(port->fcs->bfa)); bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE, FC_CLASS_3, len, &fchs, bfa_fcs_port_ns_plogi_response, diff --git a/trunk/drivers/scsi/bfa/rport.c b/trunk/drivers/scsi/bfa/rport.c index 8e73dd9a625a..9cf58bb138dc 100644 --- a/trunk/drivers/scsi/bfa/rport.c +++ b/trunk/drivers/scsi/bfa/rport.c @@ -224,7 +224,7 @@ bfa_fcs_rport_sm_uninit(struct bfa_fcs_rport_s *rport, enum rport_event event) break; default: - bfa_sm_fault(rport->fcs, event); + bfa_assert(0); } } @@ -276,7 +276,7 @@ bfa_fcs_rport_sm_plogi_sending(struct bfa_fcs_rport_s *rport, break; default: - bfa_sm_fault(rport->fcs, event); + bfa_assert(0); } } @@ -332,7 +332,7 @@ bfa_fcs_rport_sm_plogiacc_sending(struct bfa_fcs_rport_s *rport, break; default: - bfa_sm_fault(rport->fcs, event); + bfa_assert(0); } } @@ -406,7 +406,7 @@ bfa_fcs_rport_sm_plogi_retry(struct bfa_fcs_rport_s *rport, break; default: - bfa_sm_fault(rport->fcs, event); + bfa_assert(0); } } @@ -481,7 +481,7 @@ bfa_fcs_rport_sm_plogi(struct bfa_fcs_rport_s *rport, enum rport_event event) break; default: - bfa_sm_fault(rport->fcs, event); + bfa_assert(0); } } @@ -534,7 +534,7 @@ bfa_fcs_rport_sm_hal_online(struct bfa_fcs_rport_s *rport, break; default: - bfa_sm_fault(rport->fcs, event); + bfa_assert(0); } } @@ -589,7 +589,7 @@ bfa_fcs_rport_sm_online(struct bfa_fcs_rport_s *rport, enum rport_event event) break; default: - bfa_sm_fault(rport->fcs, event); + bfa_assert(0); } } @@ -646,7 +646,7 @@ bfa_fcs_rport_sm_nsquery_sending(struct bfa_fcs_rport_s *rport, break; default: - bfa_sm_fault(rport->fcs, event); + bfa_assert(0); } } @@ -704,7 +704,7 @@ bfa_fcs_rport_sm_nsquery(struct bfa_fcs_rport_s *rport, enum rport_event event) break; default: - bfa_sm_fault(rport->fcs, event); + bfa_assert(0); } } @@ -754,7 +754,7 @@ bfa_fcs_rport_sm_adisc_sending(struct bfa_fcs_rport_s *rport, break; default: - bfa_sm_fault(rport->fcs, event); + bfa_assert(0); } } @@ -816,7 +816,7 @@ bfa_fcs_rport_sm_adisc(struct bfa_fcs_rport_s *rport, enum rport_event event) break; default: - bfa_sm_fault(rport->fcs, event); + bfa_assert(0); } } @@ -846,7 +846,7 @@ bfa_fcs_rport_sm_fc4_logorcv(struct bfa_fcs_rport_s *rport, break; default: - bfa_sm_fault(rport->fcs, event); + bfa_assert(0); } } @@ -869,7 +869,7 @@ bfa_fcs_rport_sm_fc4_logosend(struct bfa_fcs_rport_s *rport, break; default: - bfa_sm_fault(rport->fcs, event); + bfa_assert(0); } } @@ -905,7 +905,7 @@ bfa_fcs_rport_sm_fc4_offline(struct bfa_fcs_rport_s *rport, break; default: - bfa_sm_fault(rport->fcs, event); + bfa_assert(0); } } @@ -925,17 +925,10 @@ bfa_fcs_rport_sm_hcb_offline(struct bfa_fcs_rport_s *rport, case RPSM_EVENT_HCB_OFFLINE: case RPSM_EVENT_ADDRESS_CHANGE: if (bfa_fcs_port_is_online(rport->port)) { - if (bfa_fcs_fabric_is_switched(rport->port->fabric)) { - bfa_sm_set_state(rport, - bfa_fcs_rport_sm_nsdisc_sending); - rport->ns_retries = 0; - bfa_fcs_rport_send_gidpn(rport, NULL); - } else { - bfa_sm_set_state(rport, - bfa_fcs_rport_sm_plogi_sending); - rport->plogi_retries = 0; - bfa_fcs_rport_send_plogi(rport, NULL); - } + bfa_sm_set_state(rport, + bfa_fcs_rport_sm_nsdisc_sending); + rport->ns_retries = 0; + bfa_fcs_rport_send_gidpn(rport, NULL); } else { rport->pid = 0; bfa_sm_set_state(rport, bfa_fcs_rport_sm_offline); @@ -958,7 +951,7 @@ bfa_fcs_rport_sm_hcb_offline(struct bfa_fcs_rport_s *rport, break; default: - bfa_sm_fault(rport->fcs, event); + bfa_assert(0); } } @@ -1018,7 +1011,7 @@ bfa_fcs_rport_sm_hcb_logorcv(struct bfa_fcs_rport_s *rport, break; default: - bfa_sm_fault(rport->fcs, event); + bfa_assert(0); } } @@ -1045,7 +1038,7 @@ bfa_fcs_rport_sm_hcb_logosend(struct bfa_fcs_rport_s *rport, break; default: - bfa_sm_fault(rport->fcs, event); + bfa_assert(0); } } @@ -1080,7 +1073,7 @@ bfa_fcs_rport_sm_logo_sending(struct bfa_fcs_rport_s *rport, break; default: - bfa_sm_fault(rport->fcs, event); + bfa_assert(0); } } @@ -1139,7 +1132,7 @@ bfa_fcs_rport_sm_offline(struct bfa_fcs_rport_s *rport, enum rport_event event) break; default: - bfa_sm_fault(rport->fcs, event); + bfa_assert(0); } } @@ -1195,7 +1188,7 @@ bfa_fcs_rport_sm_nsdisc_sending(struct bfa_fcs_rport_s *rport, break; default: - bfa_sm_fault(rport->fcs, event); + bfa_assert(0); } } @@ -1256,7 +1249,7 @@ bfa_fcs_rport_sm_nsdisc_retry(struct bfa_fcs_rport_s *rport, break; default: - bfa_sm_fault(rport->fcs, event); + bfa_assert(0); } } @@ -1341,7 +1334,7 @@ bfa_fcs_rport_sm_nsdisc_sent(struct bfa_fcs_rport_s *rport, break; default: - bfa_sm_fault(rport->fcs, event); + bfa_assert(0); } } @@ -1373,7 +1366,7 @@ bfa_fcs_rport_send_plogi(void *rport_cbarg, struct bfa_fcxp_s *fcxp_alloced) len = fc_plogi_build(&fchs, bfa_fcxp_get_reqbuf(fcxp), rport->pid, bfa_fcs_port_get_fcid(port), 0, port->port_cfg.pwwn, port->port_cfg.nwwn, - bfa_fcport_get_maxfrsize(port->fcs->bfa)); + bfa_pport_get_maxfrsize(port->fcs->bfa)); bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE, FC_CLASS_3, len, &fchs, bfa_fcs_rport_plogi_response, @@ -1485,7 +1478,7 @@ bfa_fcs_rport_send_plogiacc(void *rport_cbarg, struct bfa_fcxp_s *fcxp_alloced) len = fc_plogi_acc_build(&fchs, bfa_fcxp_get_reqbuf(fcxp), rport->pid, bfa_fcs_port_get_fcid(port), rport->reply_oxid, port->port_cfg.pwwn, port->port_cfg.nwwn, - bfa_fcport_get_maxfrsize(port->fcs->bfa)); + bfa_pport_get_maxfrsize(port->fcs->bfa)); bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE, FC_CLASS_3, len, &fchs, NULL, NULL, FC_MAX_PDUSZ, 0); @@ -1820,7 +1813,7 @@ bfa_fcs_rport_process_rpsc(struct bfa_fcs_rport_s *rport, /* * get curent speed from pport attributes from BFA */ - bfa_fcport_get_attr(port->fcs->bfa, &pport_attr); + bfa_pport_get_attr(port->fcs->bfa, &pport_attr); speeds.port_op_speed = fc_bfa_speed_to_rpsc_operspeed(pport_attr.speed); @@ -2039,10 +2032,13 @@ bfa_fcs_rport_aen_post(struct bfa_fcs_rport_s *rport, switch (event) { case BFA_RPORT_AEN_ONLINE: + bfa_log(logmod, BFA_AEN_RPORT_ONLINE, rpwwn_ptr, lpwwn_ptr); + break; case BFA_RPORT_AEN_OFFLINE: + bfa_log(logmod, BFA_AEN_RPORT_OFFLINE, rpwwn_ptr, lpwwn_ptr); + break; case BFA_RPORT_AEN_DISCONNECT: - bfa_log(logmod, BFA_LOG_CREATE_ID(BFA_AEN_CAT_RPORT, event), - rpwwn_ptr, lpwwn_ptr); + bfa_log(logmod, BFA_AEN_RPORT_DISCONNECT, rpwwn_ptr, lpwwn_ptr); break; case BFA_RPORT_AEN_QOS_PRIO: aen_data.rport.priv.qos = data->priv.qos; @@ -2168,7 +2164,7 @@ bfa_fcs_rport_update(struct bfa_fcs_rport_s *rport, struct fc_logi_s *plogi) bfa_trc(port->fcs, port->fabric->bb_credit); port->fabric->bb_credit = bfa_os_ntohs(plogi->csp.bbcred); - bfa_fcport_set_tx_bbcredit(port->fcs->bfa, + bfa_pport_set_tx_bbcredit(port->fcs->bfa, port->fabric->bb_credit); } @@ -2578,6 +2574,23 @@ bfa_fcs_rport_send_ls_rjt(struct bfa_fcs_rport_s *rport, struct fchs_s *rx_fchs, FC_CLASS_3, len, &fchs, NULL, NULL, FC_MAX_PDUSZ, 0); } +/** + * Module initialization + */ +void +bfa_fcs_rport_modinit(struct bfa_fcs_s *fcs) +{ +} + +/** + * Module cleanup + */ +void +bfa_fcs_rport_modexit(struct bfa_fcs_s *fcs) +{ + bfa_fcs_modexit_comp(fcs); +} + /** * Return state of rport. */ diff --git a/trunk/drivers/scsi/bfa/rport_api.c b/trunk/drivers/scsi/bfa/rport_api.c index a441f41d2a64..3dae1774181e 100644 --- a/trunk/drivers/scsi/bfa/rport_api.c +++ b/trunk/drivers/scsi/bfa/rport_api.c @@ -102,7 +102,7 @@ bfa_fcs_rport_get_attr(struct bfa_fcs_rport_s *rport, rport_attr->qos_attr = qos_attr; rport_attr->trl_enforced = BFA_FALSE; - if (bfa_fcport_is_ratelim(port->fcs->bfa)) { + if (bfa_pport_is_ratelim(port->fcs->bfa)) { if ((rport->rpf.rpsc_speed == BFA_PPORT_SPEED_UNKNOWN) || (rport->rpf.rpsc_speed < bfa_fcs_port_get_rport_max_speed(port))) diff --git a/trunk/drivers/scsi/bfa/rport_ftrs.c b/trunk/drivers/scsi/bfa/rport_ftrs.c index ae7bba67ae2a..e1932c885ac2 100644 --- a/trunk/drivers/scsi/bfa/rport_ftrs.c +++ b/trunk/drivers/scsi/bfa/rport_ftrs.c @@ -91,7 +91,7 @@ bfa_fcs_rpf_sm_uninit(struct bfa_fcs_rpf_s *rpf, enum rpf_event event) break; default: - bfa_sm_fault(rport->fcs, event); + bfa_assert(0); } } @@ -114,7 +114,7 @@ bfa_fcs_rpf_sm_rpsc_sending(struct bfa_fcs_rpf_s *rpf, enum rpf_event event) break; default: - bfa_sm_fault(rport->fcs, event); + bfa_assert(0); } } @@ -160,7 +160,7 @@ bfa_fcs_rpf_sm_rpsc(struct bfa_fcs_rpf_s *rpf, enum rpf_event event) break; default: - bfa_sm_fault(rport->fcs, event); + bfa_assert(0); } } @@ -186,7 +186,7 @@ bfa_fcs_rpf_sm_rpsc_retry(struct bfa_fcs_rpf_s *rpf, enum rpf_event event) break; default: - bfa_sm_fault(rport->fcs, event); + bfa_assert(0); } } @@ -206,7 +206,7 @@ bfa_fcs_rpf_sm_online(struct bfa_fcs_rpf_s *rpf, enum rpf_event event) break; default: - bfa_sm_fault(rport->fcs, event); + bfa_assert(0); } } @@ -229,7 +229,7 @@ bfa_fcs_rpf_sm_offline(struct bfa_fcs_rpf_s *rpf, enum rpf_event event) break; default: - bfa_sm_fault(rport->fcs, event); + bfa_assert(0); } } /** diff --git a/trunk/drivers/scsi/bfa/scn.c b/trunk/drivers/scsi/bfa/scn.c index 8fe09ba88a91..bd4771ff62c8 100644 --- a/trunk/drivers/scsi/bfa/scn.c +++ b/trunk/drivers/scsi/bfa/scn.c @@ -90,7 +90,7 @@ bfa_fcs_port_scn_sm_offline(struct bfa_fcs_port_scn_s *scn, break; default: - bfa_sm_fault(scn->port->fcs, event); + bfa_assert(0); } } @@ -109,7 +109,7 @@ bfa_fcs_port_scn_sm_sending_scr(struct bfa_fcs_port_scn_s *scn, break; default: - bfa_sm_fault(scn->port->fcs, event); + bfa_assert(0); } } @@ -137,7 +137,7 @@ bfa_fcs_port_scn_sm_scr(struct bfa_fcs_port_scn_s *scn, break; default: - bfa_sm_fault(scn->port->fcs, event); + bfa_assert(0); } } @@ -157,7 +157,7 @@ bfa_fcs_port_scn_sm_scr_retry(struct bfa_fcs_port_scn_s *scn, break; default: - bfa_sm_fault(scn->port->fcs, event); + bfa_assert(0); } } @@ -171,7 +171,7 @@ bfa_fcs_port_scn_sm_online(struct bfa_fcs_port_scn_s *scn, break; default: - bfa_sm_fault(scn->port->fcs, event); + bfa_assert(0); } } diff --git a/trunk/drivers/scsi/bfa/vport.c b/trunk/drivers/scsi/bfa/vport.c index 27cd619a227a..e90f1e38c32d 100644 --- a/trunk/drivers/scsi/bfa/vport.c +++ b/trunk/drivers/scsi/bfa/vport.c @@ -122,7 +122,7 @@ bfa_fcs_vport_sm_uninit(struct bfa_fcs_vport_s *vport, break; default: - bfa_sm_fault(__vport_fcs(vport), event); + bfa_assert(0); } } @@ -165,7 +165,7 @@ bfa_fcs_vport_sm_created(struct bfa_fcs_vport_s *vport, break; default: - bfa_sm_fault(__vport_fcs(vport), event); + bfa_assert(0); } } @@ -202,7 +202,7 @@ bfa_fcs_vport_sm_offline(struct bfa_fcs_vport_s *vport, break; default: - bfa_sm_fault(__vport_fcs(vport), event); + bfa_assert(0); } } @@ -249,7 +249,7 @@ bfa_fcs_vport_sm_fdisc(struct bfa_fcs_vport_s *vport, break; default: - bfa_sm_fault(__vport_fcs(vport), event); + bfa_assert(0); } } @@ -283,7 +283,7 @@ bfa_fcs_vport_sm_fdisc_retry(struct bfa_fcs_vport_s *vport, break; default: - bfa_sm_fault(__vport_fcs(vport), event); + bfa_assert(0); } } @@ -310,7 +310,7 @@ bfa_fcs_vport_sm_online(struct bfa_fcs_vport_s *vport, break; default: - bfa_sm_fault(__vport_fcs(vport), event); + bfa_assert(0); } } @@ -339,7 +339,7 @@ bfa_fcs_vport_sm_deleting(struct bfa_fcs_vport_s *vport, break; default: - bfa_sm_fault(__vport_fcs(vport), event); + bfa_assert(0); } } @@ -387,7 +387,7 @@ bfa_fcs_vport_sm_cleanup(struct bfa_fcs_vport_s *vport, break; default: - bfa_sm_fault(__vport_fcs(vport), event); + bfa_assert(0); } } @@ -419,7 +419,7 @@ bfa_fcs_vport_sm_logo(struct bfa_fcs_vport_s *vport, break; default: - bfa_sm_fault(__vport_fcs(vport), event); + bfa_assert(0); } } @@ -447,8 +447,22 @@ bfa_fcs_vport_aen_post(bfa_fcs_lport_t *port, enum bfa_lport_aen_event event) bfa_assert(role <= BFA_PORT_ROLE_FCP_MAX); - bfa_log(logmod, BFA_LOG_CREATE_ID(BFA_AEN_CAT_LPORT, event), lpwwn_ptr, - role_str[role/2]); + switch (event) { + case BFA_LPORT_AEN_NPIV_DUP_WWN: + bfa_log(logmod, BFA_AEN_LPORT_NPIV_DUP_WWN, lpwwn_ptr, + role_str[role / 2]); + break; + case BFA_LPORT_AEN_NPIV_FABRIC_MAX: + bfa_log(logmod, BFA_AEN_LPORT_NPIV_FABRIC_MAX, lpwwn_ptr, + role_str[role / 2]); + break; + case BFA_LPORT_AEN_NPIV_UNKNOWN: + bfa_log(logmod, BFA_AEN_LPORT_NPIV_UNKNOWN, lpwwn_ptr, + role_str[role / 2]); + break; + default: + break; + } aen_data.lport.vf_id = port->fabric->vf_id; aen_data.lport.roles = role; @@ -464,7 +478,7 @@ static void bfa_fcs_vport_do_fdisc(struct bfa_fcs_vport_s *vport) { bfa_lps_fdisc(vport->lps, vport, - bfa_fcport_get_maxfrsize(__vport_bfa(vport)), + bfa_pport_get_maxfrsize(__vport_bfa(vport)), __vport_pwwn(vport), __vport_nwwn(vport)); vport->vport_stats.fdisc_sent++; } @@ -602,6 +616,38 @@ bfa_fcs_vport_delete_comp(struct bfa_fcs_vport_s *vport) bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_DELCOMP); } +/** + * Module initialization + */ +void +bfa_fcs_vport_modinit(struct bfa_fcs_s *fcs) +{ +} + +/** + * Module cleanup + */ +void +bfa_fcs_vport_modexit(struct bfa_fcs_s *fcs) +{ + bfa_fcs_modexit_comp(fcs); +} + +u32 +bfa_fcs_vport_get_max(struct bfa_fcs_s *fcs) +{ + struct bfa_ioc_attr_s ioc_attr; + + bfa_get_attr(fcs->bfa, &ioc_attr); + + if (ioc_attr.pci_attr.device_id == BFA_PCI_DEVICE_ID_CT) + return BFA_FCS_MAX_VPORTS_SUPP_CT; + else + return BFA_FCS_MAX_VPORTS_SUPP_CB; +} + + + /** * fcs_vport_api Virtual port API */ @@ -638,7 +684,7 @@ bfa_fcs_vport_create(struct bfa_fcs_vport_s *vport, struct bfa_fcs_s *fcs, return BFA_STATUS_VPORT_EXISTS; if (bfa_fcs_fabric_vport_count(&fcs->fabric) == - bfa_lps_get_max_vport(fcs->bfa)) + bfa_fcs_vport_get_max(fcs)) return BFA_STATUS_VPORT_MAX; vport->lps = bfa_lps_alloc(fcs->bfa); @@ -648,8 +694,7 @@ bfa_fcs_vport_create(struct bfa_fcs_vport_s *vport, struct bfa_fcs_s *fcs, vport->vport_drv = vport_drv; bfa_sm_set_state(vport, bfa_fcs_vport_sm_uninit); - bfa_fcs_lport_attach(&vport->lport, fcs, vf_id, vport); - bfa_fcs_lport_init(&vport->lport, vport_cfg); + bfa_fcs_lport_init(&vport->lport, fcs, vf_id, vport_cfg, vport); bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_CREATE); @@ -843,15 +888,4 @@ bfa_cb_lps_fdisclogo_comp(void *bfad, void *uarg) bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_RSP_OK); } -/** - * Received clear virtual link - */ -void -bfa_cb_lps_cvl_event(void *bfad, void *uarg) -{ - struct bfa_fcs_vport_s *vport = uarg; - /* Send an Offline followed by an ONLINE */ - bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_OFFLINE); - bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_ONLINE); -} diff --git a/trunk/drivers/scsi/bnx2i/bnx2i_iscsi.c b/trunk/drivers/scsi/bnx2i/bnx2i_iscsi.c index cb71dc984797..1c4d1215769d 100644 --- a/trunk/drivers/scsi/bnx2i/bnx2i_iscsi.c +++ b/trunk/drivers/scsi/bnx2i/bnx2i_iscsi.c @@ -1989,7 +1989,7 @@ static struct scsi_host_template bnx2i_host_template = { .queuecommand = iscsi_queuecommand, .eh_abort_handler = iscsi_eh_abort, .eh_device_reset_handler = iscsi_eh_device_reset, - .eh_target_reset_handler = iscsi_eh_recover_target, + .eh_target_reset_handler = iscsi_eh_target_reset, .change_queue_depth = iscsi_change_queue_depth, .can_queue = 1024, .max_sectors = 127, diff --git a/trunk/drivers/scsi/cxgb3i/cxgb3i_iscsi.c b/trunk/drivers/scsi/cxgb3i/cxgb3i_iscsi.c index b7c30585dadd..412853c65372 100644 --- a/trunk/drivers/scsi/cxgb3i/cxgb3i_iscsi.c +++ b/trunk/drivers/scsi/cxgb3i/cxgb3i_iscsi.c @@ -915,7 +915,7 @@ static struct scsi_host_template cxgb3i_host_template = { .cmd_per_lun = ISCSI_DEF_CMD_PER_LUN, .eh_abort_handler = iscsi_eh_abort, .eh_device_reset_handler = iscsi_eh_device_reset, - .eh_target_reset_handler = iscsi_eh_recover_target, + .eh_target_reset_handler = iscsi_eh_target_reset, .target_alloc = iscsi_target_alloc, .use_clustering = DISABLE_CLUSTERING, .this_id = -1, diff --git a/trunk/drivers/scsi/device_handler/scsi_dh_emc.c b/trunk/drivers/scsi/device_handler/scsi_dh_emc.c index 63032ec3db92..61966750bd60 100644 --- a/trunk/drivers/scsi/device_handler/scsi_dh_emc.c +++ b/trunk/drivers/scsi/device_handler/scsi_dh_emc.c @@ -272,7 +272,7 @@ static struct request *get_req(struct scsi_device *sdev, int cmd, int len = 0; rq = blk_get_request(sdev->request_queue, - (cmd != INQUIRY) ? WRITE : READ, GFP_NOIO); + (cmd == MODE_SELECT) ? WRITE : READ, GFP_NOIO); if (!rq) { sdev_printk(KERN_INFO, sdev, "get_req: blk_get_request failed"); return NULL; @@ -286,17 +286,14 @@ static struct request *get_req(struct scsi_device *sdev, int cmd, len = sizeof(short_trespass); rq->cmd_flags |= REQ_RW; rq->cmd[1] = 0x10; - rq->cmd[4] = len; break; case MODE_SELECT_10: len = sizeof(long_trespass); rq->cmd_flags |= REQ_RW; rq->cmd[1] = 0x10; - rq->cmd[8] = len; break; case INQUIRY: len = CLARIION_BUFFER_SIZE; - rq->cmd[4] = len; memset(buffer, 0, len); break; default: @@ -304,6 +301,7 @@ static struct request *get_req(struct scsi_device *sdev, int cmd, break; } + rq->cmd[4] = len; rq->cmd_type = REQ_TYPE_BLOCK_PC; rq->cmd_flags |= REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER; diff --git a/trunk/drivers/scsi/hpsa.c b/trunk/drivers/scsi/hpsa.c index 183d3a43c280..03697ba94251 100644 --- a/trunk/drivers/scsi/hpsa.c +++ b/trunk/drivers/scsi/hpsa.c @@ -43,7 +43,6 @@ #include #include #include -#include #include #include #include @@ -53,7 +52,7 @@ #include "hpsa.h" /* HPSA_DRIVER_VERSION must be 3 byte values (0-255) separated by '.' */ -#define HPSA_DRIVER_VERSION "2.0.2-1" +#define HPSA_DRIVER_VERSION "2.0.1-3" #define DRIVER_NAME "HP HPSA Driver (v " HPSA_DRIVER_VERSION ")" /* How long to wait (in milliseconds) for board to go into simple mode */ @@ -135,8 +134,6 @@ static int hpsa_scsi_queue_command(struct scsi_cmnd *cmd, static void hpsa_scan_start(struct Scsi_Host *); static int hpsa_scan_finished(struct Scsi_Host *sh, unsigned long elapsed_time); -static int hpsa_change_queue_depth(struct scsi_device *sdev, - int qdepth, int reason); static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd); static int hpsa_slave_alloc(struct scsi_device *sdev); @@ -185,8 +182,8 @@ static struct scsi_host_template hpsa_driver_template = { .queuecommand = hpsa_scsi_queue_command, .scan_start = hpsa_scan_start, .scan_finished = hpsa_scan_finished, - .change_queue_depth = hpsa_change_queue_depth, .this_id = -1, + .sg_tablesize = MAXSGENTRIES, .use_clustering = ENABLE_CLUSTERING, .eh_device_reset_handler = hpsa_eh_device_reset_handler, .ioctl = hpsa_ioctl, @@ -211,6 +208,133 @@ static inline struct ctlr_info *shost_to_hba(struct Scsi_Host *sh) return (struct ctlr_info *) *priv; } +static struct task_struct *hpsa_scan_thread; +static DEFINE_MUTEX(hpsa_scan_mutex); +static LIST_HEAD(hpsa_scan_q); +static int hpsa_scan_func(void *data); + +/** + * add_to_scan_list() - add controller to rescan queue + * @h: Pointer to the controller. + * + * Adds the controller to the rescan queue if not already on the queue. + * + * returns 1 if added to the queue, 0 if skipped (could be on the + * queue already, or the controller could be initializing or shutting + * down). + **/ +static int add_to_scan_list(struct ctlr_info *h) +{ + struct ctlr_info *test_h; + int found = 0; + int ret = 0; + + if (h->busy_initializing) + return 0; + + /* + * If we don't get the lock, it means the driver is unloading + * and there's no point in scheduling a new scan. + */ + if (!mutex_trylock(&h->busy_shutting_down)) + return 0; + + mutex_lock(&hpsa_scan_mutex); + list_for_each_entry(test_h, &hpsa_scan_q, scan_list) { + if (test_h == h) { + found = 1; + break; + } + } + if (!found && !h->busy_scanning) { + INIT_COMPLETION(h->scan_wait); + list_add_tail(&h->scan_list, &hpsa_scan_q); + ret = 1; + } + mutex_unlock(&hpsa_scan_mutex); + mutex_unlock(&h->busy_shutting_down); + + return ret; +} + +/** + * remove_from_scan_list() - remove controller from rescan queue + * @h: Pointer to the controller. + * + * Removes the controller from the rescan queue if present. Blocks if + * the controller is currently conducting a rescan. The controller + * can be in one of three states: + * 1. Doesn't need a scan + * 2. On the scan list, but not scanning yet (we remove it) + * 3. Busy scanning (and not on the list). In this case we want to wait for + * the scan to complete to make sure the scanning thread for this + * controller is completely idle. + **/ +static void remove_from_scan_list(struct ctlr_info *h) +{ + struct ctlr_info *test_h, *tmp_h; + + mutex_lock(&hpsa_scan_mutex); + list_for_each_entry_safe(test_h, tmp_h, &hpsa_scan_q, scan_list) { + if (test_h == h) { /* state 2. */ + list_del(&h->scan_list); + complete_all(&h->scan_wait); + mutex_unlock(&hpsa_scan_mutex); + return; + } + } + if (h->busy_scanning) { /* state 3. */ + mutex_unlock(&hpsa_scan_mutex); + wait_for_completion(&h->scan_wait); + } else { /* state 1, nothing to do. */ + mutex_unlock(&hpsa_scan_mutex); + } +} + +/* hpsa_scan_func() - kernel thread used to rescan controllers + * @data: Ignored. + * + * A kernel thread used scan for drive topology changes on + * controllers. The thread processes only one controller at a time + * using a queue. Controllers are added to the queue using + * add_to_scan_list() and removed from the queue either after done + * processing or using remove_from_scan_list(). + * + * returns 0. + **/ +static int hpsa_scan_func(__attribute__((unused)) void *data) +{ + struct ctlr_info *h; + int host_no; + + while (1) { + set_current_state(TASK_INTERRUPTIBLE); + schedule(); + if (kthread_should_stop()) + break; + + while (1) { + mutex_lock(&hpsa_scan_mutex); + if (list_empty(&hpsa_scan_q)) { + mutex_unlock(&hpsa_scan_mutex); + break; + } + h = list_entry(hpsa_scan_q.next, struct ctlr_info, + scan_list); + list_del(&h->scan_list); + h->busy_scanning = 1; + mutex_unlock(&hpsa_scan_mutex); + host_no = h->scsi_host ? h->scsi_host->host_no : -1; + hpsa_scan_start(h->scsi_host); + complete_all(&h->scan_wait); + mutex_lock(&hpsa_scan_mutex); + h->busy_scanning = 0; + mutex_unlock(&hpsa_scan_mutex); + } + } + return 0; +} + static int check_for_unit_attention(struct ctlr_info *h, struct CommandList *c) { @@ -228,8 +352,21 @@ static int check_for_unit_attention(struct ctlr_info *h, break; case REPORT_LUNS_CHANGED: dev_warn(&h->pdev->dev, "hpsa%d: report LUN data " - "changed, action required\n", h->ctlr); + "changed\n", h->ctlr); /* + * Here, we could call add_to_scan_list and wake up the scan thread, + * except that it's quite likely that we will get more than one + * REPORT_LUNS_CHANGED condition in quick succession, which means + * that those which occur after the first one will likely happen + * *during* the hpsa_scan_thread's rescan. And the rescan code is not + * robust enough to restart in the middle, undoing what it has already + * done, and it's not clear that it's even possible to do this, since + * part of what it does is notify the SCSI mid layer, which starts + * doing it's own i/o to read partition tables and so on, and the + * driver doesn't have visibility to know what might need undoing. + * In any event, if possible, it is horribly complicated to get right + * so we just don't do it for now. + * * Note: this REPORT_LUNS_CHANGED condition only occurs on the MSA2012. */ break; @@ -256,7 +393,10 @@ static ssize_t host_store_rescan(struct device *dev, struct ctlr_info *h; struct Scsi_Host *shost = class_to_shost(dev); h = shost_to_hba(shost); - hpsa_scan_start(h->scsi_host); + if (add_to_scan_list(h)) { + wake_up_process(hpsa_scan_thread); + wait_for_completion_interruptible(&h->scan_wait); + } return count; } @@ -843,76 +983,6 @@ static void hpsa_scsi_setup(struct ctlr_info *h) spin_lock_init(&h->devlock); } -static void hpsa_free_sg_chain_blocks(struct ctlr_info *h) -{ - int i; - - if (!h->cmd_sg_list) - return; - for (i = 0; i < h->nr_cmds; i++) { - kfree(h->cmd_sg_list[i]); - h->cmd_sg_list[i] = NULL; - } - kfree(h->cmd_sg_list); - h->cmd_sg_list = NULL; -} - -static int hpsa_allocate_sg_chain_blocks(struct ctlr_info *h) -{ - int i; - - if (h->chainsize <= 0) - return 0; - - h->cmd_sg_list = kzalloc(sizeof(*h->cmd_sg_list) * h->nr_cmds, - GFP_KERNEL); - if (!h->cmd_sg_list) - return -ENOMEM; - for (i = 0; i < h->nr_cmds; i++) { - h->cmd_sg_list[i] = kmalloc(sizeof(*h->cmd_sg_list[i]) * - h->chainsize, GFP_KERNEL); - if (!h->cmd_sg_list[i]) - goto clean; - } - return 0; - -clean: - hpsa_free_sg_chain_blocks(h); - return -ENOMEM; -} - -static void hpsa_map_sg_chain_block(struct ctlr_info *h, - struct CommandList *c) -{ - struct SGDescriptor *chain_sg, *chain_block; - u64 temp64; - - chain_sg = &c->SG[h->max_cmd_sg_entries - 1]; - chain_block = h->cmd_sg_list[c->cmdindex]; - chain_sg->Ext = HPSA_SG_CHAIN; - chain_sg->Len = sizeof(*chain_sg) * - (c->Header.SGTotal - h->max_cmd_sg_entries); - temp64 = pci_map_single(h->pdev, chain_block, chain_sg->Len, - PCI_DMA_TODEVICE); - chain_sg->Addr.lower = (u32) (temp64 & 0x0FFFFFFFFULL); - chain_sg->Addr.upper = (u32) ((temp64 >> 32) & 0x0FFFFFFFFULL); -} - -static void hpsa_unmap_sg_chain_block(struct ctlr_info *h, - struct CommandList *c) -{ - struct SGDescriptor *chain_sg; - union u64bit temp64; - - if (c->Header.SGTotal <= h->max_cmd_sg_entries) - return; - - chain_sg = &c->SG[h->max_cmd_sg_entries - 1]; - temp64.val32.lower = chain_sg->Addr.lower; - temp64.val32.upper = chain_sg->Addr.upper; - pci_unmap_single(h->pdev, temp64.val, chain_sg->Len, PCI_DMA_TODEVICE); -} - static void complete_scsi_command(struct CommandList *cp, int timeout, u32 tag) { @@ -929,12 +999,10 @@ static void complete_scsi_command(struct CommandList *cp, h = cp->h; scsi_dma_unmap(cmd); /* undo the DMA mappings */ - if (cp->Header.SGTotal > h->max_cmd_sg_entries) - hpsa_unmap_sg_chain_block(h, cp); cmd->result = (DID_OK << 16); /* host byte */ cmd->result |= (COMMAND_COMPLETE << 8); /* msg byte */ - cmd->result |= ei->ScsiStatus; + cmd->result |= (ei->ScsiStatus << 1); /* copy the sense data whether we need to or not. */ memcpy(cmd->sense_buffer, ei->SenseInfo, @@ -1135,7 +1203,6 @@ static int hpsa_scsi_detect(struct ctlr_info *h) sh->max_id = HPSA_MAX_LUN; sh->can_queue = h->nr_cmds; sh->cmd_per_lun = h->nr_cmds; - sh->sg_tablesize = h->maxsgentries; h->scsi_host = sh; sh->hostdata[0] = (unsigned long) h; sh->irq = h->intr[PERF_MODE_INT]; @@ -1315,7 +1382,7 @@ static int hpsa_send_reset(struct ctlr_info *h, unsigned char *scsi3addr) if (c == NULL) { /* trouble... */ dev_warn(&h->pdev->dev, "cmd_special_alloc returned NULL!\n"); - return -ENOMEM; + return -1; } fill_cmd(c, HPSA_DEVICE_RESET_MSG, h, NULL, 0, 0, scsi3addr, TYPE_MSG); @@ -1837,17 +1904,16 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno) * dma mapping and fills in the scatter gather entries of the * hpsa command, cp. */ -static int hpsa_scatter_gather(struct ctlr_info *h, +static int hpsa_scatter_gather(struct pci_dev *pdev, struct CommandList *cp, struct scsi_cmnd *cmd) { unsigned int len; struct scatterlist *sg; u64 addr64; - int use_sg, i, sg_index, chained; - struct SGDescriptor *curr_sg; + int use_sg, i; - BUG_ON(scsi_sg_count(cmd) > h->maxsgentries); + BUG_ON(scsi_sg_count(cmd) > MAXSGENTRIES); use_sg = scsi_dma_map(cmd); if (use_sg < 0) @@ -1856,33 +1922,15 @@ static int hpsa_scatter_gather(struct ctlr_info *h, if (!use_sg) goto sglist_finished; - curr_sg = cp->SG; - chained = 0; - sg_index = 0; scsi_for_each_sg(cmd, sg, use_sg, i) { - if (i == h->max_cmd_sg_entries - 1 && - use_sg > h->max_cmd_sg_entries) { - chained = 1; - curr_sg = h->cmd_sg_list[cp->cmdindex]; - sg_index = 0; - } addr64 = (u64) sg_dma_address(sg); len = sg_dma_len(sg); - curr_sg->Addr.lower = (u32) (addr64 & 0x0FFFFFFFFULL); - curr_sg->Addr.upper = (u32) ((addr64 >> 32) & 0x0FFFFFFFFULL); - curr_sg->Len = len; - curr_sg->Ext = 0; /* we are not chaining */ - curr_sg++; - } - - if (use_sg + chained > h->maxSG) - h->maxSG = use_sg + chained; - - if (chained) { - cp->Header.SGList = h->max_cmd_sg_entries; - cp->Header.SGTotal = (u16) (use_sg + 1); - hpsa_map_sg_chain_block(h, cp); - return 0; + cp->SG[i].Addr.lower = + (u32) (addr64 & (u64) 0x00000000FFFFFFFF); + cp->SG[i].Addr.upper = + (u32) ((addr64 >> 32) & (u64) 0x00000000FFFFFFFF); + cp->SG[i].Len = len; + cp->SG[i].Ext = 0; /* we are not chaining */ } sglist_finished: @@ -1978,7 +2026,7 @@ static int hpsa_scsi_queue_command(struct scsi_cmnd *cmd, break; } - if (hpsa_scatter_gather(h, c, cmd) < 0) { /* Fill SG list */ + if (hpsa_scatter_gather(h->pdev, c, cmd) < 0) { /* Fill SG list */ cmd_free(h, c); return SCSI_MLQUEUE_HOST_BUSY; } @@ -2029,23 +2077,6 @@ static int hpsa_scan_finished(struct Scsi_Host *sh, return finished; } -static int hpsa_change_queue_depth(struct scsi_device *sdev, - int qdepth, int reason) -{ - struct ctlr_info *h = sdev_to_hba(sdev); - - if (reason != SCSI_QDEPTH_DEFAULT) - return -ENOTSUPP; - - if (qdepth < 1) - qdepth = 1; - else - if (qdepth > h->nr_cmds) - qdepth = h->nr_cmds; - scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth); - return sdev->queue_depth; -} - static void hpsa_unregister_scsi(struct ctlr_info *h) { /* we are being forcibly unloaded, and may not refuse. */ @@ -2930,7 +2961,7 @@ static irqreturn_t do_hpsa_intr(int irq, void *dev_id) return IRQ_HANDLED; } -/* Send a message CDB to the firmware. */ +/* Send a message CDB to the firmwart. */ static __devinit int hpsa_message(struct pci_dev *pdev, unsigned char opcode, unsigned char type) { @@ -3265,7 +3296,7 @@ static void __devinit hpsa_interrupt_mode(struct ctlr_info *h, h->intr[PERF_MODE_INT] = pdev->irq; } -static int __devinit hpsa_pci_init(struct ctlr_info *h, struct pci_dev *pdev) +static int hpsa_pci_init(struct ctlr_info *h, struct pci_dev *pdev) { ushort subsystem_vendor_id, subsystem_device_id, command; u32 board_id, scratchpad = 0; @@ -3374,23 +3405,6 @@ static int __devinit hpsa_pci_init(struct ctlr_info *h, struct pci_dev *pdev) h->board_id = board_id; h->max_commands = readl(&(h->cfgtable->MaxPerformantModeCommands)); - h->maxsgentries = readl(&(h->cfgtable->MaxScatterGatherElements)); - - /* - * Limit in-command s/g elements to 32 save dma'able memory. - * Howvever spec says if 0, use 31 - */ - - h->max_cmd_sg_entries = 31; - if (h->maxsgentries > 512) { - h->max_cmd_sg_entries = 32; - h->chainsize = h->maxsgentries - h->max_cmd_sg_entries + 1; - h->maxsgentries--; /* save one for chain pointer */ - } else { - h->maxsgentries = 31; /* default to traditional values */ - h->chainsize = 0; - } - h->product_name = products[prod_index].product_name; h->access = *(products[prod_index].access); /* Allow room for some ioctls */ @@ -3518,6 +3532,8 @@ static int __devinit hpsa_init_one(struct pci_dev *pdev, h->busy_initializing = 1; INIT_HLIST_HEAD(&h->cmpQ); INIT_HLIST_HEAD(&h->reqQ); + mutex_init(&h->busy_shutting_down); + init_completion(&h->scan_wait); rc = hpsa_pci_init(h, pdev); if (rc != 0) goto clean1; @@ -3571,8 +3587,6 @@ static int __devinit hpsa_init_one(struct pci_dev *pdev, rc = -ENOMEM; goto clean4; } - if (hpsa_allocate_sg_chain_blocks(h)) - goto clean4; spin_lock_init(&h->lock); spin_lock_init(&h->scan_lock); init_waitqueue_head(&h->scan_wait_queue); @@ -3595,7 +3609,6 @@ static int __devinit hpsa_init_one(struct pci_dev *pdev, return 1; clean4: - hpsa_free_sg_chain_blocks(h); kfree(h->cmd_pool_bits); if (h->cmd_pool) pci_free_consistent(h->pdev, @@ -3668,10 +3681,11 @@ static void __devexit hpsa_remove_one(struct pci_dev *pdev) return; } h = pci_get_drvdata(pdev); + mutex_lock(&h->busy_shutting_down); + remove_from_scan_list(h); hpsa_unregister_scsi(h); /* unhook from SCSI subsystem */ hpsa_shutdown(pdev); iounmap(h->vaddr); - hpsa_free_sg_chain_blocks(h); pci_free_consistent(h->pdev, h->nr_cmds * sizeof(struct CommandList), h->cmd_pool, h->cmd_pool_dhandle); @@ -3689,6 +3703,7 @@ static void __devexit hpsa_remove_one(struct pci_dev *pdev) */ pci_release_regions(pdev); pci_set_drvdata(pdev, NULL); + mutex_unlock(&h->busy_shutting_down); kfree(h); } @@ -3842,12 +3857,23 @@ static void hpsa_put_ctlr_into_performant_mode(struct ctlr_info *h) */ static int __init hpsa_init(void) { - return pci_register_driver(&hpsa_pci_driver); + int err; + /* Start the scan thread */ + hpsa_scan_thread = kthread_run(hpsa_scan_func, NULL, "hpsa_scan"); + if (IS_ERR(hpsa_scan_thread)) { + err = PTR_ERR(hpsa_scan_thread); + return -ENODEV; + } + err = pci_register_driver(&hpsa_pci_driver); + if (err) + kthread_stop(hpsa_scan_thread); + return err; } static void __exit hpsa_cleanup(void) { pci_unregister_driver(&hpsa_pci_driver); + kthread_stop(hpsa_scan_thread); } module_init(hpsa_init); diff --git a/trunk/drivers/scsi/hpsa.h b/trunk/drivers/scsi/hpsa.h index 1bb5233b09a0..a0502b3ac17e 100644 --- a/trunk/drivers/scsi/hpsa.h +++ b/trunk/drivers/scsi/hpsa.h @@ -83,10 +83,6 @@ struct ctlr_info { unsigned int maxQsinceinit; unsigned int maxSG; spinlock_t lock; - int maxsgentries; - u8 max_cmd_sg_entries; - int chainsize; - struct SGDescriptor **cmd_sg_list; /* pointers to command and error info pool */ struct CommandList *cmd_pool; @@ -101,6 +97,9 @@ struct ctlr_info { int scan_finished; spinlock_t scan_lock; wait_queue_head_t scan_wait_queue; + struct mutex busy_shutting_down; + struct list_head scan_list; + struct completion scan_wait; struct Scsi_Host *scsi_host; spinlock_t devlock; /* to protect hba[ctlr]->dev[]; */ diff --git a/trunk/drivers/scsi/hpsa_cmd.h b/trunk/drivers/scsi/hpsa_cmd.h index 56fb9827681e..3e0abdf76689 100644 --- a/trunk/drivers/scsi/hpsa_cmd.h +++ b/trunk/drivers/scsi/hpsa_cmd.h @@ -23,8 +23,7 @@ /* general boundary defintions */ #define SENSEINFOBYTES 32 /* may vary between hbas */ -#define MAXSGENTRIES 32 -#define HPSA_SG_CHAIN 0x80000000 +#define MAXSGENTRIES 31 #define MAXREPLYQS 256 /* Command Status value */ @@ -306,23 +305,20 @@ struct CommandList { int cmd_type; long cmdindex; struct hlist_node list; + struct CommandList *prev; + struct CommandList *next; struct request *rq; struct completion *waiting; + int retry_count; void *scsi_cmd; /* on 64 bit architectures, to get this to be 32-byte-aligned - * it so happens we need PAD_64 bytes of padding, on 32 bit systems, - * we need PAD_32 bytes of padding (see below). This does that. - * If it happens that 64 bit and 32 bit systems need different - * padding, PAD_32 and PAD_64 can be set independently, and. - * the code below will do the right thing. + * it so happens we need no padding, on 32 bit systems, + * we need 8 bytes of padding. This does that. */ -#define IS_32_BIT ((8 - sizeof(long))/4) -#define IS_64_BIT (!IS_32_BIT) -#define PAD_32 (4) -#define PAD_64 (4) -#define COMMANDLIST_PAD (IS_32_BIT * PAD_32 + IS_64_BIT * PAD_64) +#define COMMANDLIST_PAD ((8 - sizeof(long))/4 * 8) u8 pad[COMMANDLIST_PAD]; + }; /* Configuration Table Structure */ diff --git a/trunk/drivers/scsi/ibmvscsi/ibmvfc.c b/trunk/drivers/scsi/ibmvscsi/ibmvfc.c index 4e577e2fee38..732f6d35b4a8 100644 --- a/trunk/drivers/scsi/ibmvscsi/ibmvfc.c +++ b/trunk/drivers/scsi/ibmvscsi/ibmvfc.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -4736,27 +4735,6 @@ static int ibmvfc_remove(struct vio_dev *vdev) return 0; } -/** - * ibmvfc_resume - Resume from suspend - * @dev: device struct - * - * We may have lost an interrupt across suspend/resume, so kick the - * interrupt handler - * - */ -static int ibmvfc_resume(struct device *dev) -{ - unsigned long flags; - struct ibmvfc_host *vhost = dev_get_drvdata(dev); - struct vio_dev *vdev = to_vio_dev(dev); - - spin_lock_irqsave(vhost->host->host_lock, flags); - vio_disable_interrupts(vdev); - tasklet_schedule(&vhost->tasklet); - spin_unlock_irqrestore(vhost->host->host_lock, flags); - return 0; -} - /** * ibmvfc_get_desired_dma - Calculate DMA resources needed by the driver * @vdev: vio device struct @@ -4777,10 +4755,6 @@ static struct vio_device_id ibmvfc_device_table[] __devinitdata = { }; MODULE_DEVICE_TABLE(vio, ibmvfc_device_table); -static struct dev_pm_ops ibmvfc_pm_ops = { - .resume = ibmvfc_resume -}; - static struct vio_driver ibmvfc_driver = { .id_table = ibmvfc_device_table, .probe = ibmvfc_probe, @@ -4789,7 +4763,6 @@ static struct vio_driver ibmvfc_driver = { .driver = { .name = IBMVFC_NAME, .owner = THIS_MODULE, - .pm = &ibmvfc_pm_ops, } }; diff --git a/trunk/drivers/scsi/ibmvscsi/ibmvscsi.c b/trunk/drivers/scsi/ibmvscsi/ibmvscsi.c index dc1bcbe3b176..e3a18e0ef276 100644 --- a/trunk/drivers/scsi/ibmvscsi/ibmvscsi.c +++ b/trunk/drivers/scsi/ibmvscsi/ibmvscsi.c @@ -71,7 +71,6 @@ #include #include #include -#include #include #include #include @@ -1991,19 +1990,6 @@ static int ibmvscsi_remove(struct vio_dev *vdev) return 0; } -/** - * ibmvscsi_resume: Resume from suspend - * @dev: device struct - * - * We may have lost an interrupt across suspend/resume, so kick the - * interrupt handler - */ -static int ibmvscsi_resume(struct device *dev) -{ - struct ibmvscsi_host_data *hostdata = dev_get_drvdata(dev); - return ibmvscsi_ops->resume(hostdata); -} - /** * ibmvscsi_device_table: Used by vio.c to match devices in the device tree we * support. @@ -2014,10 +2000,6 @@ static struct vio_device_id ibmvscsi_device_table[] __devinitdata = { }; MODULE_DEVICE_TABLE(vio, ibmvscsi_device_table); -static struct dev_pm_ops ibmvscsi_pm_ops = { - .resume = ibmvscsi_resume -}; - static struct vio_driver ibmvscsi_driver = { .id_table = ibmvscsi_device_table, .probe = ibmvscsi_probe, @@ -2026,7 +2008,6 @@ static struct vio_driver ibmvscsi_driver = { .driver = { .name = "ibmvscsi", .owner = THIS_MODULE, - .pm = &ibmvscsi_pm_ops, } }; diff --git a/trunk/drivers/scsi/ibmvscsi/ibmvscsi.h b/trunk/drivers/scsi/ibmvscsi/ibmvscsi.h index 9cb7c6a773e1..76425303def0 100644 --- a/trunk/drivers/scsi/ibmvscsi/ibmvscsi.h +++ b/trunk/drivers/scsi/ibmvscsi/ibmvscsi.h @@ -120,7 +120,6 @@ struct ibmvscsi_ops { struct ibmvscsi_host_data *hostdata); int (*send_crq)(struct ibmvscsi_host_data *hostdata, u64 word1, u64 word2); - int (*resume) (struct ibmvscsi_host_data *hostdata); }; extern struct ibmvscsi_ops iseriesvscsi_ops; diff --git a/trunk/drivers/scsi/ibmvscsi/iseries_vscsi.c b/trunk/drivers/scsi/ibmvscsi/iseries_vscsi.c index f4776451a754..0775fdee5fa8 100644 --- a/trunk/drivers/scsi/ibmvscsi/iseries_vscsi.c +++ b/trunk/drivers/scsi/ibmvscsi/iseries_vscsi.c @@ -158,16 +158,10 @@ static int iseriesvscsi_send_crq(struct ibmvscsi_host_data *hostdata, 0); } -static int iseriesvscsi_resume(struct ibmvscsi_host_data *hostdata) -{ - return 0; -} - struct ibmvscsi_ops iseriesvscsi_ops = { .init_crq_queue = iseriesvscsi_init_crq_queue, .release_crq_queue = iseriesvscsi_release_crq_queue, .reset_crq_queue = iseriesvscsi_reset_crq_queue, .reenable_crq_queue = iseriesvscsi_reenable_crq_queue, .send_crq = iseriesvscsi_send_crq, - .resume = iseriesvscsi_resume, }; diff --git a/trunk/drivers/scsi/ibmvscsi/rpa_vscsi.c b/trunk/drivers/scsi/ibmvscsi/rpa_vscsi.c index 63a30cbbf9de..462a8574dad9 100644 --- a/trunk/drivers/scsi/ibmvscsi/rpa_vscsi.c +++ b/trunk/drivers/scsi/ibmvscsi/rpa_vscsi.c @@ -334,23 +334,10 @@ static int rpavscsi_reenable_crq_queue(struct crq_queue *queue, return rc; } -/** - * rpavscsi_resume: - resume after suspend - * @hostdata: ibmvscsi_host_data of host - * - */ -static int rpavscsi_resume(struct ibmvscsi_host_data *hostdata) -{ - vio_disable_interrupts(to_vio_dev(hostdata->dev)); - tasklet_schedule(&hostdata->srp_task); - return 0; -} - struct ibmvscsi_ops rpavscsi_ops = { .init_crq_queue = rpavscsi_init_crq_queue, .release_crq_queue = rpavscsi_release_crq_queue, .reset_crq_queue = rpavscsi_reset_crq_queue, .reenable_crq_queue = rpavscsi_reenable_crq_queue, .send_crq = rpavscsi_send_crq, - .resume = rpavscsi_resume, }; diff --git a/trunk/drivers/scsi/ipr.c b/trunk/drivers/scsi/ipr.c index c79cd98eb6bf..032f0d0e6cb4 100644 --- a/trunk/drivers/scsi/ipr.c +++ b/trunk/drivers/scsi/ipr.c @@ -72,8 +72,6 @@ #include #include #include -#include -#include #include #include #include @@ -93,8 +91,8 @@ static unsigned int ipr_max_speed = 1; static int ipr_testmode = 0; static unsigned int ipr_fastfail = 0; static unsigned int ipr_transop_timeout = 0; +static unsigned int ipr_enable_cache = 1; static unsigned int ipr_debug = 0; -static unsigned int ipr_max_devs = IPR_DEFAULT_SIS64_DEVS; static unsigned int ipr_dual_ioa_raid = 1; static DEFINE_SPINLOCK(ipr_driver_lock); @@ -106,20 +104,13 @@ static const struct ipr_chip_cfg_t ipr_chip_cfg[] = { { .set_interrupt_mask_reg = 0x0022C, .clr_interrupt_mask_reg = 0x00230, - .clr_interrupt_mask_reg32 = 0x00230, .sense_interrupt_mask_reg = 0x0022C, - .sense_interrupt_mask_reg32 = 0x0022C, .clr_interrupt_reg = 0x00228, - .clr_interrupt_reg32 = 0x00228, .sense_interrupt_reg = 0x00224, - .sense_interrupt_reg32 = 0x00224, .ioarrin_reg = 0x00404, .sense_uproc_interrupt_reg = 0x00214, - .sense_uproc_interrupt_reg32 = 0x00214, .set_uproc_interrupt_reg = 0x00214, - .set_uproc_interrupt_reg32 = 0x00214, - .clr_uproc_interrupt_reg = 0x00218, - .clr_uproc_interrupt_reg32 = 0x00218 + .clr_uproc_interrupt_reg = 0x00218 } }, { /* Snipe and Scamp */ @@ -128,59 +119,25 @@ static const struct ipr_chip_cfg_t ipr_chip_cfg[] = { { .set_interrupt_mask_reg = 0x00288, .clr_interrupt_mask_reg = 0x0028C, - .clr_interrupt_mask_reg32 = 0x0028C, .sense_interrupt_mask_reg = 0x00288, - .sense_interrupt_mask_reg32 = 0x00288, .clr_interrupt_reg = 0x00284, - .clr_interrupt_reg32 = 0x00284, .sense_interrupt_reg = 0x00280, - .sense_interrupt_reg32 = 0x00280, .ioarrin_reg = 0x00504, .sense_uproc_interrupt_reg = 0x00290, - .sense_uproc_interrupt_reg32 = 0x00290, .set_uproc_interrupt_reg = 0x00290, - .set_uproc_interrupt_reg32 = 0x00290, - .clr_uproc_interrupt_reg = 0x00294, - .clr_uproc_interrupt_reg32 = 0x00294 - } - }, - { /* CRoC */ - .mailbox = 0x00040, - .cache_line_size = 0x20, - { - .set_interrupt_mask_reg = 0x00010, - .clr_interrupt_mask_reg = 0x00018, - .clr_interrupt_mask_reg32 = 0x0001C, - .sense_interrupt_mask_reg = 0x00010, - .sense_interrupt_mask_reg32 = 0x00014, - .clr_interrupt_reg = 0x00008, - .clr_interrupt_reg32 = 0x0000C, - .sense_interrupt_reg = 0x00000, - .sense_interrupt_reg32 = 0x00004, - .ioarrin_reg = 0x00070, - .sense_uproc_interrupt_reg = 0x00020, - .sense_uproc_interrupt_reg32 = 0x00024, - .set_uproc_interrupt_reg = 0x00020, - .set_uproc_interrupt_reg32 = 0x00024, - .clr_uproc_interrupt_reg = 0x00028, - .clr_uproc_interrupt_reg32 = 0x0002C, - .init_feedback_reg = 0x0005C, - .dump_addr_reg = 0x00064, - .dump_data_reg = 0x00068 + .clr_uproc_interrupt_reg = 0x00294 } }, }; static const struct ipr_chip_t ipr_chip[] = { - { PCI_VENDOR_ID_MYLEX, PCI_DEVICE_ID_IBM_GEMSTONE, IPR_USE_LSI, IPR_SIS32, &ipr_chip_cfg[0] }, - { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE, IPR_USE_LSI, IPR_SIS32, &ipr_chip_cfg[0] }, - { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN, IPR_USE_LSI, IPR_SIS32, &ipr_chip_cfg[0] }, - { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN, IPR_USE_LSI, IPR_SIS32, &ipr_chip_cfg[0] }, - { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN_E, IPR_USE_MSI, IPR_SIS32, &ipr_chip_cfg[0] }, - { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_SNIPE, IPR_USE_LSI, IPR_SIS32, &ipr_chip_cfg[1] }, - { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP, IPR_USE_LSI, IPR_SIS32, &ipr_chip_cfg[1] }, - { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CROC_FPGA_E2, IPR_USE_MSI, IPR_SIS64, &ipr_chip_cfg[2] }, - { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CROC_ASIC_E2, IPR_USE_MSI, IPR_SIS64, &ipr_chip_cfg[2] } + { PCI_VENDOR_ID_MYLEX, PCI_DEVICE_ID_IBM_GEMSTONE, IPR_USE_LSI, &ipr_chip_cfg[0] }, + { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE, IPR_USE_LSI, &ipr_chip_cfg[0] }, + { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN, IPR_USE_LSI, &ipr_chip_cfg[0] }, + { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN, IPR_USE_LSI, &ipr_chip_cfg[0] }, + { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN_E, IPR_USE_MSI, &ipr_chip_cfg[0] }, + { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_SNIPE, IPR_USE_LSI, &ipr_chip_cfg[1] }, + { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP, IPR_USE_LSI, &ipr_chip_cfg[1] } }; static int ipr_max_bus_speeds [] = { @@ -199,13 +156,12 @@ module_param_named(fastfail, ipr_fastfail, int, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(fastfail, "Reduce timeouts and retries"); module_param_named(transop_timeout, ipr_transop_timeout, int, 0); MODULE_PARM_DESC(transop_timeout, "Time in seconds to wait for adapter to come operational (default: 300)"); +module_param_named(enable_cache, ipr_enable_cache, int, 0); +MODULE_PARM_DESC(enable_cache, "Enable adapter's non-volatile write cache (default: 1)"); module_param_named(debug, ipr_debug, int, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(debug, "Enable device driver debugging logging. Set to 1 to enable. (default: 0)"); module_param_named(dual_ioa_raid, ipr_dual_ioa_raid, int, 0); MODULE_PARM_DESC(dual_ioa_raid, "Enable dual adapter RAID support. Set to 1 to enable. (default: 1)"); -module_param_named(max_devs, ipr_max_devs, int, 0); -MODULE_PARM_DESC(max_devs, "Specify the maximum number of physical devices. " - "[Default=" __stringify(IPR_DEFAULT_SIS64_DEVS) "]"); MODULE_LICENSE("GPL"); MODULE_VERSION(IPR_DRIVER_VERSION); @@ -224,20 +180,6 @@ struct ipr_error_table_t ipr_error_table[] = { "FFFE: Soft device bus error recovered by the IOA"}, {0x01088100, 0, IPR_DEFAULT_LOG_LEVEL, "4101: Soft device bus fabric error"}, - {0x01100100, 0, IPR_DEFAULT_LOG_LEVEL, - "FFFC: Logical block guard error recovered by the device"}, - {0x01100300, 0, IPR_DEFAULT_LOG_LEVEL, - "FFFC: Logical block reference tag error recovered by the device"}, - {0x01108300, 0, IPR_DEFAULT_LOG_LEVEL, - "4171: Recovered scatter list tag / sequence number error"}, - {0x01109000, 0, IPR_DEFAULT_LOG_LEVEL, - "FF3D: Recovered logical block CRC error on IOA to Host transfer"}, - {0x01109200, 0, IPR_DEFAULT_LOG_LEVEL, - "4171: Recovered logical block sequence number error on IOA to Host transfer"}, - {0x0110A000, 0, IPR_DEFAULT_LOG_LEVEL, - "FFFD: Recovered logical block reference tag error detected by the IOA"}, - {0x0110A100, 0, IPR_DEFAULT_LOG_LEVEL, - "FFFD: Logical block guard error recovered by the IOA"}, {0x01170600, 0, IPR_DEFAULT_LOG_LEVEL, "FFF9: Device sector reassign successful"}, {0x01170900, 0, IPR_DEFAULT_LOG_LEVEL, @@ -294,28 +236,12 @@ struct ipr_error_table_t ipr_error_table[] = { "3120: SCSI bus is not operational"}, {0x04088100, 0, IPR_DEFAULT_LOG_LEVEL, "4100: Hard device bus fabric error"}, - {0x04100100, 0, IPR_DEFAULT_LOG_LEVEL, - "310C: Logical block guard error detected by the device"}, - {0x04100300, 0, IPR_DEFAULT_LOG_LEVEL, - "310C: Logical block reference tag error detected by the device"}, - {0x04108300, 1, IPR_DEFAULT_LOG_LEVEL, - "4170: Scatter list tag / sequence number error"}, - {0x04109000, 1, IPR_DEFAULT_LOG_LEVEL, - "8150: Logical block CRC error on IOA to Host transfer"}, - {0x04109200, 1, IPR_DEFAULT_LOG_LEVEL, - "4170: Logical block sequence number error on IOA to Host transfer"}, - {0x0410A000, 0, IPR_DEFAULT_LOG_LEVEL, - "310D: Logical block reference tag error detected by the IOA"}, - {0x0410A100, 0, IPR_DEFAULT_LOG_LEVEL, - "310D: Logical block guard error detected by the IOA"}, {0x04118000, 0, IPR_DEFAULT_LOG_LEVEL, "9000: IOA reserved area data check"}, {0x04118100, 0, IPR_DEFAULT_LOG_LEVEL, "9001: IOA reserved area invalid data pattern"}, {0x04118200, 0, IPR_DEFAULT_LOG_LEVEL, "9002: IOA reserved area LRC error"}, - {0x04118300, 1, IPR_DEFAULT_LOG_LEVEL, - "Hardware Error, IOA metadata access error"}, {0x04320000, 0, IPR_DEFAULT_LOG_LEVEL, "102E: Out of alternate sectors for disk storage"}, {0x04330000, 1, IPR_DEFAULT_LOG_LEVEL, @@ -380,8 +306,6 @@ struct ipr_error_table_t ipr_error_table[] = { "Illegal request, commands not allowed to this device"}, {0x05258100, 0, 0, "Illegal request, command not allowed to a secondary adapter"}, - {0x05258200, 0, 0, - "Illegal request, command not allowed to a non-optimized resource"}, {0x05260000, 0, 0, "Illegal request, invalid field in parameter list"}, {0x05260100, 0, 0, @@ -544,10 +468,7 @@ static void ipr_trc_hook(struct ipr_cmnd *ipr_cmd, trace_entry->time = jiffies; trace_entry->op_code = ipr_cmd->ioarcb.cmd_pkt.cdb[0]; trace_entry->type = type; - if (ipr_cmd->ioa_cfg->sis64) - trace_entry->ata_op_code = ipr_cmd->i.ata_ioadl.regs.command; - else - trace_entry->ata_op_code = ipr_cmd->ioarcb.u.add_data.u.regs.command; + trace_entry->ata_op_code = ipr_cmd->ioarcb.add_data.u.regs.command; trace_entry->cmd_index = ipr_cmd->cmd_index & 0xff; trace_entry->res_handle = ipr_cmd->ioarcb.res_handle; trace_entry->u.add_data = add_data; @@ -567,23 +488,16 @@ static void ipr_reinit_ipr_cmnd(struct ipr_cmnd *ipr_cmd) { struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb; struct ipr_ioasa *ioasa = &ipr_cmd->ioasa; - dma_addr_t dma_addr = ipr_cmd->dma_addr; + dma_addr_t dma_addr = be32_to_cpu(ioarcb->ioarcb_host_pci_addr); memset(&ioarcb->cmd_pkt, 0, sizeof(struct ipr_cmd_pkt)); - ioarcb->data_transfer_length = 0; + ioarcb->write_data_transfer_length = 0; ioarcb->read_data_transfer_length = 0; - ioarcb->ioadl_len = 0; + ioarcb->write_ioadl_len = 0; ioarcb->read_ioadl_len = 0; - - if (ipr_cmd->ioa_cfg->sis64) - ioarcb->u.sis64_addr_data.data_ioadl_addr = - cpu_to_be64(dma_addr + offsetof(struct ipr_cmnd, i.ioadl64)); - else { - ioarcb->write_ioadl_addr = - cpu_to_be32(dma_addr + offsetof(struct ipr_cmnd, i.ioadl)); - ioarcb->read_ioadl_addr = ioarcb->write_ioadl_addr; - } - + ioarcb->write_ioadl_addr = + cpu_to_be32(dma_addr + offsetof(struct ipr_cmnd, ioadl)); + ioarcb->read_ioadl_addr = ioarcb->write_ioadl_addr; ioasa->ioasc = 0; ioasa->residual_data_len = 0; ioasa->u.gata.status = 0; @@ -648,15 +562,10 @@ static void ipr_mask_and_clear_interrupts(struct ipr_ioa_cfg *ioa_cfg, ioa_cfg->allow_interrupts = 0; /* Set interrupt mask to stop all new interrupts */ - if (ioa_cfg->sis64) - writeq(~0, ioa_cfg->regs.set_interrupt_mask_reg); - else - writel(~0, ioa_cfg->regs.set_interrupt_mask_reg); + writel(~0, ioa_cfg->regs.set_interrupt_mask_reg); /* Clear any pending interrupts */ - if (ioa_cfg->sis64) - writel(~0, ioa_cfg->regs.clr_interrupt_reg); - writel(clr_ints, ioa_cfg->regs.clr_interrupt_reg32); + writel(clr_ints, ioa_cfg->regs.clr_interrupt_reg); int_reg = readl(ioa_cfg->regs.sense_interrupt_reg); } @@ -783,35 +692,6 @@ static void ipr_fail_all_ops(struct ipr_ioa_cfg *ioa_cfg) LEAVE; } -/** - * ipr_send_command - Send driver initiated requests. - * @ipr_cmd: ipr command struct - * - * This function sends a command to the adapter using the correct write call. - * In the case of sis64, calculate the ioarcb size required. Then or in the - * appropriate bits. - * - * Return value: - * none - **/ -static void ipr_send_command(struct ipr_cmnd *ipr_cmd) -{ - struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; - dma_addr_t send_dma_addr = ipr_cmd->dma_addr; - - if (ioa_cfg->sis64) { - /* The default size is 256 bytes */ - send_dma_addr |= 0x1; - - /* If the number of ioadls * size of ioadl > 128 bytes, - then use a 512 byte ioarcb */ - if (ipr_cmd->dma_use_sg * sizeof(struct ipr_ioadl64_desc) > 128 ) - send_dma_addr |= 0x4; - writeq(send_dma_addr, ioa_cfg->regs.ioarrin_reg); - } else - writel(send_dma_addr, ioa_cfg->regs.ioarrin_reg); -} - /** * ipr_do_req - Send driver initiated requests. * @ipr_cmd: ipr command struct @@ -844,8 +724,8 @@ static void ipr_do_req(struct ipr_cmnd *ipr_cmd, ipr_trc_hook(ipr_cmd, IPR_TRACE_START, 0); mb(); - - ipr_send_command(ipr_cmd); + writel(be32_to_cpu(ipr_cmd->ioarcb.ioarcb_host_pci_addr), + ioa_cfg->regs.ioarrin_reg); } /** @@ -866,51 +746,6 @@ static void ipr_internal_cmd_done(struct ipr_cmnd *ipr_cmd) complete(&ipr_cmd->completion); } -/** - * ipr_init_ioadl - initialize the ioadl for the correct SIS type - * @ipr_cmd: ipr command struct - * @dma_addr: dma address - * @len: transfer length - * @flags: ioadl flag value - * - * This function initializes an ioadl in the case where there is only a single - * descriptor. - * - * Return value: - * nothing - **/ -static void ipr_init_ioadl(struct ipr_cmnd *ipr_cmd, dma_addr_t dma_addr, - u32 len, int flags) -{ - struct ipr_ioadl_desc *ioadl = ipr_cmd->i.ioadl; - struct ipr_ioadl64_desc *ioadl64 = ipr_cmd->i.ioadl64; - - ipr_cmd->dma_use_sg = 1; - - if (ipr_cmd->ioa_cfg->sis64) { - ioadl64->flags = cpu_to_be32(flags); - ioadl64->data_len = cpu_to_be32(len); - ioadl64->address = cpu_to_be64(dma_addr); - - ipr_cmd->ioarcb.ioadl_len = - cpu_to_be32(sizeof(struct ipr_ioadl64_desc)); - ipr_cmd->ioarcb.data_transfer_length = cpu_to_be32(len); - } else { - ioadl->flags_and_data_len = cpu_to_be32(flags | len); - ioadl->address = cpu_to_be32(dma_addr); - - if (flags == IPR_IOADL_FLAGS_READ_LAST) { - ipr_cmd->ioarcb.read_ioadl_len = - cpu_to_be32(sizeof(struct ipr_ioadl_desc)); - ipr_cmd->ioarcb.read_data_transfer_length = cpu_to_be32(len); - } else { - ipr_cmd->ioarcb.ioadl_len = - cpu_to_be32(sizeof(struct ipr_ioadl_desc)); - ipr_cmd->ioarcb.data_transfer_length = cpu_to_be32(len); - } - } -} - /** * ipr_send_blocking_cmd - Send command and sleep on its completion. * @ipr_cmd: ipr command struct @@ -968,8 +803,11 @@ static void ipr_send_hcam(struct ipr_ioa_cfg *ioa_cfg, u8 type, ioarcb->cmd_pkt.cdb[7] = (sizeof(hostrcb->hcam) >> 8) & 0xff; ioarcb->cmd_pkt.cdb[8] = sizeof(hostrcb->hcam) & 0xff; - ipr_init_ioadl(ipr_cmd, hostrcb->hostrcb_dma, - sizeof(hostrcb->hcam), IPR_IOADL_FLAGS_READ_LAST); + ioarcb->read_data_transfer_length = cpu_to_be32(sizeof(hostrcb->hcam)); + ioarcb->read_ioadl_len = cpu_to_be32(sizeof(struct ipr_ioadl_desc)); + ipr_cmd->ioadl[0].flags_and_data_len = + cpu_to_be32(IPR_IOADL_FLAGS_READ_LAST | sizeof(hostrcb->hcam)); + ipr_cmd->ioadl[0].address = cpu_to_be32(hostrcb->hostrcb_dma); if (type == IPR_HCAM_CDB_OP_CODE_CONFIG_CHANGE) ipr_cmd->done = ipr_process_ccn; @@ -979,54 +817,22 @@ static void ipr_send_hcam(struct ipr_ioa_cfg *ioa_cfg, u8 type, ipr_trc_hook(ipr_cmd, IPR_TRACE_START, IPR_IOA_RES_ADDR); mb(); - - ipr_send_command(ipr_cmd); + writel(be32_to_cpu(ipr_cmd->ioarcb.ioarcb_host_pci_addr), + ioa_cfg->regs.ioarrin_reg); } else { list_add_tail(&hostrcb->queue, &ioa_cfg->hostrcb_free_q); } } -/** - * ipr_update_ata_class - Update the ata class in the resource entry - * @res: resource entry struct - * @proto: cfgte device bus protocol value - * - * Return value: - * none - **/ -static void ipr_update_ata_class(struct ipr_resource_entry *res, unsigned int proto) -{ - switch(proto) { - case IPR_PROTO_SATA: - case IPR_PROTO_SAS_STP: - res->ata_class = ATA_DEV_ATA; - break; - case IPR_PROTO_SATA_ATAPI: - case IPR_PROTO_SAS_STP_ATAPI: - res->ata_class = ATA_DEV_ATAPI; - break; - default: - res->ata_class = ATA_DEV_UNKNOWN; - break; - }; -} - /** * ipr_init_res_entry - Initialize a resource entry struct. * @res: resource entry struct - * @cfgtew: config table entry wrapper struct * * Return value: * none **/ -static void ipr_init_res_entry(struct ipr_resource_entry *res, - struct ipr_config_table_entry_wrapper *cfgtew) +static void ipr_init_res_entry(struct ipr_resource_entry *res) { - int found = 0; - unsigned int proto; - struct ipr_ioa_cfg *ioa_cfg = res->ioa_cfg; - struct ipr_resource_entry *gscsi_res = NULL; - res->needs_sync_complete = 0; res->in_erp = 0; res->add_to_ml = 0; @@ -1034,205 +840,6 @@ static void ipr_init_res_entry(struct ipr_resource_entry *res, res->resetting_device = 0; res->sdev = NULL; res->sata_port = NULL; - - if (ioa_cfg->sis64) { - proto = cfgtew->u.cfgte64->proto; - res->res_flags = cfgtew->u.cfgte64->res_flags; - res->qmodel = IPR_QUEUEING_MODEL64(res); - res->type = cfgtew->u.cfgte64->res_type & 0x0f; - - memcpy(res->res_path, &cfgtew->u.cfgte64->res_path, - sizeof(res->res_path)); - - res->bus = 0; - res->lun = scsilun_to_int(&res->dev_lun); - - if (res->type == IPR_RES_TYPE_GENERIC_SCSI) { - list_for_each_entry(gscsi_res, &ioa_cfg->used_res_q, queue) { - if (gscsi_res->dev_id == cfgtew->u.cfgte64->dev_id) { - found = 1; - res->target = gscsi_res->target; - break; - } - } - if (!found) { - res->target = find_first_zero_bit(ioa_cfg->target_ids, - ioa_cfg->max_devs_supported); - set_bit(res->target, ioa_cfg->target_ids); - } - - memcpy(&res->dev_lun.scsi_lun, &cfgtew->u.cfgte64->lun, - sizeof(res->dev_lun.scsi_lun)); - } else if (res->type == IPR_RES_TYPE_IOAFP) { - res->bus = IPR_IOAFP_VIRTUAL_BUS; - res->target = 0; - } else if (res->type == IPR_RES_TYPE_ARRAY) { - res->bus = IPR_ARRAY_VIRTUAL_BUS; - res->target = find_first_zero_bit(ioa_cfg->array_ids, - ioa_cfg->max_devs_supported); - set_bit(res->target, ioa_cfg->array_ids); - } else if (res->type == IPR_RES_TYPE_VOLUME_SET) { - res->bus = IPR_VSET_VIRTUAL_BUS; - res->target = find_first_zero_bit(ioa_cfg->vset_ids, - ioa_cfg->max_devs_supported); - set_bit(res->target, ioa_cfg->vset_ids); - } else { - res->target = find_first_zero_bit(ioa_cfg->target_ids, - ioa_cfg->max_devs_supported); - set_bit(res->target, ioa_cfg->target_ids); - } - } else { - proto = cfgtew->u.cfgte->proto; - res->qmodel = IPR_QUEUEING_MODEL(res); - res->flags = cfgtew->u.cfgte->flags; - if (res->flags & IPR_IS_IOA_RESOURCE) - res->type = IPR_RES_TYPE_IOAFP; - else - res->type = cfgtew->u.cfgte->rsvd_subtype & 0x0f; - - res->bus = cfgtew->u.cfgte->res_addr.bus; - res->target = cfgtew->u.cfgte->res_addr.target; - res->lun = cfgtew->u.cfgte->res_addr.lun; - } - - ipr_update_ata_class(res, proto); -} - -/** - * ipr_is_same_device - Determine if two devices are the same. - * @res: resource entry struct - * @cfgtew: config table entry wrapper struct - * - * Return value: - * 1 if the devices are the same / 0 otherwise - **/ -static int ipr_is_same_device(struct ipr_resource_entry *res, - struct ipr_config_table_entry_wrapper *cfgtew) -{ - if (res->ioa_cfg->sis64) { - if (!memcmp(&res->dev_id, &cfgtew->u.cfgte64->dev_id, - sizeof(cfgtew->u.cfgte64->dev_id)) && - !memcmp(&res->lun, &cfgtew->u.cfgte64->lun, - sizeof(cfgtew->u.cfgte64->lun))) { - return 1; - } - } else { - if (res->bus == cfgtew->u.cfgte->res_addr.bus && - res->target == cfgtew->u.cfgte->res_addr.target && - res->lun == cfgtew->u.cfgte->res_addr.lun) - return 1; - } - - return 0; -} - -/** - * ipr_format_resource_path - Format the resource path for printing. - * @res_path: resource path - * @buf: buffer - * - * Return value: - * pointer to buffer - **/ -static char *ipr_format_resource_path(u8 *res_path, char *buffer) -{ - int i; - - sprintf(buffer, "%02X", res_path[0]); - for (i=1; res_path[i] != 0xff; i++) - sprintf(buffer, "%s-%02X", buffer, res_path[i]); - - return buffer; -} - -/** - * ipr_update_res_entry - Update the resource entry. - * @res: resource entry struct - * @cfgtew: config table entry wrapper struct - * - * Return value: - * none - **/ -static void ipr_update_res_entry(struct ipr_resource_entry *res, - struct ipr_config_table_entry_wrapper *cfgtew) -{ - char buffer[IPR_MAX_RES_PATH_LENGTH]; - unsigned int proto; - int new_path = 0; - - if (res->ioa_cfg->sis64) { - res->flags = cfgtew->u.cfgte64->flags; - res->res_flags = cfgtew->u.cfgte64->res_flags; - res->type = cfgtew->u.cfgte64->res_type & 0x0f; - - memcpy(&res->std_inq_data, &cfgtew->u.cfgte64->std_inq_data, - sizeof(struct ipr_std_inq_data)); - - res->qmodel = IPR_QUEUEING_MODEL64(res); - proto = cfgtew->u.cfgte64->proto; - res->res_handle = cfgtew->u.cfgte64->res_handle; - res->dev_id = cfgtew->u.cfgte64->dev_id; - - memcpy(&res->dev_lun.scsi_lun, &cfgtew->u.cfgte64->lun, - sizeof(res->dev_lun.scsi_lun)); - - if (memcmp(res->res_path, &cfgtew->u.cfgte64->res_path, - sizeof(res->res_path))) { - memcpy(res->res_path, &cfgtew->u.cfgte64->res_path, - sizeof(res->res_path)); - new_path = 1; - } - - if (res->sdev && new_path) - sdev_printk(KERN_INFO, res->sdev, "Resource path: %s\n", - ipr_format_resource_path(&res->res_path[0], &buffer[0])); - } else { - res->flags = cfgtew->u.cfgte->flags; - if (res->flags & IPR_IS_IOA_RESOURCE) - res->type = IPR_RES_TYPE_IOAFP; - else - res->type = cfgtew->u.cfgte->rsvd_subtype & 0x0f; - - memcpy(&res->std_inq_data, &cfgtew->u.cfgte->std_inq_data, - sizeof(struct ipr_std_inq_data)); - - res->qmodel = IPR_QUEUEING_MODEL(res); - proto = cfgtew->u.cfgte->proto; - res->res_handle = cfgtew->u.cfgte->res_handle; - } - - ipr_update_ata_class(res, proto); -} - -/** - * ipr_clear_res_target - Clear the bit in the bit map representing the target - * for the resource. - * @res: resource entry struct - * @cfgtew: config table entry wrapper struct - * - * Return value: - * none - **/ -static void ipr_clear_res_target(struct ipr_resource_entry *res) -{ - struct ipr_resource_entry *gscsi_res = NULL; - struct ipr_ioa_cfg *ioa_cfg = res->ioa_cfg; - - if (!ioa_cfg->sis64) - return; - - if (res->bus == IPR_ARRAY_VIRTUAL_BUS) - clear_bit(res->target, ioa_cfg->array_ids); - else if (res->bus == IPR_VSET_VIRTUAL_BUS) - clear_bit(res->target, ioa_cfg->vset_ids); - else if (res->bus == 0 && res->type == IPR_RES_TYPE_GENERIC_SCSI) { - list_for_each_entry(gscsi_res, &ioa_cfg->used_res_q, queue) - if (gscsi_res->dev_id == res->dev_id && gscsi_res != res) - return; - clear_bit(res->target, ioa_cfg->target_ids); - - } else if (res->bus == 0) - clear_bit(res->target, ioa_cfg->target_ids); } /** @@ -1244,24 +851,17 @@ static void ipr_clear_res_target(struct ipr_resource_entry *res) * none **/ static void ipr_handle_config_change(struct ipr_ioa_cfg *ioa_cfg, - struct ipr_hostrcb *hostrcb) + struct ipr_hostrcb *hostrcb) { struct ipr_resource_entry *res = NULL; - struct ipr_config_table_entry_wrapper cfgtew; - __be32 cc_res_handle; - + struct ipr_config_table_entry *cfgte; u32 is_ndn = 1; - if (ioa_cfg->sis64) { - cfgtew.u.cfgte64 = &hostrcb->hcam.u.ccn.u.cfgte64; - cc_res_handle = cfgtew.u.cfgte64->res_handle; - } else { - cfgtew.u.cfgte = &hostrcb->hcam.u.ccn.u.cfgte; - cc_res_handle = cfgtew.u.cfgte->res_handle; - } + cfgte = &hostrcb->hcam.u.ccn.cfgte; list_for_each_entry(res, &ioa_cfg->used_res_q, queue) { - if (res->res_handle == cc_res_handle) { + if (!memcmp(&res->cfgte.res_addr, &cfgte->res_addr, + sizeof(cfgte->res_addr))) { is_ndn = 0; break; } @@ -1279,22 +879,20 @@ static void ipr_handle_config_change(struct ipr_ioa_cfg *ioa_cfg, struct ipr_resource_entry, queue); list_del(&res->queue); - ipr_init_res_entry(res, &cfgtew); + ipr_init_res_entry(res); list_add_tail(&res->queue, &ioa_cfg->used_res_q); } - ipr_update_res_entry(res, &cfgtew); + memcpy(&res->cfgte, cfgte, sizeof(struct ipr_config_table_entry)); if (hostrcb->hcam.notify_type == IPR_HOST_RCB_NOTIF_TYPE_REM_ENTRY) { if (res->sdev) { res->del_from_ml = 1; - res->res_handle = IPR_INVALID_RES_HANDLE; + res->cfgte.res_handle = IPR_INVALID_RES_HANDLE; if (ioa_cfg->allow_ml_add_del) schedule_work(&ioa_cfg->work_q); - } else { - ipr_clear_res_target(res); + } else list_move_tail(&res->queue, &ioa_cfg->free_res_q); - } } else if (!res->sdev) { res->add_to_ml = 1; if (ioa_cfg->allow_ml_add_del) @@ -1446,12 +1044,8 @@ static void ipr_log_ext_vpd(struct ipr_ext_vpd *vpd) static void ipr_log_enhanced_cache_error(struct ipr_ioa_cfg *ioa_cfg, struct ipr_hostrcb *hostrcb) { - struct ipr_hostrcb_type_12_error *error; - - if (ioa_cfg->sis64) - error = &hostrcb->hcam.u.error64.u.type_12_error; - else - error = &hostrcb->hcam.u.error.u.type_12_error; + struct ipr_hostrcb_type_12_error *error = + &hostrcb->hcam.u.error.u.type_12_error; ipr_err("-----Current Configuration-----\n"); ipr_err("Cache Directory Card Information:\n"); @@ -1543,48 +1137,6 @@ static void ipr_log_enhanced_config_error(struct ipr_ioa_cfg *ioa_cfg, } } -/** - * ipr_log_sis64_config_error - Log a device error. - * @ioa_cfg: ioa config struct - * @hostrcb: hostrcb struct - * - * Return value: - * none - **/ -static void ipr_log_sis64_config_error(struct ipr_ioa_cfg *ioa_cfg, - struct ipr_hostrcb *hostrcb) -{ - int errors_logged, i; - struct ipr_hostrcb64_device_data_entry_enhanced *dev_entry; - struct ipr_hostrcb_type_23_error *error; - char buffer[IPR_MAX_RES_PATH_LENGTH]; - - error = &hostrcb->hcam.u.error64.u.type_23_error; - errors_logged = be32_to_cpu(error->errors_logged); - - ipr_err("Device Errors Detected/Logged: %d/%d\n", - be32_to_cpu(error->errors_detected), errors_logged); - - dev_entry = error->dev; - - for (i = 0; i < errors_logged; i++, dev_entry++) { - ipr_err_separator; - - ipr_err("Device %d : %s", i + 1, - ipr_format_resource_path(&dev_entry->res_path[0], &buffer[0])); - ipr_log_ext_vpd(&dev_entry->vpd); - - ipr_err("-----New Device Information-----\n"); - ipr_log_ext_vpd(&dev_entry->new_vpd); - - ipr_err("Cache Directory Card Information:\n"); - ipr_log_ext_vpd(&dev_entry->ioa_last_with_dev_vpd); - - ipr_err("Adapter Card Information:\n"); - ipr_log_ext_vpd(&dev_entry->cfc_last_with_dev_vpd); - } -} - /** * ipr_log_config_error - Log a configuration error. * @ioa_cfg: ioa config struct @@ -1779,11 +1331,7 @@ static void ipr_log_enhanced_dual_ioa_error(struct ipr_ioa_cfg *ioa_cfg, { struct ipr_hostrcb_type_17_error *error; - if (ioa_cfg->sis64) - error = &hostrcb->hcam.u.error64.u.type_17_error; - else - error = &hostrcb->hcam.u.error.u.type_17_error; - + error = &hostrcb->hcam.u.error.u.type_17_error; error->failure_reason[sizeof(error->failure_reason) - 1] = '\0'; strim(error->failure_reason); @@ -1890,42 +1438,6 @@ static void ipr_log_fabric_path(struct ipr_hostrcb *hostrcb, fabric->ioa_port, fabric->cascaded_expander, fabric->phy); } -/** - * ipr_log64_fabric_path - Log a fabric path error - * @hostrcb: hostrcb struct - * @fabric: fabric descriptor - * - * Return value: - * none - **/ -static void ipr_log64_fabric_path(struct ipr_hostrcb *hostrcb, - struct ipr_hostrcb64_fabric_desc *fabric) -{ - int i, j; - u8 path_state = fabric->path_state; - u8 active = path_state & IPR_PATH_ACTIVE_MASK; - u8 state = path_state & IPR_PATH_STATE_MASK; - char buffer[IPR_MAX_RES_PATH_LENGTH]; - - for (i = 0; i < ARRAY_SIZE(path_active_desc); i++) { - if (path_active_desc[i].active != active) - continue; - - for (j = 0; j < ARRAY_SIZE(path_state_desc); j++) { - if (path_state_desc[j].state != state) - continue; - - ipr_hcam_err(hostrcb, "%s %s: Resource Path=%s\n", - path_active_desc[i].desc, path_state_desc[j].desc, - ipr_format_resource_path(&fabric->res_path[0], &buffer[0])); - return; - } - } - - ipr_err("Path state=%02X Resource Path=%s\n", path_state, - ipr_format_resource_path(&fabric->res_path[0], &buffer[0])); -} - static const struct { u8 type; char *desc; @@ -2034,49 +1546,6 @@ static void ipr_log_path_elem(struct ipr_hostrcb *hostrcb, be32_to_cpu(cfg->wwid[0]), be32_to_cpu(cfg->wwid[1])); } -/** - * ipr_log64_path_elem - Log a fabric path element. - * @hostrcb: hostrcb struct - * @cfg: fabric path element struct - * - * Return value: - * none - **/ -static void ipr_log64_path_elem(struct ipr_hostrcb *hostrcb, - struct ipr_hostrcb64_config_element *cfg) -{ - int i, j; - u8 desc_id = cfg->descriptor_id & IPR_DESCRIPTOR_MASK; - u8 type = cfg->type_status & IPR_PATH_CFG_TYPE_MASK; - u8 status = cfg->type_status & IPR_PATH_CFG_STATUS_MASK; - char buffer[IPR_MAX_RES_PATH_LENGTH]; - - if (type == IPR_PATH_CFG_NOT_EXIST || desc_id != IPR_DESCRIPTOR_SIS64) - return; - - for (i = 0; i < ARRAY_SIZE(path_type_desc); i++) { - if (path_type_desc[i].type != type) - continue; - - for (j = 0; j < ARRAY_SIZE(path_status_desc); j++) { - if (path_status_desc[j].status != status) - continue; - - ipr_hcam_err(hostrcb, "%s %s: Resource Path=%s, Link rate=%s, WWN=%08X%08X\n", - path_status_desc[j].desc, path_type_desc[i].desc, - ipr_format_resource_path(&cfg->res_path[0], &buffer[0]), - link_rate[cfg->link_rate & IPR_PHY_LINK_RATE_MASK], - be32_to_cpu(cfg->wwid[0]), be32_to_cpu(cfg->wwid[1])); - return; - } - } - ipr_hcam_err(hostrcb, "Path element=%02X: Resource Path=%s, Link rate=%s " - "WWN=%08X%08X\n", cfg->type_status, - ipr_format_resource_path(&cfg->res_path[0], &buffer[0]), - link_rate[cfg->link_rate & IPR_PHY_LINK_RATE_MASK], - be32_to_cpu(cfg->wwid[0]), be32_to_cpu(cfg->wwid[1])); -} - /** * ipr_log_fabric_error - Log a fabric error. * @ioa_cfg: ioa config struct @@ -2114,96 +1583,6 @@ static void ipr_log_fabric_error(struct ipr_ioa_cfg *ioa_cfg, ipr_log_hex_data(ioa_cfg, (u32 *)fabric, add_len); } -/** - * ipr_log_sis64_array_error - Log a sis64 array error. - * @ioa_cfg: ioa config struct - * @hostrcb: hostrcb struct - * - * Return value: - * none - **/ -static void ipr_log_sis64_array_error(struct ipr_ioa_cfg *ioa_cfg, - struct ipr_hostrcb *hostrcb) -{ - int i, num_entries; - struct ipr_hostrcb_type_24_error *error; - struct ipr_hostrcb64_array_data_entry *array_entry; - char buffer[IPR_MAX_RES_PATH_LENGTH]; - const u8 zero_sn[IPR_SERIAL_NUM_LEN] = { [0 ... IPR_SERIAL_NUM_LEN-1] = '0' }; - - error = &hostrcb->hcam.u.error64.u.type_24_error; - - ipr_err_separator; - - ipr_err("RAID %s Array Configuration: %s\n", - error->protection_level, - ipr_format_resource_path(&error->last_res_path[0], &buffer[0])); - - ipr_err_separator; - - array_entry = error->array_member; - num_entries = min_t(u32, be32_to_cpu(error->num_entries), - sizeof(error->array_member)); - - for (i = 0; i < num_entries; i++, array_entry++) { - - if (!memcmp(array_entry->vpd.vpd.sn, zero_sn, IPR_SERIAL_NUM_LEN)) - continue; - - if (error->exposed_mode_adn == i) - ipr_err("Exposed Array Member %d:\n", i); - else - ipr_err("Array Member %d:\n", i); - - ipr_err("Array Member %d:\n", i); - ipr_log_ext_vpd(&array_entry->vpd); - ipr_err("Current Location: %s", - ipr_format_resource_path(&array_entry->res_path[0], &buffer[0])); - ipr_err("Expected Location: %s", - ipr_format_resource_path(&array_entry->expected_res_path[0], &buffer[0])); - - ipr_err_separator; - } -} - -/** - * ipr_log_sis64_fabric_error - Log a sis64 fabric error. - * @ioa_cfg: ioa config struct - * @hostrcb: hostrcb struct - * - * Return value: - * none - **/ -static void ipr_log_sis64_fabric_error(struct ipr_ioa_cfg *ioa_cfg, - struct ipr_hostrcb *hostrcb) -{ - struct ipr_hostrcb_type_30_error *error; - struct ipr_hostrcb64_fabric_desc *fabric; - struct ipr_hostrcb64_config_element *cfg; - int i, add_len; - - error = &hostrcb->hcam.u.error64.u.type_30_error; - - error->failure_reason[sizeof(error->failure_reason) - 1] = '\0'; - ipr_hcam_err(hostrcb, "%s\n", error->failure_reason); - - add_len = be32_to_cpu(hostrcb->hcam.length) - - (offsetof(struct ipr_hostrcb64_error, u) + - offsetof(struct ipr_hostrcb_type_30_error, desc)); - - for (i = 0, fabric = error->desc; i < error->num_entries; i++) { - ipr_log64_fabric_path(hostrcb, fabric); - for_each_fabric_cfg(fabric, cfg) - ipr_log64_path_elem(hostrcb, cfg); - - add_len -= be16_to_cpu(fabric->length); - fabric = (struct ipr_hostrcb64_fabric_desc *) - ((unsigned long)fabric + be16_to_cpu(fabric->length)); - } - - ipr_log_hex_data(ioa_cfg, (u32 *)fabric, add_len); -} - /** * ipr_log_generic_error - Log an adapter error. * @ioa_cfg: ioa config struct @@ -2263,16 +1642,13 @@ static void ipr_handle_log_data(struct ipr_ioa_cfg *ioa_cfg, if (hostrcb->hcam.notifications_lost == IPR_HOST_RCB_NOTIFICATIONS_LOST) dev_err(&ioa_cfg->pdev->dev, "Error notifications lost\n"); - if (ioa_cfg->sis64) - ioasc = be32_to_cpu(hostrcb->hcam.u.error64.fd_ioasc); - else - ioasc = be32_to_cpu(hostrcb->hcam.u.error.fd_ioasc); + ioasc = be32_to_cpu(hostrcb->hcam.u.error.failing_dev_ioasc); - if (!ioa_cfg->sis64 && (ioasc == IPR_IOASC_BUS_WAS_RESET || - ioasc == IPR_IOASC_BUS_WAS_RESET_BY_OTHER)) { + if (ioasc == IPR_IOASC_BUS_WAS_RESET || + ioasc == IPR_IOASC_BUS_WAS_RESET_BY_OTHER) { /* Tell the midlayer we had a bus reset so it will handle the UA properly */ scsi_report_bus_reset(ioa_cfg->host, - hostrcb->hcam.u.error.fd_res_addr.bus); + hostrcb->hcam.u.error.failing_dev_res_addr.bus); } error_index = ipr_get_error(ioasc); @@ -2320,16 +1696,6 @@ static void ipr_handle_log_data(struct ipr_ioa_cfg *ioa_cfg, case IPR_HOST_RCB_OVERLAY_ID_20: ipr_log_fabric_error(ioa_cfg, hostrcb); break; - case IPR_HOST_RCB_OVERLAY_ID_23: - ipr_log_sis64_config_error(ioa_cfg, hostrcb); - break; - case IPR_HOST_RCB_OVERLAY_ID_24: - case IPR_HOST_RCB_OVERLAY_ID_26: - ipr_log_sis64_array_error(ioa_cfg, hostrcb); - break; - case IPR_HOST_RCB_OVERLAY_ID_30: - ipr_log_sis64_fabric_error(ioa_cfg, hostrcb); - break; case IPR_HOST_RCB_OVERLAY_ID_1: case IPR_HOST_RCB_OVERLAY_ID_DEFAULT: default: @@ -2354,12 +1720,7 @@ static void ipr_process_error(struct ipr_cmnd *ipr_cmd) struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; struct ipr_hostrcb *hostrcb = ipr_cmd->u.hostrcb; u32 ioasc = be32_to_cpu(ipr_cmd->ioasa.ioasc); - u32 fd_ioasc; - - if (ioa_cfg->sis64) - fd_ioasc = be32_to_cpu(hostrcb->hcam.u.error64.fd_ioasc); - else - fd_ioasc = be32_to_cpu(hostrcb->hcam.u.error.fd_ioasc); + u32 fd_ioasc = be32_to_cpu(hostrcb->hcam.u.error.failing_dev_ioasc); list_del(&hostrcb->queue); list_add_tail(&ipr_cmd->queue, &ioa_cfg->free_q); @@ -2484,14 +1845,12 @@ static const struct ipr_ses_table_entry * ipr_find_ses_entry(struct ipr_resource_entry *res) { int i, j, matches; - struct ipr_std_inq_vpids *vpids; const struct ipr_ses_table_entry *ste = ipr_ses_table; for (i = 0; i < ARRAY_SIZE(ipr_ses_table); i++, ste++) { for (j = 0, matches = 0; j < IPR_PROD_ID_LEN; j++) { if (ste->compare_product_id_byte[j] == 'X') { - vpids = &res->std_inq_data.vpids; - if (vpids->product_id[j] == ste->product_id[j]) + if (res->cfgte.std_inq_data.vpids.product_id[j] == ste->product_id[j]) matches++; else break; @@ -2526,10 +1885,10 @@ static u32 ipr_get_max_scsi_speed(struct ipr_ioa_cfg *ioa_cfg, u8 bus, u8 bus_wi /* Loop through each config table entry in the config table buffer */ list_for_each_entry(res, &ioa_cfg->used_res_q, queue) { - if (!(IPR_IS_SES_DEVICE(res->std_inq_data))) + if (!(IPR_IS_SES_DEVICE(res->cfgte.std_inq_data))) continue; - if (bus != res->bus) + if (bus != res->cfgte.res_addr.bus) continue; if (!(ste = ipr_find_ses_entry(res))) @@ -2574,31 +1933,6 @@ static int ipr_wait_iodbg_ack(struct ipr_ioa_cfg *ioa_cfg, int max_delay) return -EIO; } -/** - * ipr_get_sis64_dump_data_section - Dump IOA memory - * @ioa_cfg: ioa config struct - * @start_addr: adapter address to dump - * @dest: destination kernel buffer - * @length_in_words: length to dump in 4 byte words - * - * Return value: - * 0 on success - **/ -static int ipr_get_sis64_dump_data_section(struct ipr_ioa_cfg *ioa_cfg, - u32 start_addr, - __be32 *dest, u32 length_in_words) -{ - int i; - - for (i = 0; i < length_in_words; i++) { - writel(start_addr+(i*4), ioa_cfg->regs.dump_addr_reg); - *dest = cpu_to_be32(readl(ioa_cfg->regs.dump_data_reg)); - dest++; - } - - return 0; -} - /** * ipr_get_ldump_data_section - Dump IOA memory * @ioa_cfg: ioa config struct @@ -2616,13 +1950,9 @@ static int ipr_get_ldump_data_section(struct ipr_ioa_cfg *ioa_cfg, volatile u32 temp_pcii_reg; int i, delay = 0; - if (ioa_cfg->sis64) - return ipr_get_sis64_dump_data_section(ioa_cfg, start_addr, - dest, length_in_words); - /* Write IOA interrupt reg starting LDUMP state */ writel((IPR_UPROCI_RESET_ALERT | IPR_UPROCI_IO_DEBUG_ALERT), - ioa_cfg->regs.set_uproc_interrupt_reg32); + ioa_cfg->regs.set_uproc_interrupt_reg); /* Wait for IO debug acknowledge */ if (ipr_wait_iodbg_ack(ioa_cfg, @@ -2641,7 +1971,7 @@ static int ipr_get_ldump_data_section(struct ipr_ioa_cfg *ioa_cfg, /* Signal address valid - clear IOA Reset alert */ writel(IPR_UPROCI_RESET_ALERT, - ioa_cfg->regs.clr_uproc_interrupt_reg32); + ioa_cfg->regs.clr_uproc_interrupt_reg); for (i = 0; i < length_in_words; i++) { /* Wait for IO debug acknowledge */ @@ -2666,10 +1996,10 @@ static int ipr_get_ldump_data_section(struct ipr_ioa_cfg *ioa_cfg, /* Signal end of block transfer. Set reset alert then clear IO debug ack */ writel(IPR_UPROCI_RESET_ALERT, - ioa_cfg->regs.set_uproc_interrupt_reg32); + ioa_cfg->regs.set_uproc_interrupt_reg); writel(IPR_UPROCI_IO_DEBUG_ALERT, - ioa_cfg->regs.clr_uproc_interrupt_reg32); + ioa_cfg->regs.clr_uproc_interrupt_reg); /* Signal dump data received - Clear IO debug Ack */ writel(IPR_PCII_IO_DEBUG_ACKNOWLEDGE, @@ -2678,7 +2008,7 @@ static int ipr_get_ldump_data_section(struct ipr_ioa_cfg *ioa_cfg, /* Wait for IOA to signal LDUMP exit - IOA reset alert will be cleared */ while (delay < IPR_LDUMP_MAX_SHORT_ACK_DELAY_IN_USEC) { temp_pcii_reg = - readl(ioa_cfg->regs.sense_uproc_interrupt_reg32); + readl(ioa_cfg->regs.sense_uproc_interrupt_reg); if (!(temp_pcii_reg & IPR_UPROCI_RESET_ALERT)) return 0; @@ -2877,7 +2207,6 @@ static void ipr_get_ioa_dump(struct ipr_ioa_cfg *ioa_cfg, struct ipr_dump *dump) u32 num_entries, start_off, end_off; u32 bytes_to_copy, bytes_copied, rc; struct ipr_sdt *sdt; - int valid = 1; int i; ENTER; @@ -2891,7 +2220,7 @@ static void ipr_get_ioa_dump(struct ipr_ioa_cfg *ioa_cfg, struct ipr_dump *dump) start_addr = readl(ioa_cfg->ioa_mailbox); - if (!ioa_cfg->sis64 && !ipr_sdt_is_fmt2(start_addr)) { + if (!ipr_sdt_is_fmt2(start_addr)) { dev_err(&ioa_cfg->pdev->dev, "Invalid dump table format: %lx\n", start_addr); spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); @@ -2920,6 +2249,7 @@ static void ipr_get_ioa_dump(struct ipr_ioa_cfg *ioa_cfg, struct ipr_dump *dump) /* IOA Dump entry */ ipr_init_dump_entry_hdr(&ioa_dump->hdr); + ioa_dump->format = IPR_SDT_FMT2; ioa_dump->hdr.len = 0; ioa_dump->hdr.data_type = IPR_DUMP_DATA_TYPE_BINARY; ioa_dump->hdr.id = IPR_DUMP_IOA_DUMP_ID; @@ -2934,8 +2264,7 @@ static void ipr_get_ioa_dump(struct ipr_ioa_cfg *ioa_cfg, struct ipr_dump *dump) sizeof(struct ipr_sdt) / sizeof(__be32)); /* Smart Dump table is ready to use and the first entry is valid */ - if (rc || ((be32_to_cpu(sdt->hdr.state) != IPR_FMT3_SDT_READY_TO_USE) && - (be32_to_cpu(sdt->hdr.state) != IPR_FMT2_SDT_READY_TO_USE))) { + if (rc || (be32_to_cpu(sdt->hdr.state) != IPR_FMT2_SDT_READY_TO_USE)) { dev_err(&ioa_cfg->pdev->dev, "Dump of IOA failed. Dump table not valid: %d, %X.\n", rc, be32_to_cpu(sdt->hdr.state)); @@ -2959,19 +2288,12 @@ static void ipr_get_ioa_dump(struct ipr_ioa_cfg *ioa_cfg, struct ipr_dump *dump) } if (sdt->entry[i].flags & IPR_SDT_VALID_ENTRY) { - sdt_word = be32_to_cpu(sdt->entry[i].start_token); - if (ioa_cfg->sis64) - bytes_to_copy = be32_to_cpu(sdt->entry[i].end_token); - else { - start_off = sdt_word & IPR_FMT2_MBX_ADDR_MASK; - end_off = be32_to_cpu(sdt->entry[i].end_token); - - if (ipr_sdt_is_fmt2(sdt_word) && sdt_word) - bytes_to_copy = end_off - start_off; - else - valid = 0; - } - if (valid) { + sdt_word = be32_to_cpu(sdt->entry[i].bar_str_offset); + start_off = sdt_word & IPR_FMT2_MBX_ADDR_MASK; + end_off = be32_to_cpu(sdt->entry[i].end_offset); + + if (ipr_sdt_is_fmt2(sdt_word) && sdt_word) { + bytes_to_copy = end_off - start_off; if (bytes_to_copy > IPR_MAX_IOA_DUMP_SIZE) { sdt->entry[i].flags &= ~IPR_SDT_VALID_ENTRY; continue; @@ -3100,9 +2422,9 @@ static void ipr_worker_thread(struct work_struct *work) list_for_each_entry(res, &ioa_cfg->used_res_q, queue) { if (res->add_to_ml) { - bus = res->bus; - target = res->target; - lun = res->lun; + bus = res->cfgte.res_addr.bus; + target = res->cfgte.res_addr.target; + lun = res->cfgte.res_addr.lun; res->add_to_ml = 0; spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); scsi_add_device(ioa_cfg->host, bus, target, lun); @@ -3156,6 +2478,105 @@ static struct bin_attribute ipr_trace_attr = { }; #endif +static const struct { + enum ipr_cache_state state; + char *name; +} cache_state [] = { + { CACHE_NONE, "none" }, + { CACHE_DISABLED, "disabled" }, + { CACHE_ENABLED, "enabled" } +}; + +/** + * ipr_show_write_caching - Show the write caching attribute + * @dev: device struct + * @buf: buffer + * + * Return value: + * number of bytes printed to buffer + **/ +static ssize_t ipr_show_write_caching(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct Scsi_Host *shost = class_to_shost(dev); + struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; + unsigned long lock_flags = 0; + int i, len = 0; + + spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); + for (i = 0; i < ARRAY_SIZE(cache_state); i++) { + if (cache_state[i].state == ioa_cfg->cache_state) { + len = snprintf(buf, PAGE_SIZE, "%s\n", cache_state[i].name); + break; + } + } + spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); + return len; +} + + +/** + * ipr_store_write_caching - Enable/disable adapter write cache + * @dev: device struct + * @buf: buffer + * @count: buffer size + * + * This function will enable/disable adapter write cache. + * + * Return value: + * count on success / other on failure + **/ +static ssize_t ipr_store_write_caching(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct Scsi_Host *shost = class_to_shost(dev); + struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; + unsigned long lock_flags = 0; + enum ipr_cache_state new_state = CACHE_INVALID; + int i; + + if (!capable(CAP_SYS_ADMIN)) + return -EACCES; + if (ioa_cfg->cache_state == CACHE_NONE) + return -EINVAL; + + for (i = 0; i < ARRAY_SIZE(cache_state); i++) { + if (!strncmp(cache_state[i].name, buf, strlen(cache_state[i].name))) { + new_state = cache_state[i].state; + break; + } + } + + if (new_state != CACHE_DISABLED && new_state != CACHE_ENABLED) + return -EINVAL; + + spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); + if (ioa_cfg->cache_state == new_state) { + spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); + return count; + } + + ioa_cfg->cache_state = new_state; + dev_info(&ioa_cfg->pdev->dev, "%s adapter write cache.\n", + new_state == CACHE_ENABLED ? "Enabling" : "Disabling"); + if (!ioa_cfg->in_reset_reload) + ipr_initiate_ioa_reset(ioa_cfg, IPR_SHUTDOWN_NORMAL); + spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); + wait_event(ioa_cfg->reset_wait_q, !ioa_cfg->in_reset_reload); + + return count; +} + +static struct device_attribute ipr_ioa_cache_attr = { + .attr = { + .name = "write_cache", + .mode = S_IRUGO | S_IWUSR, + }, + .show = ipr_show_write_caching, + .store = ipr_store_write_caching +}; + /** * ipr_show_fw_version - Show the firmware version * @dev: class device struct @@ -3554,37 +2975,6 @@ static int ipr_copy_ucode_buffer(struct ipr_sglist *sglist, return result; } -/** - * ipr_build_ucode_ioadl64 - Build a microcode download IOADL - * @ipr_cmd: ipr command struct - * @sglist: scatter/gather list - * - * Builds a microcode download IOA data list (IOADL). - * - **/ -static void ipr_build_ucode_ioadl64(struct ipr_cmnd *ipr_cmd, - struct ipr_sglist *sglist) -{ - struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb; - struct ipr_ioadl64_desc *ioadl64 = ipr_cmd->i.ioadl64; - struct scatterlist *scatterlist = sglist->scatterlist; - int i; - - ipr_cmd->dma_use_sg = sglist->num_dma_sg; - ioarcb->cmd_pkt.flags_hi |= IPR_FLAGS_HI_WRITE_NOT_READ; - ioarcb->data_transfer_length = cpu_to_be32(sglist->buffer_len); - - ioarcb->ioadl_len = - cpu_to_be32(sizeof(struct ipr_ioadl64_desc) * ipr_cmd->dma_use_sg); - for (i = 0; i < ipr_cmd->dma_use_sg; i++) { - ioadl64[i].flags = cpu_to_be32(IPR_IOADL_FLAGS_WRITE); - ioadl64[i].data_len = cpu_to_be32(sg_dma_len(&scatterlist[i])); - ioadl64[i].address = cpu_to_be64(sg_dma_address(&scatterlist[i])); - } - - ioadl64[i-1].flags |= cpu_to_be32(IPR_IOADL_FLAGS_LAST); -} - /** * ipr_build_ucode_ioadl - Build a microcode download IOADL * @ipr_cmd: ipr command struct @@ -3597,15 +2987,14 @@ static void ipr_build_ucode_ioadl(struct ipr_cmnd *ipr_cmd, struct ipr_sglist *sglist) { struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb; - struct ipr_ioadl_desc *ioadl = ipr_cmd->i.ioadl; + struct ipr_ioadl_desc *ioadl = ipr_cmd->ioadl; struct scatterlist *scatterlist = sglist->scatterlist; int i; ipr_cmd->dma_use_sg = sglist->num_dma_sg; ioarcb->cmd_pkt.flags_hi |= IPR_FLAGS_HI_WRITE_NOT_READ; - ioarcb->data_transfer_length = cpu_to_be32(sglist->buffer_len); - - ioarcb->ioadl_len = + ioarcb->write_data_transfer_length = cpu_to_be32(sglist->buffer_len); + ioarcb->write_ioadl_len = cpu_to_be32(sizeof(struct ipr_ioadl_desc) * ipr_cmd->dma_use_sg); for (i = 0; i < ipr_cmd->dma_use_sg; i++) { @@ -3757,6 +3146,7 @@ static struct device_attribute *ipr_ioa_attrs[] = { &ipr_ioa_state_attr, &ipr_ioa_reset_attr, &ipr_update_fw_attr, + &ipr_ioa_cache_attr, NULL, }; @@ -4060,7 +3450,7 @@ static ssize_t ipr_show_adapter_handle(struct device *dev, struct device_attribu spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); res = (struct ipr_resource_entry *)sdev->hostdata; if (res) - len = snprintf(buf, PAGE_SIZE, "%08X\n", res->res_handle); + len = snprintf(buf, PAGE_SIZE, "%08X\n", res->cfgte.res_handle); spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); return len; } @@ -4073,43 +3463,8 @@ static struct device_attribute ipr_adapter_handle_attr = { .show = ipr_show_adapter_handle }; -/** - * ipr_show_resource_path - Show the resource path for this device. - * @dev: device struct - * @buf: buffer - * - * Return value: - * number of bytes printed to buffer - **/ -static ssize_t ipr_show_resource_path(struct device *dev, struct device_attribute *attr, char *buf) -{ - struct scsi_device *sdev = to_scsi_device(dev); - struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)sdev->host->hostdata; - struct ipr_resource_entry *res; - unsigned long lock_flags = 0; - ssize_t len = -ENXIO; - char buffer[IPR_MAX_RES_PATH_LENGTH]; - - spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); - res = (struct ipr_resource_entry *)sdev->hostdata; - if (res) - len = snprintf(buf, PAGE_SIZE, "%s\n", - ipr_format_resource_path(&res->res_path[0], &buffer[0])); - spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); - return len; -} - -static struct device_attribute ipr_resource_path_attr = { - .attr = { - .name = "resource_path", - .mode = S_IRUSR, - }, - .show = ipr_show_resource_path -}; - static struct device_attribute *ipr_dev_attrs[] = { &ipr_adapter_handle_attr, - &ipr_resource_path_attr, NULL, }; @@ -4162,9 +3517,9 @@ static struct ipr_resource_entry *ipr_find_starget(struct scsi_target *starget) struct ipr_resource_entry *res; list_for_each_entry(res, &ioa_cfg->used_res_q, queue) { - if ((res->bus == starget->channel) && - (res->target == starget->id) && - (res->lun == 0)) { + if ((res->cfgte.res_addr.bus == starget->channel) && + (res->cfgte.res_addr.target == starget->id) && + (res->cfgte.res_addr.lun == 0)) { return res; } } @@ -4234,17 +3589,6 @@ static int ipr_target_alloc(struct scsi_target *starget) static void ipr_target_destroy(struct scsi_target *starget) { struct ipr_sata_port *sata_port = starget->hostdata; - struct Scsi_Host *shost = dev_to_shost(&starget->dev); - struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *) shost->hostdata; - - if (ioa_cfg->sis64) { - if (starget->channel == IPR_ARRAY_VIRTUAL_BUS) - clear_bit(starget->id, ioa_cfg->array_ids); - else if (starget->channel == IPR_VSET_VIRTUAL_BUS) - clear_bit(starget->id, ioa_cfg->vset_ids); - else if (starget->channel == 0) - clear_bit(starget->id, ioa_cfg->target_ids); - } if (sata_port) { starget->hostdata = NULL; @@ -4266,9 +3610,9 @@ static struct ipr_resource_entry *ipr_find_sdev(struct scsi_device *sdev) struct ipr_resource_entry *res; list_for_each_entry(res, &ioa_cfg->used_res_q, queue) { - if ((res->bus == sdev->channel) && - (res->target == sdev->id) && - (res->lun == sdev->lun)) + if ((res->cfgte.res_addr.bus == sdev->channel) && + (res->cfgte.res_addr.target == sdev->id) && + (res->cfgte.res_addr.lun == sdev->lun)) return res; } @@ -4317,7 +3661,6 @@ static int ipr_slave_configure(struct scsi_device *sdev) struct ipr_resource_entry *res; struct ata_port *ap = NULL; unsigned long lock_flags = 0; - char buffer[IPR_MAX_RES_PATH_LENGTH]; spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); res = sdev->hostdata; @@ -4344,9 +3687,6 @@ static int ipr_slave_configure(struct scsi_device *sdev) ata_sas_slave_configure(sdev, ap); } else scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun); - if (ioa_cfg->sis64) - sdev_printk(KERN_INFO, sdev, "Resource path: %s\n", - ipr_format_resource_path(&res->res_path[0], &buffer[0])); return 0; } spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); @@ -4488,19 +3828,14 @@ static int ipr_device_reset(struct ipr_ioa_cfg *ioa_cfg, ipr_cmd = ipr_get_free_ipr_cmnd(ioa_cfg); ioarcb = &ipr_cmd->ioarcb; cmd_pkt = &ioarcb->cmd_pkt; + regs = &ioarcb->add_data.u.regs; - if (ipr_cmd->ioa_cfg->sis64) { - regs = &ipr_cmd->i.ata_ioadl.regs; - ioarcb->add_cmd_parms_offset = cpu_to_be16(sizeof(*ioarcb)); - } else - regs = &ioarcb->u.add_data.u.regs; - - ioarcb->res_handle = res->res_handle; + ioarcb->res_handle = res->cfgte.res_handle; cmd_pkt->request_type = IPR_RQTYPE_IOACMD; cmd_pkt->cdb[0] = IPR_RESET_DEVICE; if (ipr_is_gata(res)) { cmd_pkt->cdb[2] = IPR_ATA_PHY_RESET; - ioarcb->add_cmd_parms_len = cpu_to_be16(sizeof(regs->flags)); + ioarcb->add_cmd_parms_len = cpu_to_be32(sizeof(regs->flags)); regs->flags |= IPR_ATA_FLAG_STATUS_ON_GOOD_COMPLETION; } @@ -4545,7 +3880,19 @@ static int ipr_sata_reset(struct ata_link *link, unsigned int *classes, res = sata_port->res; if (res) { rc = ipr_device_reset(ioa_cfg, res); - *classes = res->ata_class; + switch(res->cfgte.proto) { + case IPR_PROTO_SATA: + case IPR_PROTO_SAS_STP: + *classes = ATA_DEV_ATA; + break; + case IPR_PROTO_SATA_ATAPI: + case IPR_PROTO_SAS_STP_ATAPI: + *classes = ATA_DEV_ATAPI; + break; + default: + *classes = ATA_DEV_UNKNOWN; + break; + }; } spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); @@ -4590,7 +3937,7 @@ static int __ipr_eh_dev_reset(struct scsi_cmnd * scsi_cmd) return FAILED; list_for_each_entry(ipr_cmd, &ioa_cfg->pending_q, queue) { - if (ipr_cmd->ioarcb.res_handle == res->res_handle) { + if (ipr_cmd->ioarcb.res_handle == res->cfgte.res_handle) { if (ipr_cmd->scsi_cmd) ipr_cmd->done = ipr_scsi_eh_done; if (ipr_cmd->qc) @@ -4612,7 +3959,7 @@ static int __ipr_eh_dev_reset(struct scsi_cmnd * scsi_cmd) spin_lock_irq(scsi_cmd->device->host->host_lock); list_for_each_entry(ipr_cmd, &ioa_cfg->pending_q, queue) { - if (ipr_cmd->ioarcb.res_handle == res->res_handle) { + if (ipr_cmd->ioarcb.res_handle == res->cfgte.res_handle) { rc = -EIO; break; } @@ -4651,13 +3998,13 @@ static void ipr_bus_reset_done(struct ipr_cmnd *ipr_cmd) struct ipr_resource_entry *res; ENTER; - if (!ioa_cfg->sis64) - list_for_each_entry(res, &ioa_cfg->used_res_q, queue) { - if (res->res_handle == ipr_cmd->ioarcb.res_handle) { - scsi_report_bus_reset(ioa_cfg->host, res->bus); - break; - } + list_for_each_entry(res, &ioa_cfg->used_res_q, queue) { + if (!memcmp(&res->cfgte.res_handle, &ipr_cmd->ioarcb.res_handle, + sizeof(res->cfgte.res_handle))) { + scsi_report_bus_reset(ioa_cfg->host, res->cfgte.res_addr.bus); + break; } + } /* * If abort has not completed, indicate the reset has, else call the @@ -4755,7 +4102,7 @@ static int ipr_cancel_op(struct scsi_cmnd * scsi_cmd) return SUCCESS; ipr_cmd = ipr_get_free_ipr_cmnd(ioa_cfg); - ipr_cmd->ioarcb.res_handle = res->res_handle; + ipr_cmd->ioarcb.res_handle = res->cfgte.res_handle; cmd_pkt = &ipr_cmd->ioarcb.cmd_pkt; cmd_pkt->request_type = IPR_RQTYPE_IOACMD; cmd_pkt->cdb[0] = IPR_CANCEL_ALL_REQUESTS; @@ -4892,29 +4239,11 @@ static irqreturn_t ipr_isr(int irq, void *devp) return IRQ_NONE; } - int_mask_reg = readl(ioa_cfg->regs.sense_interrupt_mask_reg32); - int_reg = readl(ioa_cfg->regs.sense_interrupt_reg32) & ~int_mask_reg; + int_mask_reg = readl(ioa_cfg->regs.sense_interrupt_mask_reg); + int_reg = readl(ioa_cfg->regs.sense_interrupt_reg) & ~int_mask_reg; - /* If an interrupt on the adapter did not occur, ignore it. - * Or in the case of SIS 64, check for a stage change interrupt. - */ + /* If an interrupt on the adapter did not occur, ignore it */ if (unlikely((int_reg & IPR_PCII_OPER_INTERRUPTS) == 0)) { - if (ioa_cfg->sis64) { - int_mask_reg = readl(ioa_cfg->regs.sense_interrupt_mask_reg); - int_reg = readl(ioa_cfg->regs.sense_interrupt_reg) & ~int_mask_reg; - if (int_reg & IPR_PCII_IPL_STAGE_CHANGE) { - - /* clear stage change */ - writel(IPR_PCII_IPL_STAGE_CHANGE, ioa_cfg->regs.clr_interrupt_reg); - int_reg = readl(ioa_cfg->regs.sense_interrupt_reg) & ~int_mask_reg; - list_del(&ioa_cfg->reset_cmd->queue); - del_timer(&ioa_cfg->reset_cmd->timer); - ipr_reset_ioa_job(ioa_cfg->reset_cmd); - spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); - return IRQ_HANDLED; - } - } - spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); return IRQ_NONE; } @@ -4957,8 +4286,8 @@ static irqreturn_t ipr_isr(int irq, void *devp) if (ipr_cmd != NULL) { /* Clear the PCI interrupt */ do { - writel(IPR_PCII_HRRQ_UPDATED, ioa_cfg->regs.clr_interrupt_reg32); - int_reg = readl(ioa_cfg->regs.sense_interrupt_reg32) & ~int_mask_reg; + writel(IPR_PCII_HRRQ_UPDATED, ioa_cfg->regs.clr_interrupt_reg); + int_reg = readl(ioa_cfg->regs.sense_interrupt_reg) & ~int_mask_reg; } while (int_reg & IPR_PCII_HRRQ_UPDATED && num_hrrq++ < IPR_MAX_HRRQ_RETRIES); @@ -4979,53 +4308,6 @@ static irqreturn_t ipr_isr(int irq, void *devp) return rc; } -/** - * ipr_build_ioadl64 - Build a scatter/gather list and map the buffer - * @ioa_cfg: ioa config struct - * @ipr_cmd: ipr command struct - * - * Return value: - * 0 on success / -1 on failure - **/ -static int ipr_build_ioadl64(struct ipr_ioa_cfg *ioa_cfg, - struct ipr_cmnd *ipr_cmd) -{ - int i, nseg; - struct scatterlist *sg; - u32 length; - u32 ioadl_flags = 0; - struct scsi_cmnd *scsi_cmd = ipr_cmd->scsi_cmd; - struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb; - struct ipr_ioadl64_desc *ioadl64 = ipr_cmd->i.ioadl64; - - length = scsi_bufflen(scsi_cmd); - if (!length) - return 0; - - nseg = scsi_dma_map(scsi_cmd); - if (nseg < 0) { - dev_err(&ioa_cfg->pdev->dev, "pci_map_sg failed!\n"); - return -1; - } - - ipr_cmd->dma_use_sg = nseg; - - if (scsi_cmd->sc_data_direction == DMA_TO_DEVICE) { - ioadl_flags = IPR_IOADL_FLAGS_WRITE; - ioarcb->cmd_pkt.flags_hi |= IPR_FLAGS_HI_WRITE_NOT_READ; - } else if (scsi_cmd->sc_data_direction == DMA_FROM_DEVICE) - ioadl_flags = IPR_IOADL_FLAGS_READ; - - scsi_for_each_sg(scsi_cmd, sg, ipr_cmd->dma_use_sg, i) { - ioadl64[i].flags = cpu_to_be32(ioadl_flags); - ioadl64[i].data_len = cpu_to_be32(sg_dma_len(sg)); - ioadl64[i].address = cpu_to_be64(sg_dma_address(sg)); - } - - ioadl64[i-1].flags |= cpu_to_be32(IPR_IOADL_FLAGS_LAST); - return 0; -} - /** * ipr_build_ioadl - Build a scatter/gather list and map the buffer * @ioa_cfg: ioa config struct @@ -5043,7 +4325,7 @@ static int ipr_build_ioadl(struct ipr_ioa_cfg *ioa_cfg, u32 ioadl_flags = 0; struct scsi_cmnd *scsi_cmd = ipr_cmd->scsi_cmd; struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb; - struct ipr_ioadl_desc *ioadl = ipr_cmd->i.ioadl; + struct ipr_ioadl_desc *ioadl = ipr_cmd->ioadl; length = scsi_bufflen(scsi_cmd); if (!length) @@ -5060,8 +4342,8 @@ static int ipr_build_ioadl(struct ipr_ioa_cfg *ioa_cfg, if (scsi_cmd->sc_data_direction == DMA_TO_DEVICE) { ioadl_flags = IPR_IOADL_FLAGS_WRITE; ioarcb->cmd_pkt.flags_hi |= IPR_FLAGS_HI_WRITE_NOT_READ; - ioarcb->data_transfer_length = cpu_to_be32(length); - ioarcb->ioadl_len = + ioarcb->write_data_transfer_length = cpu_to_be32(length); + ioarcb->write_ioadl_len = cpu_to_be32(sizeof(struct ipr_ioadl_desc) * ipr_cmd->dma_use_sg); } else if (scsi_cmd->sc_data_direction == DMA_FROM_DEVICE) { ioadl_flags = IPR_IOADL_FLAGS_READ; @@ -5070,10 +4352,11 @@ static int ipr_build_ioadl(struct ipr_ioa_cfg *ioa_cfg, cpu_to_be32(sizeof(struct ipr_ioadl_desc) * ipr_cmd->dma_use_sg); } - if (ipr_cmd->dma_use_sg <= ARRAY_SIZE(ioarcb->u.add_data.u.ioadl)) { - ioadl = ioarcb->u.add_data.u.ioadl; - ioarcb->write_ioadl_addr = cpu_to_be32((ipr_cmd->dma_addr) + - offsetof(struct ipr_ioarcb, u.add_data)); + if (ipr_cmd->dma_use_sg <= ARRAY_SIZE(ioarcb->add_data.u.ioadl)) { + ioadl = ioarcb->add_data.u.ioadl; + ioarcb->write_ioadl_addr = + cpu_to_be32(be32_to_cpu(ioarcb->ioarcb_host_pci_addr) + + offsetof(struct ipr_ioarcb, add_data)); ioarcb->read_ioadl_addr = ioarcb->write_ioadl_addr; } @@ -5163,24 +4446,18 @@ static void ipr_reinit_ipr_cmnd_for_erp(struct ipr_cmnd *ipr_cmd) { struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb; struct ipr_ioasa *ioasa = &ipr_cmd->ioasa; - dma_addr_t dma_addr = ipr_cmd->dma_addr; + dma_addr_t dma_addr = be32_to_cpu(ioarcb->ioarcb_host_pci_addr); memset(&ioarcb->cmd_pkt, 0, sizeof(struct ipr_cmd_pkt)); - ioarcb->data_transfer_length = 0; + ioarcb->write_data_transfer_length = 0; ioarcb->read_data_transfer_length = 0; - ioarcb->ioadl_len = 0; + ioarcb->write_ioadl_len = 0; ioarcb->read_ioadl_len = 0; ioasa->ioasc = 0; ioasa->residual_data_len = 0; - - if (ipr_cmd->ioa_cfg->sis64) - ioarcb->u.sis64_addr_data.data_ioadl_addr = - cpu_to_be64(dma_addr + offsetof(struct ipr_cmnd, i.ioadl64)); - else { - ioarcb->write_ioadl_addr = - cpu_to_be32(dma_addr + offsetof(struct ipr_cmnd, i.ioadl)); - ioarcb->read_ioadl_addr = ioarcb->write_ioadl_addr; - } + ioarcb->write_ioadl_addr = + cpu_to_be32(dma_addr + offsetof(struct ipr_cmnd, ioadl)); + ioarcb->read_ioadl_addr = ioarcb->write_ioadl_addr; } /** @@ -5212,8 +4489,15 @@ static void ipr_erp_request_sense(struct ipr_cmnd *ipr_cmd) cmd_pkt->flags_hi |= IPR_FLAGS_HI_NO_ULEN_CHK; cmd_pkt->timeout = cpu_to_be16(IPR_REQUEST_SENSE_TIMEOUT / HZ); - ipr_init_ioadl(ipr_cmd, ipr_cmd->sense_buffer_dma, - SCSI_SENSE_BUFFERSIZE, IPR_IOADL_FLAGS_READ_LAST); + ipr_cmd->ioadl[0].flags_and_data_len = + cpu_to_be32(IPR_IOADL_FLAGS_READ_LAST | SCSI_SENSE_BUFFERSIZE); + ipr_cmd->ioadl[0].address = + cpu_to_be32(ipr_cmd->sense_buffer_dma); + + ipr_cmd->ioarcb.read_ioadl_len = + cpu_to_be32(sizeof(struct ipr_ioadl_desc)); + ipr_cmd->ioarcb.read_data_transfer_length = + cpu_to_be32(SCSI_SENSE_BUFFERSIZE); ipr_do_req(ipr_cmd, ipr_erp_done, ipr_timeout, IPR_REQUEST_SENSE_TIMEOUT * 2); @@ -5609,9 +4893,9 @@ static int ipr_queuecommand(struct scsi_cmnd *scsi_cmd, memcpy(ioarcb->cmd_pkt.cdb, scsi_cmd->cmnd, scsi_cmd->cmd_len); ipr_cmd->scsi_cmd = scsi_cmd; - ioarcb->res_handle = res->res_handle; + ioarcb->res_handle = res->cfgte.res_handle; ipr_cmd->done = ipr_scsi_done; - ipr_trc_hook(ipr_cmd, IPR_TRACE_START, IPR_GET_RES_PHYS_LOC(res)); + ipr_trc_hook(ipr_cmd, IPR_TRACE_START, IPR_GET_PHYS_LOC(res->cfgte.res_addr)); if (ipr_is_gscsi(res) || ipr_is_vset_device(res)) { if (scsi_cmd->underflow == 0) @@ -5632,16 +4916,13 @@ static int ipr_queuecommand(struct scsi_cmnd *scsi_cmd, (!ipr_is_gscsi(res) || scsi_cmd->cmnd[0] == IPR_QUERY_RSRC_STATE)) ioarcb->cmd_pkt.request_type = IPR_RQTYPE_IOACMD; - if (likely(rc == 0)) { - if (ioa_cfg->sis64) - rc = ipr_build_ioadl64(ioa_cfg, ipr_cmd); - else - rc = ipr_build_ioadl(ioa_cfg, ipr_cmd); - } + if (likely(rc == 0)) + rc = ipr_build_ioadl(ioa_cfg, ipr_cmd); if (likely(rc == 0)) { mb(); - ipr_send_command(ipr_cmd); + writel(be32_to_cpu(ipr_cmd->ioarcb.ioarcb_host_pci_addr), + ioa_cfg->regs.ioarrin_reg); } else { list_move_tail(&ipr_cmd->queue, &ioa_cfg->free_q); return SCSI_MLQUEUE_HOST_BUSY; @@ -5754,9 +5035,20 @@ static void ipr_ata_phy_reset(struct ata_port *ap) goto out_unlock; } - ap->link.device[0].class = res->ata_class; - if (ap->link.device[0].class == ATA_DEV_UNKNOWN) + switch(res->cfgte.proto) { + case IPR_PROTO_SATA: + case IPR_PROTO_SAS_STP: + ap->link.device[0].class = ATA_DEV_ATA; + break; + case IPR_PROTO_SATA_ATAPI: + case IPR_PROTO_SAS_STP_ATAPI: + ap->link.device[0].class = ATA_DEV_ATAPI; + break; + default: + ap->link.device[0].class = ATA_DEV_UNKNOWN; ata_port_disable(ap); + break; + }; out_unlock: spin_unlock_irqrestore(ioa_cfg->host->host_lock, flags); @@ -5842,7 +5134,8 @@ static void ipr_sata_done(struct ipr_cmnd *ipr_cmd) ipr_dump_ioasa(ioa_cfg, ipr_cmd, res); if (be32_to_cpu(ipr_cmd->ioasa.ioasc_specific) & IPR_ATA_DEVICE_WAS_RESET) - scsi_report_device_reset(ioa_cfg->host, res->bus, res->target); + scsi_report_device_reset(ioa_cfg->host, res->cfgte.res_addr.bus, + res->cfgte.res_addr.target); if (IPR_IOASC_SENSE_KEY(ioasc) > RECOVERED_ERROR) qc->err_mask |= __ac_err_mask(ipr_cmd->ioasa.u.gata.status); @@ -5852,52 +5145,6 @@ static void ipr_sata_done(struct ipr_cmnd *ipr_cmd) ata_qc_complete(qc); } -/** - * ipr_build_ata_ioadl64 - Build an ATA scatter/gather list - * @ipr_cmd: ipr command struct - * @qc: ATA queued command - * - **/ -static void ipr_build_ata_ioadl64(struct ipr_cmnd *ipr_cmd, - struct ata_queued_cmd *qc) -{ - u32 ioadl_flags = 0; - struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb; - struct ipr_ioadl64_desc *ioadl64 = ipr_cmd->i.ioadl64; - struct ipr_ioadl64_desc *last_ioadl64 = NULL; - int len = qc->nbytes; - struct scatterlist *sg; - unsigned int si; - dma_addr_t dma_addr = ipr_cmd->dma_addr; - - if (len == 0) - return; - - if (qc->dma_dir == DMA_TO_DEVICE) { - ioadl_flags = IPR_IOADL_FLAGS_WRITE; - ioarcb->cmd_pkt.flags_hi |= IPR_FLAGS_HI_WRITE_NOT_READ; - } else if (qc->dma_dir == DMA_FROM_DEVICE) - ioadl_flags = IPR_IOADL_FLAGS_READ; - - ioarcb->data_transfer_length = cpu_to_be32(len); - ioarcb->ioadl_len = - cpu_to_be32(sizeof(struct ipr_ioadl64_desc) * ipr_cmd->dma_use_sg); - ioarcb->u.sis64_addr_data.data_ioadl_addr = - cpu_to_be64(dma_addr + offsetof(struct ipr_cmnd, i.ata_ioadl)); - - for_each_sg(qc->sg, sg, qc->n_elem, si) { - ioadl64->flags = cpu_to_be32(ioadl_flags); - ioadl64->data_len = cpu_to_be32(sg_dma_len(sg)); - ioadl64->address = cpu_to_be64(sg_dma_address(sg)); - - last_ioadl64 = ioadl64; - ioadl64++; - } - - if (likely(last_ioadl64)) - last_ioadl64->flags |= cpu_to_be32(IPR_IOADL_FLAGS_LAST); -} - /** * ipr_build_ata_ioadl - Build an ATA scatter/gather list * @ipr_cmd: ipr command struct @@ -5909,7 +5156,7 @@ static void ipr_build_ata_ioadl(struct ipr_cmnd *ipr_cmd, { u32 ioadl_flags = 0; struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb; - struct ipr_ioadl_desc *ioadl = ipr_cmd->i.ioadl; + struct ipr_ioadl_desc *ioadl = ipr_cmd->ioadl; struct ipr_ioadl_desc *last_ioadl = NULL; int len = qc->nbytes; struct scatterlist *sg; @@ -5921,8 +5168,8 @@ static void ipr_build_ata_ioadl(struct ipr_cmnd *ipr_cmd, if (qc->dma_dir == DMA_TO_DEVICE) { ioadl_flags = IPR_IOADL_FLAGS_WRITE; ioarcb->cmd_pkt.flags_hi |= IPR_FLAGS_HI_WRITE_NOT_READ; - ioarcb->data_transfer_length = cpu_to_be32(len); - ioarcb->ioadl_len = + ioarcb->write_data_transfer_length = cpu_to_be32(len); + ioarcb->write_ioadl_len = cpu_to_be32(sizeof(struct ipr_ioadl_desc) * ipr_cmd->dma_use_sg); } else if (qc->dma_dir == DMA_FROM_DEVICE) { ioadl_flags = IPR_IOADL_FLAGS_READ; @@ -5965,34 +5212,25 @@ static unsigned int ipr_qc_issue(struct ata_queued_cmd *qc) ipr_cmd = ipr_get_free_ipr_cmnd(ioa_cfg); ioarcb = &ipr_cmd->ioarcb; + regs = &ioarcb->add_data.u.regs; - if (ioa_cfg->sis64) { - regs = &ipr_cmd->i.ata_ioadl.regs; - ioarcb->add_cmd_parms_offset = cpu_to_be16(sizeof(*ioarcb)); - } else - regs = &ioarcb->u.add_data.u.regs; - - memset(regs, 0, sizeof(*regs)); - ioarcb->add_cmd_parms_len = cpu_to_be16(sizeof(*regs)); + memset(&ioarcb->add_data, 0, sizeof(ioarcb->add_data)); + ioarcb->add_cmd_parms_len = cpu_to_be32(sizeof(ioarcb->add_data.u.regs)); list_add_tail(&ipr_cmd->queue, &ioa_cfg->pending_q); ipr_cmd->qc = qc; ipr_cmd->done = ipr_sata_done; - ipr_cmd->ioarcb.res_handle = res->res_handle; + ipr_cmd->ioarcb.res_handle = res->cfgte.res_handle; ioarcb->cmd_pkt.request_type = IPR_RQTYPE_ATA_PASSTHRU; ioarcb->cmd_pkt.flags_hi |= IPR_FLAGS_HI_NO_LINK_DESC; ioarcb->cmd_pkt.flags_hi |= IPR_FLAGS_HI_NO_ULEN_CHK; ipr_cmd->dma_use_sg = qc->n_elem; - if (ioa_cfg->sis64) - ipr_build_ata_ioadl64(ipr_cmd, qc); - else - ipr_build_ata_ioadl(ipr_cmd, qc); - + ipr_build_ata_ioadl(ipr_cmd, qc); regs->flags |= IPR_ATA_FLAG_STATUS_ON_GOOD_COMPLETION; ipr_copy_sata_tf(regs, &qc->tf); memcpy(ioarcb->cmd_pkt.cdb, qc->cdb, IPR_MAX_CDB_LEN); - ipr_trc_hook(ipr_cmd, IPR_TRACE_START, IPR_GET_RES_PHYS_LOC(res)); + ipr_trc_hook(ipr_cmd, IPR_TRACE_START, IPR_GET_PHYS_LOC(res->cfgte.res_addr)); switch (qc->tf.protocol) { case ATA_PROT_NODATA: @@ -6019,9 +5257,8 @@ static unsigned int ipr_qc_issue(struct ata_queued_cmd *qc) } mb(); - - ipr_send_command(ipr_cmd); - + writel(be32_to_cpu(ioarcb->ioarcb_host_pci_addr), + ioa_cfg->regs.ioarrin_reg); return 0; } @@ -6222,7 +5459,7 @@ static void ipr_set_sup_dev_dflt(struct ipr_supported_device *supported_dev, * ipr_set_supported_devs - Send Set Supported Devices for a device * @ipr_cmd: ipr command struct * - * This function sends a Set Supported Devices to the adapter + * This function send a Set Supported Devices to the adapter * * Return value: * IPR_RC_JOB_CONTINUE / IPR_RC_JOB_RETURN @@ -6231,6 +5468,7 @@ static int ipr_set_supported_devs(struct ipr_cmnd *ipr_cmd) { struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; struct ipr_supported_device *supp_dev = &ioa_cfg->vpd_cbs->supp_dev; + struct ipr_ioadl_desc *ioadl = ipr_cmd->ioadl; struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb; struct ipr_resource_entry *res = ipr_cmd->u.res; @@ -6241,34 +5479,64 @@ static int ipr_set_supported_devs(struct ipr_cmnd *ipr_cmd) continue; ipr_cmd->u.res = res; - ipr_set_sup_dev_dflt(supp_dev, &res->std_inq_data.vpids); + ipr_set_sup_dev_dflt(supp_dev, &res->cfgte.std_inq_data.vpids); ioarcb->res_handle = cpu_to_be32(IPR_IOA_RES_HANDLE); ioarcb->cmd_pkt.flags_hi |= IPR_FLAGS_HI_WRITE_NOT_READ; ioarcb->cmd_pkt.request_type = IPR_RQTYPE_IOACMD; ioarcb->cmd_pkt.cdb[0] = IPR_SET_SUPPORTED_DEVICES; - ioarcb->cmd_pkt.cdb[1] = IPR_SET_ALL_SUPPORTED_DEVICES; ioarcb->cmd_pkt.cdb[7] = (sizeof(struct ipr_supported_device) >> 8) & 0xff; ioarcb->cmd_pkt.cdb[8] = sizeof(struct ipr_supported_device) & 0xff; - ipr_init_ioadl(ipr_cmd, - ioa_cfg->vpd_cbs_dma + - offsetof(struct ipr_misc_cbs, supp_dev), - sizeof(struct ipr_supported_device), - IPR_IOADL_FLAGS_WRITE_LAST); + ioadl->flags_and_data_len = cpu_to_be32(IPR_IOADL_FLAGS_WRITE_LAST | + sizeof(struct ipr_supported_device)); + ioadl->address = cpu_to_be32(ioa_cfg->vpd_cbs_dma + + offsetof(struct ipr_misc_cbs, supp_dev)); + ioarcb->write_ioadl_len = cpu_to_be32(sizeof(struct ipr_ioadl_desc)); + ioarcb->write_data_transfer_length = + cpu_to_be32(sizeof(struct ipr_supported_device)); ipr_do_req(ipr_cmd, ipr_reset_ioa_job, ipr_timeout, IPR_SET_SUP_DEVICE_TIMEOUT); - if (!ioa_cfg->sis64) - ipr_cmd->job_step = ipr_set_supported_devs; + ipr_cmd->job_step = ipr_set_supported_devs; return IPR_RC_JOB_RETURN; } return IPR_RC_JOB_CONTINUE; } +/** + * ipr_setup_write_cache - Disable write cache if needed + * @ipr_cmd: ipr command struct + * + * This function sets up adapters write cache to desired setting + * + * Return value: + * IPR_RC_JOB_CONTINUE / IPR_RC_JOB_RETURN + **/ +static int ipr_setup_write_cache(struct ipr_cmnd *ipr_cmd) +{ + struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; + + ipr_cmd->job_step = ipr_set_supported_devs; + ipr_cmd->u.res = list_entry(ioa_cfg->used_res_q.next, + struct ipr_resource_entry, queue); + + if (ioa_cfg->cache_state != CACHE_DISABLED) + return IPR_RC_JOB_CONTINUE; + + ipr_cmd->ioarcb.res_handle = cpu_to_be32(IPR_IOA_RES_HANDLE); + ipr_cmd->ioarcb.cmd_pkt.request_type = IPR_RQTYPE_IOACMD; + ipr_cmd->ioarcb.cmd_pkt.cdb[0] = IPR_IOA_SHUTDOWN; + ipr_cmd->ioarcb.cmd_pkt.cdb[1] = IPR_SHUTDOWN_PREPARE_FOR_NORMAL; + + ipr_do_req(ipr_cmd, ipr_reset_ioa_job, ipr_timeout, IPR_INTERNAL_TIMEOUT); + + return IPR_RC_JOB_RETURN; +} + /** * ipr_get_mode_page - Locate specified mode page * @mode_pages: mode page buffer @@ -6427,9 +5695,10 @@ static void ipr_modify_ioafp_mode_page_28(struct ipr_ioa_cfg *ioa_cfg, * none **/ static void ipr_build_mode_select(struct ipr_cmnd *ipr_cmd, - __be32 res_handle, u8 parm, - dma_addr_t dma_addr, u8 xfer_len) + __be32 res_handle, u8 parm, u32 dma_addr, + u8 xfer_len) { + struct ipr_ioadl_desc *ioadl = ipr_cmd->ioadl; struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb; ioarcb->res_handle = res_handle; @@ -6439,7 +5708,11 @@ static void ipr_build_mode_select(struct ipr_cmnd *ipr_cmd, ioarcb->cmd_pkt.cdb[1] = parm; ioarcb->cmd_pkt.cdb[4] = xfer_len; - ipr_init_ioadl(ipr_cmd, dma_addr, xfer_len, IPR_IOADL_FLAGS_WRITE_LAST); + ioadl->flags_and_data_len = + cpu_to_be32(IPR_IOADL_FLAGS_WRITE_LAST | xfer_len); + ioadl->address = cpu_to_be32(dma_addr); + ioarcb->write_ioadl_len = cpu_to_be32(sizeof(struct ipr_ioadl_desc)); + ioarcb->write_data_transfer_length = cpu_to_be32(xfer_len); } /** @@ -6469,9 +5742,7 @@ static int ipr_ioafp_mode_select_page28(struct ipr_cmnd *ipr_cmd) ioa_cfg->vpd_cbs_dma + offsetof(struct ipr_misc_cbs, mode_pages), length); - ipr_cmd->job_step = ipr_set_supported_devs; - ipr_cmd->u.res = list_entry(ioa_cfg->used_res_q.next, - struct ipr_resource_entry, queue); + ipr_cmd->job_step = ipr_setup_write_cache; ipr_do_req(ipr_cmd, ipr_reset_ioa_job, ipr_timeout, IPR_INTERNAL_TIMEOUT); LEAVE; @@ -6491,8 +5762,9 @@ static int ipr_ioafp_mode_select_page28(struct ipr_cmnd *ipr_cmd) **/ static void ipr_build_mode_sense(struct ipr_cmnd *ipr_cmd, __be32 res_handle, - u8 parm, dma_addr_t dma_addr, u8 xfer_len) + u8 parm, u32 dma_addr, u8 xfer_len) { + struct ipr_ioadl_desc *ioadl = ipr_cmd->ioadl; struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb; ioarcb->res_handle = res_handle; @@ -6501,7 +5773,11 @@ static void ipr_build_mode_sense(struct ipr_cmnd *ipr_cmd, ioarcb->cmd_pkt.cdb[4] = xfer_len; ioarcb->cmd_pkt.request_type = IPR_RQTYPE_SCSICDB; - ipr_init_ioadl(ipr_cmd, dma_addr, xfer_len, IPR_IOADL_FLAGS_READ_LAST); + ioadl->flags_and_data_len = + cpu_to_be32(IPR_IOADL_FLAGS_READ_LAST | xfer_len); + ioadl->address = cpu_to_be32(dma_addr); + ioarcb->read_ioadl_len = cpu_to_be32(sizeof(struct ipr_ioadl_desc)); + ioarcb->read_data_transfer_length = cpu_to_be32(xfer_len); } /** @@ -6539,13 +5815,10 @@ static int ipr_reset_cmd_failed(struct ipr_cmnd *ipr_cmd) **/ static int ipr_reset_mode_sense_failed(struct ipr_cmnd *ipr_cmd) { - struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; u32 ioasc = be32_to_cpu(ipr_cmd->ioasa.ioasc); if (ioasc == IPR_IOASC_IR_INVALID_REQ_TYPE_OR_PKT) { - ipr_cmd->job_step = ipr_set_supported_devs; - ipr_cmd->u.res = list_entry(ioa_cfg->used_res_q.next, - struct ipr_resource_entry, queue); + ipr_cmd->job_step = ipr_setup_write_cache; return IPR_RC_JOB_CONTINUE; } @@ -6685,36 +5958,24 @@ static int ipr_init_res_table(struct ipr_cmnd *ipr_cmd) { struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; struct ipr_resource_entry *res, *temp; - struct ipr_config_table_entry_wrapper cfgtew; - int entries, found, flag, i; + struct ipr_config_table_entry *cfgte; + int found, i; LIST_HEAD(old_res); ENTER; - if (ioa_cfg->sis64) - flag = ioa_cfg->u.cfg_table64->hdr64.flags; - else - flag = ioa_cfg->u.cfg_table->hdr.flags; - - if (flag & IPR_UCODE_DOWNLOAD_REQ) + if (ioa_cfg->cfg_table->hdr.flags & IPR_UCODE_DOWNLOAD_REQ) dev_err(&ioa_cfg->pdev->dev, "Microcode download required\n"); list_for_each_entry_safe(res, temp, &ioa_cfg->used_res_q, queue) list_move_tail(&res->queue, &old_res); - if (ioa_cfg->sis64) - entries = ioa_cfg->u.cfg_table64->hdr64.num_entries; - else - entries = ioa_cfg->u.cfg_table->hdr.num_entries; - - for (i = 0; i < entries; i++) { - if (ioa_cfg->sis64) - cfgtew.u.cfgte64 = &ioa_cfg->u.cfg_table64->dev[i]; - else - cfgtew.u.cfgte = &ioa_cfg->u.cfg_table->dev[i]; + for (i = 0; i < ioa_cfg->cfg_table->hdr.num_entries; i++) { + cfgte = &ioa_cfg->cfg_table->dev[i]; found = 0; list_for_each_entry_safe(res, temp, &old_res, queue) { - if (ipr_is_same_device(res, &cfgtew)) { + if (!memcmp(&res->cfgte.res_addr, + &cfgte->res_addr, sizeof(cfgte->res_addr))) { list_move_tail(&res->queue, &ioa_cfg->used_res_q); found = 1; break; @@ -6731,27 +5992,24 @@ static int ipr_init_res_table(struct ipr_cmnd *ipr_cmd) res = list_entry(ioa_cfg->free_res_q.next, struct ipr_resource_entry, queue); list_move_tail(&res->queue, &ioa_cfg->used_res_q); - ipr_init_res_entry(res, &cfgtew); + ipr_init_res_entry(res); res->add_to_ml = 1; } if (found) - ipr_update_res_entry(res, &cfgtew); + memcpy(&res->cfgte, cfgte, sizeof(struct ipr_config_table_entry)); } list_for_each_entry_safe(res, temp, &old_res, queue) { if (res->sdev) { res->del_from_ml = 1; - res->res_handle = IPR_INVALID_RES_HANDLE; + res->cfgte.res_handle = IPR_INVALID_RES_HANDLE; list_move_tail(&res->queue, &ioa_cfg->used_res_q); + } else { + list_move_tail(&res->queue, &ioa_cfg->free_res_q); } } - list_for_each_entry_safe(res, temp, &old_res, queue) { - ipr_clear_res_target(res); - list_move_tail(&res->queue, &ioa_cfg->free_res_q); - } - if (ioa_cfg->dual_raid && ipr_dual_ioa_raid) ipr_cmd->job_step = ipr_ioafp_mode_sense_page24; else @@ -6775,6 +6033,7 @@ static int ipr_ioafp_query_ioa_cfg(struct ipr_cmnd *ipr_cmd) { struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb; + struct ipr_ioadl_desc *ioadl = ipr_cmd->ioadl; struct ipr_inquiry_page3 *ucode_vpd = &ioa_cfg->vpd_cbs->page3_data; struct ipr_inquiry_cap *cap = &ioa_cfg->vpd_cbs->cap; @@ -6788,11 +6047,16 @@ static int ipr_ioafp_query_ioa_cfg(struct ipr_cmnd *ipr_cmd) ioarcb->res_handle = cpu_to_be32(IPR_IOA_RES_HANDLE); ioarcb->cmd_pkt.cdb[0] = IPR_QUERY_IOA_CONFIG; - ioarcb->cmd_pkt.cdb[7] = (ioa_cfg->cfg_table_size >> 8) & 0xff; - ioarcb->cmd_pkt.cdb[8] = ioa_cfg->cfg_table_size & 0xff; + ioarcb->cmd_pkt.cdb[7] = (sizeof(struct ipr_config_table) >> 8) & 0xff; + ioarcb->cmd_pkt.cdb[8] = sizeof(struct ipr_config_table) & 0xff; + + ioarcb->read_ioadl_len = cpu_to_be32(sizeof(struct ipr_ioadl_desc)); + ioarcb->read_data_transfer_length = + cpu_to_be32(sizeof(struct ipr_config_table)); - ipr_init_ioadl(ipr_cmd, ioa_cfg->cfg_table_dma, ioa_cfg->cfg_table_size, - IPR_IOADL_FLAGS_READ_LAST); + ioadl->address = cpu_to_be32(ioa_cfg->cfg_table_dma); + ioadl->flags_and_data_len = + cpu_to_be32(IPR_IOADL_FLAGS_READ_LAST | sizeof(struct ipr_config_table)); ipr_cmd->job_step = ipr_init_res_table; @@ -6812,9 +6076,10 @@ static int ipr_ioafp_query_ioa_cfg(struct ipr_cmnd *ipr_cmd) * none **/ static void ipr_ioafp_inquiry(struct ipr_cmnd *ipr_cmd, u8 flags, u8 page, - dma_addr_t dma_addr, u8 xfer_len) + u32 dma_addr, u8 xfer_len) { struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb; + struct ipr_ioadl_desc *ioadl = ipr_cmd->ioadl; ENTER; ioarcb->cmd_pkt.request_type = IPR_RQTYPE_SCSICDB; @@ -6825,7 +6090,12 @@ static void ipr_ioafp_inquiry(struct ipr_cmnd *ipr_cmd, u8 flags, u8 page, ioarcb->cmd_pkt.cdb[2] = page; ioarcb->cmd_pkt.cdb[4] = xfer_len; - ipr_init_ioadl(ipr_cmd, dma_addr, xfer_len, IPR_IOADL_FLAGS_READ_LAST); + ioarcb->read_ioadl_len = cpu_to_be32(sizeof(struct ipr_ioadl_desc)); + ioarcb->read_data_transfer_length = cpu_to_be32(xfer_len); + + ioadl->address = cpu_to_be32(dma_addr); + ioadl->flags_and_data_len = + cpu_to_be32(IPR_IOADL_FLAGS_READ_LAST | xfer_len); ipr_do_req(ipr_cmd, ipr_reset_ioa_job, ipr_timeout, IPR_INTERNAL_TIMEOUT); LEAVE; @@ -6896,9 +6166,13 @@ static int ipr_ioafp_cap_inquiry(struct ipr_cmnd *ipr_cmd) static int ipr_ioafp_page3_inquiry(struct ipr_cmnd *ipr_cmd) { struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; + struct ipr_inquiry_page0 *page0 = &ioa_cfg->vpd_cbs->page0_data; ENTER; + if (!ipr_inquiry_page_supported(page0, 1)) + ioa_cfg->cache_state = CACHE_NONE; + ipr_cmd->job_step = ipr_ioafp_cap_inquiry; ipr_ioafp_inquiry(ipr_cmd, 1, 3, @@ -6966,7 +6240,7 @@ static int ipr_ioafp_std_inquiry(struct ipr_cmnd *ipr_cmd) } /** - * ipr_ioafp_identify_hrrq - Send Identify Host RRQ. + * ipr_ioafp_indentify_hrrq - Send Identify Host RRQ. * @ipr_cmd: ipr command struct * * This function send an Identify Host Request Response Queue @@ -6975,7 +6249,7 @@ static int ipr_ioafp_std_inquiry(struct ipr_cmnd *ipr_cmd) * Return value: * IPR_RC_JOB_RETURN **/ -static int ipr_ioafp_identify_hrrq(struct ipr_cmnd *ipr_cmd) +static int ipr_ioafp_indentify_hrrq(struct ipr_cmnd *ipr_cmd) { struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb; @@ -6987,32 +6261,19 @@ static int ipr_ioafp_identify_hrrq(struct ipr_cmnd *ipr_cmd) ioarcb->res_handle = cpu_to_be32(IPR_IOA_RES_HANDLE); ioarcb->cmd_pkt.request_type = IPR_RQTYPE_IOACMD; - if (ioa_cfg->sis64) - ioarcb->cmd_pkt.cdb[1] = 0x1; ioarcb->cmd_pkt.cdb[2] = - ((u64) ioa_cfg->host_rrq_dma >> 24) & 0xff; + ((u32) ioa_cfg->host_rrq_dma >> 24) & 0xff; ioarcb->cmd_pkt.cdb[3] = - ((u64) ioa_cfg->host_rrq_dma >> 16) & 0xff; + ((u32) ioa_cfg->host_rrq_dma >> 16) & 0xff; ioarcb->cmd_pkt.cdb[4] = - ((u64) ioa_cfg->host_rrq_dma >> 8) & 0xff; + ((u32) ioa_cfg->host_rrq_dma >> 8) & 0xff; ioarcb->cmd_pkt.cdb[5] = - ((u64) ioa_cfg->host_rrq_dma) & 0xff; + ((u32) ioa_cfg->host_rrq_dma) & 0xff; ioarcb->cmd_pkt.cdb[7] = ((sizeof(u32) * IPR_NUM_CMD_BLKS) >> 8) & 0xff; ioarcb->cmd_pkt.cdb[8] = (sizeof(u32) * IPR_NUM_CMD_BLKS) & 0xff; - if (ioa_cfg->sis64) { - ioarcb->cmd_pkt.cdb[10] = - ((u64) ioa_cfg->host_rrq_dma >> 56) & 0xff; - ioarcb->cmd_pkt.cdb[11] = - ((u64) ioa_cfg->host_rrq_dma >> 48) & 0xff; - ioarcb->cmd_pkt.cdb[12] = - ((u64) ioa_cfg->host_rrq_dma >> 40) & 0xff; - ioarcb->cmd_pkt.cdb[13] = - ((u64) ioa_cfg->host_rrq_dma >> 32) & 0xff; - } - ipr_cmd->job_step = ipr_ioafp_std_inquiry; ipr_do_req(ipr_cmd, ipr_reset_ioa_job, ipr_timeout, IPR_INTERNAL_TIMEOUT); @@ -7093,58 +6354,7 @@ static void ipr_init_ioa_mem(struct ipr_ioa_cfg *ioa_cfg) ioa_cfg->toggle_bit = 1; /* Zero out config table */ - memset(ioa_cfg->u.cfg_table, 0, ioa_cfg->cfg_table_size); -} - -/** - * ipr_reset_next_stage - Process IPL stage change based on feedback register. - * @ipr_cmd: ipr command struct - * - * Return value: - * IPR_RC_JOB_CONTINUE / IPR_RC_JOB_RETURN - **/ -static int ipr_reset_next_stage(struct ipr_cmnd *ipr_cmd) -{ - unsigned long stage, stage_time; - u32 feedback; - volatile u32 int_reg; - struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; - u64 maskval = 0; - - feedback = readl(ioa_cfg->regs.init_feedback_reg); - stage = feedback & IPR_IPL_INIT_STAGE_MASK; - stage_time = feedback & IPR_IPL_INIT_STAGE_TIME_MASK; - - ipr_dbg("IPL stage = 0x%lx, IPL stage time = %ld\n", stage, stage_time); - - /* sanity check the stage_time value */ - if (stage_time < IPR_IPL_INIT_MIN_STAGE_TIME) - stage_time = IPR_IPL_INIT_MIN_STAGE_TIME; - else if (stage_time > IPR_LONG_OPERATIONAL_TIMEOUT) - stage_time = IPR_LONG_OPERATIONAL_TIMEOUT; - - if (stage == IPR_IPL_INIT_STAGE_UNKNOWN) { - writel(IPR_PCII_IPL_STAGE_CHANGE, ioa_cfg->regs.set_interrupt_mask_reg); - int_reg = readl(ioa_cfg->regs.sense_interrupt_mask_reg); - stage_time = ioa_cfg->transop_timeout; - ipr_cmd->job_step = ipr_ioafp_identify_hrrq; - } else if (stage == IPR_IPL_INIT_STAGE_TRANSOP) { - ipr_cmd->job_step = ipr_ioafp_identify_hrrq; - maskval = IPR_PCII_IPL_STAGE_CHANGE; - maskval = (maskval << 32) | IPR_PCII_IOA_TRANS_TO_OPER; - writeq(maskval, ioa_cfg->regs.set_interrupt_mask_reg); - int_reg = readl(ioa_cfg->regs.sense_interrupt_mask_reg); - return IPR_RC_JOB_CONTINUE; - } - - ipr_cmd->timer.data = (unsigned long) ipr_cmd; - ipr_cmd->timer.expires = jiffies + stage_time * HZ; - ipr_cmd->timer.function = (void (*)(unsigned long))ipr_oper_timeout; - ipr_cmd->done = ipr_reset_ioa_job; - add_timer(&ipr_cmd->timer); - list_add_tail(&ipr_cmd->queue, &ioa_cfg->pending_q); - - return IPR_RC_JOB_RETURN; + memset(ioa_cfg->cfg_table, 0, sizeof(struct ipr_config_table)); } /** @@ -7163,7 +6373,7 @@ static int ipr_reset_enable_ioa(struct ipr_cmnd *ipr_cmd) volatile u32 int_reg; ENTER; - ipr_cmd->job_step = ipr_ioafp_identify_hrrq; + ipr_cmd->job_step = ipr_ioafp_indentify_hrrq; ipr_init_ioa_mem(ioa_cfg); ioa_cfg->allow_interrupts = 1; @@ -7171,27 +6381,19 @@ static int ipr_reset_enable_ioa(struct ipr_cmnd *ipr_cmd) if (int_reg & IPR_PCII_IOA_TRANS_TO_OPER) { writel((IPR_PCII_ERROR_INTERRUPTS | IPR_PCII_HRRQ_UPDATED), - ioa_cfg->regs.clr_interrupt_mask_reg32); + ioa_cfg->regs.clr_interrupt_mask_reg); int_reg = readl(ioa_cfg->regs.sense_interrupt_mask_reg); return IPR_RC_JOB_CONTINUE; } /* Enable destructive diagnostics on IOA */ - writel(ioa_cfg->doorbell, ioa_cfg->regs.set_uproc_interrupt_reg32); - - writel(IPR_PCII_OPER_INTERRUPTS, ioa_cfg->regs.clr_interrupt_mask_reg32); - if (ioa_cfg->sis64) - writel(IPR_PCII_IPL_STAGE_CHANGE, ioa_cfg->regs.clr_interrupt_mask_reg); + writel(ioa_cfg->doorbell, ioa_cfg->regs.set_uproc_interrupt_reg); + writel(IPR_PCII_OPER_INTERRUPTS, ioa_cfg->regs.clr_interrupt_mask_reg); int_reg = readl(ioa_cfg->regs.sense_interrupt_mask_reg); dev_info(&ioa_cfg->pdev->dev, "Initializing IOA.\n"); - if (ioa_cfg->sis64) { - ipr_cmd->job_step = ipr_reset_next_stage; - return IPR_RC_JOB_CONTINUE; - } - ipr_cmd->timer.data = (unsigned long) ipr_cmd; ipr_cmd->timer.expires = jiffies + (ioa_cfg->transop_timeout * HZ); ipr_cmd->timer.function = (void (*)(unsigned long))ipr_oper_timeout; @@ -7261,7 +6463,7 @@ static void ipr_get_unit_check_buffer(struct ipr_ioa_cfg *ioa_cfg) mailbox = readl(ioa_cfg->ioa_mailbox); - if (!ioa_cfg->sis64 && !ipr_sdt_is_fmt2(mailbox)) { + if (!ipr_sdt_is_fmt2(mailbox)) { ipr_unit_check_no_data(ioa_cfg); return; } @@ -7270,20 +6472,15 @@ static void ipr_get_unit_check_buffer(struct ipr_ioa_cfg *ioa_cfg) rc = ipr_get_ldump_data_section(ioa_cfg, mailbox, (__be32 *) &sdt, (sizeof(struct ipr_uc_sdt)) / sizeof(__be32)); - if (rc || !(sdt.entry[0].flags & IPR_SDT_VALID_ENTRY) || - ((be32_to_cpu(sdt.hdr.state) != IPR_FMT3_SDT_READY_TO_USE) && - (be32_to_cpu(sdt.hdr.state) != IPR_FMT2_SDT_READY_TO_USE))) { + if (rc || (be32_to_cpu(sdt.hdr.state) != IPR_FMT2_SDT_READY_TO_USE) || + !(sdt.entry[0].flags & IPR_SDT_VALID_ENTRY)) { ipr_unit_check_no_data(ioa_cfg); return; } /* Find length of the first sdt entry (UC buffer) */ - if (be32_to_cpu(sdt.hdr.state) == IPR_FMT3_SDT_READY_TO_USE) - length = be32_to_cpu(sdt.entry[0].end_token); - else - length = (be32_to_cpu(sdt.entry[0].end_token) - - be32_to_cpu(sdt.entry[0].start_token)) & - IPR_FMT2_MBX_ADDR_MASK; + length = (be32_to_cpu(sdt.entry[0].end_offset) - + be32_to_cpu(sdt.entry[0].bar_str_offset)) & IPR_FMT2_MBX_ADDR_MASK; hostrcb = list_entry(ioa_cfg->hostrcb_free_q.next, struct ipr_hostrcb, queue); @@ -7291,13 +6488,13 @@ static void ipr_get_unit_check_buffer(struct ipr_ioa_cfg *ioa_cfg) memset(&hostrcb->hcam, 0, sizeof(hostrcb->hcam)); rc = ipr_get_ldump_data_section(ioa_cfg, - be32_to_cpu(sdt.entry[0].start_token), + be32_to_cpu(sdt.entry[0].bar_str_offset), (__be32 *)&hostrcb->hcam, min(length, (int)sizeof(hostrcb->hcam)) / sizeof(__be32)); if (!rc) { ipr_handle_log_data(ioa_cfg, hostrcb); - ioasc = be32_to_cpu(hostrcb->hcam.u.error.fd_ioasc); + ioasc = be32_to_cpu(hostrcb->hcam.u.error.failing_dev_ioasc); if (ioasc == IPR_IOASC_NR_IOA_RESET_REQUIRED && ioa_cfg->sdt_state == GET_DUMP) ioa_cfg->sdt_state = WAIT_FOR_DUMP; @@ -7525,7 +6722,7 @@ static int ipr_reset_alert(struct ipr_cmnd *ipr_cmd) if ((rc == PCIBIOS_SUCCESSFUL) && (cmd_reg & PCI_COMMAND_MEMORY)) { ipr_mask_and_clear_interrupts(ioa_cfg, ~0); - writel(IPR_UPROCI_RESET_ALERT, ioa_cfg->regs.set_uproc_interrupt_reg32); + writel(IPR_UPROCI_RESET_ALERT, ioa_cfg->regs.set_uproc_interrupt_reg); ipr_cmd->job_step = ipr_reset_wait_to_start_bist; } else { ipr_cmd->job_step = ioa_cfg->reset; @@ -7588,10 +6785,7 @@ static int ipr_reset_ucode_download(struct ipr_cmnd *ipr_cmd) ipr_cmd->ioarcb.cmd_pkt.cdb[7] = (sglist->buffer_len & 0x00ff00) >> 8; ipr_cmd->ioarcb.cmd_pkt.cdb[8] = sglist->buffer_len & 0x0000ff; - if (ioa_cfg->sis64) - ipr_build_ucode_ioadl64(ipr_cmd, sglist); - else - ipr_build_ucode_ioadl(ipr_cmd, sglist); + ipr_build_ucode_ioadl(ipr_cmd, sglist); ipr_cmd->job_step = ipr_reset_ucode_download_done; ipr_do_req(ipr_cmd, ipr_reset_ioa_job, ipr_timeout, @@ -7960,8 +7154,8 @@ static void ipr_free_mem(struct ipr_ioa_cfg *ioa_cfg) ipr_free_cmd_blks(ioa_cfg); pci_free_consistent(ioa_cfg->pdev, sizeof(u32) * IPR_NUM_CMD_BLKS, ioa_cfg->host_rrq, ioa_cfg->host_rrq_dma); - pci_free_consistent(ioa_cfg->pdev, ioa_cfg->cfg_table_size, - ioa_cfg->u.cfg_table, + pci_free_consistent(ioa_cfg->pdev, sizeof(struct ipr_config_table), + ioa_cfg->cfg_table, ioa_cfg->cfg_table_dma); for (i = 0; i < IPR_NUM_HCAMS; i++) { @@ -8015,7 +7209,7 @@ static int __devinit ipr_alloc_cmd_blks(struct ipr_ioa_cfg *ioa_cfg) int i; ioa_cfg->ipr_cmd_pool = pci_pool_create (IPR_NAME, ioa_cfg->pdev, - sizeof(struct ipr_cmnd), 16, 0); + sizeof(struct ipr_cmnd), 8, 0); if (!ioa_cfg->ipr_cmd_pool) return -ENOMEM; @@ -8033,25 +7227,13 @@ static int __devinit ipr_alloc_cmd_blks(struct ipr_ioa_cfg *ioa_cfg) ioa_cfg->ipr_cmnd_list_dma[i] = dma_addr; ioarcb = &ipr_cmd->ioarcb; - ipr_cmd->dma_addr = dma_addr; - if (ioa_cfg->sis64) - ioarcb->a.ioarcb_host_pci_addr64 = cpu_to_be64(dma_addr); - else - ioarcb->a.ioarcb_host_pci_addr = cpu_to_be32(dma_addr); - + ioarcb->ioarcb_host_pci_addr = cpu_to_be32(dma_addr); ioarcb->host_response_handle = cpu_to_be32(i << 2); - if (ioa_cfg->sis64) { - ioarcb->u.sis64_addr_data.data_ioadl_addr = - cpu_to_be64(dma_addr + offsetof(struct ipr_cmnd, i.ioadl64)); - ioarcb->u.sis64_addr_data.ioasa_host_pci_addr = - cpu_to_be64(dma_addr + offsetof(struct ipr_cmnd, ioasa)); - } else { - ioarcb->write_ioadl_addr = - cpu_to_be32(dma_addr + offsetof(struct ipr_cmnd, i.ioadl)); - ioarcb->read_ioadl_addr = ioarcb->write_ioadl_addr; - ioarcb->ioasa_host_pci_addr = - cpu_to_be32(dma_addr + offsetof(struct ipr_cmnd, ioasa)); - } + ioarcb->write_ioadl_addr = + cpu_to_be32(dma_addr + offsetof(struct ipr_cmnd, ioadl)); + ioarcb->read_ioadl_addr = ioarcb->write_ioadl_addr; + ioarcb->ioasa_host_pci_addr = + cpu_to_be32(dma_addr + offsetof(struct ipr_cmnd, ioasa)); ioarcb->ioasa_len = cpu_to_be16(sizeof(struct ipr_ioasa)); ipr_cmd->cmd_index = i; ipr_cmd->ioa_cfg = ioa_cfg; @@ -8078,24 +7260,13 @@ static int __devinit ipr_alloc_mem(struct ipr_ioa_cfg *ioa_cfg) ENTER; ioa_cfg->res_entries = kzalloc(sizeof(struct ipr_resource_entry) * - ioa_cfg->max_devs_supported, GFP_KERNEL); + IPR_MAX_PHYSICAL_DEVS, GFP_KERNEL); if (!ioa_cfg->res_entries) goto out; - if (ioa_cfg->sis64) { - ioa_cfg->target_ids = kzalloc(sizeof(unsigned long) * - BITS_TO_LONGS(ioa_cfg->max_devs_supported), GFP_KERNEL); - ioa_cfg->array_ids = kzalloc(sizeof(unsigned long) * - BITS_TO_LONGS(ioa_cfg->max_devs_supported), GFP_KERNEL); - ioa_cfg->vset_ids = kzalloc(sizeof(unsigned long) * - BITS_TO_LONGS(ioa_cfg->max_devs_supported), GFP_KERNEL); - } - - for (i = 0; i < ioa_cfg->max_devs_supported; i++) { + for (i = 0; i < IPR_MAX_PHYSICAL_DEVS; i++) list_add_tail(&ioa_cfg->res_entries[i].queue, &ioa_cfg->free_res_q); - ioa_cfg->res_entries[i].ioa_cfg = ioa_cfg; - } ioa_cfg->vpd_cbs = pci_alloc_consistent(ioa_cfg->pdev, sizeof(struct ipr_misc_cbs), @@ -8114,11 +7285,11 @@ static int __devinit ipr_alloc_mem(struct ipr_ioa_cfg *ioa_cfg) if (!ioa_cfg->host_rrq) goto out_ipr_free_cmd_blocks; - ioa_cfg->u.cfg_table = pci_alloc_consistent(ioa_cfg->pdev, - ioa_cfg->cfg_table_size, - &ioa_cfg->cfg_table_dma); + ioa_cfg->cfg_table = pci_alloc_consistent(ioa_cfg->pdev, + sizeof(struct ipr_config_table), + &ioa_cfg->cfg_table_dma); - if (!ioa_cfg->u.cfg_table) + if (!ioa_cfg->cfg_table) goto out_free_host_rrq; for (i = 0; i < IPR_NUM_HCAMS; i++) { @@ -8152,9 +7323,8 @@ static int __devinit ipr_alloc_mem(struct ipr_ioa_cfg *ioa_cfg) ioa_cfg->hostrcb[i], ioa_cfg->hostrcb_dma[i]); } - pci_free_consistent(pdev, ioa_cfg->cfg_table_size, - ioa_cfg->u.cfg_table, - ioa_cfg->cfg_table_dma); + pci_free_consistent(pdev, sizeof(struct ipr_config_table), + ioa_cfg->cfg_table, ioa_cfg->cfg_table_dma); out_free_host_rrq: pci_free_consistent(pdev, sizeof(u32) * IPR_NUM_CMD_BLKS, ioa_cfg->host_rrq, ioa_cfg->host_rrq_dma); @@ -8229,21 +7399,15 @@ static void __devinit ipr_init_ioa_cfg(struct ipr_ioa_cfg *ioa_cfg, init_waitqueue_head(&ioa_cfg->reset_wait_q); init_waitqueue_head(&ioa_cfg->msi_wait_q); ioa_cfg->sdt_state = INACTIVE; + if (ipr_enable_cache) + ioa_cfg->cache_state = CACHE_ENABLED; + else + ioa_cfg->cache_state = CACHE_DISABLED; ipr_initialize_bus_attr(ioa_cfg); - ioa_cfg->max_devs_supported = ipr_max_devs; - if (ioa_cfg->sis64) { - host->max_id = IPR_MAX_SIS64_TARGETS_PER_BUS; - host->max_lun = IPR_MAX_SIS64_LUNS_PER_TARGET; - if (ipr_max_devs > IPR_MAX_SIS64_DEVS) - ioa_cfg->max_devs_supported = IPR_MAX_SIS64_DEVS; - } else { - host->max_id = IPR_MAX_NUM_TARGETS_PER_BUS; - host->max_lun = IPR_MAX_NUM_LUNS_PER_TARGET; - if (ipr_max_devs > IPR_MAX_PHYSICAL_DEVS) - ioa_cfg->max_devs_supported = IPR_MAX_PHYSICAL_DEVS; - } + host->max_id = IPR_MAX_NUM_TARGETS_PER_BUS; + host->max_lun = IPR_MAX_NUM_LUNS_PER_TARGET; host->max_channel = IPR_MAX_BUS_TO_SCAN; host->unique_id = host->host_no; host->max_cmd_len = IPR_MAX_CDB_LEN; @@ -8255,26 +7419,13 @@ static void __devinit ipr_init_ioa_cfg(struct ipr_ioa_cfg *ioa_cfg, t->set_interrupt_mask_reg = base + p->set_interrupt_mask_reg; t->clr_interrupt_mask_reg = base + p->clr_interrupt_mask_reg; - t->clr_interrupt_mask_reg32 = base + p->clr_interrupt_mask_reg32; t->sense_interrupt_mask_reg = base + p->sense_interrupt_mask_reg; - t->sense_interrupt_mask_reg32 = base + p->sense_interrupt_mask_reg32; t->clr_interrupt_reg = base + p->clr_interrupt_reg; - t->clr_interrupt_reg32 = base + p->clr_interrupt_reg32; t->sense_interrupt_reg = base + p->sense_interrupt_reg; - t->sense_interrupt_reg32 = base + p->sense_interrupt_reg32; t->ioarrin_reg = base + p->ioarrin_reg; t->sense_uproc_interrupt_reg = base + p->sense_uproc_interrupt_reg; - t->sense_uproc_interrupt_reg32 = base + p->sense_uproc_interrupt_reg32; t->set_uproc_interrupt_reg = base + p->set_uproc_interrupt_reg; - t->set_uproc_interrupt_reg32 = base + p->set_uproc_interrupt_reg32; t->clr_uproc_interrupt_reg = base + p->clr_uproc_interrupt_reg; - t->clr_uproc_interrupt_reg32 = base + p->clr_uproc_interrupt_reg32; - - if (ioa_cfg->sis64) { - t->init_feedback_reg = base + p->init_feedback_reg; - t->dump_addr_reg = base + p->dump_addr_reg; - t->dump_data_reg = base + p->dump_data_reg; - } } /** @@ -8346,7 +7497,7 @@ static int __devinit ipr_test_msi(struct ipr_ioa_cfg *ioa_cfg, init_waitqueue_head(&ioa_cfg->msi_wait_q); ioa_cfg->msi_received = 0; ipr_mask_and_clear_interrupts(ioa_cfg, ~IPR_PCII_IOA_TRANS_TO_OPER); - writel(IPR_PCII_IO_DEBUG_ACKNOWLEDGE, ioa_cfg->regs.clr_interrupt_mask_reg32); + writel(IPR_PCII_IO_DEBUG_ACKNOWLEDGE, ioa_cfg->regs.clr_interrupt_mask_reg); int_reg = readl(ioa_cfg->regs.sense_interrupt_mask_reg); spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); @@ -8357,7 +7508,7 @@ static int __devinit ipr_test_msi(struct ipr_ioa_cfg *ioa_cfg, } else if (ipr_debug) dev_info(&pdev->dev, "IRQ assigned: %d\n", pdev->irq); - writel(IPR_PCII_IO_DEBUG_ACKNOWLEDGE, ioa_cfg->regs.sense_interrupt_reg32); + writel(IPR_PCII_IO_DEBUG_ACKNOWLEDGE, ioa_cfg->regs.sense_interrupt_reg); int_reg = readl(ioa_cfg->regs.sense_interrupt_reg); wait_event_timeout(ioa_cfg->msi_wait_q, ioa_cfg->msi_received, HZ); ipr_mask_and_clear_interrupts(ioa_cfg, ~IPR_PCII_IOA_TRANS_TO_OPER); @@ -8427,8 +7578,6 @@ static int __devinit ipr_probe_ioa(struct pci_dev *pdev, goto out_scsi_host_put; } - /* set SIS 32 or SIS 64 */ - ioa_cfg->sis64 = ioa_cfg->ipr_chip->sis_type == IPR_SIS64 ? 1 : 0; ioa_cfg->chip_cfg = ioa_cfg->ipr_chip->cfg; if (ipr_transop_timeout) @@ -8466,16 +7615,7 @@ static int __devinit ipr_probe_ioa(struct pci_dev *pdev, pci_set_master(pdev); - if (ioa_cfg->sis64) { - rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(64)); - if (rc < 0) { - dev_dbg(&pdev->dev, "Failed to set 64 bit PCI DMA mask\n"); - rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); - } - - } else - rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); - + rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); if (rc < 0) { dev_err(&pdev->dev, "Failed to set PCI DMA mask\n"); goto cleanup_nomem; @@ -8517,15 +7657,6 @@ static int __devinit ipr_probe_ioa(struct pci_dev *pdev, if ((rc = ipr_set_pcix_cmd_reg(ioa_cfg))) goto cleanup_nomem; - if (ioa_cfg->sis64) - ioa_cfg->cfg_table_size = (sizeof(struct ipr_config_table_hdr64) - + ((sizeof(struct ipr_config_table_entry64) - * ioa_cfg->max_devs_supported))); - else - ioa_cfg->cfg_table_size = (sizeof(struct ipr_config_table_hdr) - + ((sizeof(struct ipr_config_table_entry) - * ioa_cfg->max_devs_supported))); - rc = ipr_alloc_mem(ioa_cfg); if (rc < 0) { dev_err(&pdev->dev, @@ -8537,9 +7668,9 @@ static int __devinit ipr_probe_ioa(struct pci_dev *pdev, * If HRRQ updated interrupt is not masked, or reset alert is set, * the card is in an unknown state and needs a hard reset */ - mask = readl(ioa_cfg->regs.sense_interrupt_mask_reg32); - interrupts = readl(ioa_cfg->regs.sense_interrupt_reg32); - uproc = readl(ioa_cfg->regs.sense_uproc_interrupt_reg32); + mask = readl(ioa_cfg->regs.sense_interrupt_mask_reg); + interrupts = readl(ioa_cfg->regs.sense_interrupt_reg); + uproc = readl(ioa_cfg->regs.sense_uproc_interrupt_reg); if ((mask & IPR_PCII_HRRQ_UPDATED) == 0 || (uproc & IPR_UPROCI_RESET_ALERT)) ioa_cfg->needs_hard_reset = 1; if (interrupts & IPR_PCII_ERROR_INTERRUPTS) @@ -8826,6 +7957,9 @@ static struct pci_device_id ipr_pci_table[] __devinitdata = { { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN_E, PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_574E, 0, 0, IPR_USE_LONG_TRANSOP_TIMEOUT }, + { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN_E, + PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_575D, 0, 0, + IPR_USE_LONG_TRANSOP_TIMEOUT }, { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN_E, PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57B3, 0, 0, 0 }, { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN_E, @@ -8841,22 +7975,9 @@ static struct pci_device_id ipr_pci_table[] __devinitdata = { { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP, PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572F, 0, 0, IPR_USE_LONG_TRANSOP_TIMEOUT }, - { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CROC_FPGA_E2, - PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57B5, 0, 0, 0 }, - { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CROC_FPGA_E2, - PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_574D, 0, 0, 0 }, - { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CROC_FPGA_E2, - PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57B2, 0, 0, 0 }, - { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CROC_ASIC_E2, - PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57B4, 0, 0, 0 }, - { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CROC_ASIC_E2, - PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57B1, 0, 0, 0 }, - { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CROC_ASIC_E2, - PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57C6, 0, 0, 0 }, - { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CROC_ASIC_E2, - PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_575D, 0, 0, 0 }, - { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CROC_ASIC_E2, - PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57CE, 0, 0, 0 }, + { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_SCAMP_E, + PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_574D, 0, 0, + IPR_USE_LONG_TRANSOP_TIMEOUT }, { } }; MODULE_DEVICE_TABLE(pci, ipr_pci_table); @@ -8875,61 +7996,6 @@ static struct pci_driver ipr_driver = { .err_handler = &ipr_err_handler, }; -/** - * ipr_halt_done - Shutdown prepare completion - * - * Return value: - * none - **/ -static void ipr_halt_done(struct ipr_cmnd *ipr_cmd) -{ - struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; - - list_add_tail(&ipr_cmd->queue, &ioa_cfg->free_q); -} - -/** - * ipr_halt - Issue shutdown prepare to all adapters - * - * Return value: - * NOTIFY_OK on success / NOTIFY_DONE on failure - **/ -static int ipr_halt(struct notifier_block *nb, ulong event, void *buf) -{ - struct ipr_cmnd *ipr_cmd; - struct ipr_ioa_cfg *ioa_cfg; - unsigned long flags = 0; - - if (event != SYS_RESTART && event != SYS_HALT && event != SYS_POWER_OFF) - return NOTIFY_DONE; - - spin_lock(&ipr_driver_lock); - - list_for_each_entry(ioa_cfg, &ipr_ioa_head, queue) { - spin_lock_irqsave(ioa_cfg->host->host_lock, flags); - if (!ioa_cfg->allow_cmds) { - spin_unlock_irqrestore(ioa_cfg->host->host_lock, flags); - continue; - } - - ipr_cmd = ipr_get_free_ipr_cmnd(ioa_cfg); - ipr_cmd->ioarcb.res_handle = cpu_to_be32(IPR_IOA_RES_HANDLE); - ipr_cmd->ioarcb.cmd_pkt.request_type = IPR_RQTYPE_IOACMD; - ipr_cmd->ioarcb.cmd_pkt.cdb[0] = IPR_IOA_SHUTDOWN; - ipr_cmd->ioarcb.cmd_pkt.cdb[1] = IPR_SHUTDOWN_PREPARE_FOR_NORMAL; - - ipr_do_req(ipr_cmd, ipr_halt_done, ipr_timeout, IPR_DEVICE_RESET_TIMEOUT); - spin_unlock_irqrestore(ioa_cfg->host->host_lock, flags); - } - spin_unlock(&ipr_driver_lock); - - return NOTIFY_OK; -} - -static struct notifier_block ipr_notifier = { - ipr_halt, NULL, 0 -}; - /** * ipr_init - Module entry point * @@ -8941,7 +8007,6 @@ static int __init ipr_init(void) ipr_info("IBM Power RAID SCSI Device Driver version: %s %s\n", IPR_DRIVER_VERSION, IPR_DRIVER_DATE); - register_reboot_notifier(&ipr_notifier); return pci_register_driver(&ipr_driver); } @@ -8955,7 +8020,6 @@ static int __init ipr_init(void) **/ static void __exit ipr_exit(void) { - unregister_reboot_notifier(&ipr_notifier); pci_unregister_driver(&ipr_driver); } diff --git a/trunk/drivers/scsi/ipr.h b/trunk/drivers/scsi/ipr.h index 4c267b5e0b96..19bbcf39f0c9 100644 --- a/trunk/drivers/scsi/ipr.h +++ b/trunk/drivers/scsi/ipr.h @@ -37,8 +37,8 @@ /* * Literals */ -#define IPR_DRIVER_VERSION "2.5.0" -#define IPR_DRIVER_DATE "(February 11, 2010)" +#define IPR_DRIVER_VERSION "2.4.3" +#define IPR_DRIVER_DATE "(June 10, 2009)" /* * IPR_MAX_CMD_PER_LUN: This defines the maximum number of outstanding @@ -55,9 +55,7 @@ #define IPR_NUM_BASE_CMD_BLKS 100 #define PCI_DEVICE_ID_IBM_OBSIDIAN_E 0x0339 - -#define PCI_DEVICE_ID_IBM_CROC_FPGA_E2 0x033D -#define PCI_DEVICE_ID_IBM_CROC_ASIC_E2 0x034A +#define PCI_DEVICE_ID_IBM_SCAMP_E 0x034A #define IPR_SUBS_DEV_ID_2780 0x0264 #define IPR_SUBS_DEV_ID_5702 0x0266 @@ -72,24 +70,15 @@ #define IPR_SUBS_DEV_ID_572A 0x02C1 #define IPR_SUBS_DEV_ID_572B 0x02C2 #define IPR_SUBS_DEV_ID_572F 0x02C3 +#define IPR_SUBS_DEV_ID_574D 0x030B #define IPR_SUBS_DEV_ID_574E 0x030A #define IPR_SUBS_DEV_ID_575B 0x030D #define IPR_SUBS_DEV_ID_575C 0x0338 +#define IPR_SUBS_DEV_ID_575D 0x033E #define IPR_SUBS_DEV_ID_57B3 0x033A #define IPR_SUBS_DEV_ID_57B7 0x0360 #define IPR_SUBS_DEV_ID_57B8 0x02C2 -#define IPR_SUBS_DEV_ID_57B4 0x033B -#define IPR_SUBS_DEV_ID_57B2 0x035F -#define IPR_SUBS_DEV_ID_57C6 0x0357 - -#define IPR_SUBS_DEV_ID_57B5 0x033C -#define IPR_SUBS_DEV_ID_57CE 0x035E -#define IPR_SUBS_DEV_ID_57B1 0x0355 - -#define IPR_SUBS_DEV_ID_574D 0x0356 -#define IPR_SUBS_DEV_ID_575D 0x035D - #define IPR_NAME "ipr" /* @@ -129,10 +118,6 @@ #define IPR_NUM_LOG_HCAMS 2 #define IPR_NUM_CFG_CHG_HCAMS 2 #define IPR_NUM_HCAMS (IPR_NUM_LOG_HCAMS + IPR_NUM_CFG_CHG_HCAMS) - -#define IPR_MAX_SIS64_TARGETS_PER_BUS 1024 -#define IPR_MAX_SIS64_LUNS_PER_TARGET 0xffffffff - #define IPR_MAX_NUM_TARGETS_PER_BUS 256 #define IPR_MAX_NUM_LUNS_PER_TARGET 256 #define IPR_MAX_NUM_VSET_LUNS_PER_TARGET 8 @@ -147,15 +132,13 @@ /* We need resources for HCAMS, IOA reset, IOA bringdown, and ERP */ #define IPR_NUM_INTERNAL_CMD_BLKS (IPR_NUM_HCAMS + \ - ((IPR_NUM_RESET_RELOAD_RETRIES + 1) * 2) + 4) + ((IPR_NUM_RESET_RELOAD_RETRIES + 1) * 2) + 3) #define IPR_MAX_COMMANDS IPR_NUM_BASE_CMD_BLKS #define IPR_NUM_CMD_BLKS (IPR_NUM_BASE_CMD_BLKS + \ IPR_NUM_INTERNAL_CMD_BLKS) #define IPR_MAX_PHYSICAL_DEVS 192 -#define IPR_DEFAULT_SIS64_DEVS 1024 -#define IPR_MAX_SIS64_DEVS 4096 #define IPR_MAX_SGLIST 64 #define IPR_IOA_MAX_SECTORS 32767 @@ -190,7 +173,6 @@ #define IPR_HCAM_CDB_OP_CODE_CONFIG_CHANGE 0x01 #define IPR_HCAM_CDB_OP_CODE_LOG_DATA 0x02 #define IPR_SET_SUPPORTED_DEVICES 0xFB -#define IPR_SET_ALL_SUPPORTED_DEVICES 0x80 #define IPR_IOA_SHUTDOWN 0xF7 #define IPR_WR_BUF_DOWNLOAD_AND_SAVE 0x05 @@ -239,17 +221,9 @@ #define IPR_SDT_FMT2_BAR5_SEL 0x5 #define IPR_SDT_FMT2_EXP_ROM_SEL 0x8 #define IPR_FMT2_SDT_READY_TO_USE 0xC4D4E3F2 -#define IPR_FMT3_SDT_READY_TO_USE 0xC4D4E3F3 #define IPR_DOORBELL 0x82800000 #define IPR_RUNTIME_RESET 0x40000000 -#define IPR_IPL_INIT_MIN_STAGE_TIME 5 -#define IPR_IPL_INIT_STAGE_UNKNOWN 0x0 -#define IPR_IPL_INIT_STAGE_TRANSOP 0xB0000000 -#define IPR_IPL_INIT_STAGE_MASK 0xff000000 -#define IPR_IPL_INIT_STAGE_TIME_MASK 0x0000ffff -#define IPR_PCII_IPL_STAGE_CHANGE (0x80000000 >> 0) - #define IPR_PCII_IOA_TRANS_TO_OPER (0x80000000 >> 0) #define IPR_PCII_IOARCB_XFER_FAILED (0x80000000 >> 3) #define IPR_PCII_IOA_UNIT_CHECKED (0x80000000 >> 4) @@ -344,27 +318,27 @@ struct ipr_std_inq_data { u8 serial_num[IPR_SERIAL_NUM_LEN]; }__attribute__ ((packed)); -#define IPR_RES_TYPE_AF_DASD 0x00 -#define IPR_RES_TYPE_GENERIC_SCSI 0x01 -#define IPR_RES_TYPE_VOLUME_SET 0x02 -#define IPR_RES_TYPE_REMOTE_AF_DASD 0x03 -#define IPR_RES_TYPE_GENERIC_ATA 0x04 -#define IPR_RES_TYPE_ARRAY 0x05 -#define IPR_RES_TYPE_IOAFP 0xff - struct ipr_config_table_entry { u8 proto; #define IPR_PROTO_SATA 0x02 #define IPR_PROTO_SATA_ATAPI 0x03 #define IPR_PROTO_SAS_STP 0x06 -#define IPR_PROTO_SAS_STP_ATAPI 0x07 +#define IPR_PROTO_SAS_STP_ATAPI 0x07 u8 array_id; u8 flags; -#define IPR_IS_IOA_RESOURCE 0x80 - u8 rsvd_subtype; +#define IPR_IS_IOA_RESOURCE 0x80 +#define IPR_IS_ARRAY_MEMBER 0x20 +#define IPR_IS_HOT_SPARE 0x10 -#define IPR_QUEUEING_MODEL(res) ((((res)->flags) & 0x70) >> 4) -#define IPR_QUEUE_FROZEN_MODEL 0 + u8 rsvd_subtype; +#define IPR_RES_SUBTYPE(res) (((res)->cfgte.rsvd_subtype) & 0x0f) +#define IPR_SUBTYPE_AF_DASD 0 +#define IPR_SUBTYPE_GENERIC_SCSI 1 +#define IPR_SUBTYPE_VOLUME_SET 2 +#define IPR_SUBTYPE_GENERIC_ATA 4 + +#define IPR_QUEUEING_MODEL(res) ((((res)->cfgte.flags) & 0x70) >> 4) +#define IPR_QUEUE_FROZEN_MODEL 0 #define IPR_QUEUE_NACA_MODEL 1 struct ipr_res_addr res_addr; @@ -373,28 +347,6 @@ struct ipr_config_table_entry { struct ipr_std_inq_data std_inq_data; }__attribute__ ((packed, aligned (4))); -struct ipr_config_table_entry64 { - u8 res_type; - u8 proto; - u8 vset_num; - u8 array_id; - __be16 flags; - __be16 res_flags; -#define IPR_QUEUEING_MODEL64(res) ((((res)->res_flags) & 0x7000) >> 12) - __be32 res_handle; - u8 dev_id_type; - u8 reserved[3]; - __be64 dev_id; - __be64 lun; - __be64 lun_wwn[2]; -#define IPR_MAX_RES_PATH_LENGTH 24 - __be64 res_path; - struct ipr_std_inq_data std_inq_data; - u8 reserved2[4]; - __be64 reserved3[2]; // description text - u8 reserved4[8]; -}__attribute__ ((packed, aligned (8))); - struct ipr_config_table_hdr { u8 num_entries; u8 flags; @@ -402,35 +354,13 @@ struct ipr_config_table_hdr { __be16 reserved; }__attribute__((packed, aligned (4))); -struct ipr_config_table_hdr64 { - __be16 num_entries; - __be16 reserved; - u8 flags; - u8 reserved2[11]; -}__attribute__((packed, aligned (4))); - struct ipr_config_table { struct ipr_config_table_hdr hdr; - struct ipr_config_table_entry dev[0]; + struct ipr_config_table_entry dev[IPR_MAX_PHYSICAL_DEVS]; }__attribute__((packed, aligned (4))); -struct ipr_config_table64 { - struct ipr_config_table_hdr64 hdr64; - struct ipr_config_table_entry64 dev[0]; -}__attribute__((packed, aligned (8))); - -struct ipr_config_table_entry_wrapper { - union { - struct ipr_config_table_entry *cfgte; - struct ipr_config_table_entry64 *cfgte64; - } u; -}; - struct ipr_hostrcb_cfg_ch_not { - union { - struct ipr_config_table_entry cfgte; - struct ipr_config_table_entry64 cfgte64; - } u; + struct ipr_config_table_entry cfgte; u8 reserved[936]; }__attribute__((packed, aligned (4))); @@ -451,7 +381,7 @@ struct ipr_cmd_pkt { #define IPR_RQTYPE_HCAM 0x02 #define IPR_RQTYPE_ATA_PASSTHRU 0x04 - u8 reserved2; + u8 luntar_luntrn; u8 flags_hi; #define IPR_FLAGS_HI_WRITE_NOT_READ 0x80 @@ -473,7 +403,7 @@ struct ipr_cmd_pkt { __be16 timeout; }__attribute__ ((packed, aligned(4))); -struct ipr_ioarcb_ata_regs { /* 22 bytes */ +struct ipr_ioarcb_ata_regs { u8 flags; #define IPR_ATA_FLAG_PACKET_CMD 0x80 #define IPR_ATA_FLAG_XFER_TYPE_DMA 0x40 @@ -512,49 +442,28 @@ struct ipr_ioadl_desc { __be32 address; }__attribute__((packed, aligned (8))); -struct ipr_ioadl64_desc { - __be32 flags; - __be32 data_len; - __be64 address; -}__attribute__((packed, aligned (16))); - -struct ipr_ata64_ioadl { - struct ipr_ioarcb_ata_regs regs; - u16 reserved[5]; - struct ipr_ioadl64_desc ioadl64[IPR_NUM_IOADL_ENTRIES]; -}__attribute__((packed, aligned (16))); - struct ipr_ioarcb_add_data { union { struct ipr_ioarcb_ata_regs regs; struct ipr_ioadl_desc ioadl[5]; __be32 add_cmd_parms[10]; - } u; -}__attribute__ ((packed, aligned (4))); - -struct ipr_ioarcb_sis64_add_addr_ecb { - __be64 ioasa_host_pci_addr; - __be64 data_ioadl_addr; - __be64 reserved; - __be32 ext_control_buf[4]; -}__attribute__((packed, aligned (8))); + }u; +}__attribute__ ((packed, aligned(4))); /* IOA Request Control Block 128 bytes */ struct ipr_ioarcb { - union { - __be32 ioarcb_host_pci_addr; - __be64 ioarcb_host_pci_addr64; - } a; + __be32 ioarcb_host_pci_addr; + __be32 reserved; __be32 res_handle; __be32 host_response_handle; __be32 reserved1; __be32 reserved2; __be32 reserved3; - __be32 data_transfer_length; + __be32 write_data_transfer_length; __be32 read_data_transfer_length; __be32 write_ioadl_addr; - __be32 ioadl_len; + __be32 write_ioadl_len; __be32 read_ioadl_addr; __be32 read_ioadl_len; @@ -564,14 +473,8 @@ struct ipr_ioarcb { struct ipr_cmd_pkt cmd_pkt; - __be16 add_cmd_parms_offset; - __be16 add_cmd_parms_len; - - union { - struct ipr_ioarcb_add_data add_data; - struct ipr_ioarcb_sis64_add_addr_ecb sis64_addr_data; - } u; - + __be32 add_cmd_parms_len; + struct ipr_ioarcb_add_data add_data; }__attribute__((packed, aligned (4))); struct ipr_ioasa_vset { @@ -773,29 +676,12 @@ struct ipr_hostrcb_device_data_entry_enhanced { struct ipr_ext_vpd cfc_last_with_dev_vpd; }__attribute__((packed, aligned (4))); -struct ipr_hostrcb64_device_data_entry_enhanced { - struct ipr_ext_vpd vpd; - u8 ccin[4]; - u8 res_path[8]; - struct ipr_ext_vpd new_vpd; - u8 new_ccin[4]; - struct ipr_ext_vpd ioa_last_with_dev_vpd; - struct ipr_ext_vpd cfc_last_with_dev_vpd; -}__attribute__((packed, aligned (4))); - struct ipr_hostrcb_array_data_entry { struct ipr_vpd vpd; struct ipr_res_addr expected_dev_res_addr; struct ipr_res_addr dev_res_addr; }__attribute__((packed, aligned (4))); -struct ipr_hostrcb64_array_data_entry { - struct ipr_ext_vpd vpd; - u8 ccin[4]; - u8 expected_res_path[8]; - u8 res_path[8]; -}__attribute__((packed, aligned (4))); - struct ipr_hostrcb_array_data_entry_enhanced { struct ipr_ext_vpd vpd; u8 ccin[4]; @@ -847,14 +733,6 @@ struct ipr_hostrcb_type_13_error { struct ipr_hostrcb_device_data_entry_enhanced dev[3]; }__attribute__((packed, aligned (4))); -struct ipr_hostrcb_type_23_error { - struct ipr_ext_vpd ioa_vpd; - struct ipr_ext_vpd cfc_vpd; - __be32 errors_detected; - __be32 errors_logged; - struct ipr_hostrcb64_device_data_entry_enhanced dev[3]; -}__attribute__((packed, aligned (4))); - struct ipr_hostrcb_type_04_error { struct ipr_vpd ioa_vpd; struct ipr_vpd cfc_vpd; @@ -882,22 +760,6 @@ struct ipr_hostrcb_type_14_error { struct ipr_hostrcb_array_data_entry_enhanced array_member[18]; }__attribute__((packed, aligned (4))); -struct ipr_hostrcb_type_24_error { - struct ipr_ext_vpd ioa_vpd; - struct ipr_ext_vpd cfc_vpd; - u8 reserved[2]; - u8 exposed_mode_adn; -#define IPR_INVALID_ARRAY_DEV_NUM 0xff - u8 array_id; - u8 last_res_path[8]; - u8 protection_level[8]; - struct ipr_ext_vpd array_vpd; - u8 description[16]; - u8 reserved2[3]; - u8 num_entries; - struct ipr_hostrcb64_array_data_entry array_member[32]; -}__attribute__((packed, aligned (4))); - struct ipr_hostrcb_type_07_error { u8 failure_reason[64]; struct ipr_vpd vpd; @@ -935,22 +797,6 @@ struct ipr_hostrcb_config_element { __be32 wwid[2]; }__attribute__((packed, aligned (4))); -struct ipr_hostrcb64_config_element { - __be16 length; - u8 descriptor_id; -#define IPR_DESCRIPTOR_MASK 0xC0 -#define IPR_DESCRIPTOR_SIS64 0x00 - - u8 reserved; - u8 type_status; - - u8 reserved2[2]; - u8 link_rate; - - u8 res_path[8]; - __be32 wwid[2]; -}__attribute__((packed, aligned (8))); - struct ipr_hostrcb_fabric_desc { __be16 length; u8 ioa_port; @@ -972,20 +818,6 @@ struct ipr_hostrcb_fabric_desc { struct ipr_hostrcb_config_element elem[1]; }__attribute__((packed, aligned (4))); -struct ipr_hostrcb64_fabric_desc { - __be16 length; - u8 descriptor_id; - - u8 reserved; - u8 path_state; - - u8 reserved2[2]; - u8 res_path[8]; - u8 reserved3[6]; - __be16 num_entries; - struct ipr_hostrcb64_config_element elem[1]; -}__attribute__((packed, aligned (8))); - #define for_each_fabric_cfg(fabric, cfg) \ for (cfg = (fabric)->elem; \ cfg < ((fabric)->elem + be16_to_cpu((fabric)->num_entries)); \ @@ -998,17 +830,10 @@ struct ipr_hostrcb_type_20_error { struct ipr_hostrcb_fabric_desc desc[1]; }__attribute__((packed, aligned (4))); -struct ipr_hostrcb_type_30_error { - u8 failure_reason[64]; - u8 reserved[3]; - u8 num_entries; - struct ipr_hostrcb64_fabric_desc desc[1]; -}__attribute__((packed, aligned (4))); - struct ipr_hostrcb_error { - __be32 fd_ioasc; - struct ipr_res_addr fd_res_addr; - __be32 fd_res_handle; + __be32 failing_dev_ioasc; + struct ipr_res_addr failing_dev_res_addr; + __be32 failing_dev_res_handle; __be32 prc; union { struct ipr_hostrcb_type_ff_error type_ff_error; @@ -1025,26 +850,6 @@ struct ipr_hostrcb_error { } u; }__attribute__((packed, aligned (4))); -struct ipr_hostrcb64_error { - __be32 fd_ioasc; - __be32 ioa_fw_level; - __be32 fd_res_handle; - __be32 prc; - __be64 fd_dev_id; - __be64 fd_lun; - u8 fd_res_path[8]; - __be64 time_stamp; - u8 reserved[2]; - union { - struct ipr_hostrcb_type_ff_error type_ff_error; - struct ipr_hostrcb_type_12_error type_12_error; - struct ipr_hostrcb_type_17_error type_17_error; - struct ipr_hostrcb_type_23_error type_23_error; - struct ipr_hostrcb_type_24_error type_24_error; - struct ipr_hostrcb_type_30_error type_30_error; - } u; -}__attribute__((packed, aligned (8))); - struct ipr_hostrcb_raw { __be32 data[sizeof(struct ipr_hostrcb_error)/sizeof(__be32)]; }__attribute__((packed, aligned (4))); @@ -1082,11 +887,7 @@ struct ipr_hcam { #define IPR_HOST_RCB_OVERLAY_ID_16 0x16 #define IPR_HOST_RCB_OVERLAY_ID_17 0x17 #define IPR_HOST_RCB_OVERLAY_ID_20 0x20 -#define IPR_HOST_RCB_OVERLAY_ID_23 0x23 -#define IPR_HOST_RCB_OVERLAY_ID_24 0x24 -#define IPR_HOST_RCB_OVERLAY_ID_26 0x26 -#define IPR_HOST_RCB_OVERLAY_ID_30 0x30 -#define IPR_HOST_RCB_OVERLAY_ID_DEFAULT 0xFF +#define IPR_HOST_RCB_OVERLAY_ID_DEFAULT 0xFF u8 reserved1[3]; __be32 ilid; @@ -1096,7 +897,6 @@ struct ipr_hcam { union { struct ipr_hostrcb_error error; - struct ipr_hostrcb64_error error64; struct ipr_hostrcb_cfg_ch_not ccn; struct ipr_hostrcb_raw raw; } u; @@ -1107,14 +907,14 @@ struct ipr_hostrcb { dma_addr_t hostrcb_dma; struct list_head queue; struct ipr_ioa_cfg *ioa_cfg; - char rp_buffer[IPR_MAX_RES_PATH_LENGTH]; }; /* IPR smart dump table structures */ struct ipr_sdt_entry { - __be32 start_token; - __be32 end_token; - u8 reserved[4]; + __be32 bar_str_offset; + __be32 end_offset; + u8 entry_byte; + u8 reserved[3]; u8 flags; #define IPR_SDT_ENDIAN 0x80 @@ -1160,48 +960,28 @@ struct ipr_sata_port { }; struct ipr_resource_entry { + struct ipr_config_table_entry cfgte; u8 needs_sync_complete:1; u8 in_erp:1; u8 add_to_ml:1; u8 del_from_ml:1; u8 resetting_device:1; - u32 bus; /* AKA channel */ - u32 target; /* AKA id */ - u32 lun; -#define IPR_ARRAY_VIRTUAL_BUS 0x1 -#define IPR_VSET_VIRTUAL_BUS 0x2 -#define IPR_IOAFP_VIRTUAL_BUS 0x3 - -#define IPR_GET_RES_PHYS_LOC(res) \ - (((res)->bus << 24) | ((res)->target << 8) | (res)->lun) - - u8 ata_class; - - u8 flags; - __be16 res_flags; - - __be32 type; - - u8 qmodel; - struct ipr_std_inq_data std_inq_data; - - __be32 res_handle; - __be64 dev_id; - struct scsi_lun dev_lun; - u8 res_path[8]; - - struct ipr_ioa_cfg *ioa_cfg; struct scsi_device *sdev; struct ipr_sata_port *sata_port; struct list_head queue; -}; /* struct ipr_resource_entry */ +}; struct ipr_resource_hdr { u16 num_entries; u16 reserved; }; +struct ipr_resource_table { + struct ipr_resource_hdr hdr; + struct ipr_resource_entry dev[IPR_MAX_PHYSICAL_DEVS]; +}; + struct ipr_misc_cbs { struct ipr_ioa_vpd ioa_vpd; struct ipr_inquiry_page0 page0_data; @@ -1214,51 +994,27 @@ struct ipr_misc_cbs { struct ipr_interrupt_offsets { unsigned long set_interrupt_mask_reg; unsigned long clr_interrupt_mask_reg; - unsigned long clr_interrupt_mask_reg32; unsigned long sense_interrupt_mask_reg; - unsigned long sense_interrupt_mask_reg32; unsigned long clr_interrupt_reg; - unsigned long clr_interrupt_reg32; unsigned long sense_interrupt_reg; - unsigned long sense_interrupt_reg32; unsigned long ioarrin_reg; unsigned long sense_uproc_interrupt_reg; - unsigned long sense_uproc_interrupt_reg32; unsigned long set_uproc_interrupt_reg; - unsigned long set_uproc_interrupt_reg32; unsigned long clr_uproc_interrupt_reg; - unsigned long clr_uproc_interrupt_reg32; - - unsigned long init_feedback_reg; - - unsigned long dump_addr_reg; - unsigned long dump_data_reg; }; struct ipr_interrupts { void __iomem *set_interrupt_mask_reg; void __iomem *clr_interrupt_mask_reg; - void __iomem *clr_interrupt_mask_reg32; void __iomem *sense_interrupt_mask_reg; - void __iomem *sense_interrupt_mask_reg32; void __iomem *clr_interrupt_reg; - void __iomem *clr_interrupt_reg32; void __iomem *sense_interrupt_reg; - void __iomem *sense_interrupt_reg32; void __iomem *ioarrin_reg; void __iomem *sense_uproc_interrupt_reg; - void __iomem *sense_uproc_interrupt_reg32; void __iomem *set_uproc_interrupt_reg; - void __iomem *set_uproc_interrupt_reg32; void __iomem *clr_uproc_interrupt_reg; - void __iomem *clr_uproc_interrupt_reg32; - - void __iomem *init_feedback_reg; - - void __iomem *dump_addr_reg; - void __iomem *dump_data_reg; }; struct ipr_chip_cfg_t { @@ -1273,9 +1029,6 @@ struct ipr_chip_t { u16 intr_type; #define IPR_USE_LSI 0x00 #define IPR_USE_MSI 0x01 - u16 sis_type; -#define IPR_SIS32 0x00 -#define IPR_SIS64 0x01 const struct ipr_chip_cfg_t *cfg; }; @@ -1320,6 +1073,13 @@ enum ipr_sdt_state { DUMP_OBTAINED }; +enum ipr_cache_state { + CACHE_NONE, + CACHE_DISABLED, + CACHE_ENABLED, + CACHE_INVALID +}; + /* Per-controller data */ struct ipr_ioa_cfg { char eye_catcher[8]; @@ -1339,17 +1099,10 @@ struct ipr_ioa_cfg { u8 dual_raid:1; u8 needs_warm_reset:1; u8 msi_received:1; - u8 sis64:1; u8 revid; - /* - * Bitmaps for SIS64 generated target values - */ - unsigned long *target_ids; - unsigned long *array_ids; - unsigned long *vset_ids; - + enum ipr_cache_state cache_state; u16 type; /* CCIN of the card */ u8 log_level; @@ -1380,13 +1133,8 @@ struct ipr_ioa_cfg { char cfg_table_start[8]; #define IPR_CFG_TBL_START "cfg" - union { - struct ipr_config_table *cfg_table; - struct ipr_config_table64 *cfg_table64; - } u; + struct ipr_config_table *cfg_table; dma_addr_t cfg_table_dma; - u32 cfg_table_size; - u32 max_devs_supported; char resource_table_label[8]; #define IPR_RES_TABLE_LABEL "res_tbl" @@ -1454,17 +1202,13 @@ struct ipr_ioa_cfg { char ipr_cmd_label[8]; #define IPR_CMD_LABEL "ipr_cmd" struct ipr_cmnd *ipr_cmnd_list[IPR_NUM_CMD_BLKS]; - dma_addr_t ipr_cmnd_list_dma[IPR_NUM_CMD_BLKS]; -}; /* struct ipr_ioa_cfg */ + u32 ipr_cmnd_list_dma[IPR_NUM_CMD_BLKS]; +}; struct ipr_cmnd { struct ipr_ioarcb ioarcb; - union { - struct ipr_ioadl_desc ioadl[IPR_NUM_IOADL_ENTRIES]; - struct ipr_ioadl64_desc ioadl64[IPR_NUM_IOADL_ENTRIES]; - struct ipr_ata64_ioadl ata_ioadl; - } i; struct ipr_ioasa ioasa; + struct ipr_ioadl_desc ioadl[IPR_NUM_IOADL_ENTRIES]; struct list_head queue; struct scsi_cmnd *scsi_cmd; struct ata_queued_cmd *qc; @@ -1477,7 +1221,7 @@ struct ipr_cmnd { u8 sense_buffer[SCSI_SENSE_BUFFERSIZE]; dma_addr_t sense_buffer_dma; unsigned short dma_use_sg; - dma_addr_t dma_addr; + dma_addr_t dma_handle; struct ipr_cmnd *sibling; union { enum ipr_shutdown_type shutdown_type; @@ -1570,6 +1314,8 @@ struct ipr_ioa_dump { u32 next_page_index; u32 page_offset; u32 format; +#define IPR_SDT_FMT2 2 +#define IPR_SDT_UNKNOWN 3 }__attribute__((packed, aligned (4))); struct ipr_dump { @@ -1631,13 +1377,6 @@ struct ipr_ucode_image_header { #define ipr_info(...) printk(KERN_INFO IPR_NAME ": "__VA_ARGS__) #define ipr_dbg(...) IPR_DBG_CMD(printk(KERN_INFO IPR_NAME ": "__VA_ARGS__)) -#define ipr_res_printk(level, ioa_cfg, bus, target, lun, fmt, ...) \ - printk(level IPR_NAME ": %d:%d:%d:%d: " fmt, (ioa_cfg)->host->host_no, \ - bus, target, lun, ##__VA_ARGS__) - -#define ipr_res_err(ioa_cfg, res, fmt, ...) \ - ipr_res_printk(KERN_ERR, ioa_cfg, (res)->bus, (res)->target, (res)->lun, fmt, ##__VA_ARGS__) - #define ipr_ra_printk(level, ioa_cfg, ra, fmt, ...) \ printk(level IPR_NAME ": %d:%d:%d:%d: " fmt, (ioa_cfg)->host->host_no, \ (ra).bus, (ra).target, (ra).lun, ##__VA_ARGS__) @@ -1645,6 +1384,9 @@ struct ipr_ucode_image_header { #define ipr_ra_err(ioa_cfg, ra, fmt, ...) \ ipr_ra_printk(KERN_ERR, ioa_cfg, ra, fmt, ##__VA_ARGS__) +#define ipr_res_err(ioa_cfg, res, fmt, ...) \ + ipr_ra_err(ioa_cfg, (res)->cfgte.res_addr, fmt, ##__VA_ARGS__) + #define ipr_phys_res_err(ioa_cfg, res, fmt, ...) \ { \ if ((res).bus >= IPR_MAX_NUM_BUSES) { \ @@ -1657,21 +1399,14 @@ struct ipr_ucode_image_header { } #define ipr_hcam_err(hostrcb, fmt, ...) \ -{ \ - if (ipr_is_device(hostrcb)) { \ - if ((hostrcb)->ioa_cfg->sis64) { \ - printk(KERN_ERR IPR_NAME ": %s: " fmt, \ - ipr_format_resource_path(&hostrcb->hcam.u.error64.fd_res_path[0], \ - &hostrcb->rp_buffer[0]), \ - __VA_ARGS__); \ - } else { \ - ipr_ra_err((hostrcb)->ioa_cfg, \ - (hostrcb)->hcam.u.error.fd_res_addr, \ - fmt, __VA_ARGS__); \ - } \ - } else { \ - dev_err(&(hostrcb)->ioa_cfg->pdev->dev, fmt, __VA_ARGS__); \ - } \ +{ \ + if (ipr_is_device(&(hostrcb)->hcam.u.error.failing_dev_res_addr)) { \ + ipr_ra_err((hostrcb)->ioa_cfg, \ + (hostrcb)->hcam.u.error.failing_dev_res_addr, \ + fmt, ##__VA_ARGS__); \ + } else { \ + dev_err(&(hostrcb)->ioa_cfg->pdev->dev, fmt, ##__VA_ARGS__); \ + } \ } #define ipr_trace ipr_dbg("%s: %s: Line: %d\n",\ @@ -1697,7 +1432,7 @@ ipr_err("----------------------------------------------------------\n") **/ static inline int ipr_is_ioa_resource(struct ipr_resource_entry *res) { - return res->type == IPR_RES_TYPE_IOAFP; + return (res->cfgte.flags & IPR_IS_IOA_RESOURCE) ? 1 : 0; } /** @@ -1709,8 +1444,12 @@ static inline int ipr_is_ioa_resource(struct ipr_resource_entry *res) **/ static inline int ipr_is_af_dasd_device(struct ipr_resource_entry *res) { - return res->type == IPR_RES_TYPE_AF_DASD || - res->type == IPR_RES_TYPE_REMOTE_AF_DASD; + if (IPR_IS_DASD_DEVICE(res->cfgte.std_inq_data) && + !ipr_is_ioa_resource(res) && + IPR_RES_SUBTYPE(res) == IPR_SUBTYPE_AF_DASD) + return 1; + else + return 0; } /** @@ -1722,7 +1461,12 @@ static inline int ipr_is_af_dasd_device(struct ipr_resource_entry *res) **/ static inline int ipr_is_vset_device(struct ipr_resource_entry *res) { - return res->type == IPR_RES_TYPE_VOLUME_SET; + if (IPR_IS_DASD_DEVICE(res->cfgte.std_inq_data) && + !ipr_is_ioa_resource(res) && + IPR_RES_SUBTYPE(res) == IPR_SUBTYPE_VOLUME_SET) + return 1; + else + return 0; } /** @@ -1734,7 +1478,11 @@ static inline int ipr_is_vset_device(struct ipr_resource_entry *res) **/ static inline int ipr_is_gscsi(struct ipr_resource_entry *res) { - return res->type == IPR_RES_TYPE_GENERIC_SCSI; + if (!ipr_is_ioa_resource(res) && + IPR_RES_SUBTYPE(res) == IPR_SUBTYPE_GENERIC_SCSI) + return 1; + else + return 0; } /** @@ -1747,7 +1495,7 @@ static inline int ipr_is_gscsi(struct ipr_resource_entry *res) static inline int ipr_is_scsi_disk(struct ipr_resource_entry *res) { if (ipr_is_af_dasd_device(res) || - (ipr_is_gscsi(res) && IPR_IS_DASD_DEVICE(res->std_inq_data))) + (ipr_is_gscsi(res) && IPR_IS_DASD_DEVICE(res->cfgte.std_inq_data))) return 1; else return 0; @@ -1762,7 +1510,11 @@ static inline int ipr_is_scsi_disk(struct ipr_resource_entry *res) **/ static inline int ipr_is_gata(struct ipr_resource_entry *res) { - return res->type == IPR_RES_TYPE_GENERIC_ATA; + if (!ipr_is_ioa_resource(res) && + IPR_RES_SUBTYPE(res) == IPR_SUBTYPE_GENERIC_ATA) + return 1; + else + return 0; } /** @@ -1774,35 +1526,24 @@ static inline int ipr_is_gata(struct ipr_resource_entry *res) **/ static inline int ipr_is_naca_model(struct ipr_resource_entry *res) { - if (ipr_is_gscsi(res) && res->qmodel == IPR_QUEUE_NACA_MODEL) + if (ipr_is_gscsi(res) && IPR_QUEUEING_MODEL(res) == IPR_QUEUE_NACA_MODEL) return 1; return 0; } /** - * ipr_is_device - Determine if the hostrcb structure is related to a device - * @hostrcb: host resource control blocks struct + * ipr_is_device - Determine if resource address is that of a device + * @res_addr: resource address struct * * Return value: * 1 if AF / 0 if not AF **/ -static inline int ipr_is_device(struct ipr_hostrcb *hostrcb) +static inline int ipr_is_device(struct ipr_res_addr *res_addr) { - struct ipr_res_addr *res_addr; - u8 *res_path; - - if (hostrcb->ioa_cfg->sis64) { - res_path = &hostrcb->hcam.u.error64.fd_res_path[0]; - if ((res_path[0] == 0x00 || res_path[0] == 0x80 || - res_path[0] == 0x81) && res_path[2] != 0xFF) - return 1; - } else { - res_addr = &hostrcb->hcam.u.error.fd_res_addr; - - if ((res_addr->bus < IPR_MAX_NUM_BUSES) && - (res_addr->target < (IPR_MAX_NUM_TARGETS_PER_BUS - 1))) - return 1; - } + if ((res_addr->bus < IPR_MAX_NUM_BUSES) && + (res_addr->target < (IPR_MAX_NUM_TARGETS_PER_BUS - 1))) + return 1; + return 0; } diff --git a/trunk/drivers/scsi/iscsi_tcp.c b/trunk/drivers/scsi/iscsi_tcp.c index 249053a9d4fa..8a89ba900588 100644 --- a/trunk/drivers/scsi/iscsi_tcp.c +++ b/trunk/drivers/scsi/iscsi_tcp.c @@ -874,7 +874,7 @@ static struct scsi_host_template iscsi_sw_tcp_sht = { .cmd_per_lun = ISCSI_DEF_CMD_PER_LUN, .eh_abort_handler = iscsi_eh_abort, .eh_device_reset_handler= iscsi_eh_device_reset, - .eh_target_reset_handler = iscsi_eh_recover_target, + .eh_target_reset_handler= iscsi_eh_target_reset, .use_clustering = DISABLE_CLUSTERING, .slave_alloc = iscsi_sw_tcp_slave_alloc, .slave_configure = iscsi_sw_tcp_slave_configure, diff --git a/trunk/drivers/scsi/libiscsi.c b/trunk/drivers/scsi/libiscsi.c index 685eaec53218..703eb6a88790 100644 --- a/trunk/drivers/scsi/libiscsi.c +++ b/trunk/drivers/scsi/libiscsi.c @@ -2338,7 +2338,7 @@ EXPORT_SYMBOL_GPL(iscsi_session_recovery_timedout); * This function will wait for a relogin, session termination from * userspace, or a recovery/replacement timeout. */ -int iscsi_eh_session_reset(struct scsi_cmnd *sc) +static int iscsi_eh_session_reset(struct scsi_cmnd *sc) { struct iscsi_cls_session *cls_session; struct iscsi_session *session; @@ -2389,7 +2389,6 @@ int iscsi_eh_session_reset(struct scsi_cmnd *sc) mutex_unlock(&session->eh_mutex); return SUCCESS; } -EXPORT_SYMBOL_GPL(iscsi_eh_session_reset); static void iscsi_prep_tgt_reset_pdu(struct scsi_cmnd *sc, struct iscsi_tm *hdr) { @@ -2404,7 +2403,8 @@ static void iscsi_prep_tgt_reset_pdu(struct scsi_cmnd *sc, struct iscsi_tm *hdr) * iscsi_eh_target_reset - reset target * @sc: scsi command * - * This will attempt to send a warm target reset. + * This will attempt to send a warm target reset. If that fails + * then we will drop the session and attempt ERL0 recovery. */ int iscsi_eh_target_reset(struct scsi_cmnd *sc) { @@ -2476,27 +2476,12 @@ int iscsi_eh_target_reset(struct scsi_cmnd *sc) ISCSI_DBG_EH(session, "tgt %s reset result = %s\n", session->targetname, rc == SUCCESS ? "SUCCESS" : "FAILED"); mutex_unlock(&session->eh_mutex); - return rc; -} -EXPORT_SYMBOL_GPL(iscsi_eh_target_reset); -/** - * iscsi_eh_recover_target - reset target and possibly the session - * @sc: scsi command - * - * This will attempt to send a warm target reset. If that fails, - * we will escalate to ERL0 session recovery. - */ -int iscsi_eh_recover_target(struct scsi_cmnd *sc) -{ - int rc; - - rc = iscsi_eh_target_reset(sc); if (rc == FAILED) rc = iscsi_eh_session_reset(sc); return rc; } -EXPORT_SYMBOL_GPL(iscsi_eh_recover_target); +EXPORT_SYMBOL_GPL(iscsi_eh_target_reset); /* * Pre-allocate a pool of @max items of @item_size. By default, the pool diff --git a/trunk/drivers/scsi/lpfc/lpfc.h b/trunk/drivers/scsi/lpfc/lpfc.h index 565e16dd74fc..84b696463a58 100644 --- a/trunk/drivers/scsi/lpfc/lpfc.h +++ b/trunk/drivers/scsi/lpfc/lpfc.h @@ -37,9 +37,6 @@ struct lpfc_sli2_slim; the NameServer before giving up. */ #define LPFC_CMD_PER_LUN 3 /* max outstanding cmds per lun */ #define LPFC_DEFAULT_SG_SEG_CNT 64 /* sg element count per scsi cmnd */ -#define LPFC_DEFAULT_MENLO_SG_SEG_CNT 128 /* sg element count per scsi - cmnd for menlo needs nearly twice as for firmware - downloads using bsg */ #define LPFC_DEFAULT_PROT_SG_SEG_CNT 4096 /* sg protection elements count */ #define LPFC_MAX_SG_SEG_CNT 4096 /* sg element count per scsi cmnd */ #define LPFC_MAX_PROT_SG_SEG_CNT 4096 /* prot sg element count per scsi cmd*/ @@ -512,6 +509,7 @@ struct lpfc_hba { int (*lpfc_hba_down_link) (struct lpfc_hba *); + /* SLI4 specific HBA data structure */ struct lpfc_sli4_hba sli4_hba; @@ -625,9 +623,6 @@ struct lpfc_hba { uint32_t cfg_log_verbose; uint32_t cfg_aer_support; uint32_t cfg_suppress_link_up; -#define LPFC_INITIALIZE_LINK 0 /* do normal init_link mbox */ -#define LPFC_DELAY_INIT_LINK 1 /* layered driver hold off */ -#define LPFC_DELAY_INIT_LINK_INDEFINITELY 2 /* wait, manual intervention */ lpfc_vpd_t vpd; /* vital product data */ @@ -809,9 +804,6 @@ struct lpfc_hba { struct list_head ct_ev_waiters; struct unsol_rcv_ct_ctx ct_ctx[64]; uint32_t ctx_idx; - - uint8_t menlo_flag; /* menlo generic flags */ -#define HBA_MENLO_SUPPORT 0x1 /* HBA supports menlo commands */ }; static inline struct Scsi_Host * diff --git a/trunk/drivers/scsi/lpfc/lpfc_attr.c b/trunk/drivers/scsi/lpfc/lpfc_attr.c index 64cd17eedb64..c992e8328f9e 100644 --- a/trunk/drivers/scsi/lpfc/lpfc_attr.c +++ b/trunk/drivers/scsi/lpfc/lpfc_attr.c @@ -1939,9 +1939,7 @@ static DEVICE_ATTR(lpfc_enable_npiv, S_IRUGO, # 0x2 = never bring up link # Default value is 0. */ -LPFC_ATTR_R(suppress_link_up, LPFC_INITIALIZE_LINK, LPFC_INITIALIZE_LINK, - LPFC_DELAY_INIT_LINK_INDEFINITELY, - "Suppress Link Up at initialization"); +LPFC_ATTR_R(suppress_link_up, 0, 0, 2, "Suppress Link Up at initialization"); /* # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear @@ -1968,7 +1966,8 @@ lpfc_nodev_tmo_show(struct device *dev, struct device_attribute *attr, { struct Scsi_Host *shost = class_to_shost(dev); struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; - + int val = 0; + val = vport->cfg_devloss_tmo; return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_devloss_tmo); } diff --git a/trunk/drivers/scsi/lpfc/lpfc_bsg.c b/trunk/drivers/scsi/lpfc/lpfc_bsg.c index 692c29f6048e..f3f1bf1a0a71 100644 --- a/trunk/drivers/scsi/lpfc/lpfc_bsg.c +++ b/trunk/drivers/scsi/lpfc/lpfc_bsg.c @@ -83,28 +83,15 @@ struct lpfc_bsg_mbox { struct fc_bsg_job *set_job; }; -#define MENLO_DID 0x0000FC0E - -struct lpfc_bsg_menlo { - struct lpfc_iocbq *cmdiocbq; - struct lpfc_iocbq *rspiocbq; - struct lpfc_dmabuf *bmp; - - /* job waiting for this iocb to finish */ - struct fc_bsg_job *set_job; -}; - #define TYPE_EVT 1 #define TYPE_IOCB 2 #define TYPE_MBOX 3 -#define TYPE_MENLO 4 struct bsg_job_data { uint32_t type; union { struct lpfc_bsg_event *evt; struct lpfc_bsg_iocb iocb; struct lpfc_bsg_mbox mbox; - struct lpfc_bsg_menlo menlo; } context_un; }; @@ -2469,18 +2456,6 @@ static int lpfc_bsg_check_cmd_access(struct lpfc_hba *phba, case MBX_PORT_IOV_CONTROL: break; case MBX_SET_VARIABLE: - lpfc_printf_log(phba, KERN_INFO, LOG_INIT, - "1226 mbox: set_variable 0x%x, 0x%x\n", - mb->un.varWords[0], - mb->un.varWords[1]); - if ((mb->un.varWords[0] == SETVAR_MLOMNT) - && (mb->un.varWords[1] == 1)) { - phba->wait_4_mlo_maint_flg = 1; - } else if (mb->un.varWords[0] == SETVAR_MLORST) { - phba->link_flag &= ~LS_LOOPBACK_MODE; - phba->fc_topology = TOPOLOGY_PT_PT; - } - break; case MBX_RUN_BIU_DIAG64: case MBX_READ_EVENT_LOG: case MBX_READ_SPARM64: @@ -2662,297 +2637,6 @@ lpfc_bsg_mbox_cmd(struct fc_bsg_job *job) return rc; } -/** - * lpfc_bsg_menlo_cmd_cmp - lpfc_menlo_cmd completion handler - * @phba: Pointer to HBA context object. - * @cmdiocbq: Pointer to command iocb. - * @rspiocbq: Pointer to response iocb. - * - * This function is the completion handler for iocbs issued using - * lpfc_menlo_cmd function. This function is called by the - * ring event handler function without any lock held. This function - * can be called from both worker thread context and interrupt - * context. This function also can be called from another thread which - * cleans up the SLI layer objects. - * This function copies the contents of the response iocb to the - * response iocb memory object provided by the caller of - * lpfc_sli_issue_iocb_wait and then wakes up the thread which - * sleeps for the iocb completion. - **/ -static void -lpfc_bsg_menlo_cmd_cmp(struct lpfc_hba *phba, - struct lpfc_iocbq *cmdiocbq, - struct lpfc_iocbq *rspiocbq) -{ - struct bsg_job_data *dd_data; - struct fc_bsg_job *job; - IOCB_t *rsp; - struct lpfc_dmabuf *bmp; - struct lpfc_bsg_menlo *menlo; - unsigned long flags; - struct menlo_response *menlo_resp; - int rc = 0; - - spin_lock_irqsave(&phba->ct_ev_lock, flags); - dd_data = cmdiocbq->context1; - if (!dd_data) { - spin_unlock_irqrestore(&phba->ct_ev_lock, flags); - return; - } - - menlo = &dd_data->context_un.menlo; - job = menlo->set_job; - job->dd_data = NULL; /* so timeout handler does not reply */ - - spin_lock_irqsave(&phba->hbalock, flags); - cmdiocbq->iocb_flag |= LPFC_IO_WAKE; - if (cmdiocbq->context2 && rspiocbq) - memcpy(&((struct lpfc_iocbq *)cmdiocbq->context2)->iocb, - &rspiocbq->iocb, sizeof(IOCB_t)); - spin_unlock_irqrestore(&phba->hbalock, flags); - - bmp = menlo->bmp; - rspiocbq = menlo->rspiocbq; - rsp = &rspiocbq->iocb; - - pci_unmap_sg(phba->pcidev, job->request_payload.sg_list, - job->request_payload.sg_cnt, DMA_TO_DEVICE); - pci_unmap_sg(phba->pcidev, job->reply_payload.sg_list, - job->reply_payload.sg_cnt, DMA_FROM_DEVICE); - - /* always return the xri, this would be used in the case - * of a menlo download to allow the data to be sent as a continuation - * of the exchange. - */ - menlo_resp = (struct menlo_response *) - job->reply->reply_data.vendor_reply.vendor_rsp; - menlo_resp->xri = rsp->ulpContext; - if (rsp->ulpStatus) { - if (rsp->ulpStatus == IOSTAT_LOCAL_REJECT) { - switch (rsp->un.ulpWord[4] & 0xff) { - case IOERR_SEQUENCE_TIMEOUT: - rc = -ETIMEDOUT; - break; - case IOERR_INVALID_RPI: - rc = -EFAULT; - break; - default: - rc = -EACCES; - break; - } - } else - rc = -EACCES; - } else - job->reply->reply_payload_rcv_len = - rsp->un.genreq64.bdl.bdeSize; - - lpfc_mbuf_free(phba, bmp->virt, bmp->phys); - lpfc_sli_release_iocbq(phba, rspiocbq); - lpfc_sli_release_iocbq(phba, cmdiocbq); - kfree(bmp); - kfree(dd_data); - /* make error code available to userspace */ - job->reply->result = rc; - /* complete the job back to userspace */ - job->job_done(job); - spin_unlock_irqrestore(&phba->ct_ev_lock, flags); - return; -} - -/** - * lpfc_menlo_cmd - send an ioctl for menlo hardware - * @job: fc_bsg_job to handle - * - * This function issues a gen request 64 CR ioctl for all menlo cmd requests, - * all the command completions will return the xri for the command. - * For menlo data requests a gen request 64 CX is used to continue the exchange - * supplied in the menlo request header xri field. - **/ -static int -lpfc_menlo_cmd(struct fc_bsg_job *job) -{ - struct lpfc_vport *vport = (struct lpfc_vport *)job->shost->hostdata; - struct lpfc_hba *phba = vport->phba; - struct lpfc_iocbq *cmdiocbq, *rspiocbq; - IOCB_t *cmd, *rsp; - int rc = 0; - struct menlo_command *menlo_cmd; - struct menlo_response *menlo_resp; - struct lpfc_dmabuf *bmp = NULL; - int request_nseg; - int reply_nseg; - struct scatterlist *sgel = NULL; - int numbde; - dma_addr_t busaddr; - struct bsg_job_data *dd_data; - struct ulp_bde64 *bpl = NULL; - - /* in case no data is returned return just the return code */ - job->reply->reply_payload_rcv_len = 0; - - if (job->request_len < - sizeof(struct fc_bsg_request) + - sizeof(struct menlo_command)) { - lpfc_printf_log(phba, KERN_WARNING, LOG_LIBDFC, - "2784 Received MENLO_CMD request below " - "minimum size\n"); - rc = -ERANGE; - goto no_dd_data; - } - - if (job->reply_len < - sizeof(struct fc_bsg_request) + sizeof(struct menlo_response)) { - lpfc_printf_log(phba, KERN_WARNING, LOG_LIBDFC, - "2785 Received MENLO_CMD reply below " - "minimum size\n"); - rc = -ERANGE; - goto no_dd_data; - } - - if (!(phba->menlo_flag & HBA_MENLO_SUPPORT)) { - lpfc_printf_log(phba, KERN_WARNING, LOG_LIBDFC, - "2786 Adapter does not support menlo " - "commands\n"); - rc = -EPERM; - goto no_dd_data; - } - - menlo_cmd = (struct menlo_command *) - job->request->rqst_data.h_vendor.vendor_cmd; - - menlo_resp = (struct menlo_response *) - job->reply->reply_data.vendor_reply.vendor_rsp; - - /* allocate our bsg tracking structure */ - dd_data = kmalloc(sizeof(struct bsg_job_data), GFP_KERNEL); - if (!dd_data) { - lpfc_printf_log(phba, KERN_WARNING, LOG_LIBDFC, - "2787 Failed allocation of dd_data\n"); - rc = -ENOMEM; - goto no_dd_data; - } - - bmp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); - if (!bmp) { - rc = -ENOMEM; - goto free_dd; - } - - cmdiocbq = lpfc_sli_get_iocbq(phba); - if (!cmdiocbq) { - rc = -ENOMEM; - goto free_bmp; - } - - rspiocbq = lpfc_sli_get_iocbq(phba); - if (!rspiocbq) { - rc = -ENOMEM; - goto free_cmdiocbq; - } - - rsp = &rspiocbq->iocb; - - bmp->virt = lpfc_mbuf_alloc(phba, 0, &bmp->phys); - if (!bmp->virt) { - rc = -ENOMEM; - goto free_rspiocbq; - } - - INIT_LIST_HEAD(&bmp->list); - bpl = (struct ulp_bde64 *) bmp->virt; - request_nseg = pci_map_sg(phba->pcidev, job->request_payload.sg_list, - job->request_payload.sg_cnt, DMA_TO_DEVICE); - for_each_sg(job->request_payload.sg_list, sgel, request_nseg, numbde) { - busaddr = sg_dma_address(sgel); - bpl->tus.f.bdeFlags = BUFF_TYPE_BDE_64; - bpl->tus.f.bdeSize = sg_dma_len(sgel); - bpl->tus.w = cpu_to_le32(bpl->tus.w); - bpl->addrLow = cpu_to_le32(putPaddrLow(busaddr)); - bpl->addrHigh = cpu_to_le32(putPaddrHigh(busaddr)); - bpl++; - } - - reply_nseg = pci_map_sg(phba->pcidev, job->reply_payload.sg_list, - job->reply_payload.sg_cnt, DMA_FROM_DEVICE); - for_each_sg(job->reply_payload.sg_list, sgel, reply_nseg, numbde) { - busaddr = sg_dma_address(sgel); - bpl->tus.f.bdeFlags = BUFF_TYPE_BDE_64I; - bpl->tus.f.bdeSize = sg_dma_len(sgel); - bpl->tus.w = cpu_to_le32(bpl->tus.w); - bpl->addrLow = cpu_to_le32(putPaddrLow(busaddr)); - bpl->addrHigh = cpu_to_le32(putPaddrHigh(busaddr)); - bpl++; - } - - cmd = &cmdiocbq->iocb; - cmd->un.genreq64.bdl.ulpIoTag32 = 0; - cmd->un.genreq64.bdl.addrHigh = putPaddrHigh(bmp->phys); - cmd->un.genreq64.bdl.addrLow = putPaddrLow(bmp->phys); - cmd->un.genreq64.bdl.bdeFlags = BUFF_TYPE_BLP_64; - cmd->un.genreq64.bdl.bdeSize = - (request_nseg + reply_nseg) * sizeof(struct ulp_bde64); - cmd->un.genreq64.w5.hcsw.Fctl = (SI | LA); - cmd->un.genreq64.w5.hcsw.Dfctl = 0; - cmd->un.genreq64.w5.hcsw.Rctl = FC_RCTL_DD_UNSOL_CMD; - cmd->un.genreq64.w5.hcsw.Type = MENLO_TRANSPORT_TYPE; /* 0xfe */ - cmd->ulpBdeCount = 1; - cmd->ulpClass = CLASS3; - cmd->ulpOwner = OWN_CHIP; - cmd->ulpLe = 1; /* Limited Edition */ - cmdiocbq->iocb_flag |= LPFC_IO_LIBDFC; - cmdiocbq->vport = phba->pport; - /* We want the firmware to timeout before we do */ - cmd->ulpTimeout = MENLO_TIMEOUT - 5; - cmdiocbq->context3 = bmp; - cmdiocbq->context2 = rspiocbq; - cmdiocbq->iocb_cmpl = lpfc_bsg_menlo_cmd_cmp; - cmdiocbq->context1 = dd_data; - cmdiocbq->context2 = rspiocbq; - if (menlo_cmd->cmd == LPFC_BSG_VENDOR_MENLO_CMD) { - cmd->ulpCommand = CMD_GEN_REQUEST64_CR; - cmd->ulpPU = MENLO_PU; /* 3 */ - cmd->un.ulpWord[4] = MENLO_DID; /* 0x0000FC0E */ - cmd->ulpContext = MENLO_CONTEXT; /* 0 */ - } else { - cmd->ulpCommand = CMD_GEN_REQUEST64_CX; - cmd->ulpPU = 1; - cmd->un.ulpWord[4] = 0; - cmd->ulpContext = menlo_cmd->xri; - } - - dd_data->type = TYPE_MENLO; - dd_data->context_un.menlo.cmdiocbq = cmdiocbq; - dd_data->context_un.menlo.rspiocbq = rspiocbq; - dd_data->context_un.menlo.set_job = job; - dd_data->context_un.menlo.bmp = bmp; - - rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, cmdiocbq, - MENLO_TIMEOUT - 5); - if (rc == IOCB_SUCCESS) - return 0; /* done for now */ - - /* iocb failed so cleanup */ - pci_unmap_sg(phba->pcidev, job->request_payload.sg_list, - job->request_payload.sg_cnt, DMA_TO_DEVICE); - pci_unmap_sg(phba->pcidev, job->reply_payload.sg_list, - job->reply_payload.sg_cnt, DMA_FROM_DEVICE); - - lpfc_mbuf_free(phba, bmp->virt, bmp->phys); - -free_rspiocbq: - lpfc_sli_release_iocbq(phba, rspiocbq); -free_cmdiocbq: - lpfc_sli_release_iocbq(phba, cmdiocbq); -free_bmp: - kfree(bmp); -free_dd: - kfree(dd_data); -no_dd_data: - /* make error code available to userspace */ - job->reply->result = rc; - job->dd_data = NULL; - return rc; -} /** * lpfc_bsg_hst_vendor - process a vendor-specific fc_bsg_job * @job: fc_bsg_job to handle @@ -2985,10 +2669,6 @@ lpfc_bsg_hst_vendor(struct fc_bsg_job *job) case LPFC_BSG_VENDOR_MBOX: rc = lpfc_bsg_mbox_cmd(job); break; - case LPFC_BSG_VENDOR_MENLO_CMD: - case LPFC_BSG_VENDOR_MENLO_DATA: - rc = lpfc_menlo_cmd(job); - break; default: rc = -EINVAL; job->reply->reply_payload_rcv_len = 0; @@ -3048,7 +2728,6 @@ lpfc_bsg_timeout(struct fc_bsg_job *job) struct lpfc_bsg_event *evt; struct lpfc_bsg_iocb *iocb; struct lpfc_bsg_mbox *mbox; - struct lpfc_bsg_menlo *menlo; struct lpfc_sli_ring *pring = &phba->sli.ring[LPFC_ELS_RING]; struct bsg_job_data *dd_data; unsigned long flags; @@ -3096,17 +2775,6 @@ lpfc_bsg_timeout(struct fc_bsg_job *job) spin_unlock_irqrestore(&phba->ct_ev_lock, flags); job->job_done(job); break; - case TYPE_MENLO: - menlo = &dd_data->context_un.menlo; - cmdiocb = menlo->cmdiocbq; - /* hint to completion handler that the job timed out */ - job->reply->result = -EAGAIN; - spin_unlock_irqrestore(&phba->ct_ev_lock, flags); - /* this will call our completion handler */ - spin_lock_irq(&phba->hbalock); - lpfc_sli_issue_abort_iotag(phba, pring, cmdiocb); - spin_unlock_irq(&phba->hbalock); - break; default: spin_unlock_irqrestore(&phba->ct_ev_lock, flags); break; diff --git a/trunk/drivers/scsi/lpfc/lpfc_bsg.h b/trunk/drivers/scsi/lpfc/lpfc_bsg.h index 5bc630819b9e..6c8f87e39b98 100644 --- a/trunk/drivers/scsi/lpfc/lpfc_bsg.h +++ b/trunk/drivers/scsi/lpfc/lpfc_bsg.h @@ -31,8 +31,6 @@ #define LPFC_BSG_VENDOR_DIAG_TEST 5 #define LPFC_BSG_VENDOR_GET_MGMT_REV 6 #define LPFC_BSG_VENDOR_MBOX 7 -#define LPFC_BSG_VENDOR_MENLO_CMD 8 -#define LPFC_BSG_VENDOR_MENLO_DATA 9 struct set_ct_event { uint32_t command; @@ -98,13 +96,3 @@ struct dfc_mbox_req { uint8_t mbOffset; }; -/* Used for menlo command or menlo data. The xri is only used for menlo data */ -struct menlo_command { - uint32_t cmd; - uint32_t xri; -}; - -struct menlo_response { - uint32_t xri; /* return the xri of the iocb exchange */ -}; - diff --git a/trunk/drivers/scsi/lpfc/lpfc_crtn.h b/trunk/drivers/scsi/lpfc/lpfc_crtn.h index 5087c4211b43..6f0fb51eb461 100644 --- a/trunk/drivers/scsi/lpfc/lpfc_crtn.h +++ b/trunk/drivers/scsi/lpfc/lpfc_crtn.h @@ -63,7 +63,6 @@ void lpfc_linkdown_port(struct lpfc_vport *); void lpfc_port_link_failure(struct lpfc_vport *); void lpfc_mbx_cmpl_read_la(struct lpfc_hba *, LPFC_MBOXQ_t *); void lpfc_init_vpi_cmpl(struct lpfc_hba *, LPFC_MBOXQ_t *); -void lpfc_cancel_all_vport_retry_delay_timer(struct lpfc_hba *); void lpfc_retry_pport_discovery(struct lpfc_hba *); void lpfc_mbx_cmpl_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *); @@ -222,10 +221,6 @@ void lpfc_unregister_fcf_rescan(struct lpfc_hba *); void lpfc_unregister_unused_fcf(struct lpfc_hba *); int lpfc_sli4_redisc_fcf_table(struct lpfc_hba *); void lpfc_fcf_redisc_wait_start_timer(struct lpfc_hba *); -void lpfc_sli4_fcf_dead_failthrough(struct lpfc_hba *); -uint16_t lpfc_sli4_fcf_rr_next_index_get(struct lpfc_hba *); -int lpfc_sli4_fcf_rr_index_set(struct lpfc_hba *, uint16_t); -void lpfc_sli4_fcf_rr_index_clear(struct lpfc_hba *, uint16_t); int lpfc_mem_alloc(struct lpfc_hba *, int align); void lpfc_mem_free(struct lpfc_hba *); @@ -390,7 +385,7 @@ void lpfc_parse_fcoe_conf(struct lpfc_hba *, uint8_t *, uint32_t); int lpfc_parse_vpd(struct lpfc_hba *, uint8_t *, int); void lpfc_start_fdiscs(struct lpfc_hba *phba); struct lpfc_vport *lpfc_find_vport_by_vpid(struct lpfc_hba *, uint16_t); -struct lpfc_sglq *__lpfc_get_active_sglq(struct lpfc_hba *, uint16_t); + #define ScsiResult(host_code, scsi_code) (((host_code) << 16) | scsi_code) #define HBA_EVENT_RSCN 5 #define HBA_EVENT_LINK_UP 2 diff --git a/trunk/drivers/scsi/lpfc/lpfc_els.c b/trunk/drivers/scsi/lpfc/lpfc_els.c index ee980bd66869..2a40a6eabf4d 100644 --- a/trunk/drivers/scsi/lpfc/lpfc_els.c +++ b/trunk/drivers/scsi/lpfc/lpfc_els.c @@ -771,7 +771,6 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, struct lpfc_nodelist *ndlp = cmdiocb->context1; struct lpfc_dmabuf *pcmd = cmdiocb->context2, *prsp; struct serv_parm *sp; - uint16_t fcf_index; int rc; /* Check to see if link went down during discovery */ @@ -789,54 +788,6 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, vport->port_state); if (irsp->ulpStatus) { - /* - * In case of FIP mode, perform round robin FCF failover - * due to new FCF discovery - */ - if ((phba->hba_flag & HBA_FIP_SUPPORT) && - (phba->fcf.fcf_flag & FCF_DISCOVERY)) { - lpfc_printf_log(phba, KERN_WARNING, LOG_FIP | LOG_ELS, - "2611 FLOGI failed on registered " - "FCF record fcf_index:%d, trying " - "to perform round robin failover\n", - phba->fcf.current_rec.fcf_indx); - fcf_index = lpfc_sli4_fcf_rr_next_index_get(phba); - if (fcf_index == LPFC_FCOE_FCF_NEXT_NONE) { - /* - * Exhausted the eligible FCF record list, - * fail through to retry FLOGI on current - * FCF record. - */ - lpfc_printf_log(phba, KERN_WARNING, - LOG_FIP | LOG_ELS, - "2760 FLOGI exhausted FCF " - "round robin failover list, " - "retry FLOGI on the current " - "registered FCF index:%d\n", - phba->fcf.current_rec.fcf_indx); - spin_lock_irq(&phba->hbalock); - phba->fcf.fcf_flag &= ~FCF_DISCOVERY; - spin_unlock_irq(&phba->hbalock); - } else { - rc = lpfc_sli4_fcf_rr_read_fcf_rec(phba, - fcf_index); - if (rc) { - lpfc_printf_log(phba, KERN_WARNING, - LOG_FIP | LOG_ELS, - "2761 FLOGI round " - "robin FCF failover " - "read FCF failed " - "rc:x%x, fcf_index:" - "%d\n", rc, - phba->fcf.current_rec.fcf_indx); - spin_lock_irq(&phba->hbalock); - phba->fcf.fcf_flag &= ~FCF_DISCOVERY; - spin_unlock_irq(&phba->hbalock); - } else - goto out; - } - } - /* Check for retry */ if (lpfc_els_retry(phba, cmdiocb, rspiocb)) goto out; @@ -855,8 +806,9 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, } /* FLOGI failure */ - lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, - "0100 FLOGI failure Status:x%x/x%x TMO:x%x\n", + lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, + "0100 FLOGI failure Data: x%x x%x " + "x%x\n", irsp->ulpStatus, irsp->un.ulpWord[4], irsp->ulpTimeout); goto flogifail; @@ -890,18 +842,8 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, else rc = lpfc_cmpl_els_flogi_nport(vport, ndlp, sp); - if (!rc) { - /* Mark the FCF discovery process done */ - lpfc_printf_vlog(vport, KERN_INFO, LOG_FIP | LOG_ELS, - "2769 FLOGI successful on FCF record: " - "current_fcf_index:x%x, terminate FCF " - "round robin failover process\n", - phba->fcf.current_rec.fcf_indx); - spin_lock_irq(&phba->hbalock); - phba->fcf.fcf_flag &= ~FCF_DISCOVERY; - spin_unlock_irq(&phba->hbalock); + if (!rc) goto out; - } } flogifail: @@ -1467,10 +1409,6 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, goto out; } /* PLOGI failed */ - lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, - "2753 PLOGI failure DID:%06X Status:x%x/x%x\n", - ndlp->nlp_DID, irsp->ulpStatus, - irsp->un.ulpWord[4]); /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ if (lpfc_error_lost_link(irsp)) rc = NLP_STE_FREED_NODE; @@ -1639,10 +1577,6 @@ lpfc_cmpl_els_prli(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, goto out; } /* PRLI failed */ - lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, - "2754 PRLI failure DID:%06X Status:x%x/x%x\n", - ndlp->nlp_DID, irsp->ulpStatus, - irsp->un.ulpWord[4]); /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ if (lpfc_error_lost_link(irsp)) goto out; @@ -1926,10 +1860,6 @@ lpfc_cmpl_els_adisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, goto out; } /* ADISC failed */ - lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, - "2755 ADISC failure DID:%06X Status:x%x/x%x\n", - ndlp->nlp_DID, irsp->ulpStatus, - irsp->un.ulpWord[4]); /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ if (!lpfc_error_lost_link(irsp)) lpfc_disc_state_machine(vport, ndlp, cmdiocb, @@ -2079,10 +2009,6 @@ lpfc_cmpl_els_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, /* ELS command is being retried */ goto out; /* LOGO failed */ - lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, - "2756 LOGO failure DID:%06X Status:x%x/x%x\n", - ndlp->nlp_DID, irsp->ulpStatus, - irsp->un.ulpWord[4]); /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ if (lpfc_error_lost_link(irsp)) goto out; @@ -6063,12 +5989,7 @@ lpfc_cmpl_reg_new_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) if (phba->sli_rev < LPFC_SLI_REV4) lpfc_issue_fabric_reglogin(vport); else { - /* - * If the physical port is instantiated using - * FDISC, do not start vport discovery. - */ - if (vport->port_state != LPFC_FDISC) - lpfc_start_fdiscs(phba); + lpfc_start_fdiscs(phba); lpfc_do_scr_ns_plogi(phba, vport); } } else @@ -6134,18 +6055,21 @@ lpfc_register_new_vport(struct lpfc_hba *phba, struct lpfc_vport *vport, } /** - * lpfc_cancel_all_vport_retry_delay_timer - Cancel all vport retry delay timer + * lpfc_retry_pport_discovery - Start timer to retry FLOGI. * @phba: pointer to lpfc hba data structure. * - * This routine cancels the retry delay timers to all the vports. + * This routine abort all pending discovery commands and + * start a timer to retry FLOGI for the physical port + * discovery. **/ void -lpfc_cancel_all_vport_retry_delay_timer(struct lpfc_hba *phba) +lpfc_retry_pport_discovery(struct lpfc_hba *phba) { struct lpfc_vport **vports; struct lpfc_nodelist *ndlp; - uint32_t link_state; + struct Scsi_Host *shost; int i; + uint32_t link_state; /* Treat this failure as linkdown for all vports */ link_state = phba->link_state; @@ -6163,30 +6087,13 @@ lpfc_cancel_all_vport_retry_delay_timer(struct lpfc_hba *phba) } lpfc_destroy_vport_work_array(phba, vports); } -} - -/** - * lpfc_retry_pport_discovery - Start timer to retry FLOGI. - * @phba: pointer to lpfc hba data structure. - * - * This routine abort all pending discovery commands and - * start a timer to retry FLOGI for the physical port - * discovery. - **/ -void -lpfc_retry_pport_discovery(struct lpfc_hba *phba) -{ - struct lpfc_nodelist *ndlp; - struct Scsi_Host *shost; - - /* Cancel the all vports retry delay retry timers */ - lpfc_cancel_all_vport_retry_delay_timer(phba); /* If fabric require FLOGI, then re-instantiate physical login */ ndlp = lpfc_findnode_did(phba->pport, Fabric_DID); if (!ndlp) return; + shost = lpfc_shost_from_vport(phba->pport); mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ); spin_lock_irq(shost->host_lock); @@ -6312,8 +6219,7 @@ lpfc_cmpl_els_fdisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, lpfc_mbx_unreg_vpi(vport); spin_lock_irq(shost->host_lock); vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; - if (phba->sli_rev == LPFC_SLI_REV4) - vport->fc_flag |= FC_VPORT_NEEDS_INIT_VPI; + vport->fc_flag |= FC_VPORT_NEEDS_INIT_VPI; spin_unlock_irq(shost->host_lock); } @@ -6891,27 +6797,21 @@ lpfc_sli4_els_xri_aborted(struct lpfc_hba *phba, struct lpfc_sglq *sglq_entry = NULL, *sglq_next = NULL; unsigned long iflag = 0; - spin_lock_irqsave(&phba->hbalock, iflag); - spin_lock(&phba->sli4_hba.abts_sgl_list_lock); + spin_lock_irqsave(&phba->sli4_hba.abts_sgl_list_lock, iflag); list_for_each_entry_safe(sglq_entry, sglq_next, &phba->sli4_hba.lpfc_abts_els_sgl_list, list) { if (sglq_entry->sli4_xritag == xri) { list_del(&sglq_entry->list); + spin_unlock_irqrestore( + &phba->sli4_hba.abts_sgl_list_lock, + iflag); + spin_lock_irqsave(&phba->hbalock, iflag); + list_add_tail(&sglq_entry->list, &phba->sli4_hba.lpfc_sgl_list); - sglq_entry->state = SGL_FREED; - spin_unlock(&phba->sli4_hba.abts_sgl_list_lock); spin_unlock_irqrestore(&phba->hbalock, iflag); return; } } - spin_unlock(&phba->sli4_hba.abts_sgl_list_lock); - sglq_entry = __lpfc_get_active_sglq(phba, xri); - if (!sglq_entry || (sglq_entry->sli4_xritag != xri)) { - spin_unlock_irqrestore(&phba->hbalock, iflag); - return; - } - sglq_entry->state = SGL_XRI_ABORTED; - spin_unlock_irqrestore(&phba->hbalock, iflag); - return; + spin_unlock_irqrestore(&phba->sli4_hba.abts_sgl_list_lock, iflag); } diff --git a/trunk/drivers/scsi/lpfc/lpfc_hbadisc.c b/trunk/drivers/scsi/lpfc/lpfc_hbadisc.c index c555e3b7f202..2359d0bfb734 100644 --- a/trunk/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/trunk/drivers/scsi/lpfc/lpfc_hbadisc.c @@ -1481,6 +1481,8 @@ lpfc_match_fcf_conn_list(struct lpfc_hba *phba, int lpfc_check_pending_fcoe_event(struct lpfc_hba *phba, uint8_t unreg_fcf) { + LPFC_MBOXQ_t *mbox; + int rc; /* * If the Link is up and no FCoE events while in the * FCF discovery, no need to restart FCF discovery. @@ -1489,70 +1491,86 @@ lpfc_check_pending_fcoe_event(struct lpfc_hba *phba, uint8_t unreg_fcf) (phba->fcoe_eventtag == phba->fcoe_eventtag_at_fcf_scan)) return 0; - lpfc_printf_log(phba, KERN_INFO, LOG_FIP, - "2768 Pending link or FCF event during current " - "handling of the previous event: link_state:x%x, " - "evt_tag_at_scan:x%x, evt_tag_current:x%x\n", - phba->link_state, phba->fcoe_eventtag_at_fcf_scan, - phba->fcoe_eventtag); - spin_lock_irq(&phba->hbalock); phba->fcf.fcf_flag &= ~FCF_AVAILABLE; spin_unlock_irq(&phba->hbalock); - if (phba->link_state >= LPFC_LINK_UP) { - lpfc_printf_log(phba, KERN_INFO, LOG_FIP | LOG_DISCOVERY, - "2780 Restart FCF table scan due to " - "pending FCF event:evt_tag_at_scan:x%x, " - "evt_tag_current:x%x\n", - phba->fcoe_eventtag_at_fcf_scan, - phba->fcoe_eventtag); - lpfc_sli4_fcf_scan_read_fcf_rec(phba, LPFC_FCOE_FCF_GET_FIRST); - } else { + if (phba->link_state >= LPFC_LINK_UP) + lpfc_sli4_read_fcf_record(phba, LPFC_FCOE_FCF_GET_FIRST); + else { /* * Do not continue FCF discovery and clear FCF_DISC_INPROGRESS * flag */ spin_lock_irq(&phba->hbalock); phba->hba_flag &= ~FCF_DISC_INPROGRESS; - phba->fcf.fcf_flag &= ~(FCF_REDISC_FOV | FCF_DISCOVERY); + phba->fcf.fcf_flag &= ~FCF_REDISC_FOV; spin_unlock_irq(&phba->hbalock); } - /* Unregister the currently registered FCF if required */ if (unreg_fcf) { spin_lock_irq(&phba->hbalock); phba->fcf.fcf_flag &= ~FCF_REGISTERED; spin_unlock_irq(&phba->hbalock); - lpfc_sli4_unregister_fcf(phba); + mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); + if (!mbox) { + lpfc_printf_log(phba, KERN_ERR, + LOG_DISCOVERY|LOG_MBOX, + "2610 UNREG_FCFI mbox allocation failed\n"); + return 1; + } + lpfc_unreg_fcfi(mbox, phba->fcf.fcfi); + mbox->vport = phba->pport; + mbox->mbox_cmpl = lpfc_unregister_fcfi_cmpl; + rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); + if (rc == MBX_NOT_FINISHED) { + lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY|LOG_MBOX, + "2611 UNREG_FCFI issue mbox failed\n"); + mempool_free(mbox, phba->mbox_mem_pool); + } } + return 1; } /** - * lpfc_sli4_fcf_rec_mbox_parse - parse non-embedded fcf record mailbox command + * lpfc_mbx_cmpl_read_fcf_record - Completion handler for read_fcf mbox. * @phba: pointer to lpfc hba data structure. * @mboxq: pointer to mailbox object. - * @next_fcf_index: pointer to holder of next fcf index. - * - * This routine parses the non-embedded fcf mailbox command by performing the - * necessarily error checking, non-embedded read FCF record mailbox command - * SGE parsing, and endianness swapping. * - * Returns the pointer to the new FCF record in the non-embedded mailbox - * command DMA memory if successfully, other NULL. + * This function iterate through all the fcf records available in + * HBA and choose the optimal FCF record for discovery. After finding + * the FCF for discovery it register the FCF record and kick start + * discovery. + * If FCF_IN_USE flag is set in currently used FCF, the routine try to + * use a FCF record which match fabric name and mac address of the + * currently used FCF record. + * If the driver support only one FCF, it will try to use the FCF record + * used by BOOT_BIOS. */ -static struct fcf_record * -lpfc_sli4_fcf_rec_mbox_parse(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq, - uint16_t *next_fcf_index) +void +lpfc_mbx_cmpl_read_fcf_record(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) { void *virt_addr; dma_addr_t phys_addr; + uint8_t *bytep; struct lpfc_mbx_sge sge; struct lpfc_mbx_read_fcf_tbl *read_fcf; uint32_t shdr_status, shdr_add_status; union lpfc_sli4_cfg_shdr *shdr; struct fcf_record *new_fcf_record; + uint32_t boot_flag, addr_mode; + uint32_t next_fcf_index; + struct lpfc_fcf_rec *fcf_rec = NULL; + unsigned long iflags; + uint16_t vlan_id; + int rc; + + /* If there is pending FCoE event restart FCF table scan */ + if (lpfc_check_pending_fcoe_event(phba, 0)) { + lpfc_sli4_mbox_cmd_free(phba, mboxq); + return; + } /* Get the first SGE entry from the non-embedded DMA memory. This * routine only uses a single SGE. @@ -1563,183 +1581,59 @@ lpfc_sli4_fcf_rec_mbox_parse(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq, lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, "2524 Failed to get the non-embedded SGE " "virtual address\n"); - return NULL; + goto out; } virt_addr = mboxq->sge_array->addr[0]; shdr = (union lpfc_sli4_cfg_shdr *)virt_addr; shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); - shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); + shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, + &shdr->response); + /* + * The FCF Record was read and there is no reason for the driver + * to maintain the FCF record data or memory. Instead, just need + * to book keeping the FCFIs can be used. + */ if (shdr_status || shdr_add_status) { - if (shdr_status == STATUS_FCF_TABLE_EMPTY) - lpfc_printf_log(phba, KERN_ERR, LOG_FIP, + if (shdr_status == STATUS_FCF_TABLE_EMPTY) { + lpfc_printf_log(phba, KERN_ERR, LOG_INIT, "2726 READ_FCF_RECORD Indicates empty " "FCF table.\n"); - else - lpfc_printf_log(phba, KERN_ERR, LOG_FIP, + } else { + lpfc_printf_log(phba, KERN_ERR, LOG_INIT, "2521 READ_FCF_RECORD mailbox failed " - "with status x%x add_status x%x, " - "mbx\n", shdr_status, shdr_add_status); - return NULL; + "with status x%x add_status x%x, mbx\n", + shdr_status, shdr_add_status); + } + goto out; } - - /* Interpreting the returned information of the FCF record */ + /* Interpreting the returned information of FCF records */ read_fcf = (struct lpfc_mbx_read_fcf_tbl *)virt_addr; lpfc_sli_pcimem_bcopy(read_fcf, read_fcf, sizeof(struct lpfc_mbx_read_fcf_tbl)); - *next_fcf_index = bf_get(lpfc_mbx_read_fcf_tbl_nxt_vindx, read_fcf); + next_fcf_index = bf_get(lpfc_mbx_read_fcf_tbl_nxt_vindx, read_fcf); + new_fcf_record = (struct fcf_record *)(virt_addr + sizeof(struct lpfc_mbx_read_fcf_tbl)); lpfc_sli_pcimem_bcopy(new_fcf_record, new_fcf_record, sizeof(struct fcf_record)); + bytep = virt_addr + sizeof(union lpfc_sli4_cfg_shdr); - return new_fcf_record; -} - -/** - * lpfc_sli4_log_fcf_record_info - Log the information of a fcf record - * @phba: pointer to lpfc hba data structure. - * @fcf_record: pointer to the fcf record. - * @vlan_id: the lowest vlan identifier associated to this fcf record. - * @next_fcf_index: the index to the next fcf record in hba's fcf table. - * - * This routine logs the detailed FCF record if the LOG_FIP loggin is - * enabled. - **/ -static void -lpfc_sli4_log_fcf_record_info(struct lpfc_hba *phba, - struct fcf_record *fcf_record, - uint16_t vlan_id, - uint16_t next_fcf_index) -{ - lpfc_printf_log(phba, KERN_INFO, LOG_FIP, - "2764 READ_FCF_RECORD:\n" - "\tFCF_Index : x%x\n" - "\tFCF_Avail : x%x\n" - "\tFCF_Valid : x%x\n" - "\tFIP_Priority : x%x\n" - "\tMAC_Provider : x%x\n" - "\tLowest VLANID : x%x\n" - "\tFCF_MAC Addr : x%x:%x:%x:%x:%x:%x\n" - "\tFabric_Name : x%x:%x:%x:%x:%x:%x:%x:%x\n" - "\tSwitch_Name : x%x:%x:%x:%x:%x:%x:%x:%x\n" - "\tNext_FCF_Index: x%x\n", - bf_get(lpfc_fcf_record_fcf_index, fcf_record), - bf_get(lpfc_fcf_record_fcf_avail, fcf_record), - bf_get(lpfc_fcf_record_fcf_valid, fcf_record), - fcf_record->fip_priority, - bf_get(lpfc_fcf_record_mac_addr_prov, fcf_record), - vlan_id, - bf_get(lpfc_fcf_record_mac_0, fcf_record), - bf_get(lpfc_fcf_record_mac_1, fcf_record), - bf_get(lpfc_fcf_record_mac_2, fcf_record), - bf_get(lpfc_fcf_record_mac_3, fcf_record), - bf_get(lpfc_fcf_record_mac_4, fcf_record), - bf_get(lpfc_fcf_record_mac_5, fcf_record), - bf_get(lpfc_fcf_record_fab_name_0, fcf_record), - bf_get(lpfc_fcf_record_fab_name_1, fcf_record), - bf_get(lpfc_fcf_record_fab_name_2, fcf_record), - bf_get(lpfc_fcf_record_fab_name_3, fcf_record), - bf_get(lpfc_fcf_record_fab_name_4, fcf_record), - bf_get(lpfc_fcf_record_fab_name_5, fcf_record), - bf_get(lpfc_fcf_record_fab_name_6, fcf_record), - bf_get(lpfc_fcf_record_fab_name_7, fcf_record), - bf_get(lpfc_fcf_record_switch_name_0, fcf_record), - bf_get(lpfc_fcf_record_switch_name_1, fcf_record), - bf_get(lpfc_fcf_record_switch_name_2, fcf_record), - bf_get(lpfc_fcf_record_switch_name_3, fcf_record), - bf_get(lpfc_fcf_record_switch_name_4, fcf_record), - bf_get(lpfc_fcf_record_switch_name_5, fcf_record), - bf_get(lpfc_fcf_record_switch_name_6, fcf_record), - bf_get(lpfc_fcf_record_switch_name_7, fcf_record), - next_fcf_index); -} - -/** - * lpfc_mbx_cmpl_fcf_scan_read_fcf_rec - fcf scan read_fcf mbox cmpl handler. - * @phba: pointer to lpfc hba data structure. - * @mboxq: pointer to mailbox object. - * - * This function iterates through all the fcf records available in - * HBA and chooses the optimal FCF record for discovery. After finding - * the FCF for discovery it registers the FCF record and kicks start - * discovery. - * If FCF_IN_USE flag is set in currently used FCF, the routine tries to - * use an FCF record which matches fabric name and mac address of the - * currently used FCF record. - * If the driver supports only one FCF, it will try to use the FCF record - * used by BOOT_BIOS. - */ -void -lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) -{ - struct fcf_record *new_fcf_record; - uint32_t boot_flag, addr_mode; - uint16_t fcf_index, next_fcf_index; - struct lpfc_fcf_rec *fcf_rec = NULL; - uint16_t vlan_id; - int rc; - - /* If there is pending FCoE event restart FCF table scan */ - if (lpfc_check_pending_fcoe_event(phba, 0)) { - lpfc_sli4_mbox_cmd_free(phba, mboxq); - return; - } - - /* Parse the FCF record from the non-embedded mailbox command */ - new_fcf_record = lpfc_sli4_fcf_rec_mbox_parse(phba, mboxq, - &next_fcf_index); - if (!new_fcf_record) { - lpfc_printf_log(phba, KERN_WARNING, LOG_FIP, - "2765 Mailbox command READ_FCF_RECORD " - "failed to retrieve a FCF record.\n"); - /* Let next new FCF event trigger fast failover */ - spin_lock_irq(&phba->hbalock); - phba->hba_flag &= ~FCF_DISC_INPROGRESS; - spin_unlock_irq(&phba->hbalock); - lpfc_sli4_mbox_cmd_free(phba, mboxq); - return; - } - - /* Check the FCF record against the connection list */ rc = lpfc_match_fcf_conn_list(phba, new_fcf_record, &boot_flag, &addr_mode, &vlan_id); - - /* Log the FCF record information if turned on */ - lpfc_sli4_log_fcf_record_info(phba, new_fcf_record, vlan_id, - next_fcf_index); - /* * If the fcf record does not match with connect list entries - * read the next entry; otherwise, this is an eligible FCF - * record for round robin FCF failover. + * read the next entry. */ - if (!rc) { - lpfc_printf_log(phba, KERN_WARNING, LOG_FIP, - "2781 FCF record fcf_index:x%x failed FCF " - "connection list check, fcf_avail:x%x, " - "fcf_valid:x%x\n", - bf_get(lpfc_fcf_record_fcf_index, - new_fcf_record), - bf_get(lpfc_fcf_record_fcf_avail, - new_fcf_record), - bf_get(lpfc_fcf_record_fcf_valid, - new_fcf_record)); + if (!rc) goto read_next_fcf; - } else { - fcf_index = bf_get(lpfc_fcf_record_fcf_index, new_fcf_record); - rc = lpfc_sli4_fcf_rr_index_set(phba, fcf_index); - if (rc) - goto read_next_fcf; - } - /* * If this is not the first FCF discovery of the HBA, use last * FCF record for the discovery. The condition that a rescan * matches the in-use FCF record: fabric name, switch name, mac * address, and vlan_id. */ - spin_lock_irq(&phba->hbalock); + spin_lock_irqsave(&phba->hbalock, iflags); if (phba->fcf.fcf_flag & FCF_IN_USE) { if (lpfc_fab_name_match(phba->fcf.current_rec.fabric_name, new_fcf_record) && @@ -1755,9 +1649,8 @@ lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) __lpfc_sli4_stop_fcf_redisc_wait_timer(phba); else if (phba->fcf.fcf_flag & FCF_REDISC_FOV) /* If in fast failover, mark it's completed */ - phba->fcf.fcf_flag &= ~(FCF_REDISC_FOV | - FCF_DISCOVERY); - spin_unlock_irq(&phba->hbalock); + phba->fcf.fcf_flag &= ~FCF_REDISC_FOV; + spin_unlock_irqrestore(&phba->hbalock, iflags); goto out; } /* @@ -1768,7 +1661,7 @@ lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) * next candidate. */ if (!(phba->fcf.fcf_flag & FCF_REDISC_FOV)) { - spin_unlock_irq(&phba->hbalock); + spin_unlock_irqrestore(&phba->hbalock, iflags); goto read_next_fcf; } } @@ -1776,9 +1669,14 @@ lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) * Update on failover FCF record only if it's in FCF fast-failover * period; otherwise, update on current FCF record. */ - if (phba->fcf.fcf_flag & FCF_REDISC_FOV) - fcf_rec = &phba->fcf.failover_rec; - else + if (phba->fcf.fcf_flag & FCF_REDISC_FOV) { + /* Fast FCF failover only to the same fabric name */ + if (lpfc_fab_name_match(phba->fcf.current_rec.fabric_name, + new_fcf_record)) + fcf_rec = &phba->fcf.failover_rec; + else + goto read_next_fcf; + } else fcf_rec = &phba->fcf.current_rec; if (phba->fcf.fcf_flag & FCF_AVAILABLE) { @@ -1791,7 +1689,7 @@ lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) /* Choose this FCF record */ __lpfc_update_fcf_record(phba, fcf_rec, new_fcf_record, addr_mode, vlan_id, BOOT_ENABLE); - spin_unlock_irq(&phba->hbalock); + spin_unlock_irqrestore(&phba->hbalock, iflags); goto read_next_fcf; } /* @@ -1800,19 +1698,20 @@ lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) * the next FCF record. */ if (!boot_flag && (fcf_rec->flag & BOOT_ENABLE)) { - spin_unlock_irq(&phba->hbalock); + spin_unlock_irqrestore(&phba->hbalock, iflags); goto read_next_fcf; } /* * If the new hba FCF record has lower priority value * than the driver FCF record, use the new record. */ - if (new_fcf_record->fip_priority < fcf_rec->priority) { + if (lpfc_fab_name_match(fcf_rec->fabric_name, new_fcf_record) && + (new_fcf_record->fip_priority < fcf_rec->priority)) { /* Choose this FCF record */ __lpfc_update_fcf_record(phba, fcf_rec, new_fcf_record, addr_mode, vlan_id, 0); } - spin_unlock_irq(&phba->hbalock); + spin_unlock_irqrestore(&phba->hbalock, iflags); goto read_next_fcf; } /* @@ -1825,7 +1724,7 @@ lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) BOOT_ENABLE : 0)); phba->fcf.fcf_flag |= FCF_AVAILABLE; } - spin_unlock_irq(&phba->hbalock); + spin_unlock_irqrestore(&phba->hbalock, iflags); goto read_next_fcf; read_next_fcf: @@ -1841,22 +1740,9 @@ lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) * FCF scan inprogress, and do nothing */ if (!(phba->fcf.failover_rec.flag & RECORD_VALID)) { - lpfc_printf_log(phba, KERN_WARNING, LOG_FIP, - "2782 No suitable FCF record " - "found during this round of " - "post FCF rediscovery scan: " - "fcf_evt_tag:x%x, fcf_index: " - "x%x\n", - phba->fcoe_eventtag_at_fcf_scan, - bf_get(lpfc_fcf_record_fcf_index, - new_fcf_record)); - /* - * Let next new FCF event trigger fast - * failover - */ - spin_lock_irq(&phba->hbalock); + spin_lock_irqsave(&phba->hbalock, iflags); phba->hba_flag &= ~FCF_DISC_INPROGRESS; - spin_unlock_irq(&phba->hbalock); + spin_unlock_irqrestore(&phba->hbalock, iflags); return; } /* @@ -1868,23 +1754,16 @@ lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) * record. */ - /* Unregister the current in-use FCF record */ + /* unregister the current in-use FCF record */ lpfc_unregister_fcf(phba); - - /* Replace in-use record with the new record */ + /* replace in-use record with the new record */ memcpy(&phba->fcf.current_rec, &phba->fcf.failover_rec, sizeof(struct lpfc_fcf_rec)); /* mark the FCF fast failover completed */ - spin_lock_irq(&phba->hbalock); + spin_lock_irqsave(&phba->hbalock, iflags); phba->fcf.fcf_flag &= ~FCF_REDISC_FOV; - spin_unlock_irq(&phba->hbalock); - /* - * Set up the initial registered FCF index for FLOGI - * round robin FCF failover. - */ - phba->fcf.fcf_rr_init_indx = - phba->fcf.failover_rec.fcf_indx; + spin_unlock_irqrestore(&phba->hbalock, iflags); /* Register to the new FCF record */ lpfc_register_fcf(phba); } else { @@ -1897,25 +1776,13 @@ lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) return; /* * Otherwise, initial scan or post linkdown rescan, - * register with the best FCF record found so far - * through the FCF scanning process. - */ - - /* mark the initial FCF discovery completed */ - spin_lock_irq(&phba->hbalock); - phba->fcf.fcf_flag &= ~FCF_INIT_DISC; - spin_unlock_irq(&phba->hbalock); - /* - * Set up the initial registered FCF index for FLOGI - * round robin FCF failover + * register with the best fit FCF record found so + * far through the scanning process. */ - phba->fcf.fcf_rr_init_indx = - phba->fcf.current_rec.fcf_indx; - /* Register to the new FCF record */ lpfc_register_fcf(phba); } } else - lpfc_sli4_fcf_scan_read_fcf_rec(phba, next_fcf_index); + lpfc_sli4_read_fcf_record(phba, next_fcf_index); return; out: @@ -1925,141 +1792,6 @@ lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) return; } -/** - * lpfc_mbx_cmpl_fcf_rr_read_fcf_rec - fcf round robin read_fcf mbox cmpl hdler - * @phba: pointer to lpfc hba data structure. - * @mboxq: pointer to mailbox object. - * - * This is the callback function for FLOGI failure round robin FCF failover - * read FCF record mailbox command from the eligible FCF record bmask for - * performing the failover. If the FCF read back is not valid/available, it - * fails through to retrying FLOGI to the currently registered FCF again. - * Otherwise, if the FCF read back is valid and available, it will set the - * newly read FCF record to the failover FCF record, unregister currently - * registered FCF record, copy the failover FCF record to the current - * FCF record, and then register the current FCF record before proceeding - * to trying FLOGI on the new failover FCF. - */ -void -lpfc_mbx_cmpl_fcf_rr_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) -{ - struct fcf_record *new_fcf_record; - uint32_t boot_flag, addr_mode; - uint16_t next_fcf_index; - uint16_t current_fcf_index; - uint16_t vlan_id; - - /* If link state is not up, stop the round robin failover process */ - if (phba->link_state < LPFC_LINK_UP) { - spin_lock_irq(&phba->hbalock); - phba->fcf.fcf_flag &= ~FCF_DISCOVERY; - spin_unlock_irq(&phba->hbalock); - lpfc_sli4_mbox_cmd_free(phba, mboxq); - return; - } - - /* Parse the FCF record from the non-embedded mailbox command */ - new_fcf_record = lpfc_sli4_fcf_rec_mbox_parse(phba, mboxq, - &next_fcf_index); - if (!new_fcf_record) { - lpfc_printf_log(phba, KERN_WARNING, LOG_FIP, - "2766 Mailbox command READ_FCF_RECORD " - "failed to retrieve a FCF record.\n"); - goto out; - } - - /* Get the needed parameters from FCF record */ - lpfc_match_fcf_conn_list(phba, new_fcf_record, &boot_flag, - &addr_mode, &vlan_id); - - /* Log the FCF record information if turned on */ - lpfc_sli4_log_fcf_record_info(phba, new_fcf_record, vlan_id, - next_fcf_index); - - /* Upload new FCF record to the failover FCF record */ - spin_lock_irq(&phba->hbalock); - __lpfc_update_fcf_record(phba, &phba->fcf.failover_rec, - new_fcf_record, addr_mode, vlan_id, - (boot_flag ? BOOT_ENABLE : 0)); - spin_unlock_irq(&phba->hbalock); - - current_fcf_index = phba->fcf.current_rec.fcf_indx; - - /* Unregister the current in-use FCF record */ - lpfc_unregister_fcf(phba); - - /* Replace in-use record with the new record */ - memcpy(&phba->fcf.current_rec, &phba->fcf.failover_rec, - sizeof(struct lpfc_fcf_rec)); - - lpfc_printf_log(phba, KERN_INFO, LOG_FIP, - "2783 FLOGI round robin FCF failover from FCF " - "(index:x%x) to FCF (index:x%x).\n", - current_fcf_index, - bf_get(lpfc_fcf_record_fcf_index, new_fcf_record)); - -out: - lpfc_sli4_mbox_cmd_free(phba, mboxq); - lpfc_register_fcf(phba); -} - -/** - * lpfc_mbx_cmpl_read_fcf_rec - read fcf completion handler. - * @phba: pointer to lpfc hba data structure. - * @mboxq: pointer to mailbox object. - * - * This is the callback function of read FCF record mailbox command for - * updating the eligible FCF bmask for FLOGI failure round robin FCF - * failover when a new FCF event happened. If the FCF read back is - * valid/available and it passes the connection list check, it updates - * the bmask for the eligible FCF record for round robin failover. - */ -void -lpfc_mbx_cmpl_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) -{ - struct fcf_record *new_fcf_record; - uint32_t boot_flag, addr_mode; - uint16_t fcf_index, next_fcf_index; - uint16_t vlan_id; - int rc; - - /* If link state is not up, no need to proceed */ - if (phba->link_state < LPFC_LINK_UP) - goto out; - - /* If FCF discovery period is over, no need to proceed */ - if (phba->fcf.fcf_flag & FCF_DISCOVERY) - goto out; - - /* Parse the FCF record from the non-embedded mailbox command */ - new_fcf_record = lpfc_sli4_fcf_rec_mbox_parse(phba, mboxq, - &next_fcf_index); - if (!new_fcf_record) { - lpfc_printf_log(phba, KERN_INFO, LOG_FIP, - "2767 Mailbox command READ_FCF_RECORD " - "failed to retrieve a FCF record.\n"); - goto out; - } - - /* Check the connection list for eligibility */ - rc = lpfc_match_fcf_conn_list(phba, new_fcf_record, &boot_flag, - &addr_mode, &vlan_id); - - /* Log the FCF record information if turned on */ - lpfc_sli4_log_fcf_record_info(phba, new_fcf_record, vlan_id, - next_fcf_index); - - if (!rc) - goto out; - - /* Update the eligible FCF record index bmask */ - fcf_index = bf_get(lpfc_fcf_record_fcf_index, new_fcf_record); - rc = lpfc_sli4_fcf_rr_index_set(phba, fcf_index); - -out: - lpfc_sli4_mbox_cmd_free(phba, mboxq); -} - /** * lpfc_init_vpi_cmpl - Completion handler for init_vpi mbox command. * @phba: pointer to lpfc hba data structure. @@ -2292,6 +2024,8 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la) int rc; struct fcf_record *fcf_record; + sparam_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); + spin_lock_irq(&phba->hbalock); switch (la->UlnkSpeed) { case LA_1GHZ_LINK: @@ -2383,24 +2117,18 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la) spin_unlock_irq(&phba->hbalock); lpfc_linkup(phba); - sparam_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); - if (!sparam_mbox) - goto out; - - rc = lpfc_read_sparam(phba, sparam_mbox, 0); - if (rc) { - mempool_free(sparam_mbox, phba->mbox_mem_pool); - goto out; - } - sparam_mbox->vport = vport; - sparam_mbox->mbox_cmpl = lpfc_mbx_cmpl_read_sparam; - rc = lpfc_sli_issue_mbox(phba, sparam_mbox, MBX_NOWAIT); - if (rc == MBX_NOT_FINISHED) { - mp = (struct lpfc_dmabuf *) sparam_mbox->context1; - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); - mempool_free(sparam_mbox, phba->mbox_mem_pool); - goto out; + if (sparam_mbox) { + lpfc_read_sparam(phba, sparam_mbox, 0); + sparam_mbox->vport = vport; + sparam_mbox->mbox_cmpl = lpfc_mbx_cmpl_read_sparam; + rc = lpfc_sli_issue_mbox(phba, sparam_mbox, MBX_NOWAIT); + if (rc == MBX_NOT_FINISHED) { + mp = (struct lpfc_dmabuf *) sparam_mbox->context1; + lpfc_mbuf_free(phba, mp->virt, mp->phys); + kfree(mp); + mempool_free(sparam_mbox, phba->mbox_mem_pool); + goto out; + } } if (!(phba->hba_flag & HBA_FCOE_SUPPORT)) { @@ -2458,20 +2186,10 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la) spin_unlock_irq(&phba->hbalock); return; } - /* This is the initial FCF discovery scan */ - phba->fcf.fcf_flag |= FCF_INIT_DISC; spin_unlock_irq(&phba->hbalock); - lpfc_printf_log(phba, KERN_INFO, LOG_FIP | LOG_DISCOVERY, - "2778 Start FCF table scan at linkup\n"); - - rc = lpfc_sli4_fcf_scan_read_fcf_rec(phba, - LPFC_FCOE_FCF_GET_FIRST); - if (rc) { - spin_lock_irq(&phba->hbalock); - phba->fcf.fcf_flag &= ~FCF_INIT_DISC; - spin_unlock_irq(&phba->hbalock); + rc = lpfc_sli4_read_fcf_record(phba, LPFC_FCOE_FCF_GET_FIRST); + if (rc) goto out; - } } return; @@ -3661,12 +3379,8 @@ lpfc_unreg_hba_rpis(struct lpfc_hba *phba) shost = lpfc_shost_from_vport(vports[i]); spin_lock_irq(shost->host_lock); list_for_each_entry(ndlp, &vports[i]->fc_nodes, nlp_listp) { - if (ndlp->nlp_flag & NLP_RPI_VALID) { - /* The mempool_alloc might sleep */ - spin_unlock_irq(shost->host_lock); + if (ndlp->nlp_flag & NLP_RPI_VALID) lpfc_unreg_rpi(vports[i], ndlp); - spin_lock_irq(shost->host_lock); - } } spin_unlock_irq(shost->host_lock); } @@ -5042,7 +4756,6 @@ lpfc_unregister_fcf_rescan(struct lpfc_hba *phba) return; /* Reset HBA FCF states after successful unregister FCF */ phba->fcf.fcf_flag = 0; - phba->fcf.current_rec.flag = 0; /* * If driver is not unloading, check if there is any other @@ -5052,21 +4765,13 @@ lpfc_unregister_fcf_rescan(struct lpfc_hba *phba) (phba->link_state < LPFC_LINK_UP)) return; - /* This is considered as the initial FCF discovery scan */ - spin_lock_irq(&phba->hbalock); - phba->fcf.fcf_flag |= FCF_INIT_DISC; - spin_unlock_irq(&phba->hbalock); - rc = lpfc_sli4_fcf_scan_read_fcf_rec(phba, LPFC_FCOE_FCF_GET_FIRST); + rc = lpfc_sli4_read_fcf_record(phba, LPFC_FCOE_FCF_GET_FIRST); - if (rc) { - spin_lock_irq(&phba->hbalock); - phba->fcf.fcf_flag &= ~FCF_INIT_DISC; - spin_unlock_irq(&phba->hbalock); + if (rc) lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY|LOG_MBOX, "2553 lpfc_unregister_unused_fcf failed " "to read FCF record HBA state x%x\n", phba->pport->port_state); - } } /** diff --git a/trunk/drivers/scsi/lpfc/lpfc_init.c b/trunk/drivers/scsi/lpfc/lpfc_init.c index ea44239eeb33..d29ac7c317d9 100644 --- a/trunk/drivers/scsi/lpfc/lpfc_init.c +++ b/trunk/drivers/scsi/lpfc/lpfc_init.c @@ -350,12 +350,7 @@ lpfc_config_port_post(struct lpfc_hba *phba) mb = &pmb->u.mb; /* Get login parameters for NID. */ - rc = lpfc_read_sparam(phba, pmb, 0); - if (rc) { - mempool_free(pmb, phba->mbox_mem_pool); - return -ENOMEM; - } - + lpfc_read_sparam(phba, pmb, 0); pmb->vport = vport; if (lpfc_sli_issue_mbox(phba, pmb, MBX_POLL) != MBX_SUCCESS) { lpfc_printf_log(phba, KERN_ERR, LOG_INIT, @@ -364,7 +359,7 @@ lpfc_config_port_post(struct lpfc_hba *phba) mb->mbxCommand, mb->mbxStatus); phba->link_state = LPFC_HBA_ERROR; mp = (struct lpfc_dmabuf *) pmb->context1; - mempool_free(pmb, phba->mbox_mem_pool); + mempool_free( pmb, phba->mbox_mem_pool); lpfc_mbuf_free(phba, mp->virt, mp->phys); kfree(mp); return -EIO; @@ -549,7 +544,7 @@ lpfc_config_port_post(struct lpfc_hba *phba) mempool_free(pmb, phba->mbox_mem_pool); return -EIO; } - } else if (phba->cfg_suppress_link_up == LPFC_INITIALIZE_LINK) { + } else if (phba->cfg_suppress_link_up == 0) { lpfc_init_link(phba, pmb, phba->cfg_topology, phba->cfg_link_speed); pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; @@ -576,11 +571,6 @@ lpfc_config_port_post(struct lpfc_hba *phba) } /* MBOX buffer will be freed in mbox compl */ pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); - if (!pmb) { - phba->link_state = LPFC_HBA_ERROR; - return -ENOMEM; - } - lpfc_config_async(phba, pmb, LPFC_ELS_RING); pmb->mbox_cmpl = lpfc_config_async_cmpl; pmb->vport = phba->pport; @@ -598,11 +588,6 @@ lpfc_config_port_post(struct lpfc_hba *phba) /* Get Option rom version */ pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); - if (!pmb) { - phba->link_state = LPFC_HBA_ERROR; - return -ENOMEM; - } - lpfc_dump_wakeup_param(phba, pmb); pmb->mbox_cmpl = lpfc_dump_wakeup_param_cmpl; pmb->vport = phba->pport; @@ -667,7 +652,7 @@ lpfc_hba_init_link(struct lpfc_hba *phba) mempool_free(pmb, phba->mbox_mem_pool); return -EIO; } - phba->cfg_suppress_link_up = LPFC_INITIALIZE_LINK; + phba->cfg_suppress_link_up = 0; return 0; } @@ -822,8 +807,6 @@ lpfc_hba_down_post_s4(struct lpfc_hba *phba) LIST_HEAD(aborts); int ret; unsigned long iflag = 0; - struct lpfc_sglq *sglq_entry = NULL; - ret = lpfc_hba_down_post_s3(phba); if (ret) return ret; @@ -839,10 +822,6 @@ lpfc_hba_down_post_s4(struct lpfc_hba *phba) * list. */ spin_lock(&phba->sli4_hba.abts_sgl_list_lock); - list_for_each_entry(sglq_entry, - &phba->sli4_hba.lpfc_abts_els_sgl_list, list) - sglq_entry->state = SGL_FREED; - list_splice_init(&phba->sli4_hba.lpfc_abts_els_sgl_list, &phba->sli4_hba.lpfc_sgl_list); spin_unlock(&phba->sli4_hba.abts_sgl_list_lock); @@ -2199,10 +2178,8 @@ lpfc_stop_vport_timers(struct lpfc_vport *vport) void __lpfc_sli4_stop_fcf_redisc_wait_timer(struct lpfc_hba *phba) { - /* Clear pending FCF rediscovery wait and failover in progress flags */ - phba->fcf.fcf_flag &= ~(FCF_REDISC_PEND | - FCF_DEAD_DISC | - FCF_ACVL_DISC); + /* Clear pending FCF rediscovery wait timer */ + phba->fcf.fcf_flag &= ~FCF_REDISC_PEND; /* Now, try to stop the timer */ del_timer(&phba->fcf.redisc_wait); } @@ -2599,14 +2576,6 @@ lpfc_create_port(struct lpfc_hba *phba, int instance, struct device *dev) init_timer(&vport->els_tmofunc); vport->els_tmofunc.function = lpfc_els_timeout; vport->els_tmofunc.data = (unsigned long)vport; - if (phba->pcidev->device == PCI_DEVICE_ID_HORNET) { - phba->menlo_flag |= HBA_MENLO_SUPPORT; - /* check for menlo minimum sg count */ - if (phba->cfg_sg_seg_cnt < LPFC_DEFAULT_MENLO_SG_SEG_CNT) { - phba->cfg_sg_seg_cnt = LPFC_DEFAULT_MENLO_SG_SEG_CNT; - shost->sg_tablesize = phba->cfg_sg_seg_cnt; - } - } error = scsi_add_host_with_dma(shost, dev, &phba->pcidev->dev); if (error) @@ -2943,9 +2912,6 @@ lpfc_sli4_fcf_redisc_wait_tmo(unsigned long ptr) /* FCF rediscovery event to worker thread */ phba->fcf.fcf_flag |= FCF_REDISC_EVT; spin_unlock_irq(&phba->hbalock); - lpfc_printf_log(phba, KERN_INFO, LOG_FIP, - "2776 FCF rediscover wait timer expired, post " - "a worker thread event for FCF table scan\n"); /* wake up worker thread */ lpfc_worker_wake_up(phba); } @@ -3216,68 +3182,6 @@ lpfc_sli4_async_link_evt(struct lpfc_hba *phba, mempool_free(pmb, phba->mbox_mem_pool); } -/** - * lpfc_sli4_perform_vport_cvl - Perform clear virtual link on a vport - * @vport: pointer to vport data structure. - * - * This routine is to perform Clear Virtual Link (CVL) on a vport in - * response to a CVL event. - * - * Return the pointer to the ndlp with the vport if successful, otherwise - * return NULL. - **/ -static struct lpfc_nodelist * -lpfc_sli4_perform_vport_cvl(struct lpfc_vport *vport) -{ - struct lpfc_nodelist *ndlp; - struct Scsi_Host *shost; - struct lpfc_hba *phba; - - if (!vport) - return NULL; - ndlp = lpfc_findnode_did(vport, Fabric_DID); - if (!ndlp) - return NULL; - phba = vport->phba; - if (!phba) - return NULL; - if (phba->pport->port_state <= LPFC_FLOGI) - return NULL; - /* If virtual link is not yet instantiated ignore CVL */ - if (vport->port_state <= LPFC_FDISC) - return NULL; - shost = lpfc_shost_from_vport(vport); - if (!shost) - return NULL; - lpfc_linkdown_port(vport); - lpfc_cleanup_pending_mbox(vport); - spin_lock_irq(shost->host_lock); - vport->fc_flag |= FC_VPORT_CVL_RCVD; - spin_unlock_irq(shost->host_lock); - - return ndlp; -} - -/** - * lpfc_sli4_perform_all_vport_cvl - Perform clear virtual link on all vports - * @vport: pointer to lpfc hba data structure. - * - * This routine is to perform Clear Virtual Link (CVL) on all vports in - * response to a FCF dead event. - **/ -static void -lpfc_sli4_perform_all_vport_cvl(struct lpfc_hba *phba) -{ - struct lpfc_vport **vports; - int i; - - vports = lpfc_create_vport_work_array(phba); - if (vports) - for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) - lpfc_sli4_perform_vport_cvl(vports[i]); - lpfc_destroy_vport_work_array(phba, vports); -} - /** * lpfc_sli4_async_fcoe_evt - Process the asynchronous fcoe event * @phba: pointer to lpfc hba data structure. @@ -3294,6 +3198,7 @@ lpfc_sli4_async_fcoe_evt(struct lpfc_hba *phba, struct lpfc_vport *vport; struct lpfc_nodelist *ndlp; struct Scsi_Host *shost; + uint32_t link_state; int active_vlink_present; struct lpfc_vport **vports; int i; @@ -3303,11 +3208,10 @@ lpfc_sli4_async_fcoe_evt(struct lpfc_hba *phba, switch (event_type) { case LPFC_FCOE_EVENT_TYPE_NEW_FCF: case LPFC_FCOE_EVENT_TYPE_FCF_PARAM_MOD: - lpfc_printf_log(phba, KERN_ERR, LOG_FIP | LOG_DISCOVERY, - "2546 New FCF found/FCF parameter modified event: " - "evt_tag:x%x, fcf_index:x%x\n", - acqe_fcoe->event_tag, acqe_fcoe->index); - + lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, + "2546 New FCF found index 0x%x tag 0x%x\n", + acqe_fcoe->index, + acqe_fcoe->event_tag); spin_lock_irq(&phba->hbalock); if ((phba->fcf.fcf_flag & FCF_SCAN_DONE) || (phba->hba_flag & FCF_DISC_INPROGRESS)) { @@ -3318,7 +3222,6 @@ lpfc_sli4_async_fcoe_evt(struct lpfc_hba *phba, spin_unlock_irq(&phba->hbalock); break; } - if (phba->fcf.fcf_flag & FCF_REDISC_EVT) { /* * If fast FCF failover rescan event is pending, @@ -3329,33 +3232,12 @@ lpfc_sli4_async_fcoe_evt(struct lpfc_hba *phba, } spin_unlock_irq(&phba->hbalock); - if ((phba->fcf.fcf_flag & FCF_DISCOVERY) && - !(phba->fcf.fcf_flag & FCF_REDISC_FOV)) { - /* - * During period of FCF discovery, read the FCF - * table record indexed by the event to update - * FCF round robin failover eligible FCF bmask. - */ - lpfc_printf_log(phba, KERN_INFO, LOG_FIP | - LOG_DISCOVERY, - "2779 Read new FCF record with " - "fcf_index:x%x for updating FCF " - "round robin failover bmask\n", - acqe_fcoe->index); - rc = lpfc_sli4_read_fcf_rec(phba, acqe_fcoe->index); - } - - /* Otherwise, scan the entire FCF table and re-discover SAN */ - lpfc_printf_log(phba, KERN_INFO, LOG_FIP | LOG_DISCOVERY, - "2770 Start FCF table scan due to new FCF " - "event: evt_tag:x%x, fcf_index:x%x\n", - acqe_fcoe->event_tag, acqe_fcoe->index); - rc = lpfc_sli4_fcf_scan_read_fcf_rec(phba, - LPFC_FCOE_FCF_GET_FIRST); + /* Read the FCF table and re-discover SAN. */ + rc = lpfc_sli4_read_fcf_record(phba, LPFC_FCOE_FCF_GET_FIRST); if (rc) - lpfc_printf_log(phba, KERN_ERR, LOG_FIP | LOG_DISCOVERY, - "2547 Issue FCF scan read FCF mailbox " - "command failed 0x%x\n", rc); + lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, + "2547 Read FCF record failed 0x%x\n", + rc); break; case LPFC_FCOE_EVENT_TYPE_FCF_TABLE_FULL: @@ -3366,63 +3248,47 @@ lpfc_sli4_async_fcoe_evt(struct lpfc_hba *phba, break; case LPFC_FCOE_EVENT_TYPE_FCF_DEAD: - lpfc_printf_log(phba, KERN_ERR, LOG_FIP | LOG_DISCOVERY, + lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, "2549 FCF disconnected from network index 0x%x" " tag 0x%x\n", acqe_fcoe->index, acqe_fcoe->event_tag); /* If the event is not for currently used fcf do nothing */ if (phba->fcf.current_rec.fcf_indx != acqe_fcoe->index) break; - /* We request port to rediscover the entire FCF table for - * a fast recovery from case that the current FCF record - * is no longer valid if we are not in the middle of FCF - * failover process already. + /* + * Currently, driver support only one FCF - so treat this as + * a link down, but save the link state because we don't want + * it to be changed to Link Down unless it is already down. */ - spin_lock_irq(&phba->hbalock); - if (phba->fcf.fcf_flag & FCF_DISCOVERY) { - spin_unlock_irq(&phba->hbalock); - /* Update FLOGI FCF failover eligible FCF bmask */ - lpfc_sli4_fcf_rr_index_clear(phba, acqe_fcoe->index); - break; - } - /* Mark the fast failover process in progress */ - phba->fcf.fcf_flag |= FCF_DEAD_DISC; - spin_unlock_irq(&phba->hbalock); - lpfc_printf_log(phba, KERN_INFO, LOG_FIP | LOG_DISCOVERY, - "2771 Start FCF fast failover process due to " - "FCF DEAD event: evt_tag:x%x, fcf_index:x%x " - "\n", acqe_fcoe->event_tag, acqe_fcoe->index); - rc = lpfc_sli4_redisc_fcf_table(phba); - if (rc) { - lpfc_printf_log(phba, KERN_ERR, LOG_FIP | - LOG_DISCOVERY, - "2772 Issue FCF rediscover mabilbox " - "command failed, fail through to FCF " - "dead event\n"); - spin_lock_irq(&phba->hbalock); - phba->fcf.fcf_flag &= ~FCF_DEAD_DISC; - spin_unlock_irq(&phba->hbalock); - /* - * Last resort will fail over by treating this - * as a link down to FCF registration. - */ - lpfc_sli4_fcf_dead_failthrough(phba); - } else - /* Handling fast FCF failover to a DEAD FCF event - * is considered equalivant to receiving CVL to all - * vports. - */ - lpfc_sli4_perform_all_vport_cvl(phba); + link_state = phba->link_state; + lpfc_linkdown(phba); + phba->link_state = link_state; + /* Unregister FCF if no devices connected to it */ + lpfc_unregister_unused_fcf(phba); break; case LPFC_FCOE_EVENT_TYPE_CVL: - lpfc_printf_log(phba, KERN_ERR, LOG_FIP | LOG_DISCOVERY, + lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, "2718 Clear Virtual Link Received for VPI 0x%x" " tag 0x%x\n", acqe_fcoe->index, acqe_fcoe->event_tag); vport = lpfc_find_vport_by_vpid(phba, acqe_fcoe->index - phba->vpi_base); - ndlp = lpfc_sli4_perform_vport_cvl(vport); + if (!vport) + break; + ndlp = lpfc_findnode_did(vport, Fabric_DID); if (!ndlp) break; + shost = lpfc_shost_from_vport(vport); + if (phba->pport->port_state <= LPFC_FLOGI) + break; + /* If virtual link is not yet instantiated ignore CVL */ + if (vport->port_state <= LPFC_FDISC) + break; + + lpfc_linkdown_port(vport); + lpfc_cleanup_pending_mbox(vport); + spin_lock_irq(shost->host_lock); + vport->fc_flag |= FC_VPORT_CVL_RCVD; + spin_unlock_irq(shost->host_lock); active_vlink_present = 0; vports = lpfc_create_vport_work_array(phba); @@ -3445,7 +3311,6 @@ lpfc_sli4_async_fcoe_evt(struct lpfc_hba *phba, * re-instantiate the Vlink using FDISC. */ mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ); - shost = lpfc_shost_from_vport(vport); spin_lock_irq(shost->host_lock); ndlp->nlp_flag |= NLP_DELAY_TMO; spin_unlock_irq(shost->host_lock); @@ -3456,38 +3321,15 @@ lpfc_sli4_async_fcoe_evt(struct lpfc_hba *phba, * Otherwise, we request port to rediscover * the entire FCF table for a fast recovery * from possible case that the current FCF - * is no longer valid if we are not already - * in the FCF failover process. + * is no longer valid. */ - spin_lock_irq(&phba->hbalock); - if (phba->fcf.fcf_flag & FCF_DISCOVERY) { - spin_unlock_irq(&phba->hbalock); - break; - } - /* Mark the fast failover process in progress */ - phba->fcf.fcf_flag |= FCF_ACVL_DISC; - spin_unlock_irq(&phba->hbalock); - lpfc_printf_log(phba, KERN_INFO, LOG_FIP | - LOG_DISCOVERY, - "2773 Start FCF fast failover due " - "to CVL event: evt_tag:x%x\n", - acqe_fcoe->event_tag); rc = lpfc_sli4_redisc_fcf_table(phba); - if (rc) { - lpfc_printf_log(phba, KERN_ERR, LOG_FIP | - LOG_DISCOVERY, - "2774 Issue FCF rediscover " - "mabilbox command failed, " - "through to CVL event\n"); - spin_lock_irq(&phba->hbalock); - phba->fcf.fcf_flag &= ~FCF_ACVL_DISC; - spin_unlock_irq(&phba->hbalock); + if (rc) /* * Last resort will be re-try on the * the current registered FCF entry. */ lpfc_retry_pport_discovery(phba); - } } break; default: @@ -3584,14 +3426,11 @@ void lpfc_sli4_fcf_redisc_event_proc(struct lpfc_hba *phba) spin_unlock_irq(&phba->hbalock); /* Scan FCF table from the first entry to re-discover SAN */ - lpfc_printf_log(phba, KERN_INFO, LOG_FIP | LOG_DISCOVERY, - "2777 Start FCF table scan after FCF " - "rediscovery quiescent period over\n"); - rc = lpfc_sli4_fcf_scan_read_fcf_rec(phba, LPFC_FCOE_FCF_GET_FIRST); + rc = lpfc_sli4_read_fcf_record(phba, LPFC_FCOE_FCF_GET_FIRST); if (rc) - lpfc_printf_log(phba, KERN_ERR, LOG_FIP | LOG_DISCOVERY, - "2747 Issue FCF scan read FCF mailbox " - "command failed 0x%x\n", rc); + lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, + "2747 Post FCF rediscovery read FCF record " + "failed 0x%x\n", rc); } /** @@ -3883,7 +3722,6 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba) int rc, i, hbq_count, buf_size, dma_buf_size, max_buf_size; uint8_t pn_page[LPFC_MAX_SUPPORTED_PAGES] = {0}; struct lpfc_mqe *mqe; - int longs; /* Before proceed, wait for POST done and device ready */ rc = lpfc_sli4_post_status_check(phba); @@ -4060,24 +3898,13 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba) goto out_free_active_sgl; } - /* Allocate eligible FCF bmask memory for FCF round robin failover */ - longs = (LPFC_SLI4_FCF_TBL_INDX_MAX + BITS_PER_LONG - 1)/BITS_PER_LONG; - phba->fcf.fcf_rr_bmask = kzalloc(longs * sizeof(unsigned long), - GFP_KERNEL); - if (!phba->fcf.fcf_rr_bmask) { - lpfc_printf_log(phba, KERN_ERR, LOG_INIT, - "2759 Failed allocate memory for FCF round " - "robin failover bmask\n"); - goto out_remove_rpi_hdrs; - } - phba->sli4_hba.fcp_eq_hdl = kzalloc((sizeof(struct lpfc_fcp_eq_hdl) * phba->cfg_fcp_eq_count), GFP_KERNEL); if (!phba->sli4_hba.fcp_eq_hdl) { lpfc_printf_log(phba, KERN_ERR, LOG_INIT, "2572 Failed allocate memory for fast-path " "per-EQ handle array\n"); - goto out_free_fcf_rr_bmask; + goto out_remove_rpi_hdrs; } phba->sli4_hba.msix_entries = kzalloc((sizeof(struct msix_entry) * @@ -4130,8 +3957,6 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba) out_free_fcp_eq_hdl: kfree(phba->sli4_hba.fcp_eq_hdl); -out_free_fcf_rr_bmask: - kfree(phba->fcf.fcf_rr_bmask); out_remove_rpi_hdrs: lpfc_sli4_remove_rpi_hdrs(phba); out_free_active_sgl: @@ -4177,9 +4002,6 @@ lpfc_sli4_driver_resource_unset(struct lpfc_hba *phba) lpfc_sli4_remove_rpi_hdrs(phba); lpfc_sli4_remove_rpis(phba); - /* Free eligible FCF index bmask */ - kfree(phba->fcf.fcf_rr_bmask); - /* Free the ELS sgl list */ lpfc_free_active_sgl(phba); lpfc_free_sgl_list(phba); @@ -4575,7 +4397,6 @@ lpfc_init_sgl_list(struct lpfc_hba *phba) /* The list order is used by later block SGL registraton */ spin_lock_irq(&phba->hbalock); - sglq_entry->state = SGL_FREED; list_add_tail(&sglq_entry->list, &phba->sli4_hba.lpfc_sgl_list); phba->sli4_hba.lpfc_els_sgl_array[i] = sglq_entry; phba->sli4_hba.total_sglq_bufs++; diff --git a/trunk/drivers/scsi/lpfc/lpfc_logmsg.h b/trunk/drivers/scsi/lpfc/lpfc_logmsg.h index bb59e9273126..954ba57970a3 100644 --- a/trunk/drivers/scsi/lpfc/lpfc_logmsg.h +++ b/trunk/drivers/scsi/lpfc/lpfc_logmsg.h @@ -35,7 +35,6 @@ #define LOG_VPORT 0x00004000 /* NPIV events */ #define LOF_SECURITY 0x00008000 /* Security events */ #define LOG_EVENT 0x00010000 /* CT,TEMP,DUMP, logging */ -#define LOG_FIP 0x00020000 /* FIP events */ #define LOG_ALL_MSG 0xffffffff /* LOG all messages */ #define lpfc_printf_vlog(vport, level, mask, fmt, arg...) \ diff --git a/trunk/drivers/scsi/lpfc/lpfc_mbox.c b/trunk/drivers/scsi/lpfc/lpfc_mbox.c index 1e61ae3bc4eb..6c4dce1a30ca 100644 --- a/trunk/drivers/scsi/lpfc/lpfc_mbox.c +++ b/trunk/drivers/scsi/lpfc/lpfc_mbox.c @@ -1748,7 +1748,7 @@ lpfc_sli4_mbox_opcode_get(struct lpfc_hba *phba, struct lpfcMboxq *mbox) } /** - * lpfc_sli4_mbx_read_fcf_rec - Allocate and construct read fcf mbox cmd + * lpfc_sli4_mbx_read_fcf_record - Allocate and construct read fcf mbox cmd * @phba: pointer to lpfc hba data structure. * @fcf_index: index to fcf table. * @@ -1759,9 +1759,9 @@ lpfc_sli4_mbox_opcode_get(struct lpfc_hba *phba, struct lpfcMboxq *mbox) * NULL. **/ int -lpfc_sli4_mbx_read_fcf_rec(struct lpfc_hba *phba, - struct lpfcMboxq *mboxq, - uint16_t fcf_index) +lpfc_sli4_mbx_read_fcf_record(struct lpfc_hba *phba, + struct lpfcMboxq *mboxq, + uint16_t fcf_index) { void *virt_addr; dma_addr_t phys_addr; diff --git a/trunk/drivers/scsi/lpfc/lpfc_scsi.c b/trunk/drivers/scsi/lpfc/lpfc_scsi.c index b16bb2c9978b..483fb74bc592 100644 --- a/trunk/drivers/scsi/lpfc/lpfc_scsi.c +++ b/trunk/drivers/scsi/lpfc/lpfc_scsi.c @@ -620,40 +620,23 @@ lpfc_sli4_fcp_xri_aborted(struct lpfc_hba *phba, uint16_t xri = bf_get(lpfc_wcqe_xa_xri, axri); struct lpfc_scsi_buf *psb, *next_psb; unsigned long iflag = 0; - struct lpfc_iocbq *iocbq; - int i; - spin_lock_irqsave(&phba->hbalock, iflag); - spin_lock(&phba->sli4_hba.abts_scsi_buf_list_lock); + spin_lock_irqsave(&phba->sli4_hba.abts_scsi_buf_list_lock, iflag); list_for_each_entry_safe(psb, next_psb, &phba->sli4_hba.lpfc_abts_scsi_buf_list, list) { if (psb->cur_iocbq.sli4_xritag == xri) { list_del(&psb->list); psb->exch_busy = 0; psb->status = IOSTAT_SUCCESS; - spin_unlock( - &phba->sli4_hba.abts_scsi_buf_list_lock); - spin_unlock_irqrestore(&phba->hbalock, iflag); + spin_unlock_irqrestore( + &phba->sli4_hba.abts_scsi_buf_list_lock, + iflag); lpfc_release_scsi_buf_s4(phba, psb); return; } } - spin_unlock(&phba->sli4_hba.abts_scsi_buf_list_lock); - for (i = 1; i <= phba->sli.last_iotag; i++) { - iocbq = phba->sli.iocbq_lookup[i]; - - if (!(iocbq->iocb_flag & LPFC_IO_FCP) || - (iocbq->iocb_flag & LPFC_IO_LIBDFC)) - continue; - if (iocbq->sli4_xritag != xri) - continue; - psb = container_of(iocbq, struct lpfc_scsi_buf, cur_iocbq); - psb->exch_busy = 0; - spin_unlock_irqrestore(&phba->hbalock, iflag); - return; - - } - spin_unlock_irqrestore(&phba->hbalock, iflag); + spin_unlock_irqrestore(&phba->sli4_hba.abts_scsi_buf_list_lock, + iflag); } /** @@ -1023,7 +1006,6 @@ lpfc_scsi_prep_dma_buf_s3(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd) struct scatterlist *sgel = NULL; struct fcp_cmnd *fcp_cmnd = lpfc_cmd->fcp_cmnd; struct ulp_bde64 *bpl = lpfc_cmd->fcp_bpl; - struct lpfc_iocbq *iocbq = &lpfc_cmd->cur_iocbq; IOCB_t *iocb_cmd = &lpfc_cmd->cur_iocbq.iocb; struct ulp_bde64 *data_bde = iocb_cmd->unsli3.fcp_ext.dbde; dma_addr_t physaddr; @@ -1074,7 +1056,6 @@ lpfc_scsi_prep_dma_buf_s3(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd) physaddr = sg_dma_address(sgel); if (phba->sli_rev == 3 && !(phba->sli3_options & LPFC_SLI3_BG_ENABLED) && - !(iocbq->iocb_flag & DSS_SECURITY_OP) && nseg <= LPFC_EXT_DATA_BDE_COUNT) { data_bde->tus.f.bdeFlags = BUFF_TYPE_BDE_64; data_bde->tus.f.bdeSize = sg_dma_len(sgel); @@ -1101,8 +1082,7 @@ lpfc_scsi_prep_dma_buf_s3(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd) * explicitly reinitialized since all iocb memory resources are reused. */ if (phba->sli_rev == 3 && - !(phba->sli3_options & LPFC_SLI3_BG_ENABLED) && - !(iocbq->iocb_flag & DSS_SECURITY_OP)) { + !(phba->sli3_options & LPFC_SLI3_BG_ENABLED)) { if (num_bde > LPFC_EXT_DATA_BDE_COUNT) { /* * The extended IOCB format can only fit 3 BDE or a BPL. @@ -1127,7 +1107,6 @@ lpfc_scsi_prep_dma_buf_s3(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd) } else { iocb_cmd->un.fcpi64.bdl.bdeSize = ((num_bde + 2) * sizeof(struct ulp_bde64)); - iocb_cmd->unsli3.fcp_ext.ebde_count = (num_bde + 1); } fcp_cmnd->fcpDl = cpu_to_be32(scsi_bufflen(scsi_cmnd)); @@ -2100,7 +2079,8 @@ lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd, if (resp_info & RSP_LEN_VALID) { rsplen = be32_to_cpu(fcprsp->rspRspLen); - if (rsplen != 0 && rsplen != 4 && rsplen != 8) { + if ((rsplen != 0 && rsplen != 4 && rsplen != 8) || + (fcprsp->rspInfo3 != RSP_NO_FAILURE)) { lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP, "2719 Invalid response length: " "tgt x%x lun x%x cmnd x%x rsplen x%x\n", @@ -2110,17 +2090,6 @@ lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd, host_status = DID_ERROR; goto out; } - if (fcprsp->rspInfo3 != RSP_NO_FAILURE) { - lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP, - "2757 Protocol failure detected during " - "processing of FCP I/O op: " - "tgt x%x lun x%x cmnd x%x rspInfo3 x%x\n", - cmnd->device->id, - cmnd->device->lun, cmnd->cmnd[0], - fcprsp->rspInfo3); - host_status = DID_ERROR; - goto out; - } } if ((resp_info & SNS_LEN_VALID) && fcprsp->rspSnsLen) { diff --git a/trunk/drivers/scsi/lpfc/lpfc_sli.c b/trunk/drivers/scsi/lpfc/lpfc_sli.c index fe6660ca6452..35e3b96d4e07 100644 --- a/trunk/drivers/scsi/lpfc/lpfc_sli.c +++ b/trunk/drivers/scsi/lpfc/lpfc_sli.c @@ -494,7 +494,7 @@ __lpfc_clear_active_sglq(struct lpfc_hba *phba, uint16_t xritag) * * Returns sglq ponter = success, NULL = Failure. **/ -struct lpfc_sglq * +static struct lpfc_sglq * __lpfc_get_active_sglq(struct lpfc_hba *phba, uint16_t xritag) { uint16_t adj_xri; @@ -526,7 +526,6 @@ __lpfc_sli_get_sglq(struct lpfc_hba *phba) return NULL; adj_xri = sglq->sli4_xritag - phba->sli4_hba.max_cfg_param.xri_base; phba->sli4_hba.lpfc_sglq_active_list[adj_xri] = sglq; - sglq->state = SGL_ALLOCATED; return sglq; } @@ -581,18 +580,15 @@ __lpfc_sli_release_iocbq_s4(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq) else sglq = __lpfc_clear_active_sglq(phba, iocbq->sli4_xritag); if (sglq) { - if ((iocbq->iocb_flag & LPFC_EXCHANGE_BUSY) && - (sglq->state != SGL_XRI_ABORTED)) { + if (iocbq->iocb_flag & LPFC_EXCHANGE_BUSY) { spin_lock_irqsave(&phba->sli4_hba.abts_sgl_list_lock, iflag); list_add(&sglq->list, &phba->sli4_hba.lpfc_abts_els_sgl_list); spin_unlock_irqrestore( &phba->sli4_hba.abts_sgl_list_lock, iflag); - } else { - sglq->state = SGL_FREED; + } else list_add(&sglq->list, &phba->sli4_hba.lpfc_sgl_list); - } } @@ -2262,56 +2258,41 @@ lpfc_sli_process_sol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, spin_unlock_irqrestore(&phba->hbalock, iflag); } - if (phba->sli_rev == LPFC_SLI_REV4) { - if (saveq->iocb_flag & - LPFC_EXCHANGE_BUSY) { - /* Set cmdiocb flag for the - * exchange busy so sgl (xri) - * will not be released until - * the abort xri is received - * from hba. - */ - spin_lock_irqsave( - &phba->hbalock, iflag); - cmdiocbp->iocb_flag |= - LPFC_EXCHANGE_BUSY; - spin_unlock_irqrestore( - &phba->hbalock, iflag); - } - if (cmdiocbp->iocb_flag & - LPFC_DRIVER_ABORTED) { - /* - * Clear LPFC_DRIVER_ABORTED - * bit in case it was driver - * initiated abort. - */ - spin_lock_irqsave( - &phba->hbalock, iflag); - cmdiocbp->iocb_flag &= - ~LPFC_DRIVER_ABORTED; - spin_unlock_irqrestore( - &phba->hbalock, iflag); - cmdiocbp->iocb.ulpStatus = - IOSTAT_LOCAL_REJECT; - cmdiocbp->iocb.un.ulpWord[4] = - IOERR_ABORT_REQUESTED; - /* - * For SLI4, irsiocb contains - * NO_XRI in sli_xritag, it - * shall not affect releasing - * sgl (xri) process. - */ - saveq->iocb.ulpStatus = - IOSTAT_LOCAL_REJECT; - saveq->iocb.un.ulpWord[4] = - IOERR_SLI_ABORTED; - spin_lock_irqsave( - &phba->hbalock, iflag); - saveq->iocb_flag |= - LPFC_DELAY_MEM_FREE; - spin_unlock_irqrestore( - &phba->hbalock, iflag); - } + if ((phba->sli_rev == LPFC_SLI_REV4) && + (saveq->iocb_flag & LPFC_EXCHANGE_BUSY)) { + /* Set cmdiocb flag for the exchange + * busy so sgl (xri) will not be + * released until the abort xri is + * received from hba, clear the + * LPFC_DRIVER_ABORTED bit in case + * it was driver initiated abort. + */ + spin_lock_irqsave(&phba->hbalock, + iflag); + cmdiocbp->iocb_flag &= + ~LPFC_DRIVER_ABORTED; + cmdiocbp->iocb_flag |= + LPFC_EXCHANGE_BUSY; + spin_unlock_irqrestore(&phba->hbalock, + iflag); + cmdiocbp->iocb.ulpStatus = + IOSTAT_LOCAL_REJECT; + cmdiocbp->iocb.un.ulpWord[4] = + IOERR_ABORT_REQUESTED; + /* + * For SLI4, irsiocb contains NO_XRI + * in sli_xritag, it shall not affect + * releasing sgl (xri) process. + */ + saveq->iocb.ulpStatus = + IOSTAT_LOCAL_REJECT; + saveq->iocb.un.ulpWord[4] = + IOERR_SLI_ABORTED; + spin_lock_irqsave(&phba->hbalock, + iflag); + saveq->iocb_flag |= LPFC_DELAY_MEM_FREE; + spin_unlock_irqrestore(&phba->hbalock, + iflag); } } (cmdiocbp->iocb_cmpl) (phba, cmdiocbp, saveq); @@ -2534,16 +2515,14 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba *phba, cmdiocbq = lpfc_sli_iocbq_lookup(phba, pring, &rspiocbq); - if (unlikely(!cmdiocbq)) - break; - if (cmdiocbq->iocb_flag & LPFC_DRIVER_ABORTED) - cmdiocbq->iocb_flag &= ~LPFC_DRIVER_ABORTED; - if (cmdiocbq->iocb_cmpl) { - spin_unlock_irqrestore(&phba->hbalock, iflag); - (cmdiocbq->iocb_cmpl)(phba, cmdiocbq, - &rspiocbq); - spin_lock_irqsave(&phba->hbalock, iflag); - } + if ((cmdiocbq) && (cmdiocbq->iocb_cmpl)) { + spin_unlock_irqrestore(&phba->hbalock, + iflag); + (cmdiocbq->iocb_cmpl)(phba, cmdiocbq, + &rspiocbq); + spin_lock_irqsave(&phba->hbalock, + iflag); + } break; case LPFC_UNSOL_IOCB: spin_unlock_irqrestore(&phba->hbalock, iflag); @@ -3112,12 +3091,6 @@ lpfc_sli_brdready_s3(struct lpfc_hba *phba, uint32_t mask) /* Check to see if any errors occurred during init */ if ((status & HS_FFERM) || (i >= 20)) { - lpfc_printf_log(phba, KERN_ERR, LOG_INIT, - "2751 Adapter failed to restart, " - "status reg x%x, FW Data: A8 x%x AC x%x\n", - status, - readl(phba->MBslimaddr + 0xa8), - readl(phba->MBslimaddr + 0xac)); phba->link_state = LPFC_HBA_ERROR; retval = 1; } @@ -3305,9 +3278,6 @@ lpfc_sli_brdkill(struct lpfc_hba *phba) if (retval != MBX_SUCCESS) { if (retval != MBX_BUSY) mempool_free(pmb, phba->mbox_mem_pool); - lpfc_printf_log(phba, KERN_ERR, LOG_SLI, - "2752 KILL_BOARD command failed retval %d\n", - retval); spin_lock_irq(&phba->hbalock); phba->link_flag &= ~LS_IGNORE_ERATT; spin_unlock_irq(&phba->hbalock); @@ -4065,7 +4035,7 @@ lpfc_sli_hba_setup(struct lpfc_hba *phba) lpfc_sli_hba_setup_error: phba->link_state = LPFC_HBA_ERROR; - lpfc_printf_log(phba, KERN_ERR, LOG_INIT, + lpfc_printf_log(phba, KERN_INFO, LOG_INIT, "0445 Firmware initialization failed\n"); return rc; } @@ -4418,13 +4388,7 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba) spin_unlock_irq(&phba->hbalock); /* Read the port's service parameters. */ - rc = lpfc_read_sparam(phba, mboxq, vport->vpi); - if (rc) { - phba->link_state = LPFC_HBA_ERROR; - rc = -ENOMEM; - goto out_free_vpd; - } - + lpfc_read_sparam(phba, mboxq, vport->vpi); mboxq->vport = vport; rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL); mp = (struct lpfc_dmabuf *) mboxq->context1; @@ -4519,10 +4483,6 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba) /* Post receive buffers to the device */ lpfc_sli4_rb_setup(phba); - /* Reset HBA FCF states after HBA reset */ - phba->fcf.fcf_flag = 0; - phba->fcf.current_rec.flag = 0; - /* Start the ELS watchdog timer */ mod_timer(&vport->els_tmofunc, jiffies + HZ * (phba->fc_ratov * 2)); @@ -7476,7 +7436,6 @@ lpfc_sli_wake_iocb_wait(struct lpfc_hba *phba, { wait_queue_head_t *pdone_q; unsigned long iflags; - struct lpfc_scsi_buf *lpfc_cmd; spin_lock_irqsave(&phba->hbalock, iflags); cmdiocbq->iocb_flag |= LPFC_IO_WAKE; @@ -7484,14 +7443,6 @@ lpfc_sli_wake_iocb_wait(struct lpfc_hba *phba, memcpy(&((struct lpfc_iocbq *)cmdiocbq->context2)->iocb, &rspiocbq->iocb, sizeof(IOCB_t)); - /* Set the exchange busy flag for task management commands */ - if ((cmdiocbq->iocb_flag & LPFC_IO_FCP) && - !(cmdiocbq->iocb_flag & LPFC_IO_LIBDFC)) { - lpfc_cmd = container_of(cmdiocbq, struct lpfc_scsi_buf, - cur_iocbq); - lpfc_cmd->exch_busy = rspiocbq->iocb_flag & LPFC_EXCHANGE_BUSY; - } - pdone_q = cmdiocbq->context_un.wait_queue; if (pdone_q) wake_up(pdone_q); @@ -9110,12 +9061,6 @@ lpfc_sli4_fp_handle_fcp_wcqe(struct lpfc_hba *phba, /* Fake the irspiocb and copy necessary response information */ lpfc_sli4_iocb_param_transfer(phba, &irspiocbq, cmdiocbq, wcqe); - if (cmdiocbq->iocb_flag & LPFC_DRIVER_ABORTED) { - spin_lock_irqsave(&phba->hbalock, iflags); - cmdiocbq->iocb_flag &= ~LPFC_DRIVER_ABORTED; - spin_unlock_irqrestore(&phba->hbalock, iflags); - } - /* Pass the cmd_iocb and the rsp state to the upper layer */ (cmdiocbq->iocb_cmpl)(phba, cmdiocbq, &irspiocbq); } @@ -11996,19 +11941,15 @@ lpfc_sli4_build_dflt_fcf_record(struct lpfc_hba *phba, } /** - * lpfc_sli4_fcf_scan_read_fcf_rec - Read hba fcf record for fcf scan. + * lpfc_sli4_read_fcf_record - Read the driver's default FCF Record. * @phba: pointer to lpfc hba data structure. * @fcf_index: FCF table entry offset. * - * This routine is invoked to scan the entire FCF table by reading FCF - * record and processing it one at a time starting from the @fcf_index - * for initial FCF discovery or fast FCF failover rediscovery. - * - * Return 0 if the mailbox command is submitted sucessfully, none 0 - * otherwise. + * This routine is invoked to read up to @fcf_num of FCF record from the + * device starting with the given @fcf_index. **/ int -lpfc_sli4_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, uint16_t fcf_index) +lpfc_sli4_read_fcf_record(struct lpfc_hba *phba, uint16_t fcf_index) { int rc = 0, error; LPFC_MBOXQ_t *mboxq; @@ -12020,17 +11961,17 @@ lpfc_sli4_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, uint16_t fcf_index) "2000 Failed to allocate mbox for " "READ_FCF cmd\n"); error = -ENOMEM; - goto fail_fcf_scan; + goto fail_fcfscan; } /* Construct the read FCF record mailbox command */ - rc = lpfc_sli4_mbx_read_fcf_rec(phba, mboxq, fcf_index); + rc = lpfc_sli4_mbx_read_fcf_record(phba, mboxq, fcf_index); if (rc) { error = -EINVAL; - goto fail_fcf_scan; + goto fail_fcfscan; } /* Issue the mailbox command asynchronously */ mboxq->vport = phba->pport; - mboxq->mbox_cmpl = lpfc_mbx_cmpl_fcf_scan_read_fcf_rec; + mboxq->mbox_cmpl = lpfc_mbx_cmpl_read_fcf_record; rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_NOWAIT); if (rc == MBX_NOT_FINISHED) error = -EIO; @@ -12038,13 +11979,9 @@ lpfc_sli4_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, uint16_t fcf_index) spin_lock_irq(&phba->hbalock); phba->hba_flag |= FCF_DISC_INPROGRESS; spin_unlock_irq(&phba->hbalock); - /* Reset FCF round robin index bmask for new scan */ - if (fcf_index == LPFC_FCOE_FCF_GET_FIRST) - memset(phba->fcf.fcf_rr_bmask, 0, - sizeof(*phba->fcf.fcf_rr_bmask)); error = 0; } -fail_fcf_scan: +fail_fcfscan: if (error) { if (mboxq) lpfc_sli4_mbox_cmd_free(phba, mboxq); @@ -12056,181 +11993,6 @@ lpfc_sli4_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, uint16_t fcf_index) return error; } -/** - * lpfc_sli4_fcf_rr_read_fcf_rec - Read hba fcf record for round robin fcf. - * @phba: pointer to lpfc hba data structure. - * @fcf_index: FCF table entry offset. - * - * This routine is invoked to read an FCF record indicated by @fcf_index - * and to use it for FLOGI round robin FCF failover. - * - * Return 0 if the mailbox command is submitted sucessfully, none 0 - * otherwise. - **/ -int -lpfc_sli4_fcf_rr_read_fcf_rec(struct lpfc_hba *phba, uint16_t fcf_index) -{ - int rc = 0, error; - LPFC_MBOXQ_t *mboxq; - - mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); - if (!mboxq) { - lpfc_printf_log(phba, KERN_ERR, LOG_FIP | LOG_INIT, - "2763 Failed to allocate mbox for " - "READ_FCF cmd\n"); - error = -ENOMEM; - goto fail_fcf_read; - } - /* Construct the read FCF record mailbox command */ - rc = lpfc_sli4_mbx_read_fcf_rec(phba, mboxq, fcf_index); - if (rc) { - error = -EINVAL; - goto fail_fcf_read; - } - /* Issue the mailbox command asynchronously */ - mboxq->vport = phba->pport; - mboxq->mbox_cmpl = lpfc_mbx_cmpl_fcf_rr_read_fcf_rec; - rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_NOWAIT); - if (rc == MBX_NOT_FINISHED) - error = -EIO; - else - error = 0; - -fail_fcf_read: - if (error && mboxq) - lpfc_sli4_mbox_cmd_free(phba, mboxq); - return error; -} - -/** - * lpfc_sli4_read_fcf_rec - Read hba fcf record for update eligible fcf bmask. - * @phba: pointer to lpfc hba data structure. - * @fcf_index: FCF table entry offset. - * - * This routine is invoked to read an FCF record indicated by @fcf_index to - * determine whether it's eligible for FLOGI round robin failover list. - * - * Return 0 if the mailbox command is submitted sucessfully, none 0 - * otherwise. - **/ -int -lpfc_sli4_read_fcf_rec(struct lpfc_hba *phba, uint16_t fcf_index) -{ - int rc = 0, error; - LPFC_MBOXQ_t *mboxq; - - mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); - if (!mboxq) { - lpfc_printf_log(phba, KERN_ERR, LOG_FIP | LOG_INIT, - "2758 Failed to allocate mbox for " - "READ_FCF cmd\n"); - error = -ENOMEM; - goto fail_fcf_read; - } - /* Construct the read FCF record mailbox command */ - rc = lpfc_sli4_mbx_read_fcf_rec(phba, mboxq, fcf_index); - if (rc) { - error = -EINVAL; - goto fail_fcf_read; - } - /* Issue the mailbox command asynchronously */ - mboxq->vport = phba->pport; - mboxq->mbox_cmpl = lpfc_mbx_cmpl_read_fcf_rec; - rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_NOWAIT); - if (rc == MBX_NOT_FINISHED) - error = -EIO; - else - error = 0; - -fail_fcf_read: - if (error && mboxq) - lpfc_sli4_mbox_cmd_free(phba, mboxq); - return error; -} - -/** - * lpfc_sli4_fcf_rr_next_index_get - Get next eligible fcf record index - * @phba: pointer to lpfc hba data structure. - * - * This routine is to get the next eligible FCF record index in a round - * robin fashion. If the next eligible FCF record index equals to the - * initial round robin FCF record index, LPFC_FCOE_FCF_NEXT_NONE (0xFFFF) - * shall be returned, otherwise, the next eligible FCF record's index - * shall be returned. - **/ -uint16_t -lpfc_sli4_fcf_rr_next_index_get(struct lpfc_hba *phba) -{ - uint16_t next_fcf_index; - - /* Search from the currently registered FCF index */ - next_fcf_index = find_next_bit(phba->fcf.fcf_rr_bmask, - LPFC_SLI4_FCF_TBL_INDX_MAX, - phba->fcf.current_rec.fcf_indx); - /* Wrap around condition on phba->fcf.fcf_rr_bmask */ - if (next_fcf_index >= LPFC_SLI4_FCF_TBL_INDX_MAX) - next_fcf_index = find_next_bit(phba->fcf.fcf_rr_bmask, - LPFC_SLI4_FCF_TBL_INDX_MAX, 0); - /* Round robin failover stop condition */ - if (next_fcf_index == phba->fcf.fcf_rr_init_indx) - return LPFC_FCOE_FCF_NEXT_NONE; - - return next_fcf_index; -} - -/** - * lpfc_sli4_fcf_rr_index_set - Set bmask with eligible fcf record index - * @phba: pointer to lpfc hba data structure. - * - * This routine sets the FCF record index in to the eligible bmask for - * round robin failover search. It checks to make sure that the index - * does not go beyond the range of the driver allocated bmask dimension - * before setting the bit. - * - * Returns 0 if the index bit successfully set, otherwise, it returns - * -EINVAL. - **/ -int -lpfc_sli4_fcf_rr_index_set(struct lpfc_hba *phba, uint16_t fcf_index) -{ - if (fcf_index >= LPFC_SLI4_FCF_TBL_INDX_MAX) { - lpfc_printf_log(phba, KERN_ERR, LOG_FIP, - "2610 HBA FCF index reached driver's " - "book keeping dimension: fcf_index:%d, " - "driver_bmask_max:%d\n", - fcf_index, LPFC_SLI4_FCF_TBL_INDX_MAX); - return -EINVAL; - } - /* Set the eligible FCF record index bmask */ - set_bit(fcf_index, phba->fcf.fcf_rr_bmask); - - return 0; -} - -/** - * lpfc_sli4_fcf_rr_index_set - Clear bmask from eligible fcf record index - * @phba: pointer to lpfc hba data structure. - * - * This routine clears the FCF record index from the eligible bmask for - * round robin failover search. It checks to make sure that the index - * does not go beyond the range of the driver allocated bmask dimension - * before clearing the bit. - **/ -void -lpfc_sli4_fcf_rr_index_clear(struct lpfc_hba *phba, uint16_t fcf_index) -{ - if (fcf_index >= LPFC_SLI4_FCF_TBL_INDX_MAX) { - lpfc_printf_log(phba, KERN_ERR, LOG_FIP, - "2762 HBA FCF index goes beyond driver's " - "book keeping dimension: fcf_index:%d, " - "driver_bmask_max:%d\n", - fcf_index, LPFC_SLI4_FCF_TBL_INDX_MAX); - return; - } - /* Clear the eligible FCF record index bmask */ - clear_bit(fcf_index, phba->fcf.fcf_rr_bmask); -} - /** * lpfc_mbx_cmpl_redisc_fcf_table - completion routine for rediscover FCF table * @phba: pointer to lpfc hba data structure. @@ -12252,40 +12014,21 @@ lpfc_mbx_cmpl_redisc_fcf_table(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox) shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &redisc_fcf->header.cfg_shdr.response); if (shdr_status || shdr_add_status) { - lpfc_printf_log(phba, KERN_ERR, LOG_FIP, + lpfc_printf_log(phba, KERN_ERR, LOG_SLI, "2746 Requesting for FCF rediscovery failed " "status x%x add_status x%x\n", shdr_status, shdr_add_status); - if (phba->fcf.fcf_flag & FCF_ACVL_DISC) { - spin_lock_irq(&phba->hbalock); - phba->fcf.fcf_flag &= ~FCF_ACVL_DISC; - spin_unlock_irq(&phba->hbalock); - /* - * CVL event triggered FCF rediscover request failed, - * last resort to re-try current registered FCF entry. - */ - lpfc_retry_pport_discovery(phba); - } else { - spin_lock_irq(&phba->hbalock); - phba->fcf.fcf_flag &= ~FCF_DEAD_DISC; - spin_unlock_irq(&phba->hbalock); - /* - * DEAD FCF event triggered FCF rediscover request - * failed, last resort to fail over as a link down - * to FCF registration. - */ - lpfc_sli4_fcf_dead_failthrough(phba); - } - } else { - lpfc_printf_log(phba, KERN_INFO, LOG_FIP, - "2775 Start FCF rediscovery quiescent period " - "wait timer before scaning FCF table\n"); + /* + * Request failed, last resort to re-try current + * registered FCF entry + */ + lpfc_retry_pport_discovery(phba); + } else /* * Start FCF rediscovery wait timer for pending FCF * before rescan FCF record table. */ lpfc_fcf_redisc_wait_start_timer(phba); - } mempool_free(mbox, phba->mbox_mem_pool); } @@ -12304,9 +12047,6 @@ lpfc_sli4_redisc_fcf_table(struct lpfc_hba *phba) struct lpfc_mbx_redisc_fcf_tbl *redisc_fcf; int rc, length; - /* Cancel retry delay timers to all vports before FCF rediscover */ - lpfc_cancel_all_vport_retry_delay_timer(phba); - mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); if (!mbox) { lpfc_printf_log(phba, KERN_ERR, LOG_SLI, @@ -12337,31 +12077,6 @@ lpfc_sli4_redisc_fcf_table(struct lpfc_hba *phba) return 0; } -/** - * lpfc_sli4_fcf_dead_failthrough - Failthrough routine to fcf dead event - * @phba: pointer to lpfc hba data structure. - * - * This function is the failover routine as a last resort to the FCF DEAD - * event when driver failed to perform fast FCF failover. - **/ -void -lpfc_sli4_fcf_dead_failthrough(struct lpfc_hba *phba) -{ - uint32_t link_state; - - /* - * Last resort as FCF DEAD event failover will treat this as - * a link down, but save the link state because we don't want - * it to be changed to Link Down unless it is already down. - */ - link_state = phba->link_state; - lpfc_linkdown(phba); - phba->link_state = link_state; - - /* Unregister FCF if no devices connected to it */ - lpfc_unregister_unused_fcf(phba); -} - /** * lpfc_sli_read_link_ste - Read region 23 to decide if link is disabled. * @phba: pointer to lpfc hba data structure. diff --git a/trunk/drivers/scsi/lpfc/lpfc_sli.h b/trunk/drivers/scsi/lpfc/lpfc_sli.h index b4a639c47616..dfcf5437d1f5 100644 --- a/trunk/drivers/scsi/lpfc/lpfc_sli.h +++ b/trunk/drivers/scsi/lpfc/lpfc_sli.h @@ -62,7 +62,6 @@ struct lpfc_iocbq { #define LPFC_DELAY_MEM_FREE 0x20 /* Defer free'ing of FC data */ #define LPFC_EXCHANGE_BUSY 0x40 /* SLI4 hba reported XB in response */ #define LPFC_USE_FCPWQIDX 0x80 /* Submit to specified FCPWQ index */ -#define DSS_SECURITY_OP 0x100 /* security IO */ #define LPFC_FIP_ELS_ID_MASK 0xc000 /* ELS_ID range 0-3, non-shifted mask */ #define LPFC_FIP_ELS_ID_SHIFT 14 diff --git a/trunk/drivers/scsi/lpfc/lpfc_sli4.h b/trunk/drivers/scsi/lpfc/lpfc_sli4.h index 4a35e7b9bc5b..86308836600f 100644 --- a/trunk/drivers/scsi/lpfc/lpfc_sli4.h +++ b/trunk/drivers/scsi/lpfc/lpfc_sli4.h @@ -153,27 +153,15 @@ struct lpfc_fcf { #define FCF_REGISTERED 0x02 /* FCF registered with FW */ #define FCF_SCAN_DONE 0x04 /* FCF table scan done */ #define FCF_IN_USE 0x08 /* Atleast one discovery completed */ -#define FCF_INIT_DISC 0x10 /* Initial FCF discovery */ -#define FCF_DEAD_DISC 0x20 /* FCF DEAD fast FCF failover discovery */ -#define FCF_ACVL_DISC 0x40 /* All CVL fast FCF failover discovery */ -#define FCF_DISCOVERY (FCF_INIT_DISC | FCF_DEAD_DISC | FCF_ACVL_DISC) -#define FCF_REDISC_PEND 0x80 /* FCF rediscovery pending */ -#define FCF_REDISC_EVT 0x100 /* FCF rediscovery event to worker thread */ -#define FCF_REDISC_FOV 0x200 /* Post FCF rediscovery fast failover */ +#define FCF_REDISC_PEND 0x10 /* FCF rediscovery pending */ +#define FCF_REDISC_EVT 0x20 /* FCF rediscovery event to worker thread */ +#define FCF_REDISC_FOV 0x40 /* Post FCF rediscovery fast failover */ uint32_t addr_mode; - uint16_t fcf_rr_init_indx; struct lpfc_fcf_rec current_rec; struct lpfc_fcf_rec failover_rec; struct timer_list redisc_wait; - unsigned long *fcf_rr_bmask; /* Eligible FCF indexes for RR failover */ }; -/* - * Maximum FCF table index, it is for driver internal book keeping, it - * just needs to be no less than the supported HBA's FCF table size. - */ -#define LPFC_SLI4_FCF_TBL_INDX_MAX 32 - #define LPFC_REGION23_SIGNATURE "RG23" #define LPFC_REGION23_VERSION 1 #define LPFC_REGION23_LAST_REC 0xff @@ -443,18 +431,11 @@ enum lpfc_sge_type { SCSI_BUFF_TYPE }; -enum lpfc_sgl_state { - SGL_FREED, - SGL_ALLOCATED, - SGL_XRI_ABORTED -}; - struct lpfc_sglq { /* lpfc_sglqs are used in double linked lists */ struct list_head list; struct list_head clist; enum lpfc_sge_type buff_type; /* is this a scsi sgl */ - enum lpfc_sgl_state state; uint16_t iotag; /* pre-assigned IO tag */ uint16_t sli4_xritag; /* pre-assigned XRI, (OXID) tag. */ struct sli4_sge *sgl; /* pre-assigned SGL */ @@ -482,8 +463,8 @@ void lpfc_sli4_mbox_cmd_free(struct lpfc_hba *, struct lpfcMboxq *); void lpfc_sli4_mbx_sge_set(struct lpfcMboxq *, uint32_t, dma_addr_t, uint32_t); void lpfc_sli4_mbx_sge_get(struct lpfcMboxq *, uint32_t, struct lpfc_mbx_sge *); -int lpfc_sli4_mbx_read_fcf_rec(struct lpfc_hba *, struct lpfcMboxq *, - uint16_t); +int lpfc_sli4_mbx_read_fcf_record(struct lpfc_hba *, struct lpfcMboxq *, + uint16_t); void lpfc_sli4_hba_reset(struct lpfc_hba *); struct lpfc_queue *lpfc_sli4_queue_alloc(struct lpfc_hba *, uint32_t, @@ -542,13 +523,8 @@ int lpfc_sli4_init_vpi(struct lpfc_hba *, uint16_t); uint32_t lpfc_sli4_cq_release(struct lpfc_queue *, bool); uint32_t lpfc_sli4_eq_release(struct lpfc_queue *, bool); void lpfc_sli4_fcfi_unreg(struct lpfc_hba *, uint16_t); -int lpfc_sli4_fcf_scan_read_fcf_rec(struct lpfc_hba *, uint16_t); -int lpfc_sli4_fcf_rr_read_fcf_rec(struct lpfc_hba *, uint16_t); -int lpfc_sli4_read_fcf_rec(struct lpfc_hba *, uint16_t); -void lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *, LPFC_MBOXQ_t *); -void lpfc_mbx_cmpl_fcf_rr_read_fcf_rec(struct lpfc_hba *, LPFC_MBOXQ_t *); -void lpfc_mbx_cmpl_read_fcf_rec(struct lpfc_hba *, LPFC_MBOXQ_t *); -int lpfc_sli4_unregister_fcf(struct lpfc_hba *); +int lpfc_sli4_read_fcf_record(struct lpfc_hba *, uint16_t); +void lpfc_mbx_cmpl_read_fcf_record(struct lpfc_hba *, LPFC_MBOXQ_t *); int lpfc_sli4_post_status_check(struct lpfc_hba *); uint8_t lpfc_sli4_mbox_opcode_get(struct lpfc_hba *, struct lpfcMboxq *); diff --git a/trunk/drivers/scsi/lpfc/lpfc_version.h b/trunk/drivers/scsi/lpfc/lpfc_version.h index 013deec5dae8..ac276aa46fba 100644 --- a/trunk/drivers/scsi/lpfc/lpfc_version.h +++ b/trunk/drivers/scsi/lpfc/lpfc_version.h @@ -18,7 +18,7 @@ * included with this package. * *******************************************************************/ -#define LPFC_DRIVER_VERSION "8.3.10" +#define LPFC_DRIVER_VERSION "8.3.9" #define LPFC_DRIVER_NAME "lpfc" #define LPFC_SP_DRIVER_HANDLER_NAME "lpfc:sp" #define LPFC_FP_DRIVER_HANDLER_NAME "lpfc:fp" diff --git a/trunk/drivers/scsi/lpfc/lpfc_vport.c b/trunk/drivers/scsi/lpfc/lpfc_vport.c index 869f76cbc58a..dc86e873102a 100644 --- a/trunk/drivers/scsi/lpfc/lpfc_vport.c +++ b/trunk/drivers/scsi/lpfc/lpfc_vport.c @@ -123,12 +123,7 @@ lpfc_vport_sparm(struct lpfc_hba *phba, struct lpfc_vport *vport) } mb = &pmb->u.mb; - rc = lpfc_read_sparam(phba, pmb, vport->vpi); - if (rc) { - mempool_free(pmb, phba->mbox_mem_pool); - return -ENOMEM; - } - + lpfc_read_sparam(phba, pmb, vport->vpi); /* * Grab buffer pointer and clear context1 so we can use * lpfc_sli_issue_box_wait diff --git a/trunk/drivers/scsi/osd/osd_initiator.c b/trunk/drivers/scsi/osd/osd_initiator.c index 60de85091502..24223473f573 100644 --- a/trunk/drivers/scsi/osd/osd_initiator.c +++ b/trunk/drivers/scsi/osd/osd_initiator.c @@ -1433,10 +1433,6 @@ int osd_finalize_request(struct osd_request *or, cdbh->command_specific_options |= or->attributes_mode; if (or->attributes_mode == OSD_CDB_GET_ATTR_PAGE_SET_ONE) { ret = _osd_req_finalize_attr_page(or); - if (ret) { - OSD_DEBUG("_osd_req_finalize_attr_page failed\n"); - return ret; - } } else { /* TODO: I think that for the GET_ATTR command these 2 should * be reversed to keep them in execution order (for embeded diff --git a/trunk/drivers/scsi/pcmcia/nsp_cs.c b/trunk/drivers/scsi/pcmcia/nsp_cs.c index 021246454872..c2341af587a3 100644 --- a/trunk/drivers/scsi/pcmcia/nsp_cs.c +++ b/trunk/drivers/scsi/pcmcia/nsp_cs.c @@ -1717,7 +1717,6 @@ static int nsp_cs_config(struct pcmcia_device *link) cfg_mem->data = data; ret = pcmcia_loop_config(link, nsp_cs_config_check, cfg_mem); - if (ret) goto cs_failed; if (link->conf.Attributes & CONF_ENABLE_IRQ) { diff --git a/trunk/drivers/scsi/raid_class.c b/trunk/drivers/scsi/raid_class.c index 2c146b44d95f..bd88349b8526 100644 --- a/trunk/drivers/scsi/raid_class.c +++ b/trunk/drivers/scsi/raid_class.c @@ -63,7 +63,6 @@ static int raid_match(struct attribute_container *cont, struct device *dev) * emulated RAID devices, so start with SCSI */ struct raid_internal *i = ac_to_raid_internal(cont); -#if defined(CONFIG_SCSI) || defined(CONFIG_SCSI_MODULE) if (scsi_is_sdev_device(dev)) { struct scsi_device *sdev = to_scsi_device(dev); @@ -72,7 +71,6 @@ static int raid_match(struct attribute_container *cont, struct device *dev) return i->f->is_raid(dev); } -#endif /* FIXME: look at other subsystems too */ return 0; } diff --git a/trunk/drivers/scsi/scsi_transport_fc.c b/trunk/drivers/scsi/scsi_transport_fc.c index 1d5b72173dd8..79660ee3e211 100644 --- a/trunk/drivers/scsi/scsi_transport_fc.c +++ b/trunk/drivers/scsi/scsi_transport_fc.c @@ -1232,15 +1232,6 @@ store_fc_vport_delete(struct device *dev, struct device_attribute *attr, { struct fc_vport *vport = transport_class_to_vport(dev); struct Scsi_Host *shost = vport_to_shost(vport); - unsigned long flags; - - spin_lock_irqsave(shost->host_lock, flags); - if (vport->flags & (FC_VPORT_DEL | FC_VPORT_CREATING)) { - spin_unlock_irqrestore(shost->host_lock, flags); - return -EBUSY; - } - vport->flags |= FC_VPORT_DELETING; - spin_unlock_irqrestore(shost->host_lock, flags); fc_queue_work(shost, &vport->vport_delete_work); return count; @@ -1830,9 +1821,6 @@ store_fc_host_vport_delete(struct device *dev, struct device_attribute *attr, list_for_each_entry(vport, &fc_host->vports, peers) { if ((vport->channel == 0) && (vport->port_name == wwpn) && (vport->node_name == wwnn)) { - if (vport->flags & (FC_VPORT_DEL | FC_VPORT_CREATING)) - break; - vport->flags |= FC_VPORT_DELETING; match = 1; break; } @@ -3382,6 +3370,18 @@ fc_vport_terminate(struct fc_vport *vport) unsigned long flags; int stat; + spin_lock_irqsave(shost->host_lock, flags); + if (vport->flags & FC_VPORT_CREATING) { + spin_unlock_irqrestore(shost->host_lock, flags); + return -EBUSY; + } + if (vport->flags & (FC_VPORT_DEL)) { + spin_unlock_irqrestore(shost->host_lock, flags); + return -EALREADY; + } + vport->flags |= FC_VPORT_DELETING; + spin_unlock_irqrestore(shost->host_lock, flags); + if (i->f->vport_delete) stat = i->f->vport_delete(vport); else diff --git a/trunk/drivers/scsi/sd.c b/trunk/drivers/scsi/sd.c index 7b75c8a2a49d..83881dfb33c0 100644 --- a/trunk/drivers/scsi/sd.c +++ b/trunk/drivers/scsi/sd.c @@ -1948,7 +1948,7 @@ static void sd_read_block_limits(struct scsi_disk *sdkp) { struct request_queue *q = sdkp->disk->queue; unsigned int sector_sz = sdkp->device->sector_size; - const int vpd_len = 64; + const int vpd_len = 32; unsigned char *buffer = kmalloc(vpd_len, GFP_KERNEL); if (!buffer || @@ -1998,7 +1998,7 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp) { unsigned char *buffer; u16 rot; - const int vpd_len = 64; + const int vpd_len = 32; buffer = kmalloc(vpd_len, GFP_KERNEL); diff --git a/trunk/drivers/serial/sunsab.c b/trunk/drivers/serial/sunsab.c index d2e0321049e2..d514e28d0755 100644 --- a/trunk/drivers/serial/sunsab.c +++ b/trunk/drivers/serial/sunsab.c @@ -474,7 +474,7 @@ static void sunsab_stop_rx(struct uart_port *port) { struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; - up->interrupt_mask0 |= SAB82532_IMR0_TCD; + up->interrupt_mask0 |= SAB82532_ISR0_TCD; writeb(up->interrupt_mask1, &up->regs->w.imr0); } diff --git a/trunk/drivers/staging/samsung-laptop/samsung-laptop.c b/trunk/drivers/staging/samsung-laptop/samsung-laptop.c index eb44b60e1eb5..dd7ea4c075db 100644 --- a/trunk/drivers/staging/samsung-laptop/samsung-laptop.c +++ b/trunk/drivers/staging/samsung-laptop/samsung-laptop.c @@ -394,7 +394,6 @@ MODULE_DEVICE_TABLE(dmi, samsung_dmi_table); static int __init samsung_init(void) { - struct backlight_properties props; struct sabi_retval sretval; const char *testStr = "SECLINUX"; void __iomem *memcheck; @@ -487,14 +486,12 @@ static int __init samsung_init(void) goto error_no_platform; /* create a backlight device to talk to this one */ - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = MAX_BRIGHT; backlight_device = backlight_device_register("samsung", &sdev->dev, - NULL, &backlight_ops, - &props); + NULL, &backlight_ops); if (IS_ERR(backlight_device)) goto error_no_backlight; + backlight_device->props.max_brightness = MAX_BRIGHT; backlight_device->props.brightness = read_brightness(); backlight_device->props.power = FB_BLANK_UNBLANK; backlight_update_status(backlight_device); diff --git a/trunk/drivers/usb/misc/appledisplay.c b/trunk/drivers/usb/misc/appledisplay.c index 3adab041355a..4d2952f1fb13 100644 --- a/trunk/drivers/usb/misc/appledisplay.c +++ b/trunk/drivers/usb/misc/appledisplay.c @@ -202,7 +202,6 @@ static void appledisplay_work(struct work_struct *work) static int appledisplay_probe(struct usb_interface *iface, const struct usb_device_id *id) { - struct backlight_properties props; struct appledisplay *pdata; struct usb_device *udev = interface_to_usbdev(iface); struct usb_host_interface *iface_desc; @@ -280,16 +279,16 @@ static int appledisplay_probe(struct usb_interface *iface, /* Register backlight device */ snprintf(bl_name, sizeof(bl_name), "appledisplay%d", atomic_inc_return(&count_displays) - 1); - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = 0xff; pdata->bd = backlight_device_register(bl_name, NULL, pdata, - &appledisplay_bl_data, &props); + &appledisplay_bl_data); if (IS_ERR(pdata->bd)) { dev_err(&iface->dev, "Backlight registration failed\n"); retval = PTR_ERR(pdata->bd); goto error; } + pdata->bd->props.max_brightness = 0xff; + /* Try to get brightness */ brightness = appledisplay_bl_get_brightness(pdata->bd); diff --git a/trunk/drivers/video/Kconfig b/trunk/drivers/video/Kconfig index feaff4f04b58..dabe804ba575 100644 --- a/trunk/drivers/video/Kconfig +++ b/trunk/drivers/video/Kconfig @@ -914,7 +914,7 @@ config FB_XVR2500 config FB_XVR1000 bool "Sun XVR-1000 support" - depends on (FB = y) && SPARC64 + depends on SPARC64 select FB_CFB_FILLRECT select FB_CFB_COPYAREA select FB_CFB_IMAGEBLIT diff --git a/trunk/drivers/video/atmel_lcdfb.c b/trunk/drivers/video/atmel_lcdfb.c index 11de3bfd4e54..3d886c6902f9 100644 --- a/trunk/drivers/video/atmel_lcdfb.c +++ b/trunk/drivers/video/atmel_lcdfb.c @@ -117,7 +117,6 @@ static struct backlight_ops atmel_lcdc_bl_ops = { static void init_backlight(struct atmel_lcdfb_info *sinfo) { - struct backlight_properties props; struct backlight_device *bl; sinfo->bl_power = FB_BLANK_UNBLANK; @@ -125,10 +124,8 @@ static void init_backlight(struct atmel_lcdfb_info *sinfo) if (sinfo->backlight) return; - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = 0xff; - bl = backlight_device_register("backlight", &sinfo->pdev->dev, sinfo, - &atmel_lcdc_bl_ops, &props); + bl = backlight_device_register("backlight", &sinfo->pdev->dev, + sinfo, &atmel_lcdc_bl_ops); if (IS_ERR(bl)) { dev_err(&sinfo->pdev->dev, "error %ld on backlight register\n", PTR_ERR(bl)); @@ -138,6 +135,7 @@ static void init_backlight(struct atmel_lcdfb_info *sinfo) bl->props.power = FB_BLANK_UNBLANK; bl->props.fb_blank = FB_BLANK_UNBLANK; + bl->props.max_brightness = 0xff; bl->props.brightness = atmel_bl_get_brightness(bl); } diff --git a/trunk/drivers/video/aty/aty128fb.c b/trunk/drivers/video/aty/aty128fb.c index a489be0c4614..9ee67d6da710 100644 --- a/trunk/drivers/video/aty/aty128fb.c +++ b/trunk/drivers/video/aty/aty128fb.c @@ -1802,7 +1802,6 @@ static void aty128_bl_set_power(struct fb_info *info, int power) static void aty128_bl_init(struct aty128fb_par *par) { - struct backlight_properties props; struct fb_info *info = pci_get_drvdata(par->pdev); struct backlight_device *bd; char name[12]; @@ -1818,10 +1817,7 @@ static void aty128_bl_init(struct aty128fb_par *par) snprintf(name, sizeof(name), "aty128bl%d", info->node); - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = FB_BACKLIGHT_LEVELS - 1; - bd = backlight_device_register(name, info->dev, par, &aty128_bl_data, - &props); + bd = backlight_device_register(name, info->dev, par, &aty128_bl_data); if (IS_ERR(bd)) { info->bl_dev = NULL; printk(KERN_WARNING "aty128: Backlight registration failed\n"); @@ -1833,6 +1829,7 @@ static void aty128_bl_init(struct aty128fb_par *par) 63 * FB_BACKLIGHT_MAX / MAX_LEVEL, 219 * FB_BACKLIGHT_MAX / MAX_LEVEL); + bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1; bd->props.brightness = bd->props.max_brightness; bd->props.power = FB_BLANK_UNBLANK; backlight_update_status(bd); diff --git a/trunk/drivers/video/aty/atyfb_base.c b/trunk/drivers/video/aty/atyfb_base.c index 29d72851f85b..e45ab8db2ddc 100644 --- a/trunk/drivers/video/aty/atyfb_base.c +++ b/trunk/drivers/video/aty/atyfb_base.c @@ -2232,7 +2232,6 @@ static struct backlight_ops aty_bl_data = { static void aty_bl_init(struct atyfb_par *par) { - struct backlight_properties props; struct fb_info *info = pci_get_drvdata(par->pdev); struct backlight_device *bd; char name[12]; @@ -2244,10 +2243,7 @@ static void aty_bl_init(struct atyfb_par *par) snprintf(name, sizeof(name), "atybl%d", info->node); - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = FB_BACKLIGHT_LEVELS - 1; - bd = backlight_device_register(name, info->dev, par, &aty_bl_data, - &props); + bd = backlight_device_register(name, info->dev, par, &aty_bl_data); if (IS_ERR(bd)) { info->bl_dev = NULL; printk(KERN_WARNING "aty: Backlight registration failed\n"); @@ -2259,6 +2255,7 @@ static void aty_bl_init(struct atyfb_par *par) 0x3F * FB_BACKLIGHT_MAX / MAX_LEVEL, 0xFF * FB_BACKLIGHT_MAX / MAX_LEVEL); + bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1; bd->props.brightness = bd->props.max_brightness; bd->props.power = FB_BLANK_UNBLANK; backlight_update_status(bd); diff --git a/trunk/drivers/video/aty/radeon_backlight.c b/trunk/drivers/video/aty/radeon_backlight.c index 9fc8c66be3ce..fa1198c4ccc5 100644 --- a/trunk/drivers/video/aty/radeon_backlight.c +++ b/trunk/drivers/video/aty/radeon_backlight.c @@ -134,7 +134,6 @@ static struct backlight_ops radeon_bl_data = { void radeonfb_bl_init(struct radeonfb_info *rinfo) { - struct backlight_properties props; struct backlight_device *bd; struct radeon_bl_privdata *pdata; char name[12]; @@ -156,10 +155,7 @@ void radeonfb_bl_init(struct radeonfb_info *rinfo) snprintf(name, sizeof(name), "radeonbl%d", rinfo->info->node); - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = FB_BACKLIGHT_LEVELS - 1; - bd = backlight_device_register(name, rinfo->info->dev, pdata, - &radeon_bl_data, &props); + bd = backlight_device_register(name, rinfo->info->dev, pdata, &radeon_bl_data); if (IS_ERR(bd)) { rinfo->info->bl_dev = NULL; printk("radeonfb: Backlight registration failed\n"); @@ -189,6 +185,7 @@ void radeonfb_bl_init(struct radeonfb_info *rinfo) 63 * FB_BACKLIGHT_MAX / MAX_RADEON_LEVEL, 217 * FB_BACKLIGHT_MAX / MAX_RADEON_LEVEL); + bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1; bd->props.brightness = bd->props.max_brightness; bd->props.power = FB_BLANK_UNBLANK; backlight_update_status(bd); diff --git a/trunk/drivers/video/backlight/88pm860x_bl.c b/trunk/drivers/video/backlight/88pm860x_bl.c index 93e25c77aeb2..b8f705cca438 100644 --- a/trunk/drivers/video/backlight/88pm860x_bl.c +++ b/trunk/drivers/video/backlight/88pm860x_bl.c @@ -187,7 +187,6 @@ static int pm860x_backlight_probe(struct platform_device *pdev) struct pm860x_backlight_data *data; struct backlight_device *bl; struct resource *res; - struct backlight_properties props; unsigned char value; char name[MFD_NAME_SIZE]; int ret; @@ -224,15 +223,14 @@ static int pm860x_backlight_probe(struct platform_device *pdev) return -EINVAL; } - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = MAX_BRIGHTNESS; bl = backlight_device_register(name, &pdev->dev, data, - &pm860x_backlight_ops, &props); + &pm860x_backlight_ops); if (IS_ERR(bl)) { dev_err(&pdev->dev, "failed to register backlight\n"); kfree(data); return PTR_ERR(bl); } + bl->props.max_brightness = MAX_BRIGHTNESS; bl->props.brightness = MAX_BRIGHTNESS; platform_set_drvdata(pdev, bl); diff --git a/trunk/drivers/video/backlight/Kconfig b/trunk/drivers/video/backlight/Kconfig index c025c84601b0..0c77fc610212 100644 --- a/trunk/drivers/video/backlight/Kconfig +++ b/trunk/drivers/video/backlight/Kconfig @@ -31,13 +31,6 @@ config LCD_CORGI Say y here to support the LCD panels usually found on SHARP corgi (C7x0) and spitz (Cxx00) models. -config LCD_L4F00242T03 - tristate "Epson L4F00242T03 LCD" - depends on LCD_CLASS_DEVICE && SPI_MASTER && GENERIC_GPIO - help - SPI driver for Epson L4F00242T03. This provides basic support - for init and powering the LCD up/down through a sysfs interface. - config LCD_LMS283GF05 tristate "Samsung LMS283GF05 LCD" depends on LCD_CLASS_DEVICE && SPI_MASTER && GENERIC_GPIO diff --git a/trunk/drivers/video/backlight/Makefile b/trunk/drivers/video/backlight/Makefile index 09d1f14d6257..6c704d41462d 100644 --- a/trunk/drivers/video/backlight/Makefile +++ b/trunk/drivers/video/backlight/Makefile @@ -3,7 +3,6 @@ obj-$(CONFIG_LCD_CLASS_DEVICE) += lcd.o obj-$(CONFIG_LCD_CORGI) += corgi_lcd.o obj-$(CONFIG_LCD_HP700) += jornada720_lcd.o -obj-$(CONFIG_LCD_L4F00242T03) += l4f00242t03.o obj-$(CONFIG_LCD_LMS283GF05) += lms283gf05.o obj-$(CONFIG_LCD_LTV350QV) += ltv350qv.o obj-$(CONFIG_LCD_ILI9320) += ili9320.o diff --git a/trunk/drivers/video/backlight/adp5520_bl.c b/trunk/drivers/video/backlight/adp5520_bl.c index 5183f0e4d314..86d95c228adb 100644 --- a/trunk/drivers/video/backlight/adp5520_bl.c +++ b/trunk/drivers/video/backlight/adp5520_bl.c @@ -278,7 +278,6 @@ static const struct attribute_group adp5520_bl_attr_group = { static int __devinit adp5520_bl_probe(struct platform_device *pdev) { - struct backlight_properties props; struct backlight_device *bl; struct adp5520_bl *data; int ret = 0; @@ -301,17 +300,17 @@ static int __devinit adp5520_bl_probe(struct platform_device *pdev) mutex_init(&data->lock); - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = ADP5020_MAX_BRIGHTNESS; - bl = backlight_device_register(pdev->name, data->master, data, - &adp5520_bl_ops, &props); + bl = backlight_device_register(pdev->name, data->master, + data, &adp5520_bl_ops); if (IS_ERR(bl)) { dev_err(&pdev->dev, "failed to register backlight\n"); kfree(data); return PTR_ERR(bl); } - bl->props.brightness = ADP5020_MAX_BRIGHTNESS; + bl->props.max_brightness = + bl->props.brightness = ADP5020_MAX_BRIGHTNESS; + if (data->pdata->en_ambl_sens) ret = sysfs_create_group(&bl->dev.kobj, &adp5520_bl_attr_group); diff --git a/trunk/drivers/video/backlight/adx_bl.c b/trunk/drivers/video/backlight/adx_bl.c index b0624b983889..d769b0bab21a 100644 --- a/trunk/drivers/video/backlight/adx_bl.c +++ b/trunk/drivers/video/backlight/adx_bl.c @@ -56,7 +56,7 @@ static int adx_backlight_get_brightness(struct backlight_device *bldev) return brightness & 0xff; } -static int adx_backlight_check_fb(struct backlight_device *bldev, struct fb_info *fb) +static int adx_backlight_check_fb(struct fb_info *fb) { return 1; } @@ -70,7 +70,6 @@ static const struct backlight_ops adx_backlight_ops = { static int __devinit adx_backlight_probe(struct platform_device *pdev) { - struct backlight_properties props; struct backlight_device *bldev; struct resource *res; struct adxbl *bl; @@ -102,15 +101,14 @@ static int __devinit adx_backlight_probe(struct platform_device *pdev) goto out; } - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = 0xff; - bldev = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, - bl, &adx_backlight_ops, &props); + bldev = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, bl, + &adx_backlight_ops); if (!bldev) { ret = -ENOMEM; goto out; } + bldev->props.max_brightness = 0xff; bldev->props.brightness = 0xff; bldev->props.power = FB_BLANK_UNBLANK; diff --git a/trunk/drivers/video/backlight/atmel-pwm-bl.c b/trunk/drivers/video/backlight/atmel-pwm-bl.c index 2d9760551a4b..f625ffc69ad3 100644 --- a/trunk/drivers/video/backlight/atmel-pwm-bl.c +++ b/trunk/drivers/video/backlight/atmel-pwm-bl.c @@ -120,7 +120,6 @@ static const struct backlight_ops atmel_pwm_bl_ops = { static int atmel_pwm_bl_probe(struct platform_device *pdev) { - struct backlight_properties props; const struct atmel_pwm_bl_platform_data *pdata; struct backlight_device *bldev; struct atmel_pwm_bl *pwmbl; @@ -166,10 +165,8 @@ static int atmel_pwm_bl_probe(struct platform_device *pdev) goto err_free_gpio; } - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = pdata->pwm_duty_max - pdata->pwm_duty_min; - bldev = backlight_device_register("atmel-pwm-bl", &pdev->dev, pwmbl, - &atmel_pwm_bl_ops, &props); + bldev = backlight_device_register("atmel-pwm-bl", + &pdev->dev, pwmbl, &atmel_pwm_bl_ops); if (IS_ERR(bldev)) { retval = PTR_ERR(bldev); goto err_free_gpio; @@ -181,6 +178,7 @@ static int atmel_pwm_bl_probe(struct platform_device *pdev) /* Power up the backlight by default at middle intesity. */ bldev->props.power = FB_BLANK_UNBLANK; + bldev->props.max_brightness = pdata->pwm_duty_max - pdata->pwm_duty_min; bldev->props.brightness = bldev->props.max_brightness / 2; retval = atmel_pwm_bl_init_pwm(pwmbl); diff --git a/trunk/drivers/video/backlight/backlight.c b/trunk/drivers/video/backlight/backlight.c index 68bb838b9f11..18829cf68b1b 100644 --- a/trunk/drivers/video/backlight/backlight.c +++ b/trunk/drivers/video/backlight/backlight.c @@ -38,7 +38,7 @@ static int fb_notifier_callback(struct notifier_block *self, mutex_lock(&bd->ops_lock); if (bd->ops) if (!bd->ops->check_fb || - bd->ops->check_fb(bd, evdata->info)) { + bd->ops->check_fb(evdata->info)) { bd->props.fb_blank = *(int *)evdata->data; if (bd->props.fb_blank == FB_BLANK_UNBLANK) bd->props.state &= ~BL_CORE_FBBLANK; @@ -269,8 +269,7 @@ EXPORT_SYMBOL(backlight_force_update); * ERR_PTR() or a pointer to the newly allocated device. */ struct backlight_device *backlight_device_register(const char *name, - struct device *parent, void *devdata, const struct backlight_ops *ops, - const struct backlight_properties *props) + struct device *parent, void *devdata, const struct backlight_ops *ops) { struct backlight_device *new_bd; int rc; @@ -290,11 +289,6 @@ struct backlight_device *backlight_device_register(const char *name, dev_set_name(&new_bd->dev, name); dev_set_drvdata(&new_bd->dev, devdata); - /* Set default properties */ - if (props) - memcpy(&new_bd->props, props, - sizeof(struct backlight_properties)); - rc = device_register(&new_bd->dev); if (rc) { kfree(new_bd); diff --git a/trunk/drivers/video/backlight/corgi_lcd.c b/trunk/drivers/video/backlight/corgi_lcd.c index 73bdd8454c94..b4bcf8043797 100644 --- a/trunk/drivers/video/backlight/corgi_lcd.c +++ b/trunk/drivers/video/backlight/corgi_lcd.c @@ -533,7 +533,6 @@ static int setup_gpio_backlight(struct corgi_lcd *lcd, static int __devinit corgi_lcd_probe(struct spi_device *spi) { - struct backlight_properties props; struct corgi_lcd_platform_data *pdata = spi->dev.platform_data; struct corgi_lcd *lcd; int ret = 0; @@ -560,14 +559,13 @@ static int __devinit corgi_lcd_probe(struct spi_device *spi) lcd->power = FB_BLANK_POWERDOWN; lcd->mode = (pdata) ? pdata->init_mode : CORGI_LCD_MODE_VGA; - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = pdata->max_intensity; - lcd->bl_dev = backlight_device_register("corgi_bl", &spi->dev, lcd, - &corgi_bl_ops, &props); + lcd->bl_dev = backlight_device_register("corgi_bl", &spi->dev, + lcd, &corgi_bl_ops); if (IS_ERR(lcd->bl_dev)) { ret = PTR_ERR(lcd->bl_dev); goto err_unregister_lcd; } + lcd->bl_dev->props.max_brightness = pdata->max_intensity; lcd->bl_dev->props.brightness = pdata->default_intensity; lcd->bl_dev->props.power = FB_BLANK_UNBLANK; diff --git a/trunk/drivers/video/backlight/cr_bllcd.c b/trunk/drivers/video/backlight/cr_bllcd.c index 1cce6031bff2..da86db4374a0 100644 --- a/trunk/drivers/video/backlight/cr_bllcd.c +++ b/trunk/drivers/video/backlight/cr_bllcd.c @@ -170,7 +170,6 @@ static struct lcd_ops cr_lcd_ops = { static int cr_backlight_probe(struct platform_device *pdev) { - struct backlight_properties props; struct backlight_device *bdp; struct lcd_device *ldp; struct cr_panel *crp; @@ -191,9 +190,8 @@ static int cr_backlight_probe(struct platform_device *pdev) return -ENODEV; } - memset(&props, 0, sizeof(struct backlight_properties)); - bdp = backlight_device_register("cr-backlight", &pdev->dev, NULL, - &cr_backlight_ops, &props); + bdp = backlight_device_register("cr-backlight", + &pdev->dev, NULL, &cr_backlight_ops); if (IS_ERR(bdp)) { pci_dev_put(lpc_dev); return PTR_ERR(bdp); @@ -222,7 +220,9 @@ static int cr_backlight_probe(struct platform_device *pdev) crp->cr_lcd_device = ldp; crp->cr_backlight_device->props.power = FB_BLANK_UNBLANK; crp->cr_backlight_device->props.brightness = 0; + crp->cr_backlight_device->props.max_brightness = 0; cr_backlight_set_intensity(crp->cr_backlight_device); + cr_lcd_set_power(crp->cr_lcd_device, FB_BLANK_UNBLANK); platform_set_drvdata(pdev, crp); diff --git a/trunk/drivers/video/backlight/da903x_bl.c b/trunk/drivers/video/backlight/da903x_bl.c index 686e4a789238..74cdc640173d 100644 --- a/trunk/drivers/video/backlight/da903x_bl.c +++ b/trunk/drivers/video/backlight/da903x_bl.c @@ -105,7 +105,6 @@ static int da903x_backlight_probe(struct platform_device *pdev) struct da9034_backlight_pdata *pdata = pdev->dev.platform_data; struct da903x_backlight_data *data; struct backlight_device *bl; - struct backlight_properties props; int max_brightness; data = kzalloc(sizeof(*data), GFP_KERNEL); @@ -135,15 +134,15 @@ static int da903x_backlight_probe(struct platform_device *pdev) da903x_write(data->da903x_dev, DA9034_WLED_CONTROL2, DA9034_WLED_ISET(pdata->output_current)); - props.max_brightness = max_brightness; - bl = backlight_device_register(pdev->name, data->da903x_dev, data, - &da903x_backlight_ops, &props); + bl = backlight_device_register(pdev->name, data->da903x_dev, + data, &da903x_backlight_ops); if (IS_ERR(bl)) { dev_err(&pdev->dev, "failed to register backlight\n"); kfree(data); return PTR_ERR(bl); } + bl->props.max_brightness = max_brightness; bl->props.brightness = max_brightness; platform_set_drvdata(pdev, bl); diff --git a/trunk/drivers/video/backlight/generic_bl.c b/trunk/drivers/video/backlight/generic_bl.c index 312ca619735d..e6d348e63596 100644 --- a/trunk/drivers/video/backlight/generic_bl.c +++ b/trunk/drivers/video/backlight/generic_bl.c @@ -78,7 +78,6 @@ static const struct backlight_ops genericbl_ops = { static int genericbl_probe(struct platform_device *pdev) { - struct backlight_properties props; struct generic_bl_info *machinfo = pdev->dev.platform_data; const char *name = "generic-bl"; struct backlight_device *bd; @@ -90,15 +89,14 @@ static int genericbl_probe(struct platform_device *pdev) if (machinfo->name) name = machinfo->name; - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = machinfo->max_intensity; - bd = backlight_device_register(name, &pdev->dev, NULL, &genericbl_ops, - &props); + bd = backlight_device_register (name, + &pdev->dev, NULL, &genericbl_ops); if (IS_ERR (bd)) return PTR_ERR (bd); platform_set_drvdata(pdev, bd); + bd->props.max_brightness = machinfo->max_intensity; bd->props.power = FB_BLANK_UNBLANK; bd->props.brightness = machinfo->default_intensity; backlight_update_status(bd); diff --git a/trunk/drivers/video/backlight/hp680_bl.c b/trunk/drivers/video/backlight/hp680_bl.c index 267d23f8d645..f7cc528d5be7 100644 --- a/trunk/drivers/video/backlight/hp680_bl.c +++ b/trunk/drivers/video/backlight/hp680_bl.c @@ -105,18 +105,16 @@ static const struct backlight_ops hp680bl_ops = { static int __devinit hp680bl_probe(struct platform_device *pdev) { - struct backlight_properties props; struct backlight_device *bd; - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = HP680_MAX_INTENSITY; - bd = backlight_device_register("hp680-bl", &pdev->dev, NULL, - &hp680bl_ops, &props); + bd = backlight_device_register ("hp680-bl", &pdev->dev, NULL, + &hp680bl_ops); if (IS_ERR(bd)) return PTR_ERR(bd); platform_set_drvdata(pdev, bd); + bd->props.max_brightness = HP680_MAX_INTENSITY; bd->props.brightness = HP680_DEFAULT_INTENSITY; hp680bl_send_intensity(bd); diff --git a/trunk/drivers/video/backlight/jornada720_bl.c b/trunk/drivers/video/backlight/jornada720_bl.c index 2f177b3a4885..db9071fc5665 100644 --- a/trunk/drivers/video/backlight/jornada720_bl.c +++ b/trunk/drivers/video/backlight/jornada720_bl.c @@ -101,14 +101,10 @@ static const struct backlight_ops jornada_bl_ops = { static int jornada_bl_probe(struct platform_device *pdev) { - struct backlight_properties props; int ret; struct backlight_device *bd; - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = BL_MAX_BRIGHT; - bd = backlight_device_register(S1D_DEVICENAME, &pdev->dev, NULL, - &jornada_bl_ops, &props); + bd = backlight_device_register(S1D_DEVICENAME, &pdev->dev, NULL, &jornada_bl_ops); if (IS_ERR(bd)) { ret = PTR_ERR(bd); @@ -121,6 +117,7 @@ static int jornada_bl_probe(struct platform_device *pdev) /* note. make sure max brightness is set otherwise you will get seemingly non-related errors when trying to change brightness */ + bd->props.max_brightness = BL_MAX_BRIGHT; jornada_bl_update_status(bd); platform_set_drvdata(pdev, bd); diff --git a/trunk/drivers/video/backlight/kb3886_bl.c b/trunk/drivers/video/backlight/kb3886_bl.c index f439a8632287..939e7b830cf3 100644 --- a/trunk/drivers/video/backlight/kb3886_bl.c +++ b/trunk/drivers/video/backlight/kb3886_bl.c @@ -141,24 +141,20 @@ static const struct backlight_ops kb3886bl_ops = { static int kb3886bl_probe(struct platform_device *pdev) { - struct backlight_properties props; struct kb3886bl_machinfo *machinfo = pdev->dev.platform_data; bl_machinfo = machinfo; if (!machinfo->limit_mask) machinfo->limit_mask = -1; - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = machinfo->max_intensity; kb3886_backlight_device = backlight_device_register("kb3886-bl", - &pdev->dev, NULL, - &kb3886bl_ops, - &props); + &pdev->dev, NULL, &kb3886bl_ops); if (IS_ERR(kb3886_backlight_device)) return PTR_ERR(kb3886_backlight_device); platform_set_drvdata(pdev, kb3886_backlight_device); + kb3886_backlight_device->props.max_brightness = machinfo->max_intensity; kb3886_backlight_device->props.power = FB_BLANK_UNBLANK; kb3886_backlight_device->props.brightness = machinfo->default_intensity; backlight_update_status(kb3886_backlight_device); diff --git a/trunk/drivers/video/backlight/l4f00242t03.c b/trunk/drivers/video/backlight/l4f00242t03.c deleted file mode 100644 index 74abd6994b09..000000000000 --- a/trunk/drivers/video/backlight/l4f00242t03.c +++ /dev/null @@ -1,257 +0,0 @@ -/* - * l4f00242t03.c -- support for Epson L4F00242T03 LCD - * - * Copyright 2007-2009 Freescale Semiconductor, Inc. All Rights Reserved. - * - * Copyright (c) 2009 Alberto Panizzo - * Inspired by Marek Vasut work in l4f00242t03.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#include -#include -#include -#include -#include -#include - -#include -#include - -struct l4f00242t03_priv { - struct spi_device *spi; - struct lcd_device *ld; - int lcd_on:1; - struct regulator *io_reg; - struct regulator *core_reg; -}; - - -static void l4f00242t03_reset(unsigned int gpio) -{ - pr_debug("l4f00242t03_reset.\n"); - gpio_set_value(gpio, 1); - mdelay(100); - gpio_set_value(gpio, 0); - mdelay(10); /* tRES >= 100us */ - gpio_set_value(gpio, 1); - mdelay(20); -} - -#define param(x) ((x) | 0x100) - -static void l4f00242t03_lcd_init(struct spi_device *spi) -{ - struct l4f00242t03_pdata *pdata = spi->dev.platform_data; - struct l4f00242t03_priv *priv = dev_get_drvdata(&spi->dev); - const u16 cmd[] = { 0x36, param(0), 0x3A, param(0x60) }; - - dev_dbg(&spi->dev, "initializing LCD\n"); - - if (priv->io_reg) { - regulator_set_voltage(priv->io_reg, 1800000, 1800000); - regulator_enable(priv->io_reg); - } - - if (priv->core_reg) { - regulator_set_voltage(priv->core_reg, 2800000, 2800000); - regulator_enable(priv->core_reg); - } - - gpio_set_value(pdata->data_enable_gpio, 1); - msleep(60); - spi_write(spi, (const u8 *)cmd, ARRAY_SIZE(cmd) * sizeof(u16)); -} - -static int l4f00242t03_lcd_power_set(struct lcd_device *ld, int power) -{ - struct l4f00242t03_priv *priv = lcd_get_data(ld); - struct spi_device *spi = priv->spi; - - const u16 slpout = 0x11; - const u16 dison = 0x29; - - const u16 slpin = 0x10; - const u16 disoff = 0x28; - - if (power) { - if (priv->lcd_on) - return 0; - - dev_dbg(&spi->dev, "turning on LCD\n"); - - spi_write(spi, (const u8 *)&slpout, sizeof(u16)); - msleep(60); - spi_write(spi, (const u8 *)&dison, sizeof(u16)); - - priv->lcd_on = 1; - } else { - if (!priv->lcd_on) - return 0; - - dev_dbg(&spi->dev, "turning off LCD\n"); - - spi_write(spi, (const u8 *)&disoff, sizeof(u16)); - msleep(60); - spi_write(spi, (const u8 *)&slpin, sizeof(u16)); - - priv->lcd_on = 0; - } - - return 0; -} - -static struct lcd_ops l4f_ops = { - .set_power = l4f00242t03_lcd_power_set, - .get_power = NULL, -}; - -static int __devinit l4f00242t03_probe(struct spi_device *spi) -{ - struct l4f00242t03_priv *priv; - struct l4f00242t03_pdata *pdata = spi->dev.platform_data; - int ret; - - if (pdata == NULL) { - dev_err(&spi->dev, "Uninitialized platform data.\n"); - return -EINVAL; - } - - priv = kzalloc(sizeof(struct l4f00242t03_priv), GFP_KERNEL); - - if (priv == NULL) { - dev_err(&spi->dev, "No memory for this device.\n"); - ret = -ENOMEM; - goto err; - } - - dev_set_drvdata(&spi->dev, priv); - spi->bits_per_word = 9; - spi_setup(spi); - - priv->spi = spi; - - ret = gpio_request(pdata->reset_gpio, "lcd l4f00242t03 reset"); - if (ret) { - dev_err(&spi->dev, - "Unable to get the lcd l4f00242t03 reset gpio.\n"); - return ret; - } - - ret = gpio_direction_output(pdata->reset_gpio, 1); - if (ret) - goto err2; - - ret = gpio_request(pdata->data_enable_gpio, - "lcd l4f00242t03 data enable"); - if (ret) { - dev_err(&spi->dev, - "Unable to get the lcd l4f00242t03 data en gpio.\n"); - return ret; - } - - ret = gpio_direction_output(pdata->data_enable_gpio, 0); - if (ret) - goto err3; - - if (pdata->io_supply) { - priv->io_reg = regulator_get(NULL, pdata->io_supply); - - if (IS_ERR(priv->io_reg)) { - pr_err("%s: Unable to get the IO regulator\n", - __func__); - goto err3; - } - } - - if (pdata->core_supply) { - priv->core_reg = regulator_get(NULL, pdata->core_supply); - - if (IS_ERR(priv->core_reg)) { - pr_err("%s: Unable to get the core regulator\n", - __func__); - goto err4; - } - } - - priv->ld = lcd_device_register("l4f00242t03", - &spi->dev, priv, &l4f_ops); - if (IS_ERR(priv->ld)) { - ret = PTR_ERR(priv->ld); - goto err5; - } - - /* Init the LCD */ - l4f00242t03_reset(pdata->reset_gpio); - l4f00242t03_lcd_init(spi); - l4f00242t03_lcd_power_set(priv->ld, 1); - - dev_info(&spi->dev, "Epson l4f00242t03 lcd probed.\n"); - - return 0; - -err5: - if (priv->core_reg) - regulator_put(priv->core_reg); -err4: - if (priv->io_reg) - regulator_put(priv->io_reg); -err3: - gpio_free(pdata->data_enable_gpio); -err2: - gpio_free(pdata->reset_gpio); -err: - kfree(priv); - - return ret; -} - -static int __devexit l4f00242t03_remove(struct spi_device *spi) -{ - struct l4f00242t03_priv *priv = dev_get_drvdata(&spi->dev); - struct l4f00242t03_pdata *pdata = priv->spi->dev.platform_data; - - l4f00242t03_lcd_power_set(priv->ld, 0); - lcd_device_unregister(priv->ld); - - gpio_free(pdata->data_enable_gpio); - gpio_free(pdata->reset_gpio); - - if (priv->io_reg) - regulator_put(priv->core_reg); - if (priv->core_reg) - regulator_put(priv->io_reg); - - kfree(priv); - - return 0; -} - -static struct spi_driver l4f00242t03_driver = { - .driver = { - .name = "l4f00242t03", - .owner = THIS_MODULE, - }, - .probe = l4f00242t03_probe, - .remove = __devexit_p(l4f00242t03_remove), -}; - -static __init int l4f00242t03_init(void) -{ - return spi_register_driver(&l4f00242t03_driver); -} - -static __exit void l4f00242t03_exit(void) -{ - spi_unregister_driver(&l4f00242t03_driver); -} - -module_init(l4f00242t03_init); -module_exit(l4f00242t03_exit); - -MODULE_AUTHOR("Alberto Panizzo "); -MODULE_DESCRIPTION("EPSON L4F00242T03 LCD"); -MODULE_LICENSE("GPL v2"); diff --git a/trunk/drivers/video/backlight/locomolcd.c b/trunk/drivers/video/backlight/locomolcd.c index 7571bc26071e..00a9591b0003 100644 --- a/trunk/drivers/video/backlight/locomolcd.c +++ b/trunk/drivers/video/backlight/locomolcd.c @@ -167,7 +167,6 @@ static int locomolcd_resume(struct locomo_dev *dev) static int locomolcd_probe(struct locomo_dev *ldev) { - struct backlight_properties props; unsigned long flags; local_irq_save(flags); @@ -183,16 +182,13 @@ static int locomolcd_probe(struct locomo_dev *ldev) local_irq_restore(flags); - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = 4; - locomolcd_bl_device = backlight_device_register("locomo-bl", - &ldev->dev, NULL, - &locomobl_data, &props); + locomolcd_bl_device = backlight_device_register("locomo-bl", &ldev->dev, NULL, &locomobl_data); if (IS_ERR (locomolcd_bl_device)) return PTR_ERR (locomolcd_bl_device); /* Set up frontlight so that screen is readable */ + locomolcd_bl_device->props.max_brightness = 4, locomolcd_bl_device->props.brightness = 2; locomolcd_set_intensity(locomolcd_bl_device); diff --git a/trunk/drivers/video/backlight/max8925_bl.c b/trunk/drivers/video/backlight/max8925_bl.c index c91adaf492cf..c267069a52a3 100644 --- a/trunk/drivers/video/backlight/max8925_bl.c +++ b/trunk/drivers/video/backlight/max8925_bl.c @@ -104,7 +104,6 @@ static int __devinit max8925_backlight_probe(struct platform_device *pdev) struct max8925_backlight_pdata *pdata = NULL; struct max8925_backlight_data *data; struct backlight_device *bl; - struct backlight_properties props; struct resource *res; char name[MAX8925_NAME_SIZE]; unsigned char value; @@ -134,15 +133,14 @@ static int __devinit max8925_backlight_probe(struct platform_device *pdev) data->chip = chip; data->current_brightness = 0; - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = MAX_BRIGHTNESS; bl = backlight_device_register(name, &pdev->dev, data, - &max8925_backlight_ops, &props); + &max8925_backlight_ops); if (IS_ERR(bl)) { dev_err(&pdev->dev, "failed to register backlight\n"); kfree(data); return PTR_ERR(bl); } + bl->props.max_brightness = MAX_BRIGHTNESS; bl->props.brightness = MAX_BRIGHTNESS; platform_set_drvdata(pdev, bl); diff --git a/trunk/drivers/video/backlight/mbp_nvidia_bl.c b/trunk/drivers/video/backlight/mbp_nvidia_bl.c index 1b5d3fe6bbbc..2e78b0784bdc 100644 --- a/trunk/drivers/video/backlight/mbp_nvidia_bl.c +++ b/trunk/drivers/video/backlight/mbp_nvidia_bl.c @@ -137,51 +137,6 @@ static int mbp_dmi_match(const struct dmi_system_id *id) } static const struct dmi_system_id __initdata mbp_device_table[] = { - { - .callback = mbp_dmi_match, - .ident = "MacBook 1,1", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "MacBook1,1"), - }, - .driver_data = (void *)&intel_chipset_data, - }, - { - .callback = mbp_dmi_match, - .ident = "MacBook 2,1", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "MacBook2,1"), - }, - .driver_data = (void *)&intel_chipset_data, - }, - { - .callback = mbp_dmi_match, - .ident = "MacBook 3,1", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "MacBook3,1"), - }, - .driver_data = (void *)&intel_chipset_data, - }, - { - .callback = mbp_dmi_match, - .ident = "MacBook 4,1", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "MacBook4,1"), - }, - .driver_data = (void *)&intel_chipset_data, - }, - { - .callback = mbp_dmi_match, - .ident = "MacBook 4,2", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "MacBook4,2"), - }, - .driver_data = (void *)&intel_chipset_data, - }, { .callback = mbp_dmi_match, .ident = "MacBookPro 3,1", @@ -295,7 +250,6 @@ static const struct dmi_system_id __initdata mbp_device_table[] = { static int __init mbp_init(void) { - struct backlight_properties props; if (!dmi_check_system(mbp_device_table)) return -ENODEV; @@ -303,17 +257,14 @@ static int __init mbp_init(void) "Macbook Pro backlight")) return -ENXIO; - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = 15; - mbp_backlight_device = backlight_device_register("mbp_backlight", NULL, - NULL, - &driver_data->backlight_ops, - &props); + mbp_backlight_device = backlight_device_register("mbp_backlight", + NULL, NULL, &driver_data->backlight_ops); if (IS_ERR(mbp_backlight_device)) { release_region(driver_data->iostart, driver_data->iolen); return PTR_ERR(mbp_backlight_device); } + mbp_backlight_device->props.max_brightness = 15; mbp_backlight_device->props.brightness = driver_data->backlight_ops.get_brightness(mbp_backlight_device); backlight_update_status(mbp_backlight_device); diff --git a/trunk/drivers/video/backlight/omap1_bl.c b/trunk/drivers/video/backlight/omap1_bl.c index 333d28e6b062..a3a7f8938175 100644 --- a/trunk/drivers/video/backlight/omap1_bl.c +++ b/trunk/drivers/video/backlight/omap1_bl.c @@ -132,7 +132,6 @@ static const struct backlight_ops omapbl_ops = { static int omapbl_probe(struct platform_device *pdev) { - struct backlight_properties props; struct backlight_device *dev; struct omap_backlight *bl; struct omap_backlight_config *pdata = pdev->dev.platform_data; @@ -144,10 +143,7 @@ static int omapbl_probe(struct platform_device *pdev) if (unlikely(!bl)) return -ENOMEM; - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = OMAPBL_MAX_INTENSITY; - dev = backlight_device_register("omap-bl", &pdev->dev, bl, &omapbl_ops, - &props); + dev = backlight_device_register("omap-bl", &pdev->dev, bl, &omapbl_ops); if (IS_ERR(dev)) { kfree(bl); return PTR_ERR(dev); @@ -164,6 +160,7 @@ static int omapbl_probe(struct platform_device *pdev) omap_cfg_reg(PWL); /* Conflicts with UART3 */ dev->props.fb_blank = FB_BLANK_UNBLANK; + dev->props.max_brightness = OMAPBL_MAX_INTENSITY; dev->props.brightness = pdata->default_intensity; omapbl_update_status(dev); diff --git a/trunk/drivers/video/backlight/progear_bl.c b/trunk/drivers/video/backlight/progear_bl.c index 809278c90738..075786e05034 100644 --- a/trunk/drivers/video/backlight/progear_bl.c +++ b/trunk/drivers/video/backlight/progear_bl.c @@ -61,10 +61,8 @@ static const struct backlight_ops progearbl_ops = { static int progearbl_probe(struct platform_device *pdev) { - struct backlight_properties props; u8 temp; struct backlight_device *progear_backlight_device; - int ret; pmu_dev = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, NULL); if (!pmu_dev) { @@ -75,37 +73,28 @@ static int progearbl_probe(struct platform_device *pdev) sb_dev = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL); if (!sb_dev) { printk("ALI 1533 SB not found.\n"); - ret = -ENODEV; - goto put_pmu; + pci_dev_put(pmu_dev); + return -ENODEV; } /* Set SB_MPS1 to enable brightness control. */ pci_read_config_byte(sb_dev, SB_MPS1, &temp); pci_write_config_byte(sb_dev, SB_MPS1, temp | 0x20); - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = HW_LEVEL_MAX - HW_LEVEL_MIN; progear_backlight_device = backlight_device_register("progear-bl", &pdev->dev, NULL, - &progearbl_ops, - &props); - if (IS_ERR(progear_backlight_device)) { - ret = PTR_ERR(progear_backlight_device); - goto put_sb; - } + &progearbl_ops); + if (IS_ERR(progear_backlight_device)) + return PTR_ERR(progear_backlight_device); platform_set_drvdata(pdev, progear_backlight_device); progear_backlight_device->props.power = FB_BLANK_UNBLANK; progear_backlight_device->props.brightness = HW_LEVEL_MAX - HW_LEVEL_MIN; + progear_backlight_device->props.max_brightness = HW_LEVEL_MAX - HW_LEVEL_MIN; progearbl_set_intensity(progear_backlight_device); return 0; -put_sb: - pci_dev_put(sb_dev); -put_pmu: - pci_dev_put(pmu_dev); - return ret; } static int progearbl_remove(struct platform_device *pdev) diff --git a/trunk/drivers/video/backlight/pwm_bl.c b/trunk/drivers/video/backlight/pwm_bl.c index b89eebc3f77d..9d2ec2a1cce8 100644 --- a/trunk/drivers/video/backlight/pwm_bl.c +++ b/trunk/drivers/video/backlight/pwm_bl.c @@ -65,7 +65,6 @@ static const struct backlight_ops pwm_backlight_ops = { static int pwm_backlight_probe(struct platform_device *pdev) { - struct backlight_properties props; struct platform_pwm_backlight_data *data = pdev->dev.platform_data; struct backlight_device *bl; struct pwm_bl_data *pb; @@ -101,16 +100,15 @@ static int pwm_backlight_probe(struct platform_device *pdev) } else dev_dbg(&pdev->dev, "got pwm for backlight\n"); - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = data->max_brightness; - bl = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, pb, - &pwm_backlight_ops, &props); + bl = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, + pb, &pwm_backlight_ops); if (IS_ERR(bl)) { dev_err(&pdev->dev, "failed to register backlight\n"); ret = PTR_ERR(bl); goto err_bl; } + bl->props.max_brightness = data->max_brightness; bl->props.brightness = data->dft_brightness; backlight_update_status(bl); diff --git a/trunk/drivers/video/backlight/tosa_bl.c b/trunk/drivers/video/backlight/tosa_bl.c index f57bbf170049..e14ce4d469f5 100644 --- a/trunk/drivers/video/backlight/tosa_bl.c +++ b/trunk/drivers/video/backlight/tosa_bl.c @@ -80,7 +80,6 @@ static const struct backlight_ops bl_ops = { static int __devinit tosa_bl_probe(struct i2c_client *client, const struct i2c_device_id *id) { - struct backlight_properties props; struct tosa_bl_data *data = kzalloc(sizeof(struct tosa_bl_data), GFP_KERNEL); int ret = 0; if (!data) @@ -100,16 +99,15 @@ static int __devinit tosa_bl_probe(struct i2c_client *client, i2c_set_clientdata(client, data); data->i2c = client; - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = 512 - 1; - data->bl = backlight_device_register("tosa-bl", &client->dev, data, - &bl_ops, &props); + data->bl = backlight_device_register("tosa-bl", &client->dev, + data, &bl_ops); if (IS_ERR(data->bl)) { ret = PTR_ERR(data->bl); goto err_reg; } data->bl->props.brightness = 69; + data->bl->props.max_brightness = 512 - 1; data->bl->props.power = FB_BLANK_UNBLANK; backlight_update_status(data->bl); diff --git a/trunk/drivers/video/backlight/wm831x_bl.c b/trunk/drivers/video/backlight/wm831x_bl.c index a4312709fb1b..e32add37a203 100644 --- a/trunk/drivers/video/backlight/wm831x_bl.c +++ b/trunk/drivers/video/backlight/wm831x_bl.c @@ -125,7 +125,6 @@ static int wm831x_backlight_probe(struct platform_device *pdev) struct wm831x_backlight_pdata *pdata; struct wm831x_backlight_data *data; struct backlight_device *bl; - struct backlight_properties props; int ret, i, max_isel, isink_reg, dcdc_cfg; /* We need platform data */ @@ -192,15 +191,15 @@ static int wm831x_backlight_probe(struct platform_device *pdev) data->current_brightness = 0; data->isink_reg = isink_reg; - props.max_brightness = max_isel; - bl = backlight_device_register("wm831x", &pdev->dev, data, - &wm831x_backlight_ops, &props); + bl = backlight_device_register("wm831x", &pdev->dev, + data, &wm831x_backlight_ops); if (IS_ERR(bl)) { dev_err(&pdev->dev, "failed to register backlight\n"); kfree(data); return PTR_ERR(bl); } + bl->props.max_brightness = max_isel; bl->props.brightness = max_isel; platform_set_drvdata(pdev, bl); diff --git a/trunk/drivers/video/bf54x-lq043fb.c b/trunk/drivers/video/bf54x-lq043fb.c index 23b2a8c0dbfc..814312a7452f 100644 --- a/trunk/drivers/video/bf54x-lq043fb.c +++ b/trunk/drivers/video/bf54x-lq043fb.c @@ -433,7 +433,7 @@ static int bl_get_brightness(struct backlight_device *bd) return 0; } -static const struct backlight_ops bfin_lq043fb_bl_ops = { +static struct backlight_ops bfin_lq043fb_bl_ops = { .get_brightness = bl_get_brightness, }; @@ -501,7 +501,6 @@ static irqreturn_t bfin_bf54x_irq_error(int irq, void *dev_id) static int __devinit bfin_bf54x_probe(struct platform_device *pdev) { - struct backlight_properties props; struct bfin_bf54xfb_info *info; struct fb_info *fbinfo; int ret; @@ -646,16 +645,10 @@ static int __devinit bfin_bf54x_probe(struct platform_device *pdev) goto out8; } #ifndef NO_BL_SUPPORT - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = 255; - bl_dev = backlight_device_register("bf54x-bl", NULL, NULL, - &bfin_lq043fb_bl_ops, &props); - if (IS_ERR(bl_dev)) { - printk(KERN_ERR DRIVER_NAME - ": unable to register backlight.\n"); - ret = -EINVAL; - goto out9; - } + bl_dev = + backlight_device_register("bf54x-bl", NULL, NULL, + &bfin_lq043fb_bl_ops); + bl_dev->props.max_brightness = 255; lcd_dev = lcd_device_register(DRIVER_NAME, &pdev->dev, NULL, &bfin_lcd_ops); lcd_dev->props.max_contrast = 255, printk(KERN_INFO "Done.\n"); @@ -663,8 +656,6 @@ static int __devinit bfin_bf54x_probe(struct platform_device *pdev) return 0; -out9: - unregister_framebuffer(fbinfo); out8: free_irq(info->irq, info); out7: diff --git a/trunk/drivers/video/bfin-t350mcqb-fb.c b/trunk/drivers/video/bfin-t350mcqb-fb.c index 31a2dec927bb..5653d083a983 100644 --- a/trunk/drivers/video/bfin-t350mcqb-fb.c +++ b/trunk/drivers/video/bfin-t350mcqb-fb.c @@ -352,7 +352,7 @@ static int bl_get_brightness(struct backlight_device *bd) return 0; } -static const struct backlight_ops bfin_lq043fb_bl_ops = { +static struct backlight_ops bfin_lq043fb_bl_ops = { .get_brightness = bl_get_brightness, }; @@ -419,7 +419,6 @@ static irqreturn_t bfin_t350mcqb_irq_error(int irq, void *dev_id) static int __devinit bfin_t350mcqb_probe(struct platform_device *pdev) { - struct backlight_properties props; struct bfin_t350mcqbfb_info *info; struct fb_info *fbinfo; int ret; @@ -541,16 +540,10 @@ static int __devinit bfin_t350mcqb_probe(struct platform_device *pdev) goto out8; } #ifndef NO_BL_SUPPORT - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = 255; - bl_dev = backlight_device_register("bf52x-bl", NULL, NULL, - &bfin_lq043fb_bl_ops, &props); - if (IS_ERR(bl_dev)) { - printk(KERN_ERR DRIVER_NAME - ": unable to register backlight.\n"); - ret = -EINVAL; - goto out9; - } + bl_dev = + backlight_device_register("bf52x-bl", NULL, NULL, + &bfin_lq043fb_bl_ops); + bl_dev->props.max_brightness = 255; lcd_dev = lcd_device_register(DRIVER_NAME, NULL, &bfin_lcd_ops); lcd_dev->props.max_contrast = 255, printk(KERN_INFO "Done.\n"); @@ -558,8 +551,6 @@ static int __devinit bfin_t350mcqb_probe(struct platform_device *pdev) return 0; -out9: - unregister_framebuffer(fbinfo); out8: free_irq(info->irq, info); out7: diff --git a/trunk/drivers/video/nvidia/nv_backlight.c b/trunk/drivers/video/nvidia/nv_backlight.c index 2fb552a6f32c..443e3c85a9a0 100644 --- a/trunk/drivers/video/nvidia/nv_backlight.c +++ b/trunk/drivers/video/nvidia/nv_backlight.c @@ -94,7 +94,6 @@ static struct backlight_ops nvidia_bl_ops = { void nvidia_bl_init(struct nvidia_par *par) { - struct backlight_properties props; struct fb_info *info = pci_get_drvdata(par->pci_dev); struct backlight_device *bd; char name[12]; @@ -110,10 +109,7 @@ void nvidia_bl_init(struct nvidia_par *par) snprintf(name, sizeof(name), "nvidiabl%d", info->node); - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = FB_BACKLIGHT_LEVELS - 1; - bd = backlight_device_register(name, info->dev, par, &nvidia_bl_ops, - &props); + bd = backlight_device_register(name, info->dev, par, &nvidia_bl_ops); if (IS_ERR(bd)) { info->bl_dev = NULL; printk(KERN_WARNING "nvidia: Backlight registration failed\n"); @@ -125,6 +121,7 @@ void nvidia_bl_init(struct nvidia_par *par) 0x158 * FB_BACKLIGHT_MAX / MAX_LEVEL, 0x534 * FB_BACKLIGHT_MAX / MAX_LEVEL); + bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1; bd->props.brightness = bd->props.max_brightness; bd->props.power = FB_BLANK_UNBLANK; backlight_update_status(bd); diff --git a/trunk/drivers/video/omap2/displays/panel-taal.c b/trunk/drivers/video/omap2/displays/panel-taal.c index 59769e85d41c..fcd6a61a91eb 100644 --- a/trunk/drivers/video/omap2/displays/panel-taal.c +++ b/trunk/drivers/video/omap2/displays/panel-taal.c @@ -486,7 +486,6 @@ static struct attribute_group taal_attr_group = { static int taal_probe(struct omap_dss_device *dssdev) { - struct backlight_properties props; struct taal_data *td; struct backlight_device *bldev; int r; @@ -521,16 +520,11 @@ static int taal_probe(struct omap_dss_device *dssdev) /* if no platform set_backlight() defined, presume DSI backlight * control */ - memset(&props, 0, sizeof(struct backlight_properties)); if (!dssdev->set_backlight) td->use_dsi_bl = true; - if (td->use_dsi_bl) - props.max_brightness = 255; - else - props.max_brightness = 127; bldev = backlight_device_register("taal", &dssdev->dev, dssdev, - &taal_bl_ops, &props); + &taal_bl_ops); if (IS_ERR(bldev)) { r = PTR_ERR(bldev); goto err2; @@ -540,10 +534,13 @@ static int taal_probe(struct omap_dss_device *dssdev) bldev->props.fb_blank = FB_BLANK_UNBLANK; bldev->props.power = FB_BLANK_UNBLANK; - if (td->use_dsi_bl) + if (td->use_dsi_bl) { + bldev->props.max_brightness = 255; bldev->props.brightness = 255; - else + } else { + bldev->props.max_brightness = 127; bldev->props.brightness = 127; + } taal_bl_update_status(bldev); diff --git a/trunk/drivers/video/riva/fbdev.c b/trunk/drivers/video/riva/fbdev.c index 618f36bec10d..d94c57ffbdb1 100644 --- a/trunk/drivers/video/riva/fbdev.c +++ b/trunk/drivers/video/riva/fbdev.c @@ -338,7 +338,6 @@ static struct backlight_ops riva_bl_ops = { static void riva_bl_init(struct riva_par *par) { - struct backlight_properties props; struct fb_info *info = pci_get_drvdata(par->pdev); struct backlight_device *bd; char name[12]; @@ -354,10 +353,7 @@ static void riva_bl_init(struct riva_par *par) snprintf(name, sizeof(name), "rivabl%d", info->node); - memset(&props, 0, sizeof(struct backlight_properties)); - props.max_brightness = FB_BACKLIGHT_LEVELS - 1; - bd = backlight_device_register(name, info->dev, par, &riva_bl_ops, - &props); + bd = backlight_device_register(name, info->dev, par, &riva_bl_ops); if (IS_ERR(bd)) { info->bl_dev = NULL; printk(KERN_WARNING "riva: Backlight registration failed\n"); @@ -369,6 +365,7 @@ static void riva_bl_init(struct riva_par *par) MIN_LEVEL * FB_BACKLIGHT_MAX / MAX_LEVEL, FB_BACKLIGHT_MAX); + bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1; bd->props.brightness = bd->props.max_brightness; bd->props.power = FB_BLANK_UNBLANK; backlight_update_status(bd); diff --git a/trunk/fs/btrfs/btrfs_inode.h b/trunk/fs/btrfs/btrfs_inode.h index 7a4dee199832..3f1f50d9d916 100644 --- a/trunk/fs/btrfs/btrfs_inode.h +++ b/trunk/fs/btrfs/btrfs_inode.h @@ -153,11 +153,6 @@ struct btrfs_inode { unsigned ordered_data_close:1; unsigned dummy_inode:1; - /* - * always compress this one file - */ - unsigned force_compress:1; - struct inode vfs_inode; }; diff --git a/trunk/fs/btrfs/compression.c b/trunk/fs/btrfs/compression.c index 28b92a7218ab..a11a32058b50 100644 --- a/trunk/fs/btrfs/compression.c +++ b/trunk/fs/btrfs/compression.c @@ -478,7 +478,7 @@ static noinline int add_ra_bio_pages(struct inode *inode, goto next; } - page = alloc_page(mapping_gfp_mask(mapping) & ~__GFP_FS); + page = alloc_page(mapping_gfp_mask(mapping) | GFP_NOFS); if (!page) break; diff --git a/trunk/fs/btrfs/ctree.h b/trunk/fs/btrfs/ctree.h index 0af2e3868573..8b5cfdd4bfc1 100644 --- a/trunk/fs/btrfs/ctree.h +++ b/trunk/fs/btrfs/ctree.h @@ -373,13 +373,11 @@ struct btrfs_super_block { * ones specified below then we will fail to mount */ #define BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF (1ULL << 0) -#define BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL (2ULL << 0) #define BTRFS_FEATURE_COMPAT_SUPP 0ULL #define BTRFS_FEATURE_COMPAT_RO_SUPP 0ULL #define BTRFS_FEATURE_INCOMPAT_SUPP \ - (BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF | \ - BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL) + BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF /* * A leaf is full of items. offset and size tell us where to find @@ -1184,6 +1182,7 @@ struct btrfs_root { #define BTRFS_INODE_NOATIME (1 << 9) #define BTRFS_INODE_DIRSYNC (1 << 10) + /* some macros to generate set/get funcs for the struct fields. This * assumes there is a lefoo_to_cpu for every type, so lets make a simple * one for u8: @@ -1843,7 +1842,7 @@ BTRFS_SETGET_STACK_FUNCS(super_num_devices, struct btrfs_super_block, BTRFS_SETGET_STACK_FUNCS(super_compat_flags, struct btrfs_super_block, compat_flags, 64); BTRFS_SETGET_STACK_FUNCS(super_compat_ro_flags, struct btrfs_super_block, - compat_ro_flags, 64); + compat_flags, 64); BTRFS_SETGET_STACK_FUNCS(super_incompat_flags, struct btrfs_super_block, incompat_flags, 64); BTRFS_SETGET_STACK_FUNCS(super_csum_type, struct btrfs_super_block, @@ -2311,8 +2310,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, u32 min_type); int btrfs_start_delalloc_inodes(struct btrfs_root *root, int delay_iput); -int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end, - struct extent_state **cached_state); +int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end); int btrfs_writepages(struct address_space *mapping, struct writeback_control *wbc); int btrfs_create_subvol_root(struct btrfs_trans_handle *trans, @@ -2337,7 +2335,7 @@ int btrfs_init_cachep(void); void btrfs_destroy_cachep(void); long btrfs_ioctl_trans_end(struct file *file); struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location, - struct btrfs_root *root, int *was_new); + struct btrfs_root *root); int btrfs_commit_write(struct file *file, struct page *page, unsigned from, unsigned to); struct extent_map *btrfs_get_extent(struct inode *inode, struct page *page, @@ -2388,6 +2386,7 @@ void btrfs_sysfs_del_super(struct btrfs_fs_info *root); ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size); /* super.c */ +u64 btrfs_parse_size(char *str); int btrfs_parse_options(struct btrfs_root *root, char *options); int btrfs_sync_fs(struct super_block *sb, int wait); diff --git a/trunk/fs/btrfs/disk-io.c b/trunk/fs/btrfs/disk-io.c index 11d0ad30e203..0427183e3e05 100644 --- a/trunk/fs/btrfs/disk-io.c +++ b/trunk/fs/btrfs/disk-io.c @@ -263,15 +263,13 @@ static int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf, static int verify_parent_transid(struct extent_io_tree *io_tree, struct extent_buffer *eb, u64 parent_transid) { - struct extent_state *cached_state = NULL; int ret; if (!parent_transid || btrfs_header_generation(eb) == parent_transid) return 0; - lock_extent_bits(io_tree, eb->start, eb->start + eb->len - 1, - 0, &cached_state, GFP_NOFS); - if (extent_buffer_uptodate(io_tree, eb, cached_state) && + lock_extent(io_tree, eb->start, eb->start + eb->len - 1, GFP_NOFS); + if (extent_buffer_uptodate(io_tree, eb) && btrfs_header_generation(eb) == parent_transid) { ret = 0; goto out; @@ -284,10 +282,10 @@ static int verify_parent_transid(struct extent_io_tree *io_tree, (unsigned long long)btrfs_header_generation(eb)); } ret = 1; - clear_extent_buffer_uptodate(io_tree, eb, &cached_state); + clear_extent_buffer_uptodate(io_tree, eb); out: - unlock_extent_cached(io_tree, eb->start, eb->start + eb->len - 1, - &cached_state, GFP_NOFS); + unlock_extent(io_tree, eb->start, eb->start + eb->len - 1, + GFP_NOFS); return ret; } @@ -2499,8 +2497,7 @@ int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid) int ret; struct inode *btree_inode = buf->first_page->mapping->host; - ret = extent_buffer_uptodate(&BTRFS_I(btree_inode)->io_tree, buf, - NULL); + ret = extent_buffer_uptodate(&BTRFS_I(btree_inode)->io_tree, buf); if (!ret) return ret; diff --git a/trunk/fs/btrfs/export.c b/trunk/fs/btrfs/export.c index 951ef09b82f4..ba5c3fd5ab8c 100644 --- a/trunk/fs/btrfs/export.c +++ b/trunk/fs/btrfs/export.c @@ -95,7 +95,7 @@ static struct dentry *btrfs_get_dentry(struct super_block *sb, u64 objectid, btrfs_set_key_type(&key, BTRFS_INODE_ITEM_KEY); key.offset = 0; - inode = btrfs_iget(sb, &key, root, NULL); + inode = btrfs_iget(sb, &key, root); if (IS_ERR(inode)) { err = PTR_ERR(inode); goto fail; @@ -223,7 +223,7 @@ static struct dentry *btrfs_get_parent(struct dentry *child) key.type = BTRFS_INODE_ITEM_KEY; key.offset = 0; - dentry = d_obtain_alias(btrfs_iget(root->fs_info->sb, &key, root, NULL)); + dentry = d_obtain_alias(btrfs_iget(root->fs_info->sb, &key, root)); if (!IS_ERR(dentry)) dentry->d_op = &btrfs_dentry_operations; return dentry; diff --git a/trunk/fs/btrfs/extent-tree.c b/trunk/fs/btrfs/extent-tree.c index 1727b26fb194..559f72489b3b 100644 --- a/trunk/fs/btrfs/extent-tree.c +++ b/trunk/fs/btrfs/extent-tree.c @@ -6561,7 +6561,6 @@ static noinline int invalidate_extent_cache(struct btrfs_root *root, struct btrfs_key key; struct inode *inode = NULL; struct btrfs_file_extent_item *fi; - struct extent_state *cached_state = NULL; u64 num_bytes; u64 skip_objectid = 0; u32 nritems; @@ -6590,14 +6589,12 @@ static noinline int invalidate_extent_cache(struct btrfs_root *root, } num_bytes = btrfs_file_extent_num_bytes(leaf, fi); - lock_extent_bits(&BTRFS_I(inode)->io_tree, key.offset, - key.offset + num_bytes - 1, 0, &cached_state, - GFP_NOFS); + lock_extent(&BTRFS_I(inode)->io_tree, key.offset, + key.offset + num_bytes - 1, GFP_NOFS); btrfs_drop_extent_cache(inode, key.offset, key.offset + num_bytes - 1, 1); - unlock_extent_cached(&BTRFS_I(inode)->io_tree, key.offset, - key.offset + num_bytes - 1, &cached_state, - GFP_NOFS); + unlock_extent(&BTRFS_I(inode)->io_tree, key.offset, + key.offset + num_bytes - 1, GFP_NOFS); cond_resched(); } iput(inode); diff --git a/trunk/fs/btrfs/extent_io.c b/trunk/fs/btrfs/extent_io.c index c99121ac5d6b..7073cbb1b2d4 100644 --- a/trunk/fs/btrfs/extent_io.c +++ b/trunk/fs/btrfs/extent_io.c @@ -513,10 +513,7 @@ int clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, u64 last_end; int err; int set = 0; - int clear = 0; - if (bits & (EXTENT_IOBITS | EXTENT_BOUNDARY)) - clear = 1; again: if (!prealloc && (mask & __GFP_WAIT)) { prealloc = alloc_extent_state(mask); @@ -527,20 +524,14 @@ int clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, spin_lock(&tree->lock); if (cached_state) { cached = *cached_state; - - if (clear) { - *cached_state = NULL; - cached_state = NULL; - } - + *cached_state = NULL; + cached_state = NULL; if (cached && cached->tree && cached->start == start) { - if (clear) - atomic_dec(&cached->refs); + atomic_dec(&cached->refs); state = cached; goto hit_next; } - if (clear) - free_extent_state(cached); + free_extent_state(cached); } /* * this search will find the extents that end after @@ -955,11 +946,11 @@ int clear_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, } int set_extent_delalloc(struct extent_io_tree *tree, u64 start, u64 end, - struct extent_state **cached_state, gfp_t mask) + gfp_t mask) { return set_extent_bit(tree, start, end, EXTENT_DELALLOC | EXTENT_DIRTY | EXTENT_UPTODATE, - 0, NULL, cached_state, mask); + 0, NULL, NULL, mask); } int clear_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end, @@ -993,11 +984,10 @@ int set_extent_uptodate(struct extent_io_tree *tree, u64 start, u64 end, } static int clear_extent_uptodate(struct extent_io_tree *tree, u64 start, - u64 end, struct extent_state **cached_state, - gfp_t mask) + u64 end, gfp_t mask) { return clear_extent_bit(tree, start, end, EXTENT_UPTODATE, 0, 0, - cached_state, mask); + NULL, mask); } int wait_on_extent_writeback(struct extent_io_tree *tree, u64 start, u64 end) @@ -1181,8 +1171,7 @@ struct extent_state *find_first_extent_bit_state(struct extent_io_tree *tree, * 1 is returned if we find something, 0 if nothing was in the tree */ static noinline u64 find_delalloc_range(struct extent_io_tree *tree, - u64 *start, u64 *end, u64 max_bytes, - struct extent_state **cached_state) + u64 *start, u64 *end, u64 max_bytes) { struct rb_node *node; struct extent_state *state; @@ -1214,11 +1203,8 @@ static noinline u64 find_delalloc_range(struct extent_io_tree *tree, *end = state->end; goto out; } - if (!found) { + if (!found) *start = state->start; - *cached_state = state; - atomic_inc(&state->refs); - } found++; *end = state->end; cur_start = state->end + 1; @@ -1350,11 +1336,10 @@ static noinline u64 find_lock_delalloc_range(struct inode *inode, delalloc_start = *start; delalloc_end = 0; found = find_delalloc_range(tree, &delalloc_start, &delalloc_end, - max_bytes, &cached_state); + max_bytes); if (!found || delalloc_end <= *start) { *start = delalloc_start; *end = delalloc_end; - free_extent_state(cached_state); return found; } @@ -1737,7 +1722,7 @@ static void end_bio_extent_writepage(struct bio *bio, int err) } if (!uptodate) { - clear_extent_uptodate(tree, start, end, NULL, GFP_NOFS); + clear_extent_uptodate(tree, start, end, GFP_NOFS); ClearPageUptodate(page); SetPageError(page); } @@ -1765,8 +1750,7 @@ static void end_bio_extent_writepage(struct bio *bio, int err) static void end_bio_extent_readpage(struct bio *bio, int err) { int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); - struct bio_vec *bvec_end = bio->bi_io_vec + bio->bi_vcnt - 1; - struct bio_vec *bvec = bio->bi_io_vec; + struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1; struct extent_io_tree *tree; u64 start; u64 end; @@ -1789,7 +1773,7 @@ static void end_bio_extent_readpage(struct bio *bio, int err) else whole_page = 0; - if (++bvec <= bvec_end) + if (--bvec >= bio->bi_io_vec) prefetchw(&bvec->bv_page->flags); if (uptodate && tree->ops && tree->ops->readpage_end_io_hook) { @@ -1834,7 +1818,7 @@ static void end_bio_extent_readpage(struct bio *bio, int err) } check_page_locked(tree, page); } - } while (bvec <= bvec_end); + } while (bvec >= bio->bi_io_vec); bio_put(bio); } @@ -2720,7 +2704,6 @@ int extent_readpages(struct extent_io_tree *tree, int extent_invalidatepage(struct extent_io_tree *tree, struct page *page, unsigned long offset) { - struct extent_state *cached_state = NULL; u64 start = ((u64)page->index << PAGE_CACHE_SHIFT); u64 end = start + PAGE_CACHE_SIZE - 1; size_t blocksize = page->mapping->host->i_sb->s_blocksize; @@ -2729,12 +2712,12 @@ int extent_invalidatepage(struct extent_io_tree *tree, if (start > end) return 0; - lock_extent_bits(tree, start, end, 0, &cached_state, GFP_NOFS); + lock_extent(tree, start, end, GFP_NOFS); wait_on_page_writeback(page); clear_extent_bit(tree, start, end, EXTENT_LOCKED | EXTENT_DIRTY | EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING, - 1, 1, &cached_state, GFP_NOFS); + 1, 1, NULL, GFP_NOFS); return 0; } @@ -2937,17 +2920,16 @@ sector_t extent_bmap(struct address_space *mapping, sector_t iblock, get_extent_t *get_extent) { struct inode *inode = mapping->host; - struct extent_state *cached_state = NULL; u64 start = iblock << inode->i_blkbits; sector_t sector = 0; size_t blksize = (1 << inode->i_blkbits); struct extent_map *em; - lock_extent_bits(&BTRFS_I(inode)->io_tree, start, start + blksize - 1, - 0, &cached_state, GFP_NOFS); + lock_extent(&BTRFS_I(inode)->io_tree, start, start + blksize - 1, + GFP_NOFS); em = get_extent(inode, NULL, 0, start, blksize, 0); - unlock_extent_cached(&BTRFS_I(inode)->io_tree, start, - start + blksize - 1, &cached_state, GFP_NOFS); + unlock_extent(&BTRFS_I(inode)->io_tree, start, start + blksize - 1, + GFP_NOFS); if (!em || IS_ERR(em)) return 0; @@ -2969,7 +2951,6 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, u32 flags = 0; u64 disko = 0; struct extent_map *em = NULL; - struct extent_state *cached_state = NULL; int end = 0; u64 em_start = 0, em_len = 0; unsigned long emflags; @@ -2978,8 +2959,8 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, if (len == 0) return -EINVAL; - lock_extent_bits(&BTRFS_I(inode)->io_tree, start, start + len, 0, - &cached_state, GFP_NOFS); + lock_extent(&BTRFS_I(inode)->io_tree, start, start + len, + GFP_NOFS); em = get_extent(inode, NULL, 0, off, max - off, 0); if (!em) goto out; @@ -3042,8 +3023,8 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, out_free: free_extent_map(em); out: - unlock_extent_cached(&BTRFS_I(inode)->io_tree, start, start + len, - &cached_state, GFP_NOFS); + unlock_extent(&BTRFS_I(inode)->io_tree, start, start + len, + GFP_NOFS); return ret; } @@ -3283,8 +3264,7 @@ int set_extent_buffer_dirty(struct extent_io_tree *tree, } int clear_extent_buffer_uptodate(struct extent_io_tree *tree, - struct extent_buffer *eb, - struct extent_state **cached_state) + struct extent_buffer *eb) { unsigned long i; struct page *page; @@ -3294,7 +3274,7 @@ int clear_extent_buffer_uptodate(struct extent_io_tree *tree, clear_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags); clear_extent_uptodate(tree, eb->start, eb->start + eb->len - 1, - cached_state, GFP_NOFS); + GFP_NOFS); for (i = 0; i < num_pages; i++) { page = extent_buffer_page(eb, i); if (page) @@ -3354,8 +3334,7 @@ int extent_range_uptodate(struct extent_io_tree *tree, } int extent_buffer_uptodate(struct extent_io_tree *tree, - struct extent_buffer *eb, - struct extent_state *cached_state) + struct extent_buffer *eb) { int ret = 0; unsigned long num_pages; @@ -3367,7 +3346,7 @@ int extent_buffer_uptodate(struct extent_io_tree *tree, return 1; ret = test_range_bit(tree, eb->start, eb->start + eb->len - 1, - EXTENT_UPTODATE, 1, cached_state); + EXTENT_UPTODATE, 1, NULL); if (ret) return ret; diff --git a/trunk/fs/btrfs/extent_io.h b/trunk/fs/btrfs/extent_io.h index bbab4813646f..36de250a7b2b 100644 --- a/trunk/fs/btrfs/extent_io.h +++ b/trunk/fs/btrfs/extent_io.h @@ -163,8 +163,6 @@ int lock_extent(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask); int lock_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, int bits, struct extent_state **cached, gfp_t mask); int unlock_extent(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask); -int unlock_extent_cached(struct extent_io_tree *tree, u64 start, u64 end, - struct extent_state **cached, gfp_t mask); int try_lock_extent(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask); int extent_read_full_page(struct extent_io_tree *tree, struct page *page, @@ -198,7 +196,7 @@ int clear_extent_ordered(struct extent_io_tree *tree, u64 start, u64 end, int clear_extent_ordered_metadata(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask); int set_extent_delalloc(struct extent_io_tree *tree, u64 start, u64 end, - struct extent_state **cached_state, gfp_t mask); + gfp_t mask); int set_extent_ordered(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask); int find_first_extent_bit(struct extent_io_tree *tree, u64 start, @@ -283,11 +281,9 @@ int test_extent_buffer_dirty(struct extent_io_tree *tree, int set_extent_buffer_uptodate(struct extent_io_tree *tree, struct extent_buffer *eb); int clear_extent_buffer_uptodate(struct extent_io_tree *tree, - struct extent_buffer *eb, - struct extent_state **cached_state); + struct extent_buffer *eb); int extent_buffer_uptodate(struct extent_io_tree *tree, - struct extent_buffer *eb, - struct extent_state *cached_state); + struct extent_buffer *eb); int map_extent_buffer(struct extent_buffer *eb, unsigned long offset, unsigned long min_len, char **token, char **map, unsigned long *map_start, diff --git a/trunk/fs/btrfs/file.c b/trunk/fs/btrfs/file.c index ee3323c7fc1c..6ed434ac037f 100644 --- a/trunk/fs/btrfs/file.c +++ b/trunk/fs/btrfs/file.c @@ -123,8 +123,7 @@ static noinline int dirty_and_release_pages(struct btrfs_trans_handle *trans, root->sectorsize - 1) & ~((u64)root->sectorsize - 1); end_of_last_block = start_pos + num_bytes - 1; - err = btrfs_set_extent_delalloc(inode, start_pos, end_of_last_block, - NULL); + err = btrfs_set_extent_delalloc(inode, start_pos, end_of_last_block); if (err) return err; @@ -754,7 +753,6 @@ static noinline int prepare_pages(struct btrfs_root *root, struct file *file, loff_t pos, unsigned long first_index, unsigned long last_index, size_t write_bytes) { - struct extent_state *cached_state = NULL; int i; unsigned long index = pos >> PAGE_CACHE_SHIFT; struct inode *inode = fdentry(file)->d_inode; @@ -783,18 +781,16 @@ static noinline int prepare_pages(struct btrfs_root *root, struct file *file, } if (start_pos < inode->i_size) { struct btrfs_ordered_extent *ordered; - lock_extent_bits(&BTRFS_I(inode)->io_tree, - start_pos, last_pos - 1, 0, &cached_state, - GFP_NOFS); + lock_extent(&BTRFS_I(inode)->io_tree, + start_pos, last_pos - 1, GFP_NOFS); ordered = btrfs_lookup_first_ordered_extent(inode, last_pos - 1); if (ordered && ordered->file_offset + ordered->len > start_pos && ordered->file_offset < last_pos) { btrfs_put_ordered_extent(ordered); - unlock_extent_cached(&BTRFS_I(inode)->io_tree, - start_pos, last_pos - 1, - &cached_state, GFP_NOFS); + unlock_extent(&BTRFS_I(inode)->io_tree, + start_pos, last_pos - 1, GFP_NOFS); for (i = 0; i < num_pages; i++) { unlock_page(pages[i]); page_cache_release(pages[i]); @@ -806,13 +802,12 @@ static noinline int prepare_pages(struct btrfs_root *root, struct file *file, if (ordered) btrfs_put_ordered_extent(ordered); - clear_extent_bit(&BTRFS_I(inode)->io_tree, start_pos, + clear_extent_bits(&BTRFS_I(inode)->io_tree, start_pos, last_pos - 1, EXTENT_DIRTY | EXTENT_DELALLOC | - EXTENT_DO_ACCOUNTING, 0, 0, &cached_state, + EXTENT_DO_ACCOUNTING, GFP_NOFS); - unlock_extent_cached(&BTRFS_I(inode)->io_tree, - start_pos, last_pos - 1, &cached_state, - GFP_NOFS); + unlock_extent(&BTRFS_I(inode)->io_tree, + start_pos, last_pos - 1, GFP_NOFS); } for (i = 0; i < num_pages; i++) { clear_page_dirty_for_io(pages[i]); diff --git a/trunk/fs/btrfs/inode.c b/trunk/fs/btrfs/inode.c index 02bb099845fd..c41db6d45ab6 100644 --- a/trunk/fs/btrfs/inode.c +++ b/trunk/fs/btrfs/inode.c @@ -379,8 +379,7 @@ static noinline int compress_file_range(struct inode *inode, * change at any time if we discover bad compression ratios. */ if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NOCOMPRESS) && - (btrfs_test_opt(root, COMPRESS) || - (BTRFS_I(inode)->force_compress))) { + btrfs_test_opt(root, COMPRESS)) { WARN_ON(pages); pages = kzalloc(sizeof(struct page *) * nr_pages, GFP_NOFS); @@ -484,10 +483,8 @@ static noinline int compress_file_range(struct inode *inode, nr_pages_ret = 0; /* flag the file so we don't compress in the future */ - if (!btrfs_test_opt(root, FORCE_COMPRESS) && - !(BTRFS_I(inode)->force_compress)) { + if (!btrfs_test_opt(root, FORCE_COMPRESS)) BTRFS_I(inode)->flags |= BTRFS_INODE_NOCOMPRESS; - } } if (will_compress) { *num_added += 1; @@ -573,8 +570,8 @@ static noinline int submit_compressed_extents(struct inode *inode, unsigned long nr_written = 0; lock_extent(io_tree, async_extent->start, - async_extent->start + - async_extent->ram_size - 1, GFP_NOFS); + async_extent->start + + async_extent->ram_size - 1, GFP_NOFS); /* allocate blocks */ ret = cow_file_range(inode, async_cow->locked_page, @@ -1214,8 +1211,7 @@ static int run_delalloc_range(struct inode *inode, struct page *locked_page, else if (BTRFS_I(inode)->flags & BTRFS_INODE_PREALLOC) ret = run_delalloc_nocow(inode, locked_page, start, end, page_started, 0, nr_written); - else if (!btrfs_test_opt(root, COMPRESS) && - !(BTRFS_I(inode)->force_compress)) + else if (!btrfs_test_opt(root, COMPRESS)) ret = cow_file_range(inode, locked_page, start, end, page_started, nr_written, 1); else @@ -1512,13 +1508,12 @@ static noinline int add_pending_csums(struct btrfs_trans_handle *trans, return 0; } -int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end, - struct extent_state **cached_state) +int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end) { if ((end & (PAGE_CACHE_SIZE - 1)) == 0) WARN_ON(1); return set_extent_delalloc(&BTRFS_I(inode)->io_tree, start, end, - cached_state, GFP_NOFS); + GFP_NOFS); } /* see btrfs_writepage_start_hook for details on why this is required */ @@ -1531,7 +1526,6 @@ static void btrfs_writepage_fixup_worker(struct btrfs_work *work) { struct btrfs_writepage_fixup *fixup; struct btrfs_ordered_extent *ordered; - struct extent_state *cached_state = NULL; struct page *page; struct inode *inode; u64 page_start; @@ -1550,8 +1544,7 @@ static void btrfs_writepage_fixup_worker(struct btrfs_work *work) page_start = page_offset(page); page_end = page_offset(page) + PAGE_CACHE_SIZE - 1; - lock_extent_bits(&BTRFS_I(inode)->io_tree, page_start, page_end, 0, - &cached_state, GFP_NOFS); + lock_extent(&BTRFS_I(inode)->io_tree, page_start, page_end, GFP_NOFS); /* already ordered? We're done */ if (PagePrivate2(page)) @@ -1559,18 +1552,17 @@ static void btrfs_writepage_fixup_worker(struct btrfs_work *work) ordered = btrfs_lookup_ordered_extent(inode, page_start); if (ordered) { - unlock_extent_cached(&BTRFS_I(inode)->io_tree, page_start, - page_end, &cached_state, GFP_NOFS); + unlock_extent(&BTRFS_I(inode)->io_tree, page_start, + page_end, GFP_NOFS); unlock_page(page); btrfs_start_ordered_extent(inode, ordered, 1); goto again; } - btrfs_set_extent_delalloc(inode, page_start, page_end, &cached_state); + btrfs_set_extent_delalloc(inode, page_start, page_end); ClearPageChecked(page); out: - unlock_extent_cached(&BTRFS_I(inode)->io_tree, page_start, page_end, - &cached_state, GFP_NOFS); + unlock_extent(&BTRFS_I(inode)->io_tree, page_start, page_end, GFP_NOFS); out_page: unlock_page(page); page_cache_release(page); @@ -1699,14 +1691,14 @@ static int btrfs_finish_ordered_io(struct inode *inode, u64 start, u64 end) struct btrfs_trans_handle *trans; struct btrfs_ordered_extent *ordered_extent = NULL; struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree; - struct extent_state *cached_state = NULL; int compressed = 0; int ret; - ret = btrfs_dec_test_ordered_pending(inode, &ordered_extent, start, - end - start + 1); + ret = btrfs_dec_test_ordered_pending(inode, start, end - start + 1); if (!ret) return 0; + + ordered_extent = btrfs_lookup_ordered_extent(inode, start); BUG_ON(!ordered_extent); if (test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags)) { @@ -1721,9 +1713,9 @@ static int btrfs_finish_ordered_io(struct inode *inode, u64 start, u64 end) goto out; } - lock_extent_bits(io_tree, ordered_extent->file_offset, - ordered_extent->file_offset + ordered_extent->len - 1, - 0, &cached_state, GFP_NOFS); + lock_extent(io_tree, ordered_extent->file_offset, + ordered_extent->file_offset + ordered_extent->len - 1, + GFP_NOFS); trans = btrfs_join_transaction(root, 1); @@ -1750,10 +1742,9 @@ static int btrfs_finish_ordered_io(struct inode *inode, u64 start, u64 end) ordered_extent->len); BUG_ON(ret); } - unlock_extent_cached(io_tree, ordered_extent->file_offset, - ordered_extent->file_offset + - ordered_extent->len - 1, &cached_state, GFP_NOFS); - + unlock_extent(io_tree, ordered_extent->file_offset, + ordered_extent->file_offset + ordered_extent->len - 1, + GFP_NOFS); add_pending_csums(trans, inode, ordered_extent->file_offset, &ordered_extent->list); @@ -2162,7 +2153,7 @@ void btrfs_orphan_cleanup(struct btrfs_root *root) found_key.objectid = found_key.offset; found_key.type = BTRFS_INODE_ITEM_KEY; found_key.offset = 0; - inode = btrfs_iget(root->fs_info->sb, &found_key, root, NULL); + inode = btrfs_iget(root->fs_info->sb, &found_key, root); if (IS_ERR(inode)) break; @@ -3090,7 +3081,6 @@ static int btrfs_truncate_page(struct address_space *mapping, loff_t from) struct btrfs_root *root = BTRFS_I(inode)->root; struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree; struct btrfs_ordered_extent *ordered; - struct extent_state *cached_state = NULL; char *kaddr; u32 blocksize = root->sectorsize; pgoff_t index = from >> PAGE_CACHE_SHIFT; @@ -3137,14 +3127,12 @@ static int btrfs_truncate_page(struct address_space *mapping, loff_t from) } wait_on_page_writeback(page); - lock_extent_bits(io_tree, page_start, page_end, 0, &cached_state, - GFP_NOFS); + lock_extent(io_tree, page_start, page_end, GFP_NOFS); set_page_extent_mapped(page); ordered = btrfs_lookup_ordered_extent(inode, page_start); if (ordered) { - unlock_extent_cached(io_tree, page_start, page_end, - &cached_state, GFP_NOFS); + unlock_extent(io_tree, page_start, page_end, GFP_NOFS); unlock_page(page); page_cache_release(page); btrfs_start_ordered_extent(inode, ordered, 1); @@ -3152,15 +3140,13 @@ static int btrfs_truncate_page(struct address_space *mapping, loff_t from) goto again; } - clear_extent_bit(&BTRFS_I(inode)->io_tree, page_start, page_end, + clear_extent_bits(&BTRFS_I(inode)->io_tree, page_start, page_end, EXTENT_DIRTY | EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING, - 0, 0, &cached_state, GFP_NOFS); + GFP_NOFS); - ret = btrfs_set_extent_delalloc(inode, page_start, page_end, - &cached_state); + ret = btrfs_set_extent_delalloc(inode, page_start, page_end); if (ret) { - unlock_extent_cached(io_tree, page_start, page_end, - &cached_state, GFP_NOFS); + unlock_extent(io_tree, page_start, page_end, GFP_NOFS); goto out_unlock; } @@ -3173,8 +3159,7 @@ static int btrfs_truncate_page(struct address_space *mapping, loff_t from) } ClearPageChecked(page); set_page_dirty(page); - unlock_extent_cached(io_tree, page_start, page_end, &cached_state, - GFP_NOFS); + unlock_extent(io_tree, page_start, page_end, GFP_NOFS); out_unlock: if (ret) @@ -3192,7 +3177,6 @@ int btrfs_cont_expand(struct inode *inode, loff_t size) struct btrfs_root *root = BTRFS_I(inode)->root; struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree; struct extent_map *em; - struct extent_state *cached_state = NULL; u64 mask = root->sectorsize - 1; u64 hole_start = (inode->i_size + mask) & ~mask; u64 block_end = (size + mask) & ~mask; @@ -3208,13 +3192,11 @@ int btrfs_cont_expand(struct inode *inode, loff_t size) struct btrfs_ordered_extent *ordered; btrfs_wait_ordered_range(inode, hole_start, block_end - hole_start); - lock_extent_bits(io_tree, hole_start, block_end - 1, 0, - &cached_state, GFP_NOFS); + lock_extent(io_tree, hole_start, block_end - 1, GFP_NOFS); ordered = btrfs_lookup_ordered_extent(inode, hole_start); if (!ordered) break; - unlock_extent_cached(io_tree, hole_start, block_end - 1, - &cached_state, GFP_NOFS); + unlock_extent(io_tree, hole_start, block_end - 1, GFP_NOFS); btrfs_put_ordered_extent(ordered); } @@ -3259,8 +3241,7 @@ int btrfs_cont_expand(struct inode *inode, loff_t size) break; } - unlock_extent_cached(io_tree, hole_start, block_end - 1, &cached_state, - GFP_NOFS); + unlock_extent(io_tree, hole_start, block_end - 1, GFP_NOFS); return err; } @@ -3658,7 +3639,6 @@ static noinline void init_btrfs_i(struct inode *inode) bi->index_cnt = (u64)-1; bi->last_unlink_trans = 0; bi->ordered_data_close = 0; - bi->force_compress = 0; extent_map_tree_init(&BTRFS_I(inode)->extent_tree, GFP_NOFS); extent_io_tree_init(&BTRFS_I(inode)->io_tree, inode->i_mapping, GFP_NOFS); @@ -3707,7 +3687,7 @@ static struct inode *btrfs_iget_locked(struct super_block *s, * Returns in *is_new if the inode was read from disk */ struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location, - struct btrfs_root *root, int *new) + struct btrfs_root *root) { struct inode *inode; @@ -3722,8 +3702,6 @@ struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location, inode_tree_add(inode); unlock_new_inode(inode); - if (new) - *new = 1; } return inode; @@ -3776,7 +3754,7 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry) return NULL; if (location.type == BTRFS_INODE_ITEM_KEY) { - inode = btrfs_iget(dir->i_sb, &location, root, NULL); + inode = btrfs_iget(dir->i_sb, &location, root); return inode; } @@ -3791,7 +3769,7 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry) else inode = new_simple_dir(dir->i_sb, &location, sub_root); } else { - inode = btrfs_iget(dir->i_sb, &location, sub_root, NULL); + inode = btrfs_iget(dir->i_sb, &location, sub_root); } srcu_read_unlock(&root->fs_info->subvol_srcu, index); @@ -4523,7 +4501,7 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) err = btrfs_find_free_objectid(trans, root, dir->i_ino, &objectid); if (err) { err = -ENOSPC; - goto out_fail; + goto out_unlock; } inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, @@ -5001,7 +4979,6 @@ static void btrfs_invalidatepage(struct page *page, unsigned long offset) { struct extent_io_tree *tree; struct btrfs_ordered_extent *ordered; - struct extent_state *cached_state = NULL; u64 page_start = page_offset(page); u64 page_end = page_start + PAGE_CACHE_SIZE - 1; @@ -5020,8 +4997,7 @@ static void btrfs_invalidatepage(struct page *page, unsigned long offset) btrfs_releasepage(page, GFP_NOFS); return; } - lock_extent_bits(tree, page_start, page_end, 0, &cached_state, - GFP_NOFS); + lock_extent(tree, page_start, page_end, GFP_NOFS); ordered = btrfs_lookup_ordered_extent(page->mapping->host, page_offset(page)); if (ordered) { @@ -5032,7 +5008,7 @@ static void btrfs_invalidatepage(struct page *page, unsigned long offset) clear_extent_bit(tree, page_start, page_end, EXTENT_DIRTY | EXTENT_DELALLOC | EXTENT_LOCKED | EXTENT_DO_ACCOUNTING, 1, 0, - &cached_state, GFP_NOFS); + NULL, GFP_NOFS); /* * whoever cleared the private bit is responsible * for the finish_ordered_io @@ -5042,13 +5018,11 @@ static void btrfs_invalidatepage(struct page *page, unsigned long offset) page_start, page_end); } btrfs_put_ordered_extent(ordered); - cached_state = NULL; - lock_extent_bits(tree, page_start, page_end, 0, &cached_state, - GFP_NOFS); + lock_extent(tree, page_start, page_end, GFP_NOFS); } clear_extent_bit(tree, page_start, page_end, EXTENT_LOCKED | EXTENT_DIRTY | EXTENT_DELALLOC | - EXTENT_DO_ACCOUNTING, 1, 1, &cached_state, GFP_NOFS); + EXTENT_DO_ACCOUNTING, 1, 1, NULL, GFP_NOFS); __btrfs_releasepage(page, GFP_NOFS); ClearPageChecked(page); @@ -5081,7 +5055,6 @@ int btrfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) struct btrfs_root *root = BTRFS_I(inode)->root; struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree; struct btrfs_ordered_extent *ordered; - struct extent_state *cached_state = NULL; char *kaddr; unsigned long zero_start; loff_t size; @@ -5120,8 +5093,7 @@ int btrfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) } wait_on_page_writeback(page); - lock_extent_bits(io_tree, page_start, page_end, 0, &cached_state, - GFP_NOFS); + lock_extent(io_tree, page_start, page_end, GFP_NOFS); set_page_extent_mapped(page); /* @@ -5130,8 +5102,7 @@ int btrfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) */ ordered = btrfs_lookup_ordered_extent(inode, page_start); if (ordered) { - unlock_extent_cached(io_tree, page_start, page_end, - &cached_state, GFP_NOFS); + unlock_extent(io_tree, page_start, page_end, GFP_NOFS); unlock_page(page); btrfs_start_ordered_extent(inode, ordered, 1); btrfs_put_ordered_extent(ordered); @@ -5145,15 +5116,13 @@ int btrfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) * is probably a better way to do this, but for now keep consistent with * prepare_pages in the normal write path. */ - clear_extent_bit(&BTRFS_I(inode)->io_tree, page_start, page_end, + clear_extent_bits(&BTRFS_I(inode)->io_tree, page_start, page_end, EXTENT_DIRTY | EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING, - 0, 0, &cached_state, GFP_NOFS); + GFP_NOFS); - ret = btrfs_set_extent_delalloc(inode, page_start, page_end, - &cached_state); + ret = btrfs_set_extent_delalloc(inode, page_start, page_end); if (ret) { - unlock_extent_cached(io_tree, page_start, page_end, - &cached_state, GFP_NOFS); + unlock_extent(io_tree, page_start, page_end, GFP_NOFS); ret = VM_FAULT_SIGBUS; btrfs_free_reserved_data_space(root, inode, PAGE_CACHE_SIZE); goto out_unlock; @@ -5179,7 +5148,7 @@ int btrfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) BTRFS_I(inode)->last_trans = root->fs_info->generation; BTRFS_I(inode)->last_sub_trans = BTRFS_I(inode)->root->log_transid; - unlock_extent_cached(io_tree, page_start, page_end, &cached_state, GFP_NOFS); + unlock_extent(io_tree, page_start, page_end, GFP_NOFS); out_unlock: btrfs_unreserve_metadata_for_delalloc(root, inode, 1); @@ -5858,7 +5827,6 @@ static int prealloc_file_range(struct inode *inode, u64 start, u64 end, static long btrfs_fallocate(struct inode *inode, int mode, loff_t offset, loff_t len) { - struct extent_state *cached_state = NULL; u64 cur_offset; u64 last_byte; u64 alloc_start; @@ -5897,17 +5865,16 @@ static long btrfs_fallocate(struct inode *inode, int mode, /* the extent lock is ordered inside the running * transaction */ - lock_extent_bits(&BTRFS_I(inode)->io_tree, alloc_start, - locked_end, 0, &cached_state, GFP_NOFS); + lock_extent(&BTRFS_I(inode)->io_tree, alloc_start, locked_end, + GFP_NOFS); ordered = btrfs_lookup_first_ordered_extent(inode, alloc_end - 1); if (ordered && ordered->file_offset + ordered->len > alloc_start && ordered->file_offset < alloc_end) { btrfs_put_ordered_extent(ordered); - unlock_extent_cached(&BTRFS_I(inode)->io_tree, - alloc_start, locked_end, - &cached_state, GFP_NOFS); + unlock_extent(&BTRFS_I(inode)->io_tree, + alloc_start, locked_end, GFP_NOFS); /* * we can't wait on the range with the transaction * running or with the extent lock held @@ -5949,8 +5916,8 @@ static long btrfs_fallocate(struct inode *inode, int mode, break; } } - unlock_extent_cached(&BTRFS_I(inode)->io_tree, alloc_start, locked_end, - &cached_state, GFP_NOFS); + unlock_extent(&BTRFS_I(inode)->io_tree, alloc_start, locked_end, + GFP_NOFS); btrfs_free_reserved_data_space(BTRFS_I(inode)->root, inode, alloc_end - alloc_start); diff --git a/trunk/fs/btrfs/ioctl.c b/trunk/fs/btrfs/ioctl.c index 2845c6ceecd2..645a17927a8f 100644 --- a/trunk/fs/btrfs/ioctl.c +++ b/trunk/fs/btrfs/ioctl.c @@ -48,7 +48,6 @@ #include "print-tree.h" #include "volumes.h" #include "locking.h" -#include "ctree.h" /* Mask out flags that are inappropriate for the given type of inode. */ static inline __u32 btrfs_mask_flags(umode_t mode, __u32 flags) @@ -475,79 +474,7 @@ static noinline int btrfs_mksubvol(struct path *parent, return error; } -static int should_defrag_range(struct inode *inode, u64 start, u64 len, - int thresh, u64 *last_len, u64 *skip, - u64 *defrag_end) -{ - struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree; - struct extent_map *em = NULL; - struct extent_map_tree *em_tree = &BTRFS_I(inode)->extent_tree; - int ret = 1; - - - if (thresh == 0) - thresh = 256 * 1024; - - /* - * make sure that once we start defragging and extent, we keep on - * defragging it - */ - if (start < *defrag_end) - return 1; - - *skip = 0; - - /* - * hopefully we have this extent in the tree already, try without - * the full extent lock - */ - read_lock(&em_tree->lock); - em = lookup_extent_mapping(em_tree, start, len); - read_unlock(&em_tree->lock); - - if (!em) { - /* get the big lock and read metadata off disk */ - lock_extent(io_tree, start, start + len - 1, GFP_NOFS); - em = btrfs_get_extent(inode, NULL, 0, start, len, 0); - unlock_extent(io_tree, start, start + len - 1, GFP_NOFS); - - if (!em) - return 0; - } - - /* this will cover holes, and inline extents */ - if (em->block_start >= EXTENT_MAP_LAST_BYTE) - ret = 0; - - /* - * we hit a real extent, if it is big don't bother defragging it again - */ - if ((*last_len == 0 || *last_len >= thresh) && em->len >= thresh) - ret = 0; - - /* - * last_len ends up being a counter of how many bytes we've defragged. - * every time we choose not to defrag an extent, we reset *last_len - * so that the next tiny extent will force a defrag. - * - * The end result of this is that tiny extents before a single big - * extent will force at least part of that big extent to be defragged. - */ - if (ret) { - *last_len += len; - *defrag_end = extent_map_end(em); - } else { - *last_len = 0; - *skip = extent_map_end(em); - *defrag_end = 0; - } - - free_extent_map(em); - return ret; -} - -static int btrfs_defrag_file(struct file *file, - struct btrfs_ioctl_defrag_range_args *range) +static int btrfs_defrag_file(struct file *file) { struct inode *inode = fdentry(file)->d_inode; struct btrfs_root *root = BTRFS_I(inode)->root; @@ -559,96 +486,37 @@ static int btrfs_defrag_file(struct file *file, unsigned long total_read = 0; u64 page_start; u64 page_end; - u64 last_len = 0; - u64 skip = 0; - u64 defrag_end = 0; unsigned long i; int ret; - if (inode->i_size == 0) - return 0; - - if (range->start + range->len > range->start) { - last_index = min_t(u64, inode->i_size - 1, - range->start + range->len - 1) >> PAGE_CACHE_SHIFT; - } else { - last_index = (inode->i_size - 1) >> PAGE_CACHE_SHIFT; - } - - i = range->start >> PAGE_CACHE_SHIFT; - while (i <= last_index) { - if (!should_defrag_range(inode, (u64)i << PAGE_CACHE_SHIFT, - PAGE_CACHE_SIZE, - range->extent_thresh, - &last_len, &skip, - &defrag_end)) { - unsigned long next; - /* - * the should_defrag function tells us how much to skip - * bump our counter by the suggested amount - */ - next = (skip + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; - i = max(i + 1, next); - continue; - } + ret = btrfs_check_data_free_space(root, inode, inode->i_size); + if (ret) + return -ENOSPC; + mutex_lock(&inode->i_mutex); + last_index = inode->i_size >> PAGE_CACHE_SHIFT; + for (i = 0; i <= last_index; i++) { if (total_read % ra_pages == 0) { btrfs_force_ra(inode->i_mapping, &file->f_ra, file, i, min(last_index, i + ra_pages - 1)); } total_read++; - mutex_lock(&inode->i_mutex); - if (range->flags & BTRFS_DEFRAG_RANGE_COMPRESS) - BTRFS_I(inode)->force_compress = 1; - - ret = btrfs_check_data_free_space(root, inode, PAGE_CACHE_SIZE); - if (ret) { - ret = -ENOSPC; - break; - } - - ret = btrfs_reserve_metadata_for_delalloc(root, inode, 1); - if (ret) { - btrfs_free_reserved_data_space(root, inode, - PAGE_CACHE_SIZE); - ret = -ENOSPC; - break; - } again: - if (inode->i_size == 0 || - i > ((inode->i_size - 1) >> PAGE_CACHE_SHIFT)) { - ret = 0; - goto err_reservations; - } - page = grab_cache_page(inode->i_mapping, i); if (!page) - goto err_reservations; - + goto out_unlock; if (!PageUptodate(page)) { btrfs_readpage(NULL, page); lock_page(page); if (!PageUptodate(page)) { unlock_page(page); page_cache_release(page); - goto err_reservations; + goto out_unlock; } } - if (page->mapping != inode->i_mapping) { - unlock_page(page); - page_cache_release(page); - goto again; - } - wait_on_page_writeback(page); - if (PageDirty(page)) { - btrfs_free_reserved_data_space(root, inode, - PAGE_CACHE_SIZE); - goto loop_unlock; - } - page_start = (u64)page->index << PAGE_CACHE_SHIFT; page_end = page_start + PAGE_CACHE_SIZE - 1; lock_extent(io_tree, page_start, page_end, GFP_NOFS); @@ -669,54 +537,18 @@ static int btrfs_defrag_file(struct file *file, * page if it is dirtied again later */ clear_page_dirty_for_io(page); - clear_extent_bits(&BTRFS_I(inode)->io_tree, page_start, - page_end, EXTENT_DIRTY | EXTENT_DELALLOC | - EXTENT_DO_ACCOUNTING, GFP_NOFS); - btrfs_set_extent_delalloc(inode, page_start, page_end, NULL); - ClearPageChecked(page); + btrfs_set_extent_delalloc(inode, page_start, page_end); set_page_dirty(page); unlock_extent(io_tree, page_start, page_end, GFP_NOFS); - -loop_unlock: unlock_page(page); page_cache_release(page); - mutex_unlock(&inode->i_mutex); - - btrfs_unreserve_metadata_for_delalloc(root, inode, 1); balance_dirty_pages_ratelimited_nr(inode->i_mapping, 1); - i++; - } - - if ((range->flags & BTRFS_DEFRAG_RANGE_START_IO)) - filemap_flush(inode->i_mapping); - - if ((range->flags & BTRFS_DEFRAG_RANGE_COMPRESS)) { - /* the filemap_flush will queue IO into the worker threads, but - * we have to make sure the IO is actually started and that - * ordered extents get created before we return - */ - atomic_inc(&root->fs_info->async_submit_draining); - while (atomic_read(&root->fs_info->nr_async_submits) || - atomic_read(&root->fs_info->async_delalloc_pages)) { - wait_event(root->fs_info->async_submit_wait, - (atomic_read(&root->fs_info->nr_async_submits) == 0 && - atomic_read(&root->fs_info->async_delalloc_pages) == 0)); - } - atomic_dec(&root->fs_info->async_submit_draining); - - mutex_lock(&inode->i_mutex); - BTRFS_I(inode)->force_compress = 0; - mutex_unlock(&inode->i_mutex); } - return 0; - -err_reservations: +out_unlock: mutex_unlock(&inode->i_mutex); - btrfs_free_reserved_data_space(root, inode, PAGE_CACHE_SIZE); - btrfs_unreserve_metadata_for_delalloc(root, inode, 1); - return ret; + return 0; } static noinline int btrfs_ioctl_resize(struct btrfs_root *root, @@ -776,7 +608,7 @@ static noinline int btrfs_ioctl_resize(struct btrfs_root *root, mod = 1; sizestr++; } - new_size = memparse(sizestr, NULL); + new_size = btrfs_parse_size(sizestr); if (new_size == 0) { ret = -EINVAL; goto out_unlock; @@ -911,327 +743,6 @@ static noinline int may_destroy_subvol(struct btrfs_root *root) return ret; } -static noinline int key_in_sk(struct btrfs_key *key, - struct btrfs_ioctl_search_key *sk) -{ - struct btrfs_key test; - int ret; - - test.objectid = sk->min_objectid; - test.type = sk->min_type; - test.offset = sk->min_offset; - - ret = btrfs_comp_cpu_keys(key, &test); - if (ret < 0) - return 0; - - test.objectid = sk->max_objectid; - test.type = sk->max_type; - test.offset = sk->max_offset; - - ret = btrfs_comp_cpu_keys(key, &test); - if (ret > 0) - return 0; - return 1; -} - -static noinline int copy_to_sk(struct btrfs_root *root, - struct btrfs_path *path, - struct btrfs_key *key, - struct btrfs_ioctl_search_key *sk, - char *buf, - unsigned long *sk_offset, - int *num_found) -{ - u64 found_transid; - struct extent_buffer *leaf; - struct btrfs_ioctl_search_header sh; - unsigned long item_off; - unsigned long item_len; - int nritems; - int i; - int slot; - int found = 0; - int ret = 0; - - leaf = path->nodes[0]; - slot = path->slots[0]; - nritems = btrfs_header_nritems(leaf); - - if (btrfs_header_generation(leaf) > sk->max_transid) { - i = nritems; - goto advance_key; - } - found_transid = btrfs_header_generation(leaf); - - for (i = slot; i < nritems; i++) { - item_off = btrfs_item_ptr_offset(leaf, i); - item_len = btrfs_item_size_nr(leaf, i); - - if (item_len > BTRFS_SEARCH_ARGS_BUFSIZE) - item_len = 0; - - if (sizeof(sh) + item_len + *sk_offset > - BTRFS_SEARCH_ARGS_BUFSIZE) { - ret = 1; - goto overflow; - } - - btrfs_item_key_to_cpu(leaf, key, i); - if (!key_in_sk(key, sk)) - continue; - - sh.objectid = key->objectid; - sh.offset = key->offset; - sh.type = key->type; - sh.len = item_len; - sh.transid = found_transid; - - /* copy search result header */ - memcpy(buf + *sk_offset, &sh, sizeof(sh)); - *sk_offset += sizeof(sh); - - if (item_len) { - char *p = buf + *sk_offset; - /* copy the item */ - read_extent_buffer(leaf, p, - item_off, item_len); - *sk_offset += item_len; - } - found++; - - if (*num_found >= sk->nr_items) - break; - } -advance_key: - ret = 0; - if (key->offset < (u64)-1 && key->offset < sk->max_offset) - key->offset++; - else if (key->type < (u8)-1 && key->type < sk->max_type) { - key->offset = 0; - key->type++; - } else if (key->objectid < (u64)-1 && key->objectid < sk->max_objectid) { - key->offset = 0; - key->type = 0; - key->objectid++; - } else - ret = 1; -overflow: - *num_found += found; - return ret; -} - -static noinline int search_ioctl(struct inode *inode, - struct btrfs_ioctl_search_args *args) -{ - struct btrfs_root *root; - struct btrfs_key key; - struct btrfs_key max_key; - struct btrfs_path *path; - struct btrfs_ioctl_search_key *sk = &args->key; - struct btrfs_fs_info *info = BTRFS_I(inode)->root->fs_info; - int ret; - int num_found = 0; - unsigned long sk_offset = 0; - - path = btrfs_alloc_path(); - if (!path) - return -ENOMEM; - - if (sk->tree_id == 0) { - /* search the root of the inode that was passed */ - root = BTRFS_I(inode)->root; - } else { - key.objectid = sk->tree_id; - key.type = BTRFS_ROOT_ITEM_KEY; - key.offset = (u64)-1; - root = btrfs_read_fs_root_no_name(info, &key); - if (IS_ERR(root)) { - printk(KERN_ERR "could not find root %llu\n", - sk->tree_id); - btrfs_free_path(path); - return -ENOENT; - } - } - - key.objectid = sk->min_objectid; - key.type = sk->min_type; - key.offset = sk->min_offset; - - max_key.objectid = sk->max_objectid; - max_key.type = sk->max_type; - max_key.offset = sk->max_offset; - - path->keep_locks = 1; - - while(1) { - ret = btrfs_search_forward(root, &key, &max_key, path, 0, - sk->min_transid); - if (ret != 0) { - if (ret > 0) - ret = 0; - goto err; - } - ret = copy_to_sk(root, path, &key, sk, args->buf, - &sk_offset, &num_found); - btrfs_release_path(root, path); - if (ret || num_found >= sk->nr_items) - break; - - } - ret = 0; -err: - sk->nr_items = num_found; - btrfs_free_path(path); - return ret; -} - -static noinline int btrfs_ioctl_tree_search(struct file *file, - void __user *argp) -{ - struct btrfs_ioctl_search_args *args; - struct inode *inode; - int ret; - - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - - args = kmalloc(sizeof(*args), GFP_KERNEL); - if (!args) - return -ENOMEM; - - if (copy_from_user(args, argp, sizeof(*args))) { - kfree(args); - return -EFAULT; - } - inode = fdentry(file)->d_inode; - ret = search_ioctl(inode, args); - if (ret == 0 && copy_to_user(argp, args, sizeof(*args))) - ret = -EFAULT; - kfree(args); - return ret; -} - -/* - * Search INODE_REFs to identify path name of 'dirid' directory - * in a 'tree_id' tree. and sets path name to 'name'. - */ -static noinline int btrfs_search_path_in_tree(struct btrfs_fs_info *info, - u64 tree_id, u64 dirid, char *name) -{ - struct btrfs_root *root; - struct btrfs_key key; - char *ptr; - int ret = -1; - int slot; - int len; - int total_len = 0; - struct btrfs_inode_ref *iref; - struct extent_buffer *l; - struct btrfs_path *path; - - if (dirid == BTRFS_FIRST_FREE_OBJECTID) { - name[0]='\0'; - return 0; - } - - path = btrfs_alloc_path(); - if (!path) - return -ENOMEM; - - ptr = &name[BTRFS_INO_LOOKUP_PATH_MAX]; - - key.objectid = tree_id; - key.type = BTRFS_ROOT_ITEM_KEY; - key.offset = (u64)-1; - root = btrfs_read_fs_root_no_name(info, &key); - if (IS_ERR(root)) { - printk(KERN_ERR "could not find root %llu\n", tree_id); - ret = -ENOENT; - goto out; - } - - key.objectid = dirid; - key.type = BTRFS_INODE_REF_KEY; - key.offset = (u64)-1; - - while(1) { - ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); - if (ret < 0) - goto out; - - l = path->nodes[0]; - slot = path->slots[0]; - if (ret > 0 && slot > 0) - slot--; - btrfs_item_key_to_cpu(l, &key, slot); - - if (ret > 0 && (key.objectid != dirid || - key.type != BTRFS_INODE_REF_KEY)) { - ret = -ENOENT; - goto out; - } - - iref = btrfs_item_ptr(l, slot, struct btrfs_inode_ref); - len = btrfs_inode_ref_name_len(l, iref); - ptr -= len + 1; - total_len += len + 1; - if (ptr < name) - goto out; - - *(ptr + len) = '/'; - read_extent_buffer(l, ptr,(unsigned long)(iref + 1), len); - - if (key.offset == BTRFS_FIRST_FREE_OBJECTID) - break; - - btrfs_release_path(root, path); - key.objectid = key.offset; - key.offset = (u64)-1; - dirid = key.objectid; - - } - if (ptr < name) - goto out; - memcpy(name, ptr, total_len); - name[total_len]='\0'; - ret = 0; -out: - btrfs_free_path(path); - return ret; -} - -static noinline int btrfs_ioctl_ino_lookup(struct file *file, - void __user *argp) -{ - struct btrfs_ioctl_ino_lookup_args *args; - struct inode *inode; - int ret; - - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - - args = kmalloc(sizeof(*args), GFP_KERNEL); - if (copy_from_user(args, argp, sizeof(*args))) { - kfree(args); - return -EFAULT; - } - inode = fdentry(file)->d_inode; - - if (args->treeid == 0) - args->treeid = BTRFS_I(inode)->root->root_key.objectid; - - ret = btrfs_search_path_in_tree(BTRFS_I(inode)->root->fs_info, - args->treeid, args->objectid, - args->name); - - if (ret == 0 && copy_to_user(argp, args, sizeof(*args))) - ret = -EFAULT; - - kfree(args); - return ret; -} - static noinline int btrfs_ioctl_snap_destroy(struct file *file, void __user *arg) { @@ -1338,11 +849,10 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file, return err; } -static int btrfs_ioctl_defrag(struct file *file, void __user *argp) +static int btrfs_ioctl_defrag(struct file *file) { struct inode *inode = fdentry(file)->d_inode; struct btrfs_root *root = BTRFS_I(inode)->root; - struct btrfs_ioctl_defrag_range_args *range; int ret; ret = mnt_want_write(file->f_path.mnt); @@ -1363,30 +873,7 @@ static int btrfs_ioctl_defrag(struct file *file, void __user *argp) ret = -EINVAL; goto out; } - - range = kzalloc(sizeof(*range), GFP_KERNEL); - if (!range) { - ret = -ENOMEM; - goto out; - } - - if (argp) { - if (copy_from_user(range, argp, - sizeof(*range))) { - ret = -EFAULT; - kfree(range); - } - /* compression requires us to start the IO */ - if ((range->flags & BTRFS_DEFRAG_RANGE_COMPRESS)) { - range->flags |= BTRFS_DEFRAG_RANGE_START_IO; - range->extent_thresh = (u32)-1; - } - } else { - /* the rest are all set to zero by kzalloc */ - range->len = (u64)-1; - } - btrfs_defrag_file(file, range); - kfree(range); + btrfs_defrag_file(file); break; } out: @@ -1787,157 +1274,6 @@ static long btrfs_ioctl_trans_start(struct file *file) return ret; } -static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp) -{ - struct inode *inode = fdentry(file)->d_inode; - struct btrfs_root *root = BTRFS_I(inode)->root; - struct btrfs_root *new_root; - struct btrfs_dir_item *di; - struct btrfs_trans_handle *trans; - struct btrfs_path *path; - struct btrfs_key location; - struct btrfs_disk_key disk_key; - struct btrfs_super_block *disk_super; - u64 features; - u64 objectid = 0; - u64 dir_id; - - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - - if (copy_from_user(&objectid, argp, sizeof(objectid))) - return -EFAULT; - - if (!objectid) - objectid = root->root_key.objectid; - - location.objectid = objectid; - location.type = BTRFS_ROOT_ITEM_KEY; - location.offset = (u64)-1; - - new_root = btrfs_read_fs_root_no_name(root->fs_info, &location); - if (IS_ERR(new_root)) - return PTR_ERR(new_root); - - if (btrfs_root_refs(&new_root->root_item) == 0) - return -ENOENT; - - path = btrfs_alloc_path(); - if (!path) - return -ENOMEM; - path->leave_spinning = 1; - - trans = btrfs_start_transaction(root, 1); - if (!trans) { - btrfs_free_path(path); - return -ENOMEM; - } - - dir_id = btrfs_super_root_dir(&root->fs_info->super_copy); - di = btrfs_lookup_dir_item(trans, root->fs_info->tree_root, path, - dir_id, "default", 7, 1); - if (!di) { - btrfs_free_path(path); - btrfs_end_transaction(trans, root); - printk(KERN_ERR "Umm, you don't have the default dir item, " - "this isn't going to work\n"); - return -ENOENT; - } - - btrfs_cpu_key_to_disk(&disk_key, &new_root->root_key); - btrfs_set_dir_item_key(path->nodes[0], di, &disk_key); - btrfs_mark_buffer_dirty(path->nodes[0]); - btrfs_free_path(path); - - disk_super = &root->fs_info->super_copy; - features = btrfs_super_incompat_flags(disk_super); - if (!(features & BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL)) { - features |= BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL; - btrfs_set_super_incompat_flags(disk_super, features); - } - btrfs_end_transaction(trans, root); - - return 0; -} - -long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg) -{ - struct btrfs_ioctl_space_args space_args; - struct btrfs_ioctl_space_info space; - struct btrfs_ioctl_space_info *dest; - struct btrfs_ioctl_space_info *dest_orig; - struct btrfs_ioctl_space_info *user_dest; - struct btrfs_space_info *info; - int alloc_size; - int ret = 0; - int slot_count = 0; - - if (copy_from_user(&space_args, - (struct btrfs_ioctl_space_args __user *)arg, - sizeof(space_args))) - return -EFAULT; - - /* first we count slots */ - rcu_read_lock(); - list_for_each_entry_rcu(info, &root->fs_info->space_info, list) - slot_count++; - rcu_read_unlock(); - - /* space_slots == 0 means they are asking for a count */ - if (space_args.space_slots == 0) { - space_args.total_spaces = slot_count; - goto out; - } - alloc_size = sizeof(*dest) * slot_count; - /* we generally have at most 6 or so space infos, one for each raid - * level. So, a whole page should be more than enough for everyone - */ - if (alloc_size > PAGE_CACHE_SIZE) - return -ENOMEM; - - space_args.total_spaces = 0; - dest = kmalloc(alloc_size, GFP_NOFS); - if (!dest) - return -ENOMEM; - dest_orig = dest; - - /* now we have a buffer to copy into */ - rcu_read_lock(); - list_for_each_entry_rcu(info, &root->fs_info->space_info, list) { - /* make sure we don't copy more than we allocated - * in our buffer - */ - if (slot_count == 0) - break; - slot_count--; - - /* make sure userland has enough room in their buffer */ - if (space_args.total_spaces >= space_args.space_slots) - break; - - space.flags = info->flags; - space.total_bytes = info->total_bytes; - space.used_bytes = info->bytes_used; - memcpy(dest, &space, sizeof(space)); - dest++; - space_args.total_spaces++; - } - rcu_read_unlock(); - - user_dest = (struct btrfs_ioctl_space_info *) - (arg + sizeof(struct btrfs_ioctl_space_args)); - - if (copy_to_user(user_dest, dest_orig, alloc_size)) - ret = -EFAULT; - - kfree(dest_orig); -out: - if (ret == 0 && copy_to_user(arg, &space_args, sizeof(space_args))) - ret = -EFAULT; - - return ret; -} - /* * there are many ways the trans_start and trans_end ioctls can lead * to deadlocks. They should only be used by applications that @@ -1984,12 +1320,8 @@ long btrfs_ioctl(struct file *file, unsigned int return btrfs_ioctl_snap_create(file, argp, 1); case BTRFS_IOC_SNAP_DESTROY: return btrfs_ioctl_snap_destroy(file, argp); - case BTRFS_IOC_DEFAULT_SUBVOL: - return btrfs_ioctl_default_subvol(file, argp); case BTRFS_IOC_DEFRAG: - return btrfs_ioctl_defrag(file, NULL); - case BTRFS_IOC_DEFRAG_RANGE: - return btrfs_ioctl_defrag(file, argp); + return btrfs_ioctl_defrag(file); case BTRFS_IOC_RESIZE: return btrfs_ioctl_resize(root, argp); case BTRFS_IOC_ADD_DEV: @@ -2006,12 +1338,6 @@ long btrfs_ioctl(struct file *file, unsigned int return btrfs_ioctl_trans_start(file); case BTRFS_IOC_TRANS_END: return btrfs_ioctl_trans_end(file); - case BTRFS_IOC_TREE_SEARCH: - return btrfs_ioctl_tree_search(file, argp); - case BTRFS_IOC_INO_LOOKUP: - return btrfs_ioctl_ino_lookup(file, argp); - case BTRFS_IOC_SPACE_INFO: - return btrfs_ioctl_space_info(root, argp); case BTRFS_IOC_SYNC: btrfs_sync_fs(file->f_dentry->d_sb, 1); return 0; diff --git a/trunk/fs/btrfs/ioctl.h b/trunk/fs/btrfs/ioctl.h index 424694aa517f..bc49914475eb 100644 --- a/trunk/fs/btrfs/ioctl.h +++ b/trunk/fs/btrfs/ioctl.h @@ -30,114 +30,12 @@ struct btrfs_ioctl_vol_args { char name[BTRFS_PATH_NAME_MAX + 1]; }; -#define BTRFS_INO_LOOKUP_PATH_MAX 4080 -struct btrfs_ioctl_ino_lookup_args { - __u64 treeid; - __u64 objectid; - char name[BTRFS_INO_LOOKUP_PATH_MAX]; -}; - -struct btrfs_ioctl_search_key { - /* which root are we searching. 0 is the tree of tree roots */ - __u64 tree_id; - - /* keys returned will be >= min and <= max */ - __u64 min_objectid; - __u64 max_objectid; - - /* keys returned will be >= min and <= max */ - __u64 min_offset; - __u64 max_offset; - - /* max and min transids to search for */ - __u64 min_transid; - __u64 max_transid; - - /* keys returned will be >= min and <= max */ - __u32 min_type; - __u32 max_type; - - /* - * how many items did userland ask for, and how many are we - * returning - */ - __u32 nr_items; - - /* align to 64 bits */ - __u32 unused; - - /* some extra for later */ - __u64 unused1; - __u64 unused2; - __u64 unused3; - __u64 unused4; -}; - -struct btrfs_ioctl_search_header { - __u64 transid; - __u64 objectid; - __u64 offset; - __u32 type; - __u32 len; -}; - -#define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key)) -/* - * the buf is an array of search headers where - * each header is followed by the actual item - * the type field is expanded to 32 bits for alignment - */ -struct btrfs_ioctl_search_args { - struct btrfs_ioctl_search_key key; - char buf[BTRFS_SEARCH_ARGS_BUFSIZE]; -}; - struct btrfs_ioctl_clone_range_args { __s64 src_fd; __u64 src_offset, src_length; __u64 dest_offset; }; -/* flags for the defrag range ioctl */ -#define BTRFS_DEFRAG_RANGE_COMPRESS 1 -#define BTRFS_DEFRAG_RANGE_START_IO 2 - -struct btrfs_ioctl_defrag_range_args { - /* start of the defrag operation */ - __u64 start; - - /* number of bytes to defrag, use (u64)-1 to say all */ - __u64 len; - - /* - * flags for the operation, which can include turning - * on compression for this one defrag - */ - __u64 flags; - - /* - * any extent bigger than this will be considered - * already defragged. Use 0 to take the kernel default - * Use 1 to say every single extent must be rewritten - */ - __u32 extent_thresh; - - /* spare for later */ - __u32 unused[5]; -}; - -struct btrfs_ioctl_space_info { - __u64 flags; - __u64 total_bytes; - __u64 used_bytes; -}; - -struct btrfs_ioctl_space_args { - __u64 space_slots; - __u64 total_spaces; - struct btrfs_ioctl_space_info spaces[0]; -}; - #define BTRFS_IOC_SNAP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 1, \ struct btrfs_ioctl_vol_args) #define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \ @@ -169,13 +67,4 @@ struct btrfs_ioctl_space_args { struct btrfs_ioctl_vol_args) #define BTRFS_IOC_SNAP_DESTROY _IOW(BTRFS_IOCTL_MAGIC, 15, \ struct btrfs_ioctl_vol_args) -#define BTRFS_IOC_DEFRAG_RANGE _IOW(BTRFS_IOCTL_MAGIC, 16, \ - struct btrfs_ioctl_defrag_range_args) -#define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, \ - struct btrfs_ioctl_search_args) -#define BTRFS_IOC_INO_LOOKUP _IOWR(BTRFS_IOCTL_MAGIC, 18, \ - struct btrfs_ioctl_ino_lookup_args) -#define BTRFS_IOC_DEFAULT_SUBVOL _IOW(BTRFS_IOCTL_MAGIC, 19, u64) -#define BTRFS_IOC_SPACE_INFO _IOWR(BTRFS_IOCTL_MAGIC, 20, \ - struct btrfs_ioctl_space_args) #endif diff --git a/trunk/fs/btrfs/ordered-data.c b/trunk/fs/btrfs/ordered-data.c index a8ffecd0b491..5c2a9e78a949 100644 --- a/trunk/fs/btrfs/ordered-data.c +++ b/trunk/fs/btrfs/ordered-data.c @@ -174,6 +174,7 @@ int btrfs_add_ordered_extent(struct inode *inode, u64 file_offset, if (!entry) return -ENOMEM; + mutex_lock(&tree->mutex); entry->file_offset = file_offset; entry->start = start; entry->len = len; @@ -189,17 +190,16 @@ int btrfs_add_ordered_extent(struct inode *inode, u64 file_offset, INIT_LIST_HEAD(&entry->list); INIT_LIST_HEAD(&entry->root_extent_list); - spin_lock(&tree->lock); node = tree_insert(&tree->tree, file_offset, &entry->rb_node); BUG_ON(node); - spin_unlock(&tree->lock); spin_lock(&BTRFS_I(inode)->root->fs_info->ordered_extent_lock); list_add_tail(&entry->root_extent_list, &BTRFS_I(inode)->root->fs_info->ordered_extents); spin_unlock(&BTRFS_I(inode)->root->fs_info->ordered_extent_lock); + mutex_unlock(&tree->mutex); BUG_ON(node); return 0; } @@ -216,9 +216,9 @@ int btrfs_add_ordered_sum(struct inode *inode, struct btrfs_ordered_inode_tree *tree; tree = &BTRFS_I(inode)->ordered_tree; - spin_lock(&tree->lock); + mutex_lock(&tree->mutex); list_add_tail(&sum->list, &entry->list); - spin_unlock(&tree->lock); + mutex_unlock(&tree->mutex); return 0; } @@ -232,16 +232,15 @@ int btrfs_add_ordered_sum(struct inode *inode, * to make sure this function only returns 1 once for a given ordered extent. */ int btrfs_dec_test_ordered_pending(struct inode *inode, - struct btrfs_ordered_extent **cached, u64 file_offset, u64 io_size) { struct btrfs_ordered_inode_tree *tree; struct rb_node *node; - struct btrfs_ordered_extent *entry = NULL; + struct btrfs_ordered_extent *entry; int ret; tree = &BTRFS_I(inode)->ordered_tree; - spin_lock(&tree->lock); + mutex_lock(&tree->mutex); node = tree_search(tree, file_offset); if (!node) { ret = 1; @@ -265,11 +264,7 @@ int btrfs_dec_test_ordered_pending(struct inode *inode, else ret = 1; out: - if (!ret && cached && entry) { - *cached = entry; - atomic_inc(&entry->refs); - } - spin_unlock(&tree->lock); + mutex_unlock(&tree->mutex); return ret == 0; } @@ -296,7 +291,7 @@ int btrfs_put_ordered_extent(struct btrfs_ordered_extent *entry) /* * remove an ordered extent from the tree. No references are dropped - * and you must wake_up entry->wait. You must hold the tree lock + * and you must wake_up entry->wait. You must hold the tree mutex * while you call this function. */ static int __btrfs_remove_ordered_extent(struct inode *inode, @@ -345,9 +340,9 @@ int btrfs_remove_ordered_extent(struct inode *inode, int ret; tree = &BTRFS_I(inode)->ordered_tree; - spin_lock(&tree->lock); + mutex_lock(&tree->mutex); ret = __btrfs_remove_ordered_extent(inode, entry); - spin_unlock(&tree->lock); + mutex_unlock(&tree->mutex); wake_up(&entry->wait); return ret; @@ -572,7 +567,7 @@ struct btrfs_ordered_extent *btrfs_lookup_ordered_extent(struct inode *inode, struct btrfs_ordered_extent *entry = NULL; tree = &BTRFS_I(inode)->ordered_tree; - spin_lock(&tree->lock); + mutex_lock(&tree->mutex); node = tree_search(tree, file_offset); if (!node) goto out; @@ -583,7 +578,7 @@ struct btrfs_ordered_extent *btrfs_lookup_ordered_extent(struct inode *inode, if (entry) atomic_inc(&entry->refs); out: - spin_unlock(&tree->lock); + mutex_unlock(&tree->mutex); return entry; } @@ -599,7 +594,7 @@ btrfs_lookup_first_ordered_extent(struct inode *inode, u64 file_offset) struct btrfs_ordered_extent *entry = NULL; tree = &BTRFS_I(inode)->ordered_tree; - spin_lock(&tree->lock); + mutex_lock(&tree->mutex); node = tree_search(tree, file_offset); if (!node) goto out; @@ -607,7 +602,7 @@ btrfs_lookup_first_ordered_extent(struct inode *inode, u64 file_offset) entry = rb_entry(node, struct btrfs_ordered_extent, rb_node); atomic_inc(&entry->refs); out: - spin_unlock(&tree->lock); + mutex_unlock(&tree->mutex); return entry; } @@ -634,7 +629,7 @@ int btrfs_ordered_update_i_size(struct inode *inode, u64 offset, else offset = ALIGN(offset, BTRFS_I(inode)->root->sectorsize); - spin_lock(&tree->lock); + mutex_lock(&tree->mutex); disk_i_size = BTRFS_I(inode)->disk_i_size; /* truncate file */ @@ -740,7 +735,7 @@ int btrfs_ordered_update_i_size(struct inode *inode, u64 offset, */ if (ordered) __btrfs_remove_ordered_extent(inode, ordered); - spin_unlock(&tree->lock); + mutex_unlock(&tree->mutex); if (ordered) wake_up(&ordered->wait); return ret; @@ -767,7 +762,7 @@ int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u64 disk_bytenr, if (!ordered) return 1; - spin_lock(&tree->lock); + mutex_lock(&tree->mutex); list_for_each_entry_reverse(ordered_sum, &ordered->list, list) { if (disk_bytenr >= ordered_sum->bytenr) { num_sectors = ordered_sum->len / sectorsize; @@ -782,7 +777,7 @@ int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u64 disk_bytenr, } } out: - spin_unlock(&tree->lock); + mutex_unlock(&tree->mutex); btrfs_put_ordered_extent(ordered); return ret; } diff --git a/trunk/fs/btrfs/ordered-data.h b/trunk/fs/btrfs/ordered-data.h index c82f76a9f040..9116c6d0c5a9 100644 --- a/trunk/fs/btrfs/ordered-data.h +++ b/trunk/fs/btrfs/ordered-data.h @@ -21,7 +21,7 @@ /* one of these per inode */ struct btrfs_ordered_inode_tree { - spinlock_t lock; + struct mutex mutex; struct rb_root tree; struct rb_node *last; }; @@ -128,7 +128,7 @@ static inline int btrfs_ordered_sum_size(struct btrfs_root *root, static inline void btrfs_ordered_inode_tree_init(struct btrfs_ordered_inode_tree *t) { - spin_lock_init(&t->lock); + mutex_init(&t->mutex); t->tree = RB_ROOT; t->last = NULL; } @@ -137,8 +137,7 @@ int btrfs_put_ordered_extent(struct btrfs_ordered_extent *entry); int btrfs_remove_ordered_extent(struct inode *inode, struct btrfs_ordered_extent *entry); int btrfs_dec_test_ordered_pending(struct inode *inode, - struct btrfs_ordered_extent **cached, - u64 file_offset, u64 io_size); + u64 file_offset, u64 io_size); int btrfs_add_ordered_extent(struct inode *inode, u64 file_offset, u64 start, u64 len, u64 disk_len, int tyep); int btrfs_add_ordered_sum(struct inode *inode, diff --git a/trunk/fs/btrfs/relocation.c b/trunk/fs/btrfs/relocation.c index 0b23942cbc0d..0109e5606bad 100644 --- a/trunk/fs/btrfs/relocation.c +++ b/trunk/fs/btrfs/relocation.c @@ -2659,7 +2659,7 @@ static int relocate_file_extent_cluster(struct inode *inode, EXTENT_BOUNDARY, GFP_NOFS); nr++; } - btrfs_set_extent_delalloc(inode, page_start, page_end, NULL); + btrfs_set_extent_delalloc(inode, page_start, page_end); set_page_dirty(page); dirty_page++; @@ -3487,7 +3487,7 @@ static struct inode *create_reloc_inode(struct btrfs_fs_info *fs_info, key.objectid = objectid; key.type = BTRFS_INODE_ITEM_KEY; key.offset = 0; - inode = btrfs_iget(root->fs_info->sb, &key, root, NULL); + inode = btrfs_iget(root->fs_info->sb, &key, root); BUG_ON(IS_ERR(inode) || is_bad_inode(inode)); BTRFS_I(inode)->index_cnt = group->key.objectid; diff --git a/trunk/fs/btrfs/super.c b/trunk/fs/btrfs/super.c index 9ac612e6ca60..f8b4521de907 100644 --- a/trunk/fs/btrfs/super.c +++ b/trunk/fs/btrfs/super.c @@ -63,10 +63,10 @@ static void btrfs_put_super(struct super_block *sb) } enum { - Opt_degraded, Opt_subvol, Opt_subvolid, Opt_device, Opt_nodatasum, - Opt_nodatacow, Opt_max_extent, Opt_max_inline, Opt_alloc_start, - Opt_nobarrier, Opt_ssd, Opt_nossd, Opt_ssd_spread, Opt_thread_pool, - Opt_noacl, Opt_compress, Opt_compress_force, Opt_notreelog, Opt_ratio, + Opt_degraded, Opt_subvol, Opt_device, Opt_nodatasum, Opt_nodatacow, + Opt_max_extent, Opt_max_inline, Opt_alloc_start, Opt_nobarrier, + Opt_ssd, Opt_nossd, Opt_ssd_spread, Opt_thread_pool, Opt_noacl, + Opt_compress, Opt_compress_force, Opt_notreelog, Opt_ratio, Opt_flushoncommit, Opt_discard, Opt_err, }; @@ -74,7 +74,6 @@ enum { static match_table_t tokens = { {Opt_degraded, "degraded"}, {Opt_subvol, "subvol=%s"}, - {Opt_subvolid, "subvolid=%d"}, {Opt_device, "device=%s"}, {Opt_nodatasum, "nodatasum"}, {Opt_nodatacow, "nodatacow"}, @@ -96,6 +95,31 @@ static match_table_t tokens = { {Opt_err, NULL}, }; +u64 btrfs_parse_size(char *str) +{ + u64 res; + int mult = 1; + char *end; + char last; + + res = simple_strtoul(str, &end, 10); + + last = end[0]; + if (isalpha(last)) { + last = tolower(last); + switch (last) { + case 'g': + mult *= 1024; + case 'm': + mult *= 1024; + case 'k': + mult *= 1024; + } + res = res * mult; + } + return res; +} + /* * Regular mount options parser. Everything that is needed only when * reading in a new superblock is parsed here. @@ -133,7 +157,6 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) btrfs_set_opt(info->mount_opt, DEGRADED); break; case Opt_subvol: - case Opt_subvolid: case Opt_device: /* * These are parsed by btrfs_parse_early_options @@ -191,7 +214,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) case Opt_max_extent: num = match_strdup(&args[0]); if (num) { - info->max_extent = memparse(num, NULL); + info->max_extent = btrfs_parse_size(num); kfree(num); info->max_extent = max_t(u64, @@ -203,7 +226,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) case Opt_max_inline: num = match_strdup(&args[0]); if (num) { - info->max_inline = memparse(num, NULL); + info->max_inline = btrfs_parse_size(num); kfree(num); if (info->max_inline) { @@ -218,7 +241,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) case Opt_alloc_start: num = match_strdup(&args[0]); if (num) { - info->alloc_start = memparse(num, NULL); + info->alloc_start = btrfs_parse_size(num); kfree(num); printk(KERN_INFO "btrfs: allocations start at %llu\n", @@ -269,13 +292,12 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) * only when we need to allocate a new super block. */ static int btrfs_parse_early_options(const char *options, fmode_t flags, - void *holder, char **subvol_name, u64 *subvol_objectid, + void *holder, char **subvol_name, struct btrfs_fs_devices **fs_devices) { substring_t args[MAX_OPT_ARGS]; char *opts, *p; int error = 0; - int intarg; if (!options) goto out; @@ -298,18 +320,6 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags, case Opt_subvol: *subvol_name = match_strdup(&args[0]); break; - case Opt_subvolid: - intarg = 0; - error = match_int(&args[0], &intarg); - if (!error) { - /* we want the original fs_tree */ - if (!intarg) - *subvol_objectid = - BTRFS_FS_TREE_OBJECTID; - else - *subvol_objectid = intarg; - } - break; case Opt_device: error = btrfs_scan_one_device(match_strdup(&args[0]), flags, holder, fs_devices); @@ -337,110 +347,6 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags, return error; } -static struct dentry *get_default_root(struct super_block *sb, - u64 subvol_objectid) -{ - struct btrfs_root *root = sb->s_fs_info; - struct btrfs_root *new_root; - struct btrfs_dir_item *di; - struct btrfs_path *path; - struct btrfs_key location; - struct inode *inode; - struct dentry *dentry; - u64 dir_id; - int new = 0; - - /* - * We have a specific subvol we want to mount, just setup location and - * go look up the root. - */ - if (subvol_objectid) { - location.objectid = subvol_objectid; - location.type = BTRFS_ROOT_ITEM_KEY; - location.offset = (u64)-1; - goto find_root; - } - - path = btrfs_alloc_path(); - if (!path) - return ERR_PTR(-ENOMEM); - path->leave_spinning = 1; - - /* - * Find the "default" dir item which points to the root item that we - * will mount by default if we haven't been given a specific subvolume - * to mount. - */ - dir_id = btrfs_super_root_dir(&root->fs_info->super_copy); - di = btrfs_lookup_dir_item(NULL, root, path, dir_id, "default", 7, 0); - if (!di) { - /* - * Ok the default dir item isn't there. This is weird since - * it's always been there, but don't freak out, just try and - * mount to root most subvolume. - */ - btrfs_free_path(path); - dir_id = BTRFS_FIRST_FREE_OBJECTID; - new_root = root->fs_info->fs_root; - goto setup_root; - } - - btrfs_dir_item_key_to_cpu(path->nodes[0], di, &location); - btrfs_free_path(path); - -find_root: - new_root = btrfs_read_fs_root_no_name(root->fs_info, &location); - if (IS_ERR(new_root)) - return ERR_PTR(PTR_ERR(new_root)); - - if (btrfs_root_refs(&new_root->root_item) == 0) - return ERR_PTR(-ENOENT); - - dir_id = btrfs_root_dirid(&new_root->root_item); -setup_root: - location.objectid = dir_id; - location.type = BTRFS_INODE_ITEM_KEY; - location.offset = 0; - - inode = btrfs_iget(sb, &location, new_root, &new); - if (!inode) - return ERR_PTR(-ENOMEM); - - /* - * If we're just mounting the root most subvol put the inode and return - * a reference to the dentry. We will have already gotten a reference - * to the inode in btrfs_fill_super so we're good to go. - */ - if (!new && sb->s_root->d_inode == inode) { - iput(inode); - return dget(sb->s_root); - } - - if (new) { - const struct qstr name = { .name = "/", .len = 1 }; - - /* - * New inode, we need to make the dentry a sibling of s_root so - * everything gets cleaned up properly on unmount. - */ - dentry = d_alloc(sb->s_root, &name); - if (!dentry) { - iput(inode); - return ERR_PTR(-ENOMEM); - } - d_splice_alias(inode, dentry); - } else { - /* - * We found the inode in cache, just find a dentry for it and - * put the reference to the inode we just got. - */ - dentry = d_find_alias(inode); - iput(inode); - } - - return dentry; -} - static int btrfs_fill_super(struct super_block *sb, struct btrfs_fs_devices *fs_devices, void *data, int silent) @@ -474,7 +380,7 @@ static int btrfs_fill_super(struct super_block *sb, key.objectid = BTRFS_FIRST_FREE_OBJECTID; key.type = BTRFS_INODE_ITEM_KEY; key.offset = 0; - inode = btrfs_iget(sb, &key, tree_root->fs_info->fs_root, NULL); + inode = btrfs_iget(sb, &key, tree_root->fs_info->fs_root); if (IS_ERR(inode)) { err = PTR_ERR(inode); goto fail_close; @@ -486,6 +392,12 @@ static int btrfs_fill_super(struct super_block *sb, err = -ENOMEM; goto fail_close; } +#if 0 + /* this does the super kobj at the same time */ + err = btrfs_sysfs_add_super(tree_root->fs_info); + if (err) + goto fail_close; +#endif sb->s_root = root_dentry; @@ -577,22 +489,19 @@ static int btrfs_test_super(struct super_block *s, void *data) static int btrfs_get_sb(struct file_system_type *fs_type, int flags, const char *dev_name, void *data, struct vfsmount *mnt) { + char *subvol_name = NULL; struct block_device *bdev = NULL; struct super_block *s; struct dentry *root; struct btrfs_fs_devices *fs_devices = NULL; fmode_t mode = FMODE_READ; - char *subvol_name = NULL; - u64 subvol_objectid = 0; int error = 0; - int found = 0; if (!(flags & MS_RDONLY)) mode |= FMODE_WRITE; error = btrfs_parse_early_options(data, mode, fs_type, - &subvol_name, &subvol_objectid, - &fs_devices); + &subvol_name, &fs_devices); if (error) return error; @@ -621,7 +530,6 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags, goto error_close_devices; } - found = 1; btrfs_close_devices(fs_devices); } else { char b[BDEVNAME_SIZE]; @@ -639,35 +547,25 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags, s->s_flags |= MS_ACTIVE; } - root = get_default_root(s, subvol_objectid); - if (IS_ERR(root)) { - error = PTR_ERR(root); - deactivate_locked_super(s); - goto error; - } - /* if they gave us a subvolume name bind mount into that */ - if (strcmp(subvol_name, ".")) { - struct dentry *new_root; - mutex_lock(&root->d_inode->i_mutex); - new_root = lookup_one_len(subvol_name, root, + if (!strcmp(subvol_name, ".")) + root = dget(s->s_root); + else { + mutex_lock(&s->s_root->d_inode->i_mutex); + root = lookup_one_len(subvol_name, s->s_root, strlen(subvol_name)); - mutex_unlock(&root->d_inode->i_mutex); + mutex_unlock(&s->s_root->d_inode->i_mutex); - if (IS_ERR(new_root)) { + if (IS_ERR(root)) { deactivate_locked_super(s); - error = PTR_ERR(new_root); - dput(root); - goto error_close_devices; + error = PTR_ERR(root); + goto error_free_subvol_name; } - if (!new_root->d_inode) { + if (!root->d_inode) { dput(root); - dput(new_root); deactivate_locked_super(s); error = -ENXIO; - goto error_close_devices; + goto error_free_subvol_name; } - dput(root); - root = new_root; } mnt->mnt_sb = s; @@ -682,7 +580,6 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags, btrfs_close_devices(fs_devices); error_free_subvol_name: kfree(subvol_name); -error: return error; } @@ -727,37 +624,14 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf) { struct btrfs_root *root = btrfs_sb(dentry->d_sb); struct btrfs_super_block *disk_super = &root->fs_info->super_copy; - struct list_head *head = &root->fs_info->space_info; - struct btrfs_space_info *found; - u64 total_used = 0; - u64 data_used = 0; int bits = dentry->d_sb->s_blocksize_bits; __be32 *fsid = (__be32 *)root->fs_info->fsid; - rcu_read_lock(); - list_for_each_entry_rcu(found, head, list) { - if (found->flags & (BTRFS_BLOCK_GROUP_DUP| - BTRFS_BLOCK_GROUP_RAID10| - BTRFS_BLOCK_GROUP_RAID1)) { - total_used += found->bytes_used; - if (found->flags & BTRFS_BLOCK_GROUP_DATA) - data_used += found->bytes_used; - else - data_used += found->total_bytes; - } - - total_used += found->bytes_used; - if (found->flags & BTRFS_BLOCK_GROUP_DATA) - data_used += found->bytes_used; - else - data_used += found->total_bytes; - } - rcu_read_unlock(); - buf->f_namelen = BTRFS_NAME_LEN; buf->f_blocks = btrfs_super_total_bytes(disk_super) >> bits; - buf->f_bfree = buf->f_blocks - (total_used >> bits); - buf->f_bavail = buf->f_blocks - (data_used >> bits); + buf->f_bfree = buf->f_blocks - + (btrfs_super_bytes_used(disk_super) >> bits); + buf->f_bavail = buf->f_bfree; buf->f_bsize = dentry->d_sb->s_blocksize; buf->f_type = BTRFS_SUPER_MAGIC; diff --git a/trunk/fs/btrfs/transaction.c b/trunk/fs/btrfs/transaction.c index 2d654c1c794d..2a36e236a492 100644 --- a/trunk/fs/btrfs/transaction.c +++ b/trunk/fs/btrfs/transaction.c @@ -997,10 +997,13 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, mutex_unlock(&root->fs_info->trans_mutex); - if (flush_on_commit || snap_pending) { + if (flush_on_commit) { btrfs_start_delalloc_inodes(root, 1); ret = btrfs_wait_ordered_extents(root, 0, 1); BUG_ON(ret); + } else if (snap_pending) { + ret = btrfs_wait_ordered_extents(root, 0, 1); + BUG_ON(ret); } /* diff --git a/trunk/fs/btrfs/tree-log.c b/trunk/fs/btrfs/tree-log.c index 1255fcc8ade5..4a9434b622ec 100644 --- a/trunk/fs/btrfs/tree-log.c +++ b/trunk/fs/btrfs/tree-log.c @@ -445,7 +445,7 @@ static noinline struct inode *read_one_inode(struct btrfs_root *root, key.objectid = objectid; key.type = BTRFS_INODE_ITEM_KEY; key.offset = 0; - inode = btrfs_iget(root->fs_info->sb, &key, root, NULL); + inode = btrfs_iget(root->fs_info->sb, &key, root); if (IS_ERR(inode)) { inode = NULL; } else if (is_bad_inode(inode)) { diff --git a/trunk/fs/btrfs/volumes.c b/trunk/fs/btrfs/volumes.c index 9df8e3f1ccab..41ecbb2347f2 100644 --- a/trunk/fs/btrfs/volumes.c +++ b/trunk/fs/btrfs/volumes.c @@ -256,13 +256,13 @@ static noinline int run_scheduled_bios(struct btrfs_device *device) wake_up(&fs_info->async_submit_wait); BUG_ON(atomic_read(&cur->bi_cnt) == 0); + submit_bio(cur->bi_rw, cur); + num_run++; + batch_run++; if (bio_rw_flagged(cur, BIO_RW_SYNCIO)) num_sync_run++; - submit_bio(cur->bi_rw, cur); - num_run++; - batch_run++; if (need_resched()) { if (num_sync_run) { blk_run_backing_dev(bdi, NULL); @@ -325,6 +325,16 @@ static noinline int run_scheduled_bios(struct btrfs_device *device) num_sync_run = 0; blk_run_backing_dev(bdi, NULL); } + + cond_resched(); + if (again) + goto loop; + + spin_lock(&device->io_lock); + if (device->pending_bios.head || device->pending_sync_bios.head) + goto loop_lock; + spin_unlock(&device->io_lock); + /* * IO has already been through a long path to get here. Checksumming, * async helper threads, perhaps compression. We've done a pretty @@ -336,16 +346,6 @@ static noinline int run_scheduled_bios(struct btrfs_device *device) * cared about found its way down here. */ blk_run_backing_dev(bdi, NULL); - - cond_resched(); - if (again) - goto loop; - - spin_lock(&device->io_lock); - if (device->pending_bios.head || device->pending_sync_bios.head) - goto loop_lock; - spin_unlock(&device->io_lock); - done: return 0; } @@ -365,7 +365,6 @@ static noinline int device_list_add(const char *path, struct btrfs_device *device; struct btrfs_fs_devices *fs_devices; u64 found_transid = btrfs_super_generation(disk_super); - char *name; fs_devices = find_fsid(disk_super->fsid); if (!fs_devices) { @@ -412,12 +411,6 @@ static noinline int device_list_add(const char *path, device->fs_devices = fs_devices; fs_devices->num_devices++; - } else if (strcmp(device->name, path)) { - name = kstrdup(path, GFP_NOFS); - if (!name) - return -ENOMEM; - kfree(device->name); - device->name = name; } if (found_transid > fs_devices->latest_trans) { @@ -599,7 +592,7 @@ static int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, goto error_close; disk_super = (struct btrfs_super_block *)bh->b_data; - devid = btrfs_stack_device_id(&disk_super->dev_item); + devid = le64_to_cpu(disk_super->dev_item.devid); if (devid != device->devid) goto error_brelse; @@ -701,7 +694,7 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder, goto error_close; } disk_super = (struct btrfs_super_block *)bh->b_data; - devid = btrfs_stack_device_id(&disk_super->dev_item); + devid = le64_to_cpu(disk_super->dev_item.devid); transid = btrfs_super_generation(disk_super); if (disk_super->label[0]) printk(KERN_INFO "device label %s ", disk_super->label); @@ -1194,7 +1187,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) goto error_close; } disk_super = (struct btrfs_super_block *)bh->b_data; - devid = btrfs_stack_device_id(&disk_super->dev_item); + devid = le64_to_cpu(disk_super->dev_item.devid); dev_uuid = disk_super->dev_item.uuid; device = btrfs_find_device(root, devid, dev_uuid, disk_super->fsid); diff --git a/trunk/fs/jffs2/readinode.c b/trunk/fs/jffs2/readinode.c index d32ee9412cb9..e22de8397b74 100644 --- a/trunk/fs/jffs2/readinode.c +++ b/trunk/fs/jffs2/readinode.c @@ -567,7 +567,7 @@ static void jffs2_free_tmp_dnode_info_list(struct rb_root *list) else BUG(); } } - *list = RB_ROOT; + list->rb_node = NULL; } static void jffs2_free_full_dirent_list(struct jffs2_full_dirent *fd) diff --git a/trunk/fs/nfs/callback_xdr.c b/trunk/fs/nfs/callback_xdr.c index a2b8b4df125d..db30c0b398b5 100644 --- a/trunk/fs/nfs/callback_xdr.c +++ b/trunk/fs/nfs/callback_xdr.c @@ -782,7 +782,6 @@ struct svc_version nfs4_callback_version1 = { .vs_proc = nfs4_callback_procedures1, .vs_xdrsize = NFS4_CALLBACK_XDRSIZE, .vs_dispatch = NULL, - .vs_hidden = 1, }; struct svc_version nfs4_callback_version4 = { diff --git a/trunk/fs/nfs/delegation.h b/trunk/fs/nfs/delegation.h index 69e7b8140122..944b627ec6e1 100644 --- a/trunk/fs/nfs/delegation.h +++ b/trunk/fs/nfs/delegation.h @@ -71,10 +71,4 @@ static inline int nfs_inode_return_delegation(struct inode *inode) } #endif -static inline int nfs_have_delegated_attributes(struct inode *inode) -{ - return nfs_have_delegation(inode, FMODE_READ) && - !(NFS_I(inode)->cache_validity & NFS_INO_REVAL_FORCED); -} - #endif diff --git a/trunk/fs/nfs/dir.c b/trunk/fs/nfs/dir.c index c6f2750648f4..a1f6b4438fb1 100644 --- a/trunk/fs/nfs/dir.c +++ b/trunk/fs/nfs/dir.c @@ -1789,7 +1789,7 @@ static int nfs_access_get_cached(struct inode *inode, struct rpc_cred *cred, str cache = nfs_access_search_rbtree(inode, cred); if (cache == NULL) goto out; - if (!nfs_have_delegated_attributes(inode) && + if (!nfs_have_delegation(inode, FMODE_READ) && !time_in_range_open(jiffies, cache->jiffies, cache->jiffies + nfsi->attrtimeo)) goto out_stale; res->jiffies = cache->jiffies; diff --git a/trunk/fs/nfs/inode.c b/trunk/fs/nfs/inode.c index e358df75a6ad..657201acda84 100644 --- a/trunk/fs/nfs/inode.c +++ b/trunk/fs/nfs/inode.c @@ -729,7 +729,7 @@ int nfs_attribute_timeout(struct inode *inode) { struct nfs_inode *nfsi = NFS_I(inode); - if (nfs_have_delegated_attributes(inode)) + if (nfs_have_delegation(inode, FMODE_READ)) return 0; return !time_in_range_open(jiffies, nfsi->read_cache_jiffies, nfsi->read_cache_jiffies + nfsi->attrtimeo); } diff --git a/trunk/fs/nfs/nfs4proc.c b/trunk/fs/nfs/nfs4proc.c index f9254fb0c9d0..eda74c42d552 100644 --- a/trunk/fs/nfs/nfs4proc.c +++ b/trunk/fs/nfs/nfs4proc.c @@ -5107,7 +5107,6 @@ static int nfs41_proc_async_sequence(struct nfs_client *clp, res = kzalloc(sizeof(*res), GFP_KERNEL); if (!args || !res) { kfree(args); - kfree(res); nfs_put_client(clp); return -ENOMEM; } diff --git a/trunk/fs/nfs/pagelist.c b/trunk/fs/nfs/pagelist.c index 29d9d36cd5f4..a12c45b65dd4 100644 --- a/trunk/fs/nfs/pagelist.c +++ b/trunk/fs/nfs/pagelist.c @@ -112,10 +112,12 @@ void nfs_unlock_request(struct nfs_page *req) */ int nfs_set_page_tag_locked(struct nfs_page *req) { + struct nfs_inode *nfsi = NFS_I(req->wb_context->path.dentry->d_inode); + if (!nfs_lock_request_dontget(req)) return 0; if (req->wb_page != NULL) - radix_tree_tag_set(&NFS_I(req->wb_context->path.dentry->d_inode)->nfs_page_tree, req->wb_index, NFS_PAGE_TAG_LOCKED); + radix_tree_tag_set(&nfsi->nfs_page_tree, req->wb_index, NFS_PAGE_TAG_LOCKED); return 1; } @@ -124,10 +126,10 @@ int nfs_set_page_tag_locked(struct nfs_page *req) */ void nfs_clear_page_tag_locked(struct nfs_page *req) { - if (req->wb_page != NULL) { - struct inode *inode = req->wb_context->path.dentry->d_inode; - struct nfs_inode *nfsi = NFS_I(inode); + struct inode *inode = req->wb_context->path.dentry->d_inode; + struct nfs_inode *nfsi = NFS_I(inode); + if (req->wb_page != NULL) { spin_lock(&inode->i_lock); radix_tree_tag_clear(&nfsi->nfs_page_tree, req->wb_index, NFS_PAGE_TAG_LOCKED); nfs_unlock_request(req); @@ -140,22 +142,16 @@ void nfs_clear_page_tag_locked(struct nfs_page *req) * nfs_clear_request - Free up all resources allocated to the request * @req: * - * Release page and open context resources associated with a read/write - * request after it has completed. + * Release page resources associated with a write request after it + * has completed. */ void nfs_clear_request(struct nfs_page *req) { struct page *page = req->wb_page; - struct nfs_open_context *ctx = req->wb_context; - if (page != NULL) { page_cache_release(page); req->wb_page = NULL; } - if (ctx != NULL) { - put_nfs_open_context(ctx); - req->wb_context = NULL; - } } @@ -169,8 +165,9 @@ static void nfs_free_request(struct kref *kref) { struct nfs_page *req = container_of(kref, struct nfs_page, wb_kref); - /* Release struct file and open context */ + /* Release struct file or cached credential */ nfs_clear_request(req); + put_nfs_open_context(req->wb_context); nfs_page_free(req); } diff --git a/trunk/fs/nfs/super.c b/trunk/fs/nfs/super.c index 6baf9a393466..f1afee4eea77 100644 --- a/trunk/fs/nfs/super.c +++ b/trunk/fs/nfs/super.c @@ -2214,7 +2214,7 @@ static int nfs_get_sb(struct file_system_type *fs_type, } else { error = nfs_bdi_register(server); if (error) - goto error_splat_bdi; + goto error_splat_super; } if (!s->s_root) { @@ -2256,9 +2256,6 @@ static int nfs_get_sb(struct file_system_type *fs_type, error_splat_root: dput(mntroot); error_splat_super: - if (server && !s->s_root) - bdi_unregister(&server->backing_dev_info); -error_splat_bdi: deactivate_locked_super(s); goto out; } @@ -2329,7 +2326,7 @@ static int nfs_xdev_get_sb(struct file_system_type *fs_type, int flags, } else { error = nfs_bdi_register(server); if (error) - goto error_splat_bdi; + goto error_splat_super; } if (!s->s_root) { @@ -2366,9 +2363,6 @@ static int nfs_xdev_get_sb(struct file_system_type *fs_type, int flags, return error; error_splat_super: - if (server && !s->s_root) - bdi_unregister(&server->backing_dev_info); -error_splat_bdi: deactivate_locked_super(s); dprintk("<-- nfs_xdev_get_sb() = %d [splat]\n", error); return error; @@ -2584,7 +2578,7 @@ static int nfs4_remote_get_sb(struct file_system_type *fs_type, } else { error = nfs_bdi_register(server); if (error) - goto error_splat_bdi; + goto error_splat_super; } if (!s->s_root) { @@ -2622,9 +2616,6 @@ static int nfs4_remote_get_sb(struct file_system_type *fs_type, error_splat_root: dput(mntroot); error_splat_super: - if (server && !s->s_root) - bdi_unregister(&server->backing_dev_info); -error_splat_bdi: deactivate_locked_super(s); goto out; } @@ -2820,7 +2811,7 @@ static int nfs4_xdev_get_sb(struct file_system_type *fs_type, int flags, } else { error = nfs_bdi_register(server); if (error) - goto error_splat_bdi; + goto error_splat_super; } if (!s->s_root) { @@ -2856,9 +2847,6 @@ static int nfs4_xdev_get_sb(struct file_system_type *fs_type, int flags, return error; error_splat_super: - if (server && !s->s_root) - bdi_unregister(&server->backing_dev_info); -error_splat_bdi: deactivate_locked_super(s); dprintk("<-- nfs4_xdev_get_sb() = %d [splat]\n", error); return error; @@ -2905,7 +2893,7 @@ static int nfs4_remote_referral_get_sb(struct file_system_type *fs_type, } else { error = nfs_bdi_register(server); if (error) - goto error_splat_bdi; + goto error_splat_super; } if (!s->s_root) { @@ -2941,9 +2929,6 @@ static int nfs4_remote_referral_get_sb(struct file_system_type *fs_type, return error; error_splat_super: - if (server && !s->s_root) - bdi_unregister(&server->backing_dev_info); -error_splat_bdi: deactivate_locked_super(s); dprintk("<-- nfs4_referral_get_sb() = %d [splat]\n", error); return error; diff --git a/trunk/fs/ntfs/super.c b/trunk/fs/ntfs/super.c index 0de1db6cddbf..1cf39dfaee7a 100644 --- a/trunk/fs/ntfs/super.c +++ b/trunk/fs/ntfs/super.c @@ -31,7 +31,6 @@ #include #include #include -#include #include "sysctl.h" #include "logfile.h" @@ -2459,6 +2458,7 @@ static void ntfs_put_super(struct super_block *sb) static s64 get_nr_free_clusters(ntfs_volume *vol) { s64 nr_free = vol->nr_clusters; + u32 *kaddr; struct address_space *mapping = vol->lcnbmp_ino->i_mapping; struct page *page; pgoff_t index, max_index; @@ -2477,8 +2477,7 @@ static s64 get_nr_free_clusters(ntfs_volume *vol) ntfs_debug("Reading $Bitmap, max_index = 0x%lx, max_size = 0x%lx.", max_index, PAGE_CACHE_SIZE / 4); for (index = 0; index < max_index; index++) { - unsigned long *kaddr; - + unsigned int i; /* * Read the page from page cache, getting it from backing store * if necessary, and increment the use count. @@ -2491,16 +2490,16 @@ static s64 get_nr_free_clusters(ntfs_volume *vol) nr_free -= PAGE_CACHE_SIZE * 8; continue; } - kaddr = kmap_atomic(page, KM_USER0); + kaddr = (u32*)kmap_atomic(page, KM_USER0); /* - * Subtract the number of set bits. If this + * For each 4 bytes, subtract the number of set bits. If this * is the last page and it is partial we don't really care as * it just means we do a little extra work but it won't affect * the result as all out of range bytes are set to zero by * ntfs_readpage(). */ - nr_free -= bitmap_weight(kaddr, - PAGE_CACHE_SIZE * BITS_PER_BYTE); + for (i = 0; i < PAGE_CACHE_SIZE / 4; i++) + nr_free -= (s64)hweight32(kaddr[i]); kunmap_atomic(kaddr, KM_USER0); page_cache_release(page); } @@ -2539,6 +2538,7 @@ static s64 get_nr_free_clusters(ntfs_volume *vol) static unsigned long __get_nr_free_mft_records(ntfs_volume *vol, s64 nr_free, const pgoff_t max_index) { + u32 *kaddr; struct address_space *mapping = vol->mftbmp_ino->i_mapping; struct page *page; pgoff_t index; @@ -2548,8 +2548,7 @@ static unsigned long __get_nr_free_mft_records(ntfs_volume *vol, ntfs_debug("Reading $MFT/$BITMAP, max_index = 0x%lx, max_size = " "0x%lx.", max_index, PAGE_CACHE_SIZE / 4); for (index = 0; index < max_index; index++) { - unsigned long *kaddr; - + unsigned int i; /* * Read the page from page cache, getting it from backing store * if necessary, and increment the use count. @@ -2562,16 +2561,16 @@ static unsigned long __get_nr_free_mft_records(ntfs_volume *vol, nr_free -= PAGE_CACHE_SIZE * 8; continue; } - kaddr = kmap_atomic(page, KM_USER0); + kaddr = (u32*)kmap_atomic(page, KM_USER0); /* - * Subtract the number of set bits. If this + * For each 4 bytes, subtract the number of set bits. If this * is the last page and it is partial we don't really care as * it just means we do a little extra work but it won't affect * the result as all out of range bytes are set to zero by * ntfs_readpage(). */ - nr_free -= bitmap_weight(kaddr, - PAGE_CACHE_SIZE * BITS_PER_BYTE); + for (i = 0; i < PAGE_CACHE_SIZE / 4; i++) + nr_free -= (s64)hweight32(kaddr[i]); kunmap_atomic(kaddr, KM_USER0); page_cache_release(page); } diff --git a/trunk/fs/xfs/linux-2.6/xfs_aops.c b/trunk/fs/xfs/linux-2.6/xfs_aops.c index 99628508cb11..9083357f9e44 100644 --- a/trunk/fs/xfs/linux-2.6/xfs_aops.c +++ b/trunk/fs/xfs/linux-2.6/xfs_aops.c @@ -932,9 +932,6 @@ xfs_aops_discard_page( if (!xfs_is_delayed_page(page, IOMAP_DELAY)) goto out_invalidate; - if (XFS_FORCED_SHUTDOWN(ip->i_mount)) - goto out_invalidate; - xfs_fs_cmn_err(CE_ALERT, ip->i_mount, "page discard on page %p, inode 0x%llx, offset %llu.", page, ip->i_ino, offset); @@ -967,10 +964,8 @@ xfs_aops_discard_page( if (error) { /* something screwed, just bail */ - if (!XFS_FORCED_SHUTDOWN(ip->i_mount)) { - xfs_fs_cmn_err(CE_ALERT, ip->i_mount, - "page discard failed delalloc mapping lookup."); - } + xfs_fs_cmn_err(CE_ALERT, ip->i_mount, + "page discard failed delalloc mapping lookup."); break; } if (!nimaps) { @@ -996,10 +991,8 @@ xfs_aops_discard_page( ASSERT(!flist.xbf_count && !flist.xbf_first); if (error) { /* something screwed, just bail */ - if (!XFS_FORCED_SHUTDOWN(ip->i_mount)) { - xfs_fs_cmn_err(CE_ALERT, ip->i_mount, + xfs_fs_cmn_err(CE_ALERT, ip->i_mount, "page discard unable to remove delalloc mapping."); - } break; } next_buffer: diff --git a/trunk/fs/xfs/linux-2.6/xfs_buf.c b/trunk/fs/xfs/linux-2.6/xfs_buf.c index bd111b7e1daa..6f76ba85f193 100644 --- a/trunk/fs/xfs/linux-2.6/xfs_buf.c +++ b/trunk/fs/xfs/linux-2.6/xfs_buf.c @@ -167,6 +167,75 @@ test_page_region( return (mask && (page_private(page) & mask) == mask); } +/* + * Mapping of multi-page buffers into contiguous virtual space + */ + +typedef struct a_list { + void *vm_addr; + struct a_list *next; +} a_list_t; + +static a_list_t *as_free_head; +static int as_list_len; +static DEFINE_SPINLOCK(as_lock); + +/* + * Try to batch vunmaps because they are costly. + */ +STATIC void +free_address( + void *addr) +{ + a_list_t *aentry; + +#ifdef CONFIG_XEN + /* + * Xen needs to be able to make sure it can get an exclusive + * RO mapping of pages it wants to turn into a pagetable. If + * a newly allocated page is also still being vmap()ed by xfs, + * it will cause pagetable construction to fail. This is a + * quick workaround to always eagerly unmap pages so that Xen + * is happy. + */ + vunmap(addr); + return; +#endif + + aentry = kmalloc(sizeof(a_list_t), GFP_NOWAIT); + if (likely(aentry)) { + spin_lock(&as_lock); + aentry->next = as_free_head; + aentry->vm_addr = addr; + as_free_head = aentry; + as_list_len++; + spin_unlock(&as_lock); + } else { + vunmap(addr); + } +} + +STATIC void +purge_addresses(void) +{ + a_list_t *aentry, *old; + + if (as_free_head == NULL) + return; + + spin_lock(&as_lock); + aentry = as_free_head; + as_free_head = NULL; + as_list_len = 0; + spin_unlock(&as_lock); + + while ((old = aentry) != NULL) { + vunmap(aentry->vm_addr); + aentry = aentry->next; + kfree(old); + } +} + /* * Internal xfs_buf_t object manipulation */ @@ -268,8 +337,7 @@ xfs_buf_free( uint i; if (xfs_buf_is_vmapped(bp)) - vm_unmap_ram(bp->b_addr - bp->b_offset, - bp->b_page_count); + free_address(bp->b_addr - bp->b_offset); for (i = 0; i < bp->b_page_count; i++) { struct page *page = bp->b_pages[i]; @@ -389,8 +457,10 @@ _xfs_buf_map_pages( bp->b_addr = page_address(bp->b_pages[0]) + bp->b_offset; bp->b_flags |= XBF_MAPPED; } else if (flags & XBF_MAPPED) { - bp->b_addr = vm_map_ram(bp->b_pages, bp->b_page_count, - -1, PAGE_KERNEL); + if (as_list_len > 64) + purge_addresses(); + bp->b_addr = vmap(bp->b_pages, bp->b_page_count, + VM_MAP, PAGE_KERNEL); if (unlikely(bp->b_addr == NULL)) return -ENOMEM; bp->b_addr += bp->b_offset; @@ -1885,6 +1955,9 @@ xfsbufd( xfs_buf_iostrategy(bp); count++; } + + if (as_list_len > 0) + purge_addresses(); if (count) blk_run_address_space(target->bt_mapping); diff --git a/trunk/include/linux/backlight.h b/trunk/include/linux/backlight.h index 4a3d52e545e1..8c4f884db6b4 100644 --- a/trunk/include/linux/backlight.h +++ b/trunk/include/linux/backlight.h @@ -36,18 +36,18 @@ struct backlight_device; struct fb_info; struct backlight_ops { - unsigned int options; + const unsigned int options; #define BL_CORE_SUSPENDRESUME (1 << 0) /* Notify the backlight driver some property has changed */ - int (*update_status)(struct backlight_device *); + int (* const update_status)(struct backlight_device *); /* Return the current backlight brightness (accounting for power, fb_blank etc.) */ - int (*get_brightness)(struct backlight_device *); + int (* const get_brightness)(struct backlight_device *); /* Check if given framebuffer device is the one bound to this backlight; return 0 if not, !=0 if it is. If NULL, backlight always matches the fb. */ - int (*check_fb)(struct backlight_device *, struct fb_info *); + int (* const check_fb)(struct fb_info *); }; /* This structure defines all the properties of a backlight */ @@ -103,8 +103,7 @@ static inline void backlight_update_status(struct backlight_device *bd) } extern struct backlight_device *backlight_device_register(const char *name, - struct device *dev, void *devdata, const struct backlight_ops *ops, - const struct backlight_properties *props); + struct device *dev, void *devdata, const struct backlight_ops *ops); extern void backlight_device_unregister(struct backlight_device *bd); extern void backlight_force_update(struct backlight_device *bd, enum backlight_update_reason reason); diff --git a/trunk/include/linux/ftrace_event.h b/trunk/include/linux/ftrace_event.h index c0f4b364c711..6b7c444ab8f6 100644 --- a/trunk/include/linux/ftrace_event.h +++ b/trunk/include/linux/ftrace_event.h @@ -131,12 +131,12 @@ struct ftrace_event_call { void *mod; void *data; - int perf_refcount; - int (*perf_event_enable)(struct ftrace_event_call *); - void (*perf_event_disable)(struct ftrace_event_call *); + int profile_count; + int (*profile_enable)(struct ftrace_event_call *); + void (*profile_disable)(struct ftrace_event_call *); }; -#define PERF_MAX_TRACE_SIZE 2048 +#define FTRACE_MAX_PROFILE_SIZE 2048 #define MAX_FILTER_PRED 32 #define MAX_FILTER_STR_VAL 256 /* Should handle KSYM_SYMBOL_LEN */ @@ -187,25 +187,22 @@ do { \ #ifdef CONFIG_PERF_EVENTS struct perf_event; - -DECLARE_PER_CPU(struct pt_regs, perf_trace_regs); - -extern int perf_trace_enable(int event_id); -extern void perf_trace_disable(int event_id); +extern int ftrace_profile_enable(int event_id); +extern void ftrace_profile_disable(int event_id); extern int ftrace_profile_set_filter(struct perf_event *event, int event_id, char *filter_str); extern void ftrace_profile_free_filter(struct perf_event *event); extern void * -perf_trace_buf_prepare(int size, unsigned short type, int *rctxp, +ftrace_perf_buf_prepare(int size, unsigned short type, int *rctxp, unsigned long *irq_flags); static inline void -perf_trace_buf_submit(void *raw_data, int size, int rctx, u64 addr, - u64 count, unsigned long irq_flags, struct pt_regs *regs) +ftrace_perf_buf_submit(void *raw_data, int size, int rctx, u64 addr, + u64 count, unsigned long irq_flags) { struct trace_entry *entry = raw_data; - perf_tp_event(entry->type, addr, count, raw_data, size, regs); + perf_tp_event(entry->type, addr, count, raw_data, size); perf_swevent_put_recursion_context(rctx); local_irq_restore(irq_flags); } diff --git a/trunk/include/linux/memory.h b/trunk/include/linux/memory.h index 85582e1bcee9..1adfe779eb99 100644 --- a/trunk/include/linux/memory.h +++ b/trunk/include/linux/memory.h @@ -36,8 +36,6 @@ struct memory_block { struct sys_device sysdev; }; -int arch_get_memory_phys_device(unsigned long start_pfn); - /* These states are exposed to userspace as text strings in sysfs */ #define MEM_ONLINE (1<<0) /* exposed to userspace */ #define MEM_GOING_OFFLINE (1<<1) /* exposed to userspace */ diff --git a/trunk/include/linux/perf_event.h b/trunk/include/linux/perf_event.h index 95477038a72a..6f8cd7da1a01 100644 --- a/trunk/include/linux/perf_event.h +++ b/trunk/include/linux/perf_event.h @@ -452,8 +452,6 @@ enum perf_callchain_context { #include #include #include -#include -#include #include #define PERF_MAX_STACK_DEPTH 255 @@ -849,44 +847,6 @@ perf_sw_event(u32 event_id, u64 nr, int nmi, struct pt_regs *regs, u64 addr) __perf_sw_event(event_id, nr, nmi, regs, addr); } -extern void -perf_arch_fetch_caller_regs(struct pt_regs *regs, unsigned long ip, int skip); - -/* - * Take a snapshot of the regs. Skip ip and frame pointer to - * the nth caller. We only need a few of the regs: - * - ip for PERF_SAMPLE_IP - * - cs for user_mode() tests - * - bp for callchains - * - eflags, for future purposes, just in case - */ -static inline void perf_fetch_caller_regs(struct pt_regs *regs, int skip) -{ - unsigned long ip; - - memset(regs, 0, sizeof(*regs)); - - switch (skip) { - case 1 : - ip = CALLER_ADDR0; - break; - case 2 : - ip = CALLER_ADDR1; - break; - case 3 : - ip = CALLER_ADDR2; - break; - case 4: - ip = CALLER_ADDR3; - break; - /* No need to support further for now */ - default: - ip = 0; - } - - return perf_arch_fetch_caller_regs(regs, ip, skip); -} - extern void __perf_event_mmap(struct vm_area_struct *vma); static inline void perf_event_mmap(struct vm_area_struct *vma) @@ -920,8 +880,7 @@ static inline bool perf_paranoid_kernel(void) } extern void perf_event_init(void); -extern void perf_tp_event(int event_id, u64 addr, u64 count, void *record, - int entry_size, struct pt_regs *regs); +extern void perf_tp_event(int event_id, u64 addr, u64 count, void *record, int entry_size); extern void perf_bp_event(struct perf_event *event, void *data); #ifndef perf_misc_flags @@ -977,21 +936,5 @@ static inline void perf_event_disable(struct perf_event *event) { } #define perf_output_put(handle, x) \ perf_output_copy((handle), &(x), sizeof(x)) -/* - * This has to have a higher priority than migration_notifier in sched.c. - */ -#define perf_cpu_notifier(fn) \ -do { \ - static struct notifier_block fn##_nb __cpuinitdata = \ - { .notifier_call = fn, .priority = 20 }; \ - fn(&fn##_nb, (unsigned long)CPU_UP_PREPARE, \ - (void *)(unsigned long)smp_processor_id()); \ - fn(&fn##_nb, (unsigned long)CPU_STARTING, \ - (void *)(unsigned long)smp_processor_id()); \ - fn(&fn##_nb, (unsigned long)CPU_ONLINE, \ - (void *)(unsigned long)smp_processor_id()); \ - register_cpu_notifier(&fn##_nb); \ -} while (0) - #endif /* __KERNEL__ */ #endif /* _LINUX_PERF_EVENT_H */ diff --git a/trunk/include/linux/spi/l4f00242t03.h b/trunk/include/linux/spi/l4f00242t03.h deleted file mode 100644 index aee1dbda4edc..000000000000 --- a/trunk/include/linux/spi/l4f00242t03.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * l4f00242t03.h -- Platform glue for Epson L4F00242T03 LCD - * - * Copyright (c) 2009 Alberto Panizzo - * Based on Marek Vasut work in lms283gf05.h - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef _INCLUDE_LINUX_SPI_L4F00242T03_H_ -#define _INCLUDE_LINUX_SPI_L4F00242T03_H_ - -struct l4f00242t03_pdata { - unsigned int reset_gpio; - unsigned int data_enable_gpio; - const char *io_supply; /* will be set to 1.8 V */ - const char *core_supply; /* will be set to 2.8 V */ -}; - -#endif /* _INCLUDE_LINUX_SPI_L4F00242T03_H_ */ diff --git a/trunk/include/linux/syscalls.h b/trunk/include/linux/syscalls.h index f994ae58a002..44f2ad0e8825 100644 --- a/trunk/include/linux/syscalls.h +++ b/trunk/include/linux/syscalls.h @@ -105,18 +105,18 @@ struct perf_event_attr; #ifdef CONFIG_PERF_EVENTS -#define TRACE_SYS_ENTER_PERF_INIT(sname) \ - .perf_event_enable = perf_sysenter_enable, \ - .perf_event_disable = perf_sysenter_disable, +#define TRACE_SYS_ENTER_PROFILE_INIT(sname) \ + .profile_enable = prof_sysenter_enable, \ + .profile_disable = prof_sysenter_disable, -#define TRACE_SYS_EXIT_PERF_INIT(sname) \ - .perf_event_enable = perf_sysexit_enable, \ - .perf_event_disable = perf_sysexit_disable, +#define TRACE_SYS_EXIT_PROFILE_INIT(sname) \ + .profile_enable = prof_sysexit_enable, \ + .profile_disable = prof_sysexit_disable, #else -#define TRACE_SYS_ENTER_PERF(sname) -#define TRACE_SYS_ENTER_PERF_INIT(sname) -#define TRACE_SYS_EXIT_PERF(sname) -#define TRACE_SYS_EXIT_PERF_INIT(sname) +#define TRACE_SYS_ENTER_PROFILE(sname) +#define TRACE_SYS_ENTER_PROFILE_INIT(sname) +#define TRACE_SYS_EXIT_PROFILE(sname) +#define TRACE_SYS_EXIT_PROFILE_INIT(sname) #endif /* CONFIG_PERF_EVENTS */ #ifdef CONFIG_FTRACE_SYSCALLS @@ -153,7 +153,7 @@ struct perf_event_attr; .regfunc = reg_event_syscall_enter, \ .unregfunc = unreg_event_syscall_enter, \ .data = (void *)&__syscall_meta_##sname,\ - TRACE_SYS_ENTER_PERF_INIT(sname) \ + TRACE_SYS_ENTER_PROFILE_INIT(sname) \ } #define SYSCALL_TRACE_EXIT_EVENT(sname) \ @@ -175,7 +175,7 @@ struct perf_event_attr; .regfunc = reg_event_syscall_exit, \ .unregfunc = unreg_event_syscall_exit, \ .data = (void *)&__syscall_meta_##sname,\ - TRACE_SYS_EXIT_PERF_INIT(sname) \ + TRACE_SYS_EXIT_PROFILE_INIT(sname) \ } #define SYSCALL_METADATA(sname, nb) \ diff --git a/trunk/include/scsi/libiscsi.h b/trunk/include/scsi/libiscsi.h index ae5196aae1a5..ff92b46f5153 100644 --- a/trunk/include/scsi/libiscsi.h +++ b/trunk/include/scsi/libiscsi.h @@ -338,8 +338,7 @@ struct iscsi_host { extern int iscsi_change_queue_depth(struct scsi_device *sdev, int depth, int reason); extern int iscsi_eh_abort(struct scsi_cmnd *sc); -extern int iscsi_eh_recover_target(struct scsi_cmnd *sc); -extern int iscsi_eh_session_reset(struct scsi_cmnd *sc); +extern int iscsi_eh_target_reset(struct scsi_cmnd *sc); extern int iscsi_eh_device_reset(struct scsi_cmnd *sc); extern int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)); diff --git a/trunk/include/trace/ftrace.h b/trunk/include/trace/ftrace.h index ea6f9d4a20e9..601ad7744247 100644 --- a/trunk/include/trace/ftrace.h +++ b/trunk/include/trace/ftrace.h @@ -401,18 +401,18 @@ static inline notrace int ftrace_get_offsets_##call( \ #undef DEFINE_EVENT #define DEFINE_EVENT(template, name, proto, args) \ \ -static void perf_trace_##name(proto); \ +static void ftrace_profile_##name(proto); \ \ static notrace int \ -perf_trace_enable_##name(struct ftrace_event_call *unused) \ +ftrace_profile_enable_##name(struct ftrace_event_call *unused) \ { \ - return register_trace_##name(perf_trace_##name); \ + return register_trace_##name(ftrace_profile_##name); \ } \ \ static notrace void \ -perf_trace_disable_##name(struct ftrace_event_call *unused) \ +ftrace_profile_disable_##name(struct ftrace_event_call *unused) \ { \ - unregister_trace_##name(perf_trace_##name); \ + unregister_trace_##name(ftrace_profile_##name); \ } #undef DEFINE_EVENT_PRINT @@ -507,12 +507,12 @@ perf_trace_disable_##name(struct ftrace_event_call *unused) \ #ifdef CONFIG_PERF_EVENTS -#define _TRACE_PERF_INIT(call) \ - .perf_event_enable = perf_trace_enable_##call, \ - .perf_event_disable = perf_trace_disable_##call, +#define _TRACE_PROFILE_INIT(call) \ + .profile_enable = ftrace_profile_enable_##call, \ + .profile_disable = ftrace_profile_disable_##call, #else -#define _TRACE_PERF_INIT(call) +#define _TRACE_PROFILE_INIT(call) #endif /* CONFIG_PERF_EVENTS */ #undef __entry @@ -638,7 +638,7 @@ __attribute__((section("_ftrace_events"))) event_##call = { \ .unregfunc = ftrace_raw_unreg_event_##call, \ .print_fmt = print_fmt_##template, \ .define_fields = ftrace_define_fields_##template, \ - _TRACE_PERF_INIT(call) \ + _TRACE_PROFILE_INIT(call) \ } #undef DEFINE_EVENT_PRINT @@ -657,18 +657,18 @@ __attribute__((section("_ftrace_events"))) event_##call = { \ .unregfunc = ftrace_raw_unreg_event_##call, \ .print_fmt = print_fmt_##call, \ .define_fields = ftrace_define_fields_##template, \ - _TRACE_PERF_INIT(call) \ + _TRACE_PROFILE_INIT(call) \ } #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) /* - * Define the insertion callback to perf events + * Define the insertion callback to profile events * * The job is very similar to ftrace_raw_event_ except that we don't * insert in the ring buffer but in a perf counter. * - * static void ftrace_perf_(proto) + * static void ftrace_profile_(proto) * { * struct ftrace_data_offsets_ __maybe_unused __data_offsets; * struct ftrace_event_call *event_call = &event_; @@ -757,14 +757,13 @@ __attribute__((section("_ftrace_events"))) event_##call = { \ #undef DECLARE_EVENT_CLASS #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ static notrace void \ -perf_trace_templ_##call(struct ftrace_event_call *event_call, \ +ftrace_profile_templ_##call(struct ftrace_event_call *event_call, \ proto) \ { \ struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\ struct ftrace_raw_##call *entry; \ u64 __addr = 0, __count = 1; \ unsigned long irq_flags; \ - struct pt_regs *__regs; \ int __entry_size; \ int __data_size; \ int rctx; \ @@ -774,10 +773,10 @@ perf_trace_templ_##call(struct ftrace_event_call *event_call, \ sizeof(u64)); \ __entry_size -= sizeof(u32); \ \ - if (WARN_ONCE(__entry_size > PERF_MAX_TRACE_SIZE, \ + if (WARN_ONCE(__entry_size > FTRACE_MAX_PROFILE_SIZE, \ "profile buffer not large enough")) \ return; \ - entry = (struct ftrace_raw_##call *)perf_trace_buf_prepare( \ + entry = (struct ftrace_raw_##call *)ftrace_perf_buf_prepare( \ __entry_size, event_call->id, &rctx, &irq_flags); \ if (!entry) \ return; \ @@ -785,20 +784,17 @@ perf_trace_templ_##call(struct ftrace_event_call *event_call, \ \ { assign; } \ \ - __regs = &__get_cpu_var(perf_trace_regs); \ - perf_fetch_caller_regs(__regs, 2); \ - \ - perf_trace_buf_submit(entry, __entry_size, rctx, __addr, \ - __count, irq_flags, __regs); \ + ftrace_perf_buf_submit(entry, __entry_size, rctx, __addr, \ + __count, irq_flags); \ } #undef DEFINE_EVENT #define DEFINE_EVENT(template, call, proto, args) \ -static notrace void perf_trace_##call(proto) \ +static notrace void ftrace_profile_##call(proto) \ { \ struct ftrace_event_call *event_call = &event_##call; \ \ - perf_trace_templ_##template(event_call, args); \ + ftrace_profile_templ_##template(event_call, args); \ } #undef DEFINE_EVENT_PRINT diff --git a/trunk/include/trace/syscall.h b/trunk/include/trace/syscall.h index e5e5f48dbfb3..0387100752f0 100644 --- a/trunk/include/trace/syscall.h +++ b/trunk/include/trace/syscall.h @@ -47,10 +47,10 @@ enum print_line_t print_syscall_exit(struct trace_iterator *iter, int flags); #endif #ifdef CONFIG_PERF_EVENTS -int perf_sysenter_enable(struct ftrace_event_call *call); -void perf_sysenter_disable(struct ftrace_event_call *call); -int perf_sysexit_enable(struct ftrace_event_call *call); -void perf_sysexit_disable(struct ftrace_event_call *call); +int prof_sysenter_enable(struct ftrace_event_call *call); +void prof_sysenter_disable(struct ftrace_event_call *call); +int prof_sysexit_enable(struct ftrace_event_call *call); +void prof_sysexit_disable(struct ftrace_event_call *call); #endif #endif /* _TRACE_SYSCALL_H */ diff --git a/trunk/kernel/kprobes.c b/trunk/kernel/kprobes.c index 0ed46f3e51e9..fa034d29cf73 100644 --- a/trunk/kernel/kprobes.c +++ b/trunk/kernel/kprobes.c @@ -259,8 +259,7 @@ static void __kprobes __free_insn_slot(struct kprobe_insn_cache *c, struct kprobe_insn_page *kip; list_for_each_entry(kip, &c->pages, list) { - long idx = ((long)slot - (long)kip->insns) / - (c->insn_size * sizeof(kprobe_opcode_t)); + long idx = ((long)slot - (long)kip->insns) / c->insn_size; if (idx >= 0 && idx < slots_per_page(c)) { WARN_ON(kip->slot_used[idx] != SLOT_USED); if (dirty) { diff --git a/trunk/kernel/lockdep.c b/trunk/kernel/lockdep.c index c927a549db2c..681bc2e1e187 100644 --- a/trunk/kernel/lockdep.c +++ b/trunk/kernel/lockdep.c @@ -3211,6 +3211,8 @@ void lock_acquire(struct lockdep_map *lock, unsigned int subclass, { unsigned long flags; + trace_lock_acquire(lock, subclass, trylock, read, check, nest_lock, ip); + if (unlikely(current->lockdep_recursion)) return; @@ -3218,7 +3220,6 @@ void lock_acquire(struct lockdep_map *lock, unsigned int subclass, check_flags(flags); current->lockdep_recursion = 1; - trace_lock_acquire(lock, subclass, trylock, read, check, nest_lock, ip); __lock_acquire(lock, subclass, trylock, read, check, irqs_disabled_flags(flags), nest_lock, ip, 0); current->lockdep_recursion = 0; @@ -3231,13 +3232,14 @@ void lock_release(struct lockdep_map *lock, int nested, { unsigned long flags; + trace_lock_release(lock, nested, ip); + if (unlikely(current->lockdep_recursion)) return; raw_local_irq_save(flags); check_flags(flags); current->lockdep_recursion = 1; - trace_lock_release(lock, nested, ip); __lock_release(lock, nested, ip); current->lockdep_recursion = 0; raw_local_irq_restore(flags); @@ -3411,6 +3413,8 @@ void lock_contended(struct lockdep_map *lock, unsigned long ip) { unsigned long flags; + trace_lock_contended(lock, ip); + if (unlikely(!lock_stat)) return; @@ -3420,7 +3424,6 @@ void lock_contended(struct lockdep_map *lock, unsigned long ip) raw_local_irq_save(flags); check_flags(flags); current->lockdep_recursion = 1; - trace_lock_contended(lock, ip); __lock_contended(lock, ip); current->lockdep_recursion = 0; raw_local_irq_restore(flags); diff --git a/trunk/kernel/perf_event.c b/trunk/kernel/perf_event.c index 574ee58a3046..4393b9e73740 100644 --- a/trunk/kernel/perf_event.c +++ b/trunk/kernel/perf_event.c @@ -81,6 +81,10 @@ extern __weak const struct pmu *hw_perf_event_init(struct perf_event *event) void __weak hw_perf_disable(void) { barrier(); } void __weak hw_perf_enable(void) { barrier(); } +void __weak hw_perf_event_setup(int cpu) { barrier(); } +void __weak hw_perf_event_setup_online(int cpu) { barrier(); } +void __weak hw_perf_event_setup_offline(int cpu) { barrier(); } + int __weak hw_perf_group_sched_in(struct perf_event *group_leader, struct perf_cpu_context *cpuctx, @@ -93,15 +97,25 @@ void __weak perf_event_print_debug(void) { } static DEFINE_PER_CPU(int, perf_disable_count); +void __perf_disable(void) +{ + __get_cpu_var(perf_disable_count)++; +} + +bool __perf_enable(void) +{ + return !--__get_cpu_var(perf_disable_count); +} + void perf_disable(void) { - if (!__get_cpu_var(perf_disable_count)++) - hw_perf_disable(); + __perf_disable(); + hw_perf_disable(); } void perf_enable(void) { - if (!--__get_cpu_var(perf_disable_count)) + if (__perf_enable()) hw_perf_enable(); } @@ -1524,15 +1538,12 @@ static void perf_ctx_adjust_freq(struct perf_event_context *ctx) */ if (interrupts == MAX_INTERRUPTS) { perf_log_throttle(event, 1); - perf_disable(); event->pmu->unthrottle(event); - perf_enable(); } if (!event->attr.freq || !event->attr.sample_freq) continue; - perf_disable(); event->pmu->read(event); now = atomic64_read(&event->count); delta = now - hwc->freq_count_stamp; @@ -1540,7 +1551,6 @@ static void perf_ctx_adjust_freq(struct perf_event_context *ctx) if (delta > 0) perf_adjust_period(event, TICK_NSEC, delta); - perf_enable(); } raw_spin_unlock(&ctx->lock); } @@ -1550,6 +1560,9 @@ static void perf_ctx_adjust_freq(struct perf_event_context *ctx) */ static void rotate_ctx(struct perf_event_context *ctx) { + if (!ctx->nr_events) + return; + raw_spin_lock(&ctx->lock); /* Rotate the first entry last of non-pinned groups */ @@ -1562,28 +1575,19 @@ void perf_event_task_tick(struct task_struct *curr) { struct perf_cpu_context *cpuctx; struct perf_event_context *ctx; - int rotate = 0; if (!atomic_read(&nr_events)) return; cpuctx = &__get_cpu_var(perf_cpu_context); - if (cpuctx->ctx.nr_events && - cpuctx->ctx.nr_events != cpuctx->ctx.nr_active) - rotate = 1; - ctx = curr->perf_event_ctxp; - if (ctx && ctx->nr_events && ctx->nr_events != ctx->nr_active) - rotate = 1; + + perf_disable(); perf_ctx_adjust_freq(&cpuctx->ctx); if (ctx) perf_ctx_adjust_freq(ctx); - if (!rotate) - return; - - perf_disable(); cpu_ctx_sched_out(cpuctx, EVENT_FLEXIBLE); if (ctx) task_ctx_sched_out(ctx, EVENT_FLEXIBLE); @@ -1595,6 +1599,7 @@ void perf_event_task_tick(struct task_struct *curr) cpu_ctx_sched_in(cpuctx, EVENT_FLEXIBLE); if (ctx) task_ctx_sched_in(curr, EVENT_FLEXIBLE); + perf_enable(); } @@ -2786,13 +2791,6 @@ __weak struct perf_callchain_entry *perf_callchain(struct pt_regs *regs) return NULL; } -#ifdef CONFIG_EVENT_TRACING -__weak -void perf_arch_fetch_caller_regs(struct pt_regs *regs, unsigned long ip, int skip) -{ -} -#endif - /* * Output */ @@ -4320,8 +4318,9 @@ static const struct pmu perf_ops_task_clock = { #ifdef CONFIG_EVENT_TRACING void perf_tp_event(int event_id, u64 addr, u64 count, void *record, - int entry_size, struct pt_regs *regs) + int entry_size) { + struct pt_regs *regs = get_irq_regs(); struct perf_sample_data data; struct perf_raw_record raw = { .size = entry_size, @@ -4331,9 +4330,12 @@ void perf_tp_event(int event_id, u64 addr, u64 count, void *record, perf_sample_data_init(&data, addr); data.raw = &raw; + if (!regs) + regs = task_pt_regs(current); + /* Trace events already protected against recursion */ do_perf_sw_event(PERF_TYPE_TRACEPOINT, event_id, count, 1, - &data, regs); + &data, regs); } EXPORT_SYMBOL_GPL(perf_tp_event); @@ -4349,7 +4351,7 @@ static int perf_tp_event_match(struct perf_event *event, static void tp_perf_event_destroy(struct perf_event *event) { - perf_trace_disable(event->attr.config); + ftrace_profile_disable(event->attr.config); } static const struct pmu *tp_perf_event_init(struct perf_event *event) @@ -4363,7 +4365,7 @@ static const struct pmu *tp_perf_event_init(struct perf_event *event) !capable(CAP_SYS_ADMIN)) return ERR_PTR(-EPERM); - if (perf_trace_enable(event->attr.config)) + if (ftrace_profile_enable(event->attr.config)) return NULL; event->destroy = tp_perf_event_destroy; @@ -5370,26 +5372,18 @@ int perf_event_init_task(struct task_struct *child) return ret; } -static void __init perf_event_init_all_cpus(void) -{ - int cpu; - struct perf_cpu_context *cpuctx; - - for_each_possible_cpu(cpu) { - cpuctx = &per_cpu(perf_cpu_context, cpu); - __perf_event_init_context(&cpuctx->ctx, NULL); - } -} - static void __cpuinit perf_event_init_cpu(int cpu) { struct perf_cpu_context *cpuctx; cpuctx = &per_cpu(perf_cpu_context, cpu); + __perf_event_init_context(&cpuctx->ctx, NULL); spin_lock(&perf_resource_lock); cpuctx->max_pertask = perf_max_events - perf_reserved_percpu; spin_unlock(&perf_resource_lock); + + hw_perf_event_setup(cpu); } #ifdef CONFIG_HOTPLUG_CPU @@ -5429,11 +5423,20 @@ perf_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) perf_event_init_cpu(cpu); break; + case CPU_ONLINE: + case CPU_ONLINE_FROZEN: + hw_perf_event_setup_online(cpu); + break; + case CPU_DOWN_PREPARE: case CPU_DOWN_PREPARE_FROZEN: perf_event_exit_cpu(cpu); break; + case CPU_DEAD: + hw_perf_event_setup_offline(cpu); + break; + default: break; } @@ -5451,7 +5454,6 @@ static struct notifier_block __cpuinitdata perf_cpu_nb = { void __init perf_event_init(void) { - perf_event_init_all_cpus(); perf_cpu_notify(&perf_cpu_nb, (unsigned long)CPU_UP_PREPARE, (void *)(long)smp_processor_id()); perf_cpu_notify(&perf_cpu_nb, (unsigned long)CPU_ONLINE, diff --git a/trunk/kernel/trace/Makefile b/trunk/kernel/trace/Makefile index 78edc6490038..d00c6fe23f54 100644 --- a/trunk/kernel/trace/Makefile +++ b/trunk/kernel/trace/Makefile @@ -52,7 +52,7 @@ obj-$(CONFIG_EVENT_TRACING) += trace_events.o obj-$(CONFIG_EVENT_TRACING) += trace_export.o obj-$(CONFIG_FTRACE_SYSCALLS) += trace_syscalls.o ifeq ($(CONFIG_PERF_EVENTS),y) -obj-$(CONFIG_EVENT_TRACING) += trace_event_perf.o +obj-$(CONFIG_EVENT_TRACING) += trace_event_profile.o endif obj-$(CONFIG_EVENT_TRACING) += trace_events_filter.o obj-$(CONFIG_KPROBE_EVENT) += trace_kprobe.o diff --git a/trunk/kernel/trace/trace_event_perf.c b/trunk/kernel/trace/trace_event_profile.c similarity index 68% rename from trunk/kernel/trace/trace_event_perf.c rename to trunk/kernel/trace/trace_event_profile.c index 81f691eb3a30..c1cc3ab633de 100644 --- a/trunk/kernel/trace/trace_event_perf.c +++ b/trunk/kernel/trace/trace_event_profile.c @@ -1,36 +1,32 @@ /* - * trace event based perf event profiling/tracing + * trace event based perf counter profiling * * Copyright (C) 2009 Red Hat Inc, Peter Zijlstra - * Copyright (C) 2009-2010 Frederic Weisbecker + * */ #include #include #include "trace.h" -DEFINE_PER_CPU(struct pt_regs, perf_trace_regs); -EXPORT_PER_CPU_SYMBOL_GPL(perf_trace_regs); - -EXPORT_SYMBOL_GPL(perf_arch_fetch_caller_regs); static char *perf_trace_buf; static char *perf_trace_buf_nmi; -typedef typeof(char [PERF_MAX_TRACE_SIZE]) perf_trace_t ; +typedef typeof(char [FTRACE_MAX_PROFILE_SIZE]) perf_trace_t ; /* Count the events in use (per event id, not per instance) */ -static int total_ref_count; +static int total_profile_count; -static int perf_trace_event_enable(struct ftrace_event_call *event) +static int ftrace_profile_enable_event(struct ftrace_event_call *event) { char *buf; int ret = -ENOMEM; - if (event->perf_refcount++ > 0) + if (event->profile_count++ > 0) return 0; - if (!total_ref_count) { + if (!total_profile_count) { buf = (char *)alloc_percpu(perf_trace_t); if (!buf) goto fail_buf; @@ -44,35 +40,35 @@ static int perf_trace_event_enable(struct ftrace_event_call *event) rcu_assign_pointer(perf_trace_buf_nmi, buf); } - ret = event->perf_event_enable(event); + ret = event->profile_enable(event); if (!ret) { - total_ref_count++; + total_profile_count++; return 0; } fail_buf_nmi: - if (!total_ref_count) { + if (!total_profile_count) { free_percpu(perf_trace_buf_nmi); free_percpu(perf_trace_buf); perf_trace_buf_nmi = NULL; perf_trace_buf = NULL; } fail_buf: - event->perf_refcount--; + event->profile_count--; return ret; } -int perf_trace_enable(int event_id) +int ftrace_profile_enable(int event_id) { struct ftrace_event_call *event; int ret = -EINVAL; mutex_lock(&event_mutex); list_for_each_entry(event, &ftrace_events, list) { - if (event->id == event_id && event->perf_event_enable && + if (event->id == event_id && event->profile_enable && try_module_get(event->mod)) { - ret = perf_trace_event_enable(event); + ret = ftrace_profile_enable_event(event); break; } } @@ -81,16 +77,16 @@ int perf_trace_enable(int event_id) return ret; } -static void perf_trace_event_disable(struct ftrace_event_call *event) +static void ftrace_profile_disable_event(struct ftrace_event_call *event) { char *buf, *nmi_buf; - if (--event->perf_refcount > 0) + if (--event->profile_count > 0) return; - event->perf_event_disable(event); + event->profile_disable(event); - if (!--total_ref_count) { + if (!--total_profile_count) { buf = perf_trace_buf; rcu_assign_pointer(perf_trace_buf, NULL); @@ -108,14 +104,14 @@ static void perf_trace_event_disable(struct ftrace_event_call *event) } } -void perf_trace_disable(int event_id) +void ftrace_profile_disable(int event_id) { struct ftrace_event_call *event; mutex_lock(&event_mutex); list_for_each_entry(event, &ftrace_events, list) { if (event->id == event_id) { - perf_trace_event_disable(event); + ftrace_profile_disable_event(event); module_put(event->mod); break; } @@ -123,8 +119,8 @@ void perf_trace_disable(int event_id) mutex_unlock(&event_mutex); } -__kprobes void *perf_trace_buf_prepare(int size, unsigned short type, - int *rctxp, unsigned long *irq_flags) +__kprobes void *ftrace_perf_buf_prepare(int size, unsigned short type, + int *rctxp, unsigned long *irq_flags) { struct trace_entry *entry; char *trace_buf, *raw_data; @@ -165,4 +161,4 @@ __kprobes void *perf_trace_buf_prepare(int size, unsigned short type, local_irq_restore(*irq_flags); return NULL; } -EXPORT_SYMBOL_GPL(perf_trace_buf_prepare); +EXPORT_SYMBOL_GPL(ftrace_perf_buf_prepare); diff --git a/trunk/kernel/trace/trace_events.c b/trunk/kernel/trace/trace_events.c index beab8bf2f310..3f972ad98d04 100644 --- a/trunk/kernel/trace/trace_events.c +++ b/trunk/kernel/trace/trace_events.c @@ -938,7 +938,7 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events, trace_create_file("enable", 0644, call->dir, call, enable); - if (call->id && call->perf_event_enable) + if (call->id && call->profile_enable) trace_create_file("id", 0444, call->dir, call, id); diff --git a/trunk/kernel/trace/trace_kprobe.c b/trunk/kernel/trace/trace_kprobe.c index 1251e367bae9..505c92273b1a 100644 --- a/trunk/kernel/trace/trace_kprobe.c +++ b/trunk/kernel/trace/trace_kprobe.c @@ -1214,7 +1214,7 @@ static int set_print_fmt(struct trace_probe *tp) #ifdef CONFIG_PERF_EVENTS /* Kprobe profile handler */ -static __kprobes void kprobe_perf_func(struct kprobe *kp, +static __kprobes void kprobe_profile_func(struct kprobe *kp, struct pt_regs *regs) { struct trace_probe *tp = container_of(kp, struct trace_probe, rp.kp); @@ -1227,11 +1227,11 @@ static __kprobes void kprobe_perf_func(struct kprobe *kp, __size = SIZEOF_KPROBE_TRACE_ENTRY(tp->nr_args); size = ALIGN(__size + sizeof(u32), sizeof(u64)); size -= sizeof(u32); - if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE, + if (WARN_ONCE(size > FTRACE_MAX_PROFILE_SIZE, "profile buffer not large enough")) return; - entry = perf_trace_buf_prepare(size, call->id, &rctx, &irq_flags); + entry = ftrace_perf_buf_prepare(size, call->id, &rctx, &irq_flags); if (!entry) return; @@ -1240,11 +1240,11 @@ static __kprobes void kprobe_perf_func(struct kprobe *kp, for (i = 0; i < tp->nr_args; i++) entry->args[i] = call_fetch(&tp->args[i].fetch, regs); - perf_trace_buf_submit(entry, size, rctx, entry->ip, 1, irq_flags, regs); + ftrace_perf_buf_submit(entry, size, rctx, entry->ip, 1, irq_flags); } /* Kretprobe profile handler */ -static __kprobes void kretprobe_perf_func(struct kretprobe_instance *ri, +static __kprobes void kretprobe_profile_func(struct kretprobe_instance *ri, struct pt_regs *regs) { struct trace_probe *tp = container_of(ri->rp, struct trace_probe, rp); @@ -1257,11 +1257,11 @@ static __kprobes void kretprobe_perf_func(struct kretprobe_instance *ri, __size = SIZEOF_KRETPROBE_TRACE_ENTRY(tp->nr_args); size = ALIGN(__size + sizeof(u32), sizeof(u64)); size -= sizeof(u32); - if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE, + if (WARN_ONCE(size > FTRACE_MAX_PROFILE_SIZE, "profile buffer not large enough")) return; - entry = perf_trace_buf_prepare(size, call->id, &rctx, &irq_flags); + entry = ftrace_perf_buf_prepare(size, call->id, &rctx, &irq_flags); if (!entry) return; @@ -1271,11 +1271,10 @@ static __kprobes void kretprobe_perf_func(struct kretprobe_instance *ri, for (i = 0; i < tp->nr_args; i++) entry->args[i] = call_fetch(&tp->args[i].fetch, regs); - perf_trace_buf_submit(entry, size, rctx, entry->ret_ip, 1, - irq_flags, regs); + ftrace_perf_buf_submit(entry, size, rctx, entry->ret_ip, 1, irq_flags); } -static int probe_perf_enable(struct ftrace_event_call *call) +static int probe_profile_enable(struct ftrace_event_call *call) { struct trace_probe *tp = (struct trace_probe *)call->data; @@ -1287,7 +1286,7 @@ static int probe_perf_enable(struct ftrace_event_call *call) return enable_kprobe(&tp->rp.kp); } -static void probe_perf_disable(struct ftrace_event_call *call) +static void probe_profile_disable(struct ftrace_event_call *call) { struct trace_probe *tp = (struct trace_probe *)call->data; @@ -1312,7 +1311,7 @@ int kprobe_dispatcher(struct kprobe *kp, struct pt_regs *regs) kprobe_trace_func(kp, regs); #ifdef CONFIG_PERF_EVENTS if (tp->flags & TP_FLAG_PROFILE) - kprobe_perf_func(kp, regs); + kprobe_profile_func(kp, regs); #endif return 0; /* We don't tweek kernel, so just return 0 */ } @@ -1326,7 +1325,7 @@ int kretprobe_dispatcher(struct kretprobe_instance *ri, struct pt_regs *regs) kretprobe_trace_func(ri, regs); #ifdef CONFIG_PERF_EVENTS if (tp->flags & TP_FLAG_PROFILE) - kretprobe_perf_func(ri, regs); + kretprobe_profile_func(ri, regs); #endif return 0; /* We don't tweek kernel, so just return 0 */ } @@ -1359,8 +1358,8 @@ static int register_probe_event(struct trace_probe *tp) call->unregfunc = probe_event_disable; #ifdef CONFIG_PERF_EVENTS - call->perf_event_enable = probe_perf_enable; - call->perf_event_disable = probe_perf_disable; + call->profile_enable = probe_profile_enable; + call->profile_disable = probe_profile_disable; #endif call->data = tp; ret = trace_add_event_call(call); diff --git a/trunk/kernel/trace/trace_syscalls.c b/trunk/kernel/trace/trace_syscalls.c index 33c2a5b769dc..cba47d7935cc 100644 --- a/trunk/kernel/trace/trace_syscalls.c +++ b/trunk/kernel/trace/trace_syscalls.c @@ -428,12 +428,12 @@ core_initcall(init_ftrace_syscalls); #ifdef CONFIG_PERF_EVENTS -static DECLARE_BITMAP(enabled_perf_enter_syscalls, NR_syscalls); -static DECLARE_BITMAP(enabled_perf_exit_syscalls, NR_syscalls); -static int sys_perf_refcount_enter; -static int sys_perf_refcount_exit; +static DECLARE_BITMAP(enabled_prof_enter_syscalls, NR_syscalls); +static DECLARE_BITMAP(enabled_prof_exit_syscalls, NR_syscalls); +static int sys_prof_refcount_enter; +static int sys_prof_refcount_exit; -static void perf_syscall_enter(struct pt_regs *regs, long id) +static void prof_syscall_enter(struct pt_regs *regs, long id) { struct syscall_metadata *sys_data; struct syscall_trace_enter *rec; @@ -443,7 +443,7 @@ static void perf_syscall_enter(struct pt_regs *regs, long id) int size; syscall_nr = syscall_get_nr(current, regs); - if (!test_bit(syscall_nr, enabled_perf_enter_syscalls)) + if (!test_bit(syscall_nr, enabled_prof_enter_syscalls)) return; sys_data = syscall_nr_to_meta(syscall_nr); @@ -455,11 +455,11 @@ static void perf_syscall_enter(struct pt_regs *regs, long id) size = ALIGN(size + sizeof(u32), sizeof(u64)); size -= sizeof(u32); - if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE, - "perf buffer not large enough")) + if (WARN_ONCE(size > FTRACE_MAX_PROFILE_SIZE, + "profile buffer not large enough")) return; - rec = (struct syscall_trace_enter *)perf_trace_buf_prepare(size, + rec = (struct syscall_trace_enter *)ftrace_perf_buf_prepare(size, sys_data->enter_event->id, &rctx, &flags); if (!rec) return; @@ -467,10 +467,10 @@ static void perf_syscall_enter(struct pt_regs *regs, long id) rec->nr = syscall_nr; syscall_get_arguments(current, regs, 0, sys_data->nb_args, (unsigned long *)&rec->args); - perf_trace_buf_submit(rec, size, rctx, 0, 1, flags, regs); + ftrace_perf_buf_submit(rec, size, rctx, 0, 1, flags); } -int perf_sysenter_enable(struct ftrace_event_call *call) +int prof_sysenter_enable(struct ftrace_event_call *call) { int ret = 0; int num; @@ -478,34 +478,34 @@ int perf_sysenter_enable(struct ftrace_event_call *call) num = ((struct syscall_metadata *)call->data)->syscall_nr; mutex_lock(&syscall_trace_lock); - if (!sys_perf_refcount_enter) - ret = register_trace_sys_enter(perf_syscall_enter); + if (!sys_prof_refcount_enter) + ret = register_trace_sys_enter(prof_syscall_enter); if (ret) { pr_info("event trace: Could not activate" "syscall entry trace point"); } else { - set_bit(num, enabled_perf_enter_syscalls); - sys_perf_refcount_enter++; + set_bit(num, enabled_prof_enter_syscalls); + sys_prof_refcount_enter++; } mutex_unlock(&syscall_trace_lock); return ret; } -void perf_sysenter_disable(struct ftrace_event_call *call) +void prof_sysenter_disable(struct ftrace_event_call *call) { int num; num = ((struct syscall_metadata *)call->data)->syscall_nr; mutex_lock(&syscall_trace_lock); - sys_perf_refcount_enter--; - clear_bit(num, enabled_perf_enter_syscalls); - if (!sys_perf_refcount_enter) - unregister_trace_sys_enter(perf_syscall_enter); + sys_prof_refcount_enter--; + clear_bit(num, enabled_prof_enter_syscalls); + if (!sys_prof_refcount_enter) + unregister_trace_sys_enter(prof_syscall_enter); mutex_unlock(&syscall_trace_lock); } -static void perf_syscall_exit(struct pt_regs *regs, long ret) +static void prof_syscall_exit(struct pt_regs *regs, long ret) { struct syscall_metadata *sys_data; struct syscall_trace_exit *rec; @@ -515,7 +515,7 @@ static void perf_syscall_exit(struct pt_regs *regs, long ret) int size; syscall_nr = syscall_get_nr(current, regs); - if (!test_bit(syscall_nr, enabled_perf_exit_syscalls)) + if (!test_bit(syscall_nr, enabled_prof_exit_syscalls)) return; sys_data = syscall_nr_to_meta(syscall_nr); @@ -530,11 +530,11 @@ static void perf_syscall_exit(struct pt_regs *regs, long ret) * Impossible, but be paranoid with the future * How to put this check outside runtime? */ - if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE, - "exit event has grown above perf buffer size")) + if (WARN_ONCE(size > FTRACE_MAX_PROFILE_SIZE, + "exit event has grown above profile buffer size")) return; - rec = (struct syscall_trace_exit *)perf_trace_buf_prepare(size, + rec = (struct syscall_trace_exit *)ftrace_perf_buf_prepare(size, sys_data->exit_event->id, &rctx, &flags); if (!rec) return; @@ -542,10 +542,10 @@ static void perf_syscall_exit(struct pt_regs *regs, long ret) rec->nr = syscall_nr; rec->ret = syscall_get_return_value(current, regs); - perf_trace_buf_submit(rec, size, rctx, 0, 1, flags, regs); + ftrace_perf_buf_submit(rec, size, rctx, 0, 1, flags); } -int perf_sysexit_enable(struct ftrace_event_call *call) +int prof_sysexit_enable(struct ftrace_event_call *call) { int ret = 0; int num; @@ -553,30 +553,30 @@ int perf_sysexit_enable(struct ftrace_event_call *call) num = ((struct syscall_metadata *)call->data)->syscall_nr; mutex_lock(&syscall_trace_lock); - if (!sys_perf_refcount_exit) - ret = register_trace_sys_exit(perf_syscall_exit); + if (!sys_prof_refcount_exit) + ret = register_trace_sys_exit(prof_syscall_exit); if (ret) { pr_info("event trace: Could not activate" "syscall exit trace point"); } else { - set_bit(num, enabled_perf_exit_syscalls); - sys_perf_refcount_exit++; + set_bit(num, enabled_prof_exit_syscalls); + sys_prof_refcount_exit++; } mutex_unlock(&syscall_trace_lock); return ret; } -void perf_sysexit_disable(struct ftrace_event_call *call) +void prof_sysexit_disable(struct ftrace_event_call *call) { int num; num = ((struct syscall_metadata *)call->data)->syscall_nr; mutex_lock(&syscall_trace_lock); - sys_perf_refcount_exit--; - clear_bit(num, enabled_perf_exit_syscalls); - if (!sys_perf_refcount_exit) - unregister_trace_sys_exit(perf_syscall_exit); + sys_prof_refcount_exit--; + clear_bit(num, enabled_prof_exit_syscalls); + if (!sys_prof_refcount_exit) + unregister_trace_sys_exit(prof_syscall_exit); mutex_unlock(&syscall_trace_lock); } diff --git a/trunk/mm/page_cgroup.c b/trunk/mm/page_cgroup.c index 6c0081441a32..3dd88539a0e6 100644 --- a/trunk/mm/page_cgroup.c +++ b/trunk/mm/page_cgroup.c @@ -284,7 +284,6 @@ static DEFINE_MUTEX(swap_cgroup_mutex); struct swap_cgroup_ctrl { struct page **map; unsigned long length; - spinlock_t lock; }; struct swap_cgroup_ctrl swap_cgroup_ctrl[MAX_SWAPFILES]; @@ -354,22 +353,16 @@ unsigned short swap_cgroup_cmpxchg(swp_entry_t ent, struct swap_cgroup_ctrl *ctrl; struct page *mappage; struct swap_cgroup *sc; - unsigned long flags; - unsigned short retval; ctrl = &swap_cgroup_ctrl[type]; mappage = ctrl->map[idx]; sc = page_address(mappage); sc += pos; - spin_lock_irqsave(&ctrl->lock, flags); - retval = sc->id; - if (retval == old) - sc->id = new; + if (cmpxchg(&sc->id, old, new) == old) + return old; else - retval = 0; - spin_unlock_irqrestore(&ctrl->lock, flags); - return retval; + return 0; } /** @@ -390,17 +383,13 @@ unsigned short swap_cgroup_record(swp_entry_t ent, unsigned short id) struct page *mappage; struct swap_cgroup *sc; unsigned short old; - unsigned long flags; ctrl = &swap_cgroup_ctrl[type]; mappage = ctrl->map[idx]; sc = page_address(mappage); sc += pos; - spin_lock_irqsave(&ctrl->lock, flags); - old = sc->id; - sc->id = id; - spin_unlock_irqrestore(&ctrl->lock, flags); + old = xchg(&sc->id, id); return old; } @@ -452,7 +441,6 @@ int swap_cgroup_swapon(int type, unsigned long max_pages) mutex_lock(&swap_cgroup_mutex); ctrl->length = length; ctrl->map = array; - spin_lock_init(&ctrl->lock); if (swap_cgroup_prepare(type)) { /* memory shortage */ ctrl->map = NULL; diff --git a/trunk/net/bridge/br_device.c b/trunk/net/bridge/br_device.c index 90a9024e5c1e..eb7062d2e9e5 100644 --- a/trunk/net/bridge/br_device.c +++ b/trunk/net/bridge/br_device.c @@ -40,7 +40,7 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev) goto out; mdst = br_mdb_get(br, skb); - if (mdst || BR_INPUT_SKB_CB_MROUTERS_ONLY(skb)) + if (mdst || BR_INPUT_SKB_CB(skb)->mrouters_only) br_multicast_deliver(mdst, skb); else br_flood_deliver(br, skb); diff --git a/trunk/net/bridge/br_forward.c b/trunk/net/bridge/br_forward.c index 8dbec83e50ca..d61e6f741125 100644 --- a/trunk/net/bridge/br_forward.c +++ b/trunk/net/bridge/br_forward.c @@ -19,11 +19,6 @@ #include #include "br_private.h" -static int deliver_clone(const struct net_bridge_port *prev, - struct sk_buff *skb, - void (*__packet_hook)(const struct net_bridge_port *p, - struct sk_buff *skb)); - /* Don't forward packets to originating port or forwarding diasabled */ static inline int should_deliver(const struct net_bridge_port *p, const struct sk_buff *skb) @@ -99,22 +94,17 @@ void br_deliver(const struct net_bridge_port *to, struct sk_buff *skb) } /* called with rcu_read_lock */ -void br_forward(const struct net_bridge_port *to, struct sk_buff *skb, struct sk_buff *skb0) +void br_forward(const struct net_bridge_port *to, struct sk_buff *skb) { if (should_deliver(to, skb)) { - if (skb0) - deliver_clone(to, skb, __br_forward); - else - __br_forward(to, skb); + __br_forward(to, skb); return; } - if (!skb0) - kfree_skb(skb); + kfree_skb(skb); } -static int deliver_clone(const struct net_bridge_port *prev, - struct sk_buff *skb, +static int deliver_clone(struct net_bridge_port *prev, struct sk_buff *skb, void (*__packet_hook)(const struct net_bridge_port *p, struct sk_buff *skb)) { diff --git a/trunk/net/bridge/br_input.c b/trunk/net/bridge/br_input.c index d74d570fc848..53b39851d87d 100644 --- a/trunk/net/bridge/br_input.c +++ b/trunk/net/bridge/br_input.c @@ -70,7 +70,7 @@ int br_handle_frame_finish(struct sk_buff *skb) if (is_multicast_ether_addr(dest)) { mdst = br_mdb_get(br, skb); - if (mdst || BR_INPUT_SKB_CB_MROUTERS_ONLY(skb)) { + if (mdst || BR_INPUT_SKB_CB(skb)->mrouters_only) { if ((mdst && !hlist_unhashed(&mdst->mglist)) || br_multicast_is_router(br)) skb2 = skb; @@ -90,7 +90,7 @@ int br_handle_frame_finish(struct sk_buff *skb) if (skb) { if (dst) - br_forward(dst->dst, skb, skb2); + br_forward(dst->dst, skb); else br_flood_forward(br, skb, skb2); } diff --git a/trunk/net/bridge/br_multicast.c b/trunk/net/bridge/br_multicast.c index 6980625537ca..fd96a8dc97f4 100644 --- a/trunk/net/bridge/br_multicast.c +++ b/trunk/net/bridge/br_multicast.c @@ -49,23 +49,22 @@ static struct net_bridge_mdb_entry *__br_mdb_ip_get( static struct net_bridge_mdb_entry *br_mdb_ip_get( struct net_bridge_mdb_htable *mdb, __be32 dst) { - if (!mdb) - return NULL; - return __br_mdb_ip_get(mdb, dst, br_ip_hash(mdb, dst)); } struct net_bridge_mdb_entry *br_mdb_get(struct net_bridge *br, struct sk_buff *skb) { - if (br->multicast_disabled) + struct net_bridge_mdb_htable *mdb = br->mdb; + + if (!mdb || br->multicast_disabled) return NULL; switch (skb->protocol) { case htons(ETH_P_IP): if (BR_INPUT_SKB_CB(skb)->igmp) break; - return br_mdb_ip_get(br->mdb, ip_hdr(skb)->daddr); + return br_mdb_ip_get(mdb, ip_hdr(skb)->daddr); } return NULL; @@ -852,8 +851,8 @@ static int br_multicast_query(struct net_bridge *br, if (ih3->nsrcs) goto out; - max_delay = ih3->code ? - IGMPV3_MRC(ih3->code) * (HZ / IGMP_TIMER_SCALE) : 1; + max_delay = ih3->code ? 1 : + IGMPV3_MRC(ih3->code) * (HZ / IGMP_TIMER_SCALE); } if (!group) @@ -991,7 +990,7 @@ static int br_multicast_ipv4_rcv(struct net_bridge *br, err = pskb_trim_rcsum(skb2, len); if (err) - goto err_out; + return err; } len -= ip_hdrlen(skb2); @@ -1013,7 +1012,7 @@ static int br_multicast_ipv4_rcv(struct net_bridge *br, case CHECKSUM_NONE: skb2->csum = 0; if (skb_checksum_complete(skb2)) - goto out; + return -EINVAL; } err = 0; @@ -1040,7 +1039,6 @@ static int br_multicast_ipv4_rcv(struct net_bridge *br, out: __skb_push(skb2, offset); -err_out: if (skb2 != skb) kfree_skb(skb2); return err; diff --git a/trunk/net/bridge/br_private.h b/trunk/net/bridge/br_private.h index 846d7d1e2075..fef0384e3c0b 100644 --- a/trunk/net/bridge/br_private.h +++ b/trunk/net/bridge/br_private.h @@ -206,20 +206,12 @@ struct net_bridge struct br_input_skb_cb { struct net_device *brdev; -#ifdef CONFIG_BRIDGE_IGMP_SNOOPING int igmp; int mrouters_only; -#endif }; #define BR_INPUT_SKB_CB(__skb) ((struct br_input_skb_cb *)(__skb)->cb) -#ifdef CONFIG_BRIDGE_IGMP_SNOOPING -# define BR_INPUT_SKB_CB_MROUTERS_ONLY(__skb) (BR_INPUT_SKB_CB(__skb)->mrouters_only) -#else -# define BR_INPUT_SKB_CB_MROUTERS_ONLY(__skb) (0) -#endif - extern struct notifier_block br_device_notifier; extern const u8 br_group_address[ETH_ALEN]; @@ -260,7 +252,7 @@ extern void br_deliver(const struct net_bridge_port *to, struct sk_buff *skb); extern int br_dev_queue_push_xmit(struct sk_buff *skb); extern void br_forward(const struct net_bridge_port *to, - struct sk_buff *skb, struct sk_buff *skb0); + struct sk_buff *skb); extern int br_forward_finish(struct sk_buff *skb); extern void br_flood_deliver(struct net_bridge *br, struct sk_buff *skb); extern void br_flood_forward(struct net_bridge *br, struct sk_buff *skb, diff --git a/trunk/net/core/netpoll.c b/trunk/net/core/netpoll.c index d4ec38fa64e6..7aa697253765 100644 --- a/trunk/net/core/netpoll.c +++ b/trunk/net/core/netpoll.c @@ -735,7 +735,7 @@ int netpoll_setup(struct netpoll *np) npinfo = kmalloc(sizeof(*npinfo), GFP_KERNEL); if (!npinfo) { err = -ENOMEM; - goto put; + goto release; } npinfo->rx_flags = 0; @@ -845,7 +845,7 @@ int netpoll_setup(struct netpoll *np) kfree(npinfo); } -put: + dev_put(ndev); return err; } diff --git a/trunk/net/dccp/ipv4.c b/trunk/net/dccp/ipv4.c index 4071eaf2b361..b195c4feaa0a 100644 --- a/trunk/net/dccp/ipv4.c +++ b/trunk/net/dccp/ipv4.c @@ -998,11 +998,11 @@ static struct inet_protosw dccp_v4_protosw = { static int __net_init dccp_v4_init_net(struct net *net) { - if (dccp_hashinfo.bhash == NULL) - return -ESOCKTNOSUPPORT; + int err; - return inet_ctl_sock_create(&net->dccp.v4_ctl_sk, PF_INET, - SOCK_DCCP, IPPROTO_DCCP, net); + err = inet_ctl_sock_create(&net->dccp.v4_ctl_sk, PF_INET, + SOCK_DCCP, IPPROTO_DCCP, net); + return err; } static void __net_exit dccp_v4_exit_net(struct net *net) diff --git a/trunk/net/dccp/ipv6.c b/trunk/net/dccp/ipv6.c index af3394df63b7..1aec6349e858 100644 --- a/trunk/net/dccp/ipv6.c +++ b/trunk/net/dccp/ipv6.c @@ -1191,11 +1191,11 @@ static struct inet_protosw dccp_v6_protosw = { static int __net_init dccp_v6_init_net(struct net *net) { - if (dccp_hashinfo.bhash == NULL) - return -ESOCKTNOSUPPORT; + int err; - return inet_ctl_sock_create(&net->dccp.v6_ctl_sk, PF_INET6, - SOCK_DCCP, IPPROTO_DCCP, net); + err = inet_ctl_sock_create(&net->dccp.v6_ctl_sk, PF_INET6, + SOCK_DCCP, IPPROTO_DCCP, net); + return err; } static void __net_exit dccp_v6_exit_net(struct net *net) diff --git a/trunk/net/dccp/proto.c b/trunk/net/dccp/proto.c index aa4cef374fd0..0ef7061920c0 100644 --- a/trunk/net/dccp/proto.c +++ b/trunk/net/dccp/proto.c @@ -1036,7 +1036,7 @@ static int __init dccp_init(void) FIELD_SIZEOF(struct sk_buff, cb)); rc = percpu_counter_init(&dccp_orphan_count, 0); if (rc) - goto out_fail; + goto out; rc = -ENOBUFS; inet_hashinfo_init(&dccp_hashinfo); dccp_hashinfo.bind_bucket_cachep = @@ -1125,9 +1125,8 @@ static int __init dccp_init(void) goto out_sysctl_exit; dccp_timestamping_init(); - - return 0; - +out: + return rc; out_sysctl_exit: dccp_sysctl_exit(); out_ackvec_exit: @@ -1136,19 +1135,18 @@ static int __init dccp_init(void) dccp_mib_exit(); out_free_dccp_bhash: free_pages((unsigned long)dccp_hashinfo.bhash, bhash_order); + dccp_hashinfo.bhash = NULL; out_free_dccp_locks: inet_ehash_locks_free(&dccp_hashinfo); out_free_dccp_ehash: free_pages((unsigned long)dccp_hashinfo.ehash, ehash_order); + dccp_hashinfo.ehash = NULL; out_free_bind_bucket_cachep: kmem_cache_destroy(dccp_hashinfo.bind_bucket_cachep); + dccp_hashinfo.bind_bucket_cachep = NULL; out_free_percpu: percpu_counter_destroy(&dccp_orphan_count); -out_fail: - dccp_hashinfo.bhash = NULL; - dccp_hashinfo.ehash = NULL; - dccp_hashinfo.bind_bucket_cachep = NULL; - return rc; + goto out; } static void __exit dccp_fini(void) diff --git a/trunk/net/ipv4/route.c b/trunk/net/ipv4/route.c index a770df2493d2..d9b40248b97f 100644 --- a/trunk/net/ipv4/route.c +++ b/trunk/net/ipv4/route.c @@ -932,8 +932,10 @@ static void rt_secret_rebuild_oneshot(struct net *net) { del_timer_sync(&net->ipv4.rt_secret_timer); rt_cache_invalidate(net); - if (ip_rt_secret_interval) - mod_timer(&net->ipv4.rt_secret_timer, jiffies + ip_rt_secret_interval); + if (ip_rt_secret_interval) { + net->ipv4.rt_secret_timer.expires += ip_rt_secret_interval; + add_timer(&net->ipv4.rt_secret_timer); + } } static void rt_emergency_hash_rebuild(struct net *net) @@ -3101,20 +3103,22 @@ static void rt_secret_reschedule(int old) rtnl_lock(); for_each_net(net) { int deleted = del_timer_sync(&net->ipv4.rt_secret_timer); - long time; if (!new) continue; if (deleted) { - time = net->ipv4.rt_secret_timer.expires - jiffies; + long time = net->ipv4.rt_secret_timer.expires - jiffies; if (time <= 0 || (time += diff) <= 0) time = 0; + + net->ipv4.rt_secret_timer.expires = time; } else - time = new; + net->ipv4.rt_secret_timer.expires = new; - mod_timer(&net->ipv4.rt_secret_timer, jiffies + time); + net->ipv4.rt_secret_timer.expires += jiffies; + add_timer(&net->ipv4.rt_secret_timer); } rtnl_unlock(); } diff --git a/trunk/net/phonet/pn_dev.c b/trunk/net/phonet/pn_dev.c index 5c6ae0c701c0..c597cc53a6fb 100644 --- a/trunk/net/phonet/pn_dev.c +++ b/trunk/net/phonet/pn_dev.c @@ -107,7 +107,8 @@ static void phonet_device_destroy(struct net_device *dev) if (pnd) { u8 addr; - for_each_set_bit(addr, pnd->addrs, 64) + for (addr = find_first_bit(pnd->addrs, 64); addr < 64; + addr = find_next_bit(pnd->addrs, 64, 1+addr)) phonet_address_notify(RTM_DELADDR, dev, addr); kfree(pnd); } diff --git a/trunk/net/phonet/pn_netlink.c b/trunk/net/phonet/pn_netlink.c index fe2e7088ee07..2e6c7eb8e76a 100644 --- a/trunk/net/phonet/pn_netlink.c +++ b/trunk/net/phonet/pn_netlink.c @@ -141,7 +141,8 @@ static int getaddr_dumpit(struct sk_buff *skb, struct netlink_callback *cb) continue; addr_idx = 0; - for_each_set_bit(addr, pnd->addrs, 64) { + for (addr = find_first_bit(pnd->addrs, 64); addr < 64; + addr = find_next_bit(pnd->addrs, 64, 1+addr)) { if (addr_idx++ < addr_start_idx) continue; diff --git a/trunk/net/sunrpc/xprtsock.c b/trunk/net/sunrpc/xprtsock.c index e4839c07c913..75ab08eac66b 100644 --- a/trunk/net/sunrpc/xprtsock.c +++ b/trunk/net/sunrpc/xprtsock.c @@ -548,6 +548,8 @@ static int xs_udp_send_request(struct rpc_task *task) /* Still some bytes left; set up for a retry later. */ status = -EAGAIN; } + if (!transport->sock) + goto out; switch (status) { case -ENOTSOCK: @@ -567,7 +569,7 @@ static int xs_udp_send_request(struct rpc_task *task) * prompts ECONNREFUSED. */ clear_bit(SOCK_ASYNC_NOSPACE, &transport->sock->flags); } - +out: return status; } @@ -649,6 +651,8 @@ static int xs_tcp_send_request(struct rpc_task *task) status = -EAGAIN; break; } + if (!transport->sock) + goto out; switch (status) { case -ENOTSOCK: @@ -668,7 +672,7 @@ static int xs_tcp_send_request(struct rpc_task *task) case -ENOTCONN: clear_bit(SOCK_ASYNC_NOSPACE, &transport->sock->flags); } - +out: return status; } diff --git a/trunk/net/tipc/ref.c b/trunk/net/tipc/ref.c index 8dea66500cf5..414fc34b8bea 100644 --- a/trunk/net/tipc/ref.c +++ b/trunk/net/tipc/ref.c @@ -153,11 +153,11 @@ void tipc_ref_table_stop(void) u32 tipc_ref_acquire(void *object, spinlock_t **lock) { + struct reference *entry; u32 index; u32 index_mask; u32 next_plus_upper; u32 ref; - struct reference *entry = NULL; if (!object) { err("Attempt to acquire reference to non-existent object\n"); @@ -175,36 +175,30 @@ u32 tipc_ref_acquire(void *object, spinlock_t **lock) index = tipc_ref_table.first_free; entry = &(tipc_ref_table.entries[index]); index_mask = tipc_ref_table.index_mask; + /* take lock in case a previous user of entry still holds it */ + spin_lock_bh(&entry->lock); next_plus_upper = entry->ref; tipc_ref_table.first_free = next_plus_upper & index_mask; ref = (next_plus_upper & ~index_mask) + index; + entry->ref = ref; + entry->object = object; + *lock = &entry->lock; } else if (tipc_ref_table.init_point < tipc_ref_table.capacity) { index = tipc_ref_table.init_point++; entry = &(tipc_ref_table.entries[index]); spin_lock_init(&entry->lock); + spin_lock_bh(&entry->lock); ref = tipc_ref_table.start_mask + index; + entry->ref = ref; + entry->object = object; + *lock = &entry->lock; } else { ref = 0; } write_unlock_bh(&ref_table_lock); - /* - * Grab the lock so no one else can modify this entry - * While we assign its ref value & object pointer - */ - if (entry) { - spin_lock_bh(&entry->lock); - entry->ref = ref; - entry->object = object; - *lock = &entry->lock; - /* - * keep it locked, the caller is responsible - * for unlocking this when they're done with it - */ - } - return ref; } diff --git a/trunk/sound/oss/sequencer.c b/trunk/sound/oss/sequencer.c index e85789e53816..c79874696bec 100644 --- a/trunk/sound/oss/sequencer.c +++ b/trunk/sound/oss/sequencer.c @@ -1631,6 +1631,8 @@ unsigned long compute_finetune(unsigned long base_freq, int bend, int range, } semitones = bend / 100; + if (semitones > 99) + semitones = 99; cents = bend % 100; amount = (int) (semitone_tuning[semitones] * multiplier * cent_tuning[cents]) / 10000; diff --git a/trunk/sound/pci/hda/hda_codec.c b/trunk/sound/pci/hda/hda_codec.c index 0e76ac2b2ace..5bd7cf45f3a5 100644 --- a/trunk/sound/pci/hda/hda_codec.c +++ b/trunk/sound/pci/hda/hda_codec.c @@ -1806,8 +1806,6 @@ int snd_hda_add_nid(struct hda_codec *codec, struct snd_kcontrol *kctl, item->nid = nid; return 0; } - printk(KERN_ERR "hda-codec: no NID for mapping control %s:%d:%d\n", - kctl->id.name, kctl->id.index, index); return -EINVAL; } EXPORT_SYMBOL_HDA(snd_hda_add_nid); @@ -2886,7 +2884,7 @@ int /*__devinit*/ snd_hda_build_controls(struct hda_bus *bus) list_for_each_entry(codec, &bus->codec_list, list) { int err = snd_hda_codec_build_controls(codec); if (err < 0) { - printk(KERN_ERR "hda_codec: cannot build controls " + printk(KERN_ERR "hda_codec: cannot build controls" "for #%d (error %d)\n", codec->addr, err); err = snd_hda_codec_reset(codec); if (err < 0) { diff --git a/trunk/sound/pci/hda/hda_intel.c b/trunk/sound/pci/hda/hda_intel.c index 8b2915631cc3..da1ac9068aac 100644 --- a/trunk/sound/pci/hda/hda_intel.c +++ b/trunk/sound/pci/hda/hda_intel.c @@ -2271,7 +2271,6 @@ static struct snd_pci_quirk position_fix_list[] __devinitdata = { SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", POS_FIX_LPIB), SND_PCI_QUIRK(0x1462, 0x1002, "MSI Wind U115", POS_FIX_LPIB), SND_PCI_QUIRK(0x1565, 0x820f, "Biostar Microtech", POS_FIX_LPIB), - SND_PCI_QUIRK(0x8086, 0xd601, "eMachines T5212", POS_FIX_LPIB), {} }; @@ -2379,13 +2378,6 @@ static void __devinit check_msi(struct azx *chip) "hda_intel: msi for device %04x:%04x set to %d\n", q->subvendor, q->subdevice, q->value); chip->msi = q->value; - return; - } - - /* NVidia chipsets seem to cause troubles with MSI */ - if (chip->driver_type == AZX_DRIVER_NVIDIA) { - printk(KERN_INFO "hda_intel: Disable MSI for Nvidia chipset\n"); - chip->msi = 0; } } @@ -2714,7 +2706,6 @@ static DEFINE_PCI_DEVICE_TABLE(azx_ids) = { { PCI_DEVICE(0x8086, 0x3a6e), .driver_data = AZX_DRIVER_ICH }, /* PCH */ { PCI_DEVICE(0x8086, 0x3b56), .driver_data = AZX_DRIVER_ICH }, - { PCI_DEVICE(0x8086, 0x3b57), .driver_data = AZX_DRIVER_ICH }, /* CPT */ { PCI_DEVICE(0x8086, 0x1c20), .driver_data = AZX_DRIVER_PCH }, /* SCH */ diff --git a/trunk/sound/pci/hda/patch_realtek.c b/trunk/sound/pci/hda/patch_realtek.c index 4ec57633af88..3a8371990d75 100644 --- a/trunk/sound/pci/hda/patch_realtek.c +++ b/trunk/sound/pci/hda/patch_realtek.c @@ -6477,7 +6477,7 @@ static struct alc_config_preset alc260_presets[] = { .num_dacs = ARRAY_SIZE(alc260_dac_nids), .dac_nids = alc260_dac_nids, .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), - .adc_nids = alc260_dual_adc_nids, + .adc_nids = alc260_adc_nids, .num_channel_mode = ARRAY_SIZE(alc260_modes), .channel_mode = alc260_modes, .input_mux = &alc260_capture_source, @@ -9195,7 +9195,6 @@ static struct snd_pci_quirk alc882_cfg_tbl[] = { SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG), SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG), SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG), - SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG), SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG), SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG), SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG), @@ -9205,7 +9204,6 @@ static struct snd_pci_quirk alc882_cfg_tbl[] = { SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG), SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG), SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG), - SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG), SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG), SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG), @@ -9237,7 +9235,7 @@ static struct snd_pci_quirk alc882_cfg_tbl[] = { SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL), SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL), SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL), - SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG), + SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), {} }; diff --git a/trunk/tools/perf/Documentation/Makefile b/trunk/tools/perf/Documentation/Makefile index bd498d496952..bdd3b7ecad0a 100644 --- a/trunk/tools/perf/Documentation/Makefile +++ b/trunk/tools/perf/Documentation/Makefile @@ -24,10 +24,7 @@ DOC_MAN1=$(patsubst %.txt,%.1,$(MAN1_TXT)) DOC_MAN5=$(patsubst %.txt,%.5,$(MAN5_TXT)) DOC_MAN7=$(patsubst %.txt,%.7,$(MAN7_TXT)) -# Make the path relative to DESTDIR, not prefix -ifndef DESTDIR prefix?=$(HOME) -endif bindir?=$(prefix)/bin htmldir?=$(prefix)/share/doc/perf-doc pdfdir?=$(prefix)/share/doc/perf-doc @@ -35,6 +32,7 @@ mandir?=$(prefix)/share/man man1dir=$(mandir)/man1 man5dir=$(mandir)/man5 man7dir=$(mandir)/man7 +# DESTDIR= ASCIIDOC=asciidoc ASCIIDOC_EXTRA = --unsafe diff --git a/trunk/tools/perf/Makefile b/trunk/tools/perf/Makefile index 8a8f52db7e38..2d537382c686 100644 --- a/trunk/tools/perf/Makefile +++ b/trunk/tools/perf/Makefile @@ -216,10 +216,7 @@ STRIP ?= strip # runtime figures out where they are based on the path to the executable. # This can help installing the suite in a relocatable way. -# Make the path relative to DESTDIR, not to prefix -ifndef DESTDIR prefix = $(HOME) -endif bindir_relative = bin bindir = $(prefix)/$(bindir_relative) mandir = share/man @@ -236,6 +233,7 @@ sysconfdir = $(prefix)/etc ETC_PERFCONFIG = etc/perfconfig endif lib = lib +# DESTDIR= export prefix bindir sharedir sysconfdir @@ -389,7 +387,6 @@ LIB_H += util/thread.h LIB_H += util/trace-event.h LIB_H += util/probe-finder.h LIB_H += util/probe-event.h -LIB_H += util/cpumap.h LIB_OBJS += util/abspath.o LIB_OBJS += util/alias.o @@ -436,7 +433,6 @@ LIB_OBJS += util/sort.o LIB_OBJS += util/hist.o LIB_OBJS += util/probe-event.o LIB_OBJS += util/util.o -LIB_OBJS += util/cpumap.o BUILTIN_OBJS += builtin-annotate.o diff --git a/trunk/tools/perf/builtin-annotate.c b/trunk/tools/perf/builtin-annotate.c index 6ad7148451c5..5ec5de995872 100644 --- a/trunk/tools/perf/builtin-annotate.c +++ b/trunk/tools/perf/builtin-annotate.c @@ -116,7 +116,7 @@ static int perf_session__add_hist_entry(struct perf_session *self, return 0; } - he = __perf_session__add_hist_entry(&self->hists, al, NULL, count, &hit); + he = __perf_session__add_hist_entry(self, al, NULL, count, &hit); if (he == NULL) return -ENOMEM; @@ -564,8 +564,8 @@ static int __cmd_annotate(void) if (verbose > 2) dsos__fprintf(stdout); - perf_session__collapse_resort(&session->hists); - perf_session__output_resort(&session->hists, session->event_total[0]); + perf_session__collapse_resort(session); + perf_session__output_resort(session, session->event_total[0]); perf_session__find_annotations(session); out_delete: perf_session__delete(session); diff --git a/trunk/tools/perf/builtin-diff.c b/trunk/tools/perf/builtin-diff.c index 1ea15d8aeed1..18b3f505f9db 100644 --- a/trunk/tools/perf/builtin-diff.c +++ b/trunk/tools/perf/builtin-diff.c @@ -26,8 +26,7 @@ static int perf_session__add_hist_entry(struct perf_session *self, struct addr_location *al, u64 count) { bool hit; - struct hist_entry *he = __perf_session__add_hist_entry(&self->hists, - al, NULL, + struct hist_entry *he = __perf_session__add_hist_entry(self, al, NULL, count, &hit); if (he == NULL) return -ENOMEM; @@ -115,7 +114,7 @@ static void perf_session__resort_hist_entries(struct perf_session *self) static void perf_session__set_hist_entries_positions(struct perf_session *self) { - perf_session__output_resort(&self->hists, self->events_stats.total); + perf_session__output_resort(self, self->events_stats.total); perf_session__resort_hist_entries(self); } @@ -167,15 +166,13 @@ static int __cmd_diff(void) goto out_delete; } - perf_session__output_resort(&session[1]->hists, - session[1]->events_stats.total); + perf_session__output_resort(session[1], session[1]->events_stats.total); if (show_displacement) perf_session__set_hist_entries_positions(session[0]); perf_session__match_hists(session[0], session[1]); - perf_session__fprintf_hists(&session[1]->hists, session[0], - show_displacement, stdout, - session[1]->events_stats.total); + perf_session__fprintf_hists(session[1], session[0], + show_displacement, stdout); out_delete: for (i = 0; i < 2; ++i) perf_session__delete(session[i]); diff --git a/trunk/tools/perf/builtin-record.c b/trunk/tools/perf/builtin-record.c index 3b8b6387c47c..771533ced6a8 100644 --- a/trunk/tools/perf/builtin-record.c +++ b/trunk/tools/perf/builtin-record.c @@ -22,7 +22,6 @@ #include "util/debug.h" #include "util/session.h" #include "util/symbol.h" -#include "util/cpumap.h" #include #include @@ -245,9 +244,6 @@ static void create_counter(int counter, int cpu, pid_t pid) attr->sample_type |= PERF_SAMPLE_IP | PERF_SAMPLE_TID; - if (nr_counters > 1) - attr->sample_type |= PERF_SAMPLE_ID; - if (freq) { attr->sample_type |= PERF_SAMPLE_PERIOD; attr->freq = 1; @@ -395,9 +391,6 @@ static int process_buildids(void) { u64 size = lseek(output, 0, SEEK_CUR); - if (size == 0) - return 0; - session->fd = output; return __perf_session__process_events(session, post_processing_offset, size - post_processing_offset, @@ -425,6 +418,9 @@ static int __cmd_record(int argc, const char **argv) char buf; page_size = sysconf(_SC_PAGE_SIZE); + nr_cpus = sysconf(_SC_NPROCESSORS_ONLN); + assert(nr_cpus <= MAX_NR_CPUS); + assert(nr_cpus >= 0); atexit(sig_atexit); signal(SIGCHLD, sig_handler); @@ -548,9 +544,8 @@ static int __cmd_record(int argc, const char **argv) if ((!system_wide && !inherit) || profile_cpu != -1) { open_counters(profile_cpu, target_pid); } else { - nr_cpus = read_cpu_map(); for (i = 0; i < nr_cpus; i++) - open_counters(cpumap[i], target_pid); + open_counters(i, target_pid); } if (file_new) { diff --git a/trunk/tools/perf/builtin-report.c b/trunk/tools/perf/builtin-report.c index f815de25d0fc..cfc655d40bb7 100644 --- a/trunk/tools/perf/builtin-report.c +++ b/trunk/tools/perf/builtin-report.c @@ -45,71 +45,28 @@ static char *pretty_printing_style = default_pretty_printing_style; static char callchain_default_opt[] = "fractal,0.5"; -static struct event_stat_id *get_stats(struct perf_session *self, - u64 event_stream, u32 type, u64 config) -{ - struct rb_node **p = &self->stats_by_id.rb_node; - struct rb_node *parent = NULL; - struct event_stat_id *iter, *new; - - while (*p != NULL) { - parent = *p; - iter = rb_entry(parent, struct event_stat_id, rb_node); - if (iter->config == config) - return iter; - - - if (config > iter->config) - p = &(*p)->rb_right; - else - p = &(*p)->rb_left; - } - - new = malloc(sizeof(struct event_stat_id)); - if (new == NULL) - return NULL; - memset(new, 0, sizeof(struct event_stat_id)); - new->event_stream = event_stream; - new->config = config; - new->type = type; - rb_link_node(&new->rb_node, parent, p); - rb_insert_color(&new->rb_node, &self->stats_by_id); - return new; -} - static int perf_session__add_hist_entry(struct perf_session *self, struct addr_location *al, - struct sample_data *data) + struct ip_callchain *chain, u64 count) { struct symbol **syms = NULL, *parent = NULL; bool hit; struct hist_entry *he; - struct event_stat_id *stats; - struct perf_event_attr *attr; - if ((sort__has_parent || symbol_conf.use_callchain) && data->callchain) + if ((sort__has_parent || symbol_conf.use_callchain) && chain) syms = perf_session__resolve_callchain(self, al->thread, - data->callchain, &parent); - - attr = perf_header__find_attr(data->id, &self->header); - if (attr) - stats = get_stats(self, data->id, attr->type, attr->config); - else - stats = get_stats(self, data->id, 0, 0); - if (stats == NULL) - return -ENOMEM; - he = __perf_session__add_hist_entry(&stats->hists, al, parent, - data->period, &hit); + chain, &parent); + he = __perf_session__add_hist_entry(self, al, parent, count, &hit); if (he == NULL) return -ENOMEM; if (hit) - he->count += data->period; + he->count += count; if (symbol_conf.use_callchain) { if (!hit) callchain_init(&he->callchain); - append_chain(&he->callchain, data->callchain, syms); + append_chain(&he->callchain, chain, syms); free(syms); } @@ -129,30 +86,10 @@ static int validate_chain(struct ip_callchain *chain, event_t *event) return 0; } -static int add_event_total(struct perf_session *session, - struct sample_data *data, - struct perf_event_attr *attr) -{ - struct event_stat_id *stats; - - if (attr) - stats = get_stats(session, data->id, attr->type, attr->config); - else - stats = get_stats(session, data->id, 0, 0); - - if (!stats) - return -ENOMEM; - - stats->stats.total += data->period; - session->events_stats.total += data->period; - return 0; -} - static int process_sample_event(event_t *event, struct perf_session *session) { struct sample_data data = { .period = 1, }; struct addr_location al; - struct perf_event_attr *attr; event__parse_sample(event, session->sample_type, &data); @@ -186,18 +123,12 @@ static int process_sample_event(event_t *event, struct perf_session *session) if (al.filtered || (hide_unresolved && al.sym == NULL)) return 0; - if (perf_session__add_hist_entry(session, &al, &data)) { + if (perf_session__add_hist_entry(session, &al, data.callchain, data.period)) { pr_debug("problem incrementing symbol count, skipping event\n"); return -1; } - attr = perf_header__find_attr(data.id, &session->header); - - if (add_event_total(session, &data, attr)) { - pr_debug("problem adding event count\n"); - return -1; - } - + session->events_stats.total += data.period; return 0; } @@ -266,7 +197,6 @@ static int __cmd_report(void) { int ret = -EINVAL; struct perf_session *session; - struct rb_node *next; session = perf_session__new(input_name, O_RDONLY, force); if (session == NULL) @@ -294,28 +224,10 @@ static int __cmd_report(void) if (verbose > 2) dsos__fprintf(stdout); - next = rb_first(&session->stats_by_id); - while (next) { - struct event_stat_id *stats; - - stats = rb_entry(next, struct event_stat_id, rb_node); - perf_session__collapse_resort(&stats->hists); - perf_session__output_resort(&stats->hists, stats->stats.total); - if (rb_first(&session->stats_by_id) == - rb_last(&session->stats_by_id)) - fprintf(stdout, "# Samples: %Ld\n#\n", - stats->stats.total); - else - fprintf(stdout, "# Samples: %Ld %s\n#\n", - stats->stats.total, - __event_name(stats->type, stats->config)); - - perf_session__fprintf_hists(&stats->hists, NULL, false, stdout, - stats->stats.total); - fprintf(stdout, "\n\n"); - next = rb_next(&stats->rb_node); - } - + perf_session__collapse_resort(session); + perf_session__output_resort(session, session->events_stats.total); + fprintf(stdout, "# Samples: %Ld\n#\n", session->events_stats.total); + perf_session__fprintf_hists(session, NULL, false, stdout); if (sort_order == default_sort_order && parent_pattern == default_parent_pattern) fprintf(stdout, "#\n# (For a higher level overview, try: perf report --sort comm,dso)\n#\n"); diff --git a/trunk/tools/perf/builtin-stat.c b/trunk/tools/perf/builtin-stat.c index 95db31cff6fd..e8c85d5aec41 100644 --- a/trunk/tools/perf/builtin-stat.c +++ b/trunk/tools/perf/builtin-stat.c @@ -45,7 +45,6 @@ #include "util/event.h" #include "util/debug.h" #include "util/header.h" -#include "util/cpumap.h" #include #include @@ -152,7 +151,7 @@ static void create_perf_stat_counter(int counter, int pid) unsigned int cpu; for (cpu = 0; cpu < nr_cpus; cpu++) { - fd[cpu][counter] = sys_perf_event_open(attr, -1, cpumap[cpu], -1, 0); + fd[cpu][counter] = sys_perf_event_open(attr, -1, cpu, -1, 0); if (fd[cpu][counter] < 0 && verbose) fprintf(stderr, ERR_PERF_OPEN, counter, fd[cpu][counter], strerror(errno)); @@ -520,10 +519,9 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used) nr_counters = ARRAY_SIZE(default_attrs); } - if (system_wide) - nr_cpus = read_cpu_map(); - else - nr_cpus = 1; + nr_cpus = sysconf(_SC_NPROCESSORS_ONLN); + assert(nr_cpus <= MAX_NR_CPUS); + assert((int)nr_cpus >= 0); /* * We dont want to block the signals - that would cause diff --git a/trunk/tools/perf/builtin-top.c b/trunk/tools/perf/builtin-top.c index 0b719e3dde05..31f2e597800c 100644 --- a/trunk/tools/perf/builtin-top.c +++ b/trunk/tools/perf/builtin-top.c @@ -28,7 +28,6 @@ #include #include "util/parse-options.h" #include "util/parse-events.h" -#include "util/cpumap.h" #include "util/debug.h" @@ -1124,7 +1123,7 @@ static void start_counter(int i, int counter) cpu = profile_cpu; if (target_pid == -1 && profile_cpu == -1) - cpu = cpumap[i]; + cpu = i; attr = attrs + counter; @@ -1348,10 +1347,12 @@ int cmd_top(int argc, const char **argv, const char *prefix __used) attrs[counter].sample_period = default_interval; } + nr_cpus = sysconf(_SC_NPROCESSORS_ONLN); + assert(nr_cpus <= MAX_NR_CPUS); + assert(nr_cpus >= 0); + if (target_pid != -1 || profile_cpu != -1) nr_cpus = 1; - else - nr_cpus = read_cpu_map(); get_term_dimensions(&winsize); if (print_entries == 0) { diff --git a/trunk/tools/perf/util/cpumap.c b/trunk/tools/perf/util/cpumap.c deleted file mode 100644 index 4e01490e51e5..000000000000 --- a/trunk/tools/perf/util/cpumap.c +++ /dev/null @@ -1,59 +0,0 @@ -#include "util.h" -#include "../perf.h" -#include "cpumap.h" -#include -#include - -int cpumap[MAX_NR_CPUS]; - -static int default_cpu_map(void) -{ - int nr_cpus, i; - - nr_cpus = sysconf(_SC_NPROCESSORS_ONLN); - assert(nr_cpus <= MAX_NR_CPUS); - assert((int)nr_cpus >= 0); - - for (i = 0; i < nr_cpus; ++i) - cpumap[i] = i; - - return nr_cpus; -} - -int read_cpu_map(void) -{ - FILE *onlnf; - int nr_cpus = 0; - int n, cpu, prev; - char sep; - - onlnf = fopen("/sys/devices/system/cpu/online", "r"); - if (!onlnf) - return default_cpu_map(); - - sep = 0; - prev = -1; - for (;;) { - n = fscanf(onlnf, "%u%c", &cpu, &sep); - if (n <= 0) - break; - if (prev >= 0) { - assert(nr_cpus + cpu - prev - 1 < MAX_NR_CPUS); - while (++prev < cpu) - cpumap[nr_cpus++] = prev; - } - assert (nr_cpus < MAX_NR_CPUS); - cpumap[nr_cpus++] = cpu; - if (n == 2 && sep == '-') - prev = cpu; - else - prev = -1; - if (n == 1 || sep == '\n') - break; - } - fclose(onlnf); - if (nr_cpus > 0) - return nr_cpus; - - return default_cpu_map(); -} diff --git a/trunk/tools/perf/util/cpumap.h b/trunk/tools/perf/util/cpumap.h deleted file mode 100644 index 86c78bb33098..000000000000 --- a/trunk/tools/perf/util/cpumap.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef __PERF_CPUMAP_H -#define __PERF_CPUMAP_H - -extern int read_cpu_map(void); -extern int cpumap[]; - -#endif /* __PERF_CPUMAP_H */ diff --git a/trunk/tools/perf/util/event.h b/trunk/tools/perf/util/event.h index a33b94952e34..50a7132887f5 100644 --- a/trunk/tools/perf/util/event.h +++ b/trunk/tools/perf/util/event.h @@ -99,15 +99,6 @@ struct events_stats { u64 lost; }; -struct event_stat_id { - struct rb_node rb_node; - struct rb_root hists; - struct events_stats stats; - u64 config; - u64 event_stream; - u32 type; -}; - void event__print_totals(void); struct perf_session; diff --git a/trunk/tools/perf/util/hist.c b/trunk/tools/perf/util/hist.c index 2be33c7dbf03..44408c2621cf 100644 --- a/trunk/tools/perf/util/hist.c +++ b/trunk/tools/perf/util/hist.c @@ -12,12 +12,12 @@ struct callchain_param callchain_param = { * histogram, sorted on item, collects counts */ -struct hist_entry *__perf_session__add_hist_entry(struct rb_root *hists, +struct hist_entry *__perf_session__add_hist_entry(struct perf_session *self, struct addr_location *al, struct symbol *sym_parent, u64 count, bool *hit) { - struct rb_node **p = &hists->rb_node; + struct rb_node **p = &self->hists.rb_node; struct rb_node *parent = NULL; struct hist_entry *he; struct hist_entry entry = { @@ -53,7 +53,7 @@ struct hist_entry *__perf_session__add_hist_entry(struct rb_root *hists, return NULL; *he = entry; rb_link_node(&he->rb_node, parent, p); - rb_insert_color(&he->rb_node, hists); + rb_insert_color(&he->rb_node, &self->hists); *hit = false; return he; } @@ -130,7 +130,7 @@ static void collapse__insert_entry(struct rb_root *root, struct hist_entry *he) rb_insert_color(&he->rb_node, root); } -void perf_session__collapse_resort(struct rb_root *hists) +void perf_session__collapse_resort(struct perf_session *self) { struct rb_root tmp; struct rb_node *next; @@ -140,17 +140,17 @@ void perf_session__collapse_resort(struct rb_root *hists) return; tmp = RB_ROOT; - next = rb_first(hists); + next = rb_first(&self->hists); while (next) { n = rb_entry(next, struct hist_entry, rb_node); next = rb_next(&n->rb_node); - rb_erase(&n->rb_node, hists); + rb_erase(&n->rb_node, &self->hists); collapse__insert_entry(&tmp, n); } - *hists = tmp; + self->hists = tmp; } /* @@ -183,7 +183,7 @@ static void perf_session__insert_output_hist_entry(struct rb_root *root, rb_insert_color(&he->rb_node, root); } -void perf_session__output_resort(struct rb_root *hists, u64 total_samples) +void perf_session__output_resort(struct perf_session *self, u64 total_samples) { struct rb_root tmp; struct rb_node *next; @@ -194,18 +194,18 @@ void perf_session__output_resort(struct rb_root *hists, u64 total_samples) total_samples * (callchain_param.min_percent / 100); tmp = RB_ROOT; - next = rb_first(hists); + next = rb_first(&self->hists); while (next) { n = rb_entry(next, struct hist_entry, rb_node); next = rb_next(&n->rb_node); - rb_erase(&n->rb_node, hists); + rb_erase(&n->rb_node, &self->hists); perf_session__insert_output_hist_entry(&tmp, n, min_callchain_hits); } - *hists = tmp; + self->hists = tmp; } static size_t callchain__fprintf_left_margin(FILE *fp, int left_margin) @@ -456,10 +456,10 @@ static size_t hist_entry_callchain__fprintf(FILE *fp, struct hist_entry *self, } static size_t hist_entry__fprintf(struct hist_entry *self, + struct perf_session *session, struct perf_session *pair_session, bool show_displacement, - long displacement, FILE *fp, - u64 session_total) + long displacement, FILE *fp) { struct sort_entry *se; u64 count, total; @@ -474,7 +474,7 @@ static size_t hist_entry__fprintf(struct hist_entry *self, total = pair_session->events_stats.total; } else { count = self->count; - total = session_total; + total = session->events_stats.total; } if (total) @@ -496,8 +496,8 @@ static size_t hist_entry__fprintf(struct hist_entry *self, if (total > 0) old_percent = (count * 100.0) / total; - if (session_total > 0) - new_percent = (self->count * 100.0) / session_total; + if (session->events_stats.total > 0) + new_percent = (self->count * 100.0) / session->events_stats.total; diff = new_percent - old_percent; @@ -544,17 +544,16 @@ static size_t hist_entry__fprintf(struct hist_entry *self, left_margin -= thread__comm_len(self->thread); } - hist_entry_callchain__fprintf(fp, self, session_total, + hist_entry_callchain__fprintf(fp, self, session->events_stats.total, left_margin); } return ret; } -size_t perf_session__fprintf_hists(struct rb_root *hists, +size_t perf_session__fprintf_hists(struct perf_session *self, struct perf_session *pair, - bool show_displacement, FILE *fp, - u64 session_total) + bool show_displacement, FILE *fp) { struct sort_entry *se; struct rb_node *nd; @@ -642,7 +641,7 @@ size_t perf_session__fprintf_hists(struct rb_root *hists, fprintf(fp, "\n#\n"); print_entries: - for (nd = rb_first(hists); nd; nd = rb_next(nd)) { + for (nd = rb_first(&self->hists); nd; nd = rb_next(nd)) { struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); if (show_displacement) { @@ -653,13 +652,8 @@ size_t perf_session__fprintf_hists(struct rb_root *hists, displacement = 0; ++position; } - ret += hist_entry__fprintf(h, pair, show_displacement, - displacement, fp, session_total); - if (h->map == NULL && verbose > 1) { - __map_groups__fprintf_maps(&h->thread->mg, - MAP__FUNCTION, fp); - fprintf(fp, "%.10s end\n", graph_dotted_line); - } + ret += hist_entry__fprintf(h, self, pair, show_displacement, + displacement, fp); } free(rem_sq_bracket); diff --git a/trunk/tools/perf/util/hist.h b/trunk/tools/perf/util/hist.h index 16f360cce5bf..e5f99b24048b 100644 --- a/trunk/tools/perf/util/hist.h +++ b/trunk/tools/perf/util/hist.h @@ -10,9 +10,8 @@ struct perf_session; struct hist_entry; struct addr_location; struct symbol; -struct rb_root; -struct hist_entry *__perf_session__add_hist_entry(struct rb_root *hists, +struct hist_entry *__perf_session__add_hist_entry(struct perf_session *self, struct addr_location *al, struct symbol *parent, u64 count, bool *hit); @@ -20,10 +19,9 @@ extern int64_t hist_entry__cmp(struct hist_entry *, struct hist_entry *); extern int64_t hist_entry__collapse(struct hist_entry *, struct hist_entry *); void hist_entry__free(struct hist_entry *); -void perf_session__output_resort(struct rb_root *hists, u64 total_samples); -void perf_session__collapse_resort(struct rb_root *hists); -size_t perf_session__fprintf_hists(struct rb_root *hists, +void perf_session__output_resort(struct perf_session *self, u64 total_samples); +void perf_session__collapse_resort(struct perf_session *self); +size_t perf_session__fprintf_hists(struct perf_session *self, struct perf_session *pair, - bool show_displacement, FILE *fp, - u64 session_total); + bool show_displacement, FILE *fp); #endif /* __PERF_HIST_H */ diff --git a/trunk/tools/perf/util/probe-finder.c b/trunk/tools/perf/util/probe-finder.c index 1e6c65ebbd80..e77dc886760e 100644 --- a/trunk/tools/perf/util/probe-finder.c +++ b/trunk/tools/perf/util/probe-finder.c @@ -169,7 +169,7 @@ static const char *cu_find_realpath(Dwarf_Die *cu_die, const char *fname) { Dwarf_Files *files; size_t nfiles, i; - const char *src = NULL; + const char *src; int ret; if (!fname) diff --git a/trunk/tools/perf/util/session.c b/trunk/tools/perf/util/session.c index eed1cb889008..0de7258e70a5 100644 --- a/trunk/tools/perf/util/session.c +++ b/trunk/tools/perf/util/session.c @@ -70,7 +70,6 @@ struct perf_session *perf_session__new(const char *filename, int mode, bool forc memcpy(self->filename, filename, len); self->threads = RB_ROOT; - self->stats_by_id = RB_ROOT; self->last_match = NULL; self->mmap_window = 32; self->cwd = NULL; diff --git a/trunk/tools/perf/util/session.h b/trunk/tools/perf/util/session.h index 5c33417eebb3..31950fcd8a4d 100644 --- a/trunk/tools/perf/util/session.h +++ b/trunk/tools/perf/util/session.h @@ -20,7 +20,6 @@ struct perf_session { struct thread *last_match; struct map *vmlinux_maps[MAP__NR_TYPES]; struct events_stats events_stats; - struct rb_root stats_by_id; unsigned long event_total[PERF_RECORD_MAX]; unsigned long unknown_events; struct rb_root hists; diff --git a/trunk/tools/perf/util/thread.c b/trunk/tools/perf/util/thread.c index fa968312ee7d..21b92162282b 100644 --- a/trunk/tools/perf/util/thread.c +++ b/trunk/tools/perf/util/thread.c @@ -79,8 +79,8 @@ int thread__comm_len(struct thread *self) return self->comm_len; } -size_t __map_groups__fprintf_maps(struct map_groups *self, - enum map_type type, FILE *fp) +static size_t __map_groups__fprintf_maps(struct map_groups *self, + enum map_type type, FILE *fp) { size_t printed = fprintf(fp, "%s:\n", map_type__name[type]); struct rb_node *nd; @@ -89,7 +89,7 @@ size_t __map_groups__fprintf_maps(struct map_groups *self, struct map *pos = rb_entry(nd, struct map, rb_node); printed += fprintf(fp, "Map:"); printed += map__fprintf(pos, fp); - if (verbose > 2) { + if (verbose > 1) { printed += dso__fprintf(pos->dso, type, fp); printed += fprintf(fp, "--\n"); } @@ -183,8 +183,8 @@ struct thread *perf_session__findnew(struct perf_session *self, pid_t pid) return th; } -static int map_groups__fixup_overlappings(struct map_groups *self, - struct map *map) +static void map_groups__remove_overlappings(struct map_groups *self, + struct map *map) { struct rb_root *root = &self->maps[map->type]; struct rb_node *next = rb_first(root); @@ -209,36 +209,7 @@ static int map_groups__fixup_overlappings(struct map_groups *self, * list. */ list_add_tail(&pos->node, &self->removed_maps[map->type]); - /* - * Now check if we need to create new maps for areas not - * overlapped by the new map: - */ - if (map->start > pos->start) { - struct map *before = map__clone(pos); - - if (before == NULL) - return -ENOMEM; - - before->end = map->start - 1; - map_groups__insert(self, before); - if (verbose >= 2) - map__fprintf(before, stderr); - } - - if (map->end < pos->end) { - struct map *after = map__clone(pos); - - if (after == NULL) - return -ENOMEM; - - after->start = map->end + 1; - map_groups__insert(self, after); - if (verbose >= 2) - map__fprintf(after, stderr); - } } - - return 0; } void maps__insert(struct rb_root *maps, struct map *map) @@ -283,7 +254,7 @@ struct map *maps__find(struct rb_root *maps, u64 ip) void thread__insert_map(struct thread *self, struct map *map) { - map_groups__fixup_overlappings(&self->mg, map); + map_groups__remove_overlappings(&self->mg, map); map_groups__insert(&self->mg, map); } diff --git a/trunk/tools/perf/util/thread.h b/trunk/tools/perf/util/thread.h index dcf70303e58e..0a28f39de545 100644 --- a/trunk/tools/perf/util/thread.h +++ b/trunk/tools/perf/util/thread.h @@ -10,9 +10,6 @@ struct map_groups { struct list_head removed_maps[MAP__NR_TYPES]; }; -size_t __map_groups__fprintf_maps(struct map_groups *self, - enum map_type type, FILE *fp); - struct thread { struct rb_node rb_node; struct map_groups mg;