Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp824036ybl; Wed, 14 Aug 2019 06:33:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqzkzcpRIEbcRiiT8ji2Ofb7uqZPV6hXzSakQaGfugZefGHxV7p7PL36VY42wsQh3EwTyg5c X-Received: by 2002:a17:90a:b30f:: with SMTP id d15mr7167810pjr.19.1565789618293; Wed, 14 Aug 2019 06:33:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565789618; cv=none; d=google.com; s=arc-20160816; b=BReXl33zcj76Ax/xSwBWjDEKeZZCx0A44wVJSbTwiPzhwo8MERmjnDg9VunxPA/O0i AflLzx0962zLkEPlXA9fgyaw/zFuHuDRQ4Zf9fqpkggVB1ewWVYnCdSqb/bSY7TUgIJ1 2pYShTNuarv6sq4cjBiyu/DwcRk85WSubd0AsvZm66as5uqBG2iiMPTFZEJ1e95LPj2g j7czXWbD06KUx/r9D3v+oKlbRmKc0QCWi8PL1TPtAn0TxO15vcNSYfTc27Oyk4e79oLi yNUkus+sgaVwarT9hssfE7INUjO7bOtaAvAUw5esEdRWcBA1vM/0/llq8Yb9iv3uZ+5D 1Riw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:openpgp:from:references:cc:to:subject; bh=VPqK3eMe6PjlamvNQhZunguh2dtDSBFAInXpqG6QAOQ=; b=wA0bteA00VdI2WE/zZf0DAkJxyRV+eqddFjQLJewwVT/Pn93X1kstaf1XS3KCRW4I9 9uI5z5gXR3XWGdsrvYI/hfGGWoXMC+nAiRgcVxtW0bHC34QBI5VPivJuRFShTV2SX0Yc IuXumr7ZUFRyAEDNuOEQrw2KT1CiSGj+vRTP2cu55gUCzkPLPQC/YK+SU8sVzg/oaoK6 ss5ZFuG3Dfyu44tqBB/lZWpvb2Dx3gIsu5sDWS1Ovp2e5+1OdLYMBP+n/oYvdE6I1+u2 DCkqqY1+Mv0OqL2k9wIagKDfSM2nVpSRN5QPmk/KtYD2Nw0vGd7m3SO/A+43EU7ipbTm E6Jw== ARC-Authentication-Results: i=1; mx.google.com; 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 i10si66385469pfd.226.2019.08.14.06.33.21; Wed, 14 Aug 2019 06:33:38 -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; 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 S1728030AbfHNNco (ORCPT + 99 others); Wed, 14 Aug 2019 09:32:44 -0400 Received: from mx2.suse.de ([195.135.220.15]:47642 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726525AbfHNNcj (ORCPT ); Wed, 14 Aug 2019 09:32:39 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 253AFB04F; Wed, 14 Aug 2019 13:32:38 +0000 (UTC) Subject: Re: [PATCH] regmap: fix writes to non incrementing registers To: Ben Whitten Cc: Mark Brown , LKML , Greg Kroah-Hartman , "Rafael J. Wysocki" , nandor.han@vaisala.com References: <20190813212251.12316-1-ben.whitten@gmail.com> <20190814100115.GF4640@sirena.co.uk> From: =?UTF-8?Q?Andreas_F=c3=a4rber?= Openpgp: preference=signencrypt Organization: SUSE Linux GmbH Message-ID: <4ba5dd72-4a55-c383-0899-62109f10c020@suse.de> Date: Wed, 14 Aug 2019 15:32:37 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 14.08.19 um 15:09 schrieb Ben Whitten: > On Wed, 14 Aug 2019 at 11:01, Mark Brown wrote: >> >> On Tue, Aug 13, 2019 at 10:22:51PM +0100, Ben Whitten wrote: >> >>> @@ -1489,10 +1489,11 @@ static int _regmap_raw_write_impl(struct regmap *map, unsigned int reg, >>> WARN_ON(!map->bus); >>> >>> /* Check for unwritable registers before we start */ >>> - for (i = 0; i < val_len / map->format.val_bytes; i++) >>> - if (!regmap_writeable(map, >>> - reg + regmap_get_offset(map, i))) >>> - return -EINVAL; >>> + if (!regmap_writeable_noinc(map, reg)) >>> + for (i = 0; i < val_len / map->format.val_bytes; i++) >>> + if (!regmap_writeable(map, >>> + reg + regmap_get_offset(map, i))) >>> + return -EINVAL; >> >> This feels like we're getting ourselves confused about nonincrementing >> registers and probably have other breakage somewhere else - we're >> already checking for nonincrementability in regmap_write_noinc(), and >> here we're only checking if the first register in the block has that >> property which might blow up on us if there's a register in the middle >> of the block that is nonincrementable. If we're going to check this >> here I think we should check on every register, but this is >> _raw_write_impl() which is part of the call path for implementing >> regmap_noinc_write() so checking here will break the API purpose >> designed for nonincrementing writes. > > So it appeared that the last patch in this area for validating a register > block [1] broke the regmap_noinc_write use case. Then please add a Fixes: header to your commit message, so that it gets backported to all affected upstream and downstream trees. Thanks, Andreas > Because regmap_noinc_write calls _regmap_raw_write and in > turn hits the _regmap_raw_write_impl, the val_len is the depth of the > one register to write to and not a block of registers which is assumed > by the previous check. By inserting a check that the first (and only) > register is a noinc one allows me to start writing to my FIFO again. > > I'm all for an alternative solution though if there is a cleaner approach. > > Kind regards, > Ben > > [1] https://lore.kernel.org/patchwork/patch/1057184/ > -- SUSE Linux GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 21284 (AG Nürnberg)