From patchwork Thu May 27 19:56:33 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Nesterov X-Patchwork-Id: 102767 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4RJw7nH020328 for ; Thu, 27 May 2010 19:58:07 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759590Ab0E0T6G (ORCPT ); Thu, 27 May 2010 15:58:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:15421 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755488Ab0E0T6D (ORCPT ); Thu, 27 May 2010 15:58:03 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o4RJvfie017811 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 27 May 2010 15:57:41 -0400 Received: from tranklukator.englab.brq.redhat.com (dhcp-30-233.brq.redhat.com [10.34.30.233]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id o4RJvcjo017627; Thu, 27 May 2010 15:57:39 -0400 Received: by tranklukator.englab.brq.redhat.com (nbSMTP-1.00) for uid 500 onestero@redhat.com; Thu, 27 May 2010 21:56:36 +0200 (CEST) Date: Thu, 27 May 2010 21:56:33 +0200 From: Oleg Nesterov To: Mike Frysinger , Andrew Morton Cc: David Howells , Roland McGrath , linux-sh@vger.kernel.org, Paul Mundt , uclinux-dist-devel@blackfin.uclinux.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] blackfin: use ->mmap_sem to protect mm_context_t->sram_list Message-ID: <20100527195633.GC25935@redhat.com> References: <20100521162659.GA16193@redhat.com> <20100521183512.4477F40476@magilla.sf.frob.com> <20100522165320.GA19573@redhat.com> <25539.1274711817@redhat.com> <20100524151445.GA6393@redhat.com> <17134.1274778852@redhat.com> <20100525102345.GA23574@redhat.com> <20100526124006.GA28358@redhat.com> <20100527195544.GA25935@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20100527195544.GA25935@redhat.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 27 May 2010 19:58:07 +0000 (UTC) --- 34-rc1/arch/blackfin/mm/sram-alloc.c~IUAV_2_SRAM_LIST_LOCKING 2010-05-27 17:51:48.000000000 +0200 +++ 34-rc1/arch/blackfin/mm/sram-alloc.c 2010-05-27 21:31:01.000000000 +0200 @@ -702,19 +702,23 @@ EXPORT_SYMBOL(l2_sram_free); int sram_free_with_lsl(const void *addr) { - struct sram_list_struct *lsl, **tmp; + struct sram_list_struct *lsl = NULL, **tmp; struct mm_struct *mm = current->mm; + down_write(&mm->mmap_sem); for (tmp = &mm->context.sram_list; *tmp; tmp = &(*tmp)->next) - if ((*tmp)->addr == addr) - goto found; - return -1; -found: - lsl = *tmp; + if ((*tmp)->addr == addr) { + lsl = *tmp; + *tmp = lsl->next; + break; + } + up_write(&mm->mmap_sem); + + if (!lsl) + return -1; + sram_free(addr); - *tmp = lsl->next; kfree(lsl); - return 0; } EXPORT_SYMBOL(sram_free_with_lsl); @@ -749,10 +753,14 @@ void *sram_alloc_with_lsl(size_t size, u kfree(lsl); return NULL; } + + down_write(&mm->mmap_sem); lsl->addr = addr; lsl->length = size; lsl->next = mm->context.sram_list; mm->context.sram_list = lsl; + up_write(&mm->mmap_sem); + return addr; } EXPORT_SYMBOL(sram_alloc_with_lsl);