summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPixelBot AutoMerger <android-nexus-securitybot@system.gserviceaccount.com>2023-08-06 18:31:19 -0700
committerSecurityBot <android-nexus-securitybot@system.gserviceaccount.com>2023-08-06 18:31:19 -0700
commit189ffbf1262a14f00c42cd248e49f43c5bab1be1 (patch)
tree3217b36bd43b8b4c654b7ceac0550986052c1033
parentec2e64f0bb54d942059d75ccc7c4ab6daa775f78 (diff)
parenta837663b90b9ec70d05d8d25e1d99bb6242eea1d (diff)
downloadgs201-android-gs-bluejay-5.10-android14-qpr1.tar.gz
Merge android13-gs-pixel-5.10-udc into android13-gs-pixel-5.10-udc-qpr1android-u-qpr3-beta-2_r0.7android-u-qpr3-beta-2_r0.6android-u-qpr3-beta-2_r0.5android-u-qpr3-beta-2_r0.4android-u-qpr3-beta-2_r0.3android-u-qpr3-beta-2_r0.2android-u-qpr3-beta-2.1_r0.7android-u-qpr3-beta-2.1_r0.5android-u-qpr3-beta-2.1_r0.4android-u-qpr3-beta-2.1_r0.3android-u-qpr3-beta-2.1_r0.2android-u-qpr3-beta-2.1_r0.1android-u-qpr3-beta-1_r0.7android-u-qpr3-beta-1_r0.5android-u-qpr3-beta-1_r0.4android-u-qpr3-beta-1_r0.3android-u-qpr3-beta-1_r0.2android-u-qpr3-beta-1_r0.1android-u-qpr2-beta-3_r0.7android-u-qpr2-beta-3_r0.6android-u-qpr2-beta-3_r0.5android-u-qpr2-beta-3_r0.4android-u-qpr2-beta-3_r0.3android-u-qpr2-beta-3_r0.2android-u-qpr2-beta-3.1_r0.7android-u-qpr2-beta-3.1_r0.5android-u-qpr2-beta-3.1_r0.4android-u-qpr2-beta-3.1_r0.3android-u-qpr2-beta-3.1_r0.2android-u-qpr2-beta-3.1_r0.1android-u-qpr2-beta-2_r0.7android-u-qpr2-beta-2_r0.5android-u-qpr2-beta-2_r0.4android-u-qpr2-beta-2_r0.3android-u-qpr2-beta-2_r0.2android-u-qpr2-beta-2_r0.1android-u-qpr2-beta-1_r0.6android-u-qpr2-beta-1_r0.5android-u-qpr2-beta-1_r0.4android-u-qpr2-beta-1_r0.3android-u-qpr2-beta-1_r0.2android-u-qpr2-beta-1_r0.1android-u-qpr1-beta-2_r0.7android-u-qpr1-beta-2_r0.5android-u-qpr1-beta-2_r0.4android-u-qpr1-beta-2_r0.3android-u-qpr1-beta-2_r0.2android-u-qpr1-beta-2_r0.1android-u-qpr1-beta-2.2_r0.6android-u-qpr1-beta-2.2_r0.5android-u-qpr1-beta-2.2_r0.4android-u-qpr1-beta-2.2_r0.3android-u-qpr1-beta-2.2_r0.2android-u-qpr1-beta-2.2_r0.1android-u-qpr1-beta-2.1_r0.7android-u-qpr1-beta-2.1_r0.5android-u-qpr1-beta-2.1_r0.4android-u-qpr1-beta-2.1_r0.3android-u-qpr1-beta-2.1_r0.2android-u-qpr1-beta-2.1_r0.1android-u-qpr1-beta-1_r0.7android-u-qpr1-beta-1_r0.5android-u-qpr1-beta-1_r0.4android-u-qpr1-beta-1_r0.3android-u-qpr1-beta-1_r0.2android-u-qpr1-beta-1_r0.1android-15-dp-2_r0.6android-15-dp-2_r0.5android-15-dp-2_r0.4android-15-dp-2_r0.3android-15-dp-2_r0.2android-15-dp-2_r0.1android-15-dp-1_r0.7android-15-dp-1_r0.5android-15-dp-1_r0.4android-15-dp-1_r0.3android-15-dp-1_r0.2android-15-dp-1_r0.1android-15-beta-1_r0.6android-15-beta-1_r0.5android-15-beta-1_r0.4android-15-beta-1_r0.3android-15-beta-1_r0.2android-15-beta-1_r0.1android-14.0.0_r0.66android-14.0.0_r0.65android-14.0.0_r0.64android-14.0.0_r0.63android-14.0.0_r0.62android-14.0.0_r0.61android-14.0.0_r0.56android-14.0.0_r0.55android-14.0.0_r0.54android-14.0.0_r0.53android-14.0.0_r0.52android-14.0.0_r0.51android-14.0.0_r0.44android-14.0.0_r0.43android-14.0.0_r0.42android-14.0.0_r0.41android-14.0.0_r0.40android-14.0.0_r0.39android-14.0.0_r0.37android-14.0.0_r0.36android-14.0.0_r0.35android-14.0.0_r0.34android-14.0.0_r0.33android-14.0.0_r0.31android-14.0.0_r0.25android-14.0.0_r0.23android-14.0.0_r0.22android-14.0.0_r0.21android-14.0.0_r0.19android-gs-tangorpro-5.10-u-qpr1-beta2android-gs-tangorpro-5.10-android15-dpandroid-gs-tangorpro-5.10-android15-betaandroid-gs-tangorpro-5.10-android14-qpr3-betaandroid-gs-tangorpro-5.10-android14-qpr2-betaandroid-gs-tangorpro-5.10-android14-qpr2android-gs-tangorpro-5.10-android14-qpr1-betaandroid-gs-tangorpro-5.10-android14-qpr1android-gs-raviole-5.10-u-qpr1-beta2android-gs-raviole-5.10-android15-dpandroid-gs-raviole-5.10-android15-betaandroid-gs-raviole-5.10-android14-qpr3-betaandroid-gs-raviole-5.10-android14-qpr2-betaandroid-gs-raviole-5.10-android14-qpr2android-gs-raviole-5.10-android14-qpr1-betaandroid-gs-raviole-5.10-android14-qpr1android-gs-pantah-5.10-u-qpr1-beta2android-gs-pantah-5.10-android15-dpandroid-gs-pantah-5.10-android15-betaandroid-gs-pantah-5.10-android14-qpr3-betaandroid-gs-pantah-5.10-android14-qpr2-betaandroid-gs-pantah-5.10-android14-qpr2android-gs-pantah-5.10-android14-qpr1-betaandroid-gs-pantah-5.10-android14-qpr1android-gs-lynx-5.10-u-qpr1-beta2android-gs-lynx-5.10-android15-dpandroid-gs-lynx-5.10-android15-betaandroid-gs-lynx-5.10-android14-qpr3-betaandroid-gs-lynx-5.10-android14-qpr2-betaandroid-gs-lynx-5.10-android14-qpr2android-gs-lynx-5.10-android14-qpr1-betaandroid-gs-lynx-5.10-android14-qpr1android-gs-felix-5.10-u-qpr1-beta2android-gs-felix-5.10-android15-dpandroid-gs-felix-5.10-android15-betaandroid-gs-felix-5.10-android14-qpr3-betaandroid-gs-felix-5.10-android14-qpr2-betaandroid-gs-felix-5.10-android14-qpr2android-gs-felix-5.10-android14-qpr1-betaandroid-gs-felix-5.10-android14-qpr1android-gs-bluejay-5.10-u-qpr1-beta2android-gs-bluejay-5.10-android15-dpandroid-gs-bluejay-5.10-android15-betaandroid-gs-bluejay-5.10-android14-qpr3-betaandroid-gs-bluejay-5.10-android14-qpr2-betaandroid-gs-bluejay-5.10-android14-qpr2android-gs-bluejay-5.10-android14-qpr1-betaandroid-gs-bluejay-5.10-android14-qpr1
SBMerger: 526756187 Change-Id: I2ece8a1a1b31db9484f0e98e8f026d2e49fcf119 Signed-off-by: SecurityBot <android-nexus-securitybot@system.gserviceaccount.com>
-rw-r--r--gxp-common-platform.c44
-rw-r--r--gxp-vd.c34
-rw-r--r--gxp-vd.h13
3 files changed, 64 insertions, 27 deletions
diff --git a/gxp-common-platform.c b/gxp-common-platform.c
index 7514b11..6318e98 100644
--- a/gxp-common-platform.c
+++ b/gxp-common-platform.c
@@ -280,8 +280,7 @@ error_destroy:
return ret;
}
-static int gxp_unmap_buffer(struct gxp_client *client,
- struct gxp_map_ioctl __user *argp)
+static int gxp_unmap_buffer(struct gxp_client *client, struct gxp_map_ioctl __user *argp)
{
struct gxp_dev *gxp = client->gxp;
struct gxp_map_ioctl ibuf;
@@ -300,29 +299,32 @@ static int gxp_unmap_buffer(struct gxp_client *client,
goto out;
}
- map = gxp_vd_mapping_search(client->vd,
- (dma_addr_t)ibuf.device_address);
+ down_write(&client->vd->mappings_semaphore);
+
+ map = gxp_vd_mapping_search_locked(client->vd, (dma_addr_t)ibuf.device_address);
if (!map) {
- dev_err(gxp->dev,
- "Mapping not found for provided device address %#llX\n",
+ dev_err(gxp->dev, "Mapping not found for provided device address %#llX\n",
ibuf.device_address);
ret = -EINVAL;
- goto out;
} else if (!map->host_address) {
dev_err(gxp->dev, "dma-bufs must be unmapped via GXP_UNMAP_DMABUF\n");
ret = -EINVAL;
- goto out;
}
- WARN_ON(map->host_address != ibuf.host_address);
+ if (ret) {
+ up_write(&client->vd->mappings_semaphore);
+ goto out_put;
+ }
+
+ gxp_vd_mapping_remove_locked(client->vd, map);
+ up_write(&client->vd->mappings_semaphore);
- gxp_vd_mapping_remove(client->vd, map);
- gxp_mapping_iova_log(client, map,
- GXP_IOVA_LOG_UNMAP | GXP_IOVA_LOG_BUFFER);
+ gxp_mapping_iova_log(client, map, GXP_IOVA_LOG_UNMAP | GXP_IOVA_LOG_BUFFER);
+out_put:
/* Release the reference from gxp_vd_mapping_search() */
- gxp_mapping_put(map);
-
+ if (map)
+ gxp_mapping_put(map);
out:
up_read(&client->semaphore);
@@ -1335,8 +1337,7 @@ out_unlock:
return ret;
}
-static int gxp_unmap_dmabuf(struct gxp_client *client,
- struct gxp_map_dmabuf_ioctl __user *argp)
+static int gxp_unmap_dmabuf(struct gxp_client *client, struct gxp_map_dmabuf_ioctl __user *argp)
{
struct gxp_dev *gxp = client->gxp;
struct gxp_map_dmabuf_ioctl ibuf;
@@ -1355,14 +1356,17 @@ static int gxp_unmap_dmabuf(struct gxp_client *client,
goto out;
}
+ down_write(&client->vd->mappings_semaphore);
+
/*
* Fetch and remove the internal mapping records.
* If host_address is not 0, the provided device_address belongs to a
* non-dma-buf mapping.
*/
- mapping = gxp_vd_mapping_search(client->vd, ibuf.device_address);
+ mapping = gxp_vd_mapping_search_locked(client->vd, ibuf.device_address);
if (IS_ERR_OR_NULL(mapping) || mapping->host_address) {
dev_warn(gxp->dev, "No dma-buf mapped for given IOVA\n");
+ up_write(&client->vd->mappings_semaphore);
/*
* If the device address belongs to a non-dma-buf mapping,
* release the reference to it obtained via the search.
@@ -1374,10 +1378,10 @@ static int gxp_unmap_dmabuf(struct gxp_client *client,
}
/* Remove the mapping from its VD, releasing the VD's reference */
- gxp_vd_mapping_remove(client->vd, mapping);
+ gxp_vd_mapping_remove_locked(client->vd, mapping);
+ up_write(&client->vd->mappings_semaphore);
- gxp_mapping_iova_log(client, mapping,
- GXP_IOVA_LOG_UNMAP | GXP_IOVA_LOG_DMABUF);
+ gxp_mapping_iova_log(client, mapping, GXP_IOVA_LOG_UNMAP | GXP_IOVA_LOG_DMABUF);
/* Release the reference from gxp_vd_mapping_search() */
gxp_mapping_put(mapping);
diff --git a/gxp-vd.c b/gxp-vd.c
index 37d8ab5..a0bfe95 100644
--- a/gxp-vd.c
+++ b/gxp-vd.c
@@ -1315,14 +1315,19 @@ void gxp_vd_mapping_remove(struct gxp_virtual_device *vd,
struct gxp_mapping *map)
{
down_write(&vd->mappings_semaphore);
+ gxp_vd_mapping_remove_locked(vd, map);
+ up_write(&vd->mappings_semaphore);
+}
+
+void gxp_vd_mapping_remove_locked(struct gxp_virtual_device *vd, struct gxp_mapping *map)
+{
+ lockdep_assert_held_write(&vd->mappings_semaphore);
/* Drop the mapping from this virtual device's records */
rb_erase(&map->node, &vd->mappings_root);
/* Release the reference obtained in gxp_vd_mapping_store() */
gxp_mapping_put(map);
-
- up_write(&vd->mappings_semaphore);
}
static bool is_device_address_in_mapping(struct gxp_mapping *mapping,
@@ -1339,7 +1344,7 @@ gxp_vd_mapping_internal_search(struct gxp_virtual_device *vd,
struct rb_node *node;
struct gxp_mapping *mapping;
- down_read(&vd->mappings_semaphore);
+ lockdep_assert_held(&vd->mappings_semaphore);
node = vd->mappings_root.rb_node;
@@ -1349,7 +1354,6 @@ gxp_vd_mapping_internal_search(struct gxp_virtual_device *vd,
(check_range &&
is_device_address_in_mapping(mapping, device_address))) {
gxp_mapping_get(mapping);
- up_read(&vd->mappings_semaphore);
return mapping; /* Found it */
} else if (mapping->device_address > device_address) {
node = node->rb_left;
@@ -1358,14 +1362,24 @@ gxp_vd_mapping_internal_search(struct gxp_virtual_device *vd,
}
}
- up_read(&vd->mappings_semaphore);
-
return NULL;
}
struct gxp_mapping *gxp_vd_mapping_search(struct gxp_virtual_device *vd,
dma_addr_t device_address)
{
+ struct gxp_mapping *mapping;
+
+ down_read(&vd->mappings_semaphore);
+ mapping = gxp_vd_mapping_search_locked(vd, device_address);
+ up_read(&vd->mappings_semaphore);
+
+ return mapping;
+}
+
+struct gxp_mapping *gxp_vd_mapping_search_locked(struct gxp_virtual_device *vd,
+ dma_addr_t device_address)
+{
return gxp_vd_mapping_internal_search(vd, device_address, false);
}
@@ -1373,7 +1387,13 @@ struct gxp_mapping *
gxp_vd_mapping_search_in_range(struct gxp_virtual_device *vd,
dma_addr_t device_address)
{
- return gxp_vd_mapping_internal_search(vd, device_address, true);
+ struct gxp_mapping *mapping;
+
+ down_read(&vd->mappings_semaphore);
+ mapping = gxp_vd_mapping_internal_search(vd, device_address, true);
+ up_read(&vd->mappings_semaphore);
+
+ return mapping;
}
struct gxp_mapping *gxp_vd_mapping_search_host(struct gxp_virtual_device *vd,
diff --git a/gxp-vd.h b/gxp-vd.h
index e0bd5ce..47ba60a 100644
--- a/gxp-vd.h
+++ b/gxp-vd.h
@@ -265,6 +265,12 @@ void gxp_vd_mapping_remove(struct gxp_virtual_device *vd,
struct gxp_mapping *map);
/**
+ * gxp_vd_mapping_remove_locked() - The same as `gxp_vd_mapping_remove` but the caller holds
+ * @vd->mappings_semaphore as write.
+ */
+void gxp_vd_mapping_remove_locked(struct gxp_virtual_device *vd, struct gxp_mapping *map);
+
+/**
* gxp_vd_mapping_search() - Obtain a reference to the mapping starting at the
* specified device address
* @vd: The virtual device to search for the mapping
@@ -278,6 +284,13 @@ struct gxp_mapping *gxp_vd_mapping_search(struct gxp_virtual_device *vd,
dma_addr_t device_address);
/**
+ * gxp_vd_mapping_search_locked() - The same as `gxp_vd_mapping_search` but the caller holds
+ * @vd->mappings_semaphore.
+ */
+struct gxp_mapping *gxp_vd_mapping_search_locked(struct gxp_virtual_device *vd,
+ dma_addr_t device_address);
+
+/**
* gxp_vd_mapping_search_in_range() - Obtain a reference to the mapping which
* contains the specified device address
* @vd: The virtual device to search for the mapping