Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6828DC433EF for ; Tue, 29 Mar 2022 17:03:00 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B9B448408A; Tue, 29 Mar 2022 19:01:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="X1D/4TZr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E23048404D; Tue, 29 Mar 2022 19:00:12 +0200 (CEST) Received: from mail-ej1-x64a.google.com (mail-ej1-x64a.google.com [IPv6:2a00:1450:4864:20::64a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C90938403D for ; Tue, 29 Mar 2022 18:59:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=3DjtDYgYKBqkJbLdUUPXXPUN.LXVd-KXXcURbcb.MNWg.MN@flex--ascull.bounces.google.com Received: by mail-ej1-x64a.google.com with SMTP id zd21-20020a17090698d500b006df778721f7so8411394ejb.3 for ; Tue, 29 Mar 2022 09:59:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=KHfShgtpFK9h7/qcRPIVETCNmPZw+lKXZmAAIlEGB+w=; b=X1D/4TZr9ECkITLdE7atXbL1U8OUGJp2PrmZecE8Xed6jb5RWuzbMgw4SmjkC3zLxF Q62Xt1QEuBgjdEHNmGQS9yyMiw8IoeBmhj/Q2F6vDDiA7mz0WvrObr3KONGEBttKtlxU Rjy3b4diz79raPfNSe2vYPCd10/4AH7pT8bJxfl9JlEkOyoiX9QqkjnV1e55tan/aq47 JYJNDx2hVOr63Wdnau/VHbjXPEFw3KVBvn1YR5lvR/M7DiIjyWgOokiZjVWuCL4RSoyI 5duBwQqf58Md0wXNgZAv+Z/SD9IcAd8XBG4o4omAZxVEGCO/JJf3wiimaSFvV5l4mxO3 FvLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=KHfShgtpFK9h7/qcRPIVETCNmPZw+lKXZmAAIlEGB+w=; b=z9m7ZQLYO5Ccye5vULVJcwTXIkQo11dYZWiRrarLJ7aXstVljaQyTrWcX23qZgOpi7 Y1HQRIZYnewleeCrO/yHIxYgBScXOZLoxjUmD7sQ4Tm0ByX1+hb3M6EfOff8jebf83OU DKh+V5TLex3k/+Yui8zUSCULVmQ8qqpHJaX2bThJWukiFORk73xxRRTDyJHi9kp/caZM 1fjzemfecMPPHcHdYuLfSWzvOzfxlGTxawtdTUjnTz+P8ALhxPArrXHTx9x41p8pzhir GywQ7BfWrLGXTPaD+piLsRf1++s39leGQaOi2v/nXHeNZecdypcV8ZMvJYOn0+K4bDh5 00pQ== X-Gm-Message-State: AOAM530iLsDNuRzsC0KZqzHM/x9siM8NAAA5jWdxQP66Pi2+E9ypmY8o OnFl0TlQuHmeRs5wByshg6yRblqDsabnLgnXzTAxfSBxmexrJg1aZm1CyQlKFc95pqmzSe7tB7D qFJw60yrEzezDmsDAM5eRMkfpzAvhMsyBc+gU4r6rOYViNaWvM7aQhuSX/Yo= X-Google-Smtp-Source: ABdhPJwpJbLZrWY3az7eBzYVPhYLxv19t3tCYSGWx/2dsm0juuifGrAPKVOSE+kvDpLiEDLox0ywHEOElEM= X-Received: from ascull.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1510]) (user=ascull job=sendgmr) by 2002:a17:907:6e93:b0:6df:8c1a:d08b with SMTP id sh19-20020a1709076e9300b006df8c1ad08bmr35328712ejc.557.1648573198337; Tue, 29 Mar 2022 09:59:58 -0700 (PDT) Date: Tue, 29 Mar 2022 16:59:00 +0000 In-Reply-To: <20220329165900.1139885-1-ascull@google.com> Message-Id: <20220329165900.1139885-19-ascull@google.com> Mime-Version: 1.0 References: <20220329165900.1139885-1-ascull@google.com> X-Mailer: git-send-email 2.35.1.1021.g381101b075-goog Subject: [PATCH v2 18/18] virtio: pci: Make use of dm_pci_map_bar() From: Andrew Scull To: u-boot@lists.denx.de Cc: sjg@chromium.org, bmeng.cn@gmail.com, adelva@google.com, keirf@google.com, ptosi@google.com, Andrew Scull Content-Type: text/plain; charset="UTF-8" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean The virtio PCI capabilities describe regions of memory that should be mapped. Map those with dm_pci_map_bar() which will ensure they are valid PCI regions. Signed-off-by: Andrew Scull --- drivers/virtio/virtio_pci_modern.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c index f1e64a3438..880a12cc28 100644 --- a/drivers/virtio/virtio_pci_modern.c +++ b/drivers/virtio/virtio_pci_modern.c @@ -459,19 +459,17 @@ static int virtio_pci_find_capability(struct udevice *udev, u8 cfg_type, static void __iomem *virtio_pci_map_capability(struct udevice *udev, const struct virtio_pci_cap *cap) { - ulong base; - void __iomem *p; - /* - * TODO: adding 64-bit BAR support - * - * Per spec, the BAR is permitted to be either 32-bit or 64-bit. - * For simplicity, only read the BAR address as 32-bit. + * Find the corresponding memory region that isn't system memory but is + * writable. */ - base = dm_pci_read_bar32(udev, cap->bar); - p = (void __iomem *)base + cap->offset; + unsigned long mask = + PCI_REGION_TYPE | PCI_REGION_SYS_MEMORY | PCI_REGION_RO; + unsigned long flags = PCI_REGION_MEM; + u8 *p = dm_pci_map_bar(udev, PCI_BASE_ADDRESS_0 + cap->bar, cap->offset, + cap->length, mask, flags); - return p; + return (void __iomem *)p; } static int virtio_pci_bind(struct udevice *udev) -- 2.35.1.1021.g381101b075-goog