Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp579320lqr; Wed, 5 Jun 2024 14:51:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUnB+SBirpP3HrlTkyc9C8jlNLrR3CEe65Nt8QhEfc4Pzn0WpyXo8KxZzbgTryL2SEdLIFCuL7zdRSdlwi9BUM0vgLVAbFp4QcVY4mfCw== X-Google-Smtp-Source: AGHT+IH7c3DsdZDEvVOVHiz+DsaSGlSSh629CZXxadMZ8KS0zO82bwX9nhmWvuYgn+K2obuQ8UG/ X-Received: by 2002:a05:6e02:154b:b0:374:9c0b:e18f with SMTP id e9e14a558f8ab-374b1f01c43mr40919465ab.16.1717624263562; Wed, 05 Jun 2024 14:51:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717624263; cv=pass; d=google.com; s=arc-20160816; b=bnSFOjjpeQx6nOiwSIoSSjCMCwxT6o1aPDHgxCzeSlM1B1QXApy+KeK6jz5wtHtYiA 9PmOTdr2ZEUFwhBp9FOQKl1uJPjNkg8aPCwivSy59Q4VZkoeAIHifPx5U76r2mvoAyld iRsuqKT79h98K5TY7gBjfuk9CkZRCuRz+aSJDIGzThrnKLBy3lsJzfYmaTl1FgoH+KhB P8FIWRL3QW+5hgLFGwgmVB9D+3dCVf8kWu4Cf+e7ZQQJPFNV4a22jqJ1St+qLpMmlOO/ bCkUHlvQb9i26d/XhC22ymKd/1GWbs7kkDxlmWJZR9SxpzKLsJIRS1EQmLls+n+fInoF gkmg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=iTBiKvOZtBNblIWb1cS7CeNoRrpZ3phkUvzOyTJpLCA=; fh=wz+uQH5Xho5V18mTmvFmx7u85aP1ZSxgT3pc51+dMfI=; b=yOinHrDzRCVo1XqyKZL0Wx1J/3MvwIF6/EgP0x2jNTFWEMBj15qhGGPNrwPdZt8Q2Q GMre19HA5G0wiLCiGAKDA4+NX+vhaKFPhJ0iE3tluRby3N91AYvVFfIhmqsUpEsMcY8k SyvUnkLKSUroLGVhp6MvIV1U9cgpOJpV07OctEMIw1eRYES1Q8s5dRkPMiNZ4szbnY+L lKMtJO+su4uLDwhEZR321qL8WKSwZXofokbkyHNNi5A+6GN+pSTgAoK8UsWfRf9tH6Tk MQl5lJ4rBJUS/7ggEzY14Fw48OF0KZw0LBxE6IHc3F8UeueCL+Xle7h4pxwoiHPW2HeH xWzQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=IsEWGT8i; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-203298-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203298-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-6de2760a6efsi19893a12.544.2024.06.05.14.51.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 14:51:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-203298-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=IsEWGT8i; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-203298-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203298-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id BB60DB254A7 for ; Wed, 5 Jun 2024 21:35:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8D38116C695; Wed, 5 Jun 2024 21:32:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IsEWGT8i" Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3983416ABD8 for ; Wed, 5 Jun 2024 21:32:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717623136; cv=none; b=pB+z7t4ZrCGjrJTZwPqnJpU+6wpZKGgWiWrBqTyQ7x+bZFjQjZxJ9HJrGXID1DPBz3INUiTVKQglQLbcmlAKuoCt06/RFRkiObOHs8TqqBtfBmj1/ngz5HArKxu53+w3f5X51s3/eNx0z8MAsWOGz/CAr1aqg5K3cGxi/G/3xYs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717623136; c=relaxed/simple; bh=2LvJMHkgU4AO0k7JuEOpImVPgoMfIqlW7xjlqc199rk=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Ev4+WMSnhLsf0KQPznFYPR4g8BZBnKHOF+pa4ajFDedKGO2EVKUKVufBku+xg+g8DkEqCF3TUpOWw4UylUVoZz+X1M9a7UspkNQ0jf1ImDfGh3aBHYXdTZmperPjhXH64ixxJsJsveVnOMX8mON8pZGGlB3cbKZtkHpsOlxhMWc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=IsEWGT8i; arc=none smtp.client-ip=209.85.128.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-62a24836e10so119277b3.2 for ; Wed, 05 Jun 2024 14:32:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717623134; x=1718227934; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=iTBiKvOZtBNblIWb1cS7CeNoRrpZ3phkUvzOyTJpLCA=; b=IsEWGT8iIg1T14K4dOloXje5CvpTSDfe+ec/PF8fFqjsNQJJEBtpq0M60T+ZKWcSUN f3cbUpWr9aWI5gdWKSXBgdcwNOYbBqqiFXkBRVuBBjaP4b/eXllGIYs+uUSocEdPIEx+ VOJi5+qqkGKHsalZdHDBQ1cSQUa5jW3sfX/bDPKnhuHC6P/55rXdEaBBsmN4mQpy0IZY fXXBQoygTcMf98wh74PXEMAofsFazED8KtMur3fYPVNN0dzaE50Tpa257/3lAKPQT9V+ pbtzr5WtZIBFPM+yh9AbyNyfHVLRaa5bVP3p+nRuIzeHLfMl4C7i61e/c5R42gqer6z4 yVBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717623134; x=1718227934; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iTBiKvOZtBNblIWb1cS7CeNoRrpZ3phkUvzOyTJpLCA=; b=OnS8rQ0e2mtN/x42Wxg+spsiqXP3E9p9UFyTiPZ7Tgz2w5OOT9d963rNrWzT/Xf5jJ yNcV9+x5wS4TmwNvu6/6GNXEmh6mkCDz/AczQ0/IKfyU1utRYMlwfNOLiidSwy0kGdxU jWZwdw/S03hvlIOUqRKjBgLlJzthClp3gGBPp6vA1GQTcCCTTbN93VZxn714bDAD9zaQ PBtUrNS95kGU3VreUIJfYm2iCgz5xlL88GKfMGgk8H3SKQ7CZlFij6VtBN38jYuj5O7u hRdgYxLkvo4tBgqOVDAZ4uEVPcmgAm6ZTUEfd1XAlUglOuR3KF1TwiE3WD5gf5Q6TaKS n0Rg== X-Forwarded-Encrypted: i=1; AJvYcCX9E0229g2gH3f6bbymPeFDM98HDT4llyaSj8PpjC1JDzUktlezGCfRk38qe0wbkCyeydHMkbiURZI/qsydkDV4ECzVuQyC0Nw3RVFn X-Gm-Message-State: AOJu0YyeT9b259os+eLd/tAtJSUYPK4HQiU1j8hHprKlqCWRyVHfEIft VwTG5jqUJiaeczFdFZZO0u7idMeDH9OLCEgKHx0sXiDS3EuRN9qlKveAKOZNgjZaY1reB3NqUWJ fUaXNjedIkNcV20j2BytJkwzl+Q8= X-Received: by 2002:a05:690c:fc6:b0:61b:e5de:1206 with SMTP id 00721157ae682-62cbb5ec24amr38461097b3.3.1717623134083; Wed, 05 Jun 2024 14:32:14 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240605195324.3213954-1-olvaffe@gmail.com> In-Reply-To: From: Chia-I Wu Date: Wed, 5 Jun 2024 14:32:03 -0700 Message-ID: Subject: Re: [PATCH v3] resource: add a simple test for walk_iomem_res_desc() To: Andy Shevchenko Cc: Greg Kroah-Hartman , AKASHI Takahiro , Baoquan He , Dan Williams , Alison Schofield , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jun 5, 2024 at 1:33=E2=80=AFPM Andy Shevchenko wrote: > > On Wed, Jun 05, 2024 at 12:53:10PM -0700, Chia-I Wu wrote: > > This mainly tests that find_next_iomem_res() does not miss resources. > > ... > > > v2: update subject, use DEFINE_RES_NAMED and hardcoded offsets > > v3: really hardcode offsets > > This doesn't explain why you multiplied previous values. They were quite randomly picked. They were changed because multiples of 0x1000 are easier to read than multiples of 0x400. All suggestions have been incorporated in v4. > > ... > > > +static int resource_walk_count(struct resource *res, void *data) > > +{ > > + int *count =3D data; > > + Blank line. > > > + (*count)++; > > + return 0; > > +} > > ... > > > +static void resource_test_walk_iomem_res_desc(struct kunit *test) > > +{ > > + struct resource root =3D { > > + .name =3D "Resource Walk Test", > > + }; > > + struct resource res[8]; > > + int count; > > + > > + KUNIT_ASSERT_EQ(test, 0, > > + allocate_resource(&iomem_resource, &root, 0x10000= 0, > > + 0, ~0, 0x100000, NULL, NULL)); > > Shouldn't this use RESOURCE_SIZE_MAX? > > Please, split the assertion and allocate_resource() call, so it becomes > readable what exactly you checked against. > > > + /* build the resource tree */ > > + res[0] =3D DEFINE_RES_NAMED(root.start + 0x0000, 0x1000, "SYSRAM = 1", > > + IORESOURCE_SYSTEM_RAM); > > + res[1] =3D DEFINE_RES_NAMED(root.start + 0x1000, 0x1000, "OTHER",= 0); > > + > > + res[2] =3D DEFINE_RES_NAMED(root.start + 0x3000, 0x1000, "NESTED"= , 0); > > + res[3] =3D DEFINE_RES_NAMED(root.start + 0x3800, 0x0400, "SYSRAM = 2", > > + IORESOURCE_SYSTEM_RAM); > > + > > + res[4] =3D DEFINE_RES_NAMED(root.start + 0x4000, 0x1000, "SYSRAM = 3", > > + IORESOURCE_SYSTEM_RAM); > > + > > + KUNIT_EXPECT_EQ(test, 0, request_resource(&root, &res[0])); > > + KUNIT_EXPECT_EQ(test, 0, request_resource(&root, &res[1])); > > + KUNIT_EXPECT_EQ(test, 0, request_resource(&root, &res[2])); > > + KUNIT_EXPECT_EQ(test, 0, request_resource(&res[2], &res[3])); > > + KUNIT_EXPECT_EQ(test, 0, request_resource(&root, &res[4])); > > + > > + /* walk the entire region */ > > + count =3D 0; > > + walk_iomem_res_desc(IORES_DESC_NONE, IORESOURCE_SYSTEM_RAM, > > + root.start, root.end, &count, resource_walk_count= ); > > + KUNIT_EXPECT_EQ(test, count, 3); > > + > > + /* walk the region requested by res[1] */ > > + count =3D 0; > > + walk_iomem_res_desc(IORES_DESC_NONE, IORESOURCE_SYSTEM_RAM, > > + res[1].start, res[1].end, &count, resource_walk_c= ount); > > + KUNIT_EXPECT_EQ(test, count, 0); > > + > > + /* walk the region requested by res[2] */ > > + count =3D 0; > > + walk_iomem_res_desc(IORES_DESC_NONE, IORESOURCE_SYSTEM_RAM, > > + res[2].start, res[2].end, &count, resource_walk_c= ount); > > + KUNIT_EXPECT_EQ(test, count, 1); > > + > > + /* walk the region requested by res[4] */ > > + count =3D 0; > > + walk_iomem_res_desc(IORES_DESC_NONE, IORESOURCE_SYSTEM_RAM, > > + res[4].start, res[4].end, &count, resource_walk_c= ount); > > + KUNIT_EXPECT_EQ(test, count, 1); > > + > > + release_resource(&root); > > +} > > Other than the above, LGTM. Hopefully next version will be ready to apply= . > > -- > With Best Regards, > Andy Shevchenko > >