Received: by 2002:a05:7412:bc1a:b0:d7:7d3a:4fe2 with SMTP id ki26csp1291122rdb; Mon, 21 Aug 2023 03:28:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF1B/uNPWLDMNcwPvir6+dxA9EeQPZDOKeqVtfhXlVoccRZmiCo/z1RH1qyWUPMwMyhebWy X-Received: by 2002:a17:907:778d:b0:99e:1265:5463 with SMTP id ky13-20020a170907778d00b0099e12655463mr4983104ejc.46.1692613722095; Mon, 21 Aug 2023 03:28:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692613722; cv=none; d=google.com; s=arc-20160816; b=S7G7Bp+YsFeSY/HuUelcWSsMqHajaLp1YGiFHKNCbnVYTxk93SvAKCdzrPXdVAcaSU U1Mn6F6PkW3jP55VGtdTmZ6v4UqYn+VE+pd1kyV7F0xHxclOOiydbTfUbOqWLekSTg+c mc6IwokU6IUAj7AexPkTtgg8rxpMoFc0Jcqz7azARwaT3+7s9qm852Fa3SJHaoCQuATq Y7No4ACP4hEOlUv9e3fq/gtoC6pikT9RNK0NR/x1evnKUCLOtbXdzSbvoNsqNcvzWa0J MkisrkgKp5kjcR9i6Nzgt3ocm06zBdMrlwZeyM4uQrF0WaFM82shEo0FZc3HUJsbnt0R 1kXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=q0hAiCJ7zuF/BJvWon2xmgouSjvbEZ3isy72Ev4ZlXA=; fh=4lCuB6TSxj+YlVbWvqSzB4eXBjkwvdvctPQLi8w1uUw=; b=QcrJxZT0p07CZM+BBheWEa4b90v1Zi2z/p8USh3ig2vf4aa1Tv0J//uztUAxXuMZNO EYA5hYyxamIM5F+mPdJOyucN5YSuD4WJSxQ/JfhObftvKRajjvcg+B2I4UpMG0Ey4W5x SiZcheTq3wJsqqe3bKAaCVhv6wExgf6hHxfWCZI/9FXDh/O7OqwicRG44NQQbHzARMPU gHLy3HvVjurvwfD3c0D532+BzZ/Lustle77jQDre+GzqafRGUdyKBx+YenyOtW/9QJwb OhBLN49LPxUdZ63cDqCLKmVF70I7zFDRfKHtWcr056aWiiUDOdCgTN9dL+vYbFbhk+4u LUag== 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=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sa3-20020a170906eda300b009a1694c93adsi4062282ejb.249.2023.08.21.03.28.17; Mon, 21 Aug 2023 03:28:42 -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=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234355AbjHUJ3b (ORCPT + 99 others); Mon, 21 Aug 2023 05:29:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234326AbjHUJ33 (ORCPT ); Mon, 21 Aug 2023 05:29:29 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3D41291; Mon, 21 Aug 2023 02:29:28 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BA6F32F4; Mon, 21 Aug 2023 02:30:08 -0700 (PDT) Received: from [10.57.3.137] (unknown [10.57.3.137]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 07EC23F762; Mon, 21 Aug 2023 02:29:25 -0700 (PDT) Message-ID: <2f1beb3e-c9df-46c5-fe5d-0d688a730521@arm.com> Date: Mon, 21 Aug 2023 10:29:22 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Subject: Re: [PATCH v5] perf: arm_cspmu: Separate Arm and vendor module Content-Language: en-GB To: Besar Wicaksono , Suzuki K Poulose Cc: "ilkka@os.amperecomputing.com" , "catalin.marinas@arm.com" , "will@kernel.org" , "mark.rutland@arm.com" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "linux-tegra@vger.kernel.org" , Thierry Reding , Jonathan Hunter , Vikram Sethi , Richard Wiley , Eric Funsten References: <20230705104745.52255-1-bwicaksono@nvidia.com> From: Robin Murphy In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE 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 2023-08-19 21:11, Besar Wicaksono wrote: [...] >>> +void arm_cspmu_impl_unregister(const struct arm_cspmu_impl_match >> *impl_match) >>> +{ >>> + struct device *dev; >>> + struct arm_cspmu_impl_match *match; >>> + >>> + match = arm_cspmu_impl_match_get(impl_match->pmiidr_val); >>> + >>> + WARN_ON(!match); Nit: do "if (WARN_ON(!match)) return;" rather than indenting almost the whole function. >>> + >>> + if (match) { >>> + /* Unbind the driver from all matching backend devices. */ >>> +dev_release: >>> + dev = driver_find_device(&arm_cspmu_driver.driver, NULL, >>> + match, arm_cspmu_match_device); >>> + if (dev) { >>> + device_release_driver(dev); >>> + goto dev_release; >>> + } >> >> minor nit: We could simply do : >> >> static int arm_cspmu_release_driver(struct device *dev, void *data) >> { >> struct arm_cspmu *cspmu = >> platform_get_drvdata(to_platform_device(dev)); >> >> if (cspmu && cspmu->impl.match == match) >> device_release_driver(dev); >> return 0; >> } >> >> ret = driver_for_each_device(&driver, NULL, match, >> arm_csmpu_release_driver); >> > > It doesn’t seem to work for me. > Is it safe to release while iterating via driver_for_each_device ? Looking at the klist code it doesn't *obviously* appear safe to modify the list during iteration, so probably best not to risk it anyway. However, please try to write this loop as an actual loop, e.g.: while ((dev = driver_find_device())) device_release_driver(); At first glance I thought there was a bug here that it's only processing a single device, then eventually I saw the goto and my thought changed to "Eww..." Thanks, Robin.