Message ID | 20230807122233.28563-1-yangyicong@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp1418415vqr; Mon, 7 Aug 2023 05:41:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH/gXOJEgl9k3bWpdOmZKBMsl8uchI4x/QCX/+1EBQIqWeOBCmKvrQF1haK5H/v5RCNvwsD X-Received: by 2002:aa7:dad0:0:b0:51d:9ddf:f0f6 with SMTP id x16-20020aa7dad0000000b0051d9ddff0f6mr7488242eds.36.1691412074071; Mon, 07 Aug 2023 05:41:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691412074; cv=none; d=google.com; s=arc-20160816; b=AskiphkEy4UVz9S74aiOFGOUYq55YfeEXARLbx1ihhwXRj6AW/+LYocgli9BHtZcuo k1HT+LG9JyPjHVqA9EcpEFAqb+Z4FuQZ7RrqP7J5WKuhTqPAkWg+ZV38ATi7yvcc2H8c jMB1dw05yDVKz2A1V0B6BAd0fefMa71xmopG887JBhs8hHEcEubnmCQRY5JpMxA7UaKH HgMhh+1Wz3dCiMrWBXMe8eW9KIIYH6+SycuLYHUgV+DM8ZHTJahTj/CZPFvWRZxpaeVF p292577GA3w3hAXtB3Nr801JiiBdVtCHxPE4+kjJBWGuRQ9gt1puF+RFr2CwVoLVjOxU e5FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=A/S+3aJ3O1yd5vFLtKBMqSs/mZdKBDmf++v4qBAuZ1U=; fh=y8l7po28TA4R+rcyOvpu2ivWNM7RLzraWjE+jfcFHGY=; b=exL1kohBciCPiVwSPLe7ImHYwldcrrrmVahJIz3YRS2drcnP0htsAO0TKgOxK7aMfa Vcq6DrW7TDG15B5OH01R7cm0obybOuDjbGFVmuZjgz9A714lIcA7f3+46qwL0X2XBP1C bzc6fz7gng/oVG30PmHo2BNu7oIZUood5Inwp2R7QT9h3N5Zc2F3JGu2y4/z44EroG3f OYbTjjOE3i0EQBTdjJL01BlFh5zv3zmj4K6/HihapID6UMB86lN/vfxHNaiNMIGANuTA d3Rt3eM1QZ8VwDQOSO4WJ4MvrRtbOJ2wVuWEQM2X1wNrHL+Rw9MtdIZNTGNOxq0YrluA 6txA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b11-20020aa7df8b000000b005233f932c8asi234299edy.624.2023.08.07.05.40.49; Mon, 07 Aug 2023 05:41:14 -0700 (PDT) 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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231895AbjHGMYu (ORCPT <rfc822;aaronkmseo@gmail.com> + 99 others); Mon, 7 Aug 2023 08:24:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231252AbjHGMYt (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 7 Aug 2023 08:24:49 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1D63E41 for <linux-kernel@vger.kernel.org>; Mon, 7 Aug 2023 05:24:47 -0700 (PDT) Received: from canpemm500009.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RKFpw280wzfbnT; Mon, 7 Aug 2023 20:23:36 +0800 (CST) Received: from localhost.localdomain (10.50.163.32) by canpemm500009.china.huawei.com (7.192.105.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Mon, 7 Aug 2023 20:24:45 +0800 From: Yicong Yang <yangyicong@huawei.com> To: <will@kernel.org>, <mark.rutland@arm.com>, <linux-arm-kernel@lists.infradead.org>, <linux-kernel@vger.kernel.org> CC: <jonathan.cameron@huawei.com>, <linuxarm@huawei.com>, <yangyicong@hisilicon.com> Subject: [PATCH] perf/smmuv3: Add platform id table for module auto loading Date: Mon, 7 Aug 2023 20:22:33 +0800 Message-ID: <20230807122233.28563-1-yangyicong@huawei.com> X-Mailer: git-send-email 2.31.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.50.163.32] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500009.china.huawei.com (7.192.105.203) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773574107286707376 X-GMAIL-MSGID: 1773574107286707376 |
Series |
perf/smmuv3: Add platform id table for module auto loading
|
|
Commit Message
Yicong Yang
Aug. 7, 2023, 12:22 p.m. UTC
From: Yicong Yang <yangyicong@hisilicon.com> On ACPI based system the device is probed by the name directly. If the driver is configured as module it can only be loaded manually. Add the platform id table as well as the module alias then the driver will be loaded automatically by the udev or others once the device added. Signed-off-by: Yicong Yang <yangyicong@hisilicon.com> --- drivers/perf/arm_smmuv3_pmu.c | 7 +++++++ 1 file changed, 7 insertions(+)
Comments
On 2023-08-07 20:22, Yicong Yang <yangyicong@huawei.com> wrote: > From: Yicong Yang <yangyicong@hisilicon.com> > > On ACPI based system the device is probed by the name directly. If the > driver is configured as module it can only be loaded manually. Add the > platform id table as well as the module alias then the driver will be > loaded automatically by the udev or others once the device added. > Please consider revise the long log to clearly express the purpose of the changes in this patch: - What's the exact issue the patch is addressing - Why the changes in this patch can fix the issue or make something working - Consider impact of the changes introduced by this patch These info may help reviewers and maintainers .. and yourself on code merge. Regards.
On Wed, Aug 9, 2023 at 1:01 PM Liang Li <liliang6@email.cn> wrote: > > On 2023-08-07 20:22, Yicong Yang <yangyicong@huawei.com> wrote: > > From: Yicong Yang <yangyicong@hisilicon.com> > > > > On ACPI based system the device is probed by the name directly. If the > > driver is configured as module it can only be loaded manually. Add the > > platform id table as well as the module alias then the driver will be > > loaded automatically by the udev or others once the device added. > > > > Please consider revise the long log to clearly express the purpose of the > changes in this patch: > > - What's the exact issue the patch is addressing > - Why the changes in this patch can fix the issue or make something working > - Consider impact of the changes introduced by this patch > > These info may help reviewers and maintainers .. and yourself on code merge. years ago, i found a good doc regarding this, https://wiki.archlinux.org/title/Modalias guess it is because /lib/modules/$(uname -r)/modules.alias fails to contain smmu driver without the MODULE_DEVICE_TABLE, isn't it, yicong? > > Regards. > Thanks Barry
Hi Yicong, Thanks for your reply, On 2023-08-09 14:31, Yicong Yang <yangyicong@huawei.com> wrote: > Hi Barry, Liang, > > On 2023/8/9 13:47, Barry Song wrote: > > On Wed, Aug 9, 2023 at 1:01 PM Liang Li <liliang6@email.cn> wrote: > >> > >> On 2023-08-07 20:22, Yicong Yang <yangyicong@huawei.com> wrote: > >>> From: Yicong Yang <yangyicong@hisilicon.com> > >>> > >>> On ACPI based system the device is probed by the name directly. If the > >>> driver is configured as module it can only be loaded manually. Add the > >>> platform id table as well as the module alias then the driver will be > >>> loaded automatically by the udev or others once the device added. > >>> > >> > >> Please consider revise the long log to clearly express the purpose of the > >> changes in this patch: > >> > >> - What's the exact issue the patch is addressing > >> - Why the changes in this patch can fix the issue or make something working > >> - Consider impact of the changes introduced by this patch > >> > >> These info may help reviewers and maintainers .. and yourself on code merge. > > > > years ago, i found a good doc regarding this, > > https://wiki.archlinux.org/title/Modalias > > > > guess it is because /lib/modules/$(uname -r)/modules.alias fails to contain smmu > > driver without the MODULE_DEVICE_TABLE, isn't it, yicong? > > Yes I think it's the reason. I didn't find summary in kernel docs for the modalias > as well as the uevent mechanism. Arch wiki has a well illustration for the modalias > and suse[1] describes how this is used by the udev for module auto loading. > > For my case I'm using a ACPI based arm64 server and after booting the arm_smmuv3_pmu.ko > is not auto loaded by the udevd since we aren't providing this information. In order > to support this we need to provide this MODULE_DEVICE_TABLE() when the smmu pmu added > as a platform device, then the userspace udev can know which module to load after the > device is added. > Then what's the purpose of the added '.id_table = ...' line in the previous patch ? <We lost the patch context in this thread.> Based on above clarification, the updated DEVICE_TABLE would update modalias as expected, right ? > [1] https://documentation.suse.com/sles/15-SP1/html/SLES-all/cha-udev.html#sec-udev-drivers > > Thanks. Regards. Liang Li
On Fri, Aug 11, 2023 at 6:14 PM Yicong Yang <yangyicong@huawei.com> wrote: > > On 2023/8/9 20:11, Liang Li wrote: > > Hi Yicong, > > > > Thanks for your reply, > > > > On 2023-08-09 14:31, Yicong Yang <yangyicong@huawei.com> wrote: > >> Hi Barry, Liang, > >> > >> On 2023/8/9 13:47, Barry Song wrote: > >>> On Wed, Aug 9, 2023 at 1:01 PM Liang Li <liliang6@email.cn> wrote: > >>>> > >>>> On 2023-08-07 20:22, Yicong Yang <yangyicong@huawei.com> wrote: > >>>>> From: Yicong Yang <yangyicong@hisilicon.com> > >>>>> > >>>>> On ACPI based system the device is probed by the name directly. If the > >>>>> driver is configured as module it can only be loaded manually. Add the > >>>>> platform id table as well as the module alias then the driver will be > >>>>> loaded automatically by the udev or others once the device added. > >>>>> > >>>> > >>>> Please consider revise the long log to clearly express the purpose of the > >>>> changes in this patch: > >>>> > >>>> - What's the exact issue the patch is addressing > >>>> - Why the changes in this patch can fix the issue or make something working > >>>> - Consider impact of the changes introduced by this patch > >>>> > >>>> These info may help reviewers and maintainers .. and yourself on code merge. > >>> > >>> years ago, i found a good doc regarding this, > >>> https://wiki.archlinux.org/title/Modalias > >>> > >>> guess it is because /lib/modules/$(uname -r)/modules.alias fails to contain smmu > >>> driver without the MODULE_DEVICE_TABLE, isn't it, yicong? > >> > >> Yes I think it's the reason. I didn't find summary in kernel docs for the modalias > >> as well as the uevent mechanism. Arch wiki has a well illustration for the modalias > >> and suse[1] describes how this is used by the udev for module auto loading. > >> > >> For my case I'm using a ACPI based arm64 server and after booting the arm_smmuv3_pmu.ko > >> is not auto loaded by the udevd since we aren't providing this information. In order > >> to support this we need to provide this MODULE_DEVICE_TABLE() when the smmu pmu added > >> as a platform device, then the userspace udev can know which module to load after the > >> device is added. > >> > > > > Then what's the purpose of the added '.id_table = ...' line in the previous > > patch ? > > <We lost the patch context in this thread.> > > > > Based on above clarification, the updated DEVICE_TABLE would update modalias > > as expected, right ? > > ok, it's lack of illustration in the commit. If we're going to use MODULE_DEVICE_TABLE we need > a platform id table. So I add it and I found it weired if we have a id table but not use it for > probing, so I also initialize .id_table. > > I found there's also an another way to implement this by used MODULE_ALIAS(), and no need to add > an id table. Maybe this way is less controversial. right, how is your driver matching with your device? acpi_driver_match_device() or strcmp(pdev->name, drv->name) == 0 ? static int platform_match(struct device *dev, struct device_driver *drv) { struct platform_device *pdev = to_platform_device(dev); struct platform_driver *pdrv = to_platform_driver(drv); /* When driver_override is set, only bind to the matching driver */ if (pdev->driver_override) return !strcmp(pdev->driver_override, drv->name); /* Attempt an OF style match first */ if (of_driver_match_device(dev, drv)) return 1; /* Then try ACPI style match */ if (acpi_driver_match_device(dev, drv)) return 1; /* Then try to match against the id table */ if (pdrv->id_table) return platform_match_id(pdrv->id_table, pdev) != NULL; /* fall-back to driver name match */ return (strcmp(pdev->name, drv->name) == 0); } In both cases, it seems we don't need id_table. id_table can support two or above device names, so that one driver can support multiple device IDs usually with different specific device data. > > diff --git a/drivers/perf/arm_smmuv3_pmu.c b/drivers/perf/arm_smmuv3_pmu.c > index 25a269d431e4..4c32b6dbfe76 100644 > --- a/drivers/perf/arm_smmuv3_pmu.c > +++ b/drivers/perf/arm_smmuv3_pmu.c > @@ -984,6 +984,7 @@ static void __exit arm_smmu_pmu_exit(void) > > module_exit(arm_smmu_pmu_exit); > > +MODULE_ALIAS("platform:arm-smmu-v3-pmcg"); > MODULE_DESCRIPTION("PMU driver for ARM SMMUv3 Performance Monitors Extension"); > MODULE_AUTHOR("Neil Leeder <nleeder@codeaurora.org>"); > MODULE_AUTHOR("Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>"); > Thanks Barry
On Sat, Aug 12, 2023 at 1:24 PM Barry Song <21cnbao@gmail.com> wrote: > > On Fri, Aug 11, 2023 at 6:14 PM Yicong Yang <yangyicong@huawei.com> wrote: > > > > On 2023/8/9 20:11, Liang Li wrote: > > > Hi Yicong, > > > > > > Thanks for your reply, > > > > > > On 2023-08-09 14:31, Yicong Yang <yangyicong@huawei.com> wrote: > > >> Hi Barry, Liang, > > >> > > >> On 2023/8/9 13:47, Barry Song wrote: > > >>> On Wed, Aug 9, 2023 at 1:01 PM Liang Li <liliang6@email.cn> wrote: > > >>>> > > >>>> On 2023-08-07 20:22, Yicong Yang <yangyicong@huawei.com> wrote: > > >>>>> From: Yicong Yang <yangyicong@hisilicon.com> > > >>>>> > > >>>>> On ACPI based system the device is probed by the name directly. If the > > >>>>> driver is configured as module it can only be loaded manually. Add the > > >>>>> platform id table as well as the module alias then the driver will be > > >>>>> loaded automatically by the udev or others once the device added. > > >>>>> > > >>>> > > >>>> Please consider revise the long log to clearly express the purpose of the > > >>>> changes in this patch: > > >>>> > > >>>> - What's the exact issue the patch is addressing > > >>>> - Why the changes in this patch can fix the issue or make something working > > >>>> - Consider impact of the changes introduced by this patch > > >>>> > > >>>> These info may help reviewers and maintainers .. and yourself on code merge. > > >>> > > >>> years ago, i found a good doc regarding this, > > >>> https://wiki.archlinux.org/title/Modalias > > >>> > > >>> guess it is because /lib/modules/$(uname -r)/modules.alias fails to contain smmu > > >>> driver without the MODULE_DEVICE_TABLE, isn't it, yicong? > > >> > > >> Yes I think it's the reason. I didn't find summary in kernel docs for the modalias > > >> as well as the uevent mechanism. Arch wiki has a well illustration for the modalias > > >> and suse[1] describes how this is used by the udev for module auto loading. > > >> > > >> For my case I'm using a ACPI based arm64 server and after booting the arm_smmuv3_pmu.ko > > >> is not auto loaded by the udevd since we aren't providing this information. In order > > >> to support this we need to provide this MODULE_DEVICE_TABLE() when the smmu pmu added > > >> as a platform device, then the userspace udev can know which module to load after the > > >> device is added. > > >> > > > > > > Then what's the purpose of the added '.id_table = ...' line in the previous > > > patch ? > > > <We lost the patch context in this thread.> > > > > > > Based on above clarification, the updated DEVICE_TABLE would update modalias > > > as expected, right ? > > > > ok, it's lack of illustration in the commit. If we're going to use MODULE_DEVICE_TABLE we need > > a platform id table. So I add it and I found it weired if we have a id table but not use it for > > probing, so I also initialize .id_table. > > > > I found there's also an another way to implement this by used MODULE_ALIAS(), and no need to add > > an id table. Maybe this way is less controversial. > > right, how is your driver matching with your device? > > acpi_driver_match_device() or strcmp(pdev->name, drv->name) == 0 ? btw, those drivers supporting acpi probe usually have a acpi table #if IS_ENABLED(CONFIG_ACPI) static const struct acpi_device_id hidma_acpi_ids[] = { {"QCOM8061"}, {"QCOM8062", HIDMA_MSI_CAP}, {"QCOM8063", (HIDMA_MSI_CAP | HIDMA_IDENTITY_CAP)}, {}, }; MODULE_DEVICE_TABLE(acpi, hidma_acpi_ids); #endif > > static int platform_match(struct device *dev, struct device_driver *drv) > { > struct platform_device *pdev = to_platform_device(dev); > struct platform_driver *pdrv = to_platform_driver(drv); > > /* When driver_override is set, only bind to the matching driver */ > if (pdev->driver_override) > return !strcmp(pdev->driver_override, drv->name); > > /* Attempt an OF style match first */ > if (of_driver_match_device(dev, drv)) > return 1; > > /* Then try ACPI style match */ > if (acpi_driver_match_device(dev, drv)) > return 1; > > /* Then try to match against the id table */ > if (pdrv->id_table) > return platform_match_id(pdrv->id_table, pdev) != NULL; > > /* fall-back to driver name match */ > return (strcmp(pdev->name, drv->name) == 0); > } > > In both cases, it seems we don't need id_table. id_table can support > two or above device names, so that one driver can support > multiple device IDs usually with different specific device data. > > > > > diff --git a/drivers/perf/arm_smmuv3_pmu.c b/drivers/perf/arm_smmuv3_pmu.c > > index 25a269d431e4..4c32b6dbfe76 100644 > > --- a/drivers/perf/arm_smmuv3_pmu.c > > +++ b/drivers/perf/arm_smmuv3_pmu.c > > @@ -984,6 +984,7 @@ static void __exit arm_smmu_pmu_exit(void) > > > > module_exit(arm_smmu_pmu_exit); > > > > +MODULE_ALIAS("platform:arm-smmu-v3-pmcg"); > > MODULE_DESCRIPTION("PMU driver for ARM SMMUv3 Performance Monitors Extension"); > > MODULE_AUTHOR("Neil Leeder <nleeder@codeaurora.org>"); > > MODULE_AUTHOR("Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>"); > > > > Thanks > Barry
diff --git a/drivers/perf/arm_smmuv3_pmu.c b/drivers/perf/arm_smmuv3_pmu.c index 25a269d431e4..f27c5f585524 100644 --- a/drivers/perf/arm_smmuv3_pmu.c +++ b/drivers/perf/arm_smmuv3_pmu.c @@ -946,7 +946,14 @@ static const struct of_device_id smmu_pmu_of_match[] = { MODULE_DEVICE_TABLE(of, smmu_pmu_of_match); #endif +static const struct platform_device_id smmu_pmu_platform_match[] = { + { "arm-smmu-v3-pmcg", 0 }, + {} +}; +MODULE_DEVICE_TABLE(platform, smmu_pmu_platform_match); + static struct platform_driver smmu_pmu_driver = { + .id_table = smmu_pmu_platform_match, .driver = { .name = "arm-smmu-v3-pmcg", .of_match_table = of_match_ptr(smmu_pmu_of_match),