kpu_profile ? kpu_profile : default_pfl_name, KPU_NAME_LEN);
}
+static atomic_t device_bound = ATOMIC_INIT(0);
+
static int rvu_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
struct device *dev = &pdev->dev;
struct rvu *rvu;
int err;
+ if (atomic_cmpxchg(&device_bound, 0, 1) != 0) {
+ dev_warn(dev, "Only one af device is supported.\n");
+ return -EBUSY;
+ }
+
rvu = devm_kzalloc(dev, sizeof(*rvu), GFP_KERNEL);
- if (!rvu)
+ if (!rvu) {
+ atomic_set(&device_bound, 0);
return -ENOMEM;
+ }
rvu->hw = devm_kzalloc(dev, sizeof(struct rvu_hwinfo), GFP_KERNEL);
if (!rvu->hw) {
devm_kfree(dev, rvu);
+ atomic_set(&device_bound, 0);
return -ENOMEM;
}
pci_set_drvdata(pdev, NULL);
devm_kfree(&pdev->dev, rvu->hw);
devm_kfree(dev, rvu);
+ atomic_set(&device_bound, 0);
return err;
}
cn20k_free_mbox_memory(rvu);
kfree(rvu->ng_rvu);
devm_kfree(&pdev->dev, rvu);
+ atomic_set(&device_bound, 0);
}
static void rvu_shutdown(struct pci_dev *pdev)