Skip to content

Commit bc8b2cc

Browse files
Merge remote-tracking branch 'origin/android11-base' into android11-stable
* origin/android11-base: disp: msm: sde: handle partial update transitions in rounded corner platform: qpnp-revid: Add REVID support for PM8010 qcacmn: Possible OOB read in process_fw_diag_event_data regulator: qcom_pm8008-regulator: add support for PMIC PM8010 regulator: qcom_pm8008: allow multiple PM8008 instances with unique names qcacmn: Validate the buffer length in fips event handler block: pm: Fix possible unbalanced nr_pending qcacmn: Possible Integer overflow in wifi_pos_oem_rsp_handler qcacmn: Set default value of mawc_nlo_enabled ini as 0 power: supply: qpnp-smb5: specify different ICL for QC2 9V/12V level Release 5.2.022.9C qcacld-3.0: Fix buffer overflow in pe_filter_bcn_probe_frame() Release 5.2.022.9B phy: msm: usb: Check VBUS state before accessing registers in suspend phy: msm: usb: Fail suspend if psy_type is USB or USB_CDP USB: phy: msm: Apply DP pulse for CDP during bootup from sm_work msm: adsprpc: Allocate buffer taking NULL byte into consideration qcacmn: Fix OOB read issue in SSID ie qcacmn: Possible Integer overflow in wifi_pos_oem_rsp_handler qcacmn: Use local skb pointer for reentrant cld80211_msg_allocator disp: msm: sde: clear partial update mask during last close clk: qcom: debugcc: Remove the gcc_camss_camnoc clocks qcacld-3.0: Possible buffer overflow fw-api: CL 15605795 - update fw common interface files fw-api: CL 15591323 - update fw common interface files fw-api: CL 15591321 - update fw common interface files fw-api: CL 15569824 - update fw common interface files fbdev: msm: Avoid runtime sus/res for DP/HDMI uapi: Add UAPI headers for slatecom_interface driver soc: qcom: smsm: Add wakeup capable flags to SMSM IRQ Release 5.2.022.9A qcacld-3.0: Avoid buffer overflow in llstats debugfs response f2fs: don't sleep while grabing nat_tree_lock Ignore -106 error while opening channel Release 5.2.022.9 qcacld-3.0: Fix possible NULL pointer dereference qcacld-3.0: Add validation for wmi handle Release 5.2.022.8Z disp: msm: sde: handle partial update use case in rounded corner fw-api: CL 15484013 - update fw common interface files fw-api: CL 15484006 - update fw common interface files byte-cntr: Don't write csr register when byte-cntr is disabled arm64: defconfig: Set qrtr wakeup for lito qcacmn: Use local skb pointer for reentrant cld80211_msg_allocator net: qrtr: Make wakeup timeout configurable fw-api: CL 15458003 - update fw common interface files mhi: core: Avoid race condition mhi channel prepare and M0 event msm: ipa3: Fix to handle zero length frag skb packet qcacld-3.0: revert TDLS pkt statistics changes qcacmn: Possible Integer overflow in wifi_pos_oem_rsp_handler cnss_utils: Update the copyright years of file to 2017, 2019-2021 disp: msm: sde: clear partial update mask during last close FM: mutex changes modified Revert "qseecom: Add shmbrdige to allocate memory" qcacmn: Fix OOB read issue in SSID ie Revert "ANDROID: net: ipv4: sysfs_net_ipv4: Add sysfs-based knobs for controlling TCP window size" Revert "RFC: ANDROID: net: ipv4: sysfs_net_ipv4: Fix TCP window size controlling knobs" ANDROID: xt_qtaguid: fix UAF race coresight: byte-cntr: Add ETR status check in bypass notifier clk: qcom: debugcc: Remove the gcc_camss_camnoc clocks fw-api: CL 15406205 - update fw common interface files usb: f_fs: Avoid invalid pointer access in ffs_fs_get_tree serial: msm_geni_serial: Enable SW flow on in runtime suspend fw-api: CL 15389412 - update fw common interface files Release 5.2.022.8Y qcacld-3.0: Release sme global lock in the error condition defconfig: msm: Enable RPM SMD cooling device driver for KHAJE qcacmn: Fix possible OOB in wmi_extract_dbr_buf_release_entry defconfig: Enable CONFIG_ION_SYSTEM_HEAP for bengal f2fs: fix the periodic wakeups of discard thread fw-api: CL 15366529 - update fw common interface files fw-api: CL 15364598 - update fw common interface files fw-api: CL 15364591 - update fw common interface files f2fs: allow to change discard policy based on cached discard cmds qcacmn: Invoke hal_reg_write_need_delay before the register write qcacmn: Delay 50us when update same shadow reg coresight: byte-cnter: limit error log output coresight: byte-cnter: Add ETR status check in bypass notifier irqchip: mpm: Add mpm mapping for Khaje fw-api: CL 15351299 - update fw common interface files f2fs: change to use rwsem for cp_mutex cnss2: Assert on FW memory allocation failure Release 5.2.022.8X qcacld-3.0: Move call to hdd power stats callback inside lock qcacld-3.0: Set sme power stats response cb and context to NULL msm: kgsl: Keep the context alive until its fences signal fw-api: CL 15330284 - update fw common interface files soc: qcom: secure_buffer: Fix the parameter passing to dmac_flush_range Release 5.2.022.8W qcacld-3.0: Ignore RTPM suspend on pending IPA tx comps cnss_utils: Increase unsafe channel max num for 6G Release 5.2.022.8V qcacld-3.0: Don't recover wlm level if ftm mode qcacmn: Fix possible OOB in wmi_extract_dbr_buf_release_entry fw-api: CL 15275305 - update fw common interface files clk: qcom: gpucc: Update voltage fmax table for GPU clock for KHAJE msm: ipa3: Enable hardbyte limit for WAN consumer pipe Release 5.2.022.8U qcacld-3.0: Stop dsc transaction in case of reinit failure fw-api: CL 15265996 - update fw common interface files dma-mapping-fast: Fix sg-list length calculation in fast_smmu_unmap_sg() qseecom: Add shmbrdige to allocate memory msm: kgsl: Use worker to put refcount on mem entry fw-api: CL 15251368 - update fw common interface files fw-api: CL 15221536 - update fw common interface files fw-api: CL 15201884 - update fw common interface files usb: phy: qusb: Add wrapper function for phy reset usb: pd: Clear vdm_tx if SVDM message is sent on SOP' drivers: thermal: virtual-sensor: Add new virtual sensor for MSM8917 defconfig: Enable CONFIG_ION_SYSTEM_HEAP for bengal futex: Handle faults correctly for PI futexes futex: Simplify fixup_pi_state_owner() qcacmn: Fix gpio direction conversion wrong issue qcacmn: Add extra parameters to gpio command qcacmn: Add extra parameters to gpio attr qcacmn: Replace WMI_LOGD() with wmi_debug() qcacmn: change qcn9100 to qcn6122 in gpio qcacmn: Add support to config gpio cfg/output qcacmn: Add GPIO configuration OSIF code qcacmn: Add wmi interfaces for GPIO configuration qcacmn: Add and enable GPIO Component Release 5.2.022.8T qcacld-3.0: Add vendor command support for GPIO Configuration Release 5.2.022.8S qcacld-3.0: Reset rand mac addr filter after tx frame cancel driver: Fix compilation error with new sdclang 12 qcacmn: vendor interface for GPIO Configuration qcacmn: change qcn9100 to qcn6122 in hif and umac cmn: device ID and target type checks for ipq5018 target Release 5.2.022.8R defconfig: kona: Add CONFIG_AQFWD for RB5 board fw-api: CL 15144127 - update fw common interface files qcacmn: Add GPIO MODULE ID msm: adsprpc: Lock list before removing node qcacld-3.0: Update he and ht rate flags correctly clk: qcom: gpucc: Update the post div ops for GPUCC PLL for KHAJE clk: qcom: clk-alpha-pll: Update implementation for Zonda PLL rpmsg: glink: do not break from interrupt handler msm: kgsl: Use pid struct to find the process to reclaim mm: process_reclaim: pass pid struct instead of tgid msm: kgsl: Change vma->vm_file to shmem file mm: process_reclaim: skip target_vma net: qrtr: Excessive logging casuing boot failure Revert "msm: kgsl: Add GPUCC register dumps to A6xx GPU snapshot" qcacmn: Validate NDP app info length before accessing NDP app info qcacld-3.0: Send vdev create cmd from vdevmgr_mlme_ext_hdl_create qcacmn: Add length check in ndp event handler defconfig: msm: Enable CONFIG_STATIC_USERMODEHELPER for bengal_32 fdt: Update CRC check for rng-seed msm: vidc: update all intra to allow more than 30 fps defconfig: Enable blk-crypto-fallback to handle sw crypto request md: dm-default-key: Use system sector size for SDHCI devices msm: mink: Fix copy_to_user issue msm: ipa: update the iommu mapping for WDI rings fix corrupt merge msm: vdec: set hfi property when set by client serial: msm_geni_serial: Disable irq only for HSUART usecase msm_geni_serial: Correct the DMA RX interrupt logic Change-Id: I47b7612806e1966e9bd2ef8f8f67ae2cab9a3d0f Signed-off-by: UtsavBalar1231 <[email protected]> Conflicts: drivers/power/supply/qcom/smb5-lib.h drivers/regulator/qcom_pm8008-regulator.c
2 parents 4d5b632 + 5879c05 commit bc8b2cc

