Author: sephe
Date: Mon Jul 11 07:54:58 2016
New Revision: 302557
URL: https://svnweb.freebsd.org/changeset/base/302557

Log:
  hyperv/vmbus: Save vmbus softc to channels.
  
  So that we don't need to access the global vmbus softc.
  
  MFC after:    1 week
  Sponsored by: Microsoft OSTC
  Differential Revision:        https://reviews.freebsd.org/D6863

Modified:
  head/sys/dev/hyperv/include/hyperv.h
  head/sys/dev/hyperv/vmbus/hv_channel.c
  head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
  head/sys/dev/hyperv/vmbus/hv_connection.c
  head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h

Modified: head/sys/dev/hyperv/include/hyperv.h
==============================================================================
--- head/sys/dev/hyperv/include/hyperv.h        Mon Jul 11 07:45:31 2016        
(r302556)
+++ head/sys/dev/hyperv/include/hyperv.h        Mon Jul 11 07:54:58 2016        
(r302557)
@@ -713,6 +713,7 @@ typedef struct {
 typedef struct hv_vmbus_channel {
        TAILQ_ENTRY(hv_vmbus_channel)   list_entry;
        struct hv_device*               device;
+       struct vmbus_softc              *vmbus_sc;
        hv_vmbus_channel_state          state;
        hv_vmbus_channel_offer_channel  offer_msg;
        /*

Modified: head/sys/dev/hyperv/vmbus/hv_channel.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_channel.c      Mon Jul 11 07:45:31 2016        
(r302556)
+++ head/sys/dev/hyperv/vmbus/hv_channel.c      Mon Jul 11 07:54:58 2016        
(r302557)
@@ -67,7 +67,7 @@ static void
 vmbus_channel_set_event(hv_vmbus_channel *channel)
 {
        if (channel->offer_msg.monitor_allocated) {
-               struct vmbus_softc *sc = vmbus_get_softc();
+               struct vmbus_softc *sc = channel->vmbus_sc;
                hv_vmbus_monitor_page *monitor_page;
                uint32_t chanid = channel->offer_msg.child_rel_id;
 
@@ -205,7 +205,7 @@ hv_vmbus_channel_open(
 
        vmbus_on_channel_open(new_channel);
 
-       new_channel->rxq = VMBUS_PCPU_GET(vmbus_get_softc(), event_tq,
+       new_channel->rxq = VMBUS_PCPU_GET(new_channel->vmbus_sc, event_tq,
            new_channel->target_cpu);
        TASK_INIT(&new_channel->channel_task, 0, VmbusProcessChannelEvent, 
new_channel);
 

Modified: head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Mon Jul 11 07:45:31 2016        
(r302556)
+++ head/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Mon Jul 11 07:54:58 2016        
(r302557)
@@ -39,7 +39,8 @@
 typedef void   (*vmbus_chanmsg_proc_t)
                (struct vmbus_softc *, const struct vmbus_message *);
 
-static void    vmbus_channel_on_offer_internal(
+static struct hv_vmbus_channel *hv_vmbus_allocate_channel(struct vmbus_softc 
*);
+static void    vmbus_channel_on_offer_internal(struct vmbus_softc *,
                    const hv_vmbus_channel_offer_channel *offer);
 static void    vmbus_channel_on_offer_rescind_internal(void *context);
 
@@ -131,15 +132,13 @@ hv_queue_work_item(
 /**
  * @brief Allocate and initialize a vmbus channel object
  */
-hv_vmbus_channel*
-hv_vmbus_allocate_channel(void)
+static struct hv_vmbus_channel *
+hv_vmbus_allocate_channel(struct vmbus_softc *sc)
 {
-       hv_vmbus_channel* channel;
+       struct hv_vmbus_channel *channel;
 
-       channel = (hv_vmbus_channel*) malloc(
-                                       sizeof(hv_vmbus_channel),
-                                       M_DEVBUF,
-                                       M_WAITOK | M_ZERO);
+       channel = malloc(sizeof(*channel), M_DEVBUF, M_WAITOK | M_ZERO);
+       channel->vmbus_sc = sc;
 
        mtx_init(&channel->sc_lock, "vmbus multi channel", NULL, MTX_DEF);
        TAILQ_INIT(&channel->sc_list_anchor);
@@ -297,7 +296,7 @@ vmbus_channel_cpu_set(struct hv_vmbus_ch
        }
 
        chan->target_cpu = cpu;
-       chan->target_vcpu = VMBUS_PCPU_GET(vmbus_get_softc(), vcpuid, cpu);
+       chan->target_vcpu = VMBUS_PCPU_GET(chan->vmbus_sc, vcpuid, cpu);
 
        if (bootverbose) {
                printf("vmbus_chan%u: assigned to cpu%u [vcpu%u]\n",
@@ -379,16 +378,17 @@ vmbus_channel_on_offer(struct vmbus_soft
        mtx_unlock(&vmbus_chwait_lock);
 
        offer = (const hv_vmbus_channel_offer_channel *)msg->msg_data;
-       vmbus_channel_on_offer_internal(offer);
+       vmbus_channel_on_offer_internal(sc, offer);
 }
 
 static void
-vmbus_channel_on_offer_internal(const hv_vmbus_channel_offer_channel *offer)
+vmbus_channel_on_offer_internal(struct vmbus_softc *sc,
+    const hv_vmbus_channel_offer_channel *offer)
 {
        hv_vmbus_channel* new_channel;
 
        /* Allocate the channel object and save this offer */
-       new_channel = hv_vmbus_allocate_channel();
+       new_channel = hv_vmbus_allocate_channel(sc);
 
        /*
         * By default we setup state to enable batched
@@ -681,7 +681,7 @@ vmbus_select_outgoing_channel(struct hv_
                return outgoing_channel;
        }
 
-       cur_vcpu = VMBUS_PCPU_GET(vmbus_get_softc(), vcpuid, smp_pro_id);
+       cur_vcpu = VMBUS_PCPU_GET(primary->vmbus_sc, vcpuid, smp_pro_id);
        
        TAILQ_FOREACH(new_channel, &primary->sc_list_anchor, sc_list_entry) {
                if (new_channel->state != HV_CHANNEL_OPENED_STATE){

Modified: head/sys/dev/hyperv/vmbus/hv_connection.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_connection.c   Mon Jul 11 07:45:31 2016        
(r302556)
+++ head/sys/dev/hyperv/vmbus/hv_connection.c   Mon Jul 11 07:54:58 2016        
(r302557)
@@ -204,7 +204,7 @@ int hv_vmbus_post_message(void *buffer, 
 int
 hv_vmbus_set_event(hv_vmbus_channel *channel)
 {
-       struct vmbus_softc *sc = vmbus_get_softc();
+       struct vmbus_softc *sc = channel->vmbus_sc;
        int ret = 0;
        uint32_t chanid = channel->offer_msg.child_rel_id;
 
@@ -222,7 +222,7 @@ vmbus_on_channel_open(const struct hv_vm
        int flag_cnt;
 
        flag_cnt = (chan->offer_msg.child_rel_id / VMBUS_EVTFLAG_LEN) + 1;
-       flag_cnt_ptr = VMBUS_PCPU_PTR(vmbus_get_softc(), event_flags_cnt,
+       flag_cnt_ptr = VMBUS_PCPU_PTR(chan->vmbus_sc, event_flags_cnt,
            chan->target_cpu);
 
        for (;;) {

Modified: head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h   Mon Jul 11 07:45:31 2016        
(r302556)
+++ head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h   Mon Jul 11 07:54:58 2016        
(r302557)
@@ -395,7 +395,6 @@ void                        hv_ring_buffer_read_begin(
 uint32_t               hv_ring_buffer_read_end(
                                hv_vmbus_ring_buffer_info       *ring_info);
 
-hv_vmbus_channel*      hv_vmbus_allocate_channel(void);
 void                   hv_vmbus_free_vmbus_channel(hv_vmbus_channel *channel);
 void                   hv_vmbus_release_unattached_channels(void);
 
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to