Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp281166lqp; Mon, 10 Jun 2024 04:11:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU6NUNNZT+gonEouZ4LK+w61/H8cjTywgJiPmY2Dg6wVhYsv5A2JhZxC1oOgGl2bFbrG51lxf7p91Hof1U8KYFl5yJq/ZaWyYn7ATgnMg== X-Google-Smtp-Source: AGHT+IGajMZ4gK1hPYqAYhNpOe3sEv8X0b7/zkAX9hmVGVBST2thwck52qQwx5YW8oCeejIbONX8 X-Received: by 2002:a05:6a00:190a:b0:704:2f65:49a0 with SMTP id d2e1a72fcca58-7042f654d89mr5579195b3a.5.1718017908719; Mon, 10 Jun 2024 04:11:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718017908; cv=pass; d=google.com; s=arc-20160816; b=rjReLwAy4UFtvon0sdJjRyEnN8sAu8vmDKvy2gLYp5HSGi0Ouqn5WRKqY7Vpd2oKf7 IPxVCWFkpKbzJqgYKd6dQBqiOAdxo7ctXRZ/gtoHgCED3a8Xxy5h3eihyAvn+nbZH7Kf 55SI3S2xAKFtHgcTx2uUw53xkUt6dEPYVyeoS7vtx43G2w9dgNYDnzr2pI6EEMu123Xb B9IbErRdZqMlCBGnjbTmWeBqzflJXEE5fYC0wHHBhXSXPh3r1yd6YLqEaqCmWrCBbwgq IfUq9tvX6X4q4uuYKgVZtnCJa5Z9bWyxUc/hrPNSnjlh9CPxvPr5acts9A4j2Mx6nPmf F/FQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ZKRDnT36YiO5NHWmifxOcGKSpN9i3QJZvUnqhc0HlYc=; fh=WJxnDF+7qhbytTWBNToH74+tDRW0UGP+MkY9PZNCH+E=; b=K/sSY1QJB85GlWs2ACthCBH+eiDLtK2V9Xf5C6eBNUna9/LeTKmFRThp2cKtKnXA+d UfYh00kfQoogsAHGz/ZEkMyhBs7R/kLdx0wP8Jn5a2ZhaLNItHqA0YdbQqPgb1Yaj0eA 5X8G9KU1fQ6is16srGbFEKFQCTi89eZpnk59ZyVehFdalt0OFTYYEDX7UuluGXUliZTu 47w3otz3IrgBlmeXv35T8Ru3pQfTfB6dSabm12SvSzih0gy5v3/MIbxjpkrOFjeSLNJF Daw6avNmeySF7eSpUA+JZAa/NdiCOdN5lCFvO1mmOIF7t2PD3/Ok8vfcQetNsVURM/c6 J6xw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=ljljwTWM; arc=pass (i=1 spf=pass spfdomain=ventanamicro.com dkim=pass dkdomain=ventanamicro.com); spf=pass (google.com: domain of linux-kernel+bounces-208061-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208061-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-7042461fc74si3640268b3a.329.2024.06.10.04.11.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 04:11:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208061-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=ljljwTWM; arc=pass (i=1 spf=pass spfdomain=ventanamicro.com dkim=pass dkdomain=ventanamicro.com); spf=pass (google.com: domain of linux-kernel+bounces-208061-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208061-linux.lists.archive=gmail.com@vger.kernel.org" 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 567382852DF for ; Mon, 10 Jun 2024 11:06:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B1A177C6EB; Mon, 10 Jun 2024 11:06:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="ljljwTWM" Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) (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 4E5BC75811 for ; Mon, 10 Jun 2024 11:06:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718017573; cv=none; b=cqphGqOmGfRSZDavQJPyf/89L0PPUrgiSrSUXOGVFea6ji2aw7GA8Y6hyEGUQzL5/V5eF1sWnP7xMkfpe9kP2yUJjGBktOuWrywS3MsD6w4d5aeeqDyzmU0oW4vua0j5URwDWZ3OxwlGAUhv2u7Y/Dtxq13ThuVwMYwLwxxzsLo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718017573; c=relaxed/simple; bh=UHAN2MQAwy4F3MaHAlvjKZuTSk8SgdbiqOaACYFrup8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ibEYSus7Jrm11xSZ+XNOE35o2U0yJLYb9vKrmFt8JX8TcvBvHurx8BmWYQy8n58mXKYhl6ApWRgppiQy04i8WVjt2oAPtmi4Qc/ZkBFjfvSlXIs2B/mesxSbUKlu5qkQIXwek0Cb4kZGbyrkyB5rCN4J9M5EbEf8R9Gr3sx6LP4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=ljljwTWM; arc=none smtp.client-ip=209.85.208.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-57a1fe63a96so5344003a12.0 for ; Mon, 10 Jun 2024 04:06:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1718017571; x=1718622371; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ZKRDnT36YiO5NHWmifxOcGKSpN9i3QJZvUnqhc0HlYc=; b=ljljwTWMZs2m1H3DSxmzx/qxIuNFsYHxsqZpRR+pPKfbJeW3wXnHX38UV4owxET6lS BB41rs6JptuSMByojqTi4zciFOn8xCMAg/vtdCaskGi+CxOEpX4EuD5+0ZwjadEhpZMC cZH+nwGwOxEjx6x8XPdlMKfESG+Ok6aTTwyzKxGRjJt5wLI96ZZG8BVTplbq2WNzrzL/ 9ZCdxCkl1q81XP0amhOAWjxi9bNGuIWgQngrKLSM89Hm90I9TPJBgShzJsQQ38s+8HSg /tc6P/K6n+QspSbphl0VmPQ8ItBqo0c3C1l//Msb7n5odGIIjEvO6gAZiaHKpFR7Jdhc YGDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718017571; x=1718622371; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ZKRDnT36YiO5NHWmifxOcGKSpN9i3QJZvUnqhc0HlYc=; b=JNIR3ByM7M0OVNOJMlcbt/BI9wVz5SGeURdGn6skqwkp7QANEBU+U8T+wCuHu/ED7s SRQb+Ish+I8shUIIDWVBxGCacnAiMIbTrv9L19FFwKb6ZUNqG5XqY3qW5I99Z9PQ6Gzu nbVGWsMO26wxN7atOmI9HpiEa1cgboGAmIF2i4BjEd51PDO5d9dMWBDzTLNoOuBt8pRk 35c8NphuYzxOI37dyIpE0YpHoUb7XuCX0bPDGki3XiaFuPsLebChWIL8mpM/gnxdecAX VG/VdeMJHPt+jC3VHW2NkVa8sO3+jeKliDa/3QpfQMwznazCuqCP0G5YEznVhExz0WE2 tzxA== X-Forwarded-Encrypted: i=1; AJvYcCX/q+wyTvNvlgaq+hEhde4/ipSJshRPkL5tYOFJdnhlU7EYvNxfE/TK8adI6gURaES9jl9MU+aGq4lGcKMlSnb5uO9Xlx40QXfpU9gE X-Gm-Message-State: AOJu0YytGeEpvZVIDV4JPLgn7evytM3uGTIuVADOgfSzVBezL6SVWhWx MToGncWCNJ+zoIDwawc1XwSnjq06XkwuFCAGlW6Fd2XSdkjRi+7xU2ceUj3Ww64= X-Received: by 2002:a50:8d43:0:b0:57c:6d89:eaf0 with SMTP id 4fb4d7f45d1cf-57c6d89f06cmr3373682a12.14.1718017570481; Mon, 10 Jun 2024 04:06:10 -0700 (PDT) Received: from localhost (2001-1ae9-1c2-4c00-20f-c6b4-1e57-7965.ip6.tmcz.cz. [2001:1ae9:1c2:4c00:20f:c6b4:1e57:7965]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57aadf9e093sm7201840a12.13.2024.06.10.04.06.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 04:06:10 -0700 (PDT) Date: Mon, 10 Jun 2024 13:06:09 +0200 From: Andrew Jones To: Tomasz Jeznach Cc: Joerg Roedel , Will Deacon , Robin Murphy , Paul Walmsley , Palmer Dabbelt , Albert Ou , Anup Patel , Sunil V L , Nick Kossifidis , Sebastien Boeuf , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, iommu@lists.linux.dev, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux@rivosinc.com, Lu Baolu , Zong Li Subject: Re: [PATCH v7 6/7] iommu/riscv: Command and fault queue support Message-ID: <20240610-3cd1ba07c1b488a451dd7ddd@orel> References: <422f66285da1b164466b223f83d7f06564968f09.1717612299.git.tjeznach@rivosinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <422f66285da1b164466b223f83d7f06564968f09.1717612299.git.tjeznach@rivosinc.com> On Wed, Jun 05, 2024 at 12:57:48PM GMT, Tomasz Jeznach wrote: ... > +static int riscv_iommu_queue_alloc(struct riscv_iommu_device *iommu, > + struct riscv_iommu_queue *queue, > + size_t entry_size) > +{ > + unsigned int logsz; > + u64 qb, rb; > + > + /* > + * Use WARL base register property to discover maximum allowed > + * number of entries and optional fixed IO address for queue location. > + */ > + riscv_iommu_writeq(iommu, queue->qbr, RISCV_IOMMU_QUEUE_LOG2SZ_FIELD); > + qb = riscv_iommu_readq(iommu, queue->qbr); > + > + /* > + * Calculate and verify hardware supported queue length, as reported > + * by the field LOG2SZ, where max queue length is equal to 2^(LOG2SZ + 1). > + * Update queue size based on hardware supported value. > + */ > + logsz = ilog2(queue->mask); > + if (logsz > FIELD_GET(RISCV_IOMMU_QUEUE_LOG2SZ_FIELD, qb)) > + logsz = FIELD_GET(RISCV_IOMMU_QUEUE_LOG2SZ_FIELD, qb); > + > + /* > + * Use WARL base register property to discover an optional fixed IO > + * address for queue ring buffer location. Otherwise allocate contiguous > + * system memory. > + */ > + if (FIELD_GET(RISCV_IOMMU_PPN_FIELD, qb)) { > + const size_t queue_size = entry_size << (logsz + 1); > + > + queue->phys = ppn_to_phys(FIELD_GET(RISCV_IOMMU_PPN_FIELD, qb)); Shouldn't this be something like FIELD_GET(RISCV_IOMMU_PPN_FIELD, qb) << PAGE_SHIFT ppn_to_phys() assumes the ppn it's converting to be shifted up by 10, but FIELD_GET has shifted it down to zero. Thanks, drew