Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp3009953lqo; Tue, 21 May 2024 04:23:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVp+GD9tFrrlNOaqmyPP10K4u8+vZc2J51MQTsRg9AYEmlWJaWAT2JnmqobtEc4/0q9RiJfp/LjewNTozQnu0holPa/vLEHKzlLxJg5TQ== X-Google-Smtp-Source: AGHT+IEx8EEqyxJkd/4m4aMJWiU5yY+9H68oB2ubX0cq8RAK1iUi1q9BQEmUJ6O6MCxfQp4SRa+d X-Received: by 2002:a05:6a20:c889:b0:1af:fcbf:df28 with SMTP id adf61e73a8af0-1affcbfdffamr27487015637.41.1716290584889; Tue, 21 May 2024 04:23:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716290584; cv=pass; d=google.com; s=arc-20160816; b=nCR8cIdIK4TKJvcMEyTQ3WQnceCowrR6DB9RryXDoRJyfmfClRj/FpF+9J4/PDbEQi 92h5Fj9d+/TAP8PXJ4J6fpyq9E3LcxvfHfwjOy8uwtRoyk4CaeQRJWZoQq2C63kClraC kR0B6DrJ26rNU7Bl754F2az+37ZJr30+jwOqjE52X6ffxHliG1cxoQPW7fYnrM23cr7Q Ux4UsQ0zAjd3x+Lxlmj8i8u/7pLLSxZtT/wbfZFwALMCK6MhZP+45gDOjrGIOZp9X/Tw y/lJn5gLJfu9T0lyi39v1i8C6gjVNWZU4mSzmHlswSFIKINrYXf4yWhLXnFZXgURxE8G DsKA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:organization:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=sHk/Aed3i1ecXpAXSTOJ91mw0z8jVc514DVco1BYwS4=; fh=kcIE/1u4b9rrtAwfNKFyRlAEK163JO1z9HebgKFcbQU=; b=vO7YvKHI6wavdh4A2vqtOxmkLZuGZEgJuD1ld3q9nCSs4RxDgz9YDkOjACmKmCJ3uq I1of/x9O0azKDNW0txVDcIfVzHo0cYYQgMCnrRyiN728uZYhOIDFXns90kDpmdqsjoYw lRQRGebTp3TfPbAsahxhFw+8QqGRXroJp7iHOzpIJ60ynQxySiVlZEEomAwKjBXoJx1K 3Of6hbvwOYTeP4TI31d0mQS/wV11xVh/inih9xTVYpakykDGVuyPGJ5ui8lcnqmz4puU 5xX/ht7ICBEKbSsKShvu2bLXkKEedGmWqproGSXyn517+xbTSZNthPcKRD53hY0U9v6q 0oCA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=H7JUWoy6; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-184874-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184874-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b670f4e1a8si4076247a91.60.2024.05.21.04.23.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 04:23:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-184874-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=@redhat.com header.s=mimecast20190719 header.b=H7JUWoy6; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-184874-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184874-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 63EBE282355 for ; Tue, 21 May 2024 11:23:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9208974BF0; Tue, 21 May 2024 11:22:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="H7JUWoy6" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21CA55BAC1 for ; Tue, 21 May 2024 11:22:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716290576; cv=none; b=FKqthic/z2R5AgQSbikd4Q1nhl6cei9Rjj+V0oSbklCslFjR2+CxGDmbFW80Khv78u9PMLDkNMRZZ0UdqcMi9SvvntILQV1Arcoe44YOCebX5eiOtjWxOwVq/BBOfxsslQRHxejgdY3Dzg18ggAeOtq1/HmaYXH16Q5jzZ/EGTw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716290576; c=relaxed/simple; bh=k/JRGdMuDPu8HhJUTkcTAdkXQAVA5INw/irGgRh31Kw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=sN1JJJp87/Tc2iT4UQ3FZIuTZ4HNNQOhz5lcnzW5buj3rjJyN0p+kT71k+JtZFWRxnhMP6eBpkWohvOX3jdnLaTtIfbBDpYWWYly/8gnLZ81msJY11ZNfxMbgAaqBynEng/xTQHfOTmJ87Pu8XT+pPB2bhVJ5W0sQ0JuEp8+k8k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=H7JUWoy6; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716290573; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sHk/Aed3i1ecXpAXSTOJ91mw0z8jVc514DVco1BYwS4=; b=H7JUWoy6BYRxyIEbe/mGhhtALCdP9w0oOOI3Ypq1GhLP28wH8m7q2HEd1meojyLOqWf8ip xQvPP9O3y1ZytWMGLgji6VExi7pT1mk0LmhHxb8+bjaLuwOUXvJrwwuZXbHrwNppDxwoGP 7kizDua4z0/O8YHDa1d+ND/SOvp3g4Q= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-388-iluVDoaCPhuxI7B0Crv6gw-1; Tue, 21 May 2024 07:22:52 -0400 X-MC-Unique: iluVDoaCPhuxI7B0Crv6gw-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4206b3500f5so26800835e9.1 for ; Tue, 21 May 2024 04:22:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716290571; x=1716895371; h=content-transfer-encoding:in-reply-to:organization:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=sHk/Aed3i1ecXpAXSTOJ91mw0z8jVc514DVco1BYwS4=; b=OXpm6O6qV7JhXc1NGHNu6l9Uda8ANUmAlMEs4sM3SMyJAu31x5gegrQL0nTNgNZRwv bc9qRqGhEoXojLhHBRB1Vdd4/6iBS+LsLIkThWd+3AwkR30ldGr3xP9D0rCLu7ZqhAl1 AfQSmheq+lmZqpb7nFk2a4QNDgvbPCFd9Gm7smLcWEKPiugxmLeZEj7UIQauTZk3sJkD 9f60/x773CGuwqmhKk7P9xeqBihWeP+QMAJuf7u8S7OrkQzCFW0OGP2t8RP2xsJZxR00 DVr1iJlW/e4SEfmMN7iokHZ9JvEZlCVDCtc0UMqXuDMcZ0XShp5K/hf6jrqwr1Jo1n7I 7v/A== X-Forwarded-Encrypted: i=1; AJvYcCUAZl7uFOIboRBWP8KKnbTslotTRVa01Tj3hbE9Aimovzt7R0p+CMO0cYXPlHuOfurJAoiR0FqCHmEubwUoBODiclzGXzRSYTZxlLuh X-Gm-Message-State: AOJu0YzZ+iFsHdAdIpJ4L/GTUrwL4TJ529mOzJIR4tclhhdCxqA7ovtc rdj69ZhvNUBMKoPLuVEn4tAzBGyuXh3q6U0qvsnCpn2+o3uIU6JmsafNXQx+FCZKOOb6OjDHLnf Ho/DJRo2AHOqcYpG9gCtEha631kM+NLMwRiTRT3niCOjVygliWpi7OzdHqVefGw== X-Received: by 2002:a1c:7910:0:b0:41b:bb90:4af with SMTP id 5b1f17b1804b1-41feaa44138mr310694925e9.20.1716290571297; Tue, 21 May 2024 04:22:51 -0700 (PDT) X-Received: by 2002:a1c:7910:0:b0:41b:bb90:4af with SMTP id 5b1f17b1804b1-41feaa44138mr310694755e9.20.1716290570972; Tue, 21 May 2024 04:22:50 -0700 (PDT) Received: from ?IPV6:2a02:810d:4b3f:ee94:abf:b8ff:feee:998b? ([2a02:810d:4b3f:ee94:abf:b8ff:feee:998b]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3502baad04dsm31724783f8f.81.2024.05.21.04.22.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 May 2024 04:22:50 -0700 (PDT) Message-ID: <8432d37c-c3fb-4404-ab74-fb0a9940f0de@redhat.com> Date: Tue, 21 May 2024 13:22:49 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 11/11] rust: PCI: add BAR request and ioremap To: Miguel Ojeda , pstanner@redhat.com Cc: gregkh@linuxfoundation.org, rafael@kernel.org, bhelgaas@google.com, ojeda@kernel.org, alex.gaynor@gmail.com, wedsonaf@gmail.com, boqun.feng@gmail.com, gary@garyguo.net, bjorn3_gh@protonmail.com, benno.lossin@proton.me, a.hindborg@samsung.com, aliceryhl@google.com, airlied@gmail.com, fujita.tomonori@gmail.com, lina@asahilina.net, ajanulgu@redhat.com, lyude@redhat.com, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org References: <20240520172554.182094-1-dakr@redhat.com> <20240520172554.182094-12-dakr@redhat.com> Content-Language: en-US From: Danilo Krummrich Organization: RedHat In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 5/21/24 01:27, Miguel Ojeda wrote: > On Mon, May 20, 2024 at 7:27 PM Danilo Krummrich wrote: >> + let barlen = pdev.resource_len(num)?; >> + if barlen == 0 { >> + return Err(ENOMEM); >> + } >> + >> + // SAFETY: >> + // `pdev` is always valid. > > Please explain why it is always valid -- the point of a `SAFETY` > comment is not to say something is OK, but why it is so. > >> + // `barnr` is checked for validity at the top of the function. I added pci::Device::resource_len(), since I needed to get the VRAM bar size in Nova. pci::Device::resource_len() also needs to check for a valid bar index and is used above, hence the check is implicit. I just forgot to change this comment accordingly. >> + /// Returns the size of the given PCI bar resource. >> + pub fn resource_len(&self, bar: u8) -> Result { > > Sometimes `bindings::` in signatures of public methods may be > justified -- is it the case here? Or should a newtype or similar be > provided instead? I only see this function being called inside the > module, anyway. I agree, I just added this function real quick to let Nova report the VRAM bar size and forgot to clean this up. > >> + /// Mapps an entire PCI-BAR after performing a region-request on it. > > Typo. > > Cheers, > Miguel >