116 "Failed to set endian %d", ret);
117
118 return (ret);
119 } /* oce_mbox_init */
120
121 /*
122 * function to wait till we get a mbox ready after writing to the
123 * mbox doorbell
124 *
125 * dev - software handle to the device
126 *
127 * return 0=ready, ETIMEDOUT=>not ready but timed out
128 */
129 int
130 oce_mbox_wait(struct oce_dev *dev, uint32_t tmo_sec)
131 {
132 clock_t tmo;
133 clock_t now, tstamp;
134 pd_mpu_mbox_db_t mbox_db;
135
136 tmo = (tmo_sec > 0) ? drv_usectohz(tmo_sec * 1000000) :
137 drv_usectohz(DEFAULT_MQ_MBOX_TIMEOUT);
138
139 /* Add the default timeout to wait for a mailbox to complete */
140 tmo += drv_usectohz(MBX_READY_TIMEOUT);
141
142 tstamp = ddi_get_lbolt();
143 for (;;) {
144 now = ddi_get_lbolt();
145 if ((now - tstamp) >= tmo) {
146 tmo = 0;
147 break;
148 }
149
150 mbox_db.dw0 = OCE_DB_READ32(dev, PD_MPU_MBOX_DB);
151 if (oce_fm_check_acc_handle(dev, dev->db_handle) != DDI_FM_OK) {
152 ddi_fm_service_impact(dev->dip, DDI_SERVICE_DEGRADED);
153 oce_fm_ereport(dev, DDI_FM_DEVICE_INVAL_STATE);
154 }
155
156 if (mbox_db.bits.ready) {
|
116 "Failed to set endian %d", ret);
117
118 return (ret);
119 } /* oce_mbox_init */
120
121 /*
122 * function to wait till we get a mbox ready after writing to the
123 * mbox doorbell
124 *
125 * dev - software handle to the device
126 *
127 * return 0=ready, ETIMEDOUT=>not ready but timed out
128 */
129 int
130 oce_mbox_wait(struct oce_dev *dev, uint32_t tmo_sec)
131 {
132 clock_t tmo;
133 clock_t now, tstamp;
134 pd_mpu_mbox_db_t mbox_db;
135
136 tmo = (tmo_sec > 0) ? drv_sectohz(tmo_sec) :
137 drv_usectohz(DEFAULT_MQ_MBOX_TIMEOUT);
138
139 /* Add the default timeout to wait for a mailbox to complete */
140 tmo += drv_usectohz(MBX_READY_TIMEOUT);
141
142 tstamp = ddi_get_lbolt();
143 for (;;) {
144 now = ddi_get_lbolt();
145 if ((now - tstamp) >= tmo) {
146 tmo = 0;
147 break;
148 }
149
150 mbox_db.dw0 = OCE_DB_READ32(dev, PD_MPU_MBOX_DB);
151 if (oce_fm_check_acc_handle(dev, dev->db_handle) != DDI_FM_OK) {
152 ddi_fm_service_impact(dev->dip, DDI_SERVICE_DEGRADED);
153 oce_fm_ereport(dev, DDI_FM_DEVICE_INVAL_STATE);
154 }
155
156 if (mbox_db.bits.ready) {
|