From patchwork Mon Mar 2 04:38:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 5910181 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D6CBDBF6C3 for ; Mon, 2 Mar 2015 04:47:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0E25420173 for ; Mon, 2 Mar 2015 04:47:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 30A3F20212 for ; Mon, 2 Mar 2015 04:47:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753658AbbCBEqz (ORCPT ); Sun, 1 Mar 2015 23:46:55 -0500 Received: from ring0.de ([5.45.105.125]:40041 "EHLO ring0.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753481AbbCBEqu (ORCPT ); Sun, 1 Mar 2015 23:46:50 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 From: Sebastian Reichel To: Sebastian Reichel Cc: Peter Ujfalusi , Kai Vehmanen , Pavel Machek , Pali Rohar , Aaro Koskinen , Ivaylo Dimitrov , linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Kai Vehmanen , Joni Lapilainen Subject: [PATCH 2/9] HSI: cmt_speech: Avoid GFP_ATOMIC in cs_char_open Date: Mon, 2 Mar 2015 05:38:52 +0100 Message-Id: <1425271139-24715-3-git-send-email-sre@kernel.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1425271139-24715-1-git-send-email-sre@kernel.org> References: <1425271139-24715-1-git-send-email-sre@kernel.org> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kai Vehmanen Also fixes a bug in updating 'opened' state in case cs_hsi_start() fails when opening the char device. Signed-off-by: Kai Vehmanen Signed-off-by: Joni Lapilainen Signed-off-by: Sebastian Reichel --- drivers/hsi/clients/cmt_speech.c | 43 +++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/drivers/hsi/clients/cmt_speech.c b/drivers/hsi/clients/cmt_speech.c index 7c0f711..389eafb 100644 --- a/drivers/hsi/clients/cmt_speech.c +++ b/drivers/hsi/clients/cmt_speech.c @@ -1271,38 +1271,45 @@ static int cs_char_mmap(struct file *file, struct vm_area_struct *vma) static int cs_char_open(struct inode *unused, struct file *file) { int ret = 0; + unsigned long p; spin_lock_bh(&cs_char_data.lock); if (cs_char_data.opened) { ret = -EBUSY; spin_unlock_bh(&cs_char_data.lock); - goto out; - } - cs_char_data.mmap_base = get_zeroed_page(GFP_ATOMIC); - if (!cs_char_data.mmap_base) { - dev_err(&cs_char_data.cl->device, - "Shared memory allocation failed.\n"); - ret = -ENOMEM; - spin_unlock_bh(&cs_char_data.lock); - goto out; + goto out1; } - cs_char_data.mmap_size = CS_MMAP_SIZE; - cs_char_data.dataind_pending = 0; cs_char_data.opened = 1; - file->private_data = &cs_char_data; + cs_char_data.dataind_pending = 0; spin_unlock_bh(&cs_char_data.lock); - BUG_ON(cs_char_data.hi); + p = get_zeroed_page(GFP_KERNEL); + if (!p) { + ret = -ENOMEM; + goto out2; + } - ret = cs_hsi_start(&cs_char_data.hi, cs_char_data.cl, - cs_char_data.mmap_base, cs_char_data.mmap_size); + ret = cs_hsi_start(&cs_char_data.hi, cs_char_data.cl, p, CS_MMAP_SIZE); if (ret) { dev_err(&cs_char_data.cl->device, "Unable to initialize HSI\n"); - free_page(cs_char_data.mmap_base); - goto out; + goto out3; } -out: + /* these are only used in release so lock not needed */ + cs_char_data.mmap_base = p; + cs_char_data.mmap_size = CS_MMAP_SIZE; + + file->private_data = &cs_char_data; + + return 0; + +out3: + free_page(p); +out2: + spin_lock_bh(&cs_char_data.lock); + cs_char_data.opened = 0; + spin_unlock_bh(&cs_char_data.lock); +out1: return ret; }