From mboxrd@z Thu Jan 1 00:00:00 1970 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 41B0EC433F5 for ; Thu, 21 Apr 2022 16:14:31 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C394883EF3; Thu, 21 Apr 2022 18:12:26 +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="I/l3kTjI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 461D583EAF; Thu, 21 Apr 2022 18:12:00 +0200 (CEST) Received: from mail-wm1-x34a.google.com (mail-wm1-x34a.google.com [IPv6:2a00:1450:4864:20::34a]) (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 5151F83EA3 for ; Thu, 21 Apr 2022 18:11:57 +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=3TIJhYgYKBu8RjTlccXffXcV.Tfdl-SffkcZjkj.UVeo.UV@flex--ascull.bounces.google.com Received: by mail-wm1-x34a.google.com with SMTP id r83-20020a1c4456000000b0038ff033b654so46571wma.0 for ; Thu, 21 Apr 2022 09:11:57 -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=8gURXJpx+V8AevGNZu/fZ+pD33Iq5Xb6EOuTHnbxO+I=; b=I/l3kTjIoRqlbN2KrGNmC80h63qrGmc7niguMV4vVSdHvUo3pg3CTaQmHMtl8lhJCY 4lBKvj9uLhyiQ9pcDark5+IImcYlTdaBtjJqCpIxQk3b7AuYyHNExClT0ZpsP/110jaf aqT7MnBFqtLDh75BYuB8Ly4P/w1vdYOG4qzQ7CU4xEbZ6e2mwB0wodjwzNqWmHPD+kDK R7GErd2i1DVFRDdmIsCblBGDtcaq6oN5G7qec+m/WrUrfk6YM8xs+naCgrdi3HRY0sZi XqFgfIlW4vjVB7D7uqyVrqAPfGdkxRnpAgWvWyHy9NTiiHALTtubyWuqqX6NREvaKzIH 2rzg== 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=8gURXJpx+V8AevGNZu/fZ+pD33Iq5Xb6EOuTHnbxO+I=; b=UPw3uHR+3VzO+qQRbddUq8FyFrpZqsJSFp49gSl1dgOeYrq6NfgeW7ARLOZCi/9+oe FhsH0WkGj4GH5BUmfTMfQmvzohS/Z8q2nTERgKHuLkfsJcF5ysLlGZRG5fXV+Xc5gPme UyBr2U1H4aqLXBznUSekBLiN2E+/4jay/C+O0Xa7O8A4ImCnvzbxfmCEEcMIEAitKIDt 1+TiX4+5Gtr4z5VIHol4o9M+YvfgTO9QIHF8qSFs2Z79d4FQzFyu0S0EDBXE49Z9289T VSsjUijs5R8h0UaA+FZ9bPeu/wznKwn0bJ7P2OXNV3Rd0tUQSYlu99VgntzFuRCxqjhy ct5w== X-Gm-Message-State: AOAM5316Gwab0b0GiBxlw1v+WtvBAtzlDBe/ZJDwbPxphMFFSi9fxgNk Y1o5uxifmWN9ZAnQd3Cqb9bHwqaBC0r6URq6v66SrzT4DwclSIFekKDBbOnkRyPOjbXMqa/DMxU UlAIZKzzIvCEnHfIpIQPeSGCqZ2VKVdUjuBOSlH1jG34+33e0wQYFZzXwN1o= X-Google-Smtp-Source: ABdhPJwMv/FnKVi+ab+dRNvoPRwvCz4aah6dY71GD0tNJyVzcaeO9EWxXVmicPjiCdBfJmyxU/W9yCvq6ko= X-Received: from ascull.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1510]) (user=ascull job=sendgmr) by 2002:a05:600c:3ca3:b0:392:990b:af11 with SMTP id bg35-20020a05600c3ca300b00392990baf11mr76417wmb.173.1650557516883; Thu, 21 Apr 2022 09:11:56 -0700 (PDT) Date: Thu, 21 Apr 2022 16:11:15 +0000 In-Reply-To: <20220421161116.1202023-1-ascull@google.com> Message-Id: <20220421161116.1202023-18-ascull@google.com> Mime-Version: 1.0 References: <20220421161116.1202023-1-ascull@google.com> X-Mailer: git-send-email 2.36.0.rc2.479.g8af0fa9b8e-goog Subject: [PATCH v3 17/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, trini@konsulko.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 Reviewed-by: Bin Meng --- 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.36.0.rc2.479.g8af0fa9b8e-goog