sysfs.c (93a40a6d7428921897bb7fed5ffb4ce83df05432) | sysfs.c (8c66bbdc4fbf3c297ebc8edf71f359e4a132c9db) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* Copyright(c) 2019 Intel Corporation. All rights rsvd. */ 3#include <linux/init.h> 4#include <linux/kernel.h> 5#include <linux/module.h> 6#include <linux/pci.h> 7#include <linux/device.h> 8#include <linux/io-64-nonatomic-lo-hi.h> --- 96 unchanged lines hidden (view full) --- 105 rc = idxd_wq_alloc_resources(wq); 106 if (rc < 0) { 107 mutex_unlock(&wq->wq_lock); 108 dev_warn(dev, "WQ resource alloc failed\n"); 109 return rc; 110 } 111 112 spin_lock_irqsave(&idxd->dev_lock, flags); | 1// SPDX-License-Identifier: GPL-2.0 2/* Copyright(c) 2019 Intel Corporation. All rights rsvd. */ 3#include <linux/init.h> 4#include <linux/kernel.h> 5#include <linux/module.h> 6#include <linux/pci.h> 7#include <linux/device.h> 8#include <linux/io-64-nonatomic-lo-hi.h> --- 96 unchanged lines hidden (view full) --- 105 rc = idxd_wq_alloc_resources(wq); 106 if (rc < 0) { 107 mutex_unlock(&wq->wq_lock); 108 dev_warn(dev, "WQ resource alloc failed\n"); 109 return rc; 110 } 111 112 spin_lock_irqsave(&idxd->dev_lock, flags); |
113 rc = idxd_device_config(idxd); | 113 if (test_bit(IDXD_FLAG_CONFIGURABLE, &idxd->flags)) 114 rc = idxd_device_config(idxd); |
114 spin_unlock_irqrestore(&idxd->dev_lock, flags); 115 if (rc < 0) { 116 mutex_unlock(&wq->wq_lock); 117 dev_warn(dev, "Writing WQ %d config failed: %d\n", wq->id, rc); 118 return rc; 119 } 120 121 rc = idxd_wq_enable(wq); --- 43 unchanged lines hidden (view full) --- 165 mutex_unlock(&wq->wq_lock); 166 dev_info(dev, "wq %s enabled\n", dev_name(&wq->conf_dev)); 167 168 return 0; 169} 170 171static int idxd_config_bus_probe(struct device *dev) 172{ | 115 spin_unlock_irqrestore(&idxd->dev_lock, flags); 116 if (rc < 0) { 117 mutex_unlock(&wq->wq_lock); 118 dev_warn(dev, "Writing WQ %d config failed: %d\n", wq->id, rc); 119 return rc; 120 } 121 122 rc = idxd_wq_enable(wq); --- 43 unchanged lines hidden (view full) --- 166 mutex_unlock(&wq->wq_lock); 167 dev_info(dev, "wq %s enabled\n", dev_name(&wq->conf_dev)); 168 169 return 0; 170} 171 172static int idxd_config_bus_probe(struct device *dev) 173{ |
173 int rc; | 174 int rc = 0; |
174 unsigned long flags; 175 176 dev_dbg(dev, "%s called\n", __func__); 177 178 if (is_idxd_dev(dev)) { 179 struct idxd_device *idxd = confdev_to_idxd(dev); 180 181 if (idxd->state != IDXD_DEV_CONF_READY) { 182 dev_warn(dev, "Device not ready for config\n"); 183 return -EBUSY; 184 } 185 186 if (!try_module_get(THIS_MODULE)) 187 return -ENXIO; 188 189 /* Perform IDXD configuration and enabling */ 190 spin_lock_irqsave(&idxd->dev_lock, flags); | 175 unsigned long flags; 176 177 dev_dbg(dev, "%s called\n", __func__); 178 179 if (is_idxd_dev(dev)) { 180 struct idxd_device *idxd = confdev_to_idxd(dev); 181 182 if (idxd->state != IDXD_DEV_CONF_READY) { 183 dev_warn(dev, "Device not ready for config\n"); 184 return -EBUSY; 185 } 186 187 if (!try_module_get(THIS_MODULE)) 188 return -ENXIO; 189 190 /* Perform IDXD configuration and enabling */ 191 spin_lock_irqsave(&idxd->dev_lock, flags); |
191 rc = idxd_device_config(idxd); | 192 if (test_bit(IDXD_FLAG_CONFIGURABLE, &idxd->flags)) 193 rc = idxd_device_config(idxd); |
192 spin_unlock_irqrestore(&idxd->dev_lock, flags); 193 if (rc < 0) { 194 module_put(THIS_MODULE); 195 dev_warn(dev, "Device config failed: %d\n", rc); 196 return rc; 197 } 198 199 /* start device */ --- 82 unchanged lines hidden (view full) --- 282 continue; 283 dev_warn(dev, "Active wq %d on disable %s.\n", i, 284 dev_name(&idxd->conf_dev)); 285 device_release_driver(&wq->conf_dev); 286 } 287 288 idxd_unregister_dma_device(idxd); 289 rc = idxd_device_disable(idxd); | 194 spin_unlock_irqrestore(&idxd->dev_lock, flags); 195 if (rc < 0) { 196 module_put(THIS_MODULE); 197 dev_warn(dev, "Device config failed: %d\n", rc); 198 return rc; 199 } 200 201 /* start device */ --- 82 unchanged lines hidden (view full) --- 284 continue; 285 dev_warn(dev, "Active wq %d on disable %s.\n", i, 286 dev_name(&idxd->conf_dev)); 287 device_release_driver(&wq->conf_dev); 288 } 289 290 idxd_unregister_dma_device(idxd); 291 rc = idxd_device_disable(idxd); |
290 for (i = 0; i < idxd->max_wqs; i++) { 291 struct idxd_wq *wq = idxd->wqs[i]; | 292 if (test_bit(IDXD_FLAG_CONFIGURABLE, &idxd->flags)) { 293 for (i = 0; i < idxd->max_wqs; i++) { 294 struct idxd_wq *wq = idxd->wqs[i]; |
292 | 295 |
293 mutex_lock(&wq->wq_lock); 294 idxd_wq_disable_cleanup(wq); 295 mutex_unlock(&wq->wq_lock); | 296 mutex_lock(&wq->wq_lock); 297 idxd_wq_disable_cleanup(wq); 298 mutex_unlock(&wq->wq_lock); 299 } |
296 } 297 module_put(THIS_MODULE); 298 if (rc < 0) 299 dev_warn(dev, "Device disable failed\n"); 300 else 301 dev_info(dev, "Device %s disabled\n", dev_name(dev)); 302 303 } --- 1457 unchanged lines hidden --- | 300 } 301 module_put(THIS_MODULE); 302 if (rc < 0) 303 dev_warn(dev, "Device disable failed\n"); 304 else 305 dev_info(dev, "Device %s disabled\n", dev_name(dev)); 306 307 } --- 1457 unchanged lines hidden --- |