From owner-freebsd-drivers@freebsd.org Wed Jun 3 11:21:03 2020 Return-Path: Delivered-To: freebsd-drivers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2AEF6334148; Wed, 3 Jun 2020 11:21:03 +0000 (UTC) (envelope-from rajfbsd@gmail.com) Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) (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 49cRL62qWQz481m; Wed, 3 Jun 2020 11:21:02 +0000 (UTC) (envelope-from rajfbsd@gmail.com) Received: by mail-wr1-x42c.google.com with SMTP id t18so1934555wru.6; Wed, 03 Jun 2020 04:21:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=3+3zxVrq3K3bbogOKRzdRhvic6Chh3MZWACfD81N6wk=; b=TI8Ci2FELKtsCzrCsDhQVbtJkq2BlAN6w7RP/4Y1KCofCv9MpXWnqBxIsxgsl/AJv2 cFCuau1gMXvLMvI9WKiLRSa4ulT+rm2gW+FHliGq1jqOd315BampCQNUHpIRYWHvntXl 07AXB4ldBn2YyDe6AQaavtToLlxveR5/Vq9/5GikXSRoT6Cnikoqx6jUx8T5O9rl8CcN ttw2zWr3buRTk6w+CemKivd7w3r1NUIig4OjOUH9oAWrl4Fs0NSdqMJUYGjvY8C5oJaB geNKdE4Uye6flgTRZOJo3QSXJbT0bpyVR8QchPTOUqM/jTGJyCwISAcVwVvebYaV0gjY xu8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=3+3zxVrq3K3bbogOKRzdRhvic6Chh3MZWACfD81N6wk=; b=KQxEZf2kt/FwYWwwXbRWz8GG+N4adaELryzodSOY6Tlxp3RV//56t59p1pwzwqtHpg M7j0uCYvQB0DPSQbzXtMIECuFvOgRchOcTCCv/Bsk0anq5PhToVilND006rsHIz55krI xlkr0nbpSBQ8QPNpfef2PRknthevoyZKHIEBFISzfmBr6Q3dDJNaw0coWUz0Rt7kvz4U UqCfaMMGpixGtaJOgXgZUkd4ojz8vyZJCQo4uu6LNh2QLHBReL57wYStC0LyLZXEOdUJ 2MNd/0KG/ULo0McJx/OaBaz5yGji0/IdfCL/prCOMPGG1Uy9Cx2+4zhRHNTsjH9YQdgI pSmA== X-Gm-Message-State: AOAM530pTeoIbLdpVR3fIoXlO2FR4wbK+9qd8eqQcOShPNz7fnYTrTI9 0XQ4Yq70mCGnpyRzO13bAjbNnA3Nree7WQbLp3xzhKXj X-Google-Smtp-Source: ABdhPJx7Gie+fuNgncfi66VkvHGOOYmoL1Upcb3gGstORIDJghnpwgOjU9cfyKCoDoSbONJBXE9cFd2yMZEysQEnFGk= X-Received: by 2002:a5d:67c8:: with SMTP id n8mr19828649wrw.343.1591183260552; Wed, 03 Jun 2020 04:21:00 -0700 (PDT) MIME-Version: 1.0 From: Rajesh Kumar Date: Wed, 3 Jun 2020 16:50:49 +0530 Message-ID: Subject: Can we hook a device as device to two different parent devices? To: freebsd-drivers@freebsd.org, FreeBSD Hackers X-Rspamd-Queue-Id: 49cRL62qWQz481m X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=TI8Ci2FE; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of rajfbsd@gmail.com designates 2a00:1450:4864:20::42c as permitted sender) smtp.mailfrom=rajfbsd@gmail.com X-Spamd-Result: default: False [-2.47 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.97)[-0.966]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36:c]; FREEMAIL_FROM(0.00)[gmail.com]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.05)[-1.046]; DKIM_TRACE(0.00)[gmail.com:+]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::42c:from]; NEURAL_HAM_SHORT(-0.46)[-0.457]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; SUBJECT_ENDS_QUESTION(1.00)[]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; FREEMAIL_ENVFROM(0.00)[gmail.com]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.33 X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Jun 2020 11:21:03 -0000 Hi, Is it really possible to declare a module with two parents? Like the following declarations in the same driver. devclass_t test_dev_devclass; static DEFINE_CLASS_0(test_dev, test_dev_driver, test_dev_methods, sizeof(struct test_dev_ctx)); DRIVER_MODULE(test_dev, *device1*, test_dev_driver, test_dev_devclass, NULL, NULL); DRIVER_MODULE(test_dev, *device2*, test_dev_driver, test_dev_devclass, NULL, NULL); I see similar references in other drivers attaching to both simpleus and ofwbus. So, If it's possible, how to get the reference for both the parents? device_get_parent(test_dev) will give reference of one parent only right, so how to get the reference of the desired parent? Thanks, Rajesh. From owner-freebsd-drivers@freebsd.org Wed Jun 3 14:29:31 2020 Return-Path: Delivered-To: freebsd-drivers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9394033891F; Wed, 3 Jun 2020 14:29:31 +0000 (UTC) (envelope-from agapon@gmail.com) Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) (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 49cWWZ5K9cz4VKv; Wed, 3 Jun 2020 14:29:30 +0000 (UTC) (envelope-from agapon@gmail.com) Received: by mail-lj1-f171.google.com with SMTP id n24so2963716lji.10; Wed, 03 Jun 2020 07:29:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=noDJMEvzC2iEAllj39WPfqYMQBvOFLjWUSmbYbK3Ukw=; b=kpgt4D2fAkc2fXVrnmi8n08JflZF4iAxJVP5BzW0U1UO5h0C/x3rjoEG7kwex7l0mb 57vI68xyZAZAwhEw8jRkRnF4APNz7+vkOGltMcisfLJAzhIuxpHK11Wv8LD2GpI20FYf 1eZWG1pJYDuBHn5bcjVJsrON9WaZaNx1CGkpYvJFijRk6TKMzRMnj2GT75P8TPURwhXn vh7Mtjws+Q9uEggnz3uKLiCm1uu+7SnSyA7MY6pFYI57Dz8YpsrxiVE47ACTtfiKAI3P Ywojy2FC8pFmT18Z+T96/9wKtixN/kaMdR88hT6A3/xq2h6ldQoHm3LKwsyfV7iOdjKB ac8A== X-Gm-Message-State: AOAM531/VRmPZEMGz+Y/BKOwXgFc2fUxxEdBmehY7FfheSERwZX75KEb DamHZqjqObrg+8E1fDICkJVCGc3t X-Google-Smtp-Source: ABdhPJz3Nh5xq2O1hdVY/f0TVBGvlauRLeeDtui5VMZkYCIgh5mmGFJ8VyckgH76mTQTzJkcu1SLdg== X-Received: by 2002:a2e:98cb:: with SMTP id s11mr240725ljj.402.1591194568774; Wed, 03 Jun 2020 07:29:28 -0700 (PDT) Received: from [192.168.0.88] (east.meadow.volia.net. [93.72.151.96]) by smtp.googlemail.com with ESMTPSA id 15sm507516ljw.46.2020.06.03.07.29.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 03 Jun 2020 07:29:27 -0700 (PDT) Subject: Re: Can we hook a device as device to two different parent devices? To: Rajesh Kumar , freebsd-drivers@freebsd.org, FreeBSD Hackers References: From: Andriy Gapon Openpgp: preference=signencrypt Autocrypt: addr=avg@FreeBSD.org; prefer-encrypt=mutual; keydata= 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 Message-ID: Date: Wed, 3 Jun 2020 17:29:26 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:60.0) Gecko/20100101 Firefox/60.0 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 49cWWZ5K9cz4VKv X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of agapon@gmail.com designates 209.85.208.171 as permitted sender) smtp.mailfrom=agapon@gmail.com X-Spamd-Result: default: False [-0.71 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; RCVD_COUNT_THREE(0.00)[3]; NEURAL_HAM_SHORT(-0.07)[-0.074]; FREEMAIL_TO(0.00)[gmail.com,freebsd.org]; FORGED_SENDER(0.30)[avg@FreeBSD.org,agapon@gmail.com]; RECEIVED_SPAMHAUS_PBL(0.00)[93.72.151.96:received]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; SUBJECT_ENDS_QUESTION(1.00)[]; MID_RHS_MATCH_FROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; FROM_NEQ_ENVFROM(0.00)[avg@FreeBSD.org,agapon@gmail.com]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; NEURAL_HAM_MEDIUM(-0.84)[-0.839]; NEURAL_HAM_LONG(-0.79)[-0.794]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[FreeBSD.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[209.85.208.171:from]; RWL_MAILSPIKE_POSSIBLE(0.00)[209.85.208.171:from]; RCVD_TLS_ALL(0.00)[] X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Jun 2020 14:29:31 -0000 On 03/06/2020 14:20, Rajesh Kumar wrote: > Hi, > > Is it really possible to declare a module with two parents? Like the > following declarations in the same driver. > > devclass_t test_dev_devclass; > static DEFINE_CLASS_0(test_dev, test_dev_driver, test_dev_methods, > sizeof(struct test_dev_ctx)); > DRIVER_MODULE(test_dev, *device1*, test_dev_driver, test_dev_devclass, > NULL, NULL); > DRIVER_MODULE(test_dev, *device2*, test_dev_driver, test_dev_devclass, > NULL, NULL); > > I see similar references in other drivers attaching to both simpleus and > ofwbus. So, If it's possible, how to get the reference for both the > parents? device_get_parent(test_dev) will give reference of one parent > only right, so how to get the reference of the desired parent? A device can have only one parent. The declaration you quoted describes a _driver_ that can attach to devices hanging off two different buses. They would still be different devices. -- Andriy Gapon From owner-freebsd-drivers@freebsd.org Wed Jun 3 15:29:20 2020 Return-Path: Delivered-To: freebsd-drivers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DDB7D339AB8 for ; Wed, 3 Jun 2020 15:29:20 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qk1-x734.google.com (mail-qk1-x734.google.com [IPv6:2607:f8b0:4864:20::734]) (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 49cXrb6rYzz4dBW for ; Wed, 3 Jun 2020 15:29:19 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qk1-x734.google.com with SMTP id w3so2525098qkb.6 for ; Wed, 03 Jun 2020 08:29:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GrgyiUIrwkq+y80N3Xo5bFrdfICx0GeEPNszr6b9zqQ=; b=qCEjcQ0XtjmUbz/w1Bf1RC+CEEtijl+eQZkfjUzDWshUEhCHq2HoI32tL+xo2t0DCv ZiHc/QQbLEWtlTCaVVwVoTjPCSNab2Y5aX89ZHKeZHbehGcA5wSatviOnI/+x0BCbkqC DkUAsoIUh9ubjstWB9ajBVB9+wp7D1uO+arBo+Qs/xsZTdnn15VEgtbRZEpOqDQDUBtX /b3IF0vbDgNB0VaWdyqCuwX4uSl5TZWLQdkhaC/x3Vcz7lHPdMyJYkyE9MsLRnV+MRf+ odZ1P3NjH8j8ogtmd4Zsyjinp3VERkSIpJD8LNZWvgzLtvYhc2XmrVEWC9JrIoPVA3TR 8IGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GrgyiUIrwkq+y80N3Xo5bFrdfICx0GeEPNszr6b9zqQ=; b=OmOZ24+Uc0swBhRDadNeNHS6SYKTfA/M3yQKGl1KN3aXzRTyV9+MCqNmhozrGRR/1y OkMYpWo12lx8AcZl0Yca8zRpVyKbfvLuTlh2fAKL+99rrjAGEvULeVgQZQ6HdYhK5adX yHYpY8Q3zeoz7w1AnVS2+nWD06p55CK+0EEO88uUp4DnCNAagzd4un13gT4DZYKEK1hb PfAfZw0KspO1RbpbcTaaEVD+od/KaTuOFDPhzi1KqDzSRY5jQwY7H+tGtISAFSSeLAnw theiQFqhQH28ZJXzu43Z9jqSwL9gaSwlvG7MJy0fBmC4HnTW82xc2+SMIsQNhD9gzXSE qsDg== X-Gm-Message-State: AOAM532Pjzz4CgZI2sUTDFaD/5udgO9yNbR1e3z5qr1jz/dTQN4vipRI pG8KQDRC2eCjbVxH5+tea5lAl2bp/LUiFXBAgVpWHDiC X-Google-Smtp-Source: ABdhPJwoKtcQTwJYw+WFkYl2INiy6ZlW912D6iNvYMcfUzw4Yj40FNuax6CAhdusb/c/oRN2FQ2lEhfVODNp0Wsfb88= X-Received: by 2002:a37:9f09:: with SMTP id i9mr216086qke.60.1591198158502; Wed, 03 Jun 2020 08:29:18 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Warner Losh Date: Wed, 3 Jun 2020 09:29:06 -0600 Message-ID: Subject: Re: Can we hook a device as device to two different parent devices? To: Andriy Gapon Cc: Rajesh Kumar , freebsd-drivers@freebsd.org, FreeBSD Hackers X-Rspamd-Queue-Id: 49cXrb6rYzz4dBW X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bsdimp-com.20150623.gappssmtp.com header.s=20150623 header.b=qCEjcQ0X; dmarc=none; spf=none (mx1.freebsd.org: domain of wlosh@bsdimp.com has no SPF policy when checking 2607:f8b0:4864:20::734) smtp.mailfrom=wlosh@bsdimp.com X-Spamd-Result: default: False [-1.97 / 15.00]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[bsdimp-com.20150623.gappssmtp.com:s=20150623]; NEURAL_HAM_MEDIUM(-0.98)[-0.976]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; TO_DN_SOME(0.00)[]; NEURAL_HAM_LONG(-1.03)[-1.028]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-drivers@freebsd.org]; DMARC_NA(0.00)[bsdimp.com]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[bsdimp-com.20150623.gappssmtp.com:+]; NEURAL_HAM_SHORT(-0.97)[-0.971]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::734:from]; R_SPF_NA(0.00)[no SPF record]; FORGED_SENDER(0.30)[imp@bsdimp.com,wlosh@bsdimp.com]; MIME_TRACE(0.00)[0:+,1:+,2:~]; SUBJECT_ENDS_QUESTION(1.00)[]; RCVD_COUNT_TWO(0.00)[2]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[imp@bsdimp.com,wlosh@bsdimp.com]; FREEMAIL_CC(0.00)[gmail.com,freebsd.org] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.33 X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Jun 2020 15:29:20 -0000 On Wed, Jun 3, 2020, 8:29 AM Andriy Gapon wrote: > On 03/06/2020 14:20, Rajesh Kumar wrote: > > Hi, > > > > Is it really possible to declare a module with two parents? Like the > > following declarations in the same driver. > > > > devclass_t test_dev_devclass; > > static DEFINE_CLASS_0(test_dev, test_dev_driver, test_dev_methods, > > sizeof(struct test_dev_ctx)); > > DRIVER_MODULE(test_dev, *device1*, test_dev_driver, test_dev_devclass, > > NULL, NULL); > > DRIVER_MODULE(test_dev, *device2*, test_dev_driver, test_dev_devclass, > > NULL, NULL); > > > > I see similar references in other drivers attaching to both simpleus and > > ofwbus. So, If it's possible, how to get the reference for both the > > parents? device_get_parent(test_dev) will give reference of one parent > > only right, so how to get the reference of the desired parent? > > A device can have only one parent. > The declaration you quoted describes a _driver_ that can attach to devices > hanging off two different buses. They would still be different devices. > Yes. You can have a driver attach to multiple bus types, but each instance has a unique parent one exactly on of them. If you need to talk to other devices, you'll need to find them by name or other means. Warner > -- > Andriy Gapon > _______________________________________________ > freebsd-drivers@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-drivers > To unsubscribe, send any mail to "freebsd-drivers-unsubscribe@freebsd.org" > From owner-freebsd-drivers@freebsd.org Thu Jun 4 18:31:36 2020 Return-Path: Delivered-To: freebsd-drivers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6FAA532C24C; Thu, 4 Jun 2020 18:31:36 +0000 (UTC) (envelope-from rajfbsd@gmail.com) Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) (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 49dDrR2Vkpz4Vcw; Thu, 4 Jun 2020 18:31:35 +0000 (UTC) (envelope-from rajfbsd@gmail.com) Received: by mail-wr1-x42f.google.com with SMTP id y17so7184216wrn.11; Thu, 04 Jun 2020 11:31:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4w0fxpur3RWk2sa3+8JZgKq98Ncv47d1Qg1yZnzJfus=; b=AvNI+YLKMCrsAO9NWaQ7D2Kre26+ITgEPrGmoZ9a0endBxUtFWZ7gCqF+Xp2T/U0nf n3pkQfpUREnZtFhdkchJxkcUl1iJciyK08NKDTWERQT6pw84xJq/JmFhskvEO7C8fdV8 uQPTb0VAynPnsNGREn6TOZ4AsUEeih5LmzHGHLTpniXMGz2F2GGJpTa76TSPXnzgivjy 66EIE6VwIqkmbxh4VSz1hpJOX/RdVqlL9a2FdXaeJbxQWuzdgz2baCdz8EIz3dgjQHJf kdhDGiowlUSjA3d6GBhSBHPaTMsnBriH6VeebxiwthbqKRiW1xuQXLo3X9lu0wDdhTS9 nDBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4w0fxpur3RWk2sa3+8JZgKq98Ncv47d1Qg1yZnzJfus=; b=VG0kwMy4fxExWCuB28UFPPRp+EStR0lmyFkaWHGeaF66hH3vdiQBqCXQjK3mjTxGUV AbrqqQw1yrGxEMdSx+rcklsJgb//GtYaM3TQJYaK1owH7wUoSlJaS5kU5483Ci7tBzoT 4CJRoeTD78csLgBAxfnMf6+FKEeumG+4TdbVhQtB4nzCIQDOQ9C2izZiuiZbjggD3i/U g76PldEr5lvqN1icQDYThVgAjpLF6u6WTHvAP4rwOK5jq0l414cPqNugoYDSAN+vHIu9 adQN97XM2yRk8WJoSFmVBZUc/EOaa602TFT1Cd5qLpmu26MArm3dXkFZC1YJEYv/JF7Z yXCQ== X-Gm-Message-State: AOAM532qmQjShx68QvpV74dsw1tPnt76XtCwU4UQqGOHx6SAf2Y4ghA2 9XCV64MPTLfW2ZyHPIJgMuSlg/sxWj85eZ6E+L8xHt/M X-Google-Smtp-Source: ABdhPJxLFPUz5mqiLffZWDnFdAce7HZd9Dfe00eJqcYgMJzrS6fE6elUTidbidIEMmPB8h0pupUYB32v5LXOce1QzKk= X-Received: by 2002:adf:e545:: with SMTP id z5mr5462800wrm.89.1591295493871; Thu, 04 Jun 2020 11:31:33 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Rajesh Kumar Date: Fri, 5 Jun 2020 00:01:22 +0530 Message-ID: Subject: Re: Can we hook a device as device to two different parent devices? To: Warner Losh Cc: Andriy Gapon , freebsd-drivers@freebsd.org, FreeBSD Hackers X-Rspamd-Queue-Id: 49dDrR2Vkpz4Vcw X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=AvNI+YLK; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of rajfbsd@gmail.com designates 2a00:1450:4864:20::42f as permitted sender) smtp.mailfrom=rajfbsd@gmail.com X-Spamd-Result: default: False [-1.88 / 15.00]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; NEURAL_HAM_MEDIUM(-0.99)[-0.995]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FREEMAIL_FROM(0.00)[gmail.com]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; NEURAL_SPAM_SHORT(0.07)[0.068]; NEURAL_HAM_LONG(-0.95)[-0.951]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::42f:from]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; SUBJECT_ENDS_QUESTION(1.00)[]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; FREEMAIL_ENVFROM(0.00)[gmail.com]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.33 X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jun 2020 18:31:36 -0000 Thanks Warner and Andriy for your answers. Having said they are two separate instances, if the child driver calls the interface of two parents as below device1_interface(child_dev), then device_get_parent(child_dev) in the device1 interface will return device1 reference device2_interface(child_dev), then device_get_parent(child_dev) in the device2 interface will return device2 reference Is that right? Thanks, Rajesh. On Wed, Jun 3, 2020 at 8:59 PM Warner Losh wrote: > > > On Wed, Jun 3, 2020, 8:29 AM Andriy Gapon wrote: > >> On 03/06/2020 14:20, Rajesh Kumar wrote: >> > Hi, >> > >> > Is it really possible to declare a module with two parents? Like the >> > following declarations in the same driver. >> > >> > devclass_t test_dev_devclass; >> > static DEFINE_CLASS_0(test_dev, test_dev_driver, test_dev_methods, >> > sizeof(struct test_dev_ctx)); >> > DRIVER_MODULE(test_dev, *device1*, test_dev_driver, test_dev_devclass, >> > NULL, NULL); >> > DRIVER_MODULE(test_dev, *device2*, test_dev_driver, test_dev_devclass, >> > NULL, NULL); >> > >> > I see similar references in other drivers attaching to both simpleus and >> > ofwbus. So, If it's possible, how to get the reference for both the >> > parents? device_get_parent(test_dev) will give reference of one parent >> > only right, so how to get the reference of the desired parent? >> >> A device can have only one parent. >> The declaration you quoted describes a _driver_ that can attach to devices >> hanging off two different buses. They would still be different devices. >> > > Yes. You can have a driver attach to multiple bus types, but each instance > has a unique parent one exactly on of them. > > If you need to talk to other devices, you'll need to find them by name or > other means. > > Warner > > > >> -- >> Andriy Gapon >> _______________________________________________ >> freebsd-drivers@freebsd.org mailing list >> https://lists.freebsd.org/mailman/listinfo/freebsd-drivers >> To unsubscribe, send any mail to "freebsd-drivers-unsubscribe@freebsd.org >> " >> > From owner-freebsd-drivers@freebsd.org Thu Jun 4 19:39:38 2020 Return-Path: Delivered-To: freebsd-drivers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 95A8332F28A for ; Thu, 4 Jun 2020 19:39:38 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) (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 49dGLx4lDxz4frG for ; Thu, 4 Jun 2020 19:39:37 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qt1-x82a.google.com with SMTP id w9so6354994qtv.3 for ; Thu, 04 Jun 2020 12:39:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4mmpTLBUXlHbgG8nq1J56S8CibDRwEOOA1UUcOKtaec=; b=atqXz9NFzUbGAjr77O60+ZAmypwkilFOVM1+jEpjF4PvaZVBomjToGvcvLQC43P3fS nK8wCtPaYLjxe7tpKFCjV6SaeVNW8Rj6kRUMna8TXczC4xAdxhuHEm+9xZHZTHaNouee WfwXehkFvmTNxqqf17uyB1veLd7tWz7doW5j7wIfX8ivTopjtK5rMbSky3unlIPcoUbM 78oAqFaK+UzWDSXiFiTcD11BBjaz+/ej2PYLMdB2C3IchqFXfyvQI9bY3u0gfQrMIoLL hKmt4iVBpma+O+UL9cReiY30q3ySaf/HPbKvT8IOadHYlBRRzZJg6sbpBT/S8wfVikF0 cIVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4mmpTLBUXlHbgG8nq1J56S8CibDRwEOOA1UUcOKtaec=; b=smmP+5g+TUHMgVyH89PT0JOPQs+i+jEQjRhpYnSTu8oh0kc3Vi4azlv5stX+G4QfJF dxLeS0Vz5mQOHWRlIXCLkNiiNjfYyTNKodydwmOF0fwMAjNzatb4avIL3CeH+TaQwTzk iEnyCCJCBRMgA07bfjHBBAnAaIG5NpUsAdcKdutZbv+OEmqaAaqebBIszjtkxF5J4ZA2 GI0XxwH4YpBCgJaRCzSqcvRWHq91sc2cqHLFMViz61TX2etlLA2dyoiTb68KbWBh2PpM 8MbL8INTnUa4zkgKCcacuenAbxjL6i2L0+Los1x6WOwj16mFrouwaSHhnsgIe/4yun9O wKvg== X-Gm-Message-State: AOAM5327DTpILPRgb/aPATYbBoi5+ZcZC6/LYJA+EWCoWq8qmiFzdkZD zm81p6snUjxJoGrO/qM/wtwTuQIlhnMWkEcmjH6mXg== X-Google-Smtp-Source: ABdhPJwCv9/RW/HTTU+Kp+20mak2zHHsXRHXkLH8PuFvyU4EbXnyCaPZkA9T6Ml6yr8CepKLSlopiLIqiSUJ9+FI7zQ= X-Received: by 2002:ac8:192c:: with SMTP id t41mr5953313qtj.32.1591299576374; Thu, 04 Jun 2020 12:39:36 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Warner Losh Date: Thu, 4 Jun 2020 13:39:25 -0600 Message-ID: Subject: Re: Can we hook a device as device to two different parent devices? To: Rajesh Kumar Cc: Andriy Gapon , freebsd-drivers@freebsd.org, FreeBSD Hackers X-Rspamd-Queue-Id: 49dGLx4lDxz4frG X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bsdimp-com.20150623.gappssmtp.com header.s=20150623 header.b=atqXz9NF; dmarc=none; spf=none (mx1.freebsd.org: domain of wlosh@bsdimp.com has no SPF policy when checking 2607:f8b0:4864:20::82a) smtp.mailfrom=wlosh@bsdimp.com X-Spamd-Result: default: False [-0.64 / 15.00]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[bsdimp-com.20150623.gappssmtp.com:s=20150623]; NEURAL_HAM_MEDIUM(-0.89)[-0.895]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; TO_DN_SOME(0.00)[]; NEURAL_HAM_LONG(-0.96)[-0.958]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-drivers@freebsd.org]; DMARC_NA(0.00)[bsdimp.com]; NEURAL_SPAM_SHORT(0.21)[0.209]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[bsdimp-com.20150623.gappssmtp.com:+]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::82a:from]; R_SPF_NA(0.00)[no SPF record]; FREEMAIL_TO(0.00)[gmail.com]; FORGED_SENDER(0.30)[imp@bsdimp.com,wlosh@bsdimp.com]; MIME_TRACE(0.00)[0:+,1:+,2:~]; SUBJECT_ENDS_QUESTION(1.00)[]; RCVD_COUNT_TWO(0.00)[2]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[imp@bsdimp.com,wlosh@bsdimp.com] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.33 X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jun 2020 19:39:38 -0000 On Thu, Jun 4, 2020 at 12:31 PM Rajesh Kumar wrote: > Thanks Warner and Andriy for your answers. > > Having said they are two separate instances, if the child driver calls the > interface of two parents as below > device1_interface(child_dev), then device_get_parent(child_dev) in the > device1 interface will return device1 reference > device2_interface(child_dev), then device_get_parent(child_dev) in the > device2 interface will return device2 reference > > Is that right? > Yes. That's correct. For each bus instance, we loop through the possible drivers that attach to that bus looking for each device looking for drivers that will probe successfully. If you have multiple instances, or instances of different kinds of busses, what you say will hold true. Warner > Thanks, > Rajesh. > > > On Wed, Jun 3, 2020 at 8:59 PM Warner Losh wrote: > >> >> >> On Wed, Jun 3, 2020, 8:29 AM Andriy Gapon wrote: >> >>> On 03/06/2020 14:20, Rajesh Kumar wrote: >>> > Hi, >>> > >>> > Is it really possible to declare a module with two parents? Like the >>> > following declarations in the same driver. >>> > >>> > devclass_t test_dev_devclass; >>> > static DEFINE_CLASS_0(test_dev, test_dev_driver, test_dev_methods, >>> > sizeof(struct test_dev_ctx)); >>> > DRIVER_MODULE(test_dev, *device1*, test_dev_driver, test_dev_devclass, >>> > NULL, NULL); >>> > DRIVER_MODULE(test_dev, *device2*, test_dev_driver, test_dev_devclass, >>> > NULL, NULL); >>> > >>> > I see similar references in other drivers attaching to both simpleus >>> and >>> > ofwbus. So, If it's possible, how to get the reference for both the >>> > parents? device_get_parent(test_dev) will give reference of one parent >>> > only right, so how to get the reference of the desired parent? >>> >>> A device can have only one parent. >>> The declaration you quoted describes a _driver_ that can attach to >>> devices >>> hanging off two different buses. They would still be different devices. >>> >> >> Yes. You can have a driver attach to multiple bus types, but each >> instance has a unique parent one exactly on of them. >> >> If you need to talk to other devices, you'll need to find them by name or >> other means. >> >> Warner >> >> >> >>> -- >>> Andriy Gapon >>> _______________________________________________ >>> freebsd-drivers@freebsd.org mailing list >>> https://lists.freebsd.org/mailman/listinfo/freebsd-drivers >>> To unsubscribe, send any mail to " >>> freebsd-drivers-unsubscribe@freebsd.org" >>> >> From owner-freebsd-drivers@freebsd.org Thu Jun 4 21:53:06 2020 Return-Path: Delivered-To: freebsd-drivers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 785893338A5; Thu, 4 Jun 2020 21:53:06 +0000 (UTC) (envelope-from jmg@gold.funkthat.com) Received: from gold.funkthat.com (gate2.funkthat.com [208.87.223.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "gate2.funkthat.com", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49dKJx1SpVz43h0; Thu, 4 Jun 2020 21:53:04 +0000 (UTC) (envelope-from jmg@gold.funkthat.com) Received: from gold.funkthat.com (localhost [127.0.0.1]) by gold.funkthat.com (8.15.2/8.15.2) with ESMTPS id 054Lr0t4086490 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 4 Jun 2020 14:53:00 -0700 (PDT) (envelope-from jmg@gold.funkthat.com) Received: (from jmg@localhost) by gold.funkthat.com (8.15.2/8.15.2/Submit) id 054Lr0Tm086489; Thu, 4 Jun 2020 14:53:00 -0700 (PDT) (envelope-from jmg) Date: Thu, 4 Jun 2020 14:53:00 -0700 From: John-Mark Gurney To: Rajesh Kumar Cc: Warner Losh , Andriy Gapon , freebsd-drivers@freebsd.org, FreeBSD Hackers Subject: Re: Can we hook a device as device to two different parent devices? Message-ID: <20200604215300.GH4213@funkthat.com> Mail-Followup-To: Rajesh Kumar , Warner Losh , Andriy Gapon , freebsd-drivers@freebsd.org, FreeBSD Hackers References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: FreeBSD 11.3-STABLE amd64 X-PGP-Fingerprint: D87A 235F FB71 1F3F 55B7 ED9B D5FF 5A51 C0AC 3D65 X-Files: The truth is out there X-URL: https://www.funkthat.com/ X-Resume: https://www.funkthat.com/~jmg/resume.html X-TipJar: bitcoin:13Qmb6AeTgQecazTWph4XasEsP7nGRbAPE X-to-the-FBI-CIA-and-NSA: HI! HOW YA DOIN? can i haz chizburger? User-Agent: Mutt/1.6.1 (2016-04-27) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (gold.funkthat.com [127.0.0.1]); Thu, 04 Jun 2020 14:53:00 -0700 (PDT) X-Rspamd-Queue-Id: 49dKJx1SpVz43h0 X-Spamd-Bar: ++ Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of jmg@gold.funkthat.com has no SPF policy when checking 208.87.223.18) smtp.mailfrom=jmg@gold.funkthat.com X-Spamd-Result: default: False [2.19 / 15.00]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[funkthat.com]; AUTH_NA(1.00)[]; NEURAL_SPAM_MEDIUM(0.01)[0.012]; RCPT_COUNT_FIVE(0.00)[5]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_HAM_SHORT(-0.42)[-0.422]; NEURAL_SPAM_LONG(0.40)[0.401]; R_SPF_NA(0.00)[no SPF record]; FREEMAIL_TO(0.00)[gmail.com]; FORGED_SENDER(0.30)[jmg@funkthat.com,jmg@gold.funkthat.com]; SUBJECT_ENDS_QUESTION(1.00)[]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:32354, ipnet:208.87.216.0/21, country:US]; RCVD_COUNT_TWO(0.00)[2]; FROM_NEQ_ENVFROM(0.00)[jmg@funkthat.com,jmg@gold.funkthat.com] X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jun 2020 21:53:06 -0000 Rajesh Kumar wrote this message on Fri, Jun 05, 2020 at 00:01 +0530: > Thanks Warner and Andriy for your answers. > > Having said they are two separate instances, if the child driver calls the > interface of two parents as below > device1_interface(child_dev), then device_get_parent(child_dev) in the > device1 interface will return device1 reference > device2_interface(child_dev), then device_get_parent(child_dev) in the > device2 interface will return device2 reference > > Is that right? I think you're confused. The device tree is a strict tree. This means that a device can have ONLY one parent. The multiple parents is simply saying that a device can attach at different points in the tree... example, you have a device dev that is declared as possibly having both pci and simplebus: nexus0 acpi0 pcib0 pci0 hostb0 pcib1 pci1 dev0 ofwbus0 simplebus1 pnpinfo compat=simple-bus dev1 This example (and entirely made up, I've merged the tree from two different machines, running devinfo -v, only merged to make a point), dev0, when calling device_get_parent, will get the pci1 device, and dev1 when calling device_get_parent will get simplebus1... I think this might be what you said above, but couldn't follow the device1_interface(child_dev) part, as that didn't make sense to me... > On Wed, Jun 3, 2020 at 8:59 PM Warner Losh wrote: > > > > > > > On Wed, Jun 3, 2020, 8:29 AM Andriy Gapon wrote: > > > >> On 03/06/2020 14:20, Rajesh Kumar wrote: > >> > Hi, > >> > > >> > Is it really possible to declare a module with two parents? Like the > >> > following declarations in the same driver. > >> > > >> > devclass_t test_dev_devclass; > >> > static DEFINE_CLASS_0(test_dev, test_dev_driver, test_dev_methods, > >> > sizeof(struct test_dev_ctx)); > >> > DRIVER_MODULE(test_dev, *device1*, test_dev_driver, test_dev_devclass, > >> > NULL, NULL); > >> > DRIVER_MODULE(test_dev, *device2*, test_dev_driver, test_dev_devclass, > >> > NULL, NULL); > >> > > >> > I see similar references in other drivers attaching to both simpleus and > >> > ofwbus. So, If it's possible, how to get the reference for both the > >> > parents? device_get_parent(test_dev) will give reference of one parent > >> > only right, so how to get the reference of the desired parent? > >> > >> A device can have only one parent. > >> The declaration you quoted describes a _driver_ that can attach to devices > >> hanging off two different buses. They would still be different devices. > >> > > > > Yes. You can have a driver attach to multiple bus types, but each instance > > has a unique parent one exactly on of them. > > > > If you need to talk to other devices, you'll need to find them by name or > > other means. > > > > Warner > > > > > > > >> -- > >> Andriy Gapon > >> _______________________________________________ > >> freebsd-drivers@freebsd.org mailing list > >> https://lists.freebsd.org/mailman/listinfo/freebsd-drivers > >> To unsubscribe, send any mail to "freebsd-drivers-unsubscribe@freebsd.org > >> " > >> > > > _______________________________________________ > freebsd-drivers@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-drivers > To unsubscribe, send any mail to "freebsd-drivers-unsubscribe@freebsd.org" -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not." From owner-freebsd-drivers@freebsd.org Thu Jun 4 23:02:02 2020 Return-Path: Delivered-To: freebsd-drivers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5E8F5335AF2 for ; Thu, 4 Jun 2020 23:02:02 +0000 (UTC) (envelope-from marklmi@yahoo.com) Received: from sonic305-21.consmr.mail.gq1.yahoo.com (sonic305-21.consmr.mail.gq1.yahoo.com [98.137.64.84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 49dLrS4fYDz4DQx for ; Thu, 4 Jun 2020 23:02:00 +0000 (UTC) (envelope-from marklmi@yahoo.com) X-YMail-OSG: FsHjRyYVM1k.EVzkncqkLKVr1to6fauIoTSWUNwSK_PX3VznL42IssUPWf9Km4g q6PCDlPaVemUHbmv2yeKCUiIBs1BEZwI_n4VPOQu1W.Y9CK2qeibuuB0FTeCh6KlUpfOWDJEMu17 UqQtkB4N.Zbj4k4IGiOSCdHuHEKAJjRHKXcQRk5PexW.8IEtKSTM9qpeBTU7cmvatbj4GBpIPt2y eVxlyyLDko00u90O_BE1QyKsfYJRE4DdbPeFCnailr.WbJDW.j2.eRs5Jyd9UVWUArzz3e1WbN_N QMZ2PvKzBK21IsvmmGZfxeB6QrmYr4iU3EOSjBL6dFwSrUBYrUKVQ8dArsDvsLRjMeOZEpwrWxYR DciCNo99zWuvKY9d6BZSLs1oPlsTo3p493swptnrq78FZTcveUW2oZ1nnfB3DfuhJs8dsk1aWHq. Fos3cEOigt0Q1Pc_6LFOM6WLR97FJ4xRWu_.vtk0BsO8p2oTFM4hWb0dhaiH6aG_EH_Z68IxZW6m 3NVDOQYxqXsWHybJN6dYVkuObF2uMrZz1xLJu2Ed3CsjzxlzO0kfYgZ.VX4pGJ_h96Jh1Bj4BkKE SPcrnQ5DAanJrjA4Fez4x_LMz0YZP3igK.nZNm0gzyAOpbShVTF.INu7ixS8Z8U2Y48ku6VV9EIN NKQFvu41tiXRTzCnRXNFncD1TtGcL6uAnH7lH9TMXn0HGj7X3qIzCK6cgpGgvBXA5VuvHpIA4gre 0iz2vhVH0KlJC.O5JbwQB9dwhZMhQ5UrsRiiZ9ic5s6cmdUQ6stA4ogSnar_rJQcDqiZVw0KMiW7 kWoMtXv33pnQmRxfXIj1Is.zrQwSlGt__hulXRCavd4SMLAD8IWKMjMG.Hb4hqSvoLyveuZUUkpC 0RAz0pT2yxiF1_Ft6SXsJtmyq2Sh_R99ncVf7e3Z5pXMLyw_JlUJ.bps7aWXOQfeJQWh3B9xFgPR TH6m3rUEnjCQnGd9g7AcpKjtlTXpByenZbDCdR2J4njxCW4XIFxkIp9rTvyfQkYn.kAGIBxu6TpJ 0BL8Ig8VxNtEHMVjocpUncznQiy0nXJ1CDh0XVMht0b1g3IE_b8cT1F3Xq3i1qKJ8WkbNrIDr3rQ ijhYXFPbYVsQUAg4_5KzyK2ndFJkvokYWKea9dJN3arNxP24JcyBsnv_n18G4KCaE10.PjJ7wWF_ ihLOxlrE47epoD5XMZbDMoEFd192kHdATTxn_B8fSeDblqVeT1Qgsyx9OmhuNgoxSZz8FFv02KWd dC_dEoF6KC2zk1F2Jc3DqbGLJ7Sq8H35nFUem3LXAPrABiBTRaLRox3JI0Ej6yPidIQck9s6hE9k sIgIe6ZOIRY66IE4MyGNub89OlHVM1RU6zC.VPmDhxGSKYMuaUrLK1gDCCg_y2_ESHQ23Q6RH56X YN4.Yp3snBALIU2wz Received: from sonic.gate.mail.ne1.yahoo.com by sonic305.consmr.mail.gq1.yahoo.com with HTTP; Thu, 4 Jun 2020 23:01:57 +0000 Received: by smtp422.mail.ne1.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID d7199c91087251eb2b0f187614f4eef8; Thu, 04 Jun 2020 23:01:53 +0000 (UTC) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: Can we hook a device as device to two different parent devices? From: Mark Millard In-Reply-To: <20200604215300.GH4213@funkthat.com> Date: Thu, 4 Jun 2020 16:01:52 -0700 Cc: FreeBSD Hackers , freebsd-drivers@freebsd.org Content-Transfer-Encoding: 7bit Message-Id: References: <20200604215300.GH4213@funkthat.com> To: John-Mark Gurney X-Mailer: Apple Mail (2.3608.80.23.2.2) X-Rspamd-Queue-Id: 49dLrS4fYDz4DQx X-Spamd-Bar: -- X-Spamd-Result: default: False [-2.50 / 15.00]; TO_DN_SOME(0.00)[]; FREEMAIL_FROM(0.00)[yahoo.com]; MV_CASE(0.50)[]; R_SPF_ALLOW(-0.20)[+ptr:yahoo.com]; DKIM_TRACE(0.00)[yahoo.com:+]; DMARC_POLICY_ALLOW(-0.50)[yahoo.com,reject]; NEURAL_HAM_SHORT(-0.97)[-0.972]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[yahoo.com]; SUBJECT_ENDS_QUESTION(1.00)[]; MID_RHS_MATCH_FROM(0.00)[]; ASN(0.00)[asn:36647, ipnet:98.137.64.0/21, country:US]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.02)[-1.022]; R_DKIM_ALLOW(-0.20)[yahoo.com:s=s2048]; FROM_HAS_DN(0.00)[]; DWL_DNSWL_NONE(0.00)[yahoo.com:dkim]; RCPT_COUNT_THREE(0.00)[3]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_LONG(-1.00)[-1.004]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[98.137.64.84:from]; RWL_MAILSPIKE_POSSIBLE(0.00)[98.137.64.84:from]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jun 2020 23:02:02 -0000 [I'm only trying to follow along for my own edification in an area I'm not familiar with.] On 2020-Jun-4, at 14:53, John-Mark Gurney wrote: > Rajesh Kumar wrote this message on Fri, Jun 05, 2020 at 00:01 +0530: >> Thanks Warner and Andriy for your answers. >> >> Having said they are two separate instances, if the child driver calls the >> interface of two parents as below >> device1_interface(child_dev), then device_get_parent(child_dev) in the >> device1 interface will return device1 reference >> device2_interface(child_dev), then device_get_parent(child_dev) in the >> device2 interface will return device2 reference >> >> Is that right? > > I think you're confused. The device tree is a strict tree. This > means that a device can have ONLY one parent. The multiple parents > is simply saying that a device can attach at different points in the > tree... > > example, you have a device dev that is declared as possibly having both > pci and simplebus: > > nexus0 > acpi0 > pcib0 > pci0 > hostb0 > pcib1 > pci1 > dev0 > ofwbus0 > simplebus1 pnpinfo compat=simple-bus > dev1 > > This example (and entirely made up, I've merged the tree from two > different machines, running devinfo -v, only merged to make a point), > dev0, when calling device_get_parent, will get the pci1 device, and > dev1 when calling device_get_parent will get simplebus1... > > I think this might be what you said above, but couldn't follow the > device1_interface(child_dev) part, as that didn't make sense to me... You have 3 "dev" names mentioned above: dev, dev0, dev1 You mention "dev" as the "device". So am I to infer that for "dev" only one of dev0 vs. dev1 can be attached at a time (to its parent)? Code can still find out what the alternative would be for the other one of the two, but having both dev0 and dev1 based attachments at the same time can not be done? === Mark Millard marklmi at yahoo.com ( dsl-only.net went away in early 2018-Mar) From owner-freebsd-drivers@freebsd.org Fri Jun 5 06:31:40 2020 Return-Path: Delivered-To: freebsd-drivers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 385E4341F0E; Fri, 5 Jun 2020 06:31:40 +0000 (UTC) (envelope-from jmg@gold.funkthat.com) Received: from gold.funkthat.com (gate2.funkthat.com [208.87.223.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "gate2.funkthat.com", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49dXqG4lH1z4CLn; Fri, 5 Jun 2020 06:31:38 +0000 (UTC) (envelope-from jmg@gold.funkthat.com) Received: from gold.funkthat.com (localhost [127.0.0.1]) by gold.funkthat.com (8.15.2/8.15.2) with ESMTPS id 0556VS7u001094 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 4 Jun 2020 23:31:28 -0700 (PDT) (envelope-from jmg@gold.funkthat.com) Received: (from jmg@localhost) by gold.funkthat.com (8.15.2/8.15.2/Submit) id 0556VSCx001092; Thu, 4 Jun 2020 23:31:28 -0700 (PDT) (envelope-from jmg) Date: Thu, 4 Jun 2020 23:31:28 -0700 From: John-Mark Gurney To: Mark Millard Cc: FreeBSD Hackers , freebsd-drivers@freebsd.org Subject: Re: Can we hook a device as device to two different parent devices? Message-ID: <20200605063128.GI4213@funkthat.com> Mail-Followup-To: Mark Millard , FreeBSD Hackers , freebsd-drivers@freebsd.org References: <20200604215300.GH4213@funkthat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: FreeBSD 11.3-STABLE amd64 X-PGP-Fingerprint: D87A 235F FB71 1F3F 55B7 ED9B D5FF 5A51 C0AC 3D65 X-Files: The truth is out there X-URL: https://www.funkthat.com/ X-Resume: https://www.funkthat.com/~jmg/resume.html X-TipJar: bitcoin:13Qmb6AeTgQecazTWph4XasEsP7nGRbAPE X-to-the-FBI-CIA-and-NSA: HI! HOW YA DOIN? can i haz chizburger? User-Agent: Mutt/1.6.1 (2016-04-27) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (gold.funkthat.com [127.0.0.1]); Thu, 04 Jun 2020 23:31:28 -0700 (PDT) X-Rspamd-Queue-Id: 49dXqG4lH1z4CLn X-Spamd-Bar: + Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of jmg@gold.funkthat.com has no SPF policy when checking 208.87.223.18) smtp.mailfrom=jmg@gold.funkthat.com X-Spamd-Result: default: False [1.21 / 15.00]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; NEURAL_HAM_LONG(-0.53)[-0.530]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[funkthat.com]; AUTH_NA(1.00)[]; NEURAL_SPAM_SHORT(0.05)[0.048]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_HAM_MEDIUM(-0.50)[-0.504]; R_SPF_NA(0.00)[no SPF record]; FREEMAIL_TO(0.00)[yahoo.com]; FORGED_SENDER(0.30)[jmg@funkthat.com,jmg@gold.funkthat.com]; SUBJECT_ENDS_QUESTION(1.00)[]; R_DKIM_NA(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; FROM_NEQ_ENVFROM(0.00)[jmg@funkthat.com,jmg@gold.funkthat.com]; ASN(0.00)[asn:32354, ipnet:208.87.216.0/21, country:US] X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jun 2020 06:31:40 -0000 Mark Millard wrote this message on Thu, Jun 04, 2020 at 16:01 -0700: > [I'm only trying to follow along for my own edification > in an area I'm not familiar with.] > > On 2020-Jun-4, at 14:53, John-Mark Gurney wrote: > > > Rajesh Kumar wrote this message on Fri, Jun 05, 2020 at 00:01 +0530: > >> Thanks Warner and Andriy for your answers. > >> > >> Having said they are two separate instances, if the child driver calls the > >> interface of two parents as below > >> device1_interface(child_dev), then device_get_parent(child_dev) in the > >> device1 interface will return device1 reference > >> device2_interface(child_dev), then device_get_parent(child_dev) in the > >> device2 interface will return device2 reference > >> > >> Is that right? > > > > I think you're confused. The device tree is a strict tree. This > > means that a device can have ONLY one parent. The multiple parents > > is simply saying that a device can attach at different points in the > > tree... > > > > example, you have a device dev that is declared as possibly having both this should have been: "a device driver dev". > > pci and simplebus: > > > > nexus0 > > acpi0 > > pcib0 > > pci0 > > hostb0 > > pcib1 > > pci1 > > dev0 > > ofwbus0 > > simplebus1 pnpinfo compat=simple-bus > > dev1 > > > > This example (and entirely made up, I've merged the tree from two > > different machines, running devinfo -v, only merged to make a point), > > dev0, when calling device_get_parent, will get the pci1 device, and > > dev1 when calling device_get_parent will get simplebus1... > > > > I think this might be what you said above, but couldn't follow the > > device1_interface(child_dev) part, as that didn't make sense to me... > > You have 3 "dev" names mentioned above: dev, dev0, dev1 > You mention "dev" as the "device". Yeah, seeing that now, I should have said the device driver dev.. dev is not an instance of the device driver... only dev0 and dev1 are instances (attached) of the device driver... > So am I to infer that for "dev" only one of dev0 vs. dev1 dev is like em, or igb.. it's the device driver name... dev0 or dev1 is an instance of the driver... > can be attached at a time (to its parent)? Code can still each instance, dev0 or dev1 or devX, will be attached to a (one) parent.. Each parent may have multiple instances of dev, say pci1 having dev0, dev2 and dev3... and above, simplebus1 could have dev1 and dev4 as children... > find out what the alternative would be for the other one > of the two, but having both dev0 and dev1 based attachments > at the same time can not be done? A device driver can be attached to different busses at the same time, but each instance of that driver can only be attached to one bus at a time... Hope this clarifies things... It's been a few years, but I did a presentation on writing device drivers in FreeBSD: https://people.freebsd.org/~jmg/drivers/freebsd.device.driver.slides.pdf on slide 4, talking about if_re.c, you can see: static devclass_t re_devclass; DRIVER_MODULE(re, pci, re_driver, re_devclass, 0, 0); DRIVER_MODULE(re, cardbus, re_driver, re_devclass, 0, 0); DRIVER_MODULE(miibus, re, miibus_driver, miibus_devclass, 0, 0); This shows that the re driver can be attached to either the pci bus, or the cardbus... When you boot a machine, you could have re0 and re1 that are PCI cards installed in the machine.. and then later you could plug in a cardbus card where the re driver attaches, and you'd now have re2 under cardbus... Warner has also done a presentation on newbus subclassing: https://people.freebsd.org/~imp/bsdcan2013-slides.pdf -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not." From owner-freebsd-drivers@freebsd.org Fri Jun 5 11:14:38 2020 Return-Path: Delivered-To: freebsd-drivers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6C9A1347E00; Fri, 5 Jun 2020 11:14:38 +0000 (UTC) (envelope-from dsl@mcusim.org) Received: from trac.mcusim.org (trac.mcusim.org [IPv6:2a00:dd80:3c::e63]) (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 did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 49dg5n3rZHz4mNM; Fri, 5 Jun 2020 11:14:37 +0000 (UTC) (envelope-from dsl@mcusim.org) Received: from ds-laptop (unknown [IPv6:2a01:115f:77c:6700:b15d:520:8553:d458]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by trac.mcusim.org (Postfix) with ESMTPSA id 9371E255B3; Fri, 5 Jun 2020 13:14:34 +0200 (CEST) Date: Fri, 5 Jun 2020 13:14:32 +0200 From: Dmitry Salychev To: John-Mark Gurney Cc: freebsd-hackers@freebsd.org, freebsd-drivers@freebsd.org Subject: Re: Can we hook a device as device to two different parent devices? Message-ID: <20200605111432.GA30107@ds-laptop> References: <20200604215300.GH4213@funkthat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200604215300.GH4213@funkthat.com> User-Agent: Unknown/0.75.1 X-Rspamd-Queue-Id: 49dg5n3rZHz4mNM X-Spamd-Bar: -- X-Spamd-Result: default: False [-2.32 / 15.00]; SUBJECT_ENDS_QUESTION(1.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+a]; MIME_GOOD(-0.10)[text/plain]; MID_RHS_NOT_FQDN(0.50)[]; NEURAL_HAM_LONG(-1.00)[-0.996]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_HAM_SHORT(-0.99)[-0.989]; DMARC_POLICY_ALLOW(-0.50)[mcusim.org,reject]; NEURAL_HAM_MEDIUM(-1.03)[-1.033]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; ASN(0.00)[asn:36236, ipnet:2a00:dd80:3c::/48, country:US]; RCVD_TLS_ALL(0.00)[] X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jun 2020 11:14:38 -0000 Hi John-Mark, > I think you're confused. The device tree is a strict tree. This > means that a device can have ONLY one parent. The multiple parents > is simply saying that a device can attach at different points in the > tree... Does it mean that there is some kind of priorities in probes for different buses to attach a device to? Let's say that there are IIC and SPI buses for a device (like Ethernet switch) which can be used to control it. Which one will be probed first? Is there a way to re-define it? Regards, Dmitry