* [PATCH] pci: save list of detached devices, and re-probe during driver unload @ 2015-02-26 6:33 Raz Amir [not found] ` <1424932400-66862-1-git-send-email-razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 26+ messages in thread From: Raz Amir @ 2015-02-26 6:33 UTC (permalink / raw) To: dev-VfR2kkLFssw Added code that saves the pointers to the detached devices, during driver loading, and during driver unloading, go over the list, and re-attach them by calling device_probe_and_attach on each device. Signed-off-by: Raz Amir <razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- lib/librte_eal/bsdapp/nic_uio/nic_uio.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c index 5ae8560..7d702a5 100644 --- a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c +++ b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c @@ -55,6 +55,9 @@ __FBSDID("$FreeBSD$"); #define MAX_BARS (PCIR_MAX_BAR_0 + 1) +#define MAX_DETACHED_DEVICES 128 +static device_t detached_devices[MAX_DETACHED_DEVICES] = {}; +static int last_detached = 0; struct nic_uio_softc { device_t dev_t; @@ -291,14 +294,35 @@ nic_uio_load(void) if (dev != NULL) for (i = 0; i < NUM_DEVICES; i++) if (pci_get_vendor(dev) == devices[i].vend && - pci_get_device(dev) == devices[i].dev) + pci_get_device(dev) == devices[i].dev) { + if (last_detached+1 < MAX_DETACHED_DEVICES) { + printf("nic_uio_load: detaching and storing dev=%p\n", dev); + detached_devices[last_detached++] = dev; + } + else { + printf("nic_uio_load: reached MAX_DETACHED_DEVICES=%d. dev=%p won't be reattached\n", + MAX_DETACHED_DEVICES, dev); + } + device_detach(dev); + } } } static void nic_uio_unload(void) { + int i; + printf("nic_uio_unload: entered ... \n"); + + for (i = 0; i < last_detached; i++) { + printf("nic_uio_unload: calling to device_probe_and_attach for dev=%p...\n", + detached_devices[i]); + device_probe_and_attach(detached_devices[i]); + printf("nic_uio_unload: done.\n"); + } + + printf("nic_uio_unload: leaving ... \n"); } static int -- 2.1.2 ^ permalink raw reply related [flat|nested] 26+ messages in thread
[parent not found: <1424932400-66862-1-git-send-email-razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH] pci: save list of detached devices, and re-probe during driver unload [not found] ` <1424932400-66862-1-git-send-email-razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2015-03-01 13:48 ` Neil Horman [not found] ` <20150301134818.GA31578-0o1r3XBGOEbbgkc5XkKeNuvMHUBZFtU3YPYVAmT7z5s@public.gmane.org> 2015-03-03 13:32 ` Bruce Richardson ` (4 subsequent siblings) 5 siblings, 1 reply; 26+ messages in thread From: Neil Horman @ 2015-03-01 13:48 UTC (permalink / raw) To: Raz Amir; +Cc: dev-VfR2kkLFssw On Thu, Feb 26, 2015 at 06:33:20AM +0000, Raz Amir wrote: > Added code that saves the pointers to the detached devices, during > driver loading, and during driver unloading, go over the list, > and re-attach them by calling device_probe_and_attach > on each device. > > Signed-off-by: Raz Amir <razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > --- > lib/librte_eal/bsdapp/nic_uio/nic_uio.c | 26 +++++++++++++++++++++++++- > 1 file changed, 25 insertions(+), 1 deletion(-) > > diff --git a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > index 5ae8560..7d702a5 100644 > --- a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > +++ b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > @@ -55,6 +55,9 @@ __FBSDID("$FreeBSD$"); > > #define MAX_BARS (PCIR_MAX_BAR_0 + 1) > > +#define MAX_DETACHED_DEVICES 128 > +static device_t detached_devices[MAX_DETACHED_DEVICES] = {}; > +static int last_detached = 0; > > struct nic_uio_softc { > device_t dev_t; > @@ -291,14 +294,35 @@ nic_uio_load(void) > if (dev != NULL) > for (i = 0; i < NUM_DEVICES; i++) > if (pci_get_vendor(dev) == devices[i].vend && > - pci_get_device(dev) == devices[i].dev) > + pci_get_device(dev) == devices[i].dev) { > + if (last_detached+1 < MAX_DETACHED_DEVICES) { > + printf("nic_uio_load: detaching and storing dev=%p\n", dev); No printfs. Use the logging facilities > + detached_devices[last_detached++] = dev; > + } > + else { > + printf("nic_uio_load: reached MAX_DETACHED_DEVICES=%d. dev=%p won't be reattached\n", > + MAX_DETACHED_DEVICES, dev); Dittto > + } > + > device_detach(dev); > + } > } > } > > static void > nic_uio_unload(void) > { > + int i; > + printf("nic_uio_unload: entered ... \n"); > + > + for (i = 0; i < last_detached; i++) { > + printf("nic_uio_unload: calling to device_probe_and_attach for dev=%p...\n", > + detached_devices[i]); > + device_probe_and_attach(detached_devices[i]); Where is this defined? It doesn't appear to be in the latest dpdk. > + printf("nic_uio_unload: done.\n"); > + } > + > + printf("nic_uio_unload: leaving ... \n"); > } > > static int > -- > 2.1.2 > > ^ permalink raw reply [flat|nested] 26+ messages in thread
[parent not found: <20150301134818.GA31578-0o1r3XBGOEbbgkc5XkKeNuvMHUBZFtU3YPYVAmT7z5s@public.gmane.org>]
* Re: [PATCH] pci: save list of detached devices, and re-probe during driver unload [not found] ` <20150301134818.GA31578-0o1r3XBGOEbbgkc5XkKeNuvMHUBZFtU3YPYVAmT7z5s@public.gmane.org> @ 2015-03-01 14:21 ` Raz Amir 2015-03-01 17:16 ` Neil Horman 0 siblings, 1 reply; 26+ messages in thread From: Raz Amir @ 2015-03-01 14:21 UTC (permalink / raw) To: 'Neil Horman'; +Cc: dev-VfR2kkLFssw Can you refer me to the logging facilities you are referring to for this Freebsd driver? device_probe_and_attach is an API in Freebsd kernel which is called during boot for finding the relevant driver for each device. I added manual call to it in the driver unload for re-probing and re-matching the devices that were detached by the driver. Before this change, you had to reboot in order to get the devices back. -----Original Message----- From: Neil Horman [mailto:nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org] Sent: 01 March 2015 15:48 To: Raz Amir Cc: dev-VfR2kkLFssw@public.gmane.org Subject: Re: [dpdk-dev] [PATCH] pci: save list of detached devices, and re-probe during driver unload On Thu, Feb 26, 2015 at 06:33:20AM +0000, Raz Amir wrote: > Added code that saves the pointers to the detached devices, during > driver loading, and during driver unloading, go over the list, > and re-attach them by calling device_probe_and_attach > on each device. > > Signed-off-by: Raz Amir <razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > --- > lib/librte_eal/bsdapp/nic_uio/nic_uio.c | 26 +++++++++++++++++++++++++- > 1 file changed, 25 insertions(+), 1 deletion(-) > > diff --git a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > index 5ae8560..7d702a5 100644 > --- a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > +++ b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > @@ -55,6 +55,9 @@ __FBSDID("$FreeBSD$"); > > #define MAX_BARS (PCIR_MAX_BAR_0 + 1) > > +#define MAX_DETACHED_DEVICES 128 > +static device_t detached_devices[MAX_DETACHED_DEVICES] = {}; > +static int last_detached = 0; > > struct nic_uio_softc { > device_t dev_t; > @@ -291,14 +294,35 @@ nic_uio_load(void) > if (dev != NULL) > for (i = 0; i < NUM_DEVICES; i++) > if (pci_get_vendor(dev) == devices[i].vend && > - pci_get_device(dev) == devices[i].dev) > + pci_get_device(dev) == devices[i].dev) { > + if (last_detached+1 < MAX_DETACHED_DEVICES) { > + printf("nic_uio_load: detaching and storing dev=%p\n", dev); No printfs. Use the logging facilities > + detached_devices[last_detached++] = dev; > + } > + else { > + printf("nic_uio_load: reached MAX_DETACHED_DEVICES=%d. dev=%p won't be reattached\n", > + MAX_DETACHED_DEVICES, dev); Dittto > + } > + > device_detach(dev); > + } > } > } > > static void > nic_uio_unload(void) > { > + int i; > + printf("nic_uio_unload: entered ... \n"); > + > + for (i = 0; i < last_detached; i++) { > + printf("nic_uio_unload: calling to device_probe_and_attach for dev=%p...\n", > + detached_devices[i]); > + device_probe_and_attach(detached_devices[i]); Where is this defined? It doesn't appear to be in the latest dpdk. > + printf("nic_uio_unload: done.\n"); > + } > + > + printf("nic_uio_unload: leaving ... \n"); > } > > static int > -- > 2.1.2 > > ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] pci: save list of detached devices, and re-probe during driver unload 2015-03-01 14:21 ` Raz Amir @ 2015-03-01 17:16 ` Neil Horman [not found] ` <20150301171646.GA32246-0o1r3XBGOEbbgkc5XkKeNuvMHUBZFtU3YPYVAmT7z5s@public.gmane.org> 0 siblings, 1 reply; 26+ messages in thread From: Neil Horman @ 2015-03-01 17:16 UTC (permalink / raw) To: Raz Amir; +Cc: dev-VfR2kkLFssw On Sun, Mar 01, 2015 at 04:21:10PM +0200, Raz Amir wrote: > Can you refer me to the logging facilities you are referring to for this > Freebsd driver? > device_probe_and_attach is an API in Freebsd kernel which is called during rte_log and friends. > boot for finding the relevant driver for each device. > I added manual call to it in the driver unload for re-probing and > re-matching the devices that were detached by the driver. > Before this change, you had to reboot in order to get the devices back. > my bad, I didn't see it defined and was thinking it was removed from an earlier version of the dpdk. Neil > -----Original Message----- > From: Neil Horman [mailto:nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org] > Sent: 01 March 2015 15:48 > To: Raz Amir > Cc: dev-VfR2kkLFssw@public.gmane.org > Subject: Re: [dpdk-dev] [PATCH] pci: save list of detached devices, and > re-probe during driver unload > > On Thu, Feb 26, 2015 at 06:33:20AM +0000, Raz Amir wrote: > > Added code that saves the pointers to the detached devices, during > > driver loading, and during driver unloading, go over the list, > > and re-attach them by calling device_probe_and_attach > > on each device. > > > > Signed-off-by: Raz Amir <razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > --- > > lib/librte_eal/bsdapp/nic_uio/nic_uio.c | 26 +++++++++++++++++++++++++- > > 1 file changed, 25 insertions(+), 1 deletion(-) > > > > diff --git a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > > index 5ae8560..7d702a5 100644 > > --- a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > > +++ b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > > @@ -55,6 +55,9 @@ __FBSDID("$FreeBSD$"); > > > > #define MAX_BARS (PCIR_MAX_BAR_0 + 1) > > > > +#define MAX_DETACHED_DEVICES 128 > > +static device_t detached_devices[MAX_DETACHED_DEVICES] = {}; > > +static int last_detached = 0; > > > > struct nic_uio_softc { > > device_t dev_t; > > @@ -291,14 +294,35 @@ nic_uio_load(void) > > if (dev != NULL) > > for (i = 0; i < NUM_DEVICES; i++) > > if (pci_get_vendor(dev) == devices[i].vend > && > > - pci_get_device(dev) == > devices[i].dev) > > + pci_get_device(dev) == > devices[i].dev) { > > + if (last_detached+1 > < MAX_DETACHED_DEVICES) { > > + > printf("nic_uio_load: detaching and storing dev=%p\n", dev); > No printfs. Use the logging facilities > > > + > detached_devices[last_detached++] = dev; > > + } > > + else { > > + > printf("nic_uio_load: reached MAX_DETACHED_DEVICES=%d. dev=%p won't be > reattached\n", > > + > MAX_DETACHED_DEVICES, dev); > Dittto > > > + } > > + > > device_detach(dev); > > + } > > } > > } > > > > static void > > nic_uio_unload(void) > > { > > + int i; > > + printf("nic_uio_unload: entered ... \n"); > > + > > + for (i = 0; i < last_detached; i++) { > > + printf("nic_uio_unload: calling to device_probe_and_attach > for dev=%p...\n", > > + detached_devices[i]); > > + device_probe_and_attach(detached_devices[i]); > Where is this defined? It doesn't appear to be in the latest dpdk. > > > + printf("nic_uio_unload: done.\n"); > > + } > > + > > + printf("nic_uio_unload: leaving ... \n"); > > } > > > > static int > > -- > > 2.1.2 > > > > > > ^ permalink raw reply [flat|nested] 26+ messages in thread
[parent not found: <20150301171646.GA32246-0o1r3XBGOEbbgkc5XkKeNuvMHUBZFtU3YPYVAmT7z5s@public.gmane.org>]
* Re: [PATCH] pci: save list of detached devices, and re-probe during driver unload [not found] ` <20150301171646.GA32246-0o1r3XBGOEbbgkc5XkKeNuvMHUBZFtU3YPYVAmT7z5s@public.gmane.org> @ 2015-03-02 8:18 ` Raz Amir 2015-03-02 11:36 ` Neil Horman 0 siblings, 1 reply; 26+ messages in thread From: Raz Amir @ 2015-03-02 8:18 UTC (permalink / raw) To: 'Neil Horman'; +Cc: dev-VfR2kkLFssw The patch I suggest is in the nic_uio freebsd kernel driver. I don't think that rte_log can be used there. I checked the contigmem freebsd driver and it uses printf. I can either remove those printfs, or keep them. I suggest keeping them as they were very helpful for understanding the flow, and they don't provide too much output (depending on the amount of interfaces connected to the nic_uio driver). How should I continue with this patch? BTW, I don't see it in incoming patches page at http://dpdk.org/dev/patchwork/project/dpdk/list/?page=1 Is it because I missed something in the code contribution instruction? -----Original Message----- From: Neil Horman [mailto:nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org] Sent: 01 March 2015 19:17 To: Raz Amir Cc: dev-VfR2kkLFssw@public.gmane.org Subject: Re: [dpdk-dev] [PATCH] pci: save list of detached devices, and re-probe during driver unload On Sun, Mar 01, 2015 at 04:21:10PM +0200, Raz Amir wrote: > Can you refer me to the logging facilities you are referring to for > this Freebsd driver? > device_probe_and_attach is an API in Freebsd kernel which is called > during rte_log and friends. > boot for finding the relevant driver for each device. > I added manual call to it in the driver unload for re-probing and > re-matching the devices that were detached by the driver. > Before this change, you had to reboot in order to get the devices back. > my bad, I didn't see it defined and was thinking it was removed from an earlier version of the dpdk. Neil > -----Original Message----- > From: Neil Horman [mailto:nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org] > Sent: 01 March 2015 15:48 > To: Raz Amir > Cc: dev-VfR2kkLFssw@public.gmane.org > Subject: Re: [dpdk-dev] [PATCH] pci: save list of detached devices, > and re-probe during driver unload > > On Thu, Feb 26, 2015 at 06:33:20AM +0000, Raz Amir wrote: > > Added code that saves the pointers to the detached devices, during > > driver loading, and during driver unloading, go over the list, and > > re-attach them by calling device_probe_and_attach on each device. > > > > Signed-off-by: Raz Amir <razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > --- > > lib/librte_eal/bsdapp/nic_uio/nic_uio.c | 26 > > +++++++++++++++++++++++++- > > 1 file changed, 25 insertions(+), 1 deletion(-) > > > > diff --git a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > > index 5ae8560..7d702a5 100644 > > --- a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > > +++ b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > > @@ -55,6 +55,9 @@ __FBSDID("$FreeBSD$"); > > > > #define MAX_BARS (PCIR_MAX_BAR_0 + 1) > > > > +#define MAX_DETACHED_DEVICES 128 > > +static device_t detached_devices[MAX_DETACHED_DEVICES] = {}; static > > +int last_detached = 0; > > > > struct nic_uio_softc { > > device_t dev_t; > > @@ -291,14 +294,35 @@ nic_uio_load(void) > > if (dev != NULL) > > for (i = 0; i < NUM_DEVICES; i++) > > if (pci_get_vendor(dev) == devices[i].vend > && > > - pci_get_device(dev) == > devices[i].dev) > > + pci_get_device(dev) == > devices[i].dev) { > > + if (last_detached+1 > < MAX_DETACHED_DEVICES) { > > + > printf("nic_uio_load: detaching and storing dev=%p\n", dev); No > printfs. Use the logging facilities > > > + > detached_devices[last_detached++] = dev; > > + } > > + else { > > + > printf("nic_uio_load: reached MAX_DETACHED_DEVICES=%d. dev=%p won't be > reattached\n", > > + > MAX_DETACHED_DEVICES, dev); > Dittto > > > + } > > + > > device_detach(dev); > > + } > > } > > } > > > > static void > > nic_uio_unload(void) > > { > > + int i; > > + printf("nic_uio_unload: entered ... \n"); > > + > > + for (i = 0; i < last_detached; i++) { > > + printf("nic_uio_unload: calling to device_probe_and_attach > for dev=%p...\n", > > + detached_devices[i]); > > + device_probe_and_attach(detached_devices[i]); > Where is this defined? It doesn't appear to be in the latest dpdk. > > > + printf("nic_uio_unload: done.\n"); > > + } > > + > > + printf("nic_uio_unload: leaving ... \n"); > > } > > > > static int > > -- > > 2.1.2 > > > > > > ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] pci: save list of detached devices, and re-probe during driver unload 2015-03-02 8:18 ` Raz Amir @ 2015-03-02 11:36 ` Neil Horman [not found] ` <20150302113654.GA20329-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org> 0 siblings, 1 reply; 26+ messages in thread From: Neil Horman @ 2015-03-02 11:36 UTC (permalink / raw) To: Raz Amir; +Cc: dev-VfR2kkLFssw On Mon, Mar 02, 2015 at 10:18:42AM +0200, Raz Amir wrote: > The patch I suggest is in the nic_uio freebsd kernel driver. I don't think > that rte_log can be used there. > I checked the contigmem freebsd driver and it uses printf. > I can either remove those printfs, or keep them. > I suggest keeping them as they were very helpful for understanding the flow, > and they don't provide too much output (depending on the amount of > interfaces connected to the nic_uio driver). > You're right you can't use it, I thought it was the user space support for the uio driver, not the kernel module > How should I continue with this patch? > BTW, I don't see it in incoming patches page at > http://dpdk.org/dev/patchwork/project/dpdk/list/?page=1 > Is it because I missed something in the code contribution instruction? > > -----Original Message----- > From: Neil Horman [mailto:nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org] > Sent: 01 March 2015 19:17 > To: Raz Amir > Cc: dev-VfR2kkLFssw@public.gmane.org > Subject: Re: [dpdk-dev] [PATCH] pci: save list of detached devices, and > re-probe during driver unload > > On Sun, Mar 01, 2015 at 04:21:10PM +0200, Raz Amir wrote: > > Can you refer me to the logging facilities you are referring to for > > this Freebsd driver? > > device_probe_and_attach is an API in Freebsd kernel which is called > > during > rte_log and friends. > > > boot for finding the relevant driver for each device. > > I added manual call to it in the driver unload for re-probing and > > re-matching the devices that were detached by the driver. > > Before this change, you had to reboot in order to get the devices back. > > > my bad, I didn't see it defined and was thinking it was removed from an > earlier version of the dpdk. > Neil > > > -----Original Message----- > > From: Neil Horman [mailto:nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org] > > Sent: 01 March 2015 15:48 > > To: Raz Amir > > Cc: dev-VfR2kkLFssw@public.gmane.org > > Subject: Re: [dpdk-dev] [PATCH] pci: save list of detached devices, > > and re-probe during driver unload > > > > On Thu, Feb 26, 2015 at 06:33:20AM +0000, Raz Amir wrote: > > > Added code that saves the pointers to the detached devices, during > > > driver loading, and during driver unloading, go over the list, and > > > re-attach them by calling device_probe_and_attach on each device. > > > > > > Signed-off-by: Raz Amir <razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > --- > > > lib/librte_eal/bsdapp/nic_uio/nic_uio.c | 26 > > > +++++++++++++++++++++++++- > > > 1 file changed, 25 insertions(+), 1 deletion(-) > > > > > > diff --git a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > > b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > > > index 5ae8560..7d702a5 100644 > > > --- a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > > > +++ b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > > > @@ -55,6 +55,9 @@ __FBSDID("$FreeBSD$"); > > > > > > #define MAX_BARS (PCIR_MAX_BAR_0 + 1) > > > > > > +#define MAX_DETACHED_DEVICES 128 > > > +static device_t detached_devices[MAX_DETACHED_DEVICES] = {}; static > > > +int last_detached = 0; > > > > > > struct nic_uio_softc { > > > device_t dev_t; > > > @@ -291,14 +294,35 @@ nic_uio_load(void) > > > if (dev != NULL) > > > for (i = 0; i < NUM_DEVICES; i++) > > > if (pci_get_vendor(dev) == devices[i].vend > > && > > > - pci_get_device(dev) == > > devices[i].dev) > > > + pci_get_device(dev) == > > devices[i].dev) { > > > + if (last_detached+1 > > < MAX_DETACHED_DEVICES) { > > > + > > printf("nic_uio_load: detaching and storing dev=%p\n", dev); No > > printfs. Use the logging facilities > > > > > + > > detached_devices[last_detached++] = dev; > > > + } > > > + else { > > > + > > printf("nic_uio_load: reached MAX_DETACHED_DEVICES=%d. dev=%p won't be > > reattached\n", > > > + > > MAX_DETACHED_DEVICES, dev); > > Dittto > > > > > + } > > > + > > > device_detach(dev); > > > + } > > > } > > > } > > > > > > static void > > > nic_uio_unload(void) > > > { > > > + int i; > > > + printf("nic_uio_unload: entered ... \n"); > > > + > > > + for (i = 0; i < last_detached; i++) { > > > + printf("nic_uio_unload: calling to device_probe_and_attach > > for dev=%p...\n", > > > + detached_devices[i]); > > > + device_probe_and_attach(detached_devices[i]); > > Where is this defined? It doesn't appear to be in the latest dpdk. > > > > > + printf("nic_uio_unload: done.\n"); > > > + } > > > + > > > + printf("nic_uio_unload: leaving ... \n"); > > > } > > > > > > static int > > > -- > > > 2.1.2 > > > > > > > > > > > > ^ permalink raw reply [flat|nested] 26+ messages in thread
[parent not found: <20150302113654.GA20329-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org>]
* Re: [PATCH] pci: save list of detached devices, and re-probe during driver unload [not found] ` <20150302113654.GA20329-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org> @ 2015-03-02 11:58 ` Raz Amir 2015-03-02 13:29 ` Thomas Monjalon 0 siblings, 1 reply; 26+ messages in thread From: Raz Amir @ 2015-03-02 11:58 UTC (permalink / raw) To: dev-VfR2kkLFssw Thanks. How should I continue with this patch? BTW, I don't see it in incoming patches page at http://dpdk.org/dev/patchwork/project/dpdk/list/?page=1 Is it because I missed something in the code contribution instruction? -----Original Message----- From: Neil Horman [mailto:nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org] Sent: 02 March 2015 13:37 To: Raz Amir Cc: dev-VfR2kkLFssw@public.gmane.org Subject: Re: [dpdk-dev] [PATCH] pci: save list of detached devices, and re-probe during driver unload On Mon, Mar 02, 2015 at 10:18:42AM +0200, Raz Amir wrote: > The patch I suggest is in the nic_uio freebsd kernel driver. I don't > think that rte_log can be used there. > I checked the contigmem freebsd driver and it uses printf. > I can either remove those printfs, or keep them. > I suggest keeping them as they were very helpful for understanding the > flow, and they don't provide too much output (depending on the amount > of interfaces connected to the nic_uio driver). > You're right you can't use it, I thought it was the user space support for the uio driver, not the kernel module > How should I continue with this patch? > BTW, I don't see it in incoming patches page at > http://dpdk.org/dev/patchwork/project/dpdk/list/?page=1 > Is it because I missed something in the code contribution instruction? > > -----Original Message----- > From: Neil Horman [mailto:nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org] > Sent: 01 March 2015 19:17 > To: Raz Amir > Cc: dev-VfR2kkLFssw@public.gmane.org > Subject: Re: [dpdk-dev] [PATCH] pci: save list of detached devices, > and re-probe during driver unload > > On Sun, Mar 01, 2015 at 04:21:10PM +0200, Raz Amir wrote: > > Can you refer me to the logging facilities you are referring to for > > this Freebsd driver? > > device_probe_and_attach is an API in Freebsd kernel which is called > > during > rte_log and friends. > > > boot for finding the relevant driver for each device. > > I added manual call to it in the driver unload for re-probing and > > re-matching the devices that were detached by the driver. > > Before this change, you had to reboot in order to get the devices back. > > > my bad, I didn't see it defined and was thinking it was removed from > an earlier version of the dpdk. > Neil > > > -----Original Message----- > > From: Neil Horman [mailto:nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org] > > Sent: 01 March 2015 15:48 > > To: Raz Amir > > Cc: dev-VfR2kkLFssw@public.gmane.org > > Subject: Re: [dpdk-dev] [PATCH] pci: save list of detached devices, > > and re-probe during driver unload > > > > On Thu, Feb 26, 2015 at 06:33:20AM +0000, Raz Amir wrote: > > > Added code that saves the pointers to the detached devices, during > > > driver loading, and during driver unloading, go over the list, and > > > re-attach them by calling device_probe_and_attach on each device. > > > > > > Signed-off-by: Raz Amir <razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > --- > > > lib/librte_eal/bsdapp/nic_uio/nic_uio.c | 26 > > > +++++++++++++++++++++++++- > > > 1 file changed, 25 insertions(+), 1 deletion(-) > > > > > > diff --git a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > > b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > > > index 5ae8560..7d702a5 100644 > > > --- a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > > > +++ b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > > > @@ -55,6 +55,9 @@ __FBSDID("$FreeBSD$"); > > > > > > #define MAX_BARS (PCIR_MAX_BAR_0 + 1) > > > > > > +#define MAX_DETACHED_DEVICES 128 > > > +static device_t detached_devices[MAX_DETACHED_DEVICES] = {}; > > > +static int last_detached = 0; > > > > > > struct nic_uio_softc { > > > device_t dev_t; > > > @@ -291,14 +294,35 @@ nic_uio_load(void) > > > if (dev != NULL) > > > for (i = 0; i < NUM_DEVICES; i++) > > > if (pci_get_vendor(dev) == devices[i].vend > > && > > > - pci_get_device(dev) == > > devices[i].dev) > > > + pci_get_device(dev) == > > devices[i].dev) { > > > + if (last_detached+1 > > < MAX_DETACHED_DEVICES) { > > > + > > printf("nic_uio_load: detaching and storing dev=%p\n", dev); No > > printfs. Use the logging facilities > > > > > + > > detached_devices[last_detached++] = dev; > > > + } > > > + else { > > > + > > printf("nic_uio_load: reached MAX_DETACHED_DEVICES=%d. dev=%p won't > > be reattached\n", > > > + > > MAX_DETACHED_DEVICES, dev); > > Dittto > > > > > + } > > > + > > > device_detach(dev); > > > + } > > > } > > > } > > > > > > static void > > > nic_uio_unload(void) > > > { > > > + int i; > > > + printf("nic_uio_unload: entered ... \n"); > > > + > > > + for (i = 0; i < last_detached; i++) { > > > + printf("nic_uio_unload: calling to device_probe_and_attach > > for dev=%p...\n", > > > + detached_devices[i]); > > > + device_probe_and_attach(detached_devices[i]); > > Where is this defined? It doesn't appear to be in the latest dpdk. > > > > > + printf("nic_uio_unload: done.\n"); > > > + } > > > + > > > + printf("nic_uio_unload: leaving ... \n"); > > > } > > > > > > static int > > > -- > > > 2.1.2 > > > > > > > > > > > > ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] pci: save list of detached devices, and re-probe during driver unload 2015-03-02 11:58 ` Raz Amir @ 2015-03-02 13:29 ` Thomas Monjalon 2015-03-03 11:30 ` Raz Amir 0 siblings, 1 reply; 26+ messages in thread From: Thomas Monjalon @ 2015-03-02 13:29 UTC (permalink / raw) To: Raz Amir; +Cc: dev-VfR2kkLFssw 2015-03-02 13:58, Raz Amir: > BTW, I don't see it in incoming patches page at > http://dpdk.org/dev/patchwork/project/dpdk/list/?page=1 > Is it because I missed something in the code contribution instruction? It's here: http://dpdk.org/dev/patchwork/patch/3800/ ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] pci: save list of detached devices, and re-probe during driver unload 2015-03-02 13:29 ` Thomas Monjalon @ 2015-03-03 11:30 ` Raz Amir [not found] ` <EF8D26D5-4997-4F99-86B3-BF59DA25187D-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 26+ messages in thread From: Raz Amir @ 2015-03-03 11:30 UTC (permalink / raw) To: Thomas Monjalon; +Cc: dev-VfR2kkLFssw Thanks. What's next with the suggested parch? On Mar 2, 2015, at 3:29 PM, Thomas Monjalon <thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org> wrote: 2015-03-02 13:58, Raz Amir: > BTW, I don't see it in incoming patches page at > http://dpdk.org/dev/patchwork/project/dpdk/list/?page=1 > Is it because I missed something in the code contribution instruction? It's here: http://dpdk.org/dev/patchwork/patch/3800/ ^ permalink raw reply [flat|nested] 26+ messages in thread
[parent not found: <EF8D26D5-4997-4F99-86B3-BF59DA25187D-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH] pci: save list of detached devices, and re-probe during driver unload [not found] ` <EF8D26D5-4997-4F99-86B3-BF59DA25187D-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2015-03-03 11:45 ` Bruce Richardson 2015-03-03 12:56 ` Raz Amir 0 siblings, 1 reply; 26+ messages in thread From: Bruce Richardson @ 2015-03-03 11:45 UTC (permalink / raw) To: Raz Amir; +Cc: dev-VfR2kkLFssw On Tue, Mar 03, 2015 at 01:30:29PM +0200, Raz Amir wrote: > Thanks. > What's next with the suggested parch? > Hi, This patch needs to be reviewed and acked before it can be merged. I'll take a look at it and test it today, I hope, if nobody else reviews and comments on it before I get to it. Regards, /Bruce > On Mar 2, 2015, at 3:29 PM, Thomas Monjalon <thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org> wrote: > > 2015-03-02 13:58, Raz Amir: > > BTW, I don't see it in incoming patches page at > > http://dpdk.org/dev/patchwork/project/dpdk/list/?page=1 > > Is it because I missed something in the code contribution instruction? > > It's here: http://dpdk.org/dev/patchwork/patch/3800/ > ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] pci: save list of detached devices, and re-probe during driver unload 2015-03-03 11:45 ` Bruce Richardson @ 2015-03-03 12:56 ` Raz Amir 0 siblings, 0 replies; 26+ messages in thread From: Raz Amir @ 2015-03-03 12:56 UTC (permalink / raw) To: 'Bruce Richardson'; +Cc: dev-VfR2kkLFssw Thank you -----Original Message----- From: Bruce Richardson [mailto:bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org] Sent: 03 March 2015 13:45 To: Raz Amir Cc: Thomas Monjalon; dev-VfR2kkLFssw@public.gmane.org Subject: Re: [dpdk-dev] [PATCH] pci: save list of detached devices, and re-probe during driver unload On Tue, Mar 03, 2015 at 01:30:29PM +0200, Raz Amir wrote: > Thanks. > What's next with the suggested parch? > Hi, This patch needs to be reviewed and acked before it can be merged. I'll take a look at it and test it today, I hope, if nobody else reviews and comments on it before I get to it. Regards, /Bruce > On Mar 2, 2015, at 3:29 PM, Thomas Monjalon <thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org> wrote: > > 2015-03-02 13:58, Raz Amir: > > BTW, I don't see it in incoming patches page at > > http://dpdk.org/dev/patchwork/project/dpdk/list/?page=1 > > Is it because I missed something in the code contribution instruction? > > It's here: http://dpdk.org/dev/patchwork/patch/3800/ > ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] pci: save list of detached devices, and re-probe during driver unload [not found] ` <1424932400-66862-1-git-send-email-razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2015-03-01 13:48 ` Neil Horman @ 2015-03-03 13:32 ` Bruce Richardson 2015-03-04 9:07 ` Raz Amir 2015-03-04 11:15 ` [PATCH v3] " Raz Amir ` (3 subsequent siblings) 5 siblings, 1 reply; 26+ messages in thread From: Bruce Richardson @ 2015-03-03 13:32 UTC (permalink / raw) To: Raz Amir; +Cc: dev-VfR2kkLFssw On Thu, Feb 26, 2015 at 06:33:20AM +0000, Raz Amir wrote: > Added code that saves the pointers to the detached devices, during > driver loading, and during driver unloading, go over the list, > and re-attach them by calling device_probe_and_attach > on each device. > > Signed-off-by: Raz Amir <razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Couple of minor comments below. Otherwise all looks good to me. Acked-by: Bruce Richardson <bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> > --- > lib/librte_eal/bsdapp/nic_uio/nic_uio.c | 26 +++++++++++++++++++++++++- > 1 file changed, 25 insertions(+), 1 deletion(-) > > diff --git a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > index 5ae8560..7d702a5 100644 > --- a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > +++ b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > @@ -55,6 +55,9 @@ __FBSDID("$FreeBSD$"); > > #define MAX_BARS (PCIR_MAX_BAR_0 + 1) > > +#define MAX_DETACHED_DEVICES 128 > +static device_t detached_devices[MAX_DETACHED_DEVICES] = {}; > +static int last_detached = 0; Maybe num_detached/nb_detached or even just "detached" instead of "last_detached". > > struct nic_uio_softc { > device_t dev_t; > @@ -291,14 +294,35 @@ nic_uio_load(void) > if (dev != NULL) We are getting into some serious levels of indentation below, so maybe flip this condition around and put in a "continue" instead, so that we can dedent everything below that follows it. > for (i = 0; i < NUM_DEVICES; i++) > if (pci_get_vendor(dev) == devices[i].vend && > - pci_get_device(dev) == devices[i].dev) > + pci_get_device(dev) == devices[i].dev) { > + if (last_detached+1 < MAX_DETACHED_DEVICES) { I don't think you need the +1 here. > + printf("nic_uio_load: detaching and storing dev=%p\n", dev); > + detached_devices[last_detached++] = dev; > + } > + else { > + printf("nic_uio_load: reached MAX_DETACHED_DEVICES=%d. dev=%p won't be reattached\n", > + MAX_DETACHED_DEVICES, dev); > + } DPDK coding style is not to put braces around single-line statements like this. > + Remove whitespace from this new line. > device_detach(dev); > + } > } > } > > static void > nic_uio_unload(void) > { > + int i; > + printf("nic_uio_unload: entered ... \n"); > + > + for (i = 0; i < last_detached; i++) { > + printf("nic_uio_unload: calling to device_probe_and_attach for dev=%p...\n", > + detached_devices[i]); > + device_probe_and_attach(detached_devices[i]); > + printf("nic_uio_unload: done.\n"); > + } > + > + printf("nic_uio_unload: leaving ... \n"); > } > > static int > -- > 2.1.2 > ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] pci: save list of detached devices, and re-probe during driver unload 2015-03-03 13:32 ` Bruce Richardson @ 2015-03-04 9:07 ` Raz Amir 2015-03-04 10:13 ` Bruce Richardson 0 siblings, 1 reply; 26+ messages in thread From: Raz Amir @ 2015-03-04 9:07 UTC (permalink / raw) To: 'Bruce Richardson'; +Cc: dev-VfR2kkLFssw Thank you. See answers inline (mostly ack, but not only), and I will send the updated patch soon. > -----Original Message----- > From: Bruce Richardson [mailto:bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org] > Sent: 03 March 2015 15:33 > To: Raz Amir > Cc: dev-VfR2kkLFssw@public.gmane.org > Subject: Re: [dpdk-dev] [PATCH] pci: save list of detached devices, and re- > probe during driver unload > > On Thu, Feb 26, 2015 at 06:33:20AM +0000, Raz Amir wrote: > > Added code that saves the pointers to the detached devices, during > > driver loading, and during driver unloading, go over the list, and > > re-attach them by calling device_probe_and_attach on each device. > > > > Signed-off-by: Raz Amir < <mailto:razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > Couple of minor comments below. Otherwise all looks good to me. > > Acked-by: Bruce Richardson < <mailto:bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> > > --- > > lib/librte_eal/bsdapp/nic_uio/nic_uio.c | 26 > > +++++++++++++++++++++++++- > > 1 file changed, 25 insertions(+), 1 deletion(-) > > > > diff --git a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > > b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > > index 5ae8560..7d702a5 100644 > > --- a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > > +++ b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > > @@ -55,6 +55,9 @@ __FBSDID("$FreeBSD$"); > > > > #define MAX_BARS (PCIR_MAX_BAR_0 + 1) > > > > +#define MAX_DETACHED_DEVICES 128 > > +static device_t detached_devices[MAX_DETACHED_DEVICES] = {}; static > > +int last_detached = 0; > Maybe num_detached/nb_detached or even just "detached" instead of > "last_detached". Ack. > > > > > struct nic_uio_softc { > > device_t dev_t; > > @@ -291,14 +294,35 @@ nic_uio_load(void) > > if (dev != NULL) > > We are getting into some serious levels of indentation below, so maybe flip > this condition around and put in a "continue" instead, so that we can dedent > everything below that follows it. > Ack. > > for (i = 0; i < NUM_DEVICES; i++) > > if (pci_get_vendor(dev) == devices[i].vend > && > > - pci_get_device(dev) == > devices[i].dev) > > + pci_get_device(dev) == > devices[i].dev) { > > + if (last_detached+1 < > MAX_DETACHED_DEVICES) { > I don't think you need the +1 here. It is needed, otherwise the last object will be added at MAX_DETACHED_DEVICES position while the last position is MAX_DETACHED_DEVICES-1. However, I did change the code to: if (last_detached < MAX_DETACHED_DEVICES-1) { to better reflect that. You will see it in the next patch I will send. > > > + > printf("nic_uio_load: detaching and storing dev=%p\n", dev); > > + > detached_devices[last_detached++] = dev; > > + } > > + else { > > + > printf("nic_uio_load: reached MAX_DETACHED_DEVICES=%d. > dev=%p won't be reattached\n", > > + > MAX_DETACHED_DEVICES, dev); > > + } > DPDK coding style is not to put braces around single-line statements like this. Ack. > > > > + > Remove whitespace from this new line. > Ack. > > device_detach(dev); > > + } > > } > > } > > > > static void > > nic_uio_unload(void) > > { > > + int i; > > + printf("nic_uio_unload: entered ... \n"); > > + > > + for (i = 0; i < last_detached; i++) { > > + printf("nic_uio_unload: calling to device_probe_and_attach > for dev=%p...\n", > > + detached_devices[i]); > > + device_probe_and_attach(detached_devices[i]); > > + printf("nic_uio_unload: done.\n"); > > + } > > + > > + printf("nic_uio_unload: leaving ... \n"); > > } > > > > static int > > -- > > 2.1.2 > > ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] pci: save list of detached devices, and re-probe during driver unload 2015-03-04 9:07 ` Raz Amir @ 2015-03-04 10:13 ` Bruce Richardson 2015-03-04 10:28 ` Raz Amir 0 siblings, 1 reply; 26+ messages in thread From: Bruce Richardson @ 2015-03-04 10:13 UTC (permalink / raw) To: Raz Amir; +Cc: dev-VfR2kkLFssw On Wed, Mar 04, 2015 at 11:07:41AM +0200, Raz Amir wrote: > Thank you. > > See answers inline (mostly ack, but not only), and I will send the updated > patch soon. > > > > > -----Original Message----- > > > From: Bruce Richardson [mailto:bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org] > > > Sent: 03 March 2015 15:33 > > > To: Raz Amir > > > Cc: dev-VfR2kkLFssw@public.gmane.org > > > Subject: Re: [dpdk-dev] [PATCH] pci: save list of detached devices, and > re- > > > probe during driver unload > > > > > > On Thu, Feb 26, 2015 at 06:33:20AM +0000, Raz Amir wrote: > > > > Added code that saves the pointers to the detached devices, during > > > > driver loading, and during driver unloading, go over the list, and > > > > re-attach them by calling device_probe_and_attach on each device. > > > > > > > > Signed-off-by: Raz Amir < <mailto:razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > > > > Couple of minor comments below. Otherwise all looks good to me. > > > > > > Acked-by: Bruce Richardson < <mailto:bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> > bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> > > > > --- > > > > lib/librte_eal/bsdapp/nic_uio/nic_uio.c | 26 > > > > +++++++++++++++++++++++++- > > > > 1 file changed, 25 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > > > > b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > > > > index 5ae8560..7d702a5 100644 > > > > --- a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > > > > +++ b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > > > > @@ -55,6 +55,9 @@ __FBSDID("$FreeBSD$"); > > > > > > > > #define MAX_BARS (PCIR_MAX_BAR_0 + 1) > > > > > > > > +#define MAX_DETACHED_DEVICES 128 > > > > +static device_t detached_devices[MAX_DETACHED_DEVICES] = {}; static > > > > +int last_detached = 0; > > > Maybe num_detached/nb_detached or even just "detached" instead of > > > "last_detached". > > Ack. > > > > > > > > > > > > > struct nic_uio_softc { > > > > device_t dev_t; > > > > @@ -291,14 +294,35 @@ nic_uio_load(void) > > > > if (dev != NULL) > > > > > > We are getting into some serious levels of indentation below, so maybe > flip > > > this condition around and put in a "continue" instead, so that we can > dedent > > > everything below that follows it. > > > > > Ack. > > > > > > for (i = 0; i < NUM_DEVICES; > i++) > > > > if > (pci_get_vendor(dev) == devices[i].vend > > > && > > > > - > pci_get_device(dev) == > > > devices[i].dev) > > > > + > pci_get_device(dev) == > > > devices[i].dev) { > > > > + > if (last_detached+1 < > > > MAX_DETACHED_DEVICES) { > > > I don't think you need the +1 here. > > It is needed, otherwise the last object will be added at > MAX_DETACHED_DEVICES position while the last position is > MAX_DETACHED_DEVICES-1. Yes, the last position is MAX_DETACHED_DEVICES-1, but you do the addition of the element to the array using "detached_devices[last_detached++]", i.e. a post-increment, so when last_detached == (MAX_DETACHED_DEVICES-1), you still can fill in an entry. Next time around, when last_detached == MAX_DETACHED_DEVICES it's no longer safe to add, and the condition "last_detached < MAX_DETACHED_DEVICES) will now fail. No +1 or -1 necessary to prevent this. /Bruce ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] pci: save list of detached devices, and re-probe during driver unload 2015-03-04 10:13 ` Bruce Richardson @ 2015-03-04 10:28 ` Raz Amir 0 siblings, 0 replies; 26+ messages in thread From: Raz Amir @ 2015-03-04 10:28 UTC (permalink / raw) To: 'Bruce Richardson'; +Cc: dev-VfR2kkLFssw Understood. I already sent the updated patch, so I will fix this and resend it soon. -----Original Message----- From: Bruce Richardson [mailto:bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org] Sent: 04 March 2015 12:13 To: Raz Amir Cc: dev-VfR2kkLFssw@public.gmane.org Subject: Re: [dpdk-dev] [PATCH] pci: save list of detached devices, and re-probe during driver unload On Wed, Mar 04, 2015 at 11:07:41AM +0200, Raz Amir wrote: > Thank you. > > See answers inline (mostly ack, but not only), and I will send the > updated patch soon. > > > > > -----Original Message----- > > > From: Bruce Richardson [mailto:bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org] > > > Sent: 03 March 2015 15:33 > > > To: Raz Amir > > > Cc: dev-VfR2kkLFssw@public.gmane.org > > > Subject: Re: [dpdk-dev] [PATCH] pci: save list of detached devices, > > and > re- > > > probe during driver unload > > > > > > On Thu, Feb 26, 2015 at 06:33:20AM +0000, Raz Amir wrote: > > > > Added code that saves the pointers to the detached devices, during > > > > driver loading, and during driver unloading, go over the list, and > > > > re-attach them by calling device_probe_and_attach on each device. > > > > > > > > Signed-off-by: Raz Amir < <mailto:razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > > > > Couple of minor comments below. Otherwise all looks good to me. > > > > > > Acked-by: Bruce Richardson < <mailto:bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> > bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> > > > > --- > > > > lib/librte_eal/bsdapp/nic_uio/nic_uio.c | 26 > > > > +++++++++++++++++++++++++- > > > > 1 file changed, 25 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > > > > b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > > > > index 5ae8560..7d702a5 100644 > > > > --- a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > > > > +++ b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > > > > @@ -55,6 +55,9 @@ __FBSDID("$FreeBSD$"); > > > > > > > > #define MAX_BARS (PCIR_MAX_BAR_0 + 1) > > > > > > > > +#define MAX_DETACHED_DEVICES 128 > > > > +static device_t detached_devices[MAX_DETACHED_DEVICES] = {}; > > > +static > > > > +int last_detached = 0; > > > Maybe num_detached/nb_detached or even just "detached" instead of > > > "last_detached". > > Ack. > > > > > > > > > > > > > struct nic_uio_softc { > > > > device_t dev_t; > > > > @@ -291,14 +294,35 @@ nic_uio_load(void) > > > > if (dev != NULL) > > > > > > We are getting into some serious levels of indentation below, so > > maybe > flip > > > this condition around and put in a "continue" instead, so that we > > can > dedent > > > everything below that follows it. > > > > > Ack. > > > > > > for (i = 0; i < > > > NUM_DEVICES; > i++) > > > > if > (pci_get_vendor(dev) == devices[i].vend > > > && > > > > - > pci_get_device(dev) == > > > devices[i].dev) > > > > + > pci_get_device(dev) == > > > devices[i].dev) { > > > > + > if (last_detached+1 < > > > MAX_DETACHED_DEVICES) { > > > I don't think you need the +1 here. > > It is needed, otherwise the last object will be added at > MAX_DETACHED_DEVICES position while the last position is > MAX_DETACHED_DEVICES-1. Yes, the last position is MAX_DETACHED_DEVICES-1, but you do the addition of the element to the array using "detached_devices[last_detached++]", i.e. a post-increment, so when last_detached == (MAX_DETACHED_DEVICES-1), you still can fill in an entry. Next time around, when last_detached == MAX_DETACHED_DEVICES it's no longer safe to add, and the condition "last_detached < MAX_DETACHED_DEVICES) will now fail. No +1 or -1 necessary to prevent this. /Bruce ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH v3] pci: save list of detached devices, and re-probe during driver unload [not found] ` <1424932400-66862-1-git-send-email-razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2015-03-01 13:48 ` Neil Horman 2015-03-03 13:32 ` Bruce Richardson @ 2015-03-04 11:15 ` Raz Amir [not found] ` <1425467754-2693-1-git-send-email-razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2015-03-04 11:47 ` [PATCH v2] " Raz Amir ` (2 subsequent siblings) 5 siblings, 1 reply; 26+ messages in thread From: Raz Amir @ 2015-03-04 11:15 UTC (permalink / raw) To: dev-VfR2kkLFssw Added code that saves the pointers to the detached devices, during driver loading, and during driver unloading, go over the list, and re-attach them by calling device_probe_and_attach on each device. Signed-off-by: Raz Amir <razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- lib/librte_eal/bsdapp/nic_uio/nic_uio.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c index 5ae8560..78e4dea 100644 --- a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c +++ b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c @@ -55,6 +55,9 @@ __FBSDID("$FreeBSD$"); #define MAX_BARS (PCIR_MAX_BAR_0 + 1) +#define MAX_DETACHED_DEVICES 128 +static device_t detached_devices[MAX_DETACHED_DEVICES] = {}; +static int num_detached = 0; struct nic_uio_softc { device_t dev_t; @@ -289,16 +292,37 @@ nic_uio_load(void) dev = pci_find_bsf(bus, device, function); if (dev != NULL) - for (i = 0; i < NUM_DEVICES; i++) - if (pci_get_vendor(dev) == devices[i].vend && - pci_get_device(dev) == devices[i].dev) - device_detach(dev); + continue; + + for (i = 0; i < NUM_DEVICES; i++) + if (pci_get_vendor(dev) == devices[i].vend && + pci_get_device(dev) == devices[i].dev) { + if (num_detached < MAX_DETACHED_DEVICES) { + printf("nic_uio_load: detaching and storing dev=%p\n", dev); + detached_devices[num_detached++] = dev; + } + else + printf("nic_uio_load: reached MAX_DETACHED_DEVICES=%d. dev=%p won't be reattached\n", + MAX_DETACHED_DEVICES, dev); + device_detach(dev); + } } } static void nic_uio_unload(void) { + int i; + printf("nic_uio_unload: entered ... \n"); + + for (i = 0; i < num_detached; i++) { + printf("nic_uio_unload: calling to device_probe_and_attach for dev=%p...\n", + detached_devices[i]); + device_probe_and_attach(detached_devices[i]); + printf("nic_uio_unload: done.\n"); + } + + printf("nic_uio_unload: leaving ... \n"); } static int -- 2.1.2 ^ permalink raw reply related [flat|nested] 26+ messages in thread
[parent not found: <1425467754-2693-1-git-send-email-razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH v3] pci: save list of detached devices, and re-probe during driver unload [not found] ` <1425467754-2693-1-git-send-email-razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2015-03-09 8:07 ` Raz Amir [not found] ` <84B1AA3E-21E4-4A41-ADEE-B37E27147243-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 26+ messages in thread From: Raz Amir @ 2015-03-09 8:07 UTC (permalink / raw) To: dev-VfR2kkLFssw Hi, gentle reminder about this patch... On Mar 4, 2015, at 1:15 PM, Raz Amir <razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: Added code that saves the pointers to the detached devices, during driver loading, and during driver unloading, go over the list, and re-attach them by calling device_probe_and_attach on each device. Signed-off-by: Raz Amir <razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- lib/librte_eal/bsdapp/nic_uio/nic_uio.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c index 5ae8560..78e4dea 100644 --- a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c +++ b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c @@ -55,6 +55,9 @@ __FBSDID("$FreeBSD$"); #define MAX_BARS (PCIR_MAX_BAR_0 + 1) +#define MAX_DETACHED_DEVICES 128 +static device_t detached_devices[MAX_DETACHED_DEVICES] = {}; +static int num_detached = 0; struct nic_uio_softc { device_t dev_t; @@ -289,16 +292,37 @@ nic_uio_load(void) dev = pci_find_bsf(bus, device, function); if (dev != NULL) - for (i = 0; i < NUM_DEVICES; i++) - if (pci_get_vendor(dev) == devices[i].vend && - pci_get_device(dev) == devices[i].dev) - device_detach(dev); + continue; + + for (i = 0; i < NUM_DEVICES; i++) + if (pci_get_vendor(dev) == devices[i].vend && + pci_get_device(dev) == devices[i].dev) { + if (num_detached < MAX_DETACHED_DEVICES) { + printf("nic_uio_load: detaching and storing dev=%p\n", dev); + detached_devices[num_detached++] = dev; + } + else + printf("nic_uio_load: reached MAX_DETACHED_DEVICES=%d. dev=%p won't be reattached\n", + MAX_DETACHED_DEVICES, dev); + device_detach(dev); + } } } static void nic_uio_unload(void) { + int i; + printf("nic_uio_unload: entered ... \n"); + + for (i = 0; i < num_detached; i++) { + printf("nic_uio_unload: calling to device_probe_and_attach for dev=%p...\n", + detached_devices[i]); + device_probe_and_attach(detached_devices[i]); + printf("nic_uio_unload: done.\n"); + } + + printf("nic_uio_unload: leaving ... \n"); } static int -- 2.1.2 ^ permalink raw reply related [flat|nested] 26+ messages in thread
[parent not found: <84B1AA3E-21E4-4A41-ADEE-B37E27147243-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH v3] pci: save list of detached devices, and re-probe during driver unload [not found] ` <84B1AA3E-21E4-4A41-ADEE-B37E27147243-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2015-03-09 10:27 ` Bruce Richardson 2015-03-10 8:15 ` Raz Amir 0 siblings, 1 reply; 26+ messages in thread From: Bruce Richardson @ 2015-03-09 10:27 UTC (permalink / raw) To: Raz Amir; +Cc: dev-VfR2kkLFssw On Mon, Mar 09, 2015 at 10:07:29AM +0200, Raz Amir wrote: > Hi, gentle reminder about this patch... > > On Mar 4, 2015, at 1:15 PM, Raz Amir <razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Added code that saves the pointers to the detached devices, during > driver loading, and during driver unloading, go over the list, > and re-attach them by calling device_probe_and_attach > on each device. > > Signed-off-by: Raz Amir <razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > --- > lib/librte_eal/bsdapp/nic_uio/nic_uio.c | 32 ++++++++++++++++++++++++++++---- > 1 file changed, 28 insertions(+), 4 deletions(-) > > diff --git a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > index 5ae8560..78e4dea 100644 > --- a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > +++ b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > @@ -55,6 +55,9 @@ __FBSDID("$FreeBSD$"); > > #define MAX_BARS (PCIR_MAX_BAR_0 + 1) > > +#define MAX_DETACHED_DEVICES 128 > +static device_t detached_devices[MAX_DETACHED_DEVICES] = {}; > +static int num_detached = 0; > > struct nic_uio_softc { > device_t dev_t; > @@ -289,16 +292,37 @@ nic_uio_load(void) > > dev = pci_find_bsf(bus, device, function); > if (dev != NULL) > - for (i = 0; i < NUM_DEVICES; i++) > - if (pci_get_vendor(dev) == devices[i].vend && > - pci_get_device(dev) == devices[i].dev) > - device_detach(dev); > + continue; Since we have changed the body to be a continue statement, I think the condition above needs to be flipped. /Bruce ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v3] pci: save list of detached devices, and re-probe during driver unload 2015-03-09 10:27 ` Bruce Richardson @ 2015-03-10 8:15 ` Raz Amir 0 siblings, 0 replies; 26+ messages in thread From: Raz Amir @ 2015-03-10 8:15 UTC (permalink / raw) To: 'Bruce Richardson'; +Cc: dev-VfR2kkLFssw Sorry for that. Will send the new patch soon -----Original Message----- From: Bruce Richardson [mailto:bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org] Sent: 09 March 2015 12:28 To: Raz Amir Cc: dev-VfR2kkLFssw@public.gmane.org Subject: Re: [PATCH v3] pci: save list of detached devices, and re-probe during driver unload On Mon, Mar 09, 2015 at 10:07:29AM +0200, Raz Amir wrote: > Hi, gentle reminder about this patch... > > On Mar 4, 2015, at 1:15 PM, Raz Amir <razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Added code that saves the pointers to the detached devices, during > driver loading, and during driver unloading, go over the list, and > re-attach them by calling device_probe_and_attach on each device. > > Signed-off-by: Raz Amir <razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > --- > lib/librte_eal/bsdapp/nic_uio/nic_uio.c | 32 > ++++++++++++++++++++++++++++---- > 1 file changed, 28 insertions(+), 4 deletions(-) > > diff --git a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > index 5ae8560..78e4dea 100644 > --- a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > +++ b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > @@ -55,6 +55,9 @@ __FBSDID("$FreeBSD$"); > > #define MAX_BARS (PCIR_MAX_BAR_0 + 1) > > +#define MAX_DETACHED_DEVICES 128 > +static device_t detached_devices[MAX_DETACHED_DEVICES] = {}; static > +int num_detached = 0; > > struct nic_uio_softc { > device_t dev_t; > @@ -289,16 +292,37 @@ nic_uio_load(void) > > dev = pci_find_bsf(bus, device, function); > if (dev != NULL) > - for (i = 0; i < NUM_DEVICES; i++) > - if (pci_get_vendor(dev) == devices[i].vend && > - pci_get_device(dev) == devices[i].dev) > - device_detach(dev); > + continue; Since we have changed the body to be a continue statement, I think the condition above needs to be flipped. /Bruce ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH v2] pci: save list of detached devices, and re-probe during driver unload [not found] ` <1424932400-66862-1-git-send-email-razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> ` (2 preceding siblings ...) 2015-03-04 11:15 ` [PATCH v3] " Raz Amir @ 2015-03-04 11:47 ` Raz Amir 2015-03-05 14:59 ` [PATCH v4] " Raz Amir 2015-03-05 16:24 ` Raz Amir 5 siblings, 0 replies; 26+ messages in thread From: Raz Amir @ 2015-03-04 11:47 UTC (permalink / raw) To: dev-VfR2kkLFssw Added code that saves the pointers to the detached devices, during driver loading, and during driver unloading, go over the list, and re-attach them by calling device_probe_and_attach on each device. Signed-off-by: Raz Amir <razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- lib/librte_eal/bsdapp/nic_uio/nic_uio.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c index 5ae8560..077bdb3 100644 --- a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c +++ b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c @@ -55,6 +55,9 @@ __FBSDID("$FreeBSD$"); #define MAX_BARS (PCIR_MAX_BAR_0 + 1) +#define MAX_DETACHED_DEVICES 128 +static device_t detached_devices[MAX_DETACHED_DEVICES] = {}; +static int num_detached = 0; struct nic_uio_softc { device_t dev_t; @@ -289,16 +292,37 @@ nic_uio_load(void) dev = pci_find_bsf(bus, device, function); if (dev != NULL) - for (i = 0; i < NUM_DEVICES; i++) - if (pci_get_vendor(dev) == devices[i].vend && - pci_get_device(dev) == devices[i].dev) - device_detach(dev); + continue; + + for (i = 0; i < NUM_DEVICES; i++) + if (pci_get_vendor(dev) == devices[i].vend && + pci_get_device(dev) == devices[i].dev) { + if (num_detached < MAX_DETACHED_DEVICES-1) { + printf("nic_uio_load: detaching and storing dev=%p\n", dev); + detached_devices[num_detached++] = dev; + } + else + printf("nic_uio_load: reached MAX_DETACHED_DEVICES=%d. dev=%p won't be reattached\n", + MAX_DETACHED_DEVICES, dev); + device_detach(dev); + } } } static void nic_uio_unload(void) { + int i; + printf("nic_uio_unload: entered ... \n"); + + for (i = 0; i < num_detached; i++) { + printf("nic_uio_unload: calling to device_probe_and_attach for dev=%p...\n", + detached_devices[i]); + device_probe_and_attach(detached_devices[i]); + printf("nic_uio_unload: done.\n"); + } + + printf("nic_uio_unload: leaving ... \n"); } static int -- 2.1.2 ^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v4] pci: save list of detached devices, and re-probe during driver unload [not found] ` <1424932400-66862-1-git-send-email-razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> ` (3 preceding siblings ...) 2015-03-04 11:47 ` [PATCH v2] " Raz Amir @ 2015-03-05 14:59 ` Raz Amir 2015-03-05 16:24 ` Raz Amir 5 siblings, 0 replies; 26+ messages in thread From: Raz Amir @ 2015-03-05 14:59 UTC (permalink / raw) To: dev-VfR2kkLFssw Added code that saves the pointers to the detached devices, during driver loading, and during driver unloading, go over the list, and re-attach them by calling device_probe_and_attach on each device. Signed-off-by: Raz Amir <razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- lib/librte_eal/bsdapp/nic_uio/nic_uio.c | 34 ++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c index 5ae8560..7a4ed5d 100644 --- a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c +++ b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c @@ -55,6 +55,9 @@ __FBSDID("$FreeBSD$"); #define MAX_BARS (PCIR_MAX_BAR_0 + 1) +#define MAX_DETACHED_DEVICES 128 +static device_t detached_devices[MAX_DETACHED_DEVICES] = {}; +static int num_detached = 0; struct nic_uio_softc { device_t dev_t; @@ -288,17 +291,38 @@ nic_uio_load(void) function = strtol(token, NULL, 10); dev = pci_find_bsf(bus, device, function); - if (dev != NULL) - for (i = 0; i < NUM_DEVICES; i++) - if (pci_get_vendor(dev) == devices[i].vend && - pci_get_device(dev) == devices[i].dev) - device_detach(dev); + if (dev == NULL) + continue; + + for (i = 0; i < NUM_DEVICES; i++) + if (pci_get_vendor(dev) == devices[i].vend && + pci_get_device(dev) == devices[i].dev) { + if (num_detached < MAX_DETACHED_DEVICES) { + printf("nic_uio_load: detaching and storing dev=%p\n", dev); + detached_devices[num_detached++] = dev; + } + else + printf("nic_uio_load: reached MAX_DETACHED_DEVICES=%d. dev=%p won't be reattached\n", + MAX_DETACHED_DEVICES, dev); + device_detach(dev); + } } } static void nic_uio_unload(void) { + int i; + printf("nic_uio_unload: entered ... \n"); + + for (i = 0; i < num_detached; i++) { + printf("nic_uio_unload: calling to device_probe_and_attach for dev=%p...\n", + detached_devices[i]); + device_probe_and_attach(detached_devices[i]); + printf("nic_uio_unload: done.\n"); + } + + printf("nic_uio_unload: leaving ... \n"); } static int -- 2.1.2 ^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v4] pci: save list of detached devices, and re-probe during driver unload [not found] ` <1424932400-66862-1-git-send-email-razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> ` (4 preceding siblings ...) 2015-03-05 14:59 ` [PATCH v4] " Raz Amir @ 2015-03-05 16:24 ` Raz Amir [not found] ` <1425572663-22299-1-git-send-email-razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 5 siblings, 1 reply; 26+ messages in thread From: Raz Amir @ 2015-03-05 16:24 UTC (permalink / raw) To: dev-VfR2kkLFssw Added code that saves the pointers to the detached devices, during driver loading, and during driver unloading, go over the list, and re-attach them by calling device_probe_and_attach on each device. Signed-off-by: Raz Amir <razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- lib/librte_eal/bsdapp/nic_uio/nic_uio.c | 34 ++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c index 5ae8560..7a4ed5d 100644 --- a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c +++ b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c @@ -55,6 +55,9 @@ __FBSDID("$FreeBSD$"); #define MAX_BARS (PCIR_MAX_BAR_0 + 1) +#define MAX_DETACHED_DEVICES 128 +static device_t detached_devices[MAX_DETACHED_DEVICES] = {}; +static int num_detached = 0; struct nic_uio_softc { device_t dev_t; @@ -288,17 +291,38 @@ nic_uio_load(void) function = strtol(token, NULL, 10); dev = pci_find_bsf(bus, device, function); - if (dev != NULL) - for (i = 0; i < NUM_DEVICES; i++) - if (pci_get_vendor(dev) == devices[i].vend && - pci_get_device(dev) == devices[i].dev) - device_detach(dev); + if (dev == NULL) + continue; + + for (i = 0; i < NUM_DEVICES; i++) + if (pci_get_vendor(dev) == devices[i].vend && + pci_get_device(dev) == devices[i].dev) { + if (num_detached < MAX_DETACHED_DEVICES) { + printf("nic_uio_load: detaching and storing dev=%p\n", dev); + detached_devices[num_detached++] = dev; + } + else + printf("nic_uio_load: reached MAX_DETACHED_DEVICES=%d. dev=%p won't be reattached\n", + MAX_DETACHED_DEVICES, dev); + device_detach(dev); + } } } static void nic_uio_unload(void) { + int i; + printf("nic_uio_unload: entered ... \n"); + + for (i = 0; i < num_detached; i++) { + printf("nic_uio_unload: calling to device_probe_and_attach for dev=%p...\n", + detached_devices[i]); + device_probe_and_attach(detached_devices[i]); + printf("nic_uio_unload: done.\n"); + } + + printf("nic_uio_unload: leaving ... \n"); } static int -- 2.1.2 ^ permalink raw reply related [flat|nested] 26+ messages in thread
[parent not found: <1425572663-22299-1-git-send-email-razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH v4] pci: save list of detached devices, and re-probe during driver unload [not found] ` <1425572663-22299-1-git-send-email-razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2015-03-11 10:26 ` Bruce Richardson 2015-03-12 12:24 ` Raz Amir 0 siblings, 1 reply; 26+ messages in thread From: Bruce Richardson @ 2015-03-11 10:26 UTC (permalink / raw) To: Raz Amir; +Cc: dev-VfR2kkLFssw On Thu, Mar 05, 2015 at 06:24:23PM +0200, Raz Amir wrote: > Added code that saves the pointers to the detached devices, during > driver loading, and during driver unloading, go over the list, > and re-attach them by calling device_probe_and_attach > on each device. > > Signed-off-by: Raz Amir <razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Acked-by: Bruce Richardson <bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> > --- > lib/librte_eal/bsdapp/nic_uio/nic_uio.c | 34 ++++++++++++++++++++++++++++----- > 1 file changed, 29 insertions(+), 5 deletions(-) > > diff --git a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > index 5ae8560..7a4ed5d 100644 > --- a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > +++ b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > @@ -55,6 +55,9 @@ __FBSDID("$FreeBSD$"); > > #define MAX_BARS (PCIR_MAX_BAR_0 + 1) > > +#define MAX_DETACHED_DEVICES 128 > +static device_t detached_devices[MAX_DETACHED_DEVICES] = {}; > +static int num_detached = 0; > > struct nic_uio_softc { > device_t dev_t; > @@ -288,17 +291,38 @@ nic_uio_load(void) > function = strtol(token, NULL, 10); > > dev = pci_find_bsf(bus, device, function); > - if (dev != NULL) > - for (i = 0; i < NUM_DEVICES; i++) > - if (pci_get_vendor(dev) == devices[i].vend && > - pci_get_device(dev) == devices[i].dev) > - device_detach(dev); > + if (dev == NULL) > + continue; > + > + for (i = 0; i < NUM_DEVICES; i++) > + if (pci_get_vendor(dev) == devices[i].vend && > + pci_get_device(dev) == devices[i].dev) { > + if (num_detached < MAX_DETACHED_DEVICES) { > + printf("nic_uio_load: detaching and storing dev=%p\n", dev); > + detached_devices[num_detached++] = dev; > + } > + else > + printf("nic_uio_load: reached MAX_DETACHED_DEVICES=%d. dev=%p won't be reattached\n", > + MAX_DETACHED_DEVICES, dev); > + device_detach(dev); > + } > } > } > > static void > nic_uio_unload(void) > { > + int i; > + printf("nic_uio_unload: entered ... \n"); > + > + for (i = 0; i < num_detached; i++) { > + printf("nic_uio_unload: calling to device_probe_and_attach for dev=%p...\n", > + detached_devices[i]); > + device_probe_and_attach(detached_devices[i]); > + printf("nic_uio_unload: done.\n"); > + } > + > + printf("nic_uio_unload: leaving ... \n"); > } > > static int > -- > 2.1.2 > ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v4] pci: save list of detached devices, and re-probe during driver unload 2015-03-11 10:26 ` Bruce Richardson @ 2015-03-12 12:24 ` Raz Amir 2015-03-16 16:29 ` Thomas Monjalon 0 siblings, 1 reply; 26+ messages in thread From: Raz Amir @ 2015-03-12 12:24 UTC (permalink / raw) To: 'Bruce Richardson'; +Cc: dev-VfR2kkLFssw Thank you. Can you tell when will the patch be pushed to the source code? -----Original Message----- From: Bruce Richardson [mailto:bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org] Sent: 11 March 2015 12:26 To: Raz Amir Cc: dev-VfR2kkLFssw@public.gmane.org Subject: Re: [dpdk-dev] [PATCH v4] pci: save list of detached devices, and re-probe during driver unload On Thu, Mar 05, 2015 at 06:24:23PM +0200, Raz Amir wrote: > Added code that saves the pointers to the detached devices, during > driver loading, and during driver unloading, go over the list, and > re-attach them by calling device_probe_and_attach on each device. > > Signed-off-by: Raz Amir <razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Acked-by: Bruce Richardson <bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> > --- > lib/librte_eal/bsdapp/nic_uio/nic_uio.c | 34 > ++++++++++++++++++++++++++++----- > 1 file changed, 29 insertions(+), 5 deletions(-) > > diff --git a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > index 5ae8560..7a4ed5d 100644 > --- a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > +++ b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > @@ -55,6 +55,9 @@ __FBSDID("$FreeBSD$"); > > #define MAX_BARS (PCIR_MAX_BAR_0 + 1) > > +#define MAX_DETACHED_DEVICES 128 > +static device_t detached_devices[MAX_DETACHED_DEVICES] = {}; static > +int num_detached = 0; > > struct nic_uio_softc { > device_t dev_t; > @@ -288,17 +291,38 @@ nic_uio_load(void) > function = strtol(token, NULL, 10); > > dev = pci_find_bsf(bus, device, function); > - if (dev != NULL) > - for (i = 0; i < NUM_DEVICES; i++) > - if (pci_get_vendor(dev) == devices[i].vend && > - pci_get_device(dev) == devices[i].dev) > - device_detach(dev); > + if (dev == NULL) > + continue; > + > + for (i = 0; i < NUM_DEVICES; i++) > + if (pci_get_vendor(dev) == devices[i].vend && > + pci_get_device(dev) == devices[i].dev) { > + if (num_detached < MAX_DETACHED_DEVICES) { > + printf("nic_uio_load: detaching and storing dev=%p\n", dev); > + detached_devices[num_detached++] = dev; > + } > + else > + printf("nic_uio_load: reached MAX_DETACHED_DEVICES=%d. dev=%p won't be reattached\n", > + MAX_DETACHED_DEVICES, dev); > + device_detach(dev); > + } > } > } > > static void > nic_uio_unload(void) > { > + int i; > + printf("nic_uio_unload: entered ... \n"); > + > + for (i = 0; i < num_detached; i++) { > + printf("nic_uio_unload: calling to device_probe_and_attach for dev=%p...\n", > + detached_devices[i]); > + device_probe_and_attach(detached_devices[i]); > + printf("nic_uio_unload: done.\n"); > + } > + > + printf("nic_uio_unload: leaving ... \n"); > } > > static int > -- > 2.1.2 > ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v4] pci: save list of detached devices, and re-probe during driver unload 2015-03-12 12:24 ` Raz Amir @ 2015-03-16 16:29 ` Thomas Monjalon 2015-07-08 22:51 ` Thomas Monjalon 0 siblings, 1 reply; 26+ messages in thread From: Thomas Monjalon @ 2015-03-16 16:29 UTC (permalink / raw) To: Raz Amir; +Cc: dev-VfR2kkLFssw Hi, 2015-03-12 14:24, Raz Amir: > Thank you. > Can you tell when will the patch be pushed to the source code? This is changing the behaviour. I think we should keep it for 2.1 and check if some docs must be updated in the meantime. Then we should look at general behaviour for binding/unbinding devices in DPDK. I feel it would be better to have a common behaviour with BSD, Linux UIO, Linux VFIO, etc. > -----Original Message----- > From: Bruce Richardson [mailto:bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org] > Sent: 11 March 2015 12:26 > To: Raz Amir > Cc: dev-VfR2kkLFssw@public.gmane.org > Subject: Re: [dpdk-dev] [PATCH v4] pci: save list of detached devices, and > re-probe during driver unload > > On Thu, Mar 05, 2015 at 06:24:23PM +0200, Raz Amir wrote: > > Added code that saves the pointers to the detached devices, during > > driver loading, and during driver unloading, go over the list, and > > re-attach them by calling device_probe_and_attach on each device. > > > > Signed-off-by: Raz Amir <razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > Acked-by: Bruce Richardson <bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> > > > --- > > lib/librte_eal/bsdapp/nic_uio/nic_uio.c | 34 > > ++++++++++++++++++++++++++++----- > > 1 file changed, 29 insertions(+), 5 deletions(-) > > > > diff --git a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > > b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > > index 5ae8560..7a4ed5d 100644 > > --- a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > > +++ b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c > > @@ -55,6 +55,9 @@ __FBSDID("$FreeBSD$"); > > > > #define MAX_BARS (PCIR_MAX_BAR_0 + 1) > > > > +#define MAX_DETACHED_DEVICES 128 > > +static device_t detached_devices[MAX_DETACHED_DEVICES] = {}; static > > +int num_detached = 0; > > > > struct nic_uio_softc { > > device_t dev_t; > > @@ -288,17 +291,38 @@ nic_uio_load(void) > > function = strtol(token, NULL, 10); > > > > dev = pci_find_bsf(bus, device, function); > > - if (dev != NULL) > > - for (i = 0; i < NUM_DEVICES; i++) > > - if (pci_get_vendor(dev) == devices[i].vend > && > > - pci_get_device(dev) == > devices[i].dev) > > - device_detach(dev); > > + if (dev == NULL) > > + continue; > > + > > + for (i = 0; i < NUM_DEVICES; i++) > > + if (pci_get_vendor(dev) == devices[i].vend && > > + pci_get_device(dev) == > devices[i].dev) { > > + if (num_detached < > MAX_DETACHED_DEVICES) { > > + > printf("nic_uio_load: detaching and storing dev=%p\n", dev); > > + > detached_devices[num_detached++] = dev; > > + } > > + else > > + > printf("nic_uio_load: reached MAX_DETACHED_DEVICES=%d. dev=%p won't be > reattached\n", > > + > MAX_DETACHED_DEVICES, dev); > > + device_detach(dev); > > + } > > } > > } > > > > static void > > nic_uio_unload(void) > > { > > + int i; > > + printf("nic_uio_unload: entered ... \n"); > > + > > + for (i = 0; i < num_detached; i++) { > > + printf("nic_uio_unload: calling to device_probe_and_attach > for dev=%p...\n", > > + detached_devices[i]); > > + device_probe_and_attach(detached_devices[i]); > > + printf("nic_uio_unload: done.\n"); > > + } > > + > > + printf("nic_uio_unload: leaving ... \n"); > > } > > > > static int > > -- > > 2.1.2 > > > ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v4] pci: save list of detached devices, and re-probe during driver unload 2015-03-16 16:29 ` Thomas Monjalon @ 2015-07-08 22:51 ` Thomas Monjalon 0 siblings, 0 replies; 26+ messages in thread From: Thomas Monjalon @ 2015-07-08 22:51 UTC (permalink / raw) To: Raz Amir, Bruce Richardson; +Cc: dev This patch received no more comment about a common BSD/Linux behaviour. Maybe that some documentation is needed. 2015-03-16 17:29, Thomas Monjalon: > Hi, > > 2015-03-12 14:24, Raz Amir: > > Thank you. > > Can you tell when will the patch be pushed to the source code? > > This is changing the behaviour. I think we should keep it for 2.1 and check if > some docs must be updated in the meantime. > Then we should look at general behaviour for binding/unbinding devices in DPDK. > I feel it would be better to have a common behaviour with BSD, Linux UIO, > Linux VFIO, etc. > > > -----Original Message----- > > From: Bruce Richardson [mailto:bruce.richardson@intel.com] > > Sent: 11 March 2015 12:26 > > To: Raz Amir > > Cc: dev@dpdk.org > > Subject: Re: [dpdk-dev] [PATCH v4] pci: save list of detached devices, and > > re-probe during driver unload > > > > On Thu, Mar 05, 2015 at 06:24:23PM +0200, Raz Amir wrote: > > > Added code that saves the pointers to the detached devices, during > > > driver loading, and during driver unloading, go over the list, and > > > re-attach them by calling device_probe_and_attach on each device. > > > > > > Signed-off-by: Raz Amir <razamir22@gmail.com> > > Acked-by: Bruce Richardson <bruce.richardson@intel.com> Applied, thanks ^ permalink raw reply [flat|nested] 26+ messages in thread
end of thread, other threads:[~2015-07-08 22:52 UTC | newest] Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2015-02-26 6:33 [PATCH] pci: save list of detached devices, and re-probe during driver unload Raz Amir [not found] ` <1424932400-66862-1-git-send-email-razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2015-03-01 13:48 ` Neil Horman [not found] ` <20150301134818.GA31578-0o1r3XBGOEbbgkc5XkKeNuvMHUBZFtU3YPYVAmT7z5s@public.gmane.org> 2015-03-01 14:21 ` Raz Amir 2015-03-01 17:16 ` Neil Horman [not found] ` <20150301171646.GA32246-0o1r3XBGOEbbgkc5XkKeNuvMHUBZFtU3YPYVAmT7z5s@public.gmane.org> 2015-03-02 8:18 ` Raz Amir 2015-03-02 11:36 ` Neil Horman [not found] ` <20150302113654.GA20329-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org> 2015-03-02 11:58 ` Raz Amir 2015-03-02 13:29 ` Thomas Monjalon 2015-03-03 11:30 ` Raz Amir [not found] ` <EF8D26D5-4997-4F99-86B3-BF59DA25187D-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2015-03-03 11:45 ` Bruce Richardson 2015-03-03 12:56 ` Raz Amir 2015-03-03 13:32 ` Bruce Richardson 2015-03-04 9:07 ` Raz Amir 2015-03-04 10:13 ` Bruce Richardson 2015-03-04 10:28 ` Raz Amir 2015-03-04 11:15 ` [PATCH v3] " Raz Amir [not found] ` <1425467754-2693-1-git-send-email-razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2015-03-09 8:07 ` Raz Amir [not found] ` <84B1AA3E-21E4-4A41-ADEE-B37E27147243-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2015-03-09 10:27 ` Bruce Richardson 2015-03-10 8:15 ` Raz Amir 2015-03-04 11:47 ` [PATCH v2] " Raz Amir 2015-03-05 14:59 ` [PATCH v4] " Raz Amir 2015-03-05 16:24 ` Raz Amir [not found] ` <1425572663-22299-1-git-send-email-razamir22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2015-03-11 10:26 ` Bruce Richardson 2015-03-12 12:24 ` Raz Amir 2015-03-16 16:29 ` Thomas Monjalon 2015-07-08 22:51 ` Thomas Monjalon
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.