Skip to content

Commit

Permalink
Merge branch 'torvalds:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
offsoc authored Aug 11, 2024
2 parents 5a57950 + 5189daf commit 4682fa8
Show file tree
Hide file tree
Showing 19 changed files with 196 additions and 43 deletions.
5 changes: 4 additions & 1 deletion drivers/i2c/busses/i2c-qcom-geni.c
Original file line number Diff line number Diff line change
Expand Up @@ -990,8 +990,11 @@ static int __maybe_unused geni_i2c_runtime_resume(struct device *dev)
return ret;

ret = geni_se_resources_on(&gi2c->se);
if (ret)
if (ret) {
clk_disable_unprepare(gi2c->core_clk);
geni_icc_disable(&gi2c->se);
return ret;
}

enable_irq(gi2c->irq);
gi2c->suspended = 0;
Expand Down
4 changes: 2 additions & 2 deletions drivers/i2c/i2c-slave-testunit.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

enum testunit_cmds {
TU_CMD_READ_BYTES = 1, /* save 0 for ABORT, RESET or similar */
TU_CMD_HOST_NOTIFY,
TU_CMD_SMBUS_HOST_NOTIFY,
TU_CMD_SMBUS_BLOCK_PROC_CALL,
TU_NUM_CMDS
};
Expand Down Expand Up @@ -60,7 +60,7 @@ static void i2c_slave_testunit_work(struct work_struct *work)
msg.len = tu->regs[TU_REG_DATAH];
break;

case TU_CMD_HOST_NOTIFY:
case TU_CMD_SMBUS_HOST_NOTIFY:
msg.addr = 0x08;
msg.flags = 0;
msg.len = 3;
Expand Down
64 changes: 57 additions & 7 deletions drivers/i2c/i2c-smbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ static int smbus_do_alert(struct device *dev, void *addrp)
struct i2c_client *client = i2c_verify_client(dev);
struct alert_data *data = addrp;
struct i2c_driver *driver;
int ret;

if (!client || client->addr != data->addr)
return 0;
Expand All @@ -47,16 +48,47 @@ static int smbus_do_alert(struct device *dev, void *addrp)
device_lock(dev);
if (client->dev.driver) {
driver = to_i2c_driver(client->dev.driver);
if (driver->alert)
if (driver->alert) {
/* Stop iterating after we find the device */
driver->alert(client, data->type, data->data);
else
ret = -EBUSY;
} else {
dev_warn(&client->dev, "no driver alert()!\n");
} else
ret = -EOPNOTSUPP;
}
} else {
dev_dbg(&client->dev, "alert with no driver\n");
ret = -ENODEV;
}
device_unlock(dev);

return ret;
}

/* Same as above, but call back all drivers with alert handler */

static int smbus_do_alert_force(struct device *dev, void *addrp)
{
struct i2c_client *client = i2c_verify_client(dev);
struct alert_data *data = addrp;
struct i2c_driver *driver;

if (!client || (client->flags & I2C_CLIENT_TEN))
return 0;

/*
* Drivers should either disable alerts, or provide at least
* a minimal handler. Lock so the driver won't change.
*/
device_lock(dev);
if (client->dev.driver) {
driver = to_i2c_driver(client->dev.driver);
if (driver->alert)
driver->alert(client, data->type, data->data);
}
device_unlock(dev);

/* Stop iterating after we find the device */
return -EBUSY;
return 0;
}

/*
Expand All @@ -67,6 +99,7 @@ static irqreturn_t smbus_alert(int irq, void *d)
{
struct i2c_smbus_alert *alert = d;
struct i2c_client *ara;
unsigned short prev_addr = I2C_CLIENT_END; /* Not a valid address */

ara = alert->ara;

Expand Down Expand Up @@ -94,8 +127,25 @@ static irqreturn_t smbus_alert(int irq, void *d)
data.addr, data.data);

/* Notify driver for the device which issued the alert */
device_for_each_child(&ara->adapter->dev, &data,
smbus_do_alert);
status = device_for_each_child(&ara->adapter->dev, &data,
smbus_do_alert);
/*
* If we read the same address more than once, and the alert
* was not handled by a driver, it won't do any good to repeat
* the loop because it will never terminate. Try again, this
* time calling the alert handlers of all devices connected to
* the bus, and abort the loop afterwards. If this helps, we
* are all set. If it doesn't, there is nothing else we can do,
* so we might as well abort the loop.
* Note: This assumes that a driver with alert handler handles
* the alert properly and clears it if necessary.
*/
if (data.addr == prev_addr && status != -EBUSY) {
device_for_each_child(&ara->adapter->dev, &data,
smbus_do_alert_force);
break;
}
prev_addr = data.addr;
}

return IRQ_HANDLED;
Expand Down
11 changes: 7 additions & 4 deletions fs/bcachefs/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,16 +272,19 @@ bch2_acl_to_xattr(struct btree_trans *trans,
return xattr;
}

