init.c (1e5b3968a57d7894d5f86a2ecb58fa057cb6f7b2) init.c (9735bde36487da43d3c3fc910df49639f72decbf)
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/slab.h>
7#include <linux/pci.h>
8#include <linux/interrupt.h>
9#include <linux/delay.h>
10#include <linux/dma-mapping.h>
11#include <linux/workqueue.h>
12#include <linux/aer.h>
13#include <linux/fs.h>
14#include <linux/io-64-nonatomic-lo-hi.h>
15#include <linux/device.h>
16#include <linux/idr.h>
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/slab.h>
7#include <linux/pci.h>
8#include <linux/interrupt.h>
9#include <linux/delay.h>
10#include <linux/dma-mapping.h>
11#include <linux/workqueue.h>
12#include <linux/aer.h>
13#include <linux/fs.h>
14#include <linux/io-64-nonatomic-lo-hi.h>
15#include <linux/device.h>
16#include <linux/idr.h>
17#include <linux/intel-svm.h>
18#include <linux/iommu.h>
19#include <uapi/linux/idxd.h>
20#include <linux/dmaengine.h>
21#include "../dmaengine.h"
22#include "registers.h"
23#include "idxd.h"
24#include "perfmon.h"
25

--- 265 unchanged lines hidden (view full) ---

291 conf_dev->type = &idxd_group_device_type;
292 rc = dev_set_name(conf_dev, "group%d.%d", idxd->id, group->id);
293 if (rc < 0) {
294 put_device(conf_dev);
295 goto err;
296 }
297
298 idxd->groups[i] = group;
17#include <linux/iommu.h>
18#include <uapi/linux/idxd.h>
19#include <linux/dmaengine.h>
20#include "../dmaengine.h"
21#include "registers.h"
22#include "idxd.h"
23#include "perfmon.h"
24

--- 265 unchanged lines hidden (view full) ---

290 conf_dev->type = &idxd_group_device_type;
291 rc = dev_set_name(conf_dev, "group%d.%d", idxd->id, group->id);
292 if (rc < 0) {
293 put_device(conf_dev);
294 goto err;
295 }
296
297 idxd->groups[i] = group;
299 if (idxd->hw.version < DEVICE_VERSION_2 && !tc_override) {
298 if (idxd->hw.version <= DEVICE_VERSION_2 && !tc_override) {
300 group->tc_a = 1;
301 group->tc_b = 1;
302 } else {
303 group->tc_a = -1;
304 group->tc_b = -1;
305 }
306 }
307

--- 189 unchanged lines hidden (view full) ---

497 spin_lock_init(&idxd->dev_lock);
498 spin_lock_init(&idxd->cmd_lock);
499
500 return idxd;
501}
502
503static int idxd_enable_system_pasid(struct idxd_device *idxd)
504{
299 group->tc_a = 1;
300 group->tc_b = 1;
301 } else {
302 group->tc_a = -1;
303 group->tc_b = -1;
304 }
305 }
306

--- 189 unchanged lines hidden (view full) ---

496 spin_lock_init(&idxd->dev_lock);
497 spin_lock_init(&idxd->cmd_lock);
498
499 return idxd;
500}
501
502static int idxd_enable_system_pasid(struct idxd_device *idxd)
503{
505 int flags;
506 unsigned int pasid;
507 struct iommu_sva *sva;
508
509 flags = SVM_FLAG_SUPERVISOR_MODE;
510
511 sva = iommu_sva_bind_device(&idxd->pdev->dev, NULL, &flags);
512 if (IS_ERR(sva)) {
513 dev_warn(&idxd->pdev->dev,
514 "iommu sva bind failed: %ld\n", PTR_ERR(sva));
515 return PTR_ERR(sva);
516 }
517
518 pasid = iommu_sva_get_pasid(sva);
519 if (pasid == IOMMU_PASID_INVALID) {
520 iommu_sva_unbind_device(sva);
521 return -ENODEV;
522 }
523
524 idxd->sva = sva;
525 idxd->pasid = pasid;
526 dev_dbg(&idxd->pdev->dev, "system pasid: %u\n", pasid);
527 return 0;
504 return -EOPNOTSUPP;
528}
529
530static void idxd_disable_system_pasid(struct idxd_device *idxd)
531{
532
533 iommu_sva_unbind_device(idxd->sva);
534 idxd->sva = NULL;
535}

--- 275 unchanged lines hidden ---
505}
506
507static void idxd_disable_system_pasid(struct idxd_device *idxd)
508{
509
510 iommu_sva_unbind_device(idxd->sva);
511 idxd->sva = NULL;
512}

--- 275 unchanged lines hidden ---