All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] For review - core RTDM, RTnet changes
@ 2019-06-20 17:29 Philippe Gerum
  2019-06-20 17:29 ` [PATCH 1/2] drivers/net: drop socket-specific module refcounting Philippe Gerum
  2019-06-20 17:29 ` [PATCH 2/2] cobalt: switch hand over status to -ENODEV for non-RTDM fd Philippe Gerum
  0 siblings, 2 replies; 12+ messages in thread
From: Philippe Gerum @ 2019-06-20 17:29 UTC (permalink / raw)
  To: xenomai

I'm sending these changes early on for review because they might have
ramifications, so more eyeballs are needed to make sure nothing was
overlooked.  These changes are prereqs to addressing the device
teardown issue properly, so there is even more incentive to have them
right.

Thanks,

Philippe Gerum (2):
  drivers/net: drop socket-specific module refcounting
  cobalt: switch hand over status to -ENODEV for non-RTDM fd

 kernel/cobalt/rtdm/fd.c                       |  7 +--
 .../drivers/net/stack/include/rtnet_socket.h  | 15 ++----
 kernel/drivers/net/stack/ipv4/icmp.c          |  4 +-
 kernel/drivers/net/stack/socket.c             | 27 ++++-------
 lib/cobalt/rtdm.c                             | 46 +++++++++----------
 5 files changed, 40 insertions(+), 59 deletions(-)

-- 
2.21.0