File tree

133 files changed

+5020
-587
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+5020
-587
lines changed

arch/arm64/configs/vendor/bengal-perf_defconfig

+2
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ CONFIG_QTI_BCL_SOC_DRIVER=y
395395
CONFIG_QTI_QMI_COOLING_DEVICE=y
396396
CONFIG_QTI_THERMAL_LIMITS_DCVS=y
397397
CONFIG_REGULATOR_COOLING_DEVICE=y
398+
CONFIG_QTI_RPM_SMD_COOLING_DEVICE=y
398399
CONFIG_QTI_CPU_ISOLATE_COOLING_DEVICE=y
399400
CONFIG_QTI_LMH_CPU_VDD_COOLING_DEVICE=y
400401
CONFIG_QTI_CX_IPEAK_COOLING_DEVICE=y
@@ -503,6 +504,7 @@ CONFIG_UIO_MSM_SHAREDMEM=y
503504
CONFIG_STAGING=y
504505
CONFIG_ASHMEM=y
505506
CONFIG_ION=y
507+
CONFIG_ION_SYSTEM_HEAP=y
506508
CONFIG_ION_POOL_AUTO_REFILL=y
507509
CONFIG_QPNP_REVID=y
508510
CONFIG_SPS=y

arch/arm64/configs/vendor/bengal_defconfig