struct posix_acl *bch2_get_acl(struct mnt_idmap *idmap,
struct dentry *dentry, int type)
struct posix_acl *bch2_get_acl(struct inode *vinode, int type, bool rcu)
{
struct bch_inode_info *inode = to_bch_ei(dentry->d_inode);
struct bch_inode_info *inode = to_bch_ei(vinode);
struct bch_fs *c = inode->v.i_sb->s_fs_info;
struct bch_hash_info hash = bch2_hash_info_init(c, &inode->ei_inode);
struct xattr_search_key search = X_SEARCH(acl_to_xattr_type(type), "", 0);
struct btree_trans *trans = bch2_trans_get(c);
struct btree_iter iter = { NULL };
struct posix_acl *acl = NULL;

if (rcu)
return ERR_PTR(-ECHILD);

struct btree_trans *trans = bch2_trans_get(c);
retry:
bch2_trans_begin(trans);

Expand Down
2 changes: 1 addition & 1 deletion fs/bcachefs/acl.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void bch2_acl_to_text(struct printbuf *, const void *, size_t);

#ifdef CONFIG_BCACHEFS_POSIX_ACL

struct posix_acl *bch2_get_acl(struct mnt_idmap *, struct dentry *, int);
struct posix_acl *bch2_get_acl(struct inode *, int, bool);

int bch2_set_acl_trans(struct btree_trans *, subvol_inum,
struct bch_inode_unpacked *,
Expand Down
2 changes: 1 addition & 1 deletion fs/bcachefs/alloc_foreground.c
Original file line number Diff line number Diff line change
Expand Up @@ -1740,7 +1740,7 @@ void bch2_dev_alloc_debug_to_text(struct printbuf *out, struct bch_dev *ca)
printbuf_tabstop_push(out, 16);
printbuf_tabstop_push(out, 16);

bch2_dev_usage_to_text(out, &stats);
bch2_dev_usage_to_text(out, ca, &stats);

prt_newline(out);

Expand Down
3 changes: 2 additions & 1 deletion fs/bcachefs/bcachefs_format.h
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,8 @@ struct bch_sb_field_ext {
x(btree_subvolume_children, BCH_VERSION(1, 6)) \
x(mi_btree_bitmap, BCH_VERSION(1, 7)) \
x(bucket_stripe_sectors, BCH_VERSION(1, 8)) \
x(disk_accounting_v2, BCH_VERSION(1, 9))
x(disk_accounting_v2, BCH_VERSION(1, 9)) \
x(disk_accounting_v3, BCH_VERSION(1, 10))

enum bcachefs_metadata_version {
bcachefs_metadata_version_min = 9,
Expand Down
12 changes: 8 additions & 4 deletions fs/bcachefs/buckets.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,21 @@ bch2_fs_usage_read_short(struct bch_fs *c)
return ret;
}

void bch2_dev_usage_to_text(struct printbuf *out, struct bch_dev_usage *usage)
void bch2_dev_usage_to_text(struct printbuf *out,
struct bch_dev *ca,
struct bch_dev_usage *usage)
{
prt_printf(out, "\tbuckets\rsectors\rfragmented\r\n");

for (unsigned i = 0; i < BCH_DATA_NR; i++) {
bch2_prt_data_type(out, i);
prt_printf(out, "\t%llu\r%llu\r%llu\r\n",
usage->d[i].buckets,
usage->d[i].sectors,
usage->d[i].fragmented);
usage->d[i].buckets,
usage->d[i].sectors,
usage->d[i].fragmented);
}

prt_printf(out, "capacity\t%llu\r\n", ca->mi.nbuckets);
}

static int bch2_check_fix_ptr(struct btree_trans *trans,
Expand Down
2 changes: 1 addition & 1 deletion fs/bcachefs/buckets.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ static inline struct bch_dev_usage bch2_dev_usage_read(struct bch_dev *ca)
return ret;
}

void bch2_dev_usage_to_text(struct printbuf *, struct bch_dev_usage *);
void bch2_dev_usage_to_text(struct printbuf *, struct bch_dev *, struct bch_dev_usage *);

static inline u64 bch2_dev_buckets_reserved(struct bch_dev *ca, enum bch_watermark watermark)
{
Expand Down
65 changes: 64 additions & 1 deletion fs/bcachefs/disk_accounting.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,74 @@ int bch2_mod_dev_cached_sectors(struct btree_trans *trans,
return bch2_disk_accounting_mod(trans, &acc, &sectors, 1, gc);
}

static inline bool is_zero(char *start, char *end)
{
BUG_ON(start > end);

for (; start < end; start++)
if (*start)
return false;
return true;
}

#define field_end(p, member) (((void *) (&p.member)) + sizeof(p.member))

int bch2_accounting_invalid(struct bch_fs *c, struct bkey_s_c k,
enum bch_validate_flags flags,
struct printbuf *err)
{
return 0;
struct disk_accounting_pos acc_k;
bpos_to_disk_accounting_pos(&acc_k, k.k->p);
void *end = &acc_k + 1;
int ret = 0;

switch (acc_k.type) {
case BCH_DISK_ACCOUNTING_nr_inodes:
end = field_end(acc_k, nr_inodes);
break;
case BCH_DISK_ACCOUNTING_persistent_reserved:
end = field_end(acc_k, persistent_reserved);
break;
case BCH_DISK_ACCOUNTING_replicas:
bkey_fsck_err_on(!acc_k.replicas.nr_devs,
c, err, accounting_key_replicas_nr_devs_0,
"accounting key replicas entry with nr_devs=0");

bkey_fsck_err_on(acc_k.replicas.nr_required > acc_k.replicas.nr_devs ||
(acc_k.replicas.nr_required > 1 &&
acc_k.replicas.nr_required == acc_k.replicas.nr_devs),
c, err, accounting_key_replicas_nr_required_bad,
"accounting key replicas entry with bad nr_required");

for (unsigned i = 0; i + 1 < acc_k.replicas.nr_devs; i++)
bkey_fsck_err_on(acc_k.replicas.devs[i] > acc_k.replicas.devs[i + 1],
c, err, accounting_key_replicas_devs_unsorted,
"accounting key replicas entry with unsorted devs");

end = (void *) &acc_k.replicas + replicas_entry_bytes(&acc_k.replicas);
break;
case BCH_DISK_ACCOUNTING_dev_data_type:
end = field_end(acc_k, dev_data_type);
break;
case BCH_DISK_ACCOUNTING_compression:
end = field_end(acc_k, compression);
break;
case BCH_DISK_ACCOUNTING_snapshot:
end = field_end(acc_k, snapshot);
break;
case BCH_DISK_ACCOUNTING_btree:
end = field_end(acc_k, btree);
break;
case BCH_DISK_ACCOUNTING_rebalance_work:
end = field_end(acc_k, rebalance_work);
break;
}

bkey_fsck_err_on(!is_zero(end, (void *) (&acc_k + 1)),
c, err, accounting_key_junk_at_end,
"junk at end of accounting key");
fsck_err:
return ret;
}

void bch2_accounting_key_to_text(struct printbuf *out, struct disk_accounting_pos *k)
Expand Down
15 changes: 7 additions & 8 deletions fs/bcachefs/disk_accounting_format.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,19 @@ struct bch_dev_data_type {
__u8 data_type;
};

struct bch_dev_stripe_buckets {
__u8 dev;
};

struct bch_acct_compression {
__u8 type;
};

struct bch_acct_snapshot {
__u32 id;
};
} __packed;

struct bch_acct_btree {
__u32 id;
} __packed;

struct bch_acct_rebalance_work {
};

struct disk_accounting_pos {
Expand All @@ -149,12 +148,12 @@ struct disk_accounting_pos {
struct bch_persistent_reserved persistent_reserved;
struct bch_replicas_entry_v1 replicas;
struct bch_dev_data_type dev_data_type;
struct bch_dev_stripe_buckets dev_stripe_buckets;
struct bch_acct_compression compression;
struct bch_acct_snapshot snapshot;
struct bch_acct_btree btree;
};
};
struct bch_acct_rebalance_work rebalance_work;
} __packed;
} __packed;
struct bpos _pad;
};
};
Expand Down
8 changes: 4 additions & 4 deletions fs/bcachefs/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ static const struct inode_operations bch_file_inode_operations = {
.fiemap = bch2_fiemap,
.listxattr = bch2_xattr_list,
#ifdef CONFIG_BCACHEFS_POSIX_ACL
.get_acl = bch2_get_acl,
.get_inode_acl = bch2_get_acl,
.set_acl = bch2_set_acl,
#endif
};
Expand All @@ -1219,7 +1219,7 @@ static const struct inode_operations bch_dir_inode_operations = {
.tmpfile = bch2_tmpfile,
.listxattr = bch2_xattr_list,
#ifdef CONFIG_BCACHEFS_POSIX_ACL
.get_acl = bch2_get_acl,
.get_inode_acl = bch2_get_acl,
.set_acl = bch2_set_acl,
#endif
};
Expand All @@ -1241,7 +1241,7 @@ static const struct inode_operations bch_symlink_inode_operations = {
.setattr = bch2_setattr,
.listxattr = bch2_xattr_list,
#ifdef CONFIG_BCACHEFS_POSIX_ACL
.get_acl = bch2_get_acl,
.get_inode_acl = bch2_get_acl,
.set_acl = bch2_set_acl,
#endif
};
Expand All @@ -1251,7 +1251,7 @@ static const struct inode_operations bch_special_inode_operations = {
.setattr = bch2_setattr,
.listxattr = bch2_xattr_list,
#ifdef CONFIG_BCACHEFS_POSIX_ACL
.get_acl = bch2_get_acl,
.get_inode_acl = bch2_get_acl,
.set_acl = bch2_set_acl,
#endif
};
Expand Down
1 change: 0 additions & 1 deletion fs/bcachefs/replicas.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ static int bch2_memcmp(const void *l, const void *r, const void *priv)
static void verify_replicas_entry(struct bch_replicas_entry_v1 *e)
{
#ifdef CONFIG_BCACHEFS_DEBUG
BUG_ON(e->data_type >= BCH_DATA_NR);
BUG_ON(!e->nr_devs);
BUG_ON(e->nr_required > 1 &&
e->nr_required >= e->nr_devs);
Expand Down
Loading

0 comments on commit 4682fa8

Please sign in to comment.