diff --git a/android/abi_gki_aarch64_3f413d0ec7.xml b/android/abi_gki_aarch64_3f413d0ec7.xml
index ca1a87cf2ffd..85b9c6003714 100644
--- a/android/abi_gki_aarch64_3f413d0ec7.xml
+++ b/android/abi_gki_aarch64_3f413d0ec7.xml
@@ -137,6 +137,8 @@
+
+
@@ -1186,6 +1188,7 @@
+
@@ -2252,6 +2255,7 @@
+
@@ -12674,6 +12678,17 @@
+
+
+
+
+
+
+
+
+
+
+
@@ -13890,7 +13905,7 @@
-
+
@@ -19738,7 +19753,7 @@
-
+
@@ -20117,10 +20132,10 @@
-
+
-
+
@@ -20392,17 +20407,6 @@
-
-
-
-
-
-
-
-
-
-
-
@@ -21682,7 +21686,7 @@
-
+
@@ -21699,7 +21703,7 @@
-
+
@@ -21984,7 +21988,7 @@
-
+
@@ -22051,7 +22055,7 @@
-
+
@@ -22900,7 +22904,7 @@
-
+
@@ -22937,7 +22941,7 @@
-
+
@@ -23984,10 +23988,10 @@
-
+
-
+
@@ -27410,7 +27414,7 @@
-
+
@@ -28078,7 +28082,7 @@
-
+
@@ -30206,6 +30210,57 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -34498,7 +34553,7 @@
-
+
@@ -34509,7 +34564,7 @@
-
+
@@ -37041,14 +37096,6 @@
-
-
-
-
-
-
-
-
@@ -39004,7 +39051,7 @@
-
+
@@ -39012,7 +39059,7 @@
-
+
@@ -39020,7 +39067,7 @@
-
+
@@ -39628,10 +39675,10 @@
-
+
-
+
@@ -40884,7 +40931,7 @@
-
+
@@ -40893,7 +40940,7 @@
-
+
@@ -41292,6 +41339,14 @@
+
+
+
+
+
+
+
+
@@ -43278,7 +43333,7 @@
-
+
@@ -43297,7 +43352,7 @@
-
+
@@ -48596,7 +48651,7 @@
-
+
@@ -49346,7 +49401,7 @@
-
+
@@ -49356,16 +49411,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -49397,7 +49442,7 @@
-
+
@@ -49796,6 +49841,7 @@
+
@@ -49804,6 +49850,7 @@
+
@@ -49994,7 +50041,7 @@
-
+
@@ -50028,6 +50075,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -50080,7 +50144,7 @@
-
+
@@ -50102,7 +50166,7 @@
-
+
@@ -50368,6 +50432,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -50421,7 +50501,7 @@
-
+
@@ -50636,7 +50716,7 @@
-
+
@@ -50651,7 +50731,7 @@
-
+
@@ -50687,7 +50767,7 @@
-
+
@@ -50733,6 +50813,93 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -50842,6 +51009,17 @@
+
+
+
+
+
+
+
+
+
+
+
@@ -51668,7 +51846,7 @@
-
+
@@ -52063,7 +52241,7 @@
-
+
@@ -52339,10 +52517,10 @@
-
+
-
+
@@ -52355,10 +52533,10 @@
-
+
-
+
@@ -52485,7 +52663,7 @@
-
+
@@ -52503,7 +52681,7 @@
-
+
@@ -53271,7 +53449,7 @@
-
+
@@ -53419,13 +53597,13 @@
-
+
-
+
@@ -56070,7 +56248,7 @@
-
+
@@ -56811,7 +56989,7 @@
-
+
@@ -56861,7 +57039,7 @@
-
+
@@ -56891,7 +57069,7 @@
-
+
@@ -56903,7 +57081,7 @@
-
+
@@ -59015,7 +59193,7 @@
-
+
@@ -59493,7 +59671,7 @@
-
+
@@ -61217,7 +61395,7 @@
-
+
@@ -61234,7 +61412,7 @@
-
+
@@ -61290,7 +61468,7 @@
-
+
@@ -61326,7 +61504,7 @@
-
+
@@ -65100,7 +65278,7 @@
-
+
@@ -67659,7 +67837,7 @@
-
+
@@ -67726,7 +67904,7 @@
-
+
@@ -67753,7 +67931,7 @@
-
+
@@ -67961,7 +68139,7 @@
-
+
@@ -67977,7 +68155,7 @@
-
+
@@ -67988,7 +68166,7 @@
-
+
@@ -68192,43 +68370,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -68675,7 +68816,7 @@
-
+
@@ -68694,7 +68835,7 @@
-
+
@@ -69014,13 +69155,13 @@
-
+
-
+
-
+
@@ -69044,7 +69185,7 @@
-
+
@@ -69301,7 +69442,7 @@
-
+
@@ -70059,7 +70200,7 @@
-
+
@@ -70067,7 +70208,7 @@
-
+
@@ -76413,7 +76554,7 @@
-
+
@@ -76421,7 +76562,7 @@
-
+
@@ -76429,7 +76570,7 @@
-
+
@@ -76513,7 +76654,7 @@
-
+
@@ -76566,7 +76707,7 @@
-
+
@@ -77405,7 +77546,7 @@
-
+
@@ -78205,7 +78346,7 @@
-
+
@@ -78252,7 +78393,7 @@
-
+
@@ -78300,10 +78441,10 @@
-
+
-
+
@@ -79430,7 +79571,7 @@
-
+
@@ -79451,7 +79592,7 @@
-
+
@@ -80310,7 +80451,7 @@
-
+
@@ -81102,7 +81243,7 @@
-
+
@@ -81111,7 +81252,7 @@
-
+
@@ -81127,7 +81268,7 @@
-
+
@@ -81165,7 +81306,7 @@
-
+
@@ -81213,7 +81354,7 @@
-
+
@@ -81221,7 +81362,7 @@
-
+
@@ -81473,12 +81614,20 @@
+
+
+
+
+
+
+
+
@@ -81531,7 +81680,7 @@
-
+
@@ -81656,7 +81805,7 @@
-
+
@@ -81804,7 +81953,7 @@
-
+
@@ -81911,7 +82060,7 @@
-
+
@@ -82493,7 +82642,7 @@
-
+
@@ -82530,6 +82679,15 @@
+
+
+
+
+
+
+
+
+
@@ -83531,7 +83689,7 @@
-
+
@@ -83595,7 +83753,7 @@
-
+
@@ -85016,7 +85174,7 @@
-
+
@@ -85227,7 +85385,7 @@
-
+
@@ -85350,7 +85508,7 @@
-
+
@@ -85395,7 +85553,7 @@
-
+
@@ -86333,7 +86491,7 @@
-
+
@@ -86342,7 +86500,7 @@
-
+
@@ -86441,10 +86599,10 @@
-
+
-
+
@@ -86489,7 +86647,7 @@
-
+
@@ -86843,7 +87001,7 @@
-
+
@@ -86857,7 +87015,7 @@
-
+
@@ -86982,7 +87140,7 @@
-
+
@@ -87100,14 +87258,6 @@
-
-
-
-
-
-
-
-
@@ -87118,12 +87268,12 @@
-
+
-
+
-
+
@@ -87140,7 +87290,7 @@
-
+
@@ -87170,7 +87320,7 @@
-
+
@@ -87242,102 +87392,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -87355,25 +87409,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -87618,7 +87653,7 @@
-
+
@@ -87634,7 +87669,7 @@
-
+
@@ -88027,7 +88062,7 @@
-
+
@@ -89248,7 +89283,7 @@
-
+
@@ -89290,7 +89325,7 @@
-
+
@@ -89592,7 +89627,7 @@
-
+
@@ -89931,7 +89966,15 @@
-
+
+
+
+
+
+
+
+
+
@@ -90287,7 +90330,7 @@
-
+
@@ -91937,10 +91980,10 @@
-
+
-
+
@@ -94982,7 +95025,7 @@
-
+
@@ -94998,7 +95041,7 @@
-
+
@@ -95042,7 +95085,7 @@
-
+
@@ -95061,10 +95104,10 @@
-
+
-
+
@@ -95096,7 +95139,7 @@
-
+
@@ -95104,7 +95147,7 @@
-
+
@@ -95120,7 +95163,7 @@
-
+
@@ -95155,7 +95198,7 @@
-
+
@@ -95171,7 +95214,7 @@
-
+
@@ -95179,7 +95222,7 @@
-
+
@@ -95845,10 +95888,10 @@
-
+
-
+
@@ -96370,7 +96413,7 @@
-
+
@@ -96494,7 +96537,7 @@
-
+
@@ -96510,7 +96553,7 @@
-
+
@@ -96556,15 +96599,7 @@
-
-
-
-
-
-
-
-
-
+
@@ -96572,7 +96607,7 @@
-
+
@@ -96586,7 +96621,7 @@
-
+
@@ -96597,7 +96632,7 @@
-
+
@@ -96605,7 +96640,7 @@
-
+
@@ -96616,7 +96651,7 @@
-
+
@@ -96627,6 +96662,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -97009,7 +97069,7 @@
-
+
@@ -97102,10 +97162,10 @@
-
+
-
+
@@ -97348,7 +97408,7 @@
-
+
@@ -97408,7 +97468,7 @@
-
+
@@ -97442,10 +97502,10 @@
-
+
-
+
@@ -97467,7 +97527,7 @@
-
+
@@ -97475,7 +97535,7 @@
-
+
@@ -97498,7 +97558,7 @@
-
+
@@ -97576,13 +97636,13 @@
-
+
-
+
@@ -97883,7 +97943,7 @@
-
+
@@ -98057,7 +98117,7 @@
-
+
@@ -98936,10 +98996,10 @@
-
+
-
+
@@ -101125,7 +101185,7 @@
-
+
@@ -101827,7 +101887,7 @@
-
+
diff --git a/android/abi_gki_aarch64_qcom b/android/abi_gki_aarch64_qcom
index bad1ab0e89a3..93117099aa7c 100644
--- a/android/abi_gki_aarch64_qcom
+++ b/android/abi_gki_aarch64_qcom
@@ -1098,6 +1098,7 @@
init_net
__init_rwsem
init_special_inode
+ init_srcu_struct
init_timer_key
init_uts_ns
init_wait_entry
@@ -2275,6 +2276,8 @@
srcu_notifier_call_chain
srcu_notifier_chain_register
srcu_notifier_chain_unregister
+ __srcu_read_lock
+ __srcu_read_unlock
sscanf
__stack_chk_fail
__stack_chk_guard
@@ -2317,6 +2320,7 @@
synchronize_irq
synchronize_net
synchronize_rcu
+ synchronize_srcu
syscon_node_to_regmap
syscon_regmap_lookup_by_phandle
sysfs_create_bin_file
diff --git a/drivers/soc/qcom/ramdump.c b/drivers/soc/qcom/ramdump.c
index 1fea5a6ff634..33c05ce005e0 100644
--- a/drivers/soc/qcom/ramdump.c
+++ b/drivers/soc/qcom/ramdump.c
@@ -17,6 +17,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -59,6 +60,8 @@ struct ramdump_device {
size_t elfcore_size;
char *elfcore_buf;
bool complete_ramdump;
+ bool abort_ramdump;
+ struct srcu_struct rd_srcu;
};
static int ramdump_open(struct inode *inode, struct file *filep)
@@ -158,15 +161,26 @@ static ssize_t ramdump_read(struct file *filep, char __user *buf, size_t count,
size_t copy_size = 0, alignsize;
unsigned char *alignbuf = NULL, *finalbuf = NULL;
int ret = 0;
+ int srcu_idx;
loff_t orig_pos = *pos;
if ((filep->f_flags & O_NONBLOCK) && !entry->data_ready)
return -EAGAIN;
- ret = wait_event_interruptible(rd_dev->dump_wait_q, entry->data_ready);
+ ret = wait_event_interruptible(rd_dev->dump_wait_q,
+ (entry->data_ready || rd_dev->abort_ramdump));
if (ret)
return ret;
+ srcu_idx = srcu_read_lock(&rd_dev->rd_srcu);
+
+ if (rd_dev->abort_ramdump) {
+ pr_err("Ramdump(%s): Ramdump aborted\n", rd_dev->name);
+ rd_dev->ramdump_status = -1;
+ ret = -ETIME;
+ goto ramdump_done;
+ }
+
if (*pos < rd_dev->elfcore_size) {
copy_size = rd_dev->elfcore_size - *pos;
copy_size = min(copy_size, count);
@@ -178,8 +192,10 @@ static ssize_t ramdump_read(struct file *filep, char __user *buf, size_t count,
*pos += copy_size;
count -= copy_size;
buf += copy_size;
- if (count == 0)
+ if (count == 0) {
+ srcu_read_unlock(&rd_dev->rd_srcu, srcu_idx);
return copy_size;
+ }
}
addr = offset_translate(*pos - rd_dev->elfcore_size, rd_dev,
@@ -252,9 +268,12 @@ static ssize_t ramdump_read(struct file *filep, char __user *buf, size_t count,
pr_debug("Ramdump(%s): Read %zd bytes from address %lx.\n",
rd_dev->name, copy_size, addr);
+ srcu_read_unlock(&rd_dev->rd_srcu, srcu_idx);
+
return *pos - orig_pos;
ramdump_done:
+ srcu_read_unlock(&rd_dev->rd_srcu, srcu_idx);
kfree(finalbuf);
*pos = 0;
reset_ramdump_entry(entry);
@@ -361,6 +380,7 @@ void *create_ramdump_device(const char *dev_name, struct device *parent)
mutex_init(&rd_dev->consumer_lock);
atomic_set(&rd_dev->readers_left, 0);
+ init_srcu_struct(&rd_dev->rd_srcu);
cdev_init(&rd_dev->cdev, &ramdump_file_ops);
ret = cdev_add(&rd_dev->cdev, MKDEV(MAJOR(ramdump_dev), minor), 1);
@@ -373,6 +393,7 @@ void *create_ramdump_device(const char *dev_name, struct device *parent)
return (void *)rd_dev;
fail_cdev_add:
+ cleanup_srcu_struct(&rd_dev->rd_srcu);
mutex_destroy(&rd_dev->consumer_lock);
device_unregister(rd_dev->dev);
fail_return_minor:
@@ -393,6 +414,7 @@ void destroy_ramdump_device(void *dev)
cdev_del(&rd_dev->cdev);
device_unregister(rd_dev->dev);
+ cleanup_srcu_struct(&rd_dev->rd_srcu);
ida_simple_remove(&rd_minor_id, minor);
kfree(rd_dev);
}
@@ -473,6 +495,7 @@ static int _do_ramdump(void *handle, struct ramdump_segment *segments,
list_for_each_entry(entry, &rd_dev->consumer_list, list)
entry->data_ready = true;
rd_dev->ramdump_status = -1;
+ rd_dev->abort_ramdump = false;
reinit_completion(&rd_dev->ramdump_complete);
atomic_set(&rd_dev->readers_left, rd_dev->consumers);
@@ -489,6 +512,11 @@ static int _do_ramdump(void *handle, struct ramdump_segment *segments,
pr_err("Ramdump(%s): Timed out waiting for userspace.\n",
rd_dev->name);
ret = -EPIPE;
+ rd_dev->abort_ramdump = true;
+
+ /* Wait for pending readers to complete (if any) */
+ synchronize_srcu(&rd_dev->rd_srcu);
+
} else
ret = (rd_dev->ramdump_status == 0) ? 0 : -EPIPE;
@@ -602,6 +630,7 @@ static int _do_minidump(void *handle, struct ramdump_segment *segments,
list_for_each_entry(entry, &rd_dev->consumer_list, list)
entry->data_ready = true;
rd_dev->ramdump_status = -1;
+ rd_dev->abort_ramdump = false;
reinit_completion(&rd_dev->ramdump_complete);
atomic_set(&rd_dev->readers_left, rd_dev->consumers);
@@ -618,6 +647,10 @@ static int _do_minidump(void *handle, struct ramdump_segment *segments,
pr_err("Ramdump(%s): Timed out waiting for userspace.\n",
rd_dev->name);
ret = -EPIPE;
+ rd_dev->abort_ramdump = true;
+
+ /* Wait for pending readers to complete (if any) */
+ synchronize_srcu(&rd_dev->rd_srcu);
} else {
ret = (rd_dev->ramdump_status == 0) ? 0 : -EPIPE;
}