From owner-svn-src-all@freebsd.org Thu Jun 23 07:09:45 2016 Return-Path: Delivered-To: svn-src-all@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 9402FB72062; Thu, 23 Jun 2016 07:09:45 +0000 (UTC) (envelope-from sephe@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 6BA8F2EC1; Thu, 23 Jun 2016 07:09:45 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5N79iKm017895; Thu, 23 Jun 2016 07:09:44 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5N79iwQ017894; Thu, 23 Jun 2016 07:09:44 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606230709.u5N79iwQ017894@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 23 Jun 2016 07:09:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302124 - stable/10/sys/dev/hyperv/vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jun 2016 07:09:45 -0000 Author: sephe Date: Thu Jun 23 07:09:44 2016 New Revision: 302124 URL: https://svnweb.freebsd.org/changeset/base/302124 Log: MFC 300645 hyperv/vmbus: Allocate/setup IDT vector after all ISR resources are ready And release IDT vector before releasing ISR resources on interrupt teardown path. We still have some work to do on the interrupt tearing down path. MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6519 Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c Thu Jun 23 07:01:54 2016 (r302123) +++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c Thu Jun 23 07:09:44 2016 (r302124) @@ -447,35 +447,18 @@ vmbus_intr_setup(struct vmbus_softc *sc) { int cpu; - /* - * Find a free IDT vector for vmbus messages/events. - */ - sc->vmbus_idtvec = vmbus_vector_alloc(); - if (sc->vmbus_idtvec == 0) { - device_printf(sc->vmbus_dev, "cannot find free IDT vector\n"); - return ENXIO; - } - if(bootverbose) { - device_printf(sc->vmbus_dev, "vmbus IDT vector %d\n", - sc->vmbus_idtvec); - } - CPU_FOREACH(cpu) { + struct task cpuset_task; char buf[MAXCOMLEN + 1]; + cpuset_t cpu_mask; + /* Allocate an interrupt counter for Hyper-V interrupt */ snprintf(buf, sizeof(buf), "cpu%d:hyperv", cpu); intrcnt_add(buf, VMBUS_PCPU_PTR(sc, intr_cnt, cpu)); - } - - /* - * Per cpu setup. - */ - CPU_FOREACH(cpu) { - struct task cpuset_task; - cpuset_t cpu_mask; /* - * Setup taskqueue to handle events + * Setup taskqueue to handle events. Task will be per- + * channel. */ hv_vmbus_g_context.hv_event_queue[cpu] = taskqueue_create_fast("hyperv event", M_WAITOK, @@ -493,7 +476,7 @@ vmbus_intr_setup(struct vmbus_softc *sc) &cpuset_task); /* - * Setup per-cpu tasks and taskqueues to handle msg. + * Setup tasks and taskqueues to handle messages. */ hv_vmbus_g_context.hv_msg_tq[cpu] = taskqueue_create_fast( "hyperv msg", M_WAITOK, taskqueue_thread_enqueue, @@ -511,6 +494,20 @@ vmbus_intr_setup(struct vmbus_softc *sc) taskqueue_drain(hv_vmbus_g_context.hv_msg_tq[cpu], &cpuset_task); } + + /* + * All Hyper-V ISR required resources are setup, now let's find a + * free IDT vector for Hyper-V ISR and set it up. + */ + sc->vmbus_idtvec = vmbus_vector_alloc(); + if (sc->vmbus_idtvec == 0) { + device_printf(sc->vmbus_dev, "cannot find free IDT vector\n"); + return ENXIO; + } + if(bootverbose) { + device_printf(sc->vmbus_dev, "vmbus IDT vector %d\n", + sc->vmbus_idtvec); + } return 0; } @@ -519,9 +516,8 @@ vmbus_intr_teardown(struct vmbus_softc * { int cpu; - /* - * remove swi and vmbus callback vector; - */ + vmbus_vector_free(sc->vmbus_idtvec); + CPU_FOREACH(cpu) { if (hv_vmbus_g_context.hv_event_queue[cpu] != NULL) { taskqueue_free(hv_vmbus_g_context.hv_event_queue[cpu]); @@ -534,7 +530,6 @@ vmbus_intr_teardown(struct vmbus_softc * hv_vmbus_g_context.hv_msg_tq[cpu] = NULL; } } - vmbus_vector_free(sc->vmbus_idtvec); } static int @@ -706,16 +701,16 @@ vmbus_bus_init(void) sc = vmbus_get_softc(); /* - * Setup interrupt. + * Allocate DMA stuffs. */ - ret = vmbus_intr_setup(sc); + ret = vmbus_dma_alloc(sc); if (ret != 0) goto cleanup; /* - * Allocate DMA stuffs. + * Setup interrupt. */ - ret = vmbus_dma_alloc(sc); + ret = vmbus_intr_setup(sc); if (ret != 0) goto cleanup; @@ -747,8 +742,8 @@ vmbus_bus_init(void) return (ret); cleanup: - vmbus_dma_free(sc); vmbus_intr_teardown(sc); + vmbus_dma_free(sc); return (ret); } @@ -810,8 +805,8 @@ vmbus_detach(device_t dev) smp_rendezvous(NULL, vmbus_synic_teardown, NULL, NULL); - vmbus_dma_free(sc); vmbus_intr_teardown(sc); + vmbus_dma_free(sc); return (0); }