From owner-svn-src-head@freebsd.org Tue Oct 13 23:41:41 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A0521A130B0; Tue, 13 Oct 2015 23:41:41 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 79D3D1B7D; Tue, 13 Oct 2015 23:41:41 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9DNfe89015048; Tue, 13 Oct 2015 23:41:40 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9DNfeGr015047; Tue, 13 Oct 2015 23:41:40 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201510132341.t9DNfeGr015047@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: "Conrad E. Meyer" Date: Tue, 13 Oct 2015 23:41:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289272 - head/sys/dev/ntb/ntb_hw X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Oct 2015 23:41:41 -0000 Author: cem Date: Tue Oct 13 23:41:40 2015 New Revision: 289272 URL: https://svnweb.freebsd.org/changeset/base/289272 Log: NTB: MFV 9fec60c4: Fix NTB-RP Link Up The Xeon NTB-RP setup, the transparent side does not get a link up/down interrupt. Since the presence of a NTB device on the transparent side means that we have a NTB link up, we can work around the lack of an interrupt by simply calling the link up function to notify the upper layers. Authored by: Jon Mason Obtained from: Linux (Dual BSD/GPL driver) Sponsored by: EMC / Isilon Storage Division Modified: head/sys/dev/ntb/ntb_hw/ntb_hw.c Modified: head/sys/dev/ntb/ntb_hw/ntb_hw.c ============================================================================== --- head/sys/dev/ntb/ntb_hw/ntb_hw.c Tue Oct 13 23:41:06 2015 (r289271) +++ head/sys/dev/ntb/ntb_hw/ntb_hw.c Tue Oct 13 23:41:40 2015 (r289272) @@ -207,13 +207,15 @@ static void ntb_handle_legacy_interrupt( static int ntb_create_callbacks(struct ntb_softc *ntb, int num_vectors); static void ntb_free_callbacks(struct ntb_softc *ntb); static struct ntb_hw_info *ntb_get_device_info(uint32_t device_id); -static int ntb_initialize_hw(struct ntb_softc *ntb); static int ntb_setup_xeon(struct ntb_softc *ntb); static int ntb_setup_soc(struct ntb_softc *ntb); +static void ntb_teardown_xeon(struct ntb_softc *ntb); static void configure_soc_secondary_side_bars(struct ntb_softc *ntb); static void configure_xeon_secondary_side_bars(struct ntb_softc *ntb); static void ntb_handle_heartbeat(void *arg); static void ntb_handle_link_event(struct ntb_softc *ntb, int link_state); +static void ntb_hw_link_down(struct ntb_softc *ntb); +static void ntb_hw_link_up(struct ntb_softc *ntb); static void recover_soc_link(void *arg); static int ntb_check_link_status(struct ntb_softc *ntb); static void save_bar_parameters(struct ntb_pci_bar_info *bar); @@ -301,7 +303,10 @@ ntb_attach(device_t device) error = ntb_map_pci_bars(ntb); if (error) goto out; - error = ntb_initialize_hw(ntb); + if (ntb->type == NTB_SOC) + error = ntb_setup_soc(ntb); + else + error = ntb_setup_xeon(ntb); if (error) goto out; error = ntb_setup_interrupts(ntb); @@ -324,6 +329,8 @@ ntb_detach(device_t device) ntb = DEVICE2SOFTC(device); callout_drain(&ntb->heartbeat_timer); callout_drain(&ntb->lr_timer); + if (ntb->type == NTB_XEON) + ntb_teardown_xeon(ntb); ntb_teardown_interrupts(ntb); ntb_unmap_pci_bar(ntb); @@ -691,14 +698,11 @@ ntb_get_device_info(uint32_t device_id) return (NULL); } -static int -ntb_initialize_hw(struct ntb_softc *ntb) +static void +ntb_teardown_xeon(struct ntb_softc *ntb) { - if (ntb->type == NTB_SOC) - return (ntb_setup_soc(ntb)); - else - return (ntb_setup_xeon(ntb)); + ntb_hw_link_down(ntb); } static int @@ -805,8 +809,7 @@ ntb_setup_xeon(struct ntb_softc *ntb) PCIM_CMD_MEMEN | PCIM_CMD_BUSMASTEREN); /* Enable link training */ - ntb_reg_write(4, ntb->reg_ofs.lnk_cntl, - NTB_CNTL_BAR23_SNOOP | NTB_CNTL_BAR45_SNOOP); + ntb_hw_link_up(ntb); return (0); } @@ -1040,6 +1043,33 @@ ntb_handle_link_event(struct ntb_softc * } static void +ntb_hw_link_up(struct ntb_softc *ntb) +{ + + if (ntb->conn_type == NTB_CONN_TRANSPARENT) + ntb_handle_link_event(ntb, NTB_LINK_UP); + else + ntb_reg_write(4, ntb->reg_ofs.lnk_cntl, + NTB_CNTL_BAR23_SNOOP | NTB_CNTL_BAR45_SNOOP); +} + +static void +ntb_hw_link_down(struct ntb_softc *ntb) +{ + uint32_t cntl; + + if (ntb->conn_type == NTB_CONN_TRANSPARENT) { + ntb_handle_link_event(ntb, NTB_LINK_DOWN); + return; + } + + cntl = ntb_reg_read(4, ntb->reg_ofs.lnk_cntl); + cntl &= ~(NTB_CNTL_BAR23_SNOOP | NTB_CNTL_BAR45_SNOOP); + cntl |= NTB_CNTL_LINK_DISABLE; + ntb_reg_write(4, ntb->reg_ofs.lnk_cntl, cntl); +} + +static void recover_soc_link(void *arg) { struct ntb_softc *ntb = arg;