^ permalink raw reply	[flat|nested] 12+ messages in thread
* [PATCH 1/2] drivers/net: drop socket-specific module refcounting
@ 2019-08-30 16:04 Philippe Gerum
  2019-08-30 16:59 ` Jan Kiszka
  0 siblings, 1 reply; 12+ messages in thread
From: Philippe Gerum @ 2019-08-30 16:04 UTC (permalink / raw)
  To: xenomai

RTDM already refcounts rtdm_fd descriptors to prevent unsafe module
unloading while connections are still active. We can remove the legacy
module refcounting done by the generic socket code, since every socket
is covered by an RTDM file descriptor.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
---
 .../drivers/net/stack/include/rtnet_socket.h  | 15 +++--------
 kernel/drivers/net/stack/ipv4/icmp.c          |  4 +--
 kernel/drivers/net/stack/socket.c             | 27 ++++++-------------
 3 files changed, 13 insertions(+), 33 deletions(-)

diff --git a/kernel/drivers/net/stack/include/rtnet_socket.h b/kernel/drivers/net/stack/include/rtnet_socket.h
index 351e62c77..0d8850c7f 100644
--- a/kernel/drivers/net/stack/include/rtnet_socket.h
+++ b/kernel/drivers/net/stack/include/rtnet_socket.h
@@ -76,8 +76,6 @@ struct rtsocket {
 	    int                  ifindex;
 	} packet;
     } prot;
-
-    struct module *owner;
 };
 
 
@@ -97,10 +95,7 @@ int rtnet_put_arg(struct rtdm_fd *fd, void *dst,
 #define rt_socket_dereference(sock) \
     rtdm_fd_unlock(rt_socket_fd(sock))
 
-int __rt_socket_init(struct rtdm_fd *fd, unsigned short protocol,
-		struct module *module);
-#define rt_socket_init(fd, proto) \
-    __rt_socket_init(fd, proto, THIS_MODULE)
+int rt_socket_init(struct rtdm_fd *fd, unsigned short protocol);
 
 void rt_socket_cleanup(struct rtdm_fd *fd);
 int rt_socket_common_ioctl(struct rtdm_fd *fd, int request, void __user *arg);
@@ -110,16 +105,12 @@ int rt_socket_select_bind(struct rtdm_fd *fd,
 			  enum rtdm_selecttype type,
 			  unsigned fd_index);
 
-int __rt_bare_socket_init(struct rtdm_fd *fd, unsigned short protocol,
-			unsigned int priority, unsigned int pool_size,
-			struct module *module);
-#define rt_bare_socket_init(fd, proto, prio, pool_sz) \
-    __rt_bare_socket_init(fd, proto, prio, pool_sz, THIS_MODULE)
+int rt_bare_socket_init(struct rtdm_fd *fd, unsigned short protocol,
+			unsigned int priority, unsigned int pool_size);
 
 static inline void rt_bare_socket_cleanup(struct rtsocket *sock)
 {
     rtskb_pool_release(&sock->skb_pool);
-    module_put(sock->owner);
 }
 
 #endif  /* __RTNET_SOCKET_H_ */
diff --git a/kernel/drivers/net/stack/ipv4/icmp.c b/kernel/drivers/net/stack/ipv4/icmp.c
index 58d97cd7f..a944ef6b7 100644
--- a/kernel/drivers/net/stack/ipv4/icmp.c
+++ b/kernel/drivers/net/stack/ipv4/icmp.c
@@ -526,8 +526,8 @@ void __init rt_icmp_init(void)
 {
     int skbs;
 
-    skbs = __rt_bare_socket_init(icmp_fd, IPPROTO_ICMP, RT_ICMP_PRIO,
-			    ICMP_REPLY_POOL_SIZE, NULL);
+    skbs = rt_bare_socket_init(icmp_fd, IPPROTO_ICMP, RT_ICMP_PRIO,
+			    ICMP_REPLY_POOL_SIZE);
     BUG_ON(skbs < 0);
     if (skbs < ICMP_REPLY_POOL_SIZE)
 	printk("RTnet: allocated only %d icmp rtskbs\n", skbs);
diff --git a/kernel/drivers/net/stack/socket.c b/kernel/drivers/net/stack/socket.c
index ce4e4cb46..747db052f 100644
--- a/kernel/drivers/net/stack/socket.c
+++ b/kernel/drivers/net/stack/socket.c
@@ -50,36 +50,27 @@ MODULE_PARM_DESC(socket_rtskbs, "Default number of realtime socket buffers in so
  *  internal socket functions                                           *
  ************************************************************************/
 
-int __rt_bare_socket_init(struct rtdm_fd *fd, unsigned short protocol,
-			unsigned int priority, unsigned int pool_size,
-			struct module *module)
+int rt_bare_socket_init(struct rtdm_fd *fd, unsigned short protocol,
+			unsigned int priority, unsigned int pool_size)
 {
     struct rtsocket *sock = rtdm_fd_to_private(fd);
     int err;
 
-    err = try_module_get(module);
-    if (!err)
-	return -EAFNOSUPPORT;
-
     err = rtskb_pool_init(&sock->skb_pool, pool_size, NULL, fd);
-    if (err < 0) {
-	module_put(module);
+    if (err < 0)
 	return err;
-    }
 
     sock->protocol = protocol;
     sock->priority = priority;
-    sock->owner = module;
 
     return err;
 }
-EXPORT_SYMBOL_GPL(__rt_bare_socket_init);
+EXPORT_SYMBOL_GPL(rt_bare_socket_init);
 
 /***
  *  rt_socket_init - initialises a new socket structure
  */
-int __rt_socket_init(struct rtdm_fd *fd, unsigned short protocol,
-		struct module *module)
+int rt_socket_init(struct rtdm_fd *fd, unsigned short protocol)
 {
     struct rtsocket *sock = rtdm_fd_to_private(fd);
     unsigned int    pool_size;
@@ -94,10 +85,10 @@ int __rt_socket_init(struct rtdm_fd *fd, unsigned short protocol,
     rtdm_lock_init(&sock->param_lock);
     rtdm_sem_init(&sock->pending_sem, 0);
 
-    pool_size = __rt_bare_socket_init(fd, protocol,
+    pool_size = rt_bare_socket_init(fd, protocol,
 				    RTSKB_PRIO_VALUE(SOCK_DEF_PRIO,
 						    RTSKB_DEF_RT_CHANNEL),
-				    socket_rtskbs, module);
+				    socket_rtskbs);
     sock->pool_size = pool_size;
     mutex_init(&sock->pool_nrt_lock);
 
@@ -112,7 +103,7 @@ int __rt_socket_init(struct rtdm_fd *fd, unsigned short protocol,
 
     return 0;
 }
-EXPORT_SYMBOL_GPL(__rt_socket_init);
+EXPORT_SYMBOL_GPL(rt_socket_init);
 
 
 /***
@@ -133,8 +124,6 @@ void rt_socket_cleanup(struct rtdm_fd *fd)
 	rtskb_pool_release(&sock->skb_pool);
 
     mutex_unlock(&sock->pool_nrt_lock);
-
-    module_put(sock->owner);
 }
 EXPORT_SYMBOL_GPL(rt_socket_cleanup);
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-08-30 16:59 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-20 17:29 [PATCH 0/2] For review - core RTDM, RTnet changes Philippe Gerum
2019-06-20 17:29 ` [PATCH 1/2] drivers/net: drop socket-specific module refcounting Philippe Gerum
2019-07-04  9:04   ` Jan Kiszka
2019-06-20 17:29 ` [PATCH 2/2] cobalt: switch hand over status to -ENODEV for non-RTDM fd Philippe Gerum
2019-07-04  9:04   ` Jan Kiszka
2019-08-29 14:12   ` Lange Norbert
2019-08-29 14:45     ` Philippe Gerum
2019-08-29 14:52     ` Jan Kiszka
2019-08-30  9:58       ` Lange Norbert
2019-08-30 11:23         ` Jan Kiszka
2019-08-30 16:04 [PATCH 1/2] drivers/net: drop socket-specific module refcounting Philippe Gerum
2019-08-30 16:59 ` Jan Kiszka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.