+2
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ CONFIG_QTI_BCL_SOC_DRIVER=y
408408
CONFIG_QTI_QMI_COOLING_DEVICE=y
409409
CONFIG_QTI_THERMAL_LIMITS_DCVS=y
410410
CONFIG_REGULATOR_COOLING_DEVICE=y
411+
CONFIG_QTI_RPM_SMD_COOLING_DEVICE=y
411412
CONFIG_QTI_CPU_ISOLATE_COOLING_DEVICE=y
412413
CONFIG_QTI_LMH_CPU_VDD_COOLING_DEVICE=y
413414
CONFIG_QTI_CX_IPEAK_COOLING_DEVICE=y
@@ -523,6 +524,7 @@ CONFIG_UIO_MSM_SHAREDMEM=y
523524
CONFIG_STAGING=y
524525
CONFIG_ASHMEM=y
525526
CONFIG_ION=y
527+
CONFIG_ION_SYSTEM_HEAP=y
526528
CONFIG_ION_POOL_AUTO_REFILL=y
527529
CONFIG_QPNP_REVID=y
528530
CONFIG_SPS=y

arch/arm64/configs/vendor/kona-perf_defconfig

+1
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ CONFIG_BONDING=y
318318
CONFIG_DUMMY=y
319319
CONFIG_TUN=y
320320
CONFIG_VETH=y
321+
CONFIG_AQFWD=y
321322
CONFIG_SKY2=y
322323
CONFIG_RMNET=y
323324
CONFIG_SMSC911X=y

