Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp914082pxb; Wed, 1 Sep 2021 12:34:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzK3Xann7X5ot3WjeVOMzx64riC6RhtFhWjk2suPUHd/Nlho0o7ASHX4pUthjYPlQZkA7V1 X-Received: by 2002:a05:6402:2810:: with SMTP id h16mr1205192ede.133.1630524840892; Wed, 01 Sep 2021 12:34:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630524840; cv=none; d=google.com; s=arc-20160816; b=RjnYjeV+1eUmVjoC4Yyq+pDklCgXdxkXtU3/B4V+ybhQUt2XpzQnKDZk0oxI9ijJmw tGpnUHbEwDW8GKEvAv7xfBYMv+UaghUJdWjY6fHvq9+oKYrbby/uAwoYHchofgQFcKiB WTXa2DI39rtcPtCJ/zB5H/A73Hz4x6RJnbjc/1kKvtZqUSmS/DSwRt0+sKs0b/QOgEDi de7WhjNSdJV/UnEuF7pmjV0fuhSkdhi+M87XrVpZNzbshMxVKd0T/IjcfXenl9JhnPpG aAPa0gGnWbSOCk7wq34gvnpryXcmdQ1VAeYgWbF0mcmxt12X93QoQoeq5aNMBy4TjCCy xG+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9P0cXH/o2VhTYwylV3NvlY6qBue8714EM+L2aLF5Ji0=; b=BWqUPslIHJ4MVxZE6ZekaPuTwK8hLHbTJ1y3rsNi8PZx1kiULvfpTQ43I3delwrivE 9A0s66RMRIXUYfIHzczmuKPv0hyPvQRYSgqenpj8HJhf3CBD36ayAquayVIBpM5K7mqk 09Ym4q/r0rmU2QJaTxv8amaOLOSPMktGZ6Lmn8r6j9xZ1n8B3ue8NmOviPx5azVBrkyN cg5fn1vId5NOhFAA0xHhElALbns6L2hJdKEMjaYHnJ/5VYv1D7KGOz46RoRdeZG8pfOm hg9gJyP18rBQQFy81SBPXgrGcPbHQVzl5DIFvi5Ws6Z2bVrJfUImy+JgIri+LUMAyDP6 nxPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sFT9LmNk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m16si651026ejl.46.2021.09.01.12.33.32; Wed, 01 Sep 2021 12:34:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sFT9LmNk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343979AbhIAMez (ORCPT + 99 others); Wed, 1 Sep 2021 08:34:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:34562 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245727AbhIAMdJ (ORCPT ); Wed, 1 Sep 2021 08:33:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 16C45610CD; Wed, 1 Sep 2021 12:31:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1630499506; bh=cdOMxh1VKn1TKa6Yw1CN9wwj9xJTUmBkWeHxrRVZDVA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sFT9LmNkBx7KpiLJALMgX+sLUdKei/WQcivKgoi8QE9p4z8qIpa2ya7x7K53bpjJ/ PYWGbepzotuZdgs1mB5QW0IdQFAUVliOH+A6BQFLnqDxDeHqP41jVTmNOW2Hhbm0ju L7JiFUjUlMoxwDP0tie2r5rb3Hc5SlaYaR1fuGqo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Matthew Brost , John Harrison , Rodrigo Vivi , Sasha Levin Subject: [PATCH 5.4 25/48] drm/i915: Fix syncmap memory leak Date: Wed, 1 Sep 2021 14:28:15 +0200 Message-Id: <20210901122254.243898891@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210901122253.388326997@linuxfoundation.org> References: <20210901122253.388326997@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthew Brost [ Upstream commit a63bcf08f0efb5348105bb8e0e1e8c6671077753 ] A small race exists between intel_gt_retire_requests_timeout and intel_timeline_exit which could result in the syncmap not getting free'd. Rather than work to hard to seal this race, simply cleanup the syncmap on fini. unreferenced object 0xffff88813bc53b18 (size 96): comm "gem_close_race", pid 5410, jiffies 4294917818 (age 1105.600s) hex dump (first 32 bytes): 01 00 00 00 00 00 00 00 00 00 00 00 0a 00 00 00 ................ 00 00 00 00 00 00 00 00 6b 6b 6b 6b 06 00 00 00 ........kkkk.... backtrace: [<00000000120b863a>] __sync_alloc_leaf+0x1e/0x40 [i915] [<00000000042f6959>] __sync_set+0x1bb/0x240 [i915] [<0000000090f0e90f>] i915_request_await_dma_fence+0x1c7/0x400 [i915] [<0000000056a48219>] i915_request_await_object+0x222/0x360 [i915] [<00000000aaac4ee3>] i915_gem_do_execbuffer+0x1bd0/0x2250 [i915] [<000000003c9d830f>] i915_gem_execbuffer2_ioctl+0x405/0xce0 [i915] [<00000000fd7a8e68>] drm_ioctl_kernel+0xb0/0xf0 [drm] [<00000000e721ee87>] drm_ioctl+0x305/0x3c0 [drm] [<000000008b0d8986>] __x64_sys_ioctl+0x71/0xb0 [<0000000076c362a4>] do_syscall_64+0x33/0x80 [<00000000eb7a4831>] entry_SYSCALL_64_after_hwframe+0x44/0xa9 Signed-off-by: Matthew Brost Fixes: 531958f6f357 ("drm/i915/gt: Track timeline activeness in enter/exit") Cc: Reviewed-by: John Harrison Signed-off-by: John Harrison Link: https://patchwork.freedesktop.org/patch/msgid/20210730195342.110234-1-matthew.brost@intel.com (cherry picked from commit faf890985e30d5e88cc3a7c50c1bcad32f89ab7c) Signed-off-by: Rodrigo Vivi Signed-off-by: Sasha Levin --- drivers/gpu/drm/i915/gt/intel_timeline.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/i915/gt/intel_timeline.c b/drivers/gpu/drm/i915/gt/intel_timeline.c index 9cb01d9828f1..c970e3deb008 100644 --- a/drivers/gpu/drm/i915/gt/intel_timeline.c +++ b/drivers/gpu/drm/i915/gt/intel_timeline.c @@ -289,6 +289,14 @@ void intel_timeline_fini(struct intel_timeline *timeline) i915_gem_object_unpin_map(timeline->hwsp_ggtt->obj); i915_vma_put(timeline->hwsp_ggtt); + + /* + * A small race exists between intel_gt_retire_requests_timeout and + * intel_timeline_exit which could result in the syncmap not getting + * free'd. Rather than work to hard to seal this race, simply cleanup + * the syncmap on fini. + */ + i915_syncmap_free(&timeline->sync); } struct intel_timeline * -- 2.30.2