summaryrefslogtreecommitdiff
path: root/gxp-mapping.c
diff options
context:
space:
mode:
authorAurora pro automerger <aurora-pro-automerger@google.com>2022-04-28 17:59:17 +0800
committerJohn Scheible <johnscheible@google.com>2022-05-02 22:33:52 +0000
commit27bed782f3a828674c0f1584cf355bf592c382be (patch)
tree79f6f3410eece25889b3cfc80dcd156ec5b543c6 /gxp-mapping.c
parenta96a198c9328b06866df39ebd420b0f3fd58ce51 (diff)
downloadgs201-27bed782f3a828674c0f1584cf355bf592c382be.tar.gz
[Copybara Auto Merge] Merge branch 'gs201-release' into 'android13-gs-pixel-5.10'
gxp: check BLK is on during power state transition gxp: prepare more worker structures for async jobs gxp: Cleanup virt<->phys core translation APIs gxp: switch mux to make sure LPM works gxp: init has_vd_lock field of gxp_client gxp: Clean up variable names and update variable type gxp: remove gxp-tmp.h gxp: move scratchpad macros from tmp to firmware.h gxp: remove no-iommu support gxp: remove SYNC_ macros from tmp.h gxp: remove DOORBELL macros gxp: move PSM macros to lpm.h gxp: Check for valid VD in mb_eventfd IOCTLs gxp: Firmware startup and Core-On optimizations gxp: Move ownership of user response queues gxp: move macros from tmp.h to bpm.c gxp: remove legacy software mailbox support gxp: Add gxp-eventfd interface gxp: remove unused macros from gxp-tmp.h gxp: bind page tables per virtual device Bug: 176979630 Bug: 207037425 Bug: 207038856 Bug: 209083969 Bug: 225059930 Bug: 226211187 Bug: 227145352 Bug: 227693917 Bug: 227694164 Bug: 228233514 Bug: 228921329 Bug: 229095276 Bug: 229584236 GitOrigin-RevId: d2c00e3ee2d71e551d41adfa5bcc6bec79379db3 Signed-off-by: Todd Poynor <toddpoynor@google.com> Change-Id: Ia92e12a2ab46eadc2876bcdb7ed3c04e223b3901
Diffstat (limited to 'gxp-mapping.c')
-rw-r--r--gxp-mapping.c54
1 files changed, 29 insertions, 25 deletions
diff --git a/gxp-mapping.c b/gxp-mapping.c
index 5db126b..8f9359e 100644
--- a/gxp-mapping.c
+++ b/gxp-mapping.c
@@ -27,8 +27,10 @@ int gxp_mapping_init(struct gxp_dev *gxp)
return 0;
}
-struct gxp_mapping *gxp_mapping_create(struct gxp_dev *gxp, uint core_list,
- u64 user_address, size_t size, u32 flags,
+struct gxp_mapping *gxp_mapping_create(struct gxp_dev *gxp,
+ struct gxp_virtual_device *vd,
+ uint virt_core_list, u64 user_address,
+ size_t size, u32 flags,
enum dma_data_direction dir)
{
struct gxp_mapping *mapping = NULL;
@@ -90,7 +92,8 @@ struct gxp_mapping *gxp_mapping_create(struct gxp_dev *gxp, uint core_list,
goto error_unpin_pages;
}
mapping->host_address = user_address;
- mapping->core_list = core_list;
+ mapping->virt_core_list = virt_core_list;
+ mapping->vd = vd;
mapping->size = size;
mapping->map_count = 1;
mapping->gxp_dma_flags = flags;
@@ -104,8 +107,8 @@ struct gxp_mapping *gxp_mapping_create(struct gxp_dev *gxp, uint core_list,
}
/* map the user pages */
- ret = gxp_dma_map_sg(gxp, mapping->core_list, mapping->sgt.sgl,
- mapping->sgt.nents, mapping->dir,
+ ret = gxp_dma_map_sg(gxp, mapping->vd, mapping->virt_core_list,
+ mapping->sgt.sgl, mapping->sgt.nents, mapping->dir,
DMA_ATTR_SKIP_CPU_SYNC, mapping->gxp_dma_flags);
if (!ret) {
dev_dbg(gxp->dev, "Failed to map sgt (ret=%d)\n", ret);
@@ -144,9 +147,9 @@ void gxp_mapping_destroy(struct gxp_dev *gxp, struct gxp_mapping *mapping)
* user requires a mapping be synced before unmapping, they are
* responsible for calling `gxp_mapping_sync()` before hand.
*/
- gxp_dma_unmap_sg(gxp, mapping->core_list, mapping->sgt.sgl,
- mapping->sgt.orig_nents, mapping->dir,
- DMA_ATTR_SKIP_CPU_SYNC);
+ gxp_dma_unmap_sg(gxp, mapping->vd, mapping->virt_core_list,
+ mapping->sgt.sgl, mapping->sgt.orig_nents,
+ mapping->dir, DMA_ATTR_SKIP_CPU_SYNC);
/* Unpin the user pages */
for_each_sg_page(mapping->sgt.sgl, &sg_iter, mapping->sgt.orig_nents,
@@ -255,8 +258,8 @@ int gxp_mapping_put(struct gxp_dev *gxp, struct gxp_mapping *map)
{
struct rb_node **link;
struct rb_node *parent = NULL;
- u64 device_address = map->device_address;
- struct gxp_mapping *this;
+ dma_addr_t device_address = map->device_address;
+ struct gxp_mapping *mapping;
link = &gxp->mappings->rb.rb_node;
@@ -265,11 +268,11 @@ int gxp_mapping_put(struct gxp_dev *gxp, struct gxp_mapping *map)
/* Figure out where to put new node */
while (*link) {
parent = *link;
- this = rb_entry(parent, struct gxp_mapping, node);
+ mapping = rb_entry(parent, struct gxp_mapping, node);
- if (this->device_address > device_address)
+ if (mapping->device_address > device_address)
link = &(*link)->rb_left;
- else if (this->device_address < device_address)
+ else if (mapping->device_address < device_address)
link = &(*link)->rb_right;
else
goto out;
@@ -285,42 +288,43 @@ int gxp_mapping_put(struct gxp_dev *gxp, struct gxp_mapping *map)
out:
mutex_unlock(&gxp->mappings->lock);
- dev_err(gxp->dev, "Duplicate mapping: 0x%llx", map->device_address);
+ dev_err(gxp->dev, "Duplicate mapping: %pad", &map->device_address);
return -EINVAL;
}
-struct gxp_mapping *gxp_mapping_get(struct gxp_dev *gxp, u64 device_address)
+struct gxp_mapping *gxp_mapping_get(struct gxp_dev *gxp,
+ dma_addr_t device_address)
{
struct rb_node *node;
- struct gxp_mapping *this;
+ struct gxp_mapping *mapping;
mutex_lock(&gxp->mappings->lock);
node = gxp->mappings->rb.rb_node;
while (node) {
- this = rb_entry(node, struct gxp_mapping, node);
+ mapping = rb_entry(node, struct gxp_mapping, node);
- if (this->device_address > device_address) {
+ if (mapping->device_address > device_address) {
node = node->rb_left;
- } else if (this->device_address < device_address) {
+ } else if (mapping->device_address < device_address) {
node = node->rb_right;
} else {
mutex_unlock(&gxp->mappings->lock);
- return this; /* Found it */
+ return mapping; /* Found it */
}
}
mutex_unlock(&gxp->mappings->lock);
- dev_err(gxp->dev, "Mapping not found: 0x%llx", device_address);
+ dev_err(gxp->dev, "Mapping not found: %pad", &device_address);
return NULL;
}
struct gxp_mapping *gxp_mapping_get_host(struct gxp_dev *gxp, u64 host_address)
{
struct rb_node *node;
- struct gxp_mapping *this;
+ struct gxp_mapping *mapping;
mutex_lock(&gxp->mappings->lock);
@@ -332,10 +336,10 @@ struct gxp_mapping *gxp_mapping_get_host(struct gxp_dev *gxp, u64 host_address)
/* Iterate through the elements in the rbtree */
for (node = rb_first(&gxp->mappings->rb); node; node = rb_next(node)) {
- this = rb_entry(node, struct gxp_mapping, node);
- if (this->host_address == host_address) {
+ mapping = rb_entry(node, struct gxp_mapping, node);
+ if (mapping->host_address == host_address) {
mutex_unlock(&gxp->mappings->lock);
- return this;
+ return mapping;
}
}