arch/arm64/configs/vendor/kona_defconfig

+1
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ CONFIG_BONDING=y
333333
CONFIG_DUMMY=y
334334
CONFIG_TUN=y
335335
CONFIG_VETH=y
336+
CONFIG_AQFWD=y
336337
CONFIG_RMNET=y
337338
CONFIG_PPP=y
338339
CONFIG_PPP_BSDCOMP=y

arch/arm64/configs/vendor/lito-perf_defconfig

+1
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ CONFIG_NET_ACT_MIRRED=y
259259
CONFIG_NET_ACT_SKBEDIT=y
260260
CONFIG_DNS_RESOLVER=y
261261
CONFIG_QRTR=y
262+
CONFIG_QRTR_WAKEUP_MS=500
262263
CONFIG_QRTR_SMD=y
263264
CONFIG_QRTR_MHI=y
264265
CONFIG_BPF_JIT=y

arch/arm64/configs/vendor/lito_defconfig

+1
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ CONFIG_NET_ACT_MIRRED=y
265265
CONFIG_NET_ACT_SKBEDIT=y
266266
CONFIG_DNS_RESOLVER=y
267267
CONFIG_QRTR=y
268+
CONFIG_QRTR_WAKEUP_MS=500
268269
CONFIG_QRTR_SMD=y
269270
CONFIG_QRTR_MHI=y
270271
CONFIG_BPF_JIT=y

block/blk-core.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -1778,8 +1778,12 @@ EXPORT_SYMBOL_GPL(part_round_stats);
17781778
#ifdef CONFIG_PM
17791779
static void blk_pm_put_request(struct request *rq)
17801780
{
1781-
if (rq->q->dev && !(rq->rq_flags & RQF_PM) && !--rq->q->nr_pending)
1782-
pm_runtime_mark_last_busy(rq->q->dev);
1781+
if (rq->q->dev && !(rq->rq_flags & RQF_PM) &&
1782+
(rq->rq_flags & RQF_PM_ADDED)) {
1783+
rq->rq_flags &= ~RQF_PM_ADDED;
1784+
if (!--rq->q->nr_pending)
1785+
pm_runtime_mark_last_busy(rq->q->dev);
1786+
}
17831787
}
17841788
#else
17851789
static inline void blk_pm_put_request(struct request *rq) {}

block/elevator.c

