Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp725332imm; Fri, 22 Jun 2018 04:22:28 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJt98jyMudRCQISeLS20z1siDit47ONmkvVHqsKPGPFRTdW2QC78jX6w/OeceYlcCDBWUpD X-Received: by 2002:a17:902:8a81:: with SMTP id p1-v6mr1230542plo.33.1529666548086; Fri, 22 Jun 2018 04:22:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529666548; cv=none; d=google.com; s=arc-20160816; b=ygCnIXg7+n+ryBEz/26MqTqmMFdqAN/Yf964NCfzD1T+/qSdMoks0QAO5iCEmEEjMi WjhcKw+w6qhsVtG0c1wubHoqGCf7CPfcGHW0Rhi0ST2V/dUExIOoCXbxAuK/bMXI3kNI bnPtkhXFBN2wIQQURqlHLAzJnt16i5oumIdJ0w5AslGu7dlhgrfkqyVETpDer5V7ffHC lasW0sQMsm7Z4yCjYa+XdPw53yVuB0E54Z8Ia3lrO1UjrrEDktc/yl9Y+HPZHcyJsLre SRfYOWj5zQMlG3DIaO/oXFOGs3dJo7I12RCuF3FGl/NOM+0NGGmsvI+w3magcLe3sRWD VUMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=0silnt5jmYbdp8PBts+IrGrVbdLRdxecd3/+a300SaY=; b=t9R5uOlrcKVwgXYScG5+YKD1RcaTM89ZisrAo+SXRrHnBeZcdfEJ2njnf0g/QXmZ2N tcsf9dQqViYp0QLPnS3GRcP/ojTVQKWiGCFrDJixzs0Sn0eYYvgoTFwwJZMZiBA8MElU VcFU9NC2PGIjJy9QikjymCe1y8+A3Sdwo+sQDqhExSRv0IEYmktLaIFOSgFCPj1n+9RS FRurTgSD8i8a4E2e+Yd1OJ5gsBaOqqhLowW3v4R+VYLA7AyqSiZBbCkOBb6lVN+Tn6fz 69jO0YRQXKCY83uf/0h4hVOKDWhmNU63pIloWw4t2ApmqXGJ/nALYtKNWjCEfiDvt08k p0tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hNJaMA+9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u10-v6si7013294plu.160.2018.06.22.04.22.13; Fri, 22 Jun 2018 04:22:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hNJaMA+9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751385AbeFVLVe (ORCPT + 99 others); Fri, 22 Jun 2018 07:21:34 -0400 Received: from mail-it0-f67.google.com ([209.85.214.67]:53619 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751242AbeFVLVa (ORCPT ); Fri, 22 Jun 2018 07:21:30 -0400 Received: by mail-it0-f67.google.com with SMTP id a195-v6so2365942itd.3 for ; Fri, 22 Jun 2018 04:21:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=0silnt5jmYbdp8PBts+IrGrVbdLRdxecd3/+a300SaY=; b=hNJaMA+9vOjoN/ritplV8eIgWRjIinEBUhKt3ZXVz7Wqp3jvvq8pzD9brTkSGNXd1F gZd+VVww6xRUpId7+sQ4Zr8gS62fruTKWR2z2wMQ9gWNT56sJzxPxGthTFWDVsKW7BdF cWRARny17Bnsz4MNcepEG9BPrk/B2+RpqXj7c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=0silnt5jmYbdp8PBts+IrGrVbdLRdxecd3/+a300SaY=; b=OFjgPA5Gsp6BP16OVT6rlAEK18Xo0woxTO+9w7lODhQOK7DC5Sh2SusyUcp7E/DwWy YOqlPXoYH7RVSeQds/u1D7Qin3gMkJETI6mXVRWQxUCPgWNZ3SbztNirfmrzBomaqkFI oMN9o9gKmTe6N7xzCxSltaxKF9bkAu6CzD9aorLrDSc/NgKafkcqzOTecN/Y/cxYjtBd bEM6pvVuPFl7EiwTOP/amwp7qbuZZHHyJcYNU1itgel0OB8SpIlLLC3UbYt8RoIaI7au //O0fLFmAXIah4nbwlj1okuaEBEH9zilfIpIuqG99dt0bbTJaA1bVGrxvGmdEorOAP+1 sz5g== X-Gm-Message-State: APt69E3ZGBNxWEYccTXysC2HCc0/7mWozA8SFrhFav6MKcuXKmLQlGcv R2oO9kkXcnpwRBbN2GccKSMvfu7BHmGwP9+SFe910w== X-Received: by 2002:a02:4187:: with SMTP id n7-v6mr928677jad.86.1529666489751; Fri, 22 Jun 2018 04:21:29 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:bbc7:0:0:0:0:0 with HTTP; Fri, 22 Jun 2018 04:21:29 -0700 (PDT) In-Reply-To: <20180619222921.GA90490@bhelgaas-glaptop.roam.corp.google.com> References: <1526653072-7153-1-git-send-email-okaya@codeaurora.org> <1526653072-7153-2-git-send-email-okaya@codeaurora.org> <20180619222921.GA90490@bhelgaas-glaptop.roam.corp.google.com> From: Ard Biesheuvel Date: Fri, 22 Jun 2018 13:21:29 +0200 Message-ID: Subject: Re: [PATCH V2 2/2] efi/fb: Convert PCI bus address to resource if translated by the bridge To: Bjorn Helgaas Cc: Sinan Kaya , "open list:EFIFB FRAMEBUFFER DRIVER" , Bartlomiej Zolnierkiewicz , linux-arm-msm@vger.kernel.org, Timur Tabi , open list , "open list:FRAMEBUFFER LAYER" , Peter Jones , linux-arm-kernel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20 June 2018 at 00:29, Bjorn Helgaas wrote: > Minor subject nit: From the caller's point of view, we must convert a bus > address to a resource *always* (the caller has no knowledge of "whether it > is translated by the host bridge"). > > On Fri, May 18, 2018 at 10:17:51AM -0400, Sinan Kaya wrote: >> A host bridge is allowed to remap BAR addresses using _TRA attribute in >> _CRS windows. > > Also, _TRA/_CRS are ACPI-specific terms and non-ACPI host bridges can > also do the same sort of translation. Another trivial nit. > >> pci_bus 0000:00: root bus resource [mem 0x80100100000-0x8011fffffff window] (bus address [0x00100000-0x1fffffff]) >> pci 0000:02:00.0: reg 0x10: [mem 0x8011e000000-0x8011effffff] >> >> When a VGA device is behind such a host bridge and the resource is >> translated efifb driver is trying to do ioremap against bus address >> rather than the resource address and is failing to probe. >> >> efifb: probing for efifb >> efifb: cannot reserve video memory at 0x1e000000 >> efifb: framebuffer at 0x1e000000, using 1920k, total 1875k >> efifb: mode is 800x600x32, linelength=3200, pages=1 >> efifb: scrolling: redraw >> efifb: Truecolor: size=8:8:8:8, shift=24:16:8:0 >> >> Use the host bridge offset information to convert bus address to >> resource address in the fixup. >> >> Signed-off-by: Sinan Kaya > > Reviewed-by: Bjorn Helgaas > > Thanks a lot for fixing this! > Apologies for only bringing this up now, but I think this patch is wrong after all. screen_info.lfb_base is supposed to be a CPU address, and so translating it like this is wrong. If you end up with a PCI address here, you have made a mistake in hacking support for PCI outbound translations into UEFI. Other users such as UEFI itself or GRUB will treat this as a CPU physical address as well, so the kernel should not treat it any differently. >> --- >> drivers/video/fbdev/efifb.c | 5 +++++ >> 1 file changed, 5 insertions(+) >> >> diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c >> index 6daac8d..429cc85 100644 >> --- a/drivers/video/fbdev/efifb.c >> +++ b/drivers/video/fbdev/efifb.c >> @@ -431,6 +431,7 @@ static void efifb_fixup_resources(struct pci_dev *dev) >> .end = screen_info.lfb_base + screen_info.lfb_size - 1, >> .flags = IORESOURCE_MEM, >> }; >> + struct pci_bus_region region; >> int i; >> >> if (efifb_pci_dev || screen_info.orig_video_isVGA != VIDEO_TYPE_EFI) >> @@ -442,6 +443,10 @@ static void efifb_fixup_resources(struct pci_dev *dev) >> if (!screen_res.start) >> return; >> >> + region.start = screen_res.start; >> + region.end = screen_res.end; >> + pcibios_bus_to_resource(dev->bus, &screen_res, ®ion); >> + >> for (i = 0; i <= PCI_STD_RESOURCE_END; i++) { >> struct resource *res = &dev->resource[i]; >> >> -- >> 2.7.4 >> >> >> _______________________________________________ >> linux-arm-kernel mailing list >> linux-arm-kernel@lists.infradead.org >> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel