>    This probably won't go to driver-discuss, as I am not subscribed with 
> this email, but...
> 
> On Tue, 30 Oct 2007, Garrett D'Amore wrote:
> 
> > Juergen Keil wrote:
> >> Ok, returning with DDI_SUCCESS when usr/src/uts/common/io/pci-ide/pci-ide.c
> >> pciide_ddi_ctlops() is called with DDI_CTLOPS_ATTACH/DDI_CTLOPS_DETACH
> >> avoids the endless loop / hang.
> >> 
> >
> > Interesting.
> 
>    Do I understand correctly here that the idea is to have the pci-ide code 
> do this, and not have the bus code handle it?


Yes, at least that's the way I've currently changed it
("hg diff usr/src/uts/common/io/pci-ide" for my experimental changes):


diff -r 111aa1baa84a usr/src/uts/common/io/pci-ide/pci-ide.c
--- a/usr/src/uts/common/io/pci-ide/pci-ide.c   Mon Oct 29 22:45:33 2007 -0700
+++ b/usr/src/uts/common/io/pci-ide/pci-ide.c   Tue Oct 30 18:49:43 2007 +0100
@@ -380,6 +380,19 @@ pciide_ddi_ctlops(dev_info_t *dip, dev_i
 
                return (rc);
 
+/* jk:
+ * don't pass these up to the parent
+ * XXX limit to 
+ *              asp = (struct attachspec *)arg;
+ *              (asp->cmd == DDI_RESUME && asp->when == DDI_PRE)
+ *     and      (asp->cmd == DDI_SUSPEND && asp->when == DDI_POST) ?
+ */
+       case DDI_CTLOPS_ATTACH:
+               return (DDI_SUCCESS);
+       case DDI_CTLOPS_DETACH:
+               return (DDI_SUCCESS);
+/* :jk */
+
        default:
                return (ddi_ctlops(dip, rdip, ctlop, arg, result));
        }



pci-ide seems to be common code used both on sparc and x86, but I've not
made any tests on sparc (and my sparc test box wouldn't have ide/ata support,
anyway).


I'm not sure if any of the parent device nodes of "pci-ide" (pci? pciex bus? 
pci-pci bridges?, rootnext?) has a problem not seeing these DDI_CTLOPS_ATTACH /
DDI_CTLOPS_DETACH "events" for the "ide" node / "ata" driver module.
OTOH, the x86 "pci" module has a problem seeing these events, though.




I think an alternate way to fix the problem would be to send the
DDI_CTLOPS_ATTACH / DDI_CTLOPS_DETACH events to "pci-ide" parents
add some code to usr/src/uts/i86pc/io/pci/pci.c, so that pci_pre_resume() and 
pci_post_suspend() is only called for real "pci" child devices nodes in the
DDI_CTLOPS_ATTACH / DDI_CTLOPS_DETACH.  Pseudo code for 
usr/src/uts/i86pc/io/pci/pci.c pci_ctlops():


       /* for now only X86 systems support PME wakeup from suspended state */
        case DDI_CTLOPS_ATTACH:
                asp = (struct attachspec *)arg;
                if (asp->cmd == DDI_RESUME && asp->when == DDI_PRE &&
                    is_a_pci_device(rdip))            /* <<<<<<<<<<<<<<<<<< */
                        if (pci_pre_resume(rdip) != DDI_SUCCESS)
                                return (DDI_FAILURE);
                return (ddi_ctlops(dip, rdip, ctlop, arg, result));

        case DDI_CTLOPS_DETACH:
                asp = (struct attachspec *)arg;
                if (asp->cmd == DDI_SUSPEND && asp->when == DDI_POST &&
                    is_a_pci_device(rdip))           /* <<<<<<<<<<<<<<<<<< */
                        if (pci_post_suspend(rdip) != DDI_SUCCESS)
                                return (DDI_FAILURE);
                return (ddi_ctlops(dip, rdip, ctlop, arg, result));





Adding some kind of ASSERT to pci_pre_resume() and pci_post_suspend() to
make sure the code is only used for "pci" device nodes seems to a good idea,
too. Something like:

int
pci_pre_resume(dev_info_t *dip)
{
        ...
        ASSERT(is_a_pci_device(dip);
        ...
}
        


_______________________________________________
driver-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/driver-discuss

Reply via email to