+11-4
Original file line numberDiff line numberDiff line change
@@ -560,15 +560,22 @@ void elv_bio_merged(struct request_queue *q, struct request *rq,
560560
#ifdef CONFIG_PM
561561
static void blk_pm_requeue_request(struct request *rq)
562562
{
563-
if (rq->q->dev && !(rq->rq_flags & RQF_PM))
563+
if (rq->q->dev && !(rq->rq_flags & RQF_PM) &&
564+
(rq->rq_flags & (RQF_PM_ADDED | RQF_FLUSH_SEQ))) {
565+
rq->rq_flags &= ~RQF_PM_ADDED;
564566
rq->q->nr_pending--;
567+
}
565568
}
566569

567570
static void blk_pm_add_request(struct request_queue *q, struct request *rq)
568571
{
569-
if (q->dev && !(rq->rq_flags & RQF_PM) && q->nr_pending++ == 0 &&
570-
(q->rpm_status == RPM_SUSPENDED || q->rpm_status == RPM_SUSPENDING))
571-
pm_request_resume(q->dev);
572+
if (q->dev && !(rq->rq_flags & RQF_PM)) {
573+
rq->rq_flags |= RQF_PM_ADDED;
574+
if (q->nr_pending++ == 0 &&
575+
(q->rpm_status == RPM_SUSPENDED ||
576+
q->rpm_status == RPM_SUSPENDING))
577+
pm_request_resume(q->dev);
578+
}
572579
}
573580
#else
574581
static inline void blk_pm_requeue_request(struct request *rq) {}

drivers/bluetooth/btfm_slim_codec.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22
/*
3-
* Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
3+
* Copyright (c) 2016-2020, The Linux Foundation. All rights reserved.
44
*/
55

66
#include <linux/init.h>
@@ -13,6 +13,7 @@
1313
#include <linux/slimbus/slimbus.h>
1414
#include <linux/ratelimit.h>
1515
#include <linux/slab.h>
16+
#include <linux/errno.h>
1617
#include <sound/pcm.h>
1718
#include <sound/pcm_params.h>
1819
#include <sound/soc.h>
@@ -209,6 +210,11 @@ static int btfm_slim_dai_prepare(struct snd_pcm_substream *substream,
209210
/* save the enable channel status */
210211
if (ret == 0)
211212
bt_soc_enable_status = 1;
213+
214+
if (ret == -EISCONN) {
215+
BTFMSLIM_ERR("channel opened without closing, return success");
216+
ret = 0;
217+
}
212218
return ret;
213219
}
214220

drivers/bus/mhi/core/mhi_init.c

+9
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,16 @@ void mhi_deinit_chan_ctxt(struct mhi_controller *mhi_cntrl,
10511051
vfree(buf_ring->base);
10521052

10531053
buf_ring->base = tre_ring->base = NULL;
1054+
tre_ring->ctxt_wp = NULL;
10541055
chan_ctxt->rbase = 0;
1056+
chan_ctxt->rlen = 0;
1057+
chan_ctxt->rp = chan_ctxt->wp = chan_ctxt->rbase;
1058+
tre_ring->rp = tre_ring->wp = tre_ring->base;
1059+
buf_ring->rp = buf_ring->wp = buf_ring->base;
1060+
1061+
/* Update to all cores */
1062+
smp_wmb();
1063+
10551064
}
10561065

10571066
int mhi_init_chan_ctxt(struct mhi_controller *mhi_cntrl,

drivers/bus/mhi/core/mhi_pm.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,8 @@ int mhi_pm_m0_transition(struct mhi_controller *mhi_cntrl)
395395

396396
read_lock_irq(&mhi_chan->lock);
397397
/* only ring DB if ring is not empty */
398-
if (tre_ring->base && tre_ring->wp != tre_ring->rp)
398+
if (tre_ring->base && tre_ring->wp != tre_ring->rp &&
399+
mhi_chan->ch_state == MHI_CH_STATE_ENABLED)
399400
mhi_ring_chan_db(mhi_cntrl, mhi_chan);
400401
read_unlock_irq(&mhi_chan->lock);
401402
}

drivers/char/adsprpc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2673,7 +2673,7 @@ static int fastrpc_init_process(struct fastrpc_file *fl,
26732673
if (!init->filelen)
26742674
goto bail;
26752675

2676-
proc_name = kzalloc(init->filelen, GFP_KERNEL);
2676+
proc_name = kzalloc(init->filelen + 1, GFP_KERNEL);
26772677
VERIFY(err, !IS_ERR_OR_NULL(proc_name));
26782678
if (err)
26792679
goto bail;

drivers/clk/qcom/debugcc-khaje.c

-4
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ static const char *const gcc_debug_mux_parent_names[] = {
124124
"gcc_cam_throttle_rt_clk",
125125
"gcc_camera_ahb_clk",
126126
"gcc_camss_axi_clk",
127-
"gcc_camss_camnoc_atb_clk",
128-
"gcc_camss_camnoc_nts_xo_clk",
129127
"gcc_camss_cci_0_clk",
130128
"gcc_camss_cphy_0_clk",
131129
"gcc_camss_cphy_1_clk",
@@ -236,8 +234,6 @@ static int gcc_debug_mux_sels[] = {
236234
0x4E, /* gcc_cam_throttle_rt_clk */
237235
0x3A, /* gcc_camera_ahb_clk */
238236
0x141, /* gcc_camss_axi_clk */
239-
0x143, /* gcc_camss_camnoc_atb_clk */
240-
0x144, /* gcc_camss_camnoc_nts_xo_clk */
241237
0x13F, /* gcc_camss_cci_0_clk */
242238
0x130, /* gcc_camss_cphy_0_clk */
243239
0x131, /* gcc_camss_cphy_1_clk */

drivers/clk/qcom/gpucc-khaje.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,11 @@ static struct clk_rcg2 gpu_cc_gx_gfx3d_clk_src = {
223223
.vdd_class = &vdd_cx,
224224
.num_rate_max = VDD_NUM,
225225
.rate_max = (unsigned long[VDD_NUM]) {
226-
[VDD_LOWER] = 320000000,
226+
[VDD_LOWER] = 320000097,
227227
[VDD_LOW] = 465000000,
228228
[VDD_LOW_L1] = 600000000,
229-
[VDD_NOMINAL] = 785000000,
230-
[VDD_HIGH] = 1025000000,
229+
[VDD_NOMINAL] = 785088000,
230+
[VDD_HIGH] = 1025088000,
231231
[VDD_HIGH_L1] = 1114800000},
232232
},
233233
};

drivers/gpu/msm/kgsl.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -698,8 +698,7 @@ void kgsl_context_detach(struct kgsl_context *context)
698698
/* Remove the event group from the list */
699699
kgsl_del_event_group(&context->events);
700700

701-
kgsl_sync_timeline_put(context->ktimeline);
702-
701+
kgsl_sync_timeline_detach(context->ktimeline);
703702
kgsl_context_put(context);
704703
}
705704

@@ -718,6 +717,8 @@ kgsl_context_destroy(struct kref *kref)
718717
*/
719718
BUG_ON(!kgsl_context_detached(context));
720719

720+
kgsl_sync_timeline_put(context->ktimeline);
721+
721722
write_lock(&device->context_lock);
722723
if (context->id != KGSL_CONTEXT_INVALID) {
723724

@@ -741,7 +742,6 @@ kgsl_context_destroy(struct kref *kref)
741742
context->id = KGSL_CONTEXT_INVALID;
742743
}
743744
write_unlock(&device->context_lock);
744-
kgsl_sync_timeline_destroy(context);
745745
kgsl_process_private_put(context->proc_priv);
746746

747747
device->ftbl->drawctxt_destroy(context);

drivers/gpu/msm/kgsl_sharedmem.c

+12-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,18 @@ imported_mem_show(struct kgsl_process_private *priv,
171171
}
172172
}
173173

174-
kgsl_mem_entry_put(entry);
174+
/*
175+
* If refcount on mem entry is the last refcount, we will
176+
* call kgsl_mem_entry_destroy and detach it from process
177+
* list. When there is no refcount on the process private,
178+
* we will call kgsl_destroy_process_private to do cleanup.
179+
* During cleanup, we will try to remove the same sysfs
180+
* node which is in use by the current thread and this
181+
* situation will end up in a deadloack.
182+
* To avoid this situation, use a worker to put the refcount
183+
* on mem entry.
184+
*/
185+
kgsl_mem_entry_put_deferred(entry);
175186
spin_lock(&priv->mem_lock);
176187
}
177188
spin_unlock(&priv->mem_lock);

