Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4811455rwb; Mon, 21 Nov 2022 12:14:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf7XCtYnH5RFfiRZKaWwVdcXMjCr14ELdNmYXduqqYrwuZM1b2TMS3NeFEGl6MaaKDZGEtqU X-Received: by 2002:a17:90b:46ca:b0:212:ce2d:9fd7 with SMTP id jx10-20020a17090b46ca00b00212ce2d9fd7mr22445808pjb.157.1669061681955; Mon, 21 Nov 2022 12:14:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669061681; cv=none; d=google.com; s=arc-20160816; b=dKAK7Q7+vWJkHQPh4nNbYDWsX0dkQmFIfHK3w/OVGOD3/eRvEotsjSLGvhR6Ke0SG1 ZyEXoGJiGm1yATNrXjy8W1YPp59ASMaRF+OenYrW7EURpaIkDvbkm5nl3jAccI8Dzefq PCL92X31c0PE3YDUuaQ0SVhdnopFK3F/HxXlfgYJLs2ChVPm8lzgB49QGereJ743hz/o 9ZHUelkEIwWR0+XvpipPkuWXBPMbGGW3G34XkFpNbPlRBqeHsyb45rNc3DO/iEF2fwiR PL+I9QcgWQYJLk9c6M1m7M0m40dxXPtrnXf58TFYqCRv5/wMfemKIfeDRxnBNgZfyIhz Y7Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=C7m3d+zzcm0+ck6h+pP6E95Yb1gw+Bq/lQH+jPmZyAA=; b=rKbVrOzdSPLtwxRPniSyhXPo2bvmpYVUAd3UvJIcgGN0NNH94W4Duj4yfKxJgcbIDv aGIvTZUjxox/aWcm9ON1wHgODLLNDvqKWw8pvQgDA8x0cqhOteTSts9VUswELE0oWUBl VqQ0tPdvWrtOFe2e13fDxxfRWFuVx1GkgarUwjS5EfNNZzJ1xOHHShJ0zriXRNu2ZZEC CUv8qgr2q1gozdMVRfr5gkLgU+9xr767ZOmIQfWfu8gJdXPQ1i9uQcmPwwpA7nAjPE7N EtN2z7bZ55llXAo2hBdwrsLvv9X+E58XAu4OQf9gUAclNDstFFyT2ql/JfdySHnqeqzm DIqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=2tDN8HUy; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=TIDZELAF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p36-20020a635b24000000b00476d73d3a98si10698024pgb.510.2022.11.21.12.14.30; Mon, 21 Nov 2022 12:14:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=2tDN8HUy; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=TIDZELAF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230460AbiKUTkQ (ORCPT + 91 others); Mon, 21 Nov 2022 14:40:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230490AbiKUTkJ (ORCPT ); Mon, 21 Nov 2022 14:40:09 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38541CB97F; Mon, 21 Nov 2022 11:40:08 -0800 (PST) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669059605; 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: in-reply-to:in-reply-to:references:references; bh=C7m3d+zzcm0+ck6h+pP6E95Yb1gw+Bq/lQH+jPmZyAA=; b=2tDN8HUylQIoLblLUF/8xofiDN73yCUjsW5zcweV3AzT5UjOsM1EKGgEsXbHuLfBL3V5yL eIqd2cYgrBqtCoqLolT/EY18p2OK8ZP6N7qwALemkb54z4PgH6PnLvjOz7PoLbBNwAr3EP wiT4PzRQPbaIdyy/jkzK/xGjLJoCjRtU/urP6ydwSzFtqHAoFYyKMPWe3+awRbzHZdcWiz y2X39W4YFlCmfcCkYfIse2CDhUYgJEfrqMGzk5hXU04z2JqtFSAQRdec2xoG+VbLECKnt7 5C9H5WOJ227IAaaTj/zEIZ1x95Br8FabKcMeGzPnoKseeMu7MAxhsLJlZlZZtw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669059605; 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: in-reply-to:in-reply-to:references:references; bh=C7m3d+zzcm0+ck6h+pP6E95Yb1gw+Bq/lQH+jPmZyAA=; b=TIDZELAFfx7uUVsHRIhKCWs5wmXklSKUz1ZNni4hnXD389UGK3ZWkK4X/JXyxtjr32vkOK 5KJPzS//zccOhFBg== To: Jason Gunthorpe Cc: LKML , x86@kernel.org, Joerg Roedel , Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Marc Zyngier , Greg Kroah-Hartman , Dave Jiang , Alex Williamson , Kevin Tian , Dan Williams , Logan Gunthorpe , Ashok Raj , Jon Mason , Allen Hubbe , "Ahmed S. Darwish" , Reinette Chatre Subject: Re: [patch 19/33] genirq/msi: Provide msi_desc::msi_data In-Reply-To: References: <20221111133158.196269823@linutronix.de> <20221111135206.346985384@linutronix.de> <871qpzkj9k.ffs@tglx> Date: Mon, 21 Nov 2022 20:40:05 +0100 Message-ID: <87bkp0hzai.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 21 2022 at 13:20, Jason Gunthorpe wrote: > On Fri, Nov 18, 2022 at 11:08:55PM +0100, Thomas Gleixner wrote: >> Sure I could make both cookies plain u64, but I hate these forced type >> casts and the above is simple to handle and understand. > > I guess, they aren't what I think of as cookies, so I wouldn't make > them u64 in the first place. > > The argument to msi_domain_alloc_irq_at() ideally wants to be a > per-domain-type struct so we can folow it around more cleanly. This is > C so we have to type erase it as a void * through the core code, but > OK. When looking at the wire to MSI abomination and also PASID there is no real per domain struct. It's plain integer information and I hate to store it in a pointer. Especially as the pointer width on 32bit is not necessarily sufficient. Allocating 8 bytes and tracking them to be freed would be an horrible idea. > The second one is typically called "driver private data" in device > driver subsystems that can't use container_of for some reason - just a > chunk of data the driver can associate with a core owned struct. > > The usual pattern for driver private data is for the core to provide > some kind of accessor void *get_priv() (think dev_get_drvdata()) or > whatever. > > But I do understand your point about keeping the drivers away from > things. Maybe some other pattern is better in this case. At least from the two examples I have (IDXD and wire2MSI) the per instance union works perfectly fine and I can't see a reason why e.g. for your usecase cookie = { .ptr = myqueue }; would not work. The meaning of the cookie is domain implementation defined and only the actual MSI domain and the related users know whether its a value or a pointer and what to do with this information. I named it cookie because from the core MSI code's view it's completely opaque and aside of the fact that the allocation function copies the cookie into msi_desc, the core does not care at all about it. Same for the domain one which is solely handled by the domain setup code and is e.g. used to enable the irq chip callbacks to do what they need to do. Thanks, tglx