Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8465333ybl; Thu, 16 Jan 2020 17:23:49 -0800 (PST) X-Google-Smtp-Source: APXvYqzgLdCemse1Ft3D9kAN7Ev7rizWUt5y2Vg8gbNJCpcgJ6YYm7wMZwaTMys82A4NI0/w4IZB X-Received: by 2002:a05:6808:907:: with SMTP id w7mr1679619oih.91.1579224229119; Thu, 16 Jan 2020 17:23:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579224229; cv=none; d=google.com; s=arc-20160816; b=Ht+W28lvpmrsaMkXuOGOm+qoC7dE+WGIqbIcQiUerFmu4Vih9ZlVn0WDUyAJfy68yz IHnEJahzT+RQ/vGnb2gudDFmThqbWJLavwUYBTgpXmol6fQ5xeiIRgVnx37UfrSEKm0b FYucOMATRgqq2isM4HUMjh0MRsBmHdo5vAmLvzzoetV7pHTZgQf/9JNsaykBWNgGquQO iQWOgsgDbOu7px1N95dHDcasbbKeSoNsAixhlME0rSZGOIZCdIpP3TwL2WGec6Br/SuY 9pQd90GVWoaKinhDTQizH4bQo9s7XqepM2IYWdCzDef3pB5CNlyIazkIRQErvtDrDJz3 vSBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uAGyXhtqVK7C0J79VbhZFBdGLXx4D6dMNu+JFoUdwdc=; b=N6cSRJtCuUQ8BmR6sUXkBrM1j6Vj3VPPAU3axqCoCqezdfZOVkip7wTQddtdA/1oqK YnqueQ42I6mWic5zApJp9dDP73iRHzhvep1NHlCutDTk7pj1uH1S8+2VtJYD/M/rKETb AEHIOOsCOL6iJLTYGn6FI1+1Y4CdKiTPSqoMyHMQ/VsYthn4OAi+Zdzm67zT/qRXl8QC FvZkiwi6ZmK9BepktUp7bfCsTTZ9aonBTb9+FNPl5KHGJ4C4tdx5pTyDzd5GMfRmBmJd BLPxem7Reo4Twud9COCK0UVTawddAuHIucD2aElHxP3E5HZZpW59hw5Qek4rFafLxBql hRMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PbJ9JiAy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z12si15801178otm.189.2020.01.16.17.23.36; Thu, 16 Jan 2020 17:23:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PbJ9JiAy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388587AbgAPXZW (ORCPT + 99 others); Thu, 16 Jan 2020 18:25:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:54806 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733020AbgAPXZQ (ORCPT ); Thu, 16 Jan 2020 18:25:16 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DE5BC2072B; Thu, 16 Jan 2020 23:25:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579217115; bh=nihXBOFluQniosqvBT9Ave0NS8Z6fso164nYyKINBoM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PbJ9JiAyFx6K0kBqel2Q/n5vFMhD0lil5PijPU4boqif99pLLn6sDZicfmWreSyMy ISrLoRGfFsKv689kvH9NbaYgvzsWLr3pupgRjgv7wwtq6UHyYXntBfeA09/bwTei8s ojjRMhYCJjLbhzg1qTct6+bVA6jFWqpjzb0r0UKw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Philipp Zabel , Hans Verkuil , Mauro Carvalho Chehab Subject: [PATCH 5.4 154/203] media: coda: fix deadlock between decoder picture run and start command Date: Fri, 17 Jan 2020 00:17:51 +0100 Message-Id: <20200116231758.296412614@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200116231745.218684830@linuxfoundation.org> References: <20200116231745.218684830@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Philipp Zabel commit a3fd80198de6ab98a205cf7fb148d88e9e1c44bb upstream. The BIT decoder picture run temporarily locks the bitstream mutex while the coda device mutex is locked, to refill the bitstream ring buffer. Consequently, the decoder start command, which locks both mutexes when flushing the bitstream ring buffer, must lock the coda device mutex first as well, to avoid an ABBA deadlock. Fixes: e7fd95849b3c ("media: coda: flush bitstream ring buffer on decoder restart") Signed-off-by: Philipp Zabel Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/platform/coda/coda-common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/media/platform/coda/coda-common.c +++ b/drivers/media/platform/coda/coda-common.c @@ -1084,16 +1084,16 @@ static int coda_decoder_cmd(struct file switch (dc->cmd) { case V4L2_DEC_CMD_START: - mutex_lock(&ctx->bitstream_mutex); mutex_lock(&dev->coda_mutex); + mutex_lock(&ctx->bitstream_mutex); coda_bitstream_flush(ctx); - mutex_unlock(&dev->coda_mutex); dst_vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); vb2_clear_last_buffer_dequeued(dst_vq); ctx->bit_stream_param &= ~CODA_BIT_STREAM_END_FLAG; coda_fill_bitstream(ctx, NULL); mutex_unlock(&ctx->bitstream_mutex); + mutex_unlock(&dev->coda_mutex); break; case V4L2_DEC_CMD_STOP: stream_end = false;