Skip to content
Snippets Groups Projects
Select Git revision
  • 3cdeb9d15149a543f690ac9b2fccb128496dfb06
  • openEuler-1.0-LTS default protected
  • openEuler-22.09
  • OLK-5.10
  • openEuler-22.03-LTS-Ascend
  • openEuler-22.03-LTS
  • master
  • openEuler-22.03-LTS-LoongArch-NW
  • openEuler-22.09-HCK
  • openEuler-20.03-LTS-SP3
  • openEuler-21.09
  • openEuler-21.03
  • openEuler-20.09
  • 5.10.0-121.0.0
  • 5.10.0-60.61.0
  • 4.19.90-2210.3.0
  • 5.10.0-60.60.0
  • 5.10.0-120.0.0
  • 5.10.0-60.59.0
  • 5.10.0-119.0.0
  • 4.19.90-2210.2.0
  • 4.19.90-2210.1.0
  • 5.10.0-118.0.0
  • 5.10.0-106.19.0
  • 5.10.0-60.58.0
  • 4.19.90-2209.6.0
  • 5.10.0-106.18.0
  • 5.10.0-106.17.0
  • 5.10.0-106.16.0
  • 5.10.0-106.15.0
  • 5.10.0-117.0.0
  • 5.10.0-60.57.0
  • 5.10.0-116.0.0
33 results

api.c

Blame
  • api.c 6.90 KiB
    /*
     * Copyright 2014 IBM Corp.
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * as published by the Free Software Foundation; either version
     * 2 of the License, or (at your option) any later version.
     */
    
    #include <linux/pci.h>
    #include <linux/slab.h>
    #include <linux/anon_inodes.h>
    #include <linux/file.h>
    #include <misc/cxl.h>
    
    #include "cxl.h"
    
    struct cxl_context *cxl_dev_context_init(struct pci_dev *dev)
    {
    	struct cxl_afu *afu;
    	struct cxl_context  *ctx;
    	int rc;
    
    	afu = cxl_pci_to_afu(dev);
    
    	get_device(&afu->dev);
    	ctx = cxl_context_alloc();
    	if (IS_ERR(ctx))
    		return ctx;
    
    	/* Make it a slave context.  We can promote it later? */
    	rc = cxl_context_init(ctx, afu, false, NULL);
    	if (rc) {
    		kfree(ctx);
    		put_device(&afu->dev);
    		return ERR_PTR(-ENOMEM);
    	}
    	cxl_assign_psn_space(ctx);
    
    	return ctx;
    }
    EXPORT_SYMBOL_GPL(cxl_dev_context_init);
    
    struct cxl_context *cxl_get_context(struct pci_dev *dev)
    {
    	return dev->dev.archdata.cxl_ctx;
    }
    EXPORT_SYMBOL_GPL(cxl_get_context);
    
    struct device *cxl_get_phys_dev(struct pci_dev *dev)
    {
    	struct cxl_afu *afu;
    
    	afu = cxl_pci_to_afu(dev);
    
    	return afu->adapter->dev.parent;
    }
    EXPORT_SYMBOL_GPL(cxl_get_phys_dev);
    
    int cxl_release_context(struct cxl_context *ctx)
    {
    	if (ctx->status != CLOSED)
    		return -EBUSY;
    
    	put_device(&ctx->afu->dev);
    
    	cxl_context_free(ctx);
    
    	return 0;
    }