Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp842638ybi; Fri, 12 Jul 2019 05:33:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqzV/L8myMO3yOS24OD9qLPZ80XmiEzlI8+/o8jp1XEQRTOS9QxNseSz/wG/t2POPBBurfau X-Received: by 2002:a17:902:d917:: with SMTP id c23mr11229207plz.248.1562934833263; Fri, 12 Jul 2019 05:33:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562934833; cv=none; d=google.com; s=arc-20160816; b=Baia0pr08/bpNA+RvUfRDTPelbU7wc8pDXWj9wBs6B857Z+8TpXnqCRm3HvteohWN+ SYhNL8+P+ot3+XUWGpgx+32Pq/cb9lpb28WDu6z7mBopskGPCOoJRXQS/wPmq5UQfbk5 xZxrTFSrvK7U8w2Ir/gwOeJbIXfCLcWiP98Y8vehhbx0FKna6V1vVczxarXsNAN3uj+K zXlrvzWFKjFauaFKannjkxekuA7/u1MNrYWL7rqh59PYIQLuxKlxAuBxjvcFJDo0DoU6 6vP6wS+Av7GLh3FVrImdmYvWnL/vprpQSzhPOdpi4paf8WDsheJ1iMI//H2RebhDTe3w UceA== 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=kn3i7uHu3sibIp8cDuTF9DN5tM2ejJoyhnZc59NVAKc=; b=SJw+ePB8c7EOJSxyuK5+dOg3oSKSpvTtisiyw2UH2JoB4StRzkWQQNx76Koiji9GpH TgUf08F31/+v8Sl3+U0/P7ujSFjGUi6uU7YZk3pnvWTlTqLTnRO3bWeygMcxi4W/URFx HNZ0W00uM6NPNonm1bRyTF1pabeCQ1J0rHRuctpTyLbumBqvj2Lea1OlGbQ0d4WlGSy/ zMQz1seIv8ZGDwwII6ZSDISFtr5xcFwDzKP/CewU7U58eEH3RndleDaGgK0DPLEWzFI6 rWmmi2wZkvEOR/7BNJV7swpKP9I/ddaRDksqG82Yj3ij3QSZO6OU8w/R7B0PE0DNQ/Q+ 2EAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iUboyDUU; 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 d22si7881790plr.120.2019.07.12.05.33.37; Fri, 12 Jul 2019 05:33:53 -0700 (PDT) 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=iUboyDUU; 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 S1729125AbfGLMbT (ORCPT + 99 others); Fri, 12 Jul 2019 08:31:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:47844 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729105AbfGLMbR (ORCPT ); Fri, 12 Jul 2019 08:31:17 -0400 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 6398D208E4; Fri, 12 Jul 2019 12:31:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562934676; bh=kHmhzJ+BlbwwuCrF47YLjZgNe7oXTK2407h6My7ZG7c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iUboyDUUZ6I0JhejthnMy0qlBKFdY4sFLbUo1elxTOltRpPKPkSHGPfcW8hO3Fy98 MiopKC4ogpCkcuLp5sPiPrIaZMwvB7DIHRSESLG26JdlXvUTOMcO9/LZaS8gBQhudh 7dx40wTBJjVsTsHOICeQG39oUI7+2LP7zyj++LzQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dave Stevenson , Stefan Wahren , Hans Verkuil , Mauro Carvalho Chehab Subject: [PATCH 5.1 134/138] staging: bcm2835-camera: Replace spinlock protecting context_map with mutex Date: Fri, 12 Jul 2019 14:19:58 +0200 Message-Id: <20190712121633.856051273@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190712121628.731888964@linuxfoundation.org> References: <20190712121628.731888964@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: Dave Stevenson commit 8dedab2903f152aa3cee9ae3d57c828dea0d356e upstream. The commit "staging: bcm2835-camera: Replace open-coded idr with a struct idr." replaced an internal implementation of an idr with the standard functions and a spinlock. idr_alloc(GFP_KERNEL) can sleep whilst calling kmem_cache_alloc to allocate the new node, but this is not valid whilst in an atomic context due to the spinlock. There is no need for this to be a spinlock as a standard mutex is sufficient. Fixes: 950fd867c635 ("staging: bcm2835-camera: Replace open-coded idr with a struct idr.") Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c @@ -161,7 +161,8 @@ struct vchiq_mmal_instance { void *bulk_scratch; struct idr context_map; - spinlock_t context_map_lock; + /* protect accesses to context_map */ + struct mutex context_map_lock; /* component to use next */ int component_idx; @@ -184,10 +185,10 @@ get_msg_context(struct vchiq_mmal_instan * that when we service the VCHI reply, we can look up what * message is being replied to. */ - spin_lock(&instance->context_map_lock); + mutex_lock(&instance->context_map_lock); handle = idr_alloc(&instance->context_map, msg_context, 0, 0, GFP_KERNEL); - spin_unlock(&instance->context_map_lock); + mutex_unlock(&instance->context_map_lock); if (handle < 0) { kfree(msg_context); @@ -211,9 +212,9 @@ release_msg_context(struct mmal_msg_cont { struct vchiq_mmal_instance *instance = msg_context->instance; - spin_lock(&instance->context_map_lock); + mutex_lock(&instance->context_map_lock); idr_remove(&instance->context_map, msg_context->handle); - spin_unlock(&instance->context_map_lock); + mutex_unlock(&instance->context_map_lock); kfree(msg_context); } @@ -1849,7 +1850,7 @@ int vchiq_mmal_init(struct vchiq_mmal_in instance->bulk_scratch = vmalloc(PAGE_SIZE); - spin_lock_init(&instance->context_map_lock); + mutex_init(&instance->context_map_lock); idr_init_base(&instance->context_map, 1); params.callback_param = instance;