From: Philip Homburg Date: Tue, 24 Apr 2007 12:55:37 +0000 (+0000) Subject: Fixed releasing PCI resources after a driver terminates. X-Git-Tag: v3.1.4~395 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/doxygen.png?a=commitdiff_plain;h=0dc0d3fe5bf5d8d071ec84b4c640bd5e444d23b0;p=minix.git Fixed releasing PCI resources after a driver terminates. --- diff --git a/drivers/pci/main.c b/drivers/pci/main.c index c5fc96f0c..6f50de23d 100644 --- a/drivers/pci/main.c +++ b/drivers/pci/main.c @@ -11,12 +11,6 @@ main.c #define NR_DRIVERS 16 -PRIVATE struct name -{ - char name[M3_STRING]; - int tasknr; -} names[NR_DRIVERS]; - PRIVATE struct acl { int inuse; @@ -55,9 +49,6 @@ int main(void) pci_init(); - for (i= 0; im3_ca1); -#endif - empty= -1; - for (i= 0; im3_ca1) == 0) - break; - } - if (i >= NR_DRIVERS) - { - if (empty == -1) - panic("pci", "do_init: too many clients", NR_DRIVERS); - i= empty; - strcpy(names[i].name, mp->m3_ca1); - } - else if (names[i].tasknr == mp->m_source) - { - /* Ignore all init calls for a process after the first one */ - } -#if 0 - else - pci_release(names[i].name); + printf("PCI: pci_init: called by '%d'\n", mp->m_source); #endif - names[i].tasknr= mp->m_source; mp->m_type= 0; r= send(mp->m_source, mp); @@ -457,6 +424,9 @@ message *mp; printf("do_acl: deleting ACL for %d ('%s') at entry %d\n", acl[i].acl.rsp_endpoint, acl[i].acl.rsp_label, i); + /* Also release all devices held by this process */ + pci_release(proc_nr); + reply(mp, OK); } @@ -465,23 +435,9 @@ message *mp; { int i, r, devind; - /* Find the name of the caller */ - for (i= 0; im_source) - break; - } - if (i >= NR_DRIVERS) - { - printf("pci`do_reserve: task %d did not call pci_init\n", - mp->m_source); - return; - } - devind= mp->m1_i1; - - mp->m_type= pci_reserve3(devind, mp->m_source, names[i].name); + mp->m_type= pci_reserve2(devind, mp->m_source); r= send(mp->m_source, mp); if (r != 0) { diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 59918318e..0c726fff8 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -76,7 +76,9 @@ PRIVATE struct pcidev u16_t pd_vid; u16_t pd_did; u8_t pd_ilr; + u8_t pd_inuse; + endpoint_t pd_proc; struct bar { @@ -86,8 +88,6 @@ PRIVATE struct pcidev u32_t pb_size; } pd_bar[BAM_NR]; int pd_bar_nr; - - char pd_name[M3_STRING]; } pcidev[NR_PCIDEV]; /* pb_flags */ @@ -312,10 +312,9 @@ u16_t *didp; /*===========================================================================* * pci_reserve3 * *===========================================================================*/ -PUBLIC int pci_reserve3(devind, proc, name) +PUBLIC int pci_reserve2(devind, proc) int devind; int proc; -char *name; { int i, r; u8_t ilr; @@ -326,7 +325,7 @@ char *name; if(pcidev[devind].pd_inuse) return EBUSY; pcidev[devind].pd_inuse= 1; - strcpy(pcidev[devind].pd_name, name); + pcidev[devind].pd_proc= proc; for (i= 0; i