Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp241331rdb; Tue, 31 Oct 2023 06:26:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEhef9gPK2aobPtcvdTIBUN4YAt4I9oXq99n9SKU0yawhg/vUOEl1wOx84cPSIzzOtgj1c9 X-Received: by 2002:a17:902:e5c3:b0:1cc:58f1:8646 with SMTP id u3-20020a170902e5c300b001cc58f18646mr4800053plf.50.1698758777864; Tue, 31 Oct 2023 06:26:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698758777; cv=none; d=google.com; s=arc-20160816; b=BBZtKWR48TpP9evT8hluoJJDXevT/DG6upAZdu8fC16oWVTMrPAD7LKXF2uwlO1hVQ Wml93MNmHQl4HJW05YdrH/HUFglvThYAXXN7KORj+NJTnSb29EQq+BBWTxLBz+CHICLr tDFeSsIRCAvo2o9fjbrFzBld65c1+wqd4hN/MCSFCtYcKC35D6FRU/xQ4IQog3Hna2jJ izG9QeH1lY7rg49IVJg3hSrV70TSbF2/7lAPXbKU/8FnvhWKBZzdwrtb5rg6HAfe88jN 5OnNGNWhvHz6Q6unRiQw6nblQ0DefoplGtgT9xAuQo8QfN9uq6fe3hpTUNWrxN+0DHpE zFvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=pY0+visStd0TUS4K+SCgAFtPXEtJj34nCtU7F9jE/Xk=; fh=h2N42GKTpqgFW/SyCSLm/5au1JDgksDMaR/N82zbGPI=; b=MfsCb1YincLPnTulG8pFZX0TuzkFpuHw+eTqem7aNoZ96wm1e4hyQREJFxgnEs3/4G f/RpDOb9Bg4nQaRZMwH63QbyRbKSo2AG0QzV4a0cVyyMCmanONWF8zB5+tUHdTlbeg2Q vNQd1fe88Yr355zfUlIYLNNuxHwfohaq6dkCJV7S5tlI1SHsP2b1Fu0iakzXeZtBagz1 KVZJiP1x1cH/4TirMl7qDzLlztUpwQYg1dY/qAnQq82weByAFLkvnIUdSo+7PrRu5Aa5 m9CgvpHOkNtt8+oQMbag73ojrHjWxfKlEhF5qWIIflzGY/akBCaicp7RBUb7f/5C83rO W97g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BM1BqC55; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id kv8-20020a17090328c800b001b3bd85f54bsi1014938plb.35.2023.10.31.06.26.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 06:26:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BM1BqC55; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 8B98C807AC51; Tue, 31 Oct 2023 06:26:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344524AbjJaNZt (ORCPT + 99 others); Tue, 31 Oct 2023 09:25:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344461AbjJaNZt (ORCPT ); Tue, 31 Oct 2023 09:25:49 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8E1EDE for ; Tue, 31 Oct 2023 06:25:46 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03AE6C433C7; Tue, 31 Oct 2023 13:25:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698758746; bh=qq7ptxnKbInbBcr1W798zXlNpA2qLRG2+BBdxliCEnY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BM1BqC55qMoBKLr4lIAjs4LsMPAIUFPF4+s1Yhzs7kcm5VbypZVdvuffLI4ZcSDex SjQ4besqJuUByyUI3DE78AJaM/r81ujC1H4qYPZOZhrPimB+woPWOLyAuwd5LBmkr7 9UqEktCZDZj5YEHWdxptuKNGN7ogJtDl6OBo1h+i56handReipJkWz+VB7muJ0++oR vgGCCCttnioxK9bZRNv4DNZ94pUhLTL5W9cPeZY5b4jzDZjkFDRqeq0fEm/KOYKnPm +8aKW5p5//v0sMBjuJ/RHXsZLY5BDsNWelKDJtSTYY/An0skZxC73WGa1uMXYboG5p R6UogIprXd+8w== Date: Tue, 31 Oct 2023 13:25:41 +0000 From: Mark Brown To: Pierre-Louis Bossart Cc: Baojun Xu , lgirdwood@gmail.com, perex@perex.cz, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, kevin-lu@ti.com, shenghao-ding@ti.com, peeyush@ti.com, navada@ti.com, tiwai@suse.de Subject: Re: [PATCH v3] ASoC: tas2783: Add source files for tas2783 driver. Message-ID: References: <20231028092409.96813-1-baojun.xu@ti.com> <7f4465c1-5e8e-4c5f-bbff-d2c930326986@linux.intel.com> <9d922584-288a-4b73-83ef-477d1bc58521@sirena.org.uk> <9b94488e-206d-419b-92ed-e70aab11907b@linux.intel.com> <85890ed8-0ab3-4b14-879b-be9f0c760db8@linux.intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="yHndlsctv1XDmSuG" Content-Disposition: inline In-Reply-To: <85890ed8-0ab3-4b14-879b-be9f0c760db8@linux.intel.com> X-Cookie: Is it clean in other dimensions? X-Spam-Status: No, score=-1.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 31 Oct 2023 06:26:00 -0700 (PDT) --yHndlsctv1XDmSuG Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Oct 30, 2023 at 04:05:09PM -0500, Pierre-Louis Bossart wrote: > On 10/30/23 12:40, Pierre-Louis Bossart wrote: > >>>> +static bool tas2783_readable_register(struct device *dev, unsigned = int reg) > >>>> +{ > >>>> + switch (reg) { > >>>> + case 0x000 ... 0x080: /* Data port 0. */ > >>> No, this is wrong. All the data port 'standard' registers are "owned"= by > >>> the SoundWire core and handled during the port prepare/configure/bank > >>> switch routines. Do not use them for regmap. > >> This seems to come up a moderate amount and is an understandable thing > >> to do - could you (or someone else who knows SoundWire) perhaps send a > >> patch for the regmap SoundWire integration which does some validation > >> here during registration and at least prints a warning? > > Good suggestion, we could indeed check that the registers are NOT in the > > range [0,0xBF] for all ports - only the range [0xC0..FF] is allowed for > > implementation-defined values. I'll try to cook something up. > After checking, the following ranges are invalid for codec drivers: > for address < 0x1000 > LSB =3D 0x00 - 0xBF standard or reserved > 0x1800 =E2=80=93 0x1FFF reserved > 0x48000000 - 0xFFFFFFFF reserved That's a huge range... I think the concern is more the standard ranges than the reserved ranges isn't it? That's the bit that the SoundWire core or other generic code will be actively managing. > is the recommendation to check the regmap_config and its 'yes_ranges'? > Presumably if the range_min or range_max is within the invalid values > above then the configuration can be tagged as problematic in the dmesg > log or rejected with an error code? That would work for drivers that use that, but note that drivers can just provide a function here so you pretty much need to probe each individual register. It's done that way because we figured when the interface was originally defined that the compiler would probably generate better code from a switch statement in most cases than us trying to fine tune an algorithm. Probing like that is going to be unsustaniable for the full ranges above but shouldn't be too bad for the potentially standard bits, we could guard it with a config option if it's noticable. Another option would be a kselftest that looks at the readable registers in debugfs, we do build up a cache of the readable ranges there when the access map or register contents are first read. That's potentially less visible but OTOH easier to ask for on review, I was debating asking for mixer-test output on all CODEC driver submissions (similar to what the media subsystem does with their validation suite). --yHndlsctv1XDmSuG Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmVBAFQACgkQJNaLcl1U h9BHYQf5AZkATJTk5YajSzfaGkwvtsde8Po44shkOllZMOUSxo9fruicL4Z1HN69 EGKaH+ZTowx2MVJ20Ox/z3q8DxoL0Zh1PHxZ8NRlNPRjFvfUwoerBsUw4cU3as1t q395xPyGjgiWcItoFUdUZ/ICEUZQmnvt/LZ1srqbt3ilYwkIdvlv1UWwomn59fu9 upm5dSEK1MFKsctigmYsJsaNNcshJlyNNjJqjUp6AhRnUILOkPQmzkJm6QX0VVX+ YS/gIGB7Cpnkaqkc7fGIPDcHNpv6TAiP6sTOmuiZohxLaXIxD7Xi762cHI+8OXBE L+CGjNOEo/fGrgPKGVgqUaPDTh2ZwA== =c9sg -----END PGP SIGNATURE----- --yHndlsctv1XDmSuG--