Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scsi: pm8001: Initialize devices in pm8001_alloc_dev()

Devices can be allocated and freed at runtime. For example during a soft
reset all devices are freed and reallocated upon discovery.

Currently the driver fully initializes devices once in pm8001_alloc().
Allows initialization steps to happen during runtime, avoiding any
leftover states from the device being freed.

Signed-off-by: Igor Pylypiv <ipylypiv@google.com>
Signed-off-by: Terrence Adams <tadamsjr@google.com>
Link: https://lore.kernel.org/r/20241021201828.1378858-1-tadamsjr@google.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Igor Pylypiv and committed by
Martin K. Petersen
4501ea5f c8d81a43

+12 -8
-3
drivers/scsi/pm8001/pm8001_init.c
··· 451 451 } 452 452 for (i = 0; i < PM8001_MAX_DEVICES; i++) { 453 453 pm8001_ha->devices[i].dev_type = SAS_PHY_UNUSED; 454 - pm8001_ha->devices[i].id = i; 455 - pm8001_ha->devices[i].device_id = PM8001_MAX_DEVICES; 456 - atomic_set(&pm8001_ha->devices[i].running_req, 0); 457 454 } 458 455 pm8001_ha->flags = PM8001F_INIT_TIME; 459 456 return 0;
+12 -5
drivers/scsi/pm8001/pm8001_sas.c
··· 572 572 pm8001_ccb_free(pm8001_ha, ccb); 573 573 } 574 574 575 + static void pm8001_init_dev(struct pm8001_device *pm8001_dev, int id) 576 + { 577 + pm8001_dev->id = id; 578 + pm8001_dev->device_id = PM8001_MAX_DEVICES; 579 + atomic_set(&pm8001_dev->running_req, 0); 580 + } 581 + 575 582 /** 576 583 * pm8001_alloc_dev - find a empty pm8001_device 577 584 * @pm8001_ha: our hba card information ··· 587 580 { 588 581 u32 dev; 589 582 for (dev = 0; dev < PM8001_MAX_DEVICES; dev++) { 590 - if (pm8001_ha->devices[dev].dev_type == SAS_PHY_UNUSED) { 591 - pm8001_ha->devices[dev].id = dev; 592 - return &pm8001_ha->devices[dev]; 583 + struct pm8001_device *pm8001_dev = &pm8001_ha->devices[dev]; 584 + 585 + if (pm8001_dev->dev_type == SAS_PHY_UNUSED) { 586 + pm8001_init_dev(pm8001_dev, dev); 587 + return pm8001_dev; 593 588 } 594 589 } 595 590 if (dev == PM8001_MAX_DEVICES) { ··· 622 613 623 614 void pm8001_free_dev(struct pm8001_device *pm8001_dev) 624 615 { 625 - u32 id = pm8001_dev->id; 626 616 memset(pm8001_dev, 0, sizeof(*pm8001_dev)); 627 - pm8001_dev->id = id; 628 617 pm8001_dev->dev_type = SAS_PHY_UNUSED; 629 618 pm8001_dev->device_id = PM8001_MAX_DEVICES; 630 619 pm8001_dev->sas_device = NULL;