[bug report] scsi: lpfc: Commonize VMID code location

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello James Smart,

The patch e0063f4ad51c: "scsi: lpfc: Commonize VMID code location"
from May 10, 2022, leads to the following Smatch static checker
warning:

	drivers/scsi/lpfc/lpfc_vmid.c:248 lpfc_vmid_get_appid()
	warn: sleeping in atomic context

drivers/scsi/lpfc/lpfc_vmid.c
    192         } else {
    193                 /* The VMID was not found in the hashtable. At this point, */
    194                 /* drop the read lock first before proceeding further */
    195                 read_unlock(&vport->vmid_lock);
    196                 /* start the process to obtain one as per the */
    197                 /* type of the VMID indicated */
    198                 write_lock(&vport->vmid_lock);
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Holding a spin lock (write lock) disabled preemption

    199                 vmp = lpfc_get_vmid_from_hashtable(vport, hash, uuid);
    200 
    201                 /* while the read lock was released, in case the entry was */
    202                 /* added by other context or is in process of being added */
    203                 if (vmp && vmp->flag & LPFC_VMID_REGISTERED) {
    204                         lpfc_vmid_update_entry(vport, iodir, vmp, tag);
    205                         write_unlock(&vport->vmid_lock);
    206                         return 0;
    207                 } else if (vmp && vmp->flag & LPFC_VMID_REQ_REGISTER) {
    208                         write_unlock(&vport->vmid_lock);
    209                         return -EBUSY;
    210                 }
    211 
    212                 /* else search and allocate a free slot in the hash table */
    213                 if (vport->cur_vmid_cnt < vport->max_vmid) {
    214                         for (i = 0; i < vport->max_vmid; i++) {
    215                                 vmp = vport->vmid + i;
    216                                 if (vmp->flag == LPFC_VMID_SLOT_FREE)
    217                                         break;
    218                         }
    219                         if (i == vport->max_vmid)
    220                                 vmp = NULL;
    221                 } else {
    222                         vmp = NULL;
    223                 }
    224 
    225                 if (!vmp) {
    226                         write_unlock(&vport->vmid_lock);
    227                         return -ENOMEM;
    228                 }
    229 
    230                 /* Add the vmid and register */
    231                 lpfc_put_vmid_in_hashtable(vport, hash, vmp);
    232                 vmp->vmid_len = len;
    233                 memcpy(vmp->host_vmid, uuid, vmp->vmid_len);
    234                 vmp->io_rd_cnt = 0;
    235                 vmp->io_wr_cnt = 0;
    236                 vmp->flag = LPFC_VMID_SLOT_USED;
    237 
    238                 vmp->delete_inactive =
    239                         vport->vmid_inactivity_timeout ? 1 : 0;
    240 
    241                 /* if type priority tag, get next available VMID */
    242                 if (vport->phba->pport->vmid_flag & LPFC_VMID_TYPE_PRIO)
    243                         lpfc_vmid_assign_cs_ctl(vport, vmp);
    244 
    245                 /* allocate the per cpu variable for holding */
    246                 /* the last access time stamp only if VMID is enabled */
    247                 if (!vmp->last_io_time)
--> 248                         vmp->last_io_time = __alloc_percpu(sizeof(u64),
                                                    ^^^^^^^^^^^^^^^
Sleeps

    249                                                            __alignof__(struct
    250                                                            lpfc_vmid));
    251                 if (!vmp->last_io_time) {
    252                         hash_del(&vmp->hnode);
    253                         vmp->flag = LPFC_VMID_SLOT_FREE;
    254                         write_unlock(&vport->vmid_lock);
    255                         return -EIO;
    256                 }
    257 
    258                 write_unlock(&vport->vmid_lock);
    259 
    260                 /* complete transaction with switch */
    261                 if (vport->phba->pport->vmid_flag & LPFC_VMID_TYPE_PRIO)
    262                         rc = lpfc_vmid_uvem(vport, vmp, true);
    263                 else if (vport->phba->cfg_vmid_app_header)
    264                         rc = lpfc_vmid_cmd(vport, SLI_CTAS_RAPP_IDENT, vmp);
    265                 if (!rc) {
    266                         write_lock(&vport->vmid_lock);
    267                         vport->cur_vmid_cnt++;
    268                         vmp->flag |= LPFC_VMID_REQ_REGISTER;
    269                         write_unlock(&vport->vmid_lock);
    270                 } else {
    271                         write_lock(&vport->vmid_lock);
    272                         hash_del(&vmp->hnode);
    273                         vmp->flag = LPFC_VMID_SLOT_FREE;
    274                         free_percpu(vmp->last_io_time);
    275                         write_unlock(&vport->vmid_lock);
    276                         return -EIO;
    277                 }
    278 
    279                 /* finally, enable the idle timer once */
    280                 if (!(vport->phba->pport->vmid_flag & LPFC_VMID_TIMER_ENBLD)) {
    281                         mod_timer(&vport->phba->inactive_vmid_poll,
    282                                   jiffies +
    283                                   msecs_to_jiffies(1000 * LPFC_VMID_TIMER));
    284                         vport->phba->pport->vmid_flag |= LPFC_VMID_TIMER_ENBLD;
    285                 }
    286         }
    287         return rc;
    288 }

regards,
dan carpenter



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux