Author: jhb
Date: Tue Mar 13 21:42:38 2018
New Revision: 330882
URL: https://svnweb.freebsd.org/changeset/base/330882

Log:
  Simplify error handling in t4_tom.ko module loading.
  
  - Change t4_ddp_mod_load() to return void instead of always returning
    success.  This avoids having to pretend to have proper support for
    unloading when only part of t4_tom_mod_load() has run.
  - If t4_register_uld() fails, don't invoke t4_tom_mod_unload() directly.
    The module handling code in the kernel invokes MOD_UNLOAD on a module
    whose MOD_LOAD fails with an error already.
  
  Reviewed by:  np (part of a larger patch)
  MFC after:    1 month
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/tom/t4_ddp.c
  head/sys/dev/cxgbe/tom/t4_tom.c
  head/sys/dev/cxgbe/tom/t4_tom.h

Modified: head/sys/dev/cxgbe/tom/t4_ddp.c
==============================================================================
--- head/sys/dev/cxgbe/tom/t4_ddp.c     Tue Mar 13 20:54:18 2018        
(r330881)
+++ head/sys/dev/cxgbe/tom/t4_ddp.c     Tue Mar 13 21:42:38 2018        
(r330882)
@@ -1939,7 +1939,7 @@ t4_aio_queue_ddp(struct socket *so, struct kaiocb *job
        return (0);
 }
 
-int
+void
 t4_ddp_mod_load(void)
 {
 
@@ -1948,7 +1948,6 @@ t4_ddp_mod_load(void)
        TAILQ_INIT(&ddp_orphan_pagesets);
        mtx_init(&ddp_orphan_pagesets_lock, "ddp orphans", NULL, MTX_DEF);
        TASK_INIT(&ddp_orphan_task, 0, ddp_free_orphan_pagesets, NULL);
-       return (0);
 }
 
 void

Modified: head/sys/dev/cxgbe/tom/t4_tom.c
==============================================================================
--- head/sys/dev/cxgbe/tom/t4_tom.c     Tue Mar 13 20:54:18 2018        
(r330881)
+++ head/sys/dev/cxgbe/tom/t4_tom.c     Tue Mar 13 21:42:38 2018        
(r330882)
@@ -1170,7 +1170,6 @@ t4_aio_queue_tom(struct socket *so, struct kaiocb *job
 static int
 t4_tom_mod_load(void)
 {
-       int rc;
        struct protosw *tcp_protosw, *tcp6_protosw;
 
        /* CPL handlers */
@@ -1178,9 +1177,7 @@ t4_tom_mod_load(void)
        t4_init_listen_cpl_handlers();
        t4_init_cpl_io_handlers();
 
-       rc = t4_ddp_mod_load();
-       if (rc != 0)
-               return (rc);
+       t4_ddp_mod_load();
 
        tcp_protosw = pffindproto(PF_INET, IPPROTO_TCP, SOCK_STREAM);
        if (tcp_protosw == NULL)
@@ -1202,11 +1199,7 @@ t4_tom_mod_load(void)
        ifaddr_evhandler = EVENTHANDLER_REGISTER(ifaddr_event,
            t4_tom_ifaddr_event, NULL, EVENTHANDLER_PRI_ANY);
 
-       rc = t4_register_uld(&tom_uld_info);
-       if (rc != 0)
-               t4_tom_mod_unload();
-
-       return (rc);
+       return (t4_register_uld(&tom_uld_info));
 }
 
 static void

Modified: head/sys/dev/cxgbe/tom/t4_tom.h
==============================================================================
--- head/sys/dev/cxgbe/tom/t4_tom.h     Tue Mar 13 20:54:18 2018        
(r330881)
+++ head/sys/dev/cxgbe/tom/t4_tom.h     Tue Mar 13 21:42:38 2018        
(r330882)
@@ -389,7 +389,7 @@ void t4_free_page_pods(struct ppod_reservation *);
 int t4_soreceive_ddp(struct socket *, struct sockaddr **, struct uio *,
     struct mbuf **, struct mbuf **, int *);
 int t4_aio_queue_ddp(struct socket *, struct kaiocb *);
-int t4_ddp_mod_load(void);
+void t4_ddp_mod_load(void);
 void t4_ddp_mod_unload(void);
 void ddp_assert_empty(struct toepcb *);
 void ddp_init_toep(struct toepcb *);
_______________________________________________
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