drivers/gpu/msm/kgsl_sync.c

+43-23
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22
/*
3-
* Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
3+
* Copyright (c) 2012-2021, The Linux Foundation. All rights reserved.
44
*/
55

66
#include <linux/file.h>
@@ -249,27 +249,41 @@ static void kgsl_sync_timeline_value_str(struct dma_fence *fence,
249249
{
250250
struct kgsl_sync_fence *kfence = (struct kgsl_sync_fence *)fence;
251251
struct kgsl_sync_timeline *ktimeline = kfence->parent;
252+
struct kgsl_context *context = NULL;
253+
unsigned long flags;
254+
int ret = 0;
252255

253-
unsigned int timestamp_retired = 0;
254-
unsigned int timestamp_queued = 0;
256+
unsigned int timestamp_retired;
257+
unsigned int timestamp_queued;
255258

256259
if (!kref_get_unless_zero(&ktimeline->kref))
257260
return;
261+
if (!ktimeline->device)
262+
goto put_timeline;
258263

259-
/*
260-
* ktimeline->device might be NULL here but kgsl_readtimestamp()
261-
* will handle that correctly
262-
*/
263-
kgsl_readtimestamp(ktimeline->device, ktimeline->context,
264-
KGSL_TIMESTAMP_RETIRED, &timestamp_retired);
264+
spin_lock_irqsave(&ktimeline->lock, flags);
265+
ret = _kgsl_context_get(ktimeline->context);
266+
context = ret ? ktimeline->context : NULL;
267+
spin_unlock_irqrestore(&ktimeline->lock, flags);
268+
269+
/* Get the last signaled timestamp if the context is not valid */
270+
timestamp_queued = ktimeline->last_timestamp;
271+
timestamp_retired = timestamp_queued;
272+
if (context) {
273+
kgsl_readtimestamp(ktimeline->device, context,
274+
KGSL_TIMESTAMP_RETIRED, &timestamp_retired);
265275

266-
kgsl_readtimestamp(ktimeline->device, ktimeline->context,
267-
KGSL_TIMESTAMP_QUEUED, &timestamp_queued);
276+
kgsl_readtimestamp(ktimeline->device, context,
277+
KGSL_TIMESTAMP_QUEUED, &timestamp_queued);
278+
279+
kgsl_context_put(context);
280+
}
268281

269282
snprintf(str, size, "%u queued:%u retired:%u",
270283
ktimeline->last_timestamp,
271284
timestamp_queued, timestamp_retired);
272285

286+
put_timeline:
273287
kgsl_sync_timeline_put(ktimeline);
274288
}
275289

@@ -298,7 +312,7 @@ int kgsl_sync_timeline_create(struct kgsl_context *context)
298312
{
299313
struct kgsl_sync_timeline *ktimeline;
300314

301-
/* Put context when timeline is released */
315+
/* Put context at detach time */
302316
if (!_kgsl_context_get(context))
303317
return -ENOENT;
304318

@@ -319,6 +333,11 @@ int kgsl_sync_timeline_create(struct kgsl_context *context)
319333
INIT_LIST_HEAD(&ktimeline->child_list_head);
320334
spin_lock_init(&ktimeline->lock);
321335
ktimeline->device = context->device;
336+
337+
/*
338+
* The context pointer is valid till detach time, where we put the
339+
* refcount on the context
340+
*/
322341
ktimeline->context = context;
323342

324343
context->ktimeline = ktimeline;
@@ -351,30 +370,31 @@ static void kgsl_sync_timeline_signal(struct kgsl_sync_timeline *ktimeline,
351370
kgsl_sync_timeline_put(ktimeline);
352371
}
353372

354-
void kgsl_sync_timeline_destroy(struct kgsl_context *context)
373+
void kgsl_sync_timeline_detach(struct kgsl_sync_timeline *ktimeline)
355374
{
356-
struct kgsl_sync_timeline *ktimeline = context->ktimeline;
375+
unsigned long flags;
376+
struct kgsl_context *context = ktimeline->context;
357377

358-
kfree(ktimeline->name);
359-
kfree(ktimeline);
378+
/* Set context pointer to NULL and drop our refcount on the context */
379+
spin_lock_irqsave(&ktimeline->lock, flags);
380+
ktimeline->context = NULL;
381+
spin_unlock_irqrestore(&ktimeline->lock, flags);
382+
kgsl_context_put(context);
360383
}
361384

362-
static void kgsl_sync_timeline_release(struct kref *kref)
385+
static void kgsl_sync_timeline_destroy(struct kref *kref)
363386
{
364387
struct kgsl_sync_timeline *ktimeline =
365388
container_of(kref, struct kgsl_sync_timeline, kref);
366389

367-
/*
368-
* Only put the context refcount here. The context destroy function
369-
* will call kgsl_sync_timeline_destroy() to kfree it
370-
*/
371-
kgsl_context_put(ktimeline->context);
390+
kfree(ktimeline->name);
391+
kfree(ktimeline);
372392
}
373393

374394
void kgsl_sync_timeline_put(struct kgsl_sync_timeline *ktimeline)
375395
{
376396
if (ktimeline)
377-
kref_put(&ktimeline->kref, kgsl_sync_timeline_release);
397+
kref_put(&ktimeline->kref, kgsl_sync_timeline_destroy);
378398
}
379399

380400
static const struct dma_fence_ops kgsl_sync_fence_ops = {

0 commit comments

Comments
 (0)