From patchwork Tue Mar 18 12:02:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 26492 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f199.google.com (mail-ie0-f199.google.com [209.85.223.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AA5C5203C3 for ; Tue, 18 Mar 2014 12:03:33 +0000 (UTC) Received: by mail-ie0-f199.google.com with SMTP id rl12sf25366842iec.2 for ; Tue, 18 Mar 2014 05:03:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:date :message-id:subject:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=7QINf9chtKDdUVofM4MCjnWjtFZVy2O8ahKhJqebhUk=; b=c0UrV0q0PzEUJGig1sXksj0EcNkJZ6ksb31em6cjcmHd+XlBAjf/jbs0baYBjmae7g X7YgMjbNKfn8gnJ5p8G+OpAigTVlpL6fnLBLRuPSF5UCzqjBQACzKgfRimRXKxI1fy2V 00RKD3uVgEzPvkFSvN1Nil8ci2N2u0ydlZ9dMZM0dtEX0C8p4k4JobXYOqslOaPHPshY +dOYibuoSnfllGUkF7Zvn92rSxmem4LWr4+U7ZgeLTK3S1vr+iBmZsvwGTLhm4hKhqQE OeCBypnMFC0ZOoRkJKSmoTdHQvRe3P0y2zjrHRZ5UYVtd82zyKtG61CaexNvXRlshX6e idEw== X-Gm-Message-State: ALoCoQnja4VztPqNABkUL7/IG5iA0FOcjGe7wjNQ3Yi/9CuQTwjjvjqIwJJVVYXd6BACgS6MRkIH X-Received: by 10.43.103.136 with SMTP id di8mr10098962icc.14.1395144212868; Tue, 18 Mar 2014 05:03:32 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.84.170 with SMTP id l39ls980975qgd.6.gmail; Tue, 18 Mar 2014 05:03:32 -0700 (PDT) X-Received: by 10.52.26.161 with SMTP id m1mr9795985vdg.24.1395144212704; Tue, 18 Mar 2014 05:03:32 -0700 (PDT) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by mx.google.com with ESMTPS id f5si4833639vej.35.2014.03.18.05.03.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Mar 2014 05:03:32 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.175; Received: by mail-ve0-f175.google.com with SMTP id oz11so6761198veb.6 for ; Tue, 18 Mar 2014 05:03:32 -0700 (PDT) X-Received: by 10.52.134.202 with SMTP id pm10mr76934vdb.55.1395144212601; Tue, 18 Mar 2014 05:03:32 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.78.9 with SMTP id i9csp199736vck; Tue, 18 Mar 2014 05:03:32 -0700 (PDT) X-Received: by 10.66.118.71 with SMTP id kk7mr32042484pab.14.1395144211334; Tue, 18 Mar 2014 05:03:31 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id mu18si11383321pab.26.2014.03.18.05.03.29; Tue, 18 Mar 2014 05:03:29 -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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753846AbaCRMDU (ORCPT + 26 others); Tue, 18 Mar 2014 08:03:20 -0400 Received: from mezzanine.sirena.org.uk ([106.187.55.193]:54684 "EHLO mezzanine.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751184AbaCRMDT (ORCPT ); Tue, 18 Mar 2014 08:03:19 -0400 Received: from cpc11-sgyl31-2-0-cust672.sgyl.cable.virginm.net ([94.175.94.161] helo=debutante.sirena.org.uk) by mezzanine.sirena.org.uk with esmtpsa (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1WPsjk-0003za-4Y; Tue, 18 Mar 2014 12:03:17 +0000 Received: from broonie by debutante.sirena.org.uk with local (Exim 4.82) (envelope-from ) id 1WPsjg-0000ys-VR; Tue, 18 Mar 2014 12:03:12 +0000 From: Mark Brown To: Takashi Iwai Cc: linux-kernel@vger.kernel.org, linaro-kernel@lists.linaro.org, Mark Brown Date: Tue, 18 Mar 2014 12:02:58 +0000 Message-Id: <1395144178-3729-1-git-send-email-broonie@kernel.org> X-Mailer: git-send-email 1.9.0 X-SA-Exim-Connect-IP: 94.175.94.161 X-SA-Exim-Mail-From: broonie@sirena.org.uk X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on mezzanine.sirena.org.uk X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.3.2 Subject: [PATCH] regmap: Ensure regmap_register_patch() is compatible with fast_io X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on mezzanine.sirena.org.uk) Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: broonie@kernel.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Mark Brown With fast_io we use mutexes to lock the I/O operations so we would need to do GFP_ATOMIC allocations if we wanted to do allocations inside the lock as we do currently. Since it is unlikely that we will want to register a patch outside of init where concurrency shouldn't be an issue move the allocation of the patch data outside the lock. Reported-by: Takashi Iwai Signed-off-by: Mark Brown --- drivers/base/regmap/regmap.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 554119535a64..2d7d55b3bedb 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -2396,6 +2396,9 @@ EXPORT_SYMBOL_GPL(regmap_async_complete); * apply them immediately. Typically this is used to apply * corrections to be applied to the device defaults on startup, such * as the updates some vendors provide to undocumented registers. + * + * The caller must ensure that this function cannot be called + * concurrently with either itself or regcache_sync(). */ int regmap_register_patch(struct regmap *map, const struct reg_default *regs, int num_regs) @@ -2408,6 +2411,17 @@ int regmap_register_patch(struct regmap *map, const struct reg_default *regs, num_regs)) return 0; + p = krealloc(map->patch, + sizeof(struct reg_default) * (map->patch_regs + num_regs), + GFP_KERNEL); + if (p) { + memcpy(p + map->patch_regs, regs, num_regs * sizeof(*regs)); + map->patch = p; + map->patch_regs += num_regs; + } else { + return -ENOMEM; + } + map->lock(map->lock_arg); bypass = map->cache_bypass; @@ -2419,17 +2433,6 @@ int regmap_register_patch(struct regmap *map, const struct reg_default *regs, if (ret != 0) goto out; - p = krealloc(map->patch, - sizeof(struct reg_default) * (map->patch_regs + num_regs), - GFP_KERNEL); - if (p) { - memcpy(p + map->patch_regs, regs, num_regs * sizeof(*regs)); - map->patch = p; - map->patch_regs += num_regs; - } else { - ret = -ENOMEM; - } - out: map->async = false; map->cache_bypass = bypass;