Print this page
5253 kmem_alloc/kmem_zalloc won't fail with KM_SLEEP
5254 getrbuf won't fail with KM_SLEEP


 224         uint32_t num;
 225         uint32_t sector_size, addr_src, addr_desc;
 226         uint8_t *temp;
 227         caddr_t bp, bdesc;
 228 
 229         QL_PRINT(DBG_FLASH, ("%s(%d) entered to write addr %x, %d bytes\n",
 230             __func__, qlge->instance, faddr, len));
 231 
 232         sector_size = qlge->fdesc.block_size;
 233 
 234         if (faddr > qlge->fdesc.flash_size) {
 235                 cmn_err(CE_WARN, "%s(%d): invalid flash write address %x",
 236                     __func__, qlge->instance, faddr);
 237                 return (DDI_FAILURE);
 238         }
 239         /* Get semaphore to access Flash Address and Flash Data Registers */
 240         if (ql_sem_spinlock(qlge, QL_FLASH_SEM_MASK) != DDI_SUCCESS) {
 241                 return (DDI_FAILURE);
 242         }
 243         temp = kmem_zalloc(sector_size, KM_SLEEP);
 244         if (temp == NULL) {
 245                 cmn_err(CE_WARN, "%s(%d): Unable to allocate buffer",
 246                     __func__, qlge->instance);
 247                 ql_sem_unlock(qlge, QL_FLASH_SEM_MASK);
 248                 return (DDI_FAILURE);
 249         }
 250 
 251         (void) ql_unprotect_flash(qlge);
 252 
 253         get_sector_number(qlge, faddr, &start_block);
 254         get_sector_number(qlge, faddr + len - 1, &end_block);
 255 
 256         QL_PRINT(DBG_FLASH, ("%s(%d) start_block %x, end_block %x\n",
 257             __func__, qlge->instance, start_block, end_block));
 258 
 259         for (num = start_block; num <= end_block; num++) {
 260                 QL_PRINT(DBG_FLASH,
 261                     ("%s(%d) sector_size 0x%x, sector read addr %x\n",
 262                     __func__, qlge->instance, sector_size, num * sector_size));
 263                 /* read one whole sector flash data to buffer */
 264                 rval = qlge_dump_fcode(qlge, (uint8_t *)temp, sector_size,
 265                     num * sector_size);
 266 
 267                 start_byte = num * sector_size;
 268                 end_byte = start_byte + sector_size -1;
 269                 if (start_byte < faddr)




 224         uint32_t num;
 225         uint32_t sector_size, addr_src, addr_desc;
 226         uint8_t *temp;
 227         caddr_t bp, bdesc;
 228 
 229         QL_PRINT(DBG_FLASH, ("%s(%d) entered to write addr %x, %d bytes\n",
 230             __func__, qlge->instance, faddr, len));
 231 
 232         sector_size = qlge->fdesc.block_size;
 233 
 234         if (faddr > qlge->fdesc.flash_size) {
 235                 cmn_err(CE_WARN, "%s(%d): invalid flash write address %x",
 236                     __func__, qlge->instance, faddr);
 237                 return (DDI_FAILURE);
 238         }
 239         /* Get semaphore to access Flash Address and Flash Data Registers */
 240         if (ql_sem_spinlock(qlge, QL_FLASH_SEM_MASK) != DDI_SUCCESS) {
 241                 return (DDI_FAILURE);
 242         }
 243         temp = kmem_zalloc(sector_size, KM_SLEEP);






 244 
 245         (void) ql_unprotect_flash(qlge);
 246 
 247         get_sector_number(qlge, faddr, &start_block);
 248         get_sector_number(qlge, faddr + len - 1, &end_block);
 249 
 250         QL_PRINT(DBG_FLASH, ("%s(%d) start_block %x, end_block %x\n",
 251             __func__, qlge->instance, start_block, end_block));
 252 
 253         for (num = start_block; num <= end_block; num++) {
 254                 QL_PRINT(DBG_FLASH,
 255                     ("%s(%d) sector_size 0x%x, sector read addr %x\n",
 256                     __func__, qlge->instance, sector_size, num * sector_size));
 257                 /* read one whole sector flash data to buffer */
 258                 rval = qlge_dump_fcode(qlge, (uint8_t *)temp, sector_size,
 259                     num * sector_size);
 260 
 261                 start_byte = num * sector_size;
 262                 end_byte = start_byte + sector_size -1;
 263                 if (start_byte < faddr)