From nobody Sat Jun 26 05:14:58 2021 X-Original-To: freebsd-hackers@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 368A75D7F8B for ; Sat, 26 Jun 2021 05:15:07 +0000 (UTC) (envelope-from saimabaig11@gmail.com) Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GBhrp6Wzlz3GTW for ; Sat, 26 Jun 2021 05:15:06 +0000 (UTC) (envelope-from saimabaig11@gmail.com) Received: by mail-pf1-x42b.google.com with SMTP id d12so1444544pfj.2 for ; Fri, 25 Jun 2021 22:15:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:references:in-reply-to:subject:date:message-id :mime-version:content-transfer-encoding:thread-index :content-language; bh=lTR+ZaKKZEHGjhpdip/Avp2hYAwdlPgq8NyR6x4GlD4=; b=iC4eE/zqDUCD4efgIMHBg4uQaKIycFhaqVXvtNU3RgywN8aiTaky3W/YlzBcWj+bZ0 oEzj/wj9tRnDL0iE+uSF8f7AflDyFCEbl0QN1uX0WlcdQ4VK7ja33PQIpFa7WePmOI70 62B6NCS1rqA8pubagKFKd8HcciFE4NUkt1/9yPNGMraoxOgXw/hYzM3f7wiU1elCihNr N+zt9sWv5mA/NaInaZoCvaHzIc2RLGi0RurymJX4YtXVkjLVc9U2XMpKdiZa5CfTPVIC l6lcxD60Ob7NVSPl5519QNRbXOp16/n7OBi0rr5AObIJ2YXY1Yqc3vHwjCfyujC+uC2l p0XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:references:in-reply-to:subject:date :message-id:mime-version:content-transfer-encoding:thread-index :content-language; bh=lTR+ZaKKZEHGjhpdip/Avp2hYAwdlPgq8NyR6x4GlD4=; b=WDMkpE2U7eHB3YGv3PNRZcFv9yPFhgAGFRC3eNEf1Of7/PaOTf0vbGsOOs59DwEBhq VGQt2cycQTRpynBxjeIC59o3bjabwDdjnrJlG+8SEK6aoKqQ9rLNsD8S6tpZMVfzkB2q IWXUIXGvvfb9PtpkQ8W17NrBISdf4CruH0u4TyPyGmKqRF7HESJ5Ywd+g+k/YdAGt/hy Q6iR7AqeAQWKdF8FQ8NMpbwo6V02qNdqSF6yfQxzR7bhrIewSHLpps2Jx7P8tXfai8g0 YFLCJ9CQTWQAg6k/QO4EWmn+FNOMeXgfflqdBsrKdV+XU/MFet94LyHQi/5Wcb/3nCte PDZw== X-Gm-Message-State: AOAM531tXw8XZFGVnP1vSsGNeQRl8xQ90W/1ttfLfwzW0+y1CEAf0Ky/ uiXhVqBFJiubiXeFhq2KdKYccI9A81c/+g== X-Google-Smtp-Source: ABdhPJypswdBvb2LYSQy5m4NOAnBlM8I5U1Ov4bceLxJgWhjIUKuwDh8gighXQXnGyiL0OSJ6wXqrw== X-Received: by 2002:a05:6a00:23d0:b029:2de:c1a2:f1e with SMTP id g16-20020a056a0023d0b02902dec1a20f1emr14127633pfc.60.1624684505054; Fri, 25 Jun 2021 22:15:05 -0700 (PDT) Received: from ABDESKTOP ([103.208.71.171]) by smtp.gmail.com with ESMTPSA id 10sm7347296pfh.174.2021.06.25.22.15.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Jun 2021 22:15:04 -0700 (PDT) From: To: "'Warner Losh'" Cc: "'FreeBSD Hackers'" References: <003201d76a47$dae98bc0$90bca340$@gmail.com> In-Reply-To: Subject: RE: PCI probing in the kernel Date: Sat, 26 Jun 2021 10:44:58 +0530 Message-ID: <004401d76a4a$393dbaf0$abb930d0$@gmail.com> List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQHO02fCKo5d0HP9TDmrcKSdSiVnugEaiQsXqy4YRJA= Content-Language: en-us X-Rspamd-Queue-Id: 4GBhrp6Wzlz3GTW X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N It specifically says *em* probing and then it calls the *em_register* = function repeatedly which is the registration routine that the em driver = defines as part of its initialization. This is whats confusing me as to = why is it repeatedly calling these functions for a specific module = repeatedly =20 From: Warner Losh =20 Sent: Saturday, June 26, 2021 10:40 AM To: saimabaig11@gmail.com Cc: FreeBSD Hackers Subject: Re: PCI probing in the kernel =20 =20 =20 On Fri, Jun 25, 2021 at 10:59 PM > wrote: My question relates to how does the kernel go about its business of discovering PCI devices (after boot time) . I am loading the e1000(em) driver by kldloading the `if_em` module. The kernel seems to be calling = the probe routine multiple times. So the log below includes messages coming = from the kernel and also includes my own debug logs. ``` Jun 25 11:16:45 FreeBSD12 kernel: em probing Jun 25 11:16:45 FreeBSD12 syslogd: last message repeated 5 times Jun 25 11:16:45 FreeBSD12 kernel: em0: +++ Calling em_register Jun 25 11:16:45 FreeBSD12 kernel: em probing Jun 25 11:16:45 FreeBSD12 syslogd: last message repeated 5 times Jun 25 11:16:45 FreeBSD12 kernel: em0: +++ Calling em_register Jun 25 11:16:45 FreeBSD12 kernel: em probing Jun 25 11:16:45 FreeBSD12 kernel: em0: +++ Calling em_register Jun 25 11:16:45 FreeBSD12 kernel: em0: port 0x2000-0x203f mem 0xfd5c0000-0xfd5dffff,0xfdff0000-0xfdffffff irq 19 at device 1.0 on pci2 Jun 25 11:16:45 FreeBSD12 kernel: em attaching Jun 25 11:16:45 FreeBSD12 kernel: em0: +++ Calling em_register Jun 25 11:17:34 FreeBSD12 kernel: em0: Using 2048 TX descriptors and = 2048 RX descriptors Jun 25 11:17:35 FreeBSD12 kernel: em probing Jun 25 11:17:35 FreeBSD12 syslogd: last message repeated 5 times Jun 25 11:17:35 FreeBSD12 kernel: em1: +++ Calling em_register Jun 25 11:17:35 FreeBSD12 kernel: em probing Jun 25 11:17:36 FreeBSD12 kernel: Base =3D 5ee7e000, Length =3D 8000 ``` It seems that the `probe->register` sequence seems to be getting = repeated multiple times until the adapter is identified properly and its = resources allocated. Isn't multiple registration a cause of concern? Or may = something is wrong with the way I think. May be I am not getting it right? Could someone elaborate? =20 When you load a driver, we call probe on all the devices on the bus that = don't yet have drivers. I believe you are seeing this. The probe routine tries = a bunch of different devices until finding the NIC that doesn't have a driver. = It's completely normal and ordinary. =20 Warner