From nobody Tue Nov 30 10:36:36 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 3E15E18B468F; Tue, 30 Nov 2021 10:36:48 +0000 (UTC) (envelope-from manu@bidouilliste.com) Received: from mx.blih.net (mail.blih.net [212.83.155.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mx.blih.net", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J3JYW4Dhkz3QnX; Tue, 30 Nov 2021 10:36:47 +0000 (UTC) (envelope-from manu@bidouilliste.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bidouilliste.com; s=mx; t=1638268599; 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=WnHzSwvS7vgNngK+j8T207hVByxcWKAsBOaYaEEVHno=; b=AlfAvfGeQUtGY8w3EPM9udLpXfNS0zNSJxiUYwwLbrpTBM/RUkPDxhUOMKrccDJ7qQtAcT ZHytAxXb7zLM6rSfoQDNgveEnUNbjT5P33UhMTF5lNE+3b2HFQWMI6DNYr0N4Yj3bIka82 SUC+SosqbutpeK5YzwW7efO8Ly8lSpU= Received: from skull.home.blih.net (lfbn-idf2-1-1163-183.w90-92.abo.wanadoo.fr [90.92.222.183]) by mx.blih.net (OpenSMTPD) with ESMTPSA id a6bcb01f (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 30 Nov 2021 10:36:39 +0000 (UTC) Date: Tue, 30 Nov 2021 11:36:36 +0100 From: Emmanuel Vadot To: Wei Hu Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: Re: git: d11e9de955ea - stable/13 - Hyper-V: vPCI: Prepopulate device bars Message-Id: <20211130113636.5b2d51dca869da19b32e47b7@bidouilliste.com> In-Reply-To: <202111301032.1AUAWfal073106@gitrepo.freebsd.org> References: <202111301032.1AUAWfal073106@gitrepo.freebsd.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; amd64-portbld-freebsd14.0) List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4J3JYW4Dhkz3QnX X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N On Tue, 30 Nov 2021 10:32:41 GMT Wei Hu wrote: > The branch stable/13 has been updated by whu: > > URL: https://cgit.FreeBSD.org/src/commit/?id=d11e9de955ea01fe01dce58c7eb090fe0352bced > > commit d11e9de955ea01fe01dce58c7eb090fe0352bced > Author: Wei Hu > AuthorDate: 2021-11-27 06:42:34 +0000 > Commit: Wei Hu > CommitDate: 2021-11-30 07:43:32 +0000 > > Hyper-V: vPCI: Prepopulate device bars > > In recent Hyper-V releases on Windows Server 2022, vPCI code does not > initialize the last 4 bit of device bar registers. This behavior change > could result weird problems cuasing PCI code failure when configuring > bars. > > Just write all 1's to those bars whose probed values are not the same > as current read ones. This seems to make Hyper-V vPCI and > pci_write_bar() to cooperate correctly on these releases. > > Reported by: khng@freebsd.org > Tested by: khng@freebsd.org > MFC after: 2 weeks Looks more 3 days to me. Also kib@ asked you a question for this commit, it would be more polite to answer him instead of mfc this 3 days after. Cheers, > Sponsored by: Microsoft > > (cherry picked from commit 75412a521f60d4b0393c730ffb284e7c6ff9d2de) > --- > sys/dev/hyperv/pcib/vmbus_pcib.c | 43 ++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 43 insertions(+) > > diff --git a/sys/dev/hyperv/pcib/vmbus_pcib.c b/sys/dev/hyperv/pcib/vmbus_pcib.c > index 72e430c946db..c7df32044678 100644 > --- a/sys/dev/hyperv/pcib/vmbus_pcib.c > +++ b/sys/dev/hyperv/pcib/vmbus_pcib.c > @@ -1356,6 +1356,47 @@ _hv_pcifront_write_config(struct hv_pci_dev *hpdev, int where, int size, > } > } > > +/* > + * The vPCI in some Hyper-V releases do not initialize the last 4 > + * bit of BAR registers. This could result weird problems causing PCI > + * code fail to configure BAR correctly. > + * > + * Just write all 1's to those BARs whose probed values are not zero. > + * This seems to make the Hyper-V vPCI and pci_write_bar() to cooperate > + * correctly. > + */ > + > +static void > +vmbus_pcib_prepopulate_bars(struct hv_pcibus *hbus) > +{ > + struct hv_pci_dev *hpdev; > + int i; > + > + mtx_lock(&hbus->device_list_lock); > + TAILQ_FOREACH(hpdev, &hbus->children, link) { > + for (i = 0; i < 6; i++) { > + /* Ignore empty bar */ > + if (hpdev->probed_bar[i] == 0) > + continue; > + > + uint32_t bar_val = 0; > + > + _hv_pcifront_read_config(hpdev, PCIR_BAR(i), > + 4, &bar_val); > + > + if (hpdev->probed_bar[i] != bar_val) { > + if (bootverbose) > + printf("vmbus_pcib: initialize bar %d " > + "by writing all 1s\n", i); > + > + _hv_pcifront_write_config(hpdev, PCIR_BAR(i), > + 4, 0xffffffff); > + } > + } > + } > + mtx_unlock(&hbus->device_list_lock); > +} > + > static void > vmbus_pcib_set_detaching(void *arg, int pending __unused) > { > @@ -1479,6 +1520,8 @@ vmbus_pcib_attach(device_t dev) > if (ret) > goto vmbus_close; > > + vmbus_pcib_prepopulate_bars(hbus); > + > hbus->pci_bus = device_add_child(dev, "pci", -1); > if (!hbus->pci_bus) { > device_printf(dev, "failed to create pci bus\n"); -- Emmanuel Vadot