From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A7EC1CA0EE9 for ; Mon, 18 Aug 2025 17:38:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7473D10E4C2; Mon, 18 Aug 2025 17:38:35 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="BsU1eod/"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3073F10E4B4 for ; Mon, 18 Aug 2025 17:38:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1755538705; x=1787074705; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bpebQLbC70IhGRB7wVkgcz80qEVrg5DGFAiG/ao+uao=; b=BsU1eod/jwqxbXp6fJxYiMgNzYFQMYcKI77oA85ILTSBIRuLskWVa6TW 2o2a6TYqDe1jVI+qKGDRi38XGLjr+KzauthuQ5qc8KHWI21pSBVGgE+M5 rKMssePDS6gSLAFHPRW7nfLWiH3O3le1x80Tf6LGlAn508iAkCW31OPFz eFJEp+hRwcV/IaCqFb7auMoxi3JqDc1Z39gpWk2vvAojqOqzNBhi2Fwhq HiMeJRJ3XPRwIIhKn3EU3K9EfgaYW4wiwhWJUW7q7pgKmrBldCfKO8cG2 K55VS5U0YPty4nTvZmofGopCCIaF2o2KmRPDR0muwqmafYzfN2gRV27Wf A==; X-CSE-ConnectionGUID: a3SMRkrvTW+JdhsSULZWLQ== X-CSE-MsgGUID: wPyvSU7vQ5S20uGcHDgCKA== X-IronPort-AV: E=McAfee;i="6800,10657,11526"; a="57918655" X-IronPort-AV: E=Sophos;i="6.17,300,1747724400"; d="scan'208";a="57918655" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2025 10:38:25 -0700 X-CSE-ConnectionGUID: 73kGC4cKTwSmzP7Peaj6bw== X-CSE-MsgGUID: G5TQ6vLpR6OoKZUlADHgTQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,300,1747724400"; d="scan'208";a="172838884" Received: from lucas-s2600cw.jf.intel.com ([10.165.21.196]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2025 10:38:25 -0700 From: Lucas De Marchi To: intel-xe@lists.freedesktop.org Cc: Lucas De Marchi , prashanth.kumar@intel.com, dnyaneshwar.bhadane@intel.com, Riana Tauro Subject: [PATCH v4 09/13] drm/xe/configfs: Block runtime attribute changes Date: Mon, 18 Aug 2025 10:37:34 -0700 Message-ID: <20250818-psmi-v4-9-a330783ce1c0@intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250818-psmi-v4-0-a330783ce1c0@intel.com> References: <20250818-psmi-v4-0-a330783ce1c0@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.15-dev-b03c7 Content-Transfer-Encoding: 8bit X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" Although it's possible to change the attributes in runtime, they have no effect after the driver is already bound to the device. Check for that and return -EBUSY in that case. This should help users understand what's going on when the behavior is not changing even if the value from the configfs is "right", but it got to that state too late. Reviewed-by: Riana Tauro Signed-off-by: Lucas De Marchi --- v2: - Add dbg message when it's already bound (Riana) --- drivers/gpu/drm/xe/xe_configfs.c | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/gpu/drm/xe/xe_configfs.c b/drivers/gpu/drm/xe/xe_configfs.c index de73c4ff8f4f2..5babe8cc21b36 100644 --- a/drivers/gpu/drm/xe/xe_configfs.c +++ b/drivers/gpu/drm/xe/xe_configfs.c @@ -54,6 +54,8 @@ * # echo 1 > /sys/kernel/config/xe/0000:03:00.0/survivability_mode * # echo 0000:03:00.0 > /sys/bus/pci/drivers/xe/bind (Enters survivability mode if supported) * + * This attribute can only be set before binding to the device. + * * Allowed engines: * ---------------- * @@ -78,6 +80,8 @@ * available for migrations, but it's disabled. This is intended for debugging * purposes only. * + * This attribute can only be set before binding to the device. + * * PSMI * ---- * @@ -88,6 +92,8 @@ * * # echo 1 > /sys/kernel/config/xe/0000:03:00.0/enable_psmi * + * This attribute can only be set before binding to the device. + * * Remove devices * ============== * @@ -148,6 +154,32 @@ static struct xe_config_device *to_xe_config_device(struct config_item *item) return &to_xe_config_group_device(item)->config; } +static bool is_bound(struct xe_config_group_device *dev) +{ + unsigned int domain, bus, slot, function; + struct pci_dev *pdev; + const char *name; + bool ret; + + lockdep_assert_held(&dev->lock); + + name = dev->group.cg_item.ci_name; + if (sscanf(name, "%x:%x:%x.%x", &domain, &bus, &slot, &function) != 4) + return false; + + pdev = pci_get_domain_bus_and_slot(domain, bus, PCI_DEVFN(slot, function)); + if (!pdev) + return false; + + ret = pci_get_drvdata(pdev); + pci_dev_put(pdev); + + if (ret) + pci_dbg(pdev, "Already bound to driver\n"); + + return ret; +} + static ssize_t survivability_mode_show(struct config_item *item, char *page) { struct xe_config_device *dev = to_xe_config_device(item); @@ -166,6 +198,9 @@ static ssize_t survivability_mode_store(struct config_item *item, const char *pa return ret; guard(mutex)(&dev->lock); + if (is_bound(dev)) + return -EBUSY; + dev->config.survivability_mode = survivability_mode; return len; @@ -249,6 +284,9 @@ static ssize_t engines_allowed_store(struct config_item *item, const char *page, } guard(mutex)(&dev->lock); + if (is_bound(dev)) + return -EBUSY; + dev->config.engines_allowed = val; return len; @@ -272,6 +310,9 @@ static ssize_t enable_psmi_store(struct config_item *item, const char *page, siz return ret; guard(mutex)(&dev->lock); + if (is_bound(dev)) + return -EBUSY; + dev->config.enable_psmi = val; return len; -- 